Changeset 207903 in webkit


Ignore:
Timestamp:
Oct 26, 2016 10:44:12 AM (7 years ago)
Author:
hyatt@apple.com
Message:

[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.

Location:
trunk/Source/WebCore
Files:
2 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/CMakeLists.txt

    r207901 r207903  
    12701270    css/CSSCursorImageValue.cpp
    12711271    css/CSSCustomIdentValue.cpp
    1272     css/CSSCustomPropertyDeclaration.cpp
    12731272    css/CSSDefaultStyleSheets.cpp
    12741273    css/CSSFilterImageValue.cpp
  • trunk/Source/WebCore/ChangeLog

    r207901 r207903  
     12016-10-26  Dave Hyatt  <hyatt@apple.com>
     2
     3        [CSS Parser] Unify CSSCustomPropertyValue and CSSCustomPropertyDeclaration
     4        https://bugs.webkit.org/show_bug.cgi?id=164019
     5
     6        Reviewed by Zalan Bujtas.
     7
     8        * CMakeLists.txt:
     9        * WebCore.xcodeproj/project.pbxproj:
     10        * css/CSSCustomPropertyDeclaration.cpp: Removed.
     11        * css/CSSCustomPropertyDeclaration.h: Removed.
     12        Get rid of CSSCustomPropertyDeclaration.
     13
     14        * css/CSSCustomPropertyValue.h:
     15        Add new constructors to handle the new variable data format (either a CSSValueId or a
     16        CSSVariableData object that holds parser tokens).
     17
     18        * css/CSSValue.cpp:
     19        (WebCore::CSSValue::cssText):
     20        (WebCore::CSSValue::destroy):
     21        * css/CSSValue.h:
     22        (WebCore::CSSValue::isCustomPropertyDeclaration): Deleted.
     23        Get rid of CSSCustomPropertyDeclaration cases.
     24
     25        * css/CSSVariableData.h:
     26        Switch to CSSCustomPropertyValue.
     27
     28        * css/StyleResolver.cpp:
     29        (WebCore::StyleResolver::applyProperty):
     30        We've renamed the old parser variable data to deprecatedValue to make it clear it's going
     31        to be removed eventually.
     32
     33        * css/parser/CSSParserImpl.cpp:
     34        (WebCore::filterProperties):
     35        (WebCore::CSSParserImpl::consumeVariableValue):
     36        * css/parser/CSSVariableParser.cpp:
     37        (WebCore::CSSVariableParser::parseDeclarationValue):
     38        * css/parser/CSSVariableParser.h:
     39        Switch to CSSCustomPropertyValue.
     40
    1412016-10-26  Youenn Fablet  <youenn@apple.com>
    242
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r207901 r207903  
    34223422                9444CBE31D8861980073A074 /* CSSCustomIdentValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9444CBE21D8861580073A074 /* CSSCustomIdentValue.cpp */; };
    34233423                9444CBE41D8861990073A074 /* CSSCustomIdentValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 9444CBE11D8861580073A074 /* CSSCustomIdentValue.h */; };
    3424                 9444CBE51D8861990073A074 /* CSSCustomPropertyDeclaration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9444CBE01D8861580073A074 /* CSSCustomPropertyDeclaration.cpp */; };
    3425                 9444CBE61D8861990073A074 /* CSSCustomPropertyDeclaration.h in Headers */ = {isa = PBXBuildFile; fileRef = 9444CBDF1D8861580073A074 /* CSSCustomPropertyDeclaration.h */; };
    34263424                9444CBE71D8861C20073A074 /* CSSVariableData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9444CBDE1D8861580073A074 /* CSSVariableData.cpp */; };
    34273425                9444CBE81D8861C20073A074 /* CSSVariableData.h in Headers */ = {isa = PBXBuildFile; fileRef = 9444CBDD1D8861580073A074 /* CSSVariableData.h */; };
     
    94379435                574AC7531DAC367D00E9744C /* CryptoAlgorithmParameters.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CryptoAlgorithmParameters.idl; sourceTree = "<group>"; };
    94389436                574D42791D594FF6002CF50E /* GlobalCrypto.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = GlobalCrypto.idl; sourceTree = "<group>"; };
    9439                 5768E4331DB7524500D0A4F7 /* JSRsaHashedKeyGenParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSRsaHashedKeyGenParams.h; path = JSRsaHashedKeyGenParams.h; sourceTree = "<group>"; };
    9440                 5768E4351DB7527300D0A4F7 /* JSRsaHashedKeyGenParams.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JSRsaHashedKeyGenParams.cpp; path = JSRsaHashedKeyGenParams.cpp; sourceTree = "<group>"; };
     9437                5768E4331DB7524500D0A4F7 /* JSRsaHashedKeyGenParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSRsaHashedKeyGenParams.h; sourceTree = "<group>"; };
     9438                5768E4351DB7527300D0A4F7 /* JSRsaHashedKeyGenParams.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSRsaHashedKeyGenParams.cpp; sourceTree = "<group>"; };
    94419439                577483101DADC49900716EF9 /* AesKeyGenParams.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = AesKeyGenParams.idl; sourceTree = "<group>"; };
    94429440                577483111DADC55D00716EF9 /* CryptoAlgorithmAesKeyGenParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmAesKeyGenParams.h; sourceTree = "<group>"; };
     
    1081510813                9444CBDD1D8861580073A074 /* CSSVariableData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSVariableData.h; sourceTree = "<group>"; };
    1081610814                9444CBDE1D8861580073A074 /* CSSVariableData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSVariableData.cpp; sourceTree = "<group>"; };
    10817                 9444CBDF1D8861580073A074 /* CSSCustomPropertyDeclaration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSCustomPropertyDeclaration.h; sourceTree = "<group>"; };
    10818                 9444CBE01D8861580073A074 /* CSSCustomPropertyDeclaration.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSCustomPropertyDeclaration.cpp; sourceTree = "<group>"; };
    1081910815                9444CBE11D8861580073A074 /* CSSCustomIdentValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSCustomIdentValue.h; sourceTree = "<group>"; };
    1082010816                9444CBE21D8861580073A074 /* CSSCustomIdentValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSCustomIdentValue.cpp; sourceTree = "<group>"; };
     
    2286422860                                9444CBE21D8861580073A074 /* CSSCustomIdentValue.cpp */,
    2286522861                                9444CBE11D8861580073A074 /* CSSCustomIdentValue.h */,
    22866                                 9444CBE01D8861580073A074 /* CSSCustomPropertyDeclaration.cpp */,
    22867                                 9444CBDF1D8861580073A074 /* CSSCustomPropertyDeclaration.h */,
    2286822862                                BC779E131BB215BB00CAA8BF /* CSSCustomPropertyValue.h */,
    2286922863                                4A9CC81516BB9AC600EC645A /* CSSDefaultStyleSheets.cpp */,
     
    2470724701                                AA21ECCD0ABF0FC6002B834C /* CSSCursorImageValue.h in Headers */,
    2470824702                                9444CBE41D8861990073A074 /* CSSCustomIdentValue.h in Headers */,
    24709                                 9444CBE61D8861990073A074 /* CSSCustomPropertyDeclaration.h in Headers */,
    2471024703                                BC779E141BB215BB00CAA8BF /* CSSCustomPropertyValue.h in Headers */,
    2471124704                                4A9CC81816BB9AC600EC645A /* CSSDefaultStyleSheets.h in Headers */,
     
    2848228475                                AA21ECCA0ABF0FBA002B834C /* CSSCursorImageValue.cpp in Sources */,
    2848328476                                9444CBE31D8861980073A074 /* CSSCustomIdentValue.cpp in Sources */,
    28484                                 9444CBE51D8861990073A074 /* CSSCustomPropertyDeclaration.cpp in Sources */,
    2848528477                                4A9CC81716BB9AC600EC645A /* CSSDefaultStyleSheets.cpp in Sources */,
    2848628478                                FBB0C5B717BBD626003D3677 /* CSSFilterImageValue.cpp in Sources */,
  • trunk/Source/WebCore/css/CSSCustomPropertyValue.h

    r205869 r207903  
    2828
    2929#include "CSSValue.h"
     30#include "CSSVariableData.h"
    3031#include <wtf/RefPtr.h>
    3132#include <wtf/text/WTFString.h>
    3233
    33 // FIXME-NEWPARSER: This will be removed in favor of CSSCustomPropertyDeclaration
    3434namespace WebCore {
    3535
     
    3939    {
    4040        return adoptRef(*new CSSCustomPropertyValue(name, WTFMove(value)));
     41    }
     42   
     43    static Ref<CSSCustomPropertyValue> createWithVariableData(const AtomicString& name, Ref<CSSVariableData>&& value)
     44    {
     45        return adoptRef(*new CSSCustomPropertyValue(name, WTFMove(value)));
     46    }
     47   
     48    static Ref<CSSCustomPropertyValue> createWithID(const AtomicString& name, CSSValueID value)
     49    {
     50        return adoptRef(*new CSSCustomPropertyValue(name, value));
    4151    }
    4252   
     
    5060        if (!m_serialized) {
    5161            m_serialized = true;
    52             m_stringValue = m_value ? m_value->cssText() : emptyString();
     62            if (m_deprecatedValue)
     63                m_stringValue = m_deprecatedValue->cssText();
     64            else if (m_value)
     65                m_stringValue = m_value->tokenRange().serialize();
     66            else if (m_valueId != CSSValueInvalid)
     67                m_stringValue = getValueName(m_valueId);
     68            else
     69                m_stringValue = emptyString();
    5370        }
    5471        return m_stringValue;
     
    5774    const AtomicString& name() const { return m_name; }
    5875   
    59     // FIXME: Should arguably implement equals on all of the CSSParserValues, but CSSValue equivalence
    60     // is rarely used, so serialization to compare is probably fine.
     76    // FIXME: Should arguably implement equals on our internal values, but serialization to compare is probably fine.
    6177    bool equals(const CSSCustomPropertyValue& other) const { return m_name == other.m_name && customCSSText() == other.customCSSText(); }
    6278
     
    6480    bool containsVariables() const { return m_containsVariables; }
    6581
    66     const RefPtr<CSSValue> value() const { return m_value.get(); }
     82    const RefPtr<CSSValue> deprecatedValue() const { return m_deprecatedValue.get(); }
    6783
    6884private:
     
    7086        : CSSValue(CustomPropertyClass)
    7187        , m_name(name)
    72         , m_value(WTFMove(value))
    73         , m_containsVariables(m_value->isVariableDependentValue())
     88        , m_deprecatedValue(WTFMove(value))
     89        , m_containsVariables(m_deprecatedValue->isVariableDependentValue())
    7490        , m_serialized(false)
    7591    {
     
    84100    }
    85101
     102    CSSCustomPropertyValue(const AtomicString& name, CSSValueID id)
     103        : CSSValue(CustomPropertyClass)
     104        , m_name(name)
     105        , m_valueId(id)
     106    {
     107        ASSERT(id == CSSValueInherit || id == CSSValueInitial || id == CSSValueUnset || id == CSSValueRevert);
     108    }
     109   
     110    CSSCustomPropertyValue(const AtomicString& name, Ref<CSSVariableData>&& value)
     111        : CSSValue(CustomPropertyClass)
     112        , m_name(name)
     113        , m_value(WTFMove(value))
     114        , m_valueId(CSSValueInternalVariableValue)
     115        , m_containsVariables(m_value->needsVariableResolution())
     116    {
     117    }
     118   
    86119    const AtomicString m_name;
    87     RefPtr<CSSValue> m_value;
     120   
     121    RefPtr<CSSValue> m_deprecatedValue; // Used by old parser
     122    RefPtr<CSSVariableData> m_value; // Used by new parser.
     123    CSSValueID m_valueId { CSSValueInvalid }; // Used by new parser.
     124   
    88125    mutable String m_stringValue;
    89126    bool m_containsVariables { false };
  • trunk/Source/WebCore/css/CSSValue.cpp

    r207479 r207903  
    3838#include "CSSCursorImageValue.h"
    3939#include "CSSCustomIdentValue.h"
    40 #include "CSSCustomPropertyDeclaration.h"
    4140#include "CSSCustomPropertyValue.h"
    4241#include "CSSFilterImageValue.h"
     
    361360    case VariableClass:
    362361        return downcast<CSSVariableValue>(*this).customCSSText();
    363     case CustomPropertyDeclarationClass:
    364         return downcast<CSSCustomPropertyDeclaration>(*this).customCSSText();
    365362    case CustomIdentClass:
    366363        return downcast<CSSCustomIdentValue>(*this).customCSSText();
     
    516513    case VariableClass:
    517514        delete downcast<CSSVariableValue>(this);
    518         return;
    519     case CustomPropertyDeclarationClass:
    520         delete downcast<CSSCustomPropertyDeclaration>(this);
    521515        return;
    522516    case CustomIdentClass:
  • trunk/Source/WebCore/css/CSSValue.h

    r207479 r207903  
    127127#endif
    128128
    129     bool isCustomPropertyDeclaration() const { return m_classType == CustomPropertyDeclarationClass; }
    130129    bool isCustomIdentValue() const { return m_classType == CustomIdentClass; }
    131130    bool isVariableReferenceValue() const { return m_classType == VariableReferenceClass; }
     
    203202        CSSContentDistributionClass,
    204203       
    205         // FIXME-NEWPARSER: Remove in favor of new variables implementation.
     204        CustomIdentClass,
     205
     206        // FIXME-NEWPARSER: Unify variables implementation.
    206207        CustomPropertyClass,
    207208        VariableDependentClass,
     
    209210
    210211        // New variables implementation.
    211         CustomPropertyDeclarationClass,
    212         CustomIdentClass,
    213212        VariableReferenceClass,
    214213        PendingSubstitutionValueClass,
  • trunk/Source/WebCore/css/CSSVariableData.h

    r205869 r207903  
    6464
    6565    // We can safely copy the tokens (which have raw pointers to substrings) because
    66     // StylePropertySets contain references to CSSCustomPropertyDeclarations, which
     66    // StylePropertySets contain references to CSSCustomPropertyValues, which
    6767    // point to the unresolved CSSVariableData values that own the backing strings
    6868    // this will potentially reference.
  • trunk/Source/WebCore/css/StyleResolver.cpp

    r207757 r207903  
    16081608    if (id == CSSPropertyCustom) {
    16091609        customPropertyValue = &downcast<CSSCustomPropertyValue>(*valueToApply);
    1610         valueToCheckForInheritInitial = customPropertyValue->value().get();
     1610        valueToCheckForInheritInitial = customPropertyValue->deprecatedValue().get();
    16111611    }
    16121612
     
    16741674            state.style()->setCustomPropertyValue(customProperty->name(), CSSCustomPropertyValue::createInvalid());
    16751675        else
    1676             state.style()->setCustomPropertyValue(customProperty->name(), customProperty->value());
     1676            state.style()->setCustomPropertyValue(customProperty->name(), customProperty->deprecatedValue());
    16771677        return;
    16781678    }
  • trunk/Source/WebCore/css/parser/CSSParserImpl.cpp

    r207677 r207903  
    3232
    3333#include "CSSAtRuleID.h"
    34 #include "CSSCustomPropertyDeclaration.h"
     34#include "CSSCustomPropertyValue.h"
    3535#include "CSSKeyframeRule.h"
    3636#include "CSSKeyframesRule.h"
     
    9898       
    9999        if (property.id() == CSSPropertyCustom) {
    100             CSSCustomPropertyDeclaration* customValue = downcast<CSSCustomPropertyDeclaration>(property.value());
     100            CSSCustomPropertyValue* customValue = downcast<CSSCustomPropertyValue>(property.value());
    101101            const AtomicString& name = customValue->name();
    102102            if (seenCustomProperties.contains(name))
     
    828828void CSSParserImpl::consumeVariableValue(CSSParserTokenRange range, const AtomicString& variableName, bool important)
    829829{
    830     if (RefPtr<CSSCustomPropertyDeclaration> value = CSSVariableParser::parseDeclarationValue(variableName, range))
     830    if (RefPtr<CSSCustomPropertyValue> value = CSSVariableParser::parseDeclarationValue(variableName, range))
    831831        m_parsedProperties.append(CSSProperty(CSSPropertyCustom, WTFMove(value), important));
    832832}
  • trunk/Source/WebCore/css/parser/CSSVariableParser.cpp

    r205869 r207903  
    3131#include "CSSVariableParser.h"
    3232
    33 #include "CSSCustomPropertyDeclaration.h"
     33#include "CSSCustomPropertyValue.h"
    3434#include "CSSParserTokenRange.h"
    3535
     
    148148}
    149149
    150 RefPtr<CSSCustomPropertyDeclaration> CSSVariableParser::parseDeclarationValue(const AtomicString& variableName, CSSParserTokenRange range)
     150RefPtr<CSSCustomPropertyValue> CSSVariableParser::parseDeclarationValue(const AtomicString& variableName, CSSParserTokenRange range)
    151151{
    152152    if (range.atEnd())
     
    160160        return nullptr;
    161161    if (type == CSSValueInternalVariableValue)
    162         return CSSCustomPropertyDeclaration::create(variableName, CSSVariableData::create(range, hasReferences || hasAtApplyRule));
    163     return CSSCustomPropertyDeclaration::create(variableName, type);
     162        return CSSCustomPropertyValue::createWithVariableData(variableName, CSSVariableData::create(range, hasReferences || hasAtApplyRule));
     163    return CSSCustomPropertyValue::createWithID(variableName, type);
    164164}
    165165
  • trunk/Source/WebCore/css/parser/CSSVariableParser.h

    r205869 r207903  
    3636namespace WebCore {
    3737
    38 class CSSCustomPropertyDeclaration;
     38class CSSCustomPropertyValue;
    3939
    4040class CSSVariableParser {
     
    4242    static bool containsValidVariableReferences(CSSParserTokenRange);
    4343
    44     static RefPtr<CSSCustomPropertyDeclaration> parseDeclarationValue(const AtomicString&, CSSParserTokenRange);
     44    static RefPtr<CSSCustomPropertyValue> parseDeclarationValue(const AtomicString&, CSSParserTokenRange);
    4545
    4646    static bool isValidVariableName(const CSSParserToken&);
  • trunk/Source/WebCore/rendering/style/RenderStyle.cpp

    r207814 r207903  
    20672067    // hold the final values. This way when we inherit, we don't end up resubstituting variables, etc.
    20682068    for (auto& resolvedValue : resolvedValues)
    2069         customProperties.set(resolvedValue->name(), resolvedValue->value());
     2069        customProperties.set(resolvedValue->name(), resolvedValue->deprecatedValue());
    20702070
    20712071    rareInheritedData.access()->m_customProperties.access()->setContainsVariables(false);
Note: See TracChangeset for help on using the changeset viewer.