From 13c1b11317d0153af235f1f2d15798a9cd942358 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sun, 31 Jan 2021 09:36:02 +0000 Subject: css: hints: Add support for OL type attribute. --- content/handlers/css/hints.c | 47 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/content/handlers/css/hints.c b/content/handlers/css/hints.c index 9748030b7..defeae10a 100644 --- a/content/handlers/css/hints.c +++ b/content/handlers/css/hints.c @@ -1579,6 +1579,50 @@ static void css_hint_white_space_nowrap( } } +static void css_hint_list( + nscss_select_ctx *ctx, + dom_node *node) +{ + struct css_hint *hint = &(hint_ctx.hints[hint_ctx.len]); + dom_exception err; + dom_string *attr; + + err = dom_element_get_attribute(node, corestring_dom_type, &attr); + if (err == DOM_NO_ERR && attr != NULL) { + const char *attr_str = dom_string_data(attr); + size_t attr_len = dom_string_byte_length(attr); + enum css_list_style_type_e type = CSS_LIST_STYLE_TYPE_INHERIT; + + if (attr_len == 1) { + switch (attr_str[0]) { + case 'a': + type = CSS_LIST_STYLE_TYPE_LOWER_ALPHA; + break; + case 'A': + type = CSS_LIST_STYLE_TYPE_UPPER_ALPHA; + break; + case 'i': + type = CSS_LIST_STYLE_TYPE_LOWER_ROMAN; + break; + case 'I': + type = CSS_LIST_STYLE_TYPE_UPPER_ROMAN; + break; + case '1': + type = CSS_LIST_STYLE_TYPE_DECIMAL; + break; + } + } + + if (type != CSS_LIST_STYLE_TYPE_INHERIT) { + hint->prop = CSS_PROP_LIST_STYLE_TYPE; + hint->status = type; + css_hint_advance(&hint); + } + + dom_string_unref(attr); + } +} + /* Exported function, documeted in css/hints.h */ css_error node_presentational_hint(void *pw, void *node, @@ -1671,6 +1715,9 @@ css_error node_presentational_hint(void *pw, void *node, case DOM_HTML_ELEMENT_TYPE_CANVAS: css_hint_height_width_canvas(pw, node); break; + case DOM_HTML_ELEMENT_TYPE_OL: + css_hint_list(pw, node); + break; default: break; } -- cgit v1.2.3