aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2013-11-30 22:23:20 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2013-11-30 22:23:20 +0100
commit2a2a8ce66691f1ba310298945527d56fbd813ff8 (patch)
tree06fb3a4b712302a9c5f21e24eeff4821c1a4e868 /src
parentaa1f70a72b20e6003761c44056698d50ca6629c6 (diff)
accept 'auto' only for CSS properties that allow it
Instead of handling the 'auto' value implicitly for all CSS properties that accept lenght types, we now accept it only for specific properties where 'auto' is valid according to CSS 2.1. This fixes an assertion with the following HTML fragment: <div style="background:auto">hello</div>
Diffstat (limited to 'src')
-rw-r--r--src/css.hh2
-rw-r--r--src/cssparser.cc24
2 files changed, 17 insertions, 9 deletions
diff --git a/src/css.hh b/src/css.hh
index 29f0b24a..a7143c27 100644
--- a/src/css.hh
+++ b/src/css.hh
@@ -37,6 +37,8 @@ typedef enum {
'margin-*-width'). */
CSS_TYPE_SIGNED_LENGTH, /* As CSS_TYPE_LENGTH but may be negative. */
CSS_TYPE_LENGTH_PERCENTAGE_NUMBER, /* <length> or <percentage>, or <number> */
+ CSS_TYPE_AUTO, /* Represented as CssLength of type
+ CSS_LENGTH_TYPE_AUTO */
CSS_TYPE_COLOR, /* Represented as integer. */
CSS_TYPE_FONT_WEIGHT, /* this very special and only used by
'font-weight' */
diff --git a/src/cssparser.cc b/src/cssparser.cc
index e31c4090..ef18ebbc 100644
--- a/src/cssparser.cc
+++ b/src/cssparser.cc
@@ -205,7 +205,7 @@ const CssPropertyInfo Css_property_info[CSS_PROPERTY_LAST] = {
Css_font_variant_enum_vals},
{"font-weight", {CSS_TYPE_ENUM, CSS_TYPE_FONT_WEIGHT, CSS_TYPE_UNUSED},
Css_font_weight_enum_vals},
- {"height", {CSS_TYPE_LENGTH_PERCENTAGE, CSS_TYPE_UNUSED}, NULL},
+ {"height", {CSS_TYPE_LENGTH_PERCENTAGE, CSS_TYPE_AUTO, CSS_TYPE_UNUSED}, NULL},
{"left", {CSS_TYPE_UNUSED}, NULL},
{"letter-spacing", {CSS_TYPE_ENUM, CSS_TYPE_SIGNED_LENGTH, CSS_TYPE_UNUSED},
Css_letter_spacing_enum_vals},
@@ -250,7 +250,7 @@ const CssPropertyInfo Css_property_info[CSS_PROPERTY_LAST] = {
{"vertical-align",{CSS_TYPE_ENUM, CSS_TYPE_UNUSED},Css_vertical_align_vals},
{"visibility", {CSS_TYPE_UNUSED}, NULL},
{"white-space", {CSS_TYPE_ENUM, CSS_TYPE_UNUSED}, Css_white_space_vals},
- {"width", {CSS_TYPE_LENGTH_PERCENTAGE, CSS_TYPE_UNUSED}, NULL},
+ {"width", {CSS_TYPE_LENGTH_PERCENTAGE, CSS_TYPE_AUTO, CSS_TYPE_UNUSED}, NULL},
{"word-spacing", {CSS_TYPE_ENUM, CSS_TYPE_SIGNED_LENGTH, CSS_TYPE_UNUSED},
Css_word_spacing_enum_vals},
{"z-index", {CSS_TYPE_UNUSED}, NULL},
@@ -721,9 +721,12 @@ bool CssParser::tokenMatchesProperty(CssPropertyName prop, CssValueType *type)
return false;
// Fall Through
case CSS_TYPE_SIGNED_LENGTH:
- if (ttype == CSS_TK_DECINT ||
- ttype == CSS_TK_FLOAT ||
- (ttype == CSS_TK_SYMBOL && dStrAsciiCasecmp(tval, "auto") == 0))
+ if (ttype == CSS_TK_DECINT || ttype == CSS_TK_FLOAT)
+ return true;
+ break;
+
+ case CSS_TYPE_AUTO:
+ if (ttype == CSS_TK_SYMBOL && dStrAsciiCasecmp(tval, "auto") == 0)
return true;
break;
@@ -953,13 +956,16 @@ bool CssParser::parseValue(CssPropertyName prop,
ret = true;
val->intVal = CSS_CREATE_LENGTH(fval, lentype);
- } else if (ttype == CSS_TK_SYMBOL && !dStrAsciiCasecmp(tval, "auto")) {
- ret = true;
- val->intVal = CSS_LENGTH_TYPE_AUTO;
- nextToken();
}
break;
+ case CSS_TYPE_AUTO:
+ assert (ttype == CSS_TK_SYMBOL && !dStrAsciiCasecmp(tval, "auto"));
+ ret = true;
+ val->intVal = CSS_LENGTH_TYPE_AUTO;
+ nextToken();
+ break;
+
case CSS_TYPE_COLOR:
if (ttype == CSS_TK_COLOR) {
val->intVal = a_Color_parse(tval, -1, &err);