Title: [149360] trunk
Revision
149360
Author
[email protected]
Date
2013-04-30 04:00:04 -0700 (Tue, 30 Apr 2013)

Log Message

CSSParser::parseFontFamily should allow the keyword "default" as part of a font name
https://bugs.webkit.org/show_bug.cgi?id=107231

Reviewed by Ryosuke Niwa.

Source/WebCore:

Make sure that using the keyword "default" as font family doesn't
invalidate the whole declaration. It is also OK to use a font that
has "default" as part of a composite name (i.e. "default foo").
This matches the behavior of Firefox and IE.

Test: fast/css/font-family-parse-keyword.html

* css/CSSParser.cpp:
(WebCore::CSSParser::parseFontFamily):

LayoutTests:

* fast/css/font-family-parse-keyword-expected.html: Added.
* fast/css/font-family-parse-keyword.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (149359 => 149360)


--- trunk/LayoutTests/ChangeLog	2013-04-30 10:54:08 UTC (rev 149359)
+++ trunk/LayoutTests/ChangeLog	2013-04-30 11:00:04 UTC (rev 149360)
@@ -1,3 +1,13 @@
+2013-04-30  Thiago Marcos P. Santos  <[email protected]>
+
+        CSSParser::parseFontFamily should allow the keyword "default" as part of a font name
+        https://bugs.webkit.org/show_bug.cgi?id=107231
+
+        Reviewed by Ryosuke Niwa.
+
+        * fast/css/font-family-parse-keyword-expected.html: Added.
+        * fast/css/font-family-parse-keyword.html: Added.
+
 2013-04-30  Zalan Bujtas  <[email protected]>
 
         Animations fail to start on http://www.google.com/insidesearch/howsearchworks/thestory/

Added: trunk/LayoutTests/fast/css/font-family-parse-keyword-expected.html (0 => 149360)


--- trunk/LayoutTests/fast/css/font-family-parse-keyword-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/font-family-parse-keyword-expected.html	2013-04-30 11:00:04 UTC (rev 149360)
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<style>
+@font-face {
+    font-family: webkit-ahem;
+    src: url(../../resources/Ahem.ttf) format(truetype);
+}
+</style>
+<body>
+    <p>
+        https://bugs.webkit.org/b/107231 - CSSParser::parseFontFamily should allow
+        the keyword "default" as part of a font name
+    </p>
+    <p>
+        The next 4 lines should use the default font (same as this line):<br>
+        Test 1<br>
+        Test 2<br>
+        Test 3<br>
+        Test 4
+    </p>
+    <p>
+        The next 6 lines should use the font Arial:<br>
+        <span style="font-family: arial">
+            Test 1<br>
+            Test 2<br>
+            Test 3<br>
+            Test 4<br>
+            Test 5<br>
+            Test 6
+        </span>
+    </p>
+    <p>
+        The next 9 lines should use the font Ahem (black boxes):<br>
+        <span style="font-family: webkit-ahem">
+            Test 1<br>
+            Test 2<br>
+            Test 3<br>
+            Test 4<br>
+            Test 5<br>
+            Test 6<br>
+            Test 7<br>
+            Test 8<br>
+            Test 9
+        </span>
+    </p>
+</body>
+</html>

Added: trunk/LayoutTests/fast/css/font-family-parse-keyword.html (0 => 149360)


--- trunk/LayoutTests/fast/css/font-family-parse-keyword.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/font-family-parse-keyword.html	2013-04-30 11:00:04 UTC (rev 149360)
@@ -0,0 +1,50 @@
+<!DOCTYPE html>
+<style>
+@font-face {
+    font-family: webkit-ahem;
+    src: url(../../resources/Ahem.ttf) format(truetype);
+}
+@font-face {
+    font-family: default foo;
+    src: url(../../resources/Ahem.ttf) format(truetype);
+}
+@font-face {
+    font-family: bar default;
+    src: url(../../resources/Ahem.ttf) format(truetype);
+}
+</style>
+<body>
+    <p>
+        https://bugs.webkit.org/b/107231 - CSSParser::parseFontFamily should allow
+        the keyword "default" as part of a font name
+    </p>
+    <p>
+        The next 4 lines should use the default font (same as this line):<br>
+        Test 1<br>
+        <span style="font-family: default">Test 2</span><br>
+        <span style="font-family: default, invalid">Test 3</span><br>
+        <span style="font-family: invalid, default">Test 4</span>
+    </p>
+    <p>
+        The next 6 lines should use the font Arial:<br>
+        <span style="font-family: arial">Test 1</span><br>
+        <span style="font-family: default, arial">Test 2</span><br>
+        <span style="font-family: default foobar, arial">Test 3</span><br>
+        <span style="font-family: arial, default">Test 4</span><br>
+        <span style="font-family: arial, default foobar">Test 5</span><br>
+        <span style="font-family: invalid, default, arial">Test 6</span>
+    </p>
+    <p>
+        The next 9 lines should use the font Ahem (black boxes):<br>
+        <span style="font-family: webkit-ahem">Test 1</span><br>
+        <span style="font-family: default foo">Test 2</span><br>
+        <span style="font-family: default foo, invalid">Test 3</span><br>
+        <span style="font-family: invalid, default foo">Test 4</span><br>
+        <span style="font-family: invalid, default foo, foobar">Test 5</span><br>
+        <span style="font-family: bar default">Test 6</span><br>
+        <span style="font-family: bar default, invalid">Test 7</span><br>
+        <span style="font-family: invalid, bar default">Test 8</span><br>
+        <span style="font-family: invalid, bar default, foobar">Test 9</span>
+    </p>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (149359 => 149360)


--- trunk/Source/WebCore/ChangeLog	2013-04-30 10:54:08 UTC (rev 149359)
+++ trunk/Source/WebCore/ChangeLog	2013-04-30 11:00:04 UTC (rev 149360)
@@ -1,3 +1,20 @@
+2013-04-30  Thiago Marcos P. Santos  <[email protected]>
+
+        CSSParser::parseFontFamily should allow the keyword "default" as part of a font name
+        https://bugs.webkit.org/show_bug.cgi?id=107231
+
+        Reviewed by Ryosuke Niwa.
+
+        Make sure that using the keyword "default" as font family doesn't
+        invalidate the whole declaration. It is also OK to use a font that
+        has "default" as part of a composite name (i.e. "default foo").
+        This matches the behavior of Firefox and IE.
+
+        Test: fast/css/font-family-parse-keyword.html
+
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseFontFamily):
+
 2013-04-30  Zalan Bujtas  <[email protected]>
 
         Animations fail to start on http://www.google.com/insidesearch/howsearchworks/thestory/

Modified: trunk/Source/WebCore/css/CSSParser.cpp (149359 => 149360)


--- trunk/Source/WebCore/css/CSSParser.cpp	2013-04-30 10:54:08 UTC (rev 149359)
+++ trunk/Source/WebCore/css/CSSParser.cpp	2013-04-30 11:00:04 UTC (rev 149360)
@@ -5442,8 +5442,6 @@
     bool inFamily = false;
 
     while (value) {
-        if (value->id == CSSValueInitial || value->id == CSSValueInherit || value->id == CSSValueDefault)
-            return 0;
         CSSParserValue* nextValue = m_valueList->next();
         bool nextValBreaksFont = !nextValue ||
                                  (nextValue->unit == CSSParserValue::Operator && nextValue->iValue == ',');
@@ -5451,6 +5449,15 @@
             ((nextValue->id >= CSSValueSerif && nextValue->id <= CSSValueWebkitBody) ||
             (nextValue->unit == CSSPrimitiveValue::CSS_STRING || nextValue->unit == CSSPrimitiveValue::CSS_IDENT));
 
+        bool valueIsKeyword = value->id == CSSValueInitial || value->id == CSSValueInherit || value->id == CSSValueDefault;
+        if (valueIsKeyword && !inFamily) {
+            if (nextValBreaksFont)
+                value = m_valueList->next();
+            else if (nextValIsFontName)
+                value = nextValue;
+            continue;
+        }
+
         if (value->id >= CSSValueSerif && value->id <= CSSValueWebkitBody) {
             if (inFamily)
                 familyBuilder.add(value->string);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to