[CSS Parser] Fix text-emphasis-position parsing
authorhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 30 Oct 2016 03:48:06 +0000 (03:48 +0000)
committerhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 30 Oct 2016 03:48:06 +0000 (03:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=164197

Reviewed by Zalan Bujtas.

* css/parser/CSSParserFastPaths.cpp:
(WebCore::CSSParserFastPaths::isValidKeywordPropertyAndValue):
(WebCore::CSSParserFastPaths::isKeywordPropertyID):
* css/parser/CSSPropertyParser.cpp:
(WebCore::consumeTextEmphasisPosition):
(WebCore::CSSPropertyParser::parseSingleValue):

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

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

index 4569962..fde6770 100644 (file)
@@ -1,3 +1,17 @@
+2016-10-29  Dave Hyatt  <hyatt@apple.com>
+
+        [CSS Parser] Fix text-emphasis-position parsing
+        https://bugs.webkit.org/show_bug.cgi?id=164197
+
+        Reviewed by Zalan Bujtas.
+
+        * css/parser/CSSParserFastPaths.cpp:
+        (WebCore::CSSParserFastPaths::isValidKeywordPropertyAndValue):
+        (WebCore::CSSParserFastPaths::isKeywordPropertyID):
+        * css/parser/CSSPropertyParser.cpp:
+        (WebCore::consumeTextEmphasisPosition):
+        (WebCore::CSSPropertyParser::parseSingleValue):
+
 2016-10-29  Darin Adler  <darin@apple.com>
 
         Convert more of DOM from ExceptionCode to Exception
index e776793..4cf1f5e 100644 (file)
@@ -735,8 +735,6 @@ bool CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyID propertyId
         return valueID == CSSValueBefore || valueID == CSSValueAfter || valueID == CSSValueInterCharacter;
     case CSSPropertyWebkitTextCombine:
         return valueID == CSSValueNone || valueID == CSSValueHorizontal;
-    case CSSPropertyWebkitTextEmphasisPosition:
-        return valueID == CSSValueOver || valueID == CSSValueUnder;
     case CSSPropertyWebkitTextSecurity: // disc | circle | square | none
         return valueID == CSSValueDisc || valueID == CSSValueCircle || valueID == CSSValueSquare || valueID == CSSValueNone;
     case CSSPropertyTransformStyle:
@@ -925,7 +923,6 @@ bool CSSParserFastPaths::isKeywordPropertyID(CSSPropertyID propertyId)
     // FIXME-NEWPARSER: Treat the following properties as keyword properties:
     // case CSSPropertyBackgroundRepeatX:
     // case CSSPropertyBackgroundRepeatY:
-    // case CSSPropertyWebkitTextEmphasisPosition:
 
     // FIXME-NEWPARSER: Add the following unprefixed properties:
     // case CSSPropertyBackfaceVisibility:
index 9ec1c36..0e438a0 100644 (file)
@@ -3262,6 +3262,53 @@ static RefPtr<CSSValue> consumeWebkitAspectRatio(CSSParserTokenRange& range)
     return CSSAspectRatioValue::create(leftValue->floatValue(), rightValue->floatValue());
 }
 
+static RefPtr<CSSValue> consumeTextEmphasisPosition(CSSParserTokenRange& range)
+{
+    bool foundOverOrUnder = false;
+    CSSValueID overUnderValueID = CSSValueOver;
+    bool foundLeftOrRight = false;
+    CSSValueID leftRightValueID = CSSValueRight;
+    while (!range.atEnd()) {
+        switch (range.peek().id()) {
+        case CSSValueOver:
+            if (foundOverOrUnder)
+                return nullptr;
+            foundOverOrUnder = true;
+            overUnderValueID = CSSValueOver;
+            break;
+        case CSSValueUnder:
+            if (foundOverOrUnder)
+                return nullptr;
+            foundOverOrUnder = true;
+            overUnderValueID = CSSValueUnder;
+            break;
+        case CSSValueLeft:
+            if (foundLeftOrRight)
+                return nullptr;
+            foundLeftOrRight = true;
+            leftRightValueID = CSSValueLeft;
+            break;
+        case CSSValueRight:
+            if (foundLeftOrRight)
+                return nullptr;
+            foundLeftOrRight = true;
+            leftRightValueID = CSSValueRight;
+            break;
+        default:
+            return nullptr;
+        }
+        
+        range.consumeIncludingWhitespace();
+    }
+    if (!foundOverOrUnder)
+        return nullptr;
+    RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
+    list->append(CSSValuePool::singleton().createIdentifierValue(overUnderValueID));
+    if (foundLeftOrRight)
+        list->append(CSSValuePool::singleton().createIdentifierValue(leftRightValueID));
+    return list;
+}
+    
 RefPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSPropertyID property, CSSPropertyID currentShorthand)
 {
     if (CSSParserFastPaths::isKeywordPropertyID(property)) {
@@ -3657,6 +3704,8 @@ RefPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSPropertyID property, CSS
         return consumeAlt(m_range, m_context);
     case CSSPropertyWebkitAspectRatio:
         return consumeWebkitAspectRatio(m_range);
+    case CSSPropertyWebkitTextEmphasisPosition:
+        return consumeTextEmphasisPosition(m_range);
     default:
         return nullptr;
     }