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.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@107728
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2012-02-14 Alexis Menard <alexis.menard@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 <inferno@chromium.org>
Crash due to incorrect firing of mutation event during class attribute parsing.
--- /dev/null
+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
+
--- /dev/null
+<!DOCTYPE HTML>
+<html>
+<head>
+<title>Test for WebKit bug 20181 : font shorthand with inherit keyword incorrectly parsed and rendered</title>
+<script src="../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description">Test for WebKit bug <a href="https://bugs.webkit.org/show_bug.cgi?id=20181">20181</a> : 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="../js/resources/js-test-post.js"></script>
+</body>
+</html>
+2012-02-14 Alexis Menard <alexis.menard@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 <inferno@chromium.org>
Crash due to incorrect firing of mutation event during class attribute parsing.
// 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.
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);
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();
return false;
}
+ if (value->id == CSSValueInitial || value->id == CSSValueInherit)
+ return false;
+
if (!font->lineHeight)
font->lineHeight = cssValuePool()->createIdentifierValue(CSSValueNormal);
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 == ',');