[CSS Parser] Unify CSSCustomPropertyValue and CSSCustomPropertyDeclaration
authorhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Oct 2016 17:44:12 +0000 (17:44 +0000)
committerhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Oct 2016 17:44:12 +0000 (17:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=164019

Reviewed by Zalan Bujtas.

* CMakeLists.txt:
* WebCore.xcodeproj/project.pbxproj:
* css/CSSCustomPropertyDeclaration.cpp: Removed.
* css/CSSCustomPropertyDeclaration.h: Removed.
Get rid of CSSCustomPropertyDeclaration.

* css/CSSCustomPropertyValue.h:
Add new constructors to handle the new variable data format (either a CSSValueId or a
CSSVariableData object that holds parser tokens).

* css/CSSValue.cpp:
(WebCore::CSSValue::cssText):
(WebCore::CSSValue::destroy):
* css/CSSValue.h:
(WebCore::CSSValue::isCustomPropertyDeclaration): Deleted.
Get rid of CSSCustomPropertyDeclaration cases.

* css/CSSVariableData.h:
Switch to CSSCustomPropertyValue.

* css/StyleResolver.cpp:
(WebCore::StyleResolver::applyProperty):
We've renamed the old parser variable data to deprecatedValue to make it clear it's going
to be removed eventually.

* css/parser/CSSParserImpl.cpp:
(WebCore::filterProperties):
(WebCore::CSSParserImpl::consumeVariableValue):
* css/parser/CSSVariableParser.cpp:
(WebCore::CSSVariableParser::parseDeclarationValue):
* css/parser/CSSVariableParser.h:
Switch to CSSCustomPropertyValue.

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

14 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/css/CSSCustomPropertyDeclaration.cpp [deleted file]
Source/WebCore/css/CSSCustomPropertyDeclaration.h [deleted file]
Source/WebCore/css/CSSCustomPropertyValue.h
Source/WebCore/css/CSSValue.cpp
Source/WebCore/css/CSSValue.h
Source/WebCore/css/CSSVariableData.h
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/css/parser/CSSParserImpl.cpp
Source/WebCore/css/parser/CSSVariableParser.cpp
Source/WebCore/css/parser/CSSVariableParser.h
Source/WebCore/rendering/style/RenderStyle.cpp

index e83ab18..4bec77e 100644 (file)
@@ -1269,7 +1269,6 @@ set(WebCore_SOURCES
     css/CSSCrossfadeValue.cpp
     css/CSSCursorImageValue.cpp
     css/CSSCustomIdentValue.cpp
-    css/CSSCustomPropertyDeclaration.cpp
     css/CSSDefaultStyleSheets.cpp
     css/CSSFilterImageValue.cpp
     css/FontFaceSet.cpp
index 18683c8..35783b2 100644 (file)
@@ -1,3 +1,43 @@
+2016-10-26  Dave Hyatt  <hyatt@apple.com>
+
+        [CSS Parser] Unify CSSCustomPropertyValue and CSSCustomPropertyDeclaration
+        https://bugs.webkit.org/show_bug.cgi?id=164019
+
+        Reviewed by Zalan Bujtas.
+
+        * CMakeLists.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * css/CSSCustomPropertyDeclaration.cpp: Removed.
+        * css/CSSCustomPropertyDeclaration.h: Removed.
+        Get rid of CSSCustomPropertyDeclaration.
+
+        * css/CSSCustomPropertyValue.h:
+        Add new constructors to handle the new variable data format (either a CSSValueId or a
+        CSSVariableData object that holds parser tokens).
+
+        * css/CSSValue.cpp:
+        (WebCore::CSSValue::cssText):
+        (WebCore::CSSValue::destroy):
+        * css/CSSValue.h:
+        (WebCore::CSSValue::isCustomPropertyDeclaration): Deleted.
+        Get rid of CSSCustomPropertyDeclaration cases.
+
+        * css/CSSVariableData.h:
+        Switch to CSSCustomPropertyValue.
+
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::applyProperty):
+        We've renamed the old parser variable data to deprecatedValue to make it clear it's going
+        to be removed eventually.
+
+        * css/parser/CSSParserImpl.cpp:
+        (WebCore::filterProperties):
+        (WebCore::CSSParserImpl::consumeVariableValue):
+        * css/parser/CSSVariableParser.cpp:
+        (WebCore::CSSVariableParser::parseDeclarationValue):
+        * css/parser/CSSVariableParser.h:
+        Switch to CSSCustomPropertyValue.
+
 2016-10-26  Youenn Fablet  <youenn@apple.com>
 
         Enable SDPProcessor for Mac bots
index 2171ed4..88453f4 100644 (file)
                9444CBDA1D88483A0073A074 /* CSSVariableParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 9444CBD71D88482A0073A074 /* CSSVariableParser.h */; };
                9444CBE31D8861980073A074 /* CSSCustomIdentValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9444CBE21D8861580073A074 /* CSSCustomIdentValue.cpp */; };
                9444CBE41D8861990073A074 /* CSSCustomIdentValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 9444CBE11D8861580073A074 /* CSSCustomIdentValue.h */; };
-               9444CBE51D8861990073A074 /* CSSCustomPropertyDeclaration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9444CBE01D8861580073A074 /* CSSCustomPropertyDeclaration.cpp */; };
-               9444CBE61D8861990073A074 /* CSSCustomPropertyDeclaration.h in Headers */ = {isa = PBXBuildFile; fileRef = 9444CBDF1D8861580073A074 /* CSSCustomPropertyDeclaration.h */; };
                9444CBE71D8861C20073A074 /* CSSVariableData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9444CBDE1D8861580073A074 /* CSSVariableData.cpp */; };
                9444CBE81D8861C20073A074 /* CSSVariableData.h in Headers */ = {isa = PBXBuildFile; fileRef = 9444CBDD1D8861580073A074 /* CSSVariableData.h */; };
                9444CBE91D8861CA0073A074 /* CSSVariableReferenceValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9444CBDC1D8861580073A074 /* CSSVariableReferenceValue.cpp */; };
                5739E1301DAC7FD100E14383 /* JSCryptoAlgorithmParameters.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCryptoAlgorithmParameters.cpp; sourceTree = "<group>"; };
                574AC7531DAC367D00E9744C /* CryptoAlgorithmParameters.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CryptoAlgorithmParameters.idl; sourceTree = "<group>"; };
                574D42791D594FF6002CF50E /* GlobalCrypto.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = GlobalCrypto.idl; sourceTree = "<group>"; };
-               5768E4331DB7524500D0A4F7 /* JSRsaHashedKeyGenParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSRsaHashedKeyGenParams.h; path = JSRsaHashedKeyGenParams.h; sourceTree = "<group>"; };
-               5768E4351DB7527300D0A4F7 /* JSRsaHashedKeyGenParams.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JSRsaHashedKeyGenParams.cpp; path = JSRsaHashedKeyGenParams.cpp; sourceTree = "<group>"; };
+               5768E4331DB7524500D0A4F7 /* JSRsaHashedKeyGenParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSRsaHashedKeyGenParams.h; sourceTree = "<group>"; };
+               5768E4351DB7527300D0A4F7 /* JSRsaHashedKeyGenParams.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSRsaHashedKeyGenParams.cpp; sourceTree = "<group>"; };
                577483101DADC49900716EF9 /* AesKeyGenParams.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = AesKeyGenParams.idl; sourceTree = "<group>"; };
                577483111DADC55D00716EF9 /* CryptoAlgorithmAesKeyGenParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmAesKeyGenParams.h; sourceTree = "<group>"; };
                577483131DAEC2EA00716EF9 /* JSAesKeyGenParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSAesKeyGenParams.h; sourceTree = "<group>"; };
                9444CBDC1D8861580073A074 /* CSSVariableReferenceValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSVariableReferenceValue.cpp; sourceTree = "<group>"; };
                9444CBDD1D8861580073A074 /* CSSVariableData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSVariableData.h; sourceTree = "<group>"; };
                9444CBDE1D8861580073A074 /* CSSVariableData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSVariableData.cpp; sourceTree = "<group>"; };
-               9444CBDF1D8861580073A074 /* CSSCustomPropertyDeclaration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSCustomPropertyDeclaration.h; sourceTree = "<group>"; };
-               9444CBE01D8861580073A074 /* CSSCustomPropertyDeclaration.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSCustomPropertyDeclaration.cpp; sourceTree = "<group>"; };
                9444CBE11D8861580073A074 /* CSSCustomIdentValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSCustomIdentValue.h; sourceTree = "<group>"; };
                9444CBE21D8861580073A074 /* CSSCustomIdentValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSCustomIdentValue.cpp; sourceTree = "<group>"; };
                946D37281D6CB28B0077084F /* CSSParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CSSParser.cpp; path = parser/CSSParser.cpp; sourceTree = "<group>"; };
                                AA0978EE0ABAA6E100874480 /* CSSCursorImageValue.h */,
                                9444CBE21D8861580073A074 /* CSSCustomIdentValue.cpp */,
                                9444CBE11D8861580073A074 /* CSSCustomIdentValue.h */,
-                               9444CBE01D8861580073A074 /* CSSCustomPropertyDeclaration.cpp */,
-                               9444CBDF1D8861580073A074 /* CSSCustomPropertyDeclaration.h */,
                                BC779E131BB215BB00CAA8BF /* CSSCustomPropertyValue.h */,
                                4A9CC81516BB9AC600EC645A /* CSSDefaultStyleSheets.cpp */,
                                4A9CC81616BB9AC600EC645A /* CSSDefaultStyleSheets.h */,
                                2D8FEBDD143E3EF70072502B /* CSSCrossfadeValue.h in Headers */,
                                AA21ECCD0ABF0FC6002B834C /* CSSCursorImageValue.h in Headers */,
                                9444CBE41D8861990073A074 /* CSSCustomIdentValue.h in Headers */,
-                               9444CBE61D8861990073A074 /* CSSCustomPropertyDeclaration.h in Headers */,
                                BC779E141BB215BB00CAA8BF /* CSSCustomPropertyValue.h in Headers */,
                                4A9CC81816BB9AC600EC645A /* CSSDefaultStyleSheets.h in Headers */,
                                FBB0C5B817BBD629003D3677 /* CSSFilterImageValue.h in Headers */,
                                2D8FEBDC143E3EF70072502B /* CSSCrossfadeValue.cpp in Sources */,
                                AA21ECCA0ABF0FBA002B834C /* CSSCursorImageValue.cpp in Sources */,
                                9444CBE31D8861980073A074 /* CSSCustomIdentValue.cpp in Sources */,
-                               9444CBE51D8861990073A074 /* CSSCustomPropertyDeclaration.cpp in Sources */,
                                4A9CC81716BB9AC600EC645A /* CSSDefaultStyleSheets.cpp in Sources */,
                                FBB0C5B717BBD626003D3677 /* CSSFilterImageValue.cpp in Sources */,
                                BC64B4D50CB4298A005F2B62 /* CSSFontFace.cpp in Sources */,
diff --git a/Source/WebCore/css/CSSCustomPropertyDeclaration.cpp b/Source/WebCore/css/CSSCustomPropertyDeclaration.cpp
deleted file mode 100644 (file)
index c474bf5..0000000
+++ /dev/null
@@ -1,45 +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 "CSSCustomPropertyDeclaration.h"
-
-#include "CSSParserTokenRange.h"
-
-namespace WebCore {
-
-String CSSCustomPropertyDeclaration::customCSSText() const
-{
-    if (m_value)
-        return m_value->tokenRange().serialize();
-    ASSERT(m_valueId != CSSValueInternalVariableValue);
-    return getValueName(m_valueId);
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/css/CSSCustomPropertyDeclaration.h b/Source/WebCore/css/CSSCustomPropertyDeclaration.h
deleted file mode 100644 (file)
index 10ae6c9..0000000
+++ /dev/null
@@ -1,83 +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.
-
-#pragma once
-
-#include "CSSValue.h"
-#include "CSSVariableData.h"
-#include <wtf/RefPtr.h>
-#include <wtf/text/AtomicString.h>
-
-namespace WebCore {
-
-class CSSCustomPropertyDeclaration : public CSSValue {
-public:
-    static Ref<CSSCustomPropertyDeclaration> create(const AtomicString& name, Ref<CSSVariableData>&& value)
-    {
-        return adoptRef(*new CSSCustomPropertyDeclaration(name, WTFMove(value)));
-    }
-
-    static Ref<CSSCustomPropertyDeclaration> create(const AtomicString& name, CSSValueID id)
-    {
-        return adoptRef(*new CSSCustomPropertyDeclaration(name, id));
-    }
-
-    const AtomicString& name() const { return m_name; }
-    CSSVariableData* value() const { return m_value.get(); }
-    CSSValueID id() const { return m_valueId; }
-    String customCSSText() const;
-
-    bool equals(const CSSCustomPropertyDeclaration& other) const { return this == &other; }
-
-private:
-    CSSCustomPropertyDeclaration(const AtomicString& name, CSSValueID id)
-        : CSSValue(CustomPropertyDeclarationClass)
-        , m_name(name)
-        , m_value(nullptr)
-        , m_valueId(id)
-    {
-        ASSERT(id == CSSValueInherit || id == CSSValueInitial || id == CSSValueUnset || id == CSSValueRevert);
-    }
-
-    CSSCustomPropertyDeclaration(const AtomicString& name, Ref<CSSVariableData>&& value)
-        : CSSValue(CustomPropertyDeclarationClass)
-        , m_name(name)
-        , m_value(WTFMove(value))
-        , m_valueId(CSSValueInternalVariableValue)
-    {
-    }
-
-    const AtomicString m_name;
-    RefPtr<CSSVariableData> m_value;
-    CSSValueID m_valueId;
-};
-
-} // namespace WebCore
-
-SPECIALIZE_TYPE_TRAITS_CSS_VALUE(CSSCustomPropertyDeclaration, isCustomPropertyDeclaration())
index bb7794d..9e92bb2 100644 (file)
 #define CSSCustomPropertyValue_h
 
 #include "CSSValue.h"
+#include "CSSVariableData.h"
 #include <wtf/RefPtr.h>
 #include <wtf/text/WTFString.h>
 
-// FIXME-NEWPARSER: This will be removed in favor of CSSCustomPropertyDeclaration
 namespace WebCore {
 
 class CSSCustomPropertyValue final : public CSSValue {
@@ -40,6 +40,16 @@ public:
         return adoptRef(*new CSSCustomPropertyValue(name, WTFMove(value)));
     }
     
+    static Ref<CSSCustomPropertyValue> createWithVariableData(const AtomicString& name, Ref<CSSVariableData>&& value)
+    {
+        return adoptRef(*new CSSCustomPropertyValue(name, WTFMove(value)));
+    }
+    
+    static Ref<CSSCustomPropertyValue> createWithID(const AtomicString& name, CSSValueID value)
+    {
+        return adoptRef(*new CSSCustomPropertyValue(name, value));
+    }
+    
     static Ref<CSSCustomPropertyValue> createInvalid()
     {
         return adoptRef(*new CSSCustomPropertyValue(emptyString(), emptyString()));
@@ -49,28 +59,34 @@ public:
     {
         if (!m_serialized) {
             m_serialized = true;
-            m_stringValue = m_value ? m_value->cssText() : emptyString();
+            if (m_deprecatedValue)
+                m_stringValue = m_deprecatedValue->cssText();
+            else if (m_value)
+                m_stringValue = m_value->tokenRange().serialize();
+            else if (m_valueId != CSSValueInvalid)
+                m_stringValue = getValueName(m_valueId);
+            else
+                m_stringValue = emptyString();
         }
         return m_stringValue;
     }
 
     const AtomicString& name() const { return m_name; }
     
-    // FIXME: Should arguably implement equals on all of the CSSParserValues, but CSSValue equivalence
-    // is rarely used, so serialization to compare is probably fine.
+    // FIXME: Should arguably implement equals on our internal values, but serialization to compare is probably fine.
     bool equals(const CSSCustomPropertyValue& other) const { return m_name == other.m_name && customCSSText() == other.customCSSText(); }
 
     bool isInvalid() const { return !m_value; }
     bool containsVariables() const { return m_containsVariables; }
 
-    const RefPtr<CSSValue> value() const { return m_value.get(); }
+    const RefPtr<CSSValue> deprecatedValue() const { return m_deprecatedValue.get(); }
 
 private:
     CSSCustomPropertyValue(const AtomicString& name, Ref<CSSValue>&& value)
         : CSSValue(CustomPropertyClass)
         , m_name(name)
-        , m_value(WTFMove(value))
-        , m_containsVariables(m_value->isVariableDependentValue())
+        , m_deprecatedValue(WTFMove(value))
+        , m_containsVariables(m_deprecatedValue->isVariableDependentValue())
         , m_serialized(false)
     {
     }
@@ -83,8 +99,29 @@ private:
     {
     }
 
+    CSSCustomPropertyValue(const AtomicString& name, CSSValueID id)
+        : CSSValue(CustomPropertyClass)
+        , m_name(name)
+        , m_valueId(id)
+    {
+        ASSERT(id == CSSValueInherit || id == CSSValueInitial || id == CSSValueUnset || id == CSSValueRevert);
+    }
+    
+    CSSCustomPropertyValue(const AtomicString& name, Ref<CSSVariableData>&& value)
+        : CSSValue(CustomPropertyClass)
+        , m_name(name)
+        , m_value(WTFMove(value))
+        , m_valueId(CSSValueInternalVariableValue)
+        , m_containsVariables(m_value->needsVariableResolution())
+    {
+    }
+    
     const AtomicString m_name;
-    RefPtr<CSSValue> m_value;
+    
+    RefPtr<CSSValue> m_deprecatedValue; // Used by old parser
+    RefPtr<CSSVariableData> m_value; // Used by new parser.
+    CSSValueID m_valueId { CSSValueInvalid }; // Used by new parser.
+    
     mutable String m_stringValue;
     bool m_containsVariables { false };
     mutable bool m_serialized;
index e311786..4edd9ab 100644 (file)
@@ -37,7 +37,6 @@
 #include "CSSCrossfadeValue.h"
 #include "CSSCursorImageValue.h"
 #include "CSSCustomIdentValue.h"
-#include "CSSCustomPropertyDeclaration.h"
 #include "CSSCustomPropertyValue.h"
 #include "CSSFilterImageValue.h"
 #include "CSSFontFaceSrcValue.h"
@@ -360,8 +359,6 @@ String CSSValue::cssText() const
         return downcast<CSSVariableDependentValue>(*this).customCSSText();
     case VariableClass:
         return downcast<CSSVariableValue>(*this).customCSSText();
-    case CustomPropertyDeclarationClass:
-        return downcast<CSSCustomPropertyDeclaration>(*this).customCSSText();
     case CustomIdentClass:
         return downcast<CSSCustomIdentValue>(*this).customCSSText();
     case VariableReferenceClass:
@@ -516,9 +513,6 @@ void CSSValue::destroy()
     case VariableClass:
         delete downcast<CSSVariableValue>(this);
         return;
-    case CustomPropertyDeclarationClass:
-        delete downcast<CSSCustomPropertyDeclaration>(this);
-        return;
     case CustomIdentClass:
         delete downcast<CSSCustomIdentValue>(this);
         return;
index ca74bd4..6f5e4da 100644 (file)
@@ -126,7 +126,6 @@ public:
     bool isAnimationTriggerScrollValue() const { return m_classType == AnimationTriggerScrollClass; }
 #endif
 
-    bool isCustomPropertyDeclaration() const { return m_classType == CustomPropertyDeclarationClass; }
     bool isCustomIdentValue() const { return m_classType == CustomIdentClass; }
     bool isVariableReferenceValue() const { return m_classType == VariableReferenceClass; }
     bool isPendingSubstitutionValue() const { return m_classType == PendingSubstitutionValueClass; }
@@ -202,14 +201,14 @@ protected:
 
         CSSContentDistributionClass,
         
-        // FIXME-NEWPARSER: Remove in favor of new variables implementation.
+        CustomIdentClass,
+
+        // FIXME-NEWPARSER: Unify variables implementation.
         CustomPropertyClass,
         VariableDependentClass,
         VariableClass,
 
         // New variables implementation.
-        CustomPropertyDeclarationClass,
-        CustomIdentClass,
         VariableReferenceClass,
         PendingSubstitutionValueClass,
 
index bb80c53..d6f8bae 100644 (file)
@@ -63,7 +63,7 @@ private:
     CSSVariableData(const CSSParserTokenRange&, bool needsVariableResolution);
 
     // We can safely copy the tokens (which have raw pointers to substrings) because
-    // StylePropertySets contain references to CSSCustomPropertyDeclarations, which
+    // StylePropertySets contain references to CSSCustomPropertyValues, which
     // point to the unresolved CSSVariableData values that own the backing strings
     // this will potentially reference.
     CSSVariableData(const Vector<CSSParserToken>& resolvedTokens, String backingString)
index 847be52..26bbbb7 100644 (file)
@@ -1607,7 +1607,7 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value, SelectorChe
     
     if (id == CSSPropertyCustom) {
         customPropertyValue = &downcast<CSSCustomPropertyValue>(*valueToApply);
-        valueToCheckForInheritInitial = customPropertyValue->value().get();
+        valueToCheckForInheritInitial = customPropertyValue->deprecatedValue().get();
     }
 
     bool isInherit = state.parentStyle() && valueToCheckForInheritInitial->isInheritedValue();
@@ -1673,7 +1673,7 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value, SelectorChe
         } else if (isInitial)
             state.style()->setCustomPropertyValue(customProperty->name(), CSSCustomPropertyValue::createInvalid());
         else
-            state.style()->setCustomPropertyValue(customProperty->name(), customProperty->value());
+            state.style()->setCustomPropertyValue(customProperty->name(), customProperty->deprecatedValue());
         return;
     }
 
index 25e0f6f..f41d1e3 100644 (file)
@@ -31,7 +31,7 @@
 #include "CSSParserImpl.h"
 
 #include "CSSAtRuleID.h"
-#include "CSSCustomPropertyDeclaration.h"
+#include "CSSCustomPropertyValue.h"
 #include "CSSKeyframeRule.h"
 #include "CSSKeyframesRule.h"
 #include "CSSParserObserver.h"
@@ -97,7 +97,7 @@ static inline void filterProperties(bool important, const ParsedPropertyVector&
         const unsigned propertyIDIndex = property.id() - firstCSSProperty;
         
         if (property.id() == CSSPropertyCustom) {
-            CSSCustomPropertyDeclaration* customValue = downcast<CSSCustomPropertyDeclaration>(property.value());
+            CSSCustomPropertyValue* customValue = downcast<CSSCustomPropertyValue>(property.value());
             const AtomicString& name = customValue->name();
             if (seenCustomProperties.contains(name))
                 continue;
@@ -827,7 +827,7 @@ void CSSParserImpl::consumeDeclaration(CSSParserTokenRange range, StyleRule::Typ
 
 void CSSParserImpl::consumeVariableValue(CSSParserTokenRange range, const AtomicString& variableName, bool important)
 {
-    if (RefPtr<CSSCustomPropertyDeclaration> value = CSSVariableParser::parseDeclarationValue(variableName, range))
+    if (RefPtr<CSSCustomPropertyValue> value = CSSVariableParser::parseDeclarationValue(variableName, range))
         m_parsedProperties.append(CSSProperty(CSSPropertyCustom, WTFMove(value), important));
 }
 
index 50a7d48..4cbcd23 100644 (file)
@@ -30,7 +30,7 @@
 #include "config.h"
 #include "CSSVariableParser.h"
 
-#include "CSSCustomPropertyDeclaration.h"
+#include "CSSCustomPropertyValue.h"
 #include "CSSParserTokenRange.h"
 
 namespace WebCore {
@@ -147,7 +147,7 @@ bool CSSVariableParser::containsValidVariableReferences(CSSParserTokenRange rang
     return type == CSSValueInternalVariableValue && hasReferences && !hasAtApplyRule;
 }
 
-RefPtr<CSSCustomPropertyDeclaration> CSSVariableParser::parseDeclarationValue(const AtomicString& variableName, CSSParserTokenRange range)
+RefPtr<CSSCustomPropertyValue> CSSVariableParser::parseDeclarationValue(const AtomicString& variableName, CSSParserTokenRange range)
 {
     if (range.atEnd())
         return nullptr;
@@ -159,8 +159,8 @@ RefPtr<CSSCustomPropertyDeclaration> CSSVariableParser::parseDeclarationValue(co
     if (type == CSSValueInvalid)
         return nullptr;
     if (type == CSSValueInternalVariableValue)
-        return CSSCustomPropertyDeclaration::create(variableName, CSSVariableData::create(range, hasReferences || hasAtApplyRule));
-    return CSSCustomPropertyDeclaration::create(variableName, type);
+        return CSSCustomPropertyValue::createWithVariableData(variableName, CSSVariableData::create(range, hasReferences || hasAtApplyRule));
+    return CSSCustomPropertyValue::createWithID(variableName, type);
 }
 
 } // namespace WebCore
index 0b25926..238ebd6 100644 (file)
 
 namespace WebCore {
 
-class CSSCustomPropertyDeclaration;
+class CSSCustomPropertyValue;
 
 class CSSVariableParser {
 public:
     static bool containsValidVariableReferences(CSSParserTokenRange);
 
-    static RefPtr<CSSCustomPropertyDeclaration> parseDeclarationValue(const AtomicString&, CSSParserTokenRange);
+    static RefPtr<CSSCustomPropertyValue> parseDeclarationValue(const AtomicString&, CSSParserTokenRange);
 
     static bool isValidVariableName(const CSSParserToken&);
     static bool isValidVariableName(const String&);
index 4e32402..0800dcf 100644 (file)
@@ -2066,7 +2066,7 @@ void RenderStyle::checkVariablesInCustomProperties()
     // With all results computed, we can now mutate our table to eliminate the variables and
     // hold the final values. This way when we inherit, we don't end up resubstituting variables, etc.
     for (auto& resolvedValue : resolvedValues)
-        customProperties.set(resolvedValue->name(), resolvedValue->value());
+        customProperties.set(resolvedValue->name(), resolvedValue->deprecatedValue());
 
     rareInheritedData.access()->m_customProperties.access()->setContainsVariables(false);
 }