Registered custom properties should support syntax parameter for <length> and *
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Oct 2018 06:10:59 +0000 (06:10 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Oct 2018 06:10:59 +0000 (06:10 +0000)
commitd1f0bb55cc2c0d76124a50eed97718d9a5d02953
treefb165dbd7bcbd79664074984a89eacc59df285e1
parent53dea20f94b552bd21a1f561c569040c1998d284
Registered custom properties should support syntax parameter for <length> and *
https://bugs.webkit.org/show_bug.cgi?id=190039

Patch by Justin Michaud <justin_michaud@apple.com> on 2018-10-22
Reviewed by Antti Koivisto.

LayoutTests/imported/w3c:

Update WPT test results to fail in a new way.

* web-platform-tests/css/css-properties-values-api/register-property-syntax-parsing-expected.txt:
* web-platform-tests/css/css-properties-values-api/registered-properties-inheritance-expected.txt:
* web-platform-tests/css/css-properties-values-api/registered-property-cssom-expected.txt:
* web-platform-tests/css/css-properties-values-api/typedom.tentative-expected.txt:
* web-platform-tests/css/css-properties-values-api/var-reference-registered-properties-cycles-expected.txt:
* web-platform-tests/css/css-properties-values-api/var-reference-registered-properties-expected.txt:

Source/WebCore:

Refactor code so that:
- All properties applied in StyleResolver::applyMatchedProperties are only applied once.
- Custom properties are only resolved once, in StyleResolver, when they are applied to the RenderStyle. They were previously resolved
  every time they were referenced, and again in RenderStyle.
- The font-size property is applied after its variable references, but before custom properties that depend on it.
- Cycles are detected at the same time as resolution.
- MutableStyleProperties' custom properties cannot be set from Javascript or WebKitLegacy if they do not parse for the property's type.
  If they contain var(--...) references, however, then they can be set because we cannot check if the references are valid from setProperty.
  This behaviour matches chrome, but is not documented in the spec.
- Custom property values have more explicit resolved/unresolved state.
- RenderStyle only ever holds resolved custom properties, and StyleResolver::CascadedProperties only holds unresolved properties.

Tests: css-custom-properties-api/crash.html
       css-custom-properties-api/cycles.html
       css-custom-properties-api/inline.html

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::ComputedStyleExtractor::customPropertyValue):
* css/CSSCustomPropertyValue.cpp:
(WebCore::CSSCustomPropertyValue::equals const):
(WebCore::CSSCustomPropertyValue::customCSSText const):
(WebCore::CSSCustomPropertyValue::tokens const):
(WebCore::CSSCustomPropertyValue::checkVariablesForCycles const): Deleted.
(WebCore::CSSCustomPropertyValue::resolveVariableReferences const): Deleted.
(WebCore::CSSCustomPropertyValue::setResolvedTypedValue): Deleted.
* css/CSSCustomPropertyValue.h:
* css/CSSRegisteredCustomProperty.cpp:
(WebCore::CSSRegisteredCustomProperty::CSSRegisteredCustomProperty):
* css/CSSRegisteredCustomProperty.h:
* css/CSSStyleSheet.h:
* css/CSSVariableData.cpp:
(WebCore::CSSVariableData::CSSVariableData):
(WebCore::CSSVariableData::consumeAndUpdateTokens): Deleted.
(WebCore::CSSVariableData::checkVariablesForCycles const): Deleted.
(WebCore::CSSVariableData::checkVariablesForCyclesWithRange const): Deleted.
(WebCore::CSSVariableData::resolveVariableFallback const): Deleted.
(WebCore::CSSVariableData::resolveVariableReference const): Deleted.
(WebCore::CSSVariableData::resolveVariableReferences const): Deleted.
(WebCore::CSSVariableData::resolveTokenRange const): Deleted.
* css/CSSVariableData.h:
(WebCore::CSSVariableData::create):
(WebCore::CSSVariableData::createResolved): Deleted.
(WebCore::CSSVariableData::needsVariableResolution const): Deleted.
(WebCore::CSSVariableData::CSSVariableData): Deleted.
* css/CSSVariableReferenceValue.cpp:
(WebCore::resolveVariableFallback):
(WebCore::resolveVariableReference):
(WebCore::resolveTokenRange):
(WebCore::CSSVariableReferenceValue::resolveVariableReferences const):
(WebCore::CSSVariableReferenceValue::checkVariablesForCycles const): Deleted.
* css/CSSVariableReferenceValue.h:
(WebCore::CSSVariableReferenceValue::create):
(WebCore::CSSVariableReferenceValue::equals const):
(WebCore::CSSVariableReferenceValue::variableDataValue const): Deleted.
* css/DOMCSSRegisterCustomProperty.cpp:
(WebCore::DOMCSSRegisterCustomProperty::registerProperty):
* css/PropertySetCSSStyleDeclaration.cpp:
(WebCore::PropertySetCSSStyleDeclaration::setProperty):
* css/StyleBuilderCustom.h:
(WebCore::StyleBuilderCustom::applyInitialCustomProperty):
(WebCore::StyleBuilderCustom::applyValueCustomProperty):
* css/StyleProperties.cpp:
(WebCore::MutableStyleProperties::setCustomProperty):
* css/StyleProperties.h:
* css/StyleResolver.cpp:
(WebCore::StyleResolver::State::setStyle):
(WebCore::StyleResolver::styleForKeyframe):
(WebCore::StyleResolver::styleForPage):
(WebCore::StyleResolver::applyMatchedProperties):
(WebCore::StyleResolver::applyPropertyToCurrentStyle):
(WebCore::StyleResolver::applyProperty):
(WebCore::StyleResolver::resolvedVariableValue const):
(WebCore::StyleResolver::CascadedProperties::applyDeferredProperties):
(WebCore::StyleResolver::CascadedProperties::Property::apply):
(WebCore::StyleResolver::applyCascadedCustomProperty):
(WebCore::StyleResolver::applyCascadedProperties):
* css/StyleResolver.h:
* css/parser/CSSParser.cpp:
(WebCore::CSSParser::parseValueWithVariableReferences):
* css/parser/CSSParser.h:
* css/parser/CSSPropertyParser.cpp:
(WebCore::CSSPropertyParser::CSSPropertyParser):
(WebCore::CSSPropertyParser::canParseTypedCustomPropertyValue):
(WebCore::CSSPropertyParser::parseTypedCustomPropertyValue):
(WebCore::CSSPropertyParser::collectParsedCustomPropertyValueDependencies):
(WebCore::CSSPropertyParser::parseValueStart):
(WebCore::CSSPropertyParser::parseSingleValue):
* css/parser/CSSPropertyParser.h:
* css/parser/CSSVariableParser.cpp:
(WebCore::CSSVariableParser::parseDeclarationValue):
* dom/ConstantPropertyMap.cpp:
(WebCore::ConstantPropertyMap::setValueForProperty):
(WebCore::variableDataForPositivePixelLength):
(WebCore::variableDataForPositiveDuration):
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::checkVariablesInCustomProperties): Deleted.
* rendering/style/RenderStyle.h:
(WebCore::RenderStyle::setInheritedCustomPropertyValue):
(WebCore::RenderStyle::setNonInheritedCustomPropertyValue):
* rendering/style/StyleCustomPropertyData.h:
(WebCore::StyleCustomPropertyData::operator== const):
(WebCore::StyleCustomPropertyData::setCustomPropertyValue):
(WebCore::StyleCustomPropertyData::StyleCustomPropertyData):
(): Deleted.

LayoutTests:

Add tests for inline styles, font-size cycles with custom properties, and a crash that was reported.

* css-custom-properties-api/crash-expected.txt: Added.
* css-custom-properties-api/crash.html: Added.
* css-custom-properties-api/cycles-expected.txt: Added.
* css-custom-properties-api/cycles.html: Added.
* css-custom-properties-api/inline-expected.txt: Added.
* css-custom-properties-api/inline.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237347 268f45cc-cd09-0410-ab3c-d52691b4dbfc
40 files changed:
LayoutTests/ChangeLog
LayoutTests/css-custom-properties-api/crash-expected.txt [new file with mode: 0644]
LayoutTests/css-custom-properties-api/crash.html [new file with mode: 0644]
LayoutTests/css-custom-properties-api/cycles-expected.txt [new file with mode: 0644]
LayoutTests/css-custom-properties-api/cycles.html [new file with mode: 0644]
LayoutTests/css-custom-properties-api/inline-expected.txt [new file with mode: 0644]
LayoutTests/css-custom-properties-api/inline.html [new file with mode: 0644]
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/register-property-syntax-parsing-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/registered-properties-inheritance-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/registered-property-cssom-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/typedom.tentative-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/var-reference-registered-properties-cycles-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/var-reference-registered-properties-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Source/WebCore/css/CSSCustomPropertyValue.cpp
Source/WebCore/css/CSSCustomPropertyValue.h
Source/WebCore/css/CSSRegisteredCustomProperty.cpp
Source/WebCore/css/CSSRegisteredCustomProperty.h
Source/WebCore/css/CSSVariableData.cpp
Source/WebCore/css/CSSVariableData.h
Source/WebCore/css/CSSVariableReferenceValue.cpp
Source/WebCore/css/CSSVariableReferenceValue.h
Source/WebCore/css/DOMCSSRegisterCustomProperty.cpp
Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp
Source/WebCore/css/StyleBuilderCustom.h
Source/WebCore/css/StyleProperties.cpp
Source/WebCore/css/StyleProperties.h
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/css/StyleResolver.h
Source/WebCore/css/parser/CSSParser.cpp
Source/WebCore/css/parser/CSSParser.h
Source/WebCore/css/parser/CSSPropertyParser.cpp
Source/WebCore/css/parser/CSSPropertyParser.h
Source/WebCore/css/parser/CSSVariableParser.cpp
Source/WebCore/dom/ConstantPropertyMap.cpp
Source/WebCore/rendering/style/RenderStyle.cpp
Source/WebCore/rendering/style/RenderStyle.h
Source/WebCore/rendering/style/StyleCustomPropertyData.h