Title: [207513] trunk/Source/WebCore
Revision
207513
Author
hy...@apple.com
Date
2016-10-18 18:06:45 -0700 (Tue, 18 Oct 2016)

Log Message

[CSS Parser] Enable basic parser testing.
https://bugs.webkit.org/show_bug.cgi?id=163639

Reviewed by Dean Jackson.

* css/SelectorChecker.cpp:
(WebCore::SelectorChecker::matchRecursively):
Remove the ASSERT_NOT_REACHED on the new shadow selectors. We need to implement this
eventually, but it's better to not assert on that for now.

* css/parser/CSSParserValues.cpp:
(WebCore::CSSParserSelector::isHostPseudoSelector):
Make sure to check that we're a pseudoclass selector first, since otherwise we'll assert.

* css/parser/CSSParserValues.h:
(WebCore::CSSParserSelector::needsImplicitShadowCombinatorForMatching):
Make sure to check that we're a pseudoelement selector first, since otherwise we'll assert.

* css/parser/CSSPropertyParser.cpp:
(WebCore::CSSPropertyParser::addExpandedPropertyForValue):
copyRef is needed here, since a singleton value is being propagated to all the expanded shorthand properties.

(WebCore::parseSingleShadow):
(WebCore::CSSPropertyParser::consumeFont):
Remove the font properties that aren't part of our shorthand. We will need to revisit this eventually as it seems
some of the font properties should be reset as part of this shorthand but aren't.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (207512 => 207513)


--- trunk/Source/WebCore/ChangeLog	2016-10-19 01:03:23 UTC (rev 207512)
+++ trunk/Source/WebCore/ChangeLog	2016-10-19 01:06:45 UTC (rev 207513)
@@ -1,3 +1,40 @@
+2016-10-18  Dave Hyatt  <hy...@apple.com>
+
+        [CSS Parser] Enable basic parser testing.
+        https://bugs.webkit.org/show_bug.cgi?id=163639
+
+        Reviewed by Dean Jackson.
+
+        * css/SelectorChecker.cpp:
+        (WebCore::SelectorChecker::matchRecursively):
+        Remove the ASSERT_NOT_REACHED on the new shadow selectors. We need to implement this
+        eventually, but it's better to not assert on that for now.
+
+        * css/parser/CSSParserValues.cpp:
+        (WebCore::CSSParserSelector::isHostPseudoSelector):
+        Make sure to check that we're a pseudoclass selector first, since otherwise we'll assert.
+
+        * css/parser/CSSParserValues.h:
+        (WebCore::CSSParserSelector::needsImplicitShadowCombinatorForMatching):
+        Make sure to check that we're a pseudoelement selector first, since otherwise we'll assert.
+
+        * css/parser/CSSPropertyParser.cpp:
+        (WebCore::CSSPropertyParser::addExpandedPropertyForValue):
+        copyRef is needed here, since a singleton value is being propagated to all the expanded shorthand properties.
+
+        (WebCore::parseSingleShadow):
+        (WebCore::CSSPropertyParser::consumeFont):
+        Remove the font properties that aren't part of our shorthand. We will need to revisit this eventually as it seems
+        some of the font properties should be reset as part of this shorthand but aren't.
+'
+        * css/parser/CSSPropertyParserHelpers.cpp:
+        (WebCore::CSSPropertyParserHelpers::consumeInteger):
+        Just return a number for now instead of the parser_integer type.
+
+        * css/parser/CSSSelectorParser.cpp:
+        (WebCore::CSSSelectorParser::consumePseudo):
+        Clean this up so that it doesn't assert by making sure to add qualifying checks for the appropriate match type.
+
 2016-10-18  Ryosuke Niwa  <rn...@webkit.org>
 
         Update the comment for HTML Imports as there is now a proposal to use ES6 Modules for this.

Modified: trunk/Source/WebCore/css/SelectorChecker.cpp (207512 => 207513)


--- trunk/Source/WebCore/css/SelectorChecker.cpp	2016-10-19 01:03:23 UTC (rev 207512)
+++ trunk/Source/WebCore/css/SelectorChecker.cpp	2016-10-19 01:06:45 UTC (rev 207513)
@@ -457,7 +457,7 @@
     case CSSSelector::ShadowDeep:
     case CSSSelector::ShadowSlot:
         // FIXME-NEWPARSER: Have to implement these.
-        ASSERT_NOT_REACHED();
+        // ASSERT_NOT_REACHED();
         return MatchResult::fails(Match::SelectorFailsCompletely);
     }
 

Modified: trunk/Source/WebCore/css/parser/CSSParserValues.cpp (207512 => 207513)


--- trunk/Source/WebCore/css/parser/CSSParserValues.cpp	2016-10-19 01:03:23 UTC (rev 207512)
+++ trunk/Source/WebCore/css/parser/CSSParserValues.cpp	2016-10-19 01:06:45 UTC (rev 207513)
@@ -531,7 +531,7 @@
 // FIXME-NEWPARSER: Add support for :host-context
 bool CSSParserSelector::isHostPseudoSelector() const
 {
-    return pseudoClassType() == CSSSelector::PseudoClassHost;
+    return match() == CSSSelector::PseudoClass && pseudoClassType() == CSSSelector::PseudoClassHost;
 }
 
 }

Modified: trunk/Source/WebCore/css/parser/CSSParserValues.h (207512 => 207513)


--- trunk/Source/WebCore/css/parser/CSSParserValues.h	2016-10-19 01:03:23 UTC (rev 207512)
+++ trunk/Source/WebCore/css/parser/CSSParserValues.h	2016-10-19 01:06:45 UTC (rev 207513)
@@ -256,7 +256,7 @@
     bool isHostPseudoSelector() const;
 
     // FIXME-NEWPARSER: Missing "shadow"
-    bool needsImplicitShadowCombinatorForMatching() const { return pseudoElementType() == CSSSelector::PseudoElementWebKitCustom || pseudoElementType() == CSSSelector::PseudoElementUserAgentCustom || pseudoElementType() == CSSSelector::PseudoElementWebKitCustomLegacyPrefixed || pseudoElementType() == CSSSelector::PseudoElementCue || pseudoElementType() == CSSSelector::PseudoElementSlotted; }
+    bool needsImplicitShadowCombinatorForMatching() const { return match() == CSSSelector::PseudoElement && (pseudoElementType() == CSSSelector::PseudoElementWebKitCustom || pseudoElementType() == CSSSelector::PseudoElementUserAgentCustom || pseudoElementType() == CSSSelector::PseudoElementWebKitCustomLegacyPrefixed || pseudoElementType() == CSSSelector::PseudoElementCue || pseudoElementType() == CSSSelector::PseudoElementSlotted); }
 
     CSSParserSelector* tagHistory() const { return m_tagHistory.get(); }
     void setTagHistory(std::unique_ptr<CSSParserSelector> selector) { m_tagHistory = WTFMove(selector); }

Modified: trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp (207512 => 207513)


--- trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp	2016-10-19 01:03:23 UTC (rev 207512)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp	2016-10-19 01:06:45 UTC (rev 207513)
@@ -228,7 +228,7 @@
     ASSERT(shorthandLength);
     const CSSPropertyID* longhands = shorthand.properties();
     for (unsigned i = 0; i < shorthandLength; ++i)
-        addProperty(longhands[i], property, WTFMove(value), important);
+        addProperty(longhands[i], property, value.copyRef(), important);
 }
     
 bool CSSPropertyParser::parseValue(CSSPropertyID propertyID, bool important,
@@ -1292,8 +1292,9 @@
             style = consumeIdent(range);
         }
     }
-    return CSSShadowValue::create(horizontalOffset.releaseNonNull(), verticalOffset.releaseNonNull(), blurRadius.releaseNonNull(),
-        spreadDistance.releaseNonNull(), style.releaseNonNull(), color.releaseNonNull());
+    
+    // We pass RefPtrs, since they can actually be null.
+    return CSSShadowValue::create(WTFMove(horizontalOffset), WTFMove(verticalOffset), WTFMove(blurRadius), WTFMove(spreadDistance), WTFMove(style), WTFMove(color));
 }
 
 static RefPtr<CSSValue> consumeShadow(CSSParserTokenRange& range, CSSParserMode cssParserMode, bool isBoxShadowProperty)
@@ -3471,7 +3472,7 @@
     RefPtr<CSSPrimitiveValue> fontStyle;
     RefPtr<CSSPrimitiveValue> fontVariantCaps;
     RefPtr<CSSPrimitiveValue> fontWeight;
-    RefPtr<CSSPrimitiveValue> fontStretch;
+    // FIXME-NEWPARSER: Implement. RefPtr<CSSPrimitiveValue> fontStretch;
     while (!m_range.atEnd()) {
         CSSValueID id = m_range.peek().id();
         if (!fontStyle && CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyFontStyle, id, m_context.mode)) {
@@ -3490,10 +3491,11 @@
             if (fontWeight)
                 continue;
         }
-        if (!fontStretch && CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyFontStretch, id, m_context.mode))
+        /* FIXME-NEWPARSER: Implement
+         if (!fontStretch && CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyFontStretch, id, m_context.mode))
             fontStretch = consumeIdent(m_range);
-        else
-            break;
+        else*/
+        break;
     }
 
     if (m_range.atEnd())
@@ -3501,11 +3503,16 @@
 
     addProperty(CSSPropertyFontStyle, CSSPropertyFont, fontStyle ? fontStyle.releaseNonNull() : CSSValuePool::singleton().createIdentifierValue(CSSValueNormal), important);
     addProperty(CSSPropertyFontVariantCaps, CSSPropertyFont, fontVariantCaps ? fontVariantCaps.releaseNonNull() : CSSValuePool::singleton().createIdentifierValue(CSSValueNormal), important);
+/*  
+    // FIXME-NEWPARSER: What do we do with these? They aren't part of our fontShorthand().
     addProperty(CSSPropertyFontVariantLigatures, CSSPropertyFont, CSSValuePool::singleton().createIdentifierValue(CSSValueNormal), important);
     addProperty(CSSPropertyFontVariantNumeric, CSSPropertyFont, CSSValuePool::singleton().createIdentifierValue(CSSValueNormal), important);
-
+*/
+    
     addProperty(CSSPropertyFontWeight, CSSPropertyFont, fontWeight ? fontWeight.releaseNonNull() : CSSValuePool::singleton().createIdentifierValue(CSSValueNormal), important);
+    /* FIXME-NEWPARSER: Implement.
     addProperty(CSSPropertyFontStretch, CSSPropertyFont, fontStretch ? fontStretch.releaseNonNull() : CSSValuePool::singleton().createIdentifierValue(CSSValueNormal), important);
+    */
 
     // Now a font size _must_ come.
     RefPtr<CSSValue> fontSize = consumeFontSize(m_range, m_context.mode);

Modified: trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp (207512 => 207513)


--- trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp	2016-10-19 01:03:23 UTC (rev 207512)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp	2016-10-19 01:06:45 UTC (rev 207513)
@@ -122,7 +122,7 @@
     if (token.type() == NumberToken) {
         if (token.numericValueType() == NumberValueType || token.numericValue() < minimumValue)
             return nullptr;
-        return CSSPrimitiveValue::create(range.consumeIncludingWhitespace().numericValue(), CSSPrimitiveValue::UnitTypes::CSS_PARSER_INTEGER);
+        return CSSPrimitiveValue::create(range.consumeIncludingWhitespace().numericValue(), CSSPrimitiveValue::UnitTypes::CSS_NUMBER);
     }
     CalcParser calcParser(range);
     if (const CSSCalcValue* calculation = calcParser.value()) {

Modified: trunk/Source/WebCore/css/parser/CSSSelectorParser.cpp (207512 => 207513)


--- trunk/Source/WebCore/css/parser/CSSSelectorParser.cpp	2016-10-19 01:03:23 UTC (rev 207512)
+++ trunk/Source/WebCore/css/parser/CSSSelectorParser.cpp	2016-10-19 01:06:45 UTC (rev 207513)
@@ -437,7 +437,7 @@
 
     std::unique_ptr<CSSParserSelector> selector;
     StringView value = token.value();
-    if (selector->match() == CSSSelector::PseudoClass)
+    if (colons == 1)
         selector = std::unique_ptr<CSSParserSelector>(CSSParserSelector::parsePseudoClassSelectorFromStringView(value));
     else
         selector = std::unique_ptr<CSSParserSelector>(CSSParserSelector::parsePseudoElementSelectorFromStringView(value));
@@ -447,7 +447,7 @@
 
     if (token.type() == IdentToken) {
         range.consume();
-        if (selector->pseudoElementType() == CSSSelector::PseudoElementUnknown)
+        if ((selector->match() == CSSSelector::PseudoElement && selector->pseudoElementType() == CSSSelector::PseudoElementUnknown) || (selector->match() == CSSSelector::PseudoClass && selector->pseudoClassType() == CSSSelector::PseudoClassUnknown))
             return nullptr;
         return selector;
     }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to