Title: [190231] trunk/Source/WebCore
Revision
190231
Author
[email protected]
Date
2015-09-24 17:54:24 -0700 (Thu, 24 Sep 2015)

Log Message

Keep the already-parsed list of terms in custom property values so that we don't have to re-parse them
later when doing variable resolution.
https://bugs.webkit.org/show_bug.cgi?id=149544

Reviewed by Dean Jackson.

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::ComputedStyleExtractor::customPropertyValue):
(WebCore::ComputedStyleExtractor::customPropertyText):
Add a helper for getting the raw text. More closely parallels how non-custom properties work with the
extractor.

(WebCore::ComputedStyleExtractor::propertyValue):
Change propertyValue to use customPropertyText.

(WebCore::ComputedStyleExtractor::copyPropertiesInSet):
Don't copy CSS custom properties into the style declaration. This is just used for things like editing, so
we didn't need to be putting the custom properties into this set.

(WebCore::CSSComputedStyleDeclaration::getPropertyValue):
Patched to go straight to the serialized string value.

(WebCore::ComputedStyleExtractor::customPropertyValue): Deleted.
Replaced by customPropertyText.

* css/CSSComputedStyleDeclaration.h:
Rename customPropertyValue to customPropertyText and make it just return a String.

* css/CSSCustomPropertyValue.h:
(WebCore::CSSCustomPropertyValue::create):
(WebCore::CSSCustomPropertyValue::customCSSText):
(WebCore::CSSCustomPropertyValue::name):
(WebCore::CSSCustomPropertyValue::equals):
(WebCore::CSSCustomPropertyValue::CSSCustomPropertyValue):
(WebCore::CSSCustomPropertyValue::value): Deleted.
Changed to hold both a CSSParserValueList, which it adopts from the CSSParser, and a string value that
is constructed lazily only if the value is serialized. Now the problematic serialization code will only
run if someone uses the CSS OM to trigger a serialization (this should be a rare occurrence, so perf
improves with this change).

* css/CSSGrammar.y.in:
Change parsing of custom properties to be identical to regular properties. This refactoring allows
us to simply invoke the parser from style declarations as well and makes everything behave more
similarly to normal property parsing.

* css/CSSParser.cpp:
(WebCore::CSSParser::parseValue):
(WebCore::CSSParser::parseCustomPropertyValue):
(WebCore::CSSParser::parseCustomPropertyDeclaration):
(WebCore::CSSParser::addCustomPropertyDeclaration): Deleted.
* css/CSSParser.h:
(WebCore::CSSParser::setCustomPropertyName):
We now have a method for parsing custom properties that can be invoked from style declarations. The
parser list is now adopted by the CSSCustomPropertyValue.

* css/CSSParserValues.cpp:
(WebCore::CSSParserValueList::toString):
Build the string serialization code right into CSSParserValueList.

* css/CSSParserValues.h:
Add a toString() method for serialization.

* css/StyleProperties.cpp:
(WebCore::MutableStyleProperties::setProperty):
(WebCore::MutableStyleProperties::setCustomProperty):
Changed to use the new CSSParser functions. This makes the code behave almost identically to regular
property parsing.

* css/StyleResolver.cpp:
(WebCore::StyleResolver::applyProperty):
* rendering/style/RenderStyle.h:
* rendering/style/StyleCustomPropertyData.h:
Change the mapping on RenderStyle to store the custom CSS values. This way we can get to the original
parser lists for each variable when it comes time to do variable resolution.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (190230 => 190231)


--- trunk/Source/WebCore/ChangeLog	2015-09-25 00:17:16 UTC (rev 190230)
+++ trunk/Source/WebCore/ChangeLog	2015-09-25 00:54:24 UTC (rev 190231)
@@ -1,3 +1,80 @@
+2015-09-24  David Hyatt  <[email protected]>
+
+        Keep the already-parsed list of terms in custom property values so that we don't have to re-parse them
+        later when doing variable resolution.
+        https://bugs.webkit.org/show_bug.cgi?id=149544
+
+        Reviewed by Dean Jackson.
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::ComputedStyleExtractor::customPropertyValue):
+        (WebCore::ComputedStyleExtractor::customPropertyText):
+        Add a helper for getting the raw text. More closely parallels how non-custom properties work with the
+        extractor.
+
+        (WebCore::ComputedStyleExtractor::propertyValue):
+        Change propertyValue to use customPropertyText.
+
+        (WebCore::ComputedStyleExtractor::copyPropertiesInSet):
+        Don't copy CSS custom properties into the style declaration. This is just used for things like editing, so
+        we didn't need to be putting the custom properties into this set.
+
+        (WebCore::CSSComputedStyleDeclaration::getPropertyValue):
+        Patched to go straight to the serialized string value.
+
+        (WebCore::ComputedStyleExtractor::customPropertyValue): Deleted.
+        Replaced by customPropertyText.
+
+        * css/CSSComputedStyleDeclaration.h:
+        Rename customPropertyValue to customPropertyText and make it just return a String.
+
+        * css/CSSCustomPropertyValue.h:
+        (WebCore::CSSCustomPropertyValue::create):
+        (WebCore::CSSCustomPropertyValue::customCSSText):
+        (WebCore::CSSCustomPropertyValue::name):
+        (WebCore::CSSCustomPropertyValue::equals):
+        (WebCore::CSSCustomPropertyValue::CSSCustomPropertyValue):
+        (WebCore::CSSCustomPropertyValue::value): Deleted.
+        Changed to hold both a CSSParserValueList, which it adopts from the CSSParser, and a string value that
+        is constructed lazily only if the value is serialized. Now the problematic serialization code will only
+        run if someone uses the CSS OM to trigger a serialization (this should be a rare occurrence, so perf
+        improves with this change).
+
+        * css/CSSGrammar.y.in:
+        Change parsing of custom properties to be identical to regular properties. This refactoring allows
+        us to simply invoke the parser from style declarations as well and makes everything behave more
+        similarly to normal property parsing.
+
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseValue):
+        (WebCore::CSSParser::parseCustomPropertyValue):
+        (WebCore::CSSParser::parseCustomPropertyDeclaration):
+        (WebCore::CSSParser::addCustomPropertyDeclaration): Deleted.
+        * css/CSSParser.h:
+        (WebCore::CSSParser::setCustomPropertyName):
+        We now have a method for parsing custom properties that can be invoked from style declarations. The
+        parser list is now adopted by the CSSCustomPropertyValue.
+
+        * css/CSSParserValues.cpp:
+        (WebCore::CSSParserValueList::toString):
+        Build the string serialization code right into CSSParserValueList.
+
+        * css/CSSParserValues.h:
+        Add a toString() method for serialization.
+
+        * css/StyleProperties.cpp:
+        (WebCore::MutableStyleProperties::setProperty):
+        (WebCore::MutableStyleProperties::setCustomProperty):
+        Changed to use the new CSSParser functions. This makes the code behave almost identically to regular
+        property parsing.
+
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::applyProperty):
+        * rendering/style/RenderStyle.h:
+        * rendering/style/StyleCustomPropertyData.h:
+        Change the mapping on RenderStyle to store the custom CSS values. This way we can get to the original
+        parser lists for each variable when it comes time to do variable resolution.
+
 2015-09-24  Chris Dumez  <[email protected]>
 
         Rewrite Range::insertNode() as per the latest DOM specification

Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (190230 => 190231)


--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2015-09-25 00:17:16 UTC (rev 190230)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2015-09-25 00:54:24 UTC (rev 190231)
@@ -2106,10 +2106,15 @@
     if (!style || !style->hasCustomProperty(propertyName))
         return nullptr;
 
-    String result = style->getCustomPropertyValue(propertyName);
-    return CSSCustomPropertyValue::create(propertyName, result);
+    return style->getCustomPropertyValue(propertyName);
 }
 
+String ComputedStyleExtractor::customPropertyText(const String& propertyName) const
+{
+    RefPtr<CSSValue> propertyValue = this->customPropertyValue(propertyName);
+    return propertyValue ? propertyValue->cssText() : emptyString();
+}
+
 RefPtr<CSSValue> ComputedStyleExtractor::propertyValue(CSSPropertyID propertyID, EUpdateLayout updateLayout) const
 {
     Node* styledNode = this->styledNode();
@@ -3595,7 +3600,7 @@
     if (!style)
         return 0;
 
-    const HashMap<AtomicString, String>* customProperties = style->customProperties();
+    const HashMap<AtomicString, RefPtr<CSSValue>>* customProperties = style->customProperties();
     return numComputedProperties + (customProperties ? customProperties->size() : 0);
 }
 
@@ -3704,22 +3709,6 @@
         if (value)
             list.append(CSSProperty(set[i], value.release(), false));
     }
-    
-    auto* styledNode = this->styledNode();
-    if (styledNode) {
-        RefPtr<RenderStyle> style = computeRenderStyleForProperty(styledNode, m_pseudoElementSpecifier, CSSPropertyCustom);
-        if (style) {
-            const auto* customProperties = style->customProperties();
-            if (customProperties) {
-                HashMap<AtomicString, String>::const_iterator end = customProperties->end();
-                for (HashMap<AtomicString, String>::const_iterator it = customProperties->begin(); it != end; ++it) {
-                    RefPtr<CSSCustomPropertyValue> value = CSSCustomPropertyValue::create(it->key, it->value);
-                    list.append(CSSProperty(CSSPropertyCustom, value.release(), false));
-                }
-            }
-        }
-    }
-    
     return MutableStyleProperties::create(list.data(), list.size());
 }
 
@@ -3730,10 +3719,8 @@
 
 RefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(const String& propertyName)
 {
-    if (isCustomPropertyName(propertyName)) {
-        RefPtr<CSSValue> value = ComputedStyleExtractor(m_node, m_allowVisitedStyle, m_pseudoElementSpecifier).customPropertyValue(propertyName);
-        return value ? value->cloneForCSSOM() : nullptr;
-    }
+    if (isCustomPropertyName(propertyName))
+        return ComputedStyleExtractor(m_node, m_allowVisitedStyle, m_pseudoElementSpecifier).customPropertyValue(propertyName);
 
     CSSPropertyID propertyID = cssPropertyID(propertyName);
     if (!propertyID)
@@ -3744,12 +3731,8 @@
 
 String CSSComputedStyleDeclaration::getPropertyValue(const String &propertyName)
 {
-    if (isCustomPropertyName(propertyName)) {
-        RefPtr<CSSValue> value = ComputedStyleExtractor(m_node, m_allowVisitedStyle, m_pseudoElementSpecifier).customPropertyValue(propertyName);
-        if (!value)
-            return String();
-        return value->cssText();
-    }
+    if (isCustomPropertyName(propertyName))
+        return ComputedStyleExtractor(m_node, m_allowVisitedStyle, m_pseudoElementSpecifier).customPropertyText(propertyName);
 
     CSSPropertyID propertyID = cssPropertyID(propertyName);
     if (!propertyID)

Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.h (190230 => 190231)


--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.h	2015-09-25 00:17:16 UTC (rev 190230)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.h	2015-09-25 00:54:24 UTC (rev 190231)
@@ -50,6 +50,7 @@
     ComputedStyleExtractor(PassRefPtr<Node>, bool allowVisitedStyle = false, PseudoId = NOPSEUDO);
 
     RefPtr<CSSValue> propertyValue(CSSPropertyID, EUpdateLayout = UpdateLayout) const;
+    String customPropertyText(const String& propertyName) const;
     RefPtr<CSSValue> customPropertyValue(const String& propertyName) const;
 
     // Helper methods for HTML editing.

Modified: trunk/Source/WebCore/css/CSSCustomPropertyValue.h (190230 => 190231)


--- trunk/Source/WebCore/css/CSSCustomPropertyValue.h	2015-09-25 00:17:16 UTC (rev 190230)
+++ trunk/Source/WebCore/css/CSSCustomPropertyValue.h	2015-09-25 00:54:24 UTC (rev 190231)
@@ -26,34 +26,47 @@
 #ifndef CSSCustomPropertyValue_h
 #define CSSCustomPropertyValue_h
 
+#include "CSSParserValues.h"
 #include "CSSValue.h"
+#include <wtf/text/WTFString.h>
 
 namespace WebCore {
 
 class CSSCustomPropertyValue : public CSSValue {
 public:
-    static Ref<CSSCustomPropertyValue> create(const AtomicString& name, const String& value)
+    static Ref<CSSCustomPropertyValue> create(const AtomicString& name, std::unique_ptr<CSSParserValueList>& valueList)
     {
-        return adoptRef(*new CSSCustomPropertyValue(name, value));
+        return adoptRef(*new CSSCustomPropertyValue(name, valueList));
     }
     
-    bool equals(const CSSCustomPropertyValue& other) const { return m_name == other.m_name && m_value == other.m_value; }
+    String customCSSText() const
+    {
+        if (!m_serialized) {
+            m_serialized = true;
+            m_stringValue = m_parserValue ? m_parserValue->toString() : "";
+        }
+        return m_stringValue;
+    }
 
-    String customCSSText() const { return value(); }
-
     const AtomicString& name() const { return m_name; }
-    const String& value() const { return m_value; }
     
+    // FIXME: Should arguably implement equals on all of the CSSParserValues, but CSSValue equivalence
+    // is rarely used, so serialization to compare is probably fine.
+    bool equals(const CSSCustomPropertyValue& other) const { return m_name == other.m_name && customCSSText() == other.customCSSText(); }
+
 private:
-    CSSCustomPropertyValue(const AtomicString& name, const String& value)
+    CSSCustomPropertyValue(const AtomicString& name, std::unique_ptr<CSSParserValueList>& valueList)
         : CSSValue(CustomPropertyClass)
         , m_name(name)
-        , m_value(value)
+        , m_parserValue(WTF::move(valueList))
+        , m_serialized(false)
     {
     }
 
     const AtomicString m_name;
-    const String m_value;
+    std::unique_ptr<CSSParserValueList> m_parserValue;
+    mutable String m_stringValue;
+    mutable bool m_serialized;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/css/CSSGrammar.y.in (190230 => 190231)


--- trunk/Source/WebCore/css/CSSGrammar.y.in	2015-09-25 00:17:16 UTC (rev 190230)
+++ trunk/Source/WebCore/css/CSSGrammar.y.in	2015-09-25 00:54:24 UTC (rev 190231)
@@ -1539,10 +1539,21 @@
 
 declaration:
     CUSTOM_PROPERTY maybe_space ':' maybe_space expr priority {
+        $$ = false;
+        bool isPropertyParsed = false;
         std::unique_ptr<CSSParserValueList> propertyValue($5);
-        parser->addCustomPropertyDeclaration($1, propertyValue.get(), $6);
-        $$ = true;
-        parser->markPropertyEnd($6, true);
+        if (propertyValue) {
+            parser->m_valueList = WTF::move(propertyValue);
+            int oldParsedProperties = parser->m_parsedProperties.size();
+            parser->setCustomPropertyName($1);
+            $$ = parser->parseValue(CSSPropertyCustom, $6);
+            if (!$$)
+                parser->rollbackLastProperties(parser->m_parsedProperties.size() - oldParsedProperties);
+            else
+                isPropertyParsed = true;
+            parser->m_valueList = nullptr;
+        }
+        parser->markPropertyEnd($6, isPropertyParsed);
     }
     | property ':' maybe_space expr priority {
         $$ = false;

Modified: trunk/Source/WebCore/css/CSSParser.cpp (190230 => 190231)


--- trunk/Source/WebCore/css/CSSParser.cpp	2015-09-25 00:17:16 UTC (rev 190230)
+++ trunk/Source/WebCore/css/CSSParser.cpp	2015-09-25 00:54:24 UTC (rev 190231)
@@ -1351,6 +1351,19 @@
     return parser.parseValue(declaration, propertyID, string, important, contextStyleSheet);
 }
 
+CSSParser::ParseResult CSSParser::parseCustomPropertyValue(MutableStyleProperties* declaration, const AtomicString& propertyName, const String& string, bool important, CSSParserMode cssParserMode, StyleSheetContents* contextStyleSheet)
+{
+    CSSParserContext context(cssParserMode);
+    if (contextStyleSheet) {
+        context = contextStyleSheet->parserContext();
+        context.mode = cssParserMode;
+    }
+
+    CSSParser parser(context);
+    parser.setCustomPropertyName(propertyName);
+    return parser.parseValue(declaration, CSSPropertyCustom, string, important, contextStyleSheet);
+}
+
 CSSParser::ParseResult CSSParser::parseValue(MutableStyleProperties* declaration, CSSPropertyID propertyID, const String& string, bool important, StyleSheetContents* contextStyleSheet)
 {
     setStyleSheet(contextStyleSheet);
@@ -1895,6 +1908,12 @@
 {
     if (!m_valueList || !m_valueList->current())
         return false;
+    
+    if (propId == CSSPropertyCustom) {
+        // FIXME: For now put this ahead of inherit/initial processing.
+        // Eventually we want to support initial and inherit.
+        return parseCustomPropertyDeclaration(important);
+    }
 
     ValueWithCalculation valueWithCalculation(*m_valueList->current());
     CSSValueID id = valueWithCalculation.value().id;
@@ -4137,26 +4156,12 @@
     return false;
 }
 
-void CSSParser::addCustomPropertyDeclaration(const CSSParserString& name, CSSParserValueList* value, bool important)
+bool CSSParser::parseCustomPropertyDeclaration(bool important)
 {
-    if (!value)
-        return;
-
-    // The custom property comes in as a parsed set of CSSParserValues collected into a list.
-    // For CSS variables, we just want to treat the entire set of values as a string, so what we do
-    // is build up a set of CSSValues and serialize them using cssText, separating multiple values
-    // with spaces.
-    AtomicString propertyName = name;
-    StringBuilder builder;
-    for (unsigned i = 0; i < value->size(); i++) {
-        if (i)
-            builder.append(' ');
-        RefPtr<CSSValue> cssValue = value->valueAt(i)->createCSSValue();
-        if (!cssValue)
-            return;
-        builder.append(cssValue->cssText());
-    }
-    addProperty(CSSPropertyCustom, CSSCustomPropertyValue::create(propertyName, builder.toString().lower()), important, false);
+    if (m_customPropertyName.isEmpty() || !m_valueList)
+        return false;
+    addProperty(CSSPropertyCustom, CSSCustomPropertyValue::create(m_customPropertyName, m_valueList), important, false);
+    return true;
 }
 
 // [ <string> | <uri> | <counter> | attr(X) | open-quote | close-quote | no-open-quote | no-close-quote ]+ | inherit

Modified: trunk/Source/WebCore/css/CSSParser.h (190230 => 190231)


--- trunk/Source/WebCore/css/CSSParser.h	2015-09-25 00:17:16 UTC (rev 190230)
+++ trunk/Source/WebCore/css/CSSParser.h	2015-09-25 00:54:24 UTC (rev 190231)
@@ -119,6 +119,7 @@
     bool parseSupportsCondition(const String&);
 
     static ParseResult parseValue(MutableStyleProperties*, CSSPropertyID, const String&, bool important, CSSParserMode, StyleSheetContents*);
+    static ParseResult parseCustomPropertyValue(MutableStyleProperties*, const AtomicString& propertyName, const String&, bool important, CSSParserMode, StyleSheetContents* contextStyleSheet);
 
     static bool parseColor(RGBA32& color, const String&, bool strict = false);
     static bool isValidSystemColorValue(CSSValueID);
@@ -143,7 +144,7 @@
     bool parseQuotes(CSSPropertyID, bool important);
     bool parseAlt(CSSPropertyID, bool important);
     
-    void addCustomPropertyDeclaration(const CSSParserString&, CSSParserValueList*, bool important);
+    bool parseCustomPropertyDeclaration(bool important);
     
     RefPtr<CSSValue> parseAttr(CSSParserValueList& args);
 
@@ -395,6 +396,7 @@
 
     bool m_important;
     CSSPropertyID m_id;
+    AtomicString m_customPropertyName;
     StyleSheetContents* m_styleSheet;
     RefPtr<StyleRuleBase> m_rule;
     RefPtr<StyleKeyframe> m_keyframe;
@@ -466,6 +468,8 @@
     Location currentLocation();
     static bool isCalculation(CSSParserValue&);
 
+    void setCustomPropertyName(const AtomicString& propertyName) { m_customPropertyName = propertyName; }
+
 private:
     bool is8BitSource() { return m_is8BitSource; }
 

Modified: trunk/Source/WebCore/css/CSSParserValues.cpp (190230 => 190231)


--- trunk/Source/WebCore/css/CSSParserValues.cpp	2015-09-25 00:17:16 UTC (rev 190230)
+++ trunk/Source/WebCore/css/CSSParserValues.cpp	2015-09-25 00:54:24 UTC (rev 190231)
@@ -26,6 +26,7 @@
 #include "CSSSelector.h"
 #include "CSSSelectorList.h"
 #include "SelectorPseudoTypeMap.h"
+#include <wtf/text/StringBuilder.h>
 
 namespace WebCore {
 
@@ -66,6 +67,24 @@
         m_values.append(*(valueList.valueAt(i)));
 }
 
+String CSSParserValueList::toString()
+{
+    // Build up a set of CSSValues and serialize them using cssText, separating multiple values
+    // with spaces.
+    // FIXME: Teach CSSParserValues how to serialize so that we don't have to create CSSValues
+    // just to perform this serialization.
+    StringBuilder builder;
+    for (unsigned i = 0; i < size(); i++) {
+        if (i)
+            builder.append(' ');
+        RefPtr<CSSValue> cssValue = valueAt(i)->createCSSValue();
+        if (!cssValue)
+            return "";
+        builder.append(cssValue->cssText());
+    }
+    return builder.toString().lower();
+}
+
 PassRefPtr<CSSValue> CSSParserValue::createCSSValue()
 {
     RefPtr<CSSValue> parsedValue;

Modified: trunk/Source/WebCore/css/CSSParserValues.h (190230 => 190231)


--- trunk/Source/WebCore/css/CSSParserValues.h	2015-09-25 00:17:16 UTC (rev 190230)
+++ trunk/Source/WebCore/css/CSSParserValues.h	2015-09-25 00:54:24 UTC (rev 190231)
@@ -168,6 +168,8 @@
     CSSParserValue* valueAt(unsigned i) { return i < m_values.size() ? &m_values[i] : 0; }
 
     void clear() { m_values.clear(); }
+    
+    String toString();
 
 private:
     unsigned m_current;

Modified: trunk/Source/WebCore/css/StyleProperties.cpp (190230 => 190231)


--- trunk/Source/WebCore/css/StyleProperties.cpp	2015-09-25 00:17:16 UTC (rev 190230)
+++ trunk/Source/WebCore/css/StyleProperties.cpp	2015-09-25 00:54:24 UTC (rev 190231)
@@ -728,7 +728,7 @@
     return CSSParser::parseValue(this, propertyID, value, important, cssParserMode(), contextStyleSheet) == CSSParser::ParseResult::Changed;
 }
 
-bool MutableStyleProperties::setCustomProperty(const String& propertyName, const String& value, bool important, StyleSheetContents* /*contextStyleSheet*/)
+bool MutableStyleProperties::setCustomProperty(const String& propertyName, const String& value, bool important, StyleSheetContents* contextStyleSheet)
 {
     // Setting the value to an empty string just removes the property in both IE and Gecko.
     // Setting it to null seems to produce less consistent results, but we treat it just the same.
@@ -737,10 +737,7 @@
 
     // When replacing an existing property value, this moves the property to the end of the list.
     // Firefox preserves the position, and MSIE moves the property to the beginning.
-    RefPtr<CSSCustomPropertyValue> customValue = CSSCustomPropertyValue::create(propertyName, value);
-    addParsedProperty(CSSProperty(CSSPropertyCustom, customValue, important));
-    
-    return true;
+    return CSSParser::parseCustomPropertyValue(this, propertyName, value, important, cssParserMode(), contextStyleSheet) == CSSParser::ParseResult::Changed;
 }
 
 void MutableStyleProperties::setProperty(CSSPropertyID propertyID, PassRefPtr<CSSValue> prpValue, bool important)

Modified: trunk/Source/WebCore/css/StyleResolver.cpp (190230 => 190231)


--- trunk/Source/WebCore/css/StyleResolver.cpp	2015-09-25 00:17:16 UTC (rev 190230)
+++ trunk/Source/WebCore/css/StyleResolver.cpp	2015-09-25 00:54:24 UTC (rev 190231)
@@ -1901,7 +1901,7 @@
     
     if (id == CSSPropertyCustom) {
         CSSCustomPropertyValue* customProperty = &downcast<CSSCustomPropertyValue>(*value);
-        state.style()->setCustomPropertyValue(customProperty->name(), customProperty->value());
+        state.style()->setCustomPropertyValue(customProperty->name(), value);
         return;
     }
 

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (190230 => 190231)


--- trunk/Source/WebCore/rendering/style/RenderStyle.h	2015-09-25 00:17:16 UTC (rev 190230)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h	2015-09-25 00:54:24 UTC (rev 190231)
@@ -513,10 +513,10 @@
 
     const PseudoStyleCache* cachedPseudoStyles() const { return m_cachedPseudoStyles.get(); }
 
-    void setCustomPropertyValue(const AtomicString& name, const String& value) { rareInheritedData.access()->m_customProperties.access()->setCustomPropertyValue(name, value); }
-    String getCustomPropertyValue(const AtomicString& name) const { return rareInheritedData->m_customProperties->getCustomPropertyValue(name); }
+    void setCustomPropertyValue(const AtomicString& name, const RefPtr<CSSValue>& value) { rareInheritedData.access()->m_customProperties.access()->setCustomPropertyValue(name, value); }
+    RefPtr<CSSValue> getCustomPropertyValue(const AtomicString& name) const { return rareInheritedData->m_customProperties->getCustomPropertyValue(name); }
     bool hasCustomProperty(const AtomicString& name) const { return rareInheritedData->m_customProperties->hasCustomProperty(name); }
-    const HashMap<AtomicString, String>* customProperties() const { return &(rareInheritedData->m_customProperties->m_values); }
+    const HashMap<AtomicString, RefPtr<CSSValue>>* customProperties() const { return &(rareInheritedData->m_customProperties->m_values); }
 
     void setHasViewportUnits(bool hasViewportUnits = true) { noninherited_flags.setHasViewportUnits(hasViewportUnits); }
     bool hasViewportUnits() const { return noninherited_flags.hasViewportUnits(); }

Modified: trunk/Source/WebCore/rendering/style/StyleCustomPropertyData.h (190230 => 190231)


--- trunk/Source/WebCore/rendering/style/StyleCustomPropertyData.h	2015-09-25 00:17:16 UTC (rev 190230)
+++ trunk/Source/WebCore/rendering/style/StyleCustomPropertyData.h	2015-09-25 00:54:24 UTC (rev 190231)
@@ -25,10 +25,13 @@
 #include <wtf/Forward.h>
 #include <wtf/HashMap.h>
 #include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
 #include <wtf/text/AtomicStringHash.h>
 
 namespace WebCore {
 
+class CSSValue;
+
 class StyleCustomPropertyData : public RefCounted<StyleCustomPropertyData> {
 public:
     static Ref<StyleCustomPropertyData> create() { return adoptRef(*new StyleCustomPropertyData); }
@@ -37,11 +40,11 @@
     bool operator==(const StyleCustomPropertyData& o) const { return m_values == o.m_values; }
     bool operator!=(const StyleCustomPropertyData &o) const { return !(*this == o); }
     
-    void setCustomPropertyValue(const AtomicString& name, const String& value) { m_values.set(name, value); }
-    String getCustomPropertyValue(const AtomicString& name) const { return m_values.get(name); }
+    void setCustomPropertyValue(const AtomicString& name, const RefPtr<CSSValue>& value) { m_values.set(name, value); }
+    RefPtr<CSSValue> getCustomPropertyValue(const AtomicString& name) const { return m_values.get(name); }
     bool hasCustomProperty(const AtomicString& name) const { return m_values.contains(name); }
 
-    HashMap<AtomicString, String> m_values;
+    HashMap<AtomicString, RefPtr<CSSValue>> m_values;
     
 private:
     explicit StyleCustomPropertyData()
@@ -49,7 +52,7 @@
     { }
     StyleCustomPropertyData(const StyleCustomPropertyData& other)
         : RefCounted<StyleCustomPropertyData>()
-        , m_values(HashMap<AtomicString, String>(other.m_values))
+        , m_values(HashMap<AtomicString, RefPtr<CSSValue>>(other.m_values))
     { }
 };
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to