Title: [209265] trunk/Source/WebCore
Revision
209265
Author
[email protected]
Date
2016-12-02 14:07:08 -0800 (Fri, 02 Dec 2016)

Log Message

[CSS Parser] Need to set edit flags properly when user-modify/select are used.
https://bugs.webkit.org/show_bug.cgi?id=165334

Reviewed by Dean Jackson.

The old parser calls parserSetUsesStyleBasedEditability on
StyleSheetContents* from inside isValidKeywordPropertyAndValue. This
is pretty lame, but we have to do the same in order to pass editing
layout tests.

All of the functions below have been patched with the sole purpose of
propagating StyleSheetContents* through to isValidKeywordPropertyAndValue
in the new parser.

* css/parser/CSSParser.cpp:
(WebCore::CSSParser::parseValueWithVariableReferences):
* css/parser/CSSParser.h:
* css/parser/CSSParserFastPaths.cpp:
(WebCore::CSSParserFastPaths::isValidKeywordPropertyAndValue):
(WebCore::parseKeywordValue):
(WebCore::CSSParserFastPaths::maybeParseValue):
* css/parser/CSSParserFastPaths.h:
* css/parser/CSSParserImpl.cpp:
(WebCore::CSSParserImpl::consumeDeclarationValue):
* css/parser/CSSPropertyParser.cpp:
(WebCore::CSSPropertyParser::CSSPropertyParser):
(WebCore::CSSPropertyParser::parseValue):
(WebCore::CSSPropertyParser::parseSingleValue):
(WebCore::CSSPropertyParser::parseFontFaceDescriptor):
(WebCore::CSSPropertyParser::consumeFont):
(WebCore::CSSPropertyParser::parseShorthand):
* css/parser/CSSPropertyParser.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (209264 => 209265)


--- trunk/Source/WebCore/ChangeLog	2016-12-02 22:00:57 UTC (rev 209264)
+++ trunk/Source/WebCore/ChangeLog	2016-12-02 22:07:08 UTC (rev 209265)
@@ -1,3 +1,38 @@
+2016-12-02  Dave Hyatt  <[email protected]>
+
+        [CSS Parser] Need to set edit flags properly when user-modify/select are used.
+        https://bugs.webkit.org/show_bug.cgi?id=165334
+
+        Reviewed by Dean Jackson.
+
+        The old parser calls parserSetUsesStyleBasedEditability on
+        StyleSheetContents* from inside isValidKeywordPropertyAndValue. This
+        is pretty lame, but we have to do the same in order to pass editing
+        layout tests.
+
+        All of the functions below have been patched with the sole purpose of
+        propagating StyleSheetContents* through to isValidKeywordPropertyAndValue
+        in the new parser.
+
+        * css/parser/CSSParser.cpp:
+        (WebCore::CSSParser::parseValueWithVariableReferences):
+        * css/parser/CSSParser.h:
+        * css/parser/CSSParserFastPaths.cpp:
+        (WebCore::CSSParserFastPaths::isValidKeywordPropertyAndValue):
+        (WebCore::parseKeywordValue):
+        (WebCore::CSSParserFastPaths::maybeParseValue):
+        * css/parser/CSSParserFastPaths.h:
+        * css/parser/CSSParserImpl.cpp:
+        (WebCore::CSSParserImpl::consumeDeclarationValue):
+        * css/parser/CSSPropertyParser.cpp:
+        (WebCore::CSSPropertyParser::CSSPropertyParser):
+        (WebCore::CSSPropertyParser::parseValue):
+        (WebCore::CSSPropertyParser::parseSingleValue):
+        (WebCore::CSSPropertyParser::parseFontFaceDescriptor):
+        (WebCore::CSSPropertyParser::consumeFont):
+        (WebCore::CSSPropertyParser::parseShorthand):
+        * css/parser/CSSPropertyParser.h:
+
 2016-12-02  Beth Dakin  <[email protected]>
 
         REGRESSION (r208802): TouchBar pause button doesn't work

Modified: trunk/Source/WebCore/css/parser/CSSParser.cpp (209264 => 209265)


--- trunk/Source/WebCore/css/parser/CSSParser.cpp	2016-12-02 22:00:57 UTC (rev 209264)
+++ trunk/Source/WebCore/css/parser/CSSParser.cpp	2016-12-02 22:07:08 UTC (rev 209265)
@@ -1820,6 +1820,7 @@
 
 RefPtr<CSSValue> CSSParser::parseValueWithVariableReferences(CSSPropertyID propID, const CSSValue& value, const CustomPropertyValueMap& customProperties, TextDirection direction, WritingMode writingMode)
 {
+    // FIXME-NEWPARSER: Remove this block when old parser goes away.
     if (value.isVariableDependentValue()) {
         const CSSVariableDependentValue& dependentValue = downcast<CSSVariableDependentValue>(value);
         m_valueList.reset(new CSSParserValueList());
@@ -1857,7 +1858,7 @@
             return nullptr;
         
         ParsedPropertyVector parsedProperties;
-        if (!CSSPropertyParser::parseValue(shorthandID, false, resolvedTokens, m_context, parsedProperties, StyleRule::Style))
+        if (!CSSPropertyParser::parseValue(shorthandID, false, resolvedTokens, m_context, nullptr, parsedProperties, StyleRule::Style))
             return nullptr;
         
         for (auto& property : parsedProperties) {
@@ -1877,7 +1878,7 @@
         if (!variableData->resolveTokenRange(customProperties, variableData->tokens(), resolvedTokens))
             return nullptr;
         
-        return CSSPropertyParser::parseSingleValue(propID, resolvedTokens, m_context);
+        return CSSPropertyParser::parseSingleValue(propID, resolvedTokens, m_context, nullptr);
     }
     
     return nullptr;

Modified: trunk/Source/WebCore/css/parser/CSSParser.h (209264 => 209265)


--- trunk/Source/WebCore/css/parser/CSSParser.h	2016-12-02 22:00:57 UTC (rev 209264)
+++ trunk/Source/WebCore/css/parser/CSSParser.h	2016-12-02 22:07:08 UTC (rev 209265)
@@ -137,7 +137,7 @@
     static void parseDeclarationForInspector(const CSSParserContext&, const String&, CSSParserObserver&);
 
     static ParseResult parseValue(MutableStyleProperties&, CSSPropertyID, const String&, bool important, const CSSParserContext&, StyleSheetContents*);
-    static ParseResult parseCustomPropertyValue(MutableStyleProperties&, const AtomicString& propertyName, const String&, bool important, const CSSParserContext&, StyleSheetContents* contextStyleSheet);
+    static ParseResult parseCustomPropertyValue(MutableStyleProperties&, const AtomicString& propertyName, const String&, bool important, const CSSParserContext&, StyleSheetContents*);
 
     static Color parseColor(const String&, bool strict = false);
     static bool isValidSystemColorValue(CSSValueID);

Modified: trunk/Source/WebCore/css/parser/CSSParserFastPaths.cpp (209264 => 209265)


--- trunk/Source/WebCore/css/parser/CSSParserFastPaths.cpp	2016-12-02 22:00:57 UTC (rev 209264)
+++ trunk/Source/WebCore/css/parser/CSSParserFastPaths.cpp	2016-12-02 22:07:08 UTC (rev 209265)
@@ -42,6 +42,7 @@
 #include "RuntimeEnabledFeatures.h"
 #include "StyleColor.h"
 #include "StylePropertyShorthand.h"
+#include "StyleSheetContents.h"
 
 namespace WebCore {
 
@@ -496,7 +497,7 @@
     return CSSValuePool::singleton().createColorValue(color);
 }
 
-bool CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyID propertyId, CSSValueID valueID, CSSParserMode parserMode)
+bool CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyID propertyId, CSSValueID valueID, CSSParserMode parserMode, StyleSheetContents* styleSheetContents)
 {
     if (valueID == CSSValueInvalid || !isValueAllowedInMode(valueID, parserMode))
         return false;
@@ -747,9 +748,21 @@
     case CSSPropertyWebkitUserDrag: // auto | none | element
         return valueID == CSSValueAuto || valueID == CSSValueNone || valueID == CSSValueElement;
     case CSSPropertyWebkitUserModify: // read-only | read-write
-        return valueID == CSSValueReadOnly || valueID == CSSValueReadWrite || valueID == CSSValueReadWritePlaintextOnly;
+        if (valueID == CSSValueReadOnly || valueID == CSSValueReadWrite || valueID == CSSValueReadWritePlaintextOnly) {
+            if (styleSheetContents)
+                styleSheetContents->parserSetUsesStyleBasedEditability();
+            return true;
+        }
+        return false;
     case CSSPropertyWebkitUserSelect: // auto | none | text | all
-        return valueID == CSSValueAuto || valueID == CSSValueNone || valueID == CSSValueText || valueID == CSSValueAll;
+        if (valueID == CSSValueAuto || valueID == CSSValueNone || valueID == CSSValueText)
+            return true;
+        if (valueID == CSSValueAll) {
+            if (styleSheetContents)
+                styleSheetContents->parserSetUsesStyleBasedEditability();
+            return true;
+        }
+        return false;
     case CSSPropertyWritingMode:
         // Note that horizontal-bt is not supported by the unprefixed version of
         // the property, only by the -webkit- version.
@@ -1013,7 +1026,7 @@
     || equalLettersIgnoringASCIICase(string, "revert");
 }
 
-static RefPtr<CSSValue> parseKeywordValue(CSSPropertyID propertyId, const String& string, CSSParserMode parserMode)
+static RefPtr<CSSValue> parseKeywordValue(CSSPropertyID propertyId, const String& string, CSSParserMode parserMode, StyleSheetContents* styleSheetContents)
 {
     ASSERT(!string.isEmpty());
 
@@ -1045,7 +1058,7 @@
     if (valueID == CSSValueRevert)
         return CSSValuePool::singleton().createRevertValue();
     
-    if (CSSParserFastPaths::isValidKeywordPropertyAndValue(propertyId, valueID, parserMode))
+    if (CSSParserFastPaths::isValidKeywordPropertyAndValue(propertyId, valueID, parserMode, styleSheetContents))
         return CSSPrimitiveValue::createIdentifier(valueID);
     return nullptr;
 }
@@ -1256,7 +1269,7 @@
     return parseSimpleTransformList(string.characters16(), string.length());
 }
 
-RefPtr<CSSValue> CSSParserFastPaths::maybeParseValue(CSSPropertyID propertyID, const String& string, CSSParserMode parserMode)
+RefPtr<CSSValue> CSSParserFastPaths::maybeParseValue(CSSPropertyID propertyID, const String& string, CSSParserMode parserMode, StyleSheetContents* styleSheetContents)
 {
     RefPtr<CSSValue> result = parseSimpleLengthValue(propertyID, string, parserMode);
     if (result)
@@ -1263,7 +1276,7 @@
         return result;
     if (isColorPropertyID(propertyID))
         return parseColor(string, parserMode);
-    result = parseKeywordValue(propertyID, string, parserMode);
+    result = parseKeywordValue(propertyID, string, parserMode, styleSheetContents);
     if (result)
         return result;
     result = parseSimpleTransform(propertyID, string);

Modified: trunk/Source/WebCore/css/parser/CSSParserFastPaths.h (209264 => 209265)


--- trunk/Source/WebCore/css/parser/CSSParserFastPaths.h	2016-12-02 22:00:57 UTC (rev 209264)
+++ trunk/Source/WebCore/css/parser/CSSParserFastPaths.h	2016-12-02 22:07:08 UTC (rev 209265)
@@ -37,16 +37,17 @@
 namespace WebCore {
 
 class CSSValue;
+class StyleSheetContents;
 
 class CSSParserFastPaths {
 public:
     // Parses simple values like '10px' or 'green', but makes no guarantees
     // about handling any property completely.
-    static RefPtr<CSSValue> maybeParseValue(CSSPropertyID, const String&, CSSParserMode);
+    static RefPtr<CSSValue> maybeParseValue(CSSPropertyID, const String&, CSSParserMode, StyleSheetContents*);
 
     // Properties handled here shouldn't be explicitly handled in CSSPropertyParser
     static bool isKeywordPropertyID(CSSPropertyID);
-    static bool isValidKeywordPropertyAndValue(CSSPropertyID, CSSValueID, CSSParserMode);
+    static bool isValidKeywordPropertyAndValue(CSSPropertyID, CSSValueID, CSSParserMode, StyleSheetContents*);
 
     static RefPtr<CSSValue> parseColor(const String&, CSSParserMode);
 };

Modified: trunk/Source/WebCore/css/parser/CSSParserImpl.cpp (209264 => 209265)


--- trunk/Source/WebCore/css/parser/CSSParserImpl.cpp	2016-12-02 22:00:57 UTC (rev 209264)
+++ trunk/Source/WebCore/css/parser/CSSParserImpl.cpp	2016-12-02 22:07:08 UTC (rev 209265)
@@ -799,7 +799,7 @@
 
 void CSSParserImpl::consumeDeclarationValue(CSSParserTokenRange range, CSSPropertyID propertyID, bool important, StyleRule::Type ruleType)
 {
-    CSSPropertyParser::parseValue(propertyID, important, range, m_context, m_parsedProperties, ruleType);
+    CSSPropertyParser::parseValue(propertyID, important, range, m_context, m_styleSheet.get(), m_parsedProperties, ruleType);
 }
 
 std::unique_ptr<Vector<double>> CSSParserImpl::consumeKeyframeKeyList(CSSParserTokenRange range)

Modified: trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp (209264 => 209265)


--- trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp	2016-12-02 22:00:57 UTC (rev 209264)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp	2016-12-02 22:07:08 UTC (rev 209265)
@@ -208,10 +208,10 @@
     
 using namespace CSSPropertyParserHelpers;
 
-CSSPropertyParser::CSSPropertyParser(const CSSParserTokenRange& range,
-    const CSSParserContext& context, Vector<CSSProperty, 256>* parsedProperties)
+CSSPropertyParser::CSSPropertyParser(const CSSParserTokenRange& range, const CSSParserContext& context, StyleSheetContents* styleSheetContents, Vector<CSSProperty, 256>* parsedProperties)
     : m_range(range)
     , m_context(context)
+    , m_styleSheetContents(styleSheetContents)
     , m_parsedProperties(parsedProperties)
 {
     m_range.consumeWhitespace();
@@ -242,13 +242,11 @@
         addProperty(longhands[i], property, value.copyRef(), important);
 }
     
-bool CSSPropertyParser::parseValue(CSSPropertyID propertyID, bool important,
-    const CSSParserTokenRange& range, const CSSParserContext& context,
-    ParsedPropertyVector& parsedProperties, StyleRule::Type ruleType)
+bool CSSPropertyParser::parseValue(CSSPropertyID propertyID, bool important, const CSSParserTokenRange& range, const CSSParserContext& context, StyleSheetContents* styleSheetContents, ParsedPropertyVector& parsedProperties, StyleRule::Type ruleType)
 {
     int parsedPropertiesSize = parsedProperties.size();
 
-    CSSPropertyParser parser(range, context, &parsedProperties);
+    CSSPropertyParser parser(range, context, styleSheetContents, &parsedProperties);
     bool parseSuccess;
 
 #if ENABLE(CSS_DEVICE_ADAPTATION)
@@ -267,9 +265,9 @@
     return parseSuccess;
 }
 
-RefPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSPropertyID property, const CSSParserTokenRange& range, const CSSParserContext& context)
+RefPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSPropertyID property, const CSSParserTokenRange& range, const CSSParserContext& context, StyleSheetContents* styleSheetContents)
 {
-    CSSPropertyParser parser(range, context, nullptr);
+    CSSPropertyParser parser(range, context, styleSheetContents, nullptr);
     RefPtr<CSSValue> value = parser.parseSingleValue(property);
     if (!value || !parser.m_range.atEnd())
         return nullptr;
@@ -3597,7 +3595,7 @@
 RefPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSPropertyID property, CSSPropertyID currentShorthand)
 {
     if (CSSParserFastPaths::isKeywordPropertyID(property)) {
-        if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(property, m_range.peek().id(), m_context.mode))
+        if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(property, m_range.peek().id(), m_context.mode, m_styleSheetContents))
             return nullptr;
         return consumeIdent(m_range);
     }
@@ -4135,7 +4133,7 @@
     case CSSPropertyFontStretch:
     case CSSPropertyFontStyle: {
         CSSValueID id = m_range.consumeIncludingWhitespace().id();
-        if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(propId, id, m_context.mode))
+        if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(propId, id, m_context.mode, m_styleSheetContents))
             return false;
         parsedValue = CSSValuePool::singleton().createIdentifierValue(id);
         break;
@@ -4219,7 +4217,7 @@
     // 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)) {
+        if (!fontStyle && CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyFontStyle, id, m_context.mode, m_styleSheetContents)) {
             fontStyle = consumeIdent(m_range);
             continue;
         }
@@ -4236,7 +4234,7 @@
                 continue;
         }
         /* FIXME-NEWPARSER: Implement
-         if (!fontStretch && CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyFontStretch, id, m_context.mode))
+         if (!fontStretch && CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyFontStretch, id, m_context.mode, m_styleSheetContents))
             fontStretch = consumeIdent(m_range);
         else*/
         break;
@@ -5226,7 +5224,7 @@
     switch (property) {
     case CSSPropertyWebkitMarginCollapse: {
         CSSValueID id = m_range.consumeIncludingWhitespace().id();
-        if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyWebkitMarginBeforeCollapse, id, m_context.mode))
+        if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyWebkitMarginBeforeCollapse, id, m_context.mode, m_styleSheetContents))
             return false;
         addProperty(CSSPropertyWebkitMarginBeforeCollapse, CSSPropertyWebkitMarginCollapse, CSSValuePool::singleton().createIdentifierValue(id), important);
         if (m_range.atEnd()) {
@@ -5234,7 +5232,7 @@
             return true;
         }
         id = m_range.consumeIncludingWhitespace().id();
-        if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyWebkitMarginAfterCollapse, id, m_context.mode))
+        if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyWebkitMarginAfterCollapse, id, m_context.mode, m_styleSheetContents))
             return false;
         addProperty(CSSPropertyWebkitMarginAfterCollapse, CSSPropertyWebkitMarginCollapse, CSSValuePool::singleton().createIdentifierValue(id), important);
         return true;
@@ -5241,7 +5239,7 @@
     }
     case CSSPropertyOverflow: {
         CSSValueID id = m_range.consumeIncludingWhitespace().id();
-        if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyOverflowY, id, m_context.mode))
+        if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyOverflowY, id, m_context.mode, m_styleSheetContents))
             return false;
         if (!m_range.atEnd())
             return false;

Modified: trunk/Source/WebCore/css/parser/CSSPropertyParser.h (209264 => 209265)


--- trunk/Source/WebCore/css/parser/CSSPropertyParser.h	2016-12-02 22:00:57 UTC (rev 209264)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParser.h	2016-12-02 22:07:08 UTC (rev 209265)
@@ -31,7 +31,8 @@
 class CSSProperty;
 class CSSValue;
 class StylePropertyShorthand;
-
+class StyleSheetContents;
+    
 // Inputs: PropertyID, isImportant bool, CSSParserTokenRange.
 // Outputs: Vector of CSSProperties
 
@@ -39,15 +40,14 @@
     WTF_MAKE_NONCOPYABLE(CSSPropertyParser);
 public:
     static bool parseValue(CSSPropertyID, bool important,
-        const CSSParserTokenRange&, const CSSParserContext&,
+        const CSSParserTokenRange&, const CSSParserContext&, StyleSheetContents*,
         Vector<CSSProperty, 256>&, StyleRule::Type);
 
     // Parses a non-shorthand CSS property
-    static RefPtr<CSSValue> parseSingleValue(CSSPropertyID, const CSSParserTokenRange&, const CSSParserContext&);
+    static RefPtr<CSSValue> parseSingleValue(CSSPropertyID, const CSSParserTokenRange&, const CSSParserContext&, StyleSheetContents*);
 
 private:
-    CSSPropertyParser(const CSSParserTokenRange&, const CSSParserContext&,
-        Vector<CSSProperty, 256>*);
+    CSSPropertyParser(const CSSParserTokenRange&, const CSSParserContext&, StyleSheetContents*, Vector<CSSProperty, 256>*);
 
     // FIXME: Rename once the CSSParserValue-based parseValue is removed
     bool parseValueStart(CSSPropertyID, bool important);
@@ -100,6 +100,8 @@
     // Inputs:
     CSSParserTokenRange m_range;
     const CSSParserContext& m_context;
+    StyleSheetContents* m_styleSheetContents;
+
     // Outputs:
     Vector<CSSProperty, 256>* m_parsedProperties;
 };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to