diff options
author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2009-01-17 16:48:27 +0100 |
---|---|---|
committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2009-01-17 16:48:27 +0100 |
commit | 679090b3c7776ee024edce97800c51bd3e59ead2 (patch) | |
tree | 40167319d7a5bc1e46b321613cf1b0ec56940ec2 /src/cssparser.cc | |
parent | 650710395c696eb51fc46a6a7cf4c040db77b2ce (diff) |
implement parsing of CSS data from style attribute
E.g.
<body style="background-color: red; font-family: arial; font-size: 30mm">
Hello World
</body>
Diffstat (limited to 'src/cssparser.cc')
-rw-r--r-- | src/cssparser.cc | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/src/cssparser.cc b/src/cssparser.cc index 5fc10c3c..f11e0a86 100644 --- a/src/cssparser.cc +++ b/src/cssparser.cc @@ -836,7 +836,7 @@ static void Css_parse_declaration(CssParser * parser, Css_next_token(parser); if (Css_parse_value(parser, prop, &val)) { weight = Css_parse_weight(parser); - if (weight) + if (weight && importantProps) importantProps->set(prop, val); else props->set(prop, val); @@ -877,7 +877,7 @@ static void Css_parse_declaration(CssParser * parser, Css_shorthand_info[sh_index] .properties[i], &val)) { weight = Css_parse_weight(parser); - if (weight) + if (weight && importantProps) importantProps-> set(Css_shorthand_info[sh_index]. properties[i], val); @@ -908,7 +908,7 @@ static void Css_parse_declaration(CssParser * parser, weight = Css_parse_weight(parser); if (n > 0) { for (i = 0; i < 4; i++) - if (weight) + if (weight && importantProps) importantProps->set(Css_shorthand_info[sh_index] .properties[i], dir_vals[dir_set[n - 1] @@ -938,7 +938,7 @@ static void Css_parse_declaration(CssParser * parser, .properties[i], &val)) { weight = Css_parse_weight(parser); for (j = 0; j < 4; j++) - if (weight) + if (weight && importantProps) importantProps-> set(Css_shorthand_info[sh_index]. properties[j * 3 + i], val); @@ -1165,3 +1165,29 @@ void a_Css_parse(CssContext * context, while (parser.ttype != CSS_TK_END) Css_parse_ruleset(&parser); } + +CssPropertyList *a_Css_parse_declaration(const char *buf, int buflen) +{ + CssPropertyList *props = new CssPropertyList (); + CssParser parser; + + parser.context = NULL; + parser.buf = buf; + parser.buflen = buflen; + parser.bufptr = 0; + parser.order_count = 0; + parser.origin = CSS_ORIGIN_AUTHOR; + parser.within_block = true; + parser.space_separated = false; + + Css_next_token(&parser); + while (parser.ttype != CSS_TK_END) + Css_parse_declaration(&parser, props, NULL); + + if (props->size () == 0) { + delete props; + props = NULL; + } + + return props; +} |