Ignore:
Timestamp:
Oct 6, 2018, 6:57:16 AM (7 years ago)
Author:
[email protected]
Message:

Properly determine if css custom property values are computationally independent
https://bugs.webkit.org/show_bug.cgi?id=190303

Patch by Justin Michaud <Justin Michaud> on 2018-10-06
Reviewed by Antti Koivisto.

LayoutTests/imported/w3c:

  • web-platform-tests/css/css-properties-values-api/register-property-syntax-parsing-expected.txt:
  • web-platform-tests/css/css-properties-values-api/registered-property-computation-expected.txt:

Source/WebCore:

Add getDirectComputationalDependencies method to determine if a value is computationally
dependent. Use this method in CSS.registerProperty to replace existing substring checks.
No new tests are needed because the existing tests cover this behaviour.

  • css/CSSCalculationValue.cpp:

(WebCore::determineCategory):

  • css/CSSCalculationValue.h:

(WebCore::CSSCalcValue::getDirectComputationalDependencies const):
(WebCore::CSSCalcValue::getDirectRootComputationalDependencies const):

  • css/CSSCustomPropertyValue.cpp:

(WebCore::CSSCustomPropertyValue::customCSSText const):
(WebCore::CSSCustomPropertyValue::tokens const):
(WebCore::CSSCustomPropertyValue::setResolvedTypedValue):

  • css/CSSCustomPropertyValue.h:
  • css/CSSPrimitiveValue.cpp:

(WebCore::CSSPrimitiveValue::getDirectComputationalDependencies const):
(WebCore::CSSPrimitiveValue::getDirectRootComputationalDependencies const):

  • css/CSSPrimitiveValue.h:
  • css/CSSValue.cpp:

(WebCore::CSSValue::getDirectComputationalDependencies const):
(WebCore::CSSValue::getDirectRootComputationalDependencies const):

  • css/CSSValue.h:
  • css/CSSVariableData.cpp:

(WebCore::CSSVariableData::CSSVariableData):
(WebCore::CSSVariableData::resolveVariableReference const):

  • css/DOMCSSRegisterCustomProperty.cpp:

(WebCore::DOMCSSRegisterCustomProperty::registerProperty):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/css/CSSVariableData.cpp

    r236828 r236895  
    3333#include "CSSCustomPropertyValue.h"
    3434#include "CSSParserTokenRange.h"
    35 #include "CSSTokenizer.h"
    3635#include "CSSValuePool.h"
    3736#include "RenderStyle.h"
     
    8281    : m_needsVariableResolution(needsVariableResolution)
    8382{
    84     ASSERT(!range.atEnd());
    8583    consumeAndUpdateTokens(range);
    8684}
     
    147145    auto* property = style.getCustomProperty(variableName);
    148146    if (property && property->resolvedTypedValue()) {
    149         // FIXME: we should not have to serialize a value that was already resolved.
    150         auto textValue = CSSValuePool::singleton().createValue(*property->resolvedTypedValue(), style)->cssText();
    151         CSSTokenizer tokenizer(textValue);
    152         auto tokenizerRange = tokenizer.tokenRange();
    153         while (!tokenizerRange.atEnd())
    154             result.append(tokenizerRange.consume());
     147        result.appendVector(property->tokens(registeredProperties, style));
    155148        return true;
    156149    }
     
    164157    }
    165158    ASSERT(property);
    166    
    167     if (property->containsVariables()) {
    168         // FIXME: Avoid doing this work more than once.
    169         RefPtr<CSSVariableData> resolvedData = property->value()->resolveVariableReferences(registeredProperties, style);
    170         if (!resolvedData)
    171             return false;
    172         result.appendVector(resolvedData->tokens());
    173     } else
    174         result.appendVector(property->value()->tokens());
     159    result.appendVector(property->tokens(registeredProperties, style));
    175160   
    176161    return true;
Note: See TracChangeset for help on using the changeset viewer.