[CSS Parser] Support the font-synthesis property
authorhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 14 Nov 2016 21:37:03 +0000 (21:37 +0000)
committerhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 14 Nov 2016 21:37:03 +0000 (21:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=164728

Reviewed by Dean Jackson.

* css/parser/CSSPropertyParser.cpp:
(WebCore::consumeFontSynthesis):
(WebCore::CSSPropertyParser::parseSingleValue):

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

Source/WebCore/ChangeLog
Source/WebCore/css/parser/CSSPropertyParser.cpp

index 601e834..703cfe5 100644 (file)
@@ -1,3 +1,14 @@
+2016-11-14  Dave Hyatt  <hyatt@apple.com>
+
+        [CSS Parser] Support the font-synthesis property
+        https://bugs.webkit.org/show_bug.cgi?id=164728
+
+        Reviewed by Dean Jackson.
+
+        * css/parser/CSSPropertyParser.cpp:
+        (WebCore::consumeFontSynthesis):
+        (WebCore::CSSPropertyParser::parseSingleValue):
+
 2016-11-12  Sam Weinig  <sam@webkit.org>
 
         [SVG] Moving more special casing of SVG out of the bindings - SVGNumber/SVGPoint/SVGRect/SVGLength/SVGTransform/SVGMatrix
index 0d6cf3f..781b542 100644 (file)
@@ -787,6 +787,35 @@ static RefPtr<CSSValueList> consumeFontFamily(CSSParserTokenRange& range)
     return list;
 }
 
+static RefPtr<CSSValue> consumeFontSynthesis(CSSParserTokenRange& range)
+{
+    // none | [ weight || style ]
+    if (range.peek().id() == CSSValueNone)
+        return consumeIdent(range);
+    
+    RefPtr<CSSValue> weight;
+    RefPtr<CSSValue> style;
+    
+    // FIXME: We allow weight and style to occur multiple times because the
+    // old parser did, and layout tests specifically check for it. It seems
+    // wrong though.
+    do {
+        if (range.peek().id() == CSSValueWeight)
+            weight = consumeIdent(range);
+        else if (range.peek().id() == CSSValueStyle)
+            style = consumeIdent(range);
+        else
+            return nullptr;
+    } while (!range.atEnd());
+    
+    auto list = CSSValueList::createSpaceSeparated();
+    if (weight)
+        list->append(weight.releaseNonNull());
+    if (style)
+        list->append(style.releaseNonNull());
+    return WTFMove(list);
+}
+
 static RefPtr<CSSValue> consumeLetterSpacing(CSSParserTokenRange& range, CSSParserMode cssParserMode)
 {
     if (range.peek().id() == CSSValueNormal)
@@ -3348,6 +3377,8 @@ RefPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSPropertyID property, CSS
         return consumeFontFamily(m_range);
     case CSSPropertyFontWeight:
         return consumeFontWeight(m_range);
+    case CSSPropertyFontSynthesis:
+        return consumeFontSynthesis(m_range);
     case CSSPropertyLetterSpacing:
         return consumeLetterSpacing(m_range, m_context.mode);
     case CSSPropertyWordSpacing: