[webkit-changes] [WebKit/WebKit] 557b51: [@property] Handle unit cycles correctly

Antti Koivisto noreply at github.com
Thu Dec 29 12:50:14 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 557b51715d46a432b7c3e072299cb24685f6ef0f
      https://github.com/WebKit/WebKit/commit/557b51715d46a432b7c3e072299cb24685f6ef0f
  Author: Antti Koivisto <antti at apple.com>
  Date:   2022-12-29 (Thu, 29 Dec 2022)

  Changed paths:
    M LayoutTests/TestExpectations
    M LayoutTests/css-custom-properties-api/crash.html
    M LayoutTests/css-custom-properties-api/cycles.html
    M LayoutTests/css-custom-properties-api/inherits.html
    M LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/unit-cycles-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/var-reference-registered-properties-cycles-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-variables/variable-substitution-variable-declaration-expected.txt
    M Source/WebCore/css/CSSVariableReferenceValue.cpp
    M Source/WebCore/css/CSSVariableReferenceValue.h
    M Source/WebCore/css/parser/CSSParser.cpp
    M Source/WebCore/css/parser/CSSParser.h
    M Source/WebCore/style/PropertyCascade.h
    M Source/WebCore/style/StyleBuilder.cpp
    M Source/WebCore/style/StyleBuilder.h
    M Source/WebCore/style/StyleBuilderState.h

  Log Message:
  -----------
  [@property] Handle unit cycles correctly
https://bugs.webkit.org/show_bug.cgi?id=247212
rdar://101974818

Reviewed by Simon Fraser.

https://drafts.css-houdini.org/css-properties-values-api/#dependency-cycles

A registered custom property with <length> syntax may use units that depend on another property.
This can create a cycle:

div {
  --my-font-size: 10em;
  font-size: var(--my-font-size);
}

This makes both properties invalid and has to be handled similarly to cycles between custom properties.

The patch also contains some general cleanups to the custom property resolution code.

* LayoutTests/TestExpectations:
* LayoutTests/css-custom-properties-api/crash.html:
* LayoutTests/css-custom-properties-api/cycles.html:
* LayoutTests/css-custom-properties-api/inherits.html:

Update expected results to match the current spec (and Blink).
Registered typed custom properties behave like 'unset' when invalid.

* LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/unit-cycles-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-variables/variable-substitution-variable-declaration-expected.txt:
* Source/WebCore/css/CSSVariableReferenceValue.cpp:
(WebCore::CSSVariableReferenceValue::resolveVariableFallback):
(WebCore::CSSVariableReferenceValue::resolveVariableReference):
(WebCore::CSSVariableReferenceValue::resolveTokenRange):
(WebCore::CSSVariableReferenceValue::resolveVariableReferences const):
(WebCore::resolveVariableFallback): Deleted.
(WebCore::resolveVariableReference): Deleted.
(WebCore::resolveTokenRange): Deleted.

Turn static functions into private members.

* Source/WebCore/css/CSSVariableReferenceValue.h:
* Source/WebCore/css/parser/CSSParser.cpp:
(WebCore::CSSParser::parseValueWithVariableReferences):

Factor into two separate functions.

(WebCore::CSSParser::parseCustomPropertyValueWithVariableReferences):

Detect unit cycles and mark the associated normal property being part of a cycle.

* Source/WebCore/css/parser/CSSParser.h:
* Source/WebCore/style/PropertyCascade.h:
(WebCore::Style::PropertyCascade::customProperty const):

Return a reference instead of a copy.

* Source/WebCore/style/StyleBuilder.cpp:
(WebCore::Style::Builder::applyNonHighPriorityProperties):

Move custom property resolution after all other properties. Any dependent custom properties
will be already resolved by properties using them. This will just resolve the unused ones.

(WebCore::Style::Builder::applyPropertiesImpl):
(WebCore::Style::Builder::applyCustomProperty):

Remove the looping over the link match enum values. Custom properties are not legal is :visited and we anyway keep
only one version in RenderStyle.
Return invalid or unset value based on property registration status.

(WebCore::Style::Builder::applyProperty):

'unset' behaves differently if the property is registered as inherited or not.

(WebCore::Style::Builder::resolveVariableReferences):

Check for unit cycle.

(WebCore::Style::Builder::resolveCustomPropertyValueWithVariableReferences):
(WebCore::Style::Builder::resolveValue): Deleted.
(WebCore::Style::Builder::resolvedVariableValue): Deleted.
* Source/WebCore/style/StyleBuilder.h:
* Source/WebCore/style/StyleBuilderState.h:
(WebCore::Style::BuilderState::inProgressProperties const):
(WebCore::Style::BuilderState::inUnitCycleProperties):

Canonical link: https://commits.webkit.org/258357@main




More information about the webkit-changes mailing list