Reviewed by Darin, landed by ap.
Fix for http://bugzilla.opendarwin.org/show_bug.cgi?id=8132
CSS parser sometimes accepts real number as integer
Add a boolean variable per css value to catch whether values
are specified as floats or integers.
Test: fast/css/rgb-float.html
* css/CSSGrammar.y:
* css/cssparser.cpp:
(WebCore::CSSParser::validUnit):
(WebCore::CSSParser::lex):
* css/cssparser.h:
* css/tokenizer.flex:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@14352
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2006-05-13 Rob Buis <buis@kde.org>
+
+ Reviewed by Darin, landed by ap.
+
+ - test for http://bugzilla.opendarwin.org/show_bug.cgi?id=8132
+ CSS parser sometimes accepts real number as integer
+
+ * fast/css/rgb-float.html: Added.
+ * fast/css/rgb-float-expected.txt: Added.
+ * fast/css/rgb-float-expected.png: Added.
+ * fast/css/rgb-float-expected.checksum: Added.
+
2006-05-13 Sam Weinig <sam.weinig@gmail.com>
Reviewed by Hyatt, landed by ap.
--- /dev/null
+42e883abb1ec53dfb3c9ef467f7abcc4
\ No newline at end of file
--- /dev/null
+layer at (0,0) size 800x600
+ RenderCanvas at (0,0) size 800x600
+layer at (0,0) size 800x137
+ RenderBlock {HTML} at (0,0) size 800x137
+ RenderBody {BODY} at (8,21) size 784x95 [color=#008000]
+ RenderBlock {H1} at (0,0) size 784x37
+ RenderText {#text} at (0,0) size 398x37
+ text run at (0,0) width 398: "This should be green, not red"
+ RenderBlock {H1} at (0,58) size 784x37
+ RenderText {#text} at (0,0) size 411x37
+ text run at (0,0) width 411: "This should be green, not blue"
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+
+<html lang="en">
+
+<head profile="http://www.ietf.org/rfc/rfc2731.txt">
+
+<title>CSS 2.1 Test Suite: RGB color syntax error handling</title>
+
+<style type="text/css">
+body {color: green;}
+h1#floatnumnum {color: rgb(255.0, 0, 0);}
+h1#numnumfloat {color: rgb(0, 0, 128.0);}
+</style>
+</head>
+
+<body>
+<h1 id="floatnumnum">This should be green, not red</h1>
+<h1 id="numnumfloat">This should be green, not blue</h1>
+</body></html>
+
+2006-05-13 Rob Buis <buis@kde.org>
+
+ Reviewed by Darin, landed by ap.
+
+ Fix for http://bugzilla.opendarwin.org/show_bug.cgi?id=8132
+ CSS parser sometimes accepts real number as integer
+
+ Add a boolean variable per css value to catch whether values
+ are specified as floats or integers.
+
+ Test: css2.1/rgb-float.html
+
+ * css/CSSGrammar.y:
+ * css/cssparser.cpp:
+ (WebCore::CSSParser::validUnit):
+ (WebCore::CSSParser::lex):
+ * css/cssparser.h:
+ * css/tokenizer.flex:
+
2006-05-13 Sam Weinig <sam.weinig@gmail.com>
Reviewed by Hyatt, landed by ap.
%token <val> KHERZ
%token <string> DIMEN
%token <val> PERCENTAGE
-%token <val> NUMBER
+%token <val> FLOAT
+%token <val> INTEGER
%token <string> URI
%token <string> FUNCTION
;
unary_term:
- NUMBER maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_NUMBER; }
+ INTEGER maybe_space { $$.id = 0; $$.isInt = true; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_NUMBER; }
+ | FLOAT maybe_space { $$.id = 0; $$.isInt = false; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_NUMBER; }
| PERCENTAGE maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_PERCENTAGE; }
| PXS maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_PX; }
| CMS maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_CM; }
value->unit = CSSPrimitiveValue::CSS_PX;
b = true;
}
- if (!b && (unitflags & FInteger) &&
- (value->fValue - (int)value->fValue) < 0.001)
+ if (!b && (unitflags & FInteger) && value->isInt)
b = true;
break;
case CSSPrimitiveValue::CSS_PERCENTAGE:
case SECS:
case PERCENTAGE:
length--;
- case NUMBER:
+ case FLOAT:
+ case INTEGER:
yylval->val = DeprecatedString((QChar *)t, length).toDouble();
break;
struct Value {
int id;
+ bool isInt;
union {
double fValue;
int iValue;
ident -?{nmstart}{nmchar}*
name {nmchar}+
num [0-9]+|[0-9]*"."[0-9]+
+intnum [0-9]+
string {string1}|{string2}
url ([!#$%&*-~]|{nonascii}|{escape})*
w [ \t\r\n\f]*
{num}kHz {yyTok = KHERZ; return yyTok;}
{num}{ident} {yyTok = DIMEN; return yyTok;}
{num}%+ {yyTok = PERCENTAGE; return yyTok;}
-{num} {yyTok = NUMBER; return yyTok;}
+{intnum} {yyTok = INTEGER; return yyTok;}
+{num} {yyTok = FLOAT; return yyTok;}
"url("{w}{string}{w}")" {yyTok = URI; return yyTok;}
"url("{w}{url}{w}")" {yyTok = URI; return yyTok;}