- Revision
- 107728
- Author
- alexis.men...@openbossa.org
- Date
- 2012-02-14 13:00:24 -0800 (Tue, 14 Feb 2012)
Log Message
font shorthand with inherit keyword incorrectly parsed and rendered
https://bugs.webkit.org/show_bug.cgi?id=20181
Reviewed by Tony Chang.
Source/WebCore:
As stated in http://www.w3.org/TR/CSS21/changes.html#q142
if the inherit (and also by extension initial) is encountered in the
middle of the shorthand then the property becomes invalid.
Test: fast/css/font-shorthand-mix-inherit.html
* css/CSSParser.cpp:
(WebCore::CSSParser::parseFont):
(WebCore::CSSParser::parseFontFamily):
LayoutTests:
* fast/css/font-shorthand-mix-inherit-expected.txt: Added.
* fast/css/font-shorthand-mix-inherit.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (107727 => 107728)
--- trunk/LayoutTests/ChangeLog 2012-02-14 20:47:45 UTC (rev 107727)
+++ trunk/LayoutTests/ChangeLog 2012-02-14 21:00:24 UTC (rev 107728)
@@ -1,3 +1,13 @@
+2012-02-14 Alexis Menard <alexis.men...@openbossa.org>
+
+ font shorthand with inherit keyword incorrectly parsed and rendered
+ https://bugs.webkit.org/show_bug.cgi?id=20181
+
+ Reviewed by Tony Chang.
+
+ * fast/css/font-shorthand-mix-inherit-expected.txt: Added.
+ * fast/css/font-shorthand-mix-inherit.html: Added.
+
2012-02-14 Abhishek Arya <infe...@chromium.org>
Crash due to incorrect firing of mutation event during class attribute parsing.
Added: trunk/LayoutTests/fast/css/font-shorthand-mix-inherit-expected.txt (0 => 107728)
--- trunk/LayoutTests/fast/css/font-shorthand-mix-inherit-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/css/font-shorthand-mix-inherit-expected.txt 2012-02-14 21:00:24 UTC (rev 107728)
@@ -0,0 +1,20 @@
+Test for WebKit bug 20181 : font shorthand with inherit keyword incorrectly parsed and rendered
+
+PASS test.style.getPropertyValue('font') is '12pt/14pt sans-serif'
+PASS test.style.getPropertyValue('font') is 'inherit'
+PASS test.style.getPropertyValue('font') is ''
+PASS test.style.getPropertyValue('font') is ''
+PASS test.style.getPropertyValue('font') is ''
+PASS test.style.getPropertyValue('font') is ''
+PASS test.style.getPropertyValue('font') is ''
+PASS test.style.getPropertyValue('font') is ''
+PASS test.style.getPropertyValue('font') is ''
+PASS test.style.getPropertyValue('font') is ''
+PASS test.style.getPropertyValue('font') is ''
+PASS test.style.getPropertyValue('font') is ''
+PASS test.style.getPropertyValue('font') is ''
+PASS test.style.getPropertyValue('font') is ''
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/css/font-shorthand-mix-inherit.html (0 => 107728)
--- trunk/LayoutTests/fast/css/font-shorthand-mix-inherit.html (rev 0)
+++ trunk/LayoutTests/fast/css/font-shorthand-mix-inherit.html 2012-02-14 21:00:24 UTC (rev 107728)
@@ -0,0 +1,56 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<title>Test for WebKit bug 20181 : font shorthand with inherit keyword incorrectly parsed and rendered</title>
+<script src=""
+</head>
+<body>
+<p id="description">Test for WebKit bug <a href="" : font shorthand with inherit keyword incorrectly parsed and rendered</p>
+<div id="console"></div>
+
+<div id="tests_container">
+
+<div id="test"></div>
+
+</div>
+
+<script>
+ var test = document.getElementById("test");
+
+ // Sanity check.
+ test.style.font = "12pt/14pt sans-serif";
+ shouldBe("test.style.getPropertyValue('font')", "'12pt/14pt sans-serif'");
+ test.style.font = "";
+ test.style.font = "inherit";
+ shouldBe("test.style.getPropertyValue('font')", "'inherit'");
+ test.style.font = "";
+ shouldBe("test.style.getPropertyValue('font')", "''");
+ test.style.font = "12pt/14pt inherit";
+ shouldBe("test.style.getPropertyValue('font')", "''");
+ test.style.font = "12pt/14pt bold inherit";
+ shouldBe("test.style.getPropertyValue('font')", "''");
+ test.style.font = "italic 12pt/14pt bold inherit";
+ shouldBe("test.style.getPropertyValue('font')", "''");
+ test.style.font = "italic 12pt/14pt bold arial inherit";
+ shouldBe("test.style.getPropertyValue('font')", "''");
+ test.style.font = "x-large/110% 'new century schoolbook', serif, inherit";
+ shouldBe("test.style.getPropertyValue('font')", "''");
+ test.style.font = " 'inherit'";
+ shouldBe("test.style.getPropertyValue('font')", "''");
+ test.style.font = "italic inherit 12pt/14pt bold arial inherit";
+ shouldBe("test.style.getPropertyValue('font')", "''");
+ test.style.font = "arial inherit";
+ shouldBe("test.style.getPropertyValue('font')", "''");
+ test.style.font = "Arial, Helvetica, inherit, sans-serif;";
+ shouldBe("test.style.getPropertyValue('font')", "''");
+ test.style.font = "inherit, sans-serif;";
+ shouldBe("test.style.getPropertyValue('font')", "''");
+ test.style.font = "italic inherit 12pt/14pt bold arial initial";
+ shouldBe("test.style.getPropertyValue('font')", "''");
+ // clean up after ourselves
+ var tests_container = document.getElementById("tests_container");
+ tests_container.parentNode.removeChild(tests_container);
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (107727 => 107728)
--- trunk/Source/WebCore/ChangeLog 2012-02-14 20:47:45 UTC (rev 107727)
+++ trunk/Source/WebCore/ChangeLog 2012-02-14 21:00:24 UTC (rev 107728)
@@ -1,3 +1,20 @@
+2012-02-14 Alexis Menard <alexis.men...@openbossa.org>
+
+ font shorthand with inherit keyword incorrectly parsed and rendered
+ https://bugs.webkit.org/show_bug.cgi?id=20181
+
+ Reviewed by Tony Chang.
+
+ As stated in http://www.w3.org/TR/CSS21/changes.html#q142
+ if the inherit (and also by extension initial) is encountered in the
+ middle of the shorthand then the property becomes invalid.
+
+ Test: fast/css/font-shorthand-mix-inherit.html
+
+ * css/CSSParser.cpp:
+ (WebCore::CSSParser::parseFont):
+ (WebCore::CSSParser::parseFontFamily):
+
2012-02-14 Abhishek Arya <infe...@chromium.org>
Crash due to incorrect firing of mutation event during class attribute parsing.
Modified: trunk/Source/WebCore/css/CSSParser.cpp (107727 => 107728)
--- trunk/Source/WebCore/css/CSSParser.cpp 2012-02-14 20:47:45 UTC (rev 107727)
+++ trunk/Source/WebCore/css/CSSParser.cpp 2012-02-14 21:00:24 UTC (rev 107728)
@@ -4147,6 +4147,8 @@
// Optional font-style, font-variant and font-weight.
while (value) {
int id = value->id;
+ if (id == CSSValueInitial || id == CSSValueInherit)
+ return false;
if (id) {
if (id == CSSValueNormal) {
// It's the initial value for all three, so mark the corresponding longhand as explicit.
@@ -4216,6 +4218,9 @@
if (!value)
return false;
+ if (value->id == CSSValueInitial || value->id == CSSValueInherit)
+ return false;
+
// Set undefined values to default.
if (!font->style)
font->style = cssValuePool()->createIdentifierValue(CSSValueNormal);
@@ -4234,6 +4239,9 @@
if (!font->size || !value)
return false;
+ if (value->id == CSSValueInitial || value->id == CSSValueInherit)
+ return false;
+
if (value->unit == CSSParserValue::Operator && value->iValue == '/') {
// The line-height property.
value = m_valueList->next();
@@ -4252,6 +4260,9 @@
return false;
}
+ if (value->id == CSSValueInitial || value->id == CSSValueInherit)
+ return false;
+
if (!font->lineHeight)
font->lineHeight = cssValuePool()->createIdentifierValue(CSSValueNormal);
@@ -4283,6 +4294,8 @@
FontFamilyValue* currFamily = 0;
while (value) {
+ if (value->id == CSSValueInitial || value->id == CSSValueInherit)
+ return 0;
CSSParserValue* nextValue = m_valueList->next();
bool nextValBreaksFont = !nextValue ||
(nextValue->unit == CSSParserValue::Operator && nextValue->iValue == ',');