WebCore:
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 26 Apr 2008 16:41:23 +0000 (16:41 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 26 Apr 2008 16:41:23 +0000 (16:41 +0000)
2008-04-26  Anatoli Papirovski  <apapirovski@mac.com>

        Reviewed by Dave Hyatt.

        Fix for https://bugs.webkit.org/show_bug.cgi?id=18583
        WebKit should ignore declarations with a negative value for
        line-height and font-size, including in the shorthand font form.

        Tests: fast/css/font-size-negative.html
               fast/css/line-height-negative.html

        * css/CSSParser.cpp:
        (WebCore::CSSParser::parseValue):
        (WebCore::CSSParser::parseFont):

LayoutTests:

2008-04-26  Anatoli Papirovski  <apapirovski@mac.com>

        Reviewed by Dave Hyatt.

        Test for https://bugs.webkit.org/show_bug.cgi?id=18583
        Negative values are invalid for font-size and line-height,
        including in the shorthand "font".

        * fast/css/font-size-negative.html: Added.
        * fast/css/line-height-negative.html: Added.
        * platform/mac/css2.1/t100801-c548-ln-ht-02-b-ag-expected.checksum:
        * platform/mac/css2.1/t100801-c548-ln-ht-02-b-ag-expected.png:
        * platform/mac/css2.1/t100801-c548-ln-ht-02-b-ag-expected.txt:
        * platform/mac/fast/css/font-size-negative-expected.checksum: Added.
        * platform/mac/fast/css/font-size-negative-expected.png: Added.
        * platform/mac/fast/css/font-size-negative-expected.txt: Added.
        * platform/mac/fast/css/line-height-negative-expected.checksum: Added.
        * platform/mac/fast/css/line-height-negative-expected.png: Added.
        * platform/mac/fast/css/line-height-negative-expected.txt: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@32591 268f45cc-cd09-0410-ab3c-d52691b4dbfc

14 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/css/font-size-negative.html [new file with mode: 0644]
LayoutTests/fast/css/line-height-negative.html [new file with mode: 0644]
LayoutTests/platform/mac/css2.1/t100801-c548-ln-ht-02-b-ag-expected.checksum
LayoutTests/platform/mac/css2.1/t100801-c548-ln-ht-02-b-ag-expected.png
LayoutTests/platform/mac/css2.1/t100801-c548-ln-ht-02-b-ag-expected.txt
LayoutTests/platform/mac/fast/css/font-size-negative-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/css/font-size-negative-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/css/font-size-negative-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/css/line-height-negative-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/css/line-height-negative-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/css/line-height-negative-expected.txt [new file with mode: 0644]
WebCore/ChangeLog
WebCore/css/CSSParser.cpp

index 6e7bf8acb2ffab450fa57f8a8befd41cf445f186..fd265f759ccde2c0fc62727981aac38a71730426 100644 (file)
@@ -1,3 +1,23 @@
+2008-04-26  Anatoli Papirovski  <apapirovski@mac.com>
+
+        Reviewed by Dave Hyatt.
+
+        Test for https://bugs.webkit.org/show_bug.cgi?id=18583
+        Negative values are invalid for font-size and line-height,
+        including in the shorthand "font".
+
+        * fast/css/font-size-negative.html: Added.
+        * fast/css/line-height-negative.html: Added.
+        * platform/mac/css2.1/t100801-c548-ln-ht-02-b-ag-expected.checksum:
+        * platform/mac/css2.1/t100801-c548-ln-ht-02-b-ag-expected.png:
+        * platform/mac/css2.1/t100801-c548-ln-ht-02-b-ag-expected.txt:
+        * platform/mac/fast/css/font-size-negative-expected.checksum: Added.
+        * platform/mac/fast/css/font-size-negative-expected.png: Added.
+        * platform/mac/fast/css/font-size-negative-expected.txt: Added.
+        * platform/mac/fast/css/line-height-negative-expected.checksum: Added.
+        * platform/mac/fast/css/line-height-negative-expected.png: Added.
+        * platform/mac/fast/css/line-height-negative-expected.txt: Added.
+
 2008-04-25  Holger Hans Peter Freyther  <zecke@selfish.org>
 
         Rubber stamped by Simon
diff --git a/LayoutTests/fast/css/font-size-negative.html b/LayoutTests/fast/css/font-size-negative.html
new file mode 100644 (file)
index 0000000..30a275b
--- /dev/null
@@ -0,0 +1,15 @@
+<html>
+ <head>
+  <title>Negative Font-Size</title>
+  <style type="text/css">
+
+    div#test1 {font: normal 10px/1 Helvetica, Arial, sans-serif; font: normal -50px/5 Georgia, serif;}
+
+  </style>
+ </head>
+ <body>
+
+  <div id="test1">This should be fairly small text, rather than huge, it should also be set in sans-serif rather than serif.</div>
+
+ </body>
+</html>
diff --git a/LayoutTests/fast/css/line-height-negative.html b/LayoutTests/fast/css/line-height-negative.html
new file mode 100644 (file)
index 0000000..58747ad
--- /dev/null
@@ -0,0 +1,20 @@
+<html>
+ <head>
+  <title>Negative Line Height</title>
+  <style type="text/css">
+
+    div#test1 {font: normal 10px/1 Helvetica, Arial, sans-serif; font: normal 50px/-2 Helvetica, Arial, sans-serif;}
+
+    div#test2 {position: absolute; width: 200px; margin: 1em 0 0; line-height: 3em; background: red;}
+    div#test2 span {display: block; position: absolute; left: 0; top: 0; width: 200px; line-height: 3em; line-height: -5em; background: green;}
+
+  </style>
+ </head>
+ <body>
+
+  <div id="test1">This should be fairly small text, rather than huge.</div>
+
+  <div id="test2">&nbsp;<span>There should be no red here</span></div>
+
+ </body>
+</html>
index a970d5d4b03495aeac9dea337c461ee15293419b..76d9716c386909bed6937b0d2d42a5d9125c95d3 100644 (file)
@@ -1 +1 @@
-11d185dc80363a628d5c77066876d330
\ No newline at end of file
+1dd92f9c90827d2b1e6d90944d6e2021
\ No newline at end of file
index e6f9056f5357ee71852d0f7750ee31407e2fd768..a54408d12a042c8abf054cf49367c28696a1bd23 100644 (file)
Binary files a/LayoutTests/platform/mac/css2.1/t100801-c548-ln-ht-02-b-ag-expected.png and b/LayoutTests/platform/mac/css2.1/t100801-c548-ln-ht-02-b-ag-expected.png differ
index 158780a35cf0619e2951a91a91227c80d91cfbb6..8a36e4fe75e65ccf355bd230bc460fb58ed41057 100644 (file)
@@ -1,12 +1,12 @@
 layer at (0,0) size 800x600
   RenderView at (0,0) size 800x600
-layer at (0,0) size 800x286
-  RenderBlock {HTML} at (0,0) size 800x286
-    RenderBody {BODY} at (8,8) size 784x270
+layer at (0,0) size 800x310
+  RenderBlock {HTML} at (0,0) size 800x310
+    RenderBody {BODY} at (8,8) size 784x294
       RenderBlock {P} at (0,0) size 784x18
         RenderText {#text} at (0,0) size 504x18
           text run at (0,0) width 504: "There should be a big pattern of green and lime dots below, with no red present."
-      RenderBlock {DIV} at (6,24) size 66x246 [color=#00FF00] [bgcolor=#FF0000] [border: (3px solid #000000)]
+      RenderBlock {DIV} at (6,24) size 66x270 [color=#00FF00] [bgcolor=#FF0000] [border: (3px solid #000000)]
         RenderBlock {P} at (15,9) size 48x48
           RenderText {#text} at (0,6) size 36x36
             text run at (0,6) width 36: "X X"
@@ -19,11 +19,11 @@ layer at (0,0) size 800x286
           RenderText {#text} at (0,6) size 36x36
             text run at (0,6) width 36: "X X"
             text run at (0,30) width 36: "X X"
-        RenderBlock {P} at (15,153) size 48x24
-          RenderText {#text} at (0,0) size 36x24
-            text run at (0,0) width 36: "X X"
-            text run at (0,12) width 36: "X X"
-        RenderBlock {P} at (15,177) size 48x60
+        RenderBlock {P} at (15,153) size 48x48
+          RenderText {#text} at (0,6) size 36x36
+            text run at (0,6) width 36: "X X"
+            text run at (0,30) width 36: "X X"
+        RenderBlock {P} at (15,201) size 48x60
           RenderText {#text} at (0,9) size 36x42
             text run at (0,9) width 36: "X X"
             text run at (0,39) width 36: "X X"
diff --git a/LayoutTests/platform/mac/fast/css/font-size-negative-expected.checksum b/LayoutTests/platform/mac/fast/css/font-size-negative-expected.checksum
new file mode 100644 (file)
index 0000000..9e1be8e
--- /dev/null
@@ -0,0 +1 @@
+882c6cc8dcd572d740b3834fe29117b2
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/css/font-size-negative-expected.png b/LayoutTests/platform/mac/fast/css/font-size-negative-expected.png
new file mode 100644 (file)
index 0000000..932cbfa
Binary files /dev/null and b/LayoutTests/platform/mac/fast/css/font-size-negative-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/css/font-size-negative-expected.txt b/LayoutTests/platform/mac/fast/css/font-size-negative-expected.txt
new file mode 100644 (file)
index 0000000..3b475ad
--- /dev/null
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {DIV} at (0,0) size 784x10
+        RenderText {#text} at (0,-1) size 458x12
+          text run at (0,-1) width 458: "This should be fairly small text, rather than huge, it should also be set in sans-serif rather than serif."
diff --git a/LayoutTests/platform/mac/fast/css/line-height-negative-expected.checksum b/LayoutTests/platform/mac/fast/css/line-height-negative-expected.checksum
new file mode 100644 (file)
index 0000000..9e4b61b
--- /dev/null
@@ -0,0 +1 @@
+5b43014220f7cc0c2bad212c5080a8ee
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/css/line-height-negative-expected.png b/LayoutTests/platform/mac/fast/css/line-height-negative-expected.png
new file mode 100644 (file)
index 0000000..908bf80
Binary files /dev/null and b/LayoutTests/platform/mac/fast/css/line-height-negative-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/css/line-height-negative-expected.txt b/LayoutTests/platform/mac/fast/css/line-height-negative-expected.txt
new file mode 100644 (file)
index 0000000..518332a
--- /dev/null
@@ -0,0 +1,16 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {DIV} at (0,0) size 784x10
+        RenderText {#text} at (0,-1) size 225x12
+          text run at (0,-1) width 225: "This should be fairly small text, rather than huge."
+layer at (8,34) size 200x48
+  RenderBlock (positioned) {DIV} at (8,34) size 200x48 [bgcolor=#FF0000]
+    RenderText {#text} at (0,15) size 4x18
+      text run at (0,15) width 4: " "
+layer at (8,34) size 200x48
+  RenderBlock (positioned) {SPAN} at (0,0) size 200x48 [bgcolor=#008000]
+    RenderText {#text} at (0,15) size 177x18
+      text run at (0,15) width 177: "There should be no red here"
index 3f197765abb4ae770753c2e92fef3e252caeaa7a..f1b2a5e2063398357ba5c0542c4dd7848217350b 100644 (file)
@@ -1,3 +1,18 @@
+2008-04-26  Anatoli Papirovski  <apapirovski@mac.com>
+
+        Reviewed by Dave Hyatt.
+
+        Fix for https://bugs.webkit.org/show_bug.cgi?id=18583
+        WebKit should ignore declarations with a negative value for
+        line-height and font-size, including in the shorthand font form.
+
+        Tests: fast/css/font-size-negative.html
+               fast/css/line-height-negative.html
+
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseValue):
+        (WebCore::CSSParser::parseFont):
+
 2008-04-25  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Sam.
index 366d3081de9164db21fa8dcd447bce2d7cff852b..0e26d1563650194daac1bb65a640fa2c4ba0aeb1 100644 (file)
@@ -976,7 +976,7 @@ bool CSSParser::parseValue(int propId, bool important)
         if (id >= CSSValueXxSmall && id <= CSSValueLarger)
             valid_primitive = true;
         else
-            valid_primitive = (validUnit(value, FLength|FPercent, strict));
+            valid_primitive = (validUnit(value, FLength|FPercent|FNonNeg, strict));
         break;
 
     case CSSPropertyFontStyle:           // normal | italic | oblique | inherit
@@ -1039,7 +1039,7 @@ bool CSSParser::parseValue(int propId, bool important)
         if (id == CSSValueNormal)
             valid_primitive = true;
         else
-            valid_primitive = (!id && validUnit(value, FNumber|FLength|FPercent, strict));
+            valid_primitive = (!id && validUnit(value, FNumber|FLength|FPercent|FNonNeg, strict));
         break;
     case CSSPropertyCounterIncrement:    // [ <identifier> <integer>? ]+ | none | inherit
         if (id != CSSValueNone)
@@ -2689,7 +2689,7 @@ bool CSSParser::parseFont(bool important)
     // <absolute-size> | <relative-size> | <length> | <percentage> | inherit
     if (value->id >= CSSValueXxSmall && value->id <= CSSValueLarger)
         font->size = new CSSPrimitiveValue(value->id);
-    else if (validUnit(value, FLength|FPercent, strict))
+    else if (validUnit(value, FLength|FPercent|FNonNeg, strict))
         font->size = new CSSPrimitiveValue(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit);
     value = valueList->next();
     if (!font->size || !value)
@@ -2702,7 +2702,7 @@ bool CSSParser::parseFont(bool important)
             return false;
         if (value->id == CSSValueNormal) {
             // default value, nothing to do
-        } else if (validUnit(value, FNumber|FLength|FPercent, strict))
+        } else if (validUnit(value, FNumber|FLength|FPercent|FNonNeg, strict))
             font->lineHeight = new CSSPrimitiveValue(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit);
         else
             return false;