diff options
author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2009-03-23 10:13:53 +0100 |
---|---|---|
committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2009-03-23 10:13:53 +0100 |
commit | 4140475302ea088e5ad74ebf24c98700cf13b0fa (patch) | |
tree | 35365e517f8273e4f083c761d3ac63acc0bba2cc /src/cssparser.cc | |
parent | 355698bd39492da925860e5331e21f251fc53e4f (diff) |
allow negative values for specific CSS properties only
This needs to be done at parser level, so that alternative settings can
overrule a faulty negative one.
Testcase:
<html>
<head>
<style type="text/css" >
#foo {padding: -1px; background-color: green}
.bar {padding: 10px}
</style>
</head>
<body>
<div id="foo" class="bar">should be green and have 10px padding</div>
</body>
</html>
Diffstat (limited to 'src/cssparser.cc')
-rw-r--r-- | src/cssparser.cc | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/cssparser.cc b/src/cssparser.cc index 830a0475..a924816c 100644 --- a/src/cssparser.cc +++ b/src/cssparser.cc @@ -148,10 +148,10 @@ const CssPropertyInfo Css_property_info[CSS_PROPERTY_LAST] = { {"list-style-image", {CSS_TYPE_UNUSED}, NULL}, {"list-style-position", {CSS_TYPE_UNUSED}, NULL}, {"list-style-type", {CSS_TYPE_ENUM, CSS_TYPE_UNUSED}, Css_list_style_type_enum_vals}, - {"margin-bottom", {CSS_TYPE_LENGTH, CSS_TYPE_UNUSED}, NULL}, - {"margin-left", {CSS_TYPE_LENGTH, CSS_TYPE_UNUSED}, NULL}, - {"margin-right", {CSS_TYPE_LENGTH, CSS_TYPE_UNUSED}, NULL}, - {"margin-top", {CSS_TYPE_LENGTH, CSS_TYPE_UNUSED}, NULL}, + {"margin-bottom", {CSS_TYPE_SIGNED_LENGTH, CSS_TYPE_UNUSED}, NULL}, + {"margin-left", {CSS_TYPE_SIGNED_LENGTH, CSS_TYPE_UNUSED}, NULL}, + {"margin-right", {CSS_TYPE_SIGNED_LENGTH, CSS_TYPE_UNUSED}, NULL}, + {"margin-top", {CSS_TYPE_SIGNED_LENGTH, CSS_TYPE_UNUSED}, NULL}, {"marker-offset", {CSS_TYPE_UNUSED}, NULL}, {"marks", {CSS_TYPE_UNUSED}, NULL}, {"max-height", {CSS_TYPE_UNUSED}, NULL}, @@ -622,6 +622,10 @@ bool CssParser::tokenMatchesProperty(CssPropertyName prop, CssValueType * type) case CSS_TYPE_LENGTH_PERCENTAGE: case CSS_TYPE_LENGTH: + if (tval[0] == '-') + return false; + // Fall Through + case CSS_TYPE_SIGNED_LENGTH: if (ttype == CSS_TK_DECINT || ttype == CSS_TK_FLOAT || (ttype == CSS_TK_SYMBOL && dStrcasecmp(tval, "auto") == 0)) @@ -709,6 +713,7 @@ bool CssParser::parseValue(CssPropertyName prop, case CSS_TYPE_LENGTH_PERCENTAGE: case CSS_TYPE_LENGTH: + case CSS_TYPE_SIGNED_LENGTH: if (ttype == CSS_TK_DECINT || ttype == CSS_TK_FLOAT) { fval = atof(tval); lentype = CSS_LENGTH_TYPE_PX; /* Actually, there must be a unit, |