NetSurf
|
#include <string.h>
#include <strings.h>
#include "utils/nsoption.h"
#include "utils/corestrings.h"
#include "utils/log.h"
#include "utils/nsurl.h"
#include "utils/utils.h"
#include "css/hints.h"
#include "css/select.h"
Go to the source code of this file.
Data Structures | |
struct | colour_map |
Mapping of colour name to CSS color. More... | |
struct | css_hint_ctx |
Macros | |
#define | LOG_STATS |
#define | MAX_HINTS_PER_ELEMENT 32 |
Functions | |
static bool | isWhitespace (char c) |
Determine if a given character is whitespace. More... | |
static bool | isHex (char c) |
Determine if a given character is a valid hex digit. More... | |
static uint8_t | charToHex (char c) |
Convert a character representing a hex digit to the corresponding hex value. More... | |
static bool | parse_number (const char *data, bool maybe_negative, bool real, css_fixed *value, size_t *consumed) |
Parse a number string. More... | |
static bool | parse_dimension (const char *data, bool strict, css_fixed *length, css_unit *unit) |
Parse a dimension string. More... | |
static int | cmp_colour_name (const void *a, const void *b) |
Name comparator for named colour matching. More... | |
static bool | parse_named_colour (const char *name, css_color *result) |
Parse a named colour. More... | |
bool | nscss_parse_colour (const char *data, css_color *result) |
Parser for colours specified in attribute values. More... | |
static bool | parse_font_size (const char *size, uint8_t *val, css_fixed *len, css_unit *unit) |
Parse a font @size attribute. More... | |
nserror | css_hint_init (void) |
void | css_hint_fini (void) |
static void | css_hint_clean (void) |
static void | css_hint_advance (struct css_hint **hint) |
static void | css_hint_get_hints (struct css_hint **hints, uint32_t *nhints) |
static void | css_hint_table_cell_border_padding (nscss_select_ctx *ctx, dom_node *node) |
static void | css_hint_vertical_align_table_cells (nscss_select_ctx *ctx, dom_node *node) |
static void | css_hint_vertical_align_replaced (nscss_select_ctx *ctx, dom_node *node) |
static void | css_hint_text_align_normal (nscss_select_ctx *ctx, dom_node *node) |
static void | css_hint_text_align_center (nscss_select_ctx *ctx, dom_node *node) |
static void | css_hint_margin_left_right_align_center (nscss_select_ctx *ctx, dom_node *node) |
static void | css_hint_text_align_special (nscss_select_ctx *ctx, dom_node *node) |
static void | css_hint_text_align_table_special (nscss_select_ctx *ctx, dom_node *node) |
static void | css_hint_margin_hspace_vspace (nscss_select_ctx *ctx, dom_node *node) |
static void | css_hint_margin_left_right_hr (nscss_select_ctx *ctx, dom_node *node) |
static void | css_hint_table_spacing_border (nscss_select_ctx *ctx, dom_node *node) |
static void | css_hint_height (nscss_select_ctx *ctx, dom_node *node) |
static void | css_hint_width (nscss_select_ctx *ctx, dom_node *node) |
static void | css_hint_height_width_textarea (nscss_select_ctx *ctx, dom_node *node) |
static void | css_hint_height_width_canvas (nscss_select_ctx *ctx, dom_node *node) |
static void | css_hint_width_input (nscss_select_ctx *ctx, dom_node *node) |
static void | css_hint_anchor_color (nscss_select_ctx *ctx, dom_node *node) |
static void | css_hint_body_color (nscss_select_ctx *ctx, dom_node *node) |
static void | css_hint_color (nscss_select_ctx *ctx, dom_node *node) |
static void | css_hint_font_size (nscss_select_ctx *ctx, dom_node *node) |
static void | css_hint_float (nscss_select_ctx *ctx, dom_node *node) |
static void | css_hint_caption_side (nscss_select_ctx *ctx, dom_node *node) |
static void | css_hint_bg_color (nscss_select_ctx *ctx, dom_node *node) |
static void | css_hint_bg_image (nscss_select_ctx *ctx, dom_node *node) |
static void | css_hint_white_space_nowrap (nscss_select_ctx *ctx, dom_node *node) |
static void | css_hint_list (nscss_select_ctx *ctx, dom_node *node) |
css_error | node_presentational_hint (void *pw, void *node, uint32_t *nhints, css_hint **hints) |
Callback to retrieve presentational hints for a node. More... | |
Variables | |
struct css_hint_ctx | hint_ctx |
|
static |
Convert a character representing a hex digit to the corresponding hex value.
c | Character to convert |
Definition at line 69 of file hints.c.
Referenced by nscss_parse_colour().
|
static |
Name comparator for named colour matching.
a | Name to match |
b | Colour map entry to consider |
Definition at line 266 of file hints.c.
References colour_map::name.
Referenced by parse_named_colour().
|
inlinestatic |
Definition at line 610 of file hints.c.
References hint_ctx, css_hint_ctx::len, and MAX_HINTS_PER_ELEMENT.
Referenced by css_hint_anchor_color(), css_hint_bg_color(), css_hint_bg_image(), css_hint_body_color(), css_hint_caption_side(), css_hint_color(), css_hint_float(), css_hint_font_size(), css_hint_height(), css_hint_height_width_canvas(), css_hint_height_width_textarea(), css_hint_list(), css_hint_margin_hspace_vspace(), css_hint_margin_left_right_align_center(), css_hint_margin_left_right_hr(), css_hint_table_cell_border_padding(), css_hint_table_spacing_border(), css_hint_text_align_center(), css_hint_text_align_normal(), css_hint_text_align_special(), css_hint_text_align_table_special(), css_hint_vertical_align_replaced(), css_hint_vertical_align_table_cells(), css_hint_white_space_nowrap(), css_hint_width(), and css_hint_width_input().
|
static |
Definition at line 1348 of file hints.c.
References css_hint_advance(), hint_ctx, css_hint_ctx::hints, css_hint_ctx::len, named_ancestor_node(), node_is_visited(), and nscss_parse_colour().
Referenced by node_presentational_hint().
|
static |
Definition at line 1512 of file hints.c.
References css_hint_advance(), hint_ctx, css_hint_ctx::hints, css_hint_ctx::len, and nscss_parse_colour().
Referenced by node_presentational_hint().
|
static |
Definition at line 1534 of file hints.c.
References nscss_select_ctx::base_url, css_hint_advance(), hint_ctx, css_hint_ctx::hints, css_hint_ctx::len, NSERROR_OK, nsurl_access(), nsurl_join(), nsurl_length(), and nsurl_unref().
Referenced by node_presentational_hint().
|
static |
Definition at line 1400 of file hints.c.
References css_hint_advance(), hint_ctx, css_hint_ctx::hints, css_hint_ctx::len, and nscss_parse_colour().
Referenced by node_presentational_hint().
|
static |
Definition at line 1492 of file hints.c.
References css_hint_advance(), hint_ctx, css_hint_ctx::hints, and css_hint_ctx::len.
Referenced by node_presentational_hint().
|
static |
Definition at line 605 of file hints.c.
References hint_ctx, and css_hint_ctx::len.
Referenced by node_presentational_hint().
|
static |
Definition at line 1422 of file hints.c.
References css_hint_advance(), hint_ctx, css_hint_ctx::hints, css_hint_ctx::len, and nscss_parse_colour().
Referenced by node_presentational_hint().
void css_hint_fini | ( | void | ) |
Definition at line 599 of file hints.c.
References hint_ctx, css_hint_ctx::hints, and css_hint_ctx::len.
Referenced by nscss_fini().
|
static |
Definition at line 1466 of file hints.c.
References css_hint_advance(), hint_ctx, css_hint_ctx::hints, and css_hint_ctx::len.
Referenced by node_presentational_hint().
|
static |
Definition at line 1444 of file hints.c.
References css_hint_advance(), hint_ctx, css_hint_ctx::hints, css_hint_ctx::len, and parse_font_size().
Referenced by node_presentational_hint().
|
static |
Definition at line 618 of file hints.c.
References hint_ctx, css_hint_ctx::hints, and css_hint_ctx::len.
Referenced by node_presentational_hint().
|
static |
Definition at line 1147 of file hints.c.
References css_hint_advance(), hint_ctx, css_hint_ctx::hints, css_hint_ctx::len, and parse_dimension().
Referenced by node_presentational_hint().
|
static |
Definition at line 1236 of file hints.c.
References css_hint_advance(), hint_ctx, css_hint_ctx::hints, css_hint_ctx::len, and parse_dimension().
Referenced by node_presentational_hint().
|
static |
Definition at line 1195 of file hints.c.
References css_hint_advance(), hint_ctx, css_hint_ctx::hints, css_hint_ctx::len, and parse_dimension().
Referenced by node_presentational_hint().
nserror css_hint_init | ( | void | ) |
Definition at line 588 of file hints.c.
References hint_ctx, css_hint_ctx::hints, MAX_HINTS_PER_ELEMENT, NSERROR_NOMEM, and NSERROR_OK.
Referenced by nscss_init().
|
static |
Definition at line 1582 of file hints.c.
References css_hint_advance(), hint_ctx, css_hint_ctx::hints, css_hint_ctx::len, and type.
Referenced by node_presentational_hint().
|
static |
Definition at line 959 of file hints.c.
References css_hint_advance(), hint_ctx, css_hint_ctx::hints, css_hint_ctx::len, and parse_dimension().
Referenced by node_presentational_hint().
|
static |
Definition at line 875 of file hints.c.
References css_hint_advance(), hint_ctx, css_hint_ctx::hints, and css_hint_ctx::len.
Referenced by node_presentational_hint().
|
static |
Definition at line 1016 of file hints.c.
References css_hint_advance(), hint_ctx, css_hint_ctx::hints, and css_hint_ctx::len.
Referenced by node_presentational_hint().
|
static |
Definition at line 629 of file hints.c.
References css_hint_advance(), hint_ctx, css_hint_ctx::hints, css_hint_ctx::len, named_ancestor_node(), nscss_parse_colour(), and parse_dimension().
Referenced by node_presentational_hint().
|
static |
Definition at line 1067 of file hints.c.
References css_hint_advance(), hint_ctx, css_hint_ctx::hints, css_hint_ctx::len, nscss_parse_colour(), and parse_dimension().
Referenced by node_presentational_hint().
|
static |
Definition at line 864 of file hints.c.
References css_hint_advance(), hint_ctx, css_hint_ctx::hints, and css_hint_ctx::len.
Referenced by node_presentational_hint().
|
static |
Definition at line 825 of file hints.c.
References css_hint_advance(), hint_ctx, css_hint_ctx::hints, and css_hint_ctx::len.
Referenced by node_presentational_hint().
|
static |
Definition at line 908 of file hints.c.
References css_hint_advance(), hint_ctx, css_hint_ctx::hints, and css_hint_ctx::len.
Referenced by node_presentational_hint().
|
static |
Definition at line 948 of file hints.c.
References css_hint_advance(), hint_ctx, css_hint_ctx::hints, and css_hint_ctx::len.
Referenced by node_presentational_hint().
|
static |
Definition at line 781 of file hints.c.
References css_hint_advance(), hint_ctx, css_hint_ctx::hints, and css_hint_ctx::len.
Referenced by node_presentational_hint().
|
static |
Definition at line 739 of file hints.c.
References css_hint_advance(), hint_ctx, css_hint_ctx::hints, and css_hint_ctx::len.
Referenced by node_presentational_hint().
|
static |
Definition at line 1566 of file hints.c.
References css_hint_advance(), hint_ctx, css_hint_ctx::hints, and css_hint_ctx::len.
Referenced by node_presentational_hint().
|
static |
Definition at line 1171 of file hints.c.
References css_hint_advance(), hint_ctx, css_hint_ctx::hints, css_hint_ctx::len, and parse_dimension().
Referenced by node_presentational_hint().
|
static |
Definition at line 1298 of file hints.c.
References css_hint_advance(), hint_ctx, css_hint_ctx::hints, css_hint_ctx::len, and parse_dimension().
Referenced by node_presentational_hint().
|
static |
Determine if a given character is a valid hex digit.
c | Character to consider |
Definition at line 55 of file hints.c.
Referenced by nscss_parse_colour().
|
static |
Determine if a given character is whitespace.
c | Character to consider |
Definition at line 44 of file hints.c.
Referenced by parse_font_size(), and parse_number().
css_error node_presentational_hint | ( | void * | pw, |
void * | node, | ||
uint32_t * | nhints, | ||
css_hint ** | hints | ||
) |
Callback to retrieve presentational hints for a node.
[in] | pw | HTML document |
[in] | node | DOM node |
[out] | nhints | number of hints retrieved |
[out] | hints | retrieved hints |
Definition at line 1628 of file hints.c.
References css_hint_anchor_color(), css_hint_bg_color(), css_hint_bg_image(), css_hint_body_color(), css_hint_caption_side(), css_hint_clean(), css_hint_color(), css_hint_float(), css_hint_font_size(), css_hint_get_hints(), css_hint_height(), css_hint_height_width_canvas(), css_hint_height_width_textarea(), css_hint_list(), css_hint_margin_hspace_vspace(), css_hint_margin_left_right_align_center(), css_hint_margin_left_right_hr(), css_hint_table_cell_border_padding(), css_hint_table_spacing_border(), css_hint_text_align_center(), css_hint_text_align_normal(), css_hint_text_align_special(), css_hint_text_align_table_special(), css_hint_vertical_align_replaced(), css_hint_vertical_align_table_cells(), css_hint_white_space_nowrap(), css_hint_width(), css_hint_width_input(), fallthrough, hint_ctx, css_hint_ctx::len, NSLOG, and nsoption_bool.
bool nscss_parse_colour | ( | const char * | data, |
css_color * | result | ||
) |
Parser for colours specified in attribute values.
data | Data to parse (NUL-terminated) |
result | Pointer to location to receive resulting css_color |
Definition at line 449 of file hints.c.
References charToHex(), isHex(), parse_named_colour(), result, and SLEN.
Referenced by box_create_frameset(), box_iframe(), css_hint_anchor_color(), css_hint_bg_color(), css_hint_body_color(), css_hint_color(), css_hint_table_cell_border_padding(), and css_hint_table_spacing_border().
|
static |
Parse a dimension string.
data | Data to parse (NUL-terminated) |
strict | Whether to enforce strict parsing rules |
length | Pointer to location to receive dimension's length |
unit | Pointer to location to receive dimension's unit |
Definition at line 224 of file hints.c.
References parse_number().
Referenced by css_hint_height(), css_hint_height_width_canvas(), css_hint_height_width_textarea(), css_hint_margin_hspace_vspace(), css_hint_table_cell_border_padding(), css_hint_table_spacing_border(), css_hint_width(), and css_hint_width_input().
|
static |
Parse a font @size attribute.
size | Data to parse (NUL-terminated) |
val | Pointer to location to receive enum value |
len | Pointer to location to receive length |
unit | Pointer to location to receive unit |
Definition at line 509 of file hints.c.
References isWhitespace(), mode, and nsoption_int.
Referenced by css_hint_font_size().
|
static |
Parse a named colour.
name | Name to parse |
result | Pointer to location to receive css_color |
Definition at line 281 of file hints.c.
References cmp_colour_name(), colour_map::color, colour_map::name, and result.
Referenced by nscss_parse_colour().
|
static |
Parse a number string.
data | Data to parse (NUL-terminated) |
maybe_negative | Negative numbers permitted |
real | Floating point numbers permitted |
value | Pointer to location to receive numeric value |
consumed | Pointer to location to receive number of input bytes consumed |
Definition at line 101 of file hints.c.
References isWhitespace().
Referenced by parse_dimension().
struct css_hint_ctx hint_ctx |
Definition at line 586 of file hints.c.
Referenced by css_hint_advance(), css_hint_anchor_color(), css_hint_bg_color(), css_hint_bg_image(), css_hint_body_color(), css_hint_caption_side(), css_hint_clean(), css_hint_color(), css_hint_fini(), css_hint_float(), css_hint_font_size(), css_hint_get_hints(), css_hint_height(), css_hint_height_width_canvas(), css_hint_height_width_textarea(), css_hint_init(), css_hint_list(), css_hint_margin_hspace_vspace(), css_hint_margin_left_right_align_center(), css_hint_margin_left_right_hr(), css_hint_table_cell_border_padding(), css_hint_table_spacing_border(), css_hint_text_align_center(), css_hint_text_align_normal(), css_hint_text_align_special(), css_hint_text_align_table_special(), css_hint_vertical_align_replaced(), css_hint_vertical_align_table_cells(), css_hint_white_space_nowrap(), css_hint_width(), css_hint_width_input(), and node_presentational_hint().