Title: [257697] trunk/Source/WebCore
Revision
257697
Author
[email protected]
Date
2020-03-01 16:42:28 -0800 (Sun, 01 Mar 2020)

Log Message

Tighten up CSSPendingSubstitutionValue
https://bugs.webkit.org/show_bug.cgi?id=208421

Reviewed by Anders Carlsson.

* Sources.txt: Removed CSSPendingSubstitutionValue.cpp.
* WebCore.xcodeproj/project.pbxproj: Ditto.
* css/CSSPendingSubstitutionValue.cpp: Removed.

* css/CSSPendingSubstitutionValue.h:
(WebCore::CSSPendingSubstitutionValue::shorthandValue const): Return a reference
instead of a pointer.
(WebCore::CSSPendingSubstitutionValue::equals const): Updated since m_shorthandValue
is now a Ref instead of RefPtr.
(WebCore::CSSPendingSubstitutionValue::customCSSText): Made this a static member
function that always returns an empty string.

* css/StyleProperties.cpp:
(WebCore::StyleProperties::getPropertyValue const): Use auto, scoped variables
so they don't live until the end of the function. Simplified the code and the
comments while retaining as much clarity as possible. Also call getPropertyCSSValue
directly instead of calling getPropertyCSSValueInternal.
(WebCore::StyleProperties::asText const): Use is<> to make the code simpler.
Also updated to use reference instead of pointer from CSSPendingSubstitutionValue.

* css/StyleProperties.cpp:
(WebCore::StyleProperties::borderSpacingValue const): Call getPropertyCSSValue
instead of getPropertyCSSValueInternal.
(WebCore::StyleProperties::getLayeredShorthandValue const): Ditto.
(WebCore::StyleProperties::getShorthandValue const): Ditto.
(WebCore::StyleProperties::getCommonValue const): Ditto.
(WebCore::StyleProperties::pageBreakPropertyValue const): Ditto. Also added a
missing null check.
(WebCore::StyleProperties::getPropertyCSSValue const): Merged with the function
below since all this did was call getPropertyCSSValueInternal.
(WebCore::StyleProperties::getPropertyCSSValueInternal const): Renamed to take
away the word internal and merged with the function above.
(WebCore::ImmutableStyleProperties::findCustomPropertyIndex const): Removed
incorrectly copied and pasted comment.
(WebCore::MutableStyleProperties::findCustomPropertyIndex const): Ditto.
(WebCore::StyleProperties::copyPropertiesInSet const): Call getPropertyCSSValue
instead of getPropertyCSSValueInternal.
* css/StyleProperties.h: Removed getPropertyCSSValueInternal.

* css/parser/CSSParser.cpp:
(WebCore::CSSParser::parseValueWithVariableReferences): Use is<> and fewer locals.

* css/parser/CSSPropertyParser.cpp:
(WebCore::CSSPropertyParser::parseValueStart): Removed a local and made this use
more Ref and less RefPtr.

Modified Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (257696 => 257697)


--- trunk/Source/WebCore/ChangeLog	2020-03-02 00:40:05 UTC (rev 257696)
+++ trunk/Source/WebCore/ChangeLog	2020-03-02 00:42:28 UTC (rev 257697)
@@ -1,5 +1,58 @@
 2020-02-29  Darin Adler  <[email protected]>
 
+        Tighten up CSSPendingSubstitutionValue
+        https://bugs.webkit.org/show_bug.cgi?id=208421
+
+        Reviewed by Anders Carlsson.
+
+        * Sources.txt: Removed CSSPendingSubstitutionValue.cpp.
+        * WebCore.xcodeproj/project.pbxproj: Ditto.
+        * css/CSSPendingSubstitutionValue.cpp: Removed.
+
+        * css/CSSPendingSubstitutionValue.h:
+        (WebCore::CSSPendingSubstitutionValue::shorthandValue const): Return a reference
+        instead of a pointer.
+        (WebCore::CSSPendingSubstitutionValue::equals const): Updated since m_shorthandValue
+        is now a Ref instead of RefPtr.
+        (WebCore::CSSPendingSubstitutionValue::customCSSText): Made this a static member
+        function that always returns an empty string.
+
+        * css/StyleProperties.cpp:
+        (WebCore::StyleProperties::getPropertyValue const): Use auto, scoped variables
+        so they don't live until the end of the function. Simplified the code and the
+        comments while retaining as much clarity as possible. Also call getPropertyCSSValue
+        directly instead of calling getPropertyCSSValueInternal.
+        (WebCore::StyleProperties::asText const): Use is<> to make the code simpler.
+        Also updated to use reference instead of pointer from CSSPendingSubstitutionValue.
+
+        * css/StyleProperties.cpp:
+        (WebCore::StyleProperties::borderSpacingValue const): Call getPropertyCSSValue
+        instead of getPropertyCSSValueInternal.
+        (WebCore::StyleProperties::getLayeredShorthandValue const): Ditto.
+        (WebCore::StyleProperties::getShorthandValue const): Ditto.
+        (WebCore::StyleProperties::getCommonValue const): Ditto.
+        (WebCore::StyleProperties::pageBreakPropertyValue const): Ditto. Also added a
+        missing null check.
+        (WebCore::StyleProperties::getPropertyCSSValue const): Merged with the function
+        below since all this did was call getPropertyCSSValueInternal.
+        (WebCore::StyleProperties::getPropertyCSSValueInternal const): Renamed to take
+        away the word internal and merged with the function above.
+        (WebCore::ImmutableStyleProperties::findCustomPropertyIndex const): Removed
+        incorrectly copied and pasted comment.
+        (WebCore::MutableStyleProperties::findCustomPropertyIndex const): Ditto.
+        (WebCore::StyleProperties::copyPropertiesInSet const): Call getPropertyCSSValue
+        instead of getPropertyCSSValueInternal.
+        * css/StyleProperties.h: Removed getPropertyCSSValueInternal.
+
+        * css/parser/CSSParser.cpp:
+        (WebCore::CSSParser::parseValueWithVariableReferences): Use is<> and fewer locals.
+
+        * css/parser/CSSPropertyParser.cpp:
+        (WebCore::CSSPropertyParser::parseValueStart): Removed a local and made this use
+        more Ref and less RefPtr.
+
+2020-02-29  Darin Adler  <[email protected]>
+
         Move some vectors around instead of heap-allocating them and moving the pointers
         https://bugs.webkit.org/show_bug.cgi?id=208422
 

Modified: trunk/Source/WebCore/Sources.txt (257696 => 257697)


--- trunk/Source/WebCore/Sources.txt	2020-03-02 00:40:05 UTC (rev 257696)
+++ trunk/Source/WebCore/Sources.txt	2020-03-02 00:42:28 UTC (rev 257697)
@@ -721,7 +721,6 @@
 css/CSSNamespaceRule.cpp
 css/CSSPageRule.cpp
 css/CSSPaintImageValue.cpp
-css/CSSPendingSubstitutionValue.cpp
 css/CSSPrimitiveValue.cpp
 css/CSSProperty.cpp
 css/CSSPropertySourceData.cpp

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (257696 => 257697)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-03-02 00:40:05 UTC (rev 257696)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-03-02 00:42:28 UTC (rev 257697)
@@ -10861,7 +10861,6 @@
 		93FDAFC90B11307400E2746F /* EditorInsertAction.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = EditorInsertAction.h; sourceTree = "<group>"; };
 		941827881D8B242200492764 /* StyleColor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StyleColor.cpp; sourceTree = "<group>"; };
 		941827891D8B242200492764 /* StyleColor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleColor.h; sourceTree = "<group>"; };
-		9418278C1D8CAE9500492764 /* CSSPendingSubstitutionValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSPendingSubstitutionValue.cpp; sourceTree = "<group>"; };
 		9418278D1D8CAE9500492764 /* CSSPendingSubstitutionValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSPendingSubstitutionValue.h; sourceTree = "<group>"; };
 		9444CBCF1D860C740073A074 /* SizesCalcParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SizesCalcParser.h; path = parser/SizesCalcParser.h; sourceTree = "<group>"; };
 		9444CBD01D860C740073A074 /* SizesCalcParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SizesCalcParser.cpp; path = parser/SizesCalcParser.cpp; sourceTree = "<group>"; };
@@ -27478,7 +27477,6 @@
 				4B6E87682176D69200420E5E /* CSSPaintImageValue.h */,
 				4BAFD0CA2190EBD600C0AB64 /* CSSPaintSize.h */,
 				4BAFD0CD2190EBE900C0AB64 /* CSSPaintSize.idl */,
-				9418278C1D8CAE9500492764 /* CSSPendingSubstitutionValue.cpp */,
 				9418278D1D8CAE9500492764 /* CSSPendingSubstitutionValue.h */,
 				A80E6CDB0A1989CA007FB8C5 /* CSSPrimitiveValue.cpp */,
 				A80E6CBC0A1989CA007FB8C5 /* CSSPrimitiveValue.h */,

Deleted: trunk/Source/WebCore/css/CSSPendingSubstitutionValue.cpp (257696 => 257697)


--- trunk/Source/WebCore/css/CSSPendingSubstitutionValue.cpp	2020-03-02 00:40:05 UTC (rev 257696)
+++ trunk/Source/WebCore/css/CSSPendingSubstitutionValue.cpp	2020-03-02 00:42:28 UTC (rev 257697)
@@ -1,40 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Copyright (C) 2016 Apple Inc. All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//    * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//    * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//    * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#include "config.h"
-#include "CSSPendingSubstitutionValue.h"
-
-namespace WebCore {
-
-String CSSPendingSubstitutionValue::customCSSText() const
-{
-    return "";
-}
-
-} // namespace WebCore

Modified: trunk/Source/WebCore/css/CSSPendingSubstitutionValue.h (257696 => 257697)


--- trunk/Source/WebCore/css/CSSPendingSubstitutionValue.h	2020-03-02 00:40:05 UTC (rev 257696)
+++ trunk/Source/WebCore/css/CSSPendingSubstitutionValue.h	2020-03-02 00:42:28 UTC (rev 257697)
@@ -42,19 +42,12 @@
         return adoptRef(*new CSSPendingSubstitutionValue(shorthandPropertyId, WTFMove(shorthandValue)));
     }
 
-    CSSVariableReferenceValue* shorthandValue() const
-    {
-        return m_shorthandValue.get();
-    }
+    CSSVariableReferenceValue& shorthandValue() const { return m_shorthandValue; }
+    CSSPropertyID shorthandPropertyId() const { return m_shorthandPropertyId; }
 
-    CSSPropertyID shorthandPropertyId() const
-    {
-        return m_shorthandPropertyId;
-    }
+    bool equals(const CSSPendingSubstitutionValue& other) const { return m_shorthandValue.ptr() == other.m_shorthandValue.ptr(); }
+    static String customCSSText() { return emptyString(); }
 
-    bool equals(const CSSPendingSubstitutionValue& other) const { return m_shorthandValue == other.m_shorthandValue; }
-    String customCSSText() const;
-
 private:
     CSSPendingSubstitutionValue(CSSPropertyID shorthandPropertyId, Ref<CSSVariableReferenceValue>&& shorthandValue)
         : CSSValue(PendingSubstitutionValueClass)
@@ -63,8 +56,8 @@
     {
     }
 
-    CSSPropertyID m_shorthandPropertyId;
-    RefPtr<CSSVariableReferenceValue> m_shorthandValue;
+    const CSSPropertyID m_shorthandPropertyId;
+    Ref<CSSVariableReferenceValue> m_shorthandValue;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/css/StyleProperties.cpp (257696 => 257697)


--- trunk/Source/WebCore/css/StyleProperties.cpp	2020-03-02 00:40:05 UTC (rev 257696)
+++ trunk/Source/WebCore/css/StyleProperties.cpp	2020-03-02 00:42:28 UTC (rev 257697)
@@ -127,8 +127,7 @@
 
 String StyleProperties::getPropertyValue(CSSPropertyID propertyID) const
 {
-    RefPtr<CSSValue> value = getPropertyCSSValue(propertyID);
-    if (value) {
+    if (auto value = getPropertyCSSValue(propertyID)) {
         switch (propertyID) {
         case CSSPropertyFillOpacity:
         case CSSPropertyFloodOpacity:
@@ -135,11 +134,9 @@
         case CSSPropertyOpacity:
         case CSSPropertyStopOpacity:
         case CSSPropertyStrokeOpacity:
-            // Opacity values always serializes as a number.
-            if (value->isPrimitiveValue() && downcast<CSSPrimitiveValue>(value.get())->isPercentage()) {
-                auto doubleValue = downcast<CSSPrimitiveValue>(value.get())->doubleValue();
-                return makeString(doubleValue / 100.0);
-            }
+            // Opacity percentage values serialize as a fraction in the range 0-1, no "%".
+            if (is<CSSPrimitiveValue>(*value) && downcast<CSSPrimitiveValue>(*value).isPercentage())
+                return makeString(downcast<CSSPrimitiveValue>(*value).doubleValue() / 100);
             FALLTHROUGH;
         default:
             return value->cssText();
@@ -146,18 +143,14 @@
         }
     }
 
-    const StylePropertyShorthand& shorthand = shorthandForProperty(propertyID);
-    if (shorthand.length()) {
-        RefPtr<CSSValue> value = getPropertyCSSValueInternal(shorthand.properties()[0]);
-        if (!value || value->isPendingSubstitutionValue())
+    {
+        auto shorthand = shorthandForProperty(propertyID);
+        if (shorthand.length() && is<CSSPendingSubstitutionValue>(getPropertyCSSValue(shorthand.properties()[0])))
             return String();
-    // FIXME: If all longhands are the same css-generic keyword(e.g. initial or inherit),
-    // then the shorthand should be serialized to that keyword.
-    // It seems to be needed to handle this in a single function commonly for all the shorthands,
-    // not in each of the shorthand serialization function.
-    // We could call that function here.
     }
 
+    // FIXME: If all longhands are initial or inherit, the shorthand should be serialized as that keyword.
+
     // Shorthand and 4-values properties
     switch (propertyID) {
     case CSSPropertyAll:
@@ -286,12 +279,10 @@
         return getShorthandValue(perspectiveOriginShorthand());
     case CSSPropertyTransformOrigin:
         return getShorthandValue(transformOriginShorthand());
-    case CSSPropertyMarker: {
-        RefPtr<CSSValue> value = getPropertyCSSValueInternal(CSSPropertyMarkerStart);
-        if (value)
+    case CSSPropertyMarker:
+        if (auto value = getPropertyCSSValue(CSSPropertyMarkerStart))
             return value->cssText();
         return String();
-    }
     case CSSPropertyBorderRadius:
         return get4Values(borderRadiusShorthand());
 #if ENABLE(CSS_SCROLL_SNAP)
@@ -331,8 +322,8 @@
 
 String StyleProperties::borderSpacingValue(const StylePropertyShorthand& shorthand) const
 {
-    RefPtr<CSSValue> horizontalValue = getPropertyCSSValueInternal(shorthand.properties()[0]);
-    RefPtr<CSSValue> verticalValue = getPropertyCSSValueInternal(shorthand.properties()[1]);
+    auto horizontalValue = getPropertyCSSValue(shorthand.properties()[0]);
+    auto verticalValue = getPropertyCSSValue(shorthand.properties()[1]);
 
     // While standard border-spacing property does not allow specifying border-spacing-vertical without
     // specifying border-spacing-horizontal <http://www.w3.org/TR/CSS21/tables.html#separated-borders>,
@@ -517,7 +508,7 @@
     size_t numLayers = 0;
 
     for (unsigned i = 0; i < size; ++i) {
-        values[i] = getPropertyCSSValueInternal(shorthand.properties()[i]);
+        values[i] = getPropertyCSSValue(shorthand.properties()[i]);
         if (!values[i]) {
             // We don't have all longhand properties defined as required for the shorthand
             // property and thus should not serialize to a shorthand value. See spec at
@@ -664,7 +655,7 @@
     StringBuilder result;
     for (unsigned i = 0; i < shorthand.length(); ++i) {
         if (!isPropertyImplicit(shorthand.properties()[i])) {
-            RefPtr<CSSValue> value = getPropertyCSSValueInternal(shorthand.properties()[i]);
+            auto value = getPropertyCSSValue(shorthand.properties()[i]);
             if (!value)
                 return String();
             String valueText = value->cssText();
@@ -687,13 +678,13 @@
     return result.toString();
 }
 
-// only returns a non-null value if all properties have the same, non-null value
+// Returns a non-null value if all properties have the same value.
 String StyleProperties::getCommonValue(const StylePropertyShorthand& shorthand) const
 {
-    String res;
+    String result;
     bool lastPropertyWasImportant = false;
     for (unsigned i = 0; i < shorthand.length(); ++i) {
-        RefPtr<CSSValue> value = getPropertyCSSValueInternal(shorthand.properties()[i]);
+        auto value = getPropertyCSSValue(shorthand.properties()[i]);
         if (!value)
             return String();
         // FIXME: CSSInitialValue::cssText should generate the right value.
@@ -700,17 +691,16 @@
         String text = value->cssText();
         if (text.isNull())
             return String();
-        if (res.isNull())
-            res = text;
-        else if (res != text)
+        if (result.isNull())
+            result = text;
+        else if (result != text)
             return String();
-
         bool currentPropertyIsImportant = propertyIsImportant(shorthand.properties()[i]);
         if (i && lastPropertyWasImportant != currentPropertyIsImportant)
             return String();
         lastPropertyWasImportant = currentPropertyIsImportant;
     }
-    return res;
+    return result;
 }
 
 String StyleProperties::getAlignmentShorthandValue(const StylePropertyShorthand& shorthand) const
@@ -747,7 +737,9 @@
 
 String StyleProperties::pageBreakPropertyValue(const StylePropertyShorthand& shorthand) const
 {
-    RefPtr<CSSValue> value = getPropertyCSSValueInternal(shorthand.properties()[0]);
+    auto value = getPropertyCSSValue(shorthand.properties()[0]);
+    if (!value)
+        return String();
     // FIXME: Remove this isGlobalKeyword check after we do this consistently for all shorthands in getPropertyValue.
     if (value->isGlobalKeyword())
         return value->cssText();
@@ -767,11 +759,6 @@
 
 RefPtr<CSSValue> StyleProperties::getPropertyCSSValue(CSSPropertyID propertyID) const
 {
-    return getPropertyCSSValueInternal(propertyID);
-}
-
-RefPtr<CSSValue> StyleProperties::getPropertyCSSValueInternal(CSSPropertyID propertyID) const
-{
     int foundPropertyIndex = findPropertyIndex(propertyID);
     if (foundPropertyIndex == -1)
         return nullptr;
@@ -1050,10 +1037,10 @@
                 shorthandPropertyID = fallbackProperty;
         };
         
-        if (property.value() && property.value()->isPendingSubstitutionValue()) {
+        if (is<CSSPendingSubstitutionValue>(property.value())) {
             auto& substitutionValue = downcast<CSSPendingSubstitutionValue>(*property.value());
             shorthandPropertyID = substitutionValue.shorthandPropertyId();
-            value = substitutionValue.shorthandValue()->cssText();
+            value = substitutionValue.shorthandValue().cssText();
         } else {
             switch (propertyID) {
             case CSSPropertyAnimationName:
@@ -1467,8 +1454,6 @@
 
 int ImmutableStyleProperties::findCustomPropertyIndex(const String& propertyName) const
 {
-    // Convert the propertyID into an uint16_t to compare it with the metadata's m_propertyID to avoid
-    // the compiler converting it to an int multiple times in the loop.
     for (int n = m_arraySize - 1 ; n >= 0; --n) {
         if (metadataArray()[n].m_propertyID == CSSPropertyCustom) {
             // We found a custom property. See if the name matches.
@@ -1485,8 +1470,6 @@
 
 int MutableStyleProperties::findCustomPropertyIndex(const String& propertyName) const
 {
-    // Convert the propertyID into an uint16_t to compare it with the metadata's m_propertyID to avoid
-    // the compiler converting it to an int multiple times in the loop.
     for (int n = m_propertyVector.size() - 1 ; n >= 0; --n) {
         if (m_propertyVector.at(n).metadata().m_propertyID == CSSPropertyCustom) {
             // We found a custom property. See if the name matches.
@@ -1534,7 +1517,7 @@
     Vector<CSSProperty> list;
     list.reserveInitialCapacity(length);
     for (unsigned i = 0; i < length; ++i) {
-        if (auto value = getPropertyCSSValueInternal(set[i]))
+        if (auto value = getPropertyCSSValue(set[i]))
             list.uncheckedAppend(CSSProperty(set[i], WTFMove(value), false));
     }
     return MutableStyleProperties::create(WTFMove(list));

Modified: trunk/Source/WebCore/css/StyleProperties.h (257696 => 257697)


--- trunk/Source/WebCore/css/StyleProperties.h	2020-03-02 00:40:05 UTC (rev 257696)
+++ trunk/Source/WebCore/css/StyleProperties.h	2020-03-02 00:42:28 UTC (rev 257697)
@@ -45,13 +45,13 @@
 class StyleSheetContents;
 
 enum StylePropertiesType { ImmutablePropertiesType, MutablePropertiesType, DeferredPropertiesType };
-    
+
 class StylePropertiesBase : public RefCounted<StylePropertiesBase> {
 public:
     // Override RefCounted's deref() to ensure operator delete is called on
     // the appropriate subclass type.
     void deref() const;
-    
+
     StylePropertiesType type() const { return static_cast<StylePropertiesType>(m_type); }
 
     CSSParserMode cssParserMode() const { return static_cast<CSSParserMode>(m_cssParserMode); }
@@ -62,13 +62,13 @@
         , m_type(type)
         , m_arraySize(0)
     { }
-    
+
     StylePropertiesBase(CSSParserMode cssParserMode, unsigned immutableArraySize)
         : m_cssParserMode(cssParserMode)
         , m_type(ImmutablePropertiesType)
         , m_arraySize(immutableArraySize)
     { }
-    
+
     unsigned m_cssParserMode : 3;
     mutable unsigned m_type : 2;
     unsigned m_arraySize : 27;
@@ -173,9 +173,7 @@
     String borderSpacingValue(const StylePropertyShorthand&) const;
     String fontValue() const;
     void appendFontLonghandValueIfExplicit(CSSPropertyID, StringBuilder& result, String& value) const;
-    
-    RefPtr<CSSValue> getPropertyCSSValueInternal(CSSPropertyID) const;
-    
+
     friend class PropertySetCSSStyleDeclaration;
 };
 

Modified: trunk/Source/WebCore/css/parser/CSSParser.cpp (257696 => 257697)


--- trunk/Source/WebCore/css/parser/CSSParser.cpp	2020-03-02 00:40:05 UTC (rev 257696)
+++ trunk/Source/WebCore/css/parser/CSSParser.cpp	2020-03-02 00:42:28 UTC (rev 257697)
@@ -208,29 +208,27 @@
     auto direction = style.direction();
     auto writingMode = style.writingMode();
 
-    if (value.isPendingSubstitutionValue()) {
-        // FIXME: Should have a resolvedShorthands cache to stop this from being done
-        // over and over for each longhand value.
-        const CSSPendingSubstitutionValue& pendingSubstitution = downcast<CSSPendingSubstitutionValue>(value);
-        CSSPropertyID shorthandID = pendingSubstitution.shorthandPropertyId();
+    if (is<CSSPendingSubstitutionValue>(value)) {
+        // FIXME: Should have a resolvedShorthands cache to stop this from being done over and over for each longhand value.
+        auto& substitution = downcast<CSSPendingSubstitutionValue>(value);
+
+        auto shorthandID = substitution.shorthandPropertyId();
         if (CSSProperty::isDirectionAwareProperty(shorthandID))
             shorthandID = CSSProperty::resolveDirectionAwareProperty(shorthandID, direction, writingMode);
-        CSSVariableReferenceValue* shorthandValue = pendingSubstitution.shorthandValue();
 
-        auto resolvedData = shorthandValue->resolveVariableReferences(builderState);
+        auto resolvedData = substitution.shorthandValue().resolveVariableReferences(builderState);
         if (!resolvedData)
             return nullptr;
-        Vector<CSSParserToken> resolvedTokens = resolvedData->tokens();
-        
+
         ParsedPropertyVector parsedProperties;
-        if (!CSSPropertyParser::parseValue(shorthandID, false, resolvedTokens, m_context, parsedProperties, StyleRuleType::Style))
+        if (!CSSPropertyParser::parseValue(shorthandID, false, resolvedData->tokens(), m_context, parsedProperties, StyleRuleType::Style))
             return nullptr;
-        
+
         for (auto& property : parsedProperties) {
             if (property.id() == propID)
                 return property.value();
         }
-        
+
         return nullptr;
     }
 

Modified: trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp (257696 => 257697)


--- trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp	2020-03-02 00:40:05 UTC (rev 257696)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp	2020-03-02 00:42:28 UTC (rev 257697)
@@ -328,13 +328,11 @@
     }
 
     if (CSSVariableParser::containsValidVariableReferences(originalRange, m_context)) {
-        RefPtr<CSSVariableReferenceValue> variable = CSSVariableReferenceValue::create(originalRange);
-
-        if (isShorthand) {
-            RefPtr<CSSPendingSubstitutionValue> pendingValue = CSSPendingSubstitutionValue::create(propertyID, variable.releaseNonNull());
-            addExpandedPropertyForValue(propertyID, pendingValue.releaseNonNull(), important);
-        } else
-            addProperty(propertyID, CSSPropertyInvalid, variable.releaseNonNull(), important);
+        auto variable = CSSVariableReferenceValue::create(originalRange);
+        if (isShorthand)
+            addExpandedPropertyForValue(propertyID, CSSPendingSubstitutionValue::create(propertyID, WTFMove(variable)), important);
+        else
+            addProperty(propertyID, CSSPropertyInvalid, WTFMove(variable), important);
         return true;
     }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to