[webkit-changes] [WebKit/WebKit] bb27e4: [@property] Handle dynamic updates to viewport units

Cameron McCormack noreply at github.com
Sat Sep 2 16:10:41 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: bb27e4ae20f7f78a43ef1347c25be6eead488f29
      https://github.com/WebKit/WebKit/commit/bb27e4ae20f7f78a43ef1347c25be6eead488f29
  Author: Cameron McCormack <heycam at apple.com>
  Date:   2023-09-02 (Sat, 02 Sep 2023)

  Changed paths:
    M LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/at-property-viewport-units-dynamic-expected.txt
    M Source/WebCore/css/CSSPrimitiveValue.cpp
    M Source/WebCore/css/CSSRegisteredCustomProperty.h
    M Source/WebCore/css/CSSValue.h
    M Source/WebCore/css/ComputedStyleExtractor.cpp
    M Source/WebCore/css/DOMCSSRegisterCustomProperty.cpp
    M Source/WebCore/style/CustomPropertyRegistry.cpp
    M Source/WebCore/style/CustomPropertyRegistry.h
    M Source/WebCore/style/StyleScope.cpp

  Log Message:
  -----------
  [@property] Handle dynamic updates to viewport units
https://bugs.webkit.org/show_bug.cgi?id=255689
rdar://108287215

Reviewed by Antti Koivisto.

Viewport units are "computationally independent", and so are allowed in
registered custom property initial values. But we don't have any
mechanism to invalidate them when the viewport size changes.

* Source/WebCore/css/CSSPrimitiveValue.cpp:
(WebCore::CSSPrimitiveValue::collectComputedStyleDependencies const):

Record whether the value had any viewport units.

* Source/WebCore/css/CSSRegisteredCustomProperty.h:

Store the CSS parser tokens an initial value was created from if it
it contains viewport units, so that we can re-parse it when the viewport
is resized.

* Source/WebCore/css/CSSValue.h:
(WebCore::ComputedStyleDependencies::isComputationallyIndependent const):
(WebCore::ComputedStyleDependencies::isEmpty const): Deleted.

Rename isEmpty, since we don't want it to look at the new
viewportDimensions member.

* Source/WebCore/css/ComputedStyleExtractor.cpp:
(WebCore::ComputedStyleExtractor::customPropertyValue const):
(WebCore::ComputedStyleExtractor::propertyValue const):

Flush layout in the parent document if there are viewport units used
anywhere in the current document.

* Source/WebCore/css/DOMCSSRegisterCustomProperty.cpp:
(WebCore::DOMCSSRegisterCustomProperty::registerProperty):
* Source/WebCore/style/CustomPropertyRegistry.cpp:
(WebCore::Style::CustomPropertyRegistry::registerFromAPI):
(WebCore::Style::CustomPropertyRegistry::registerFromStylesheet):
(WebCore::Style::CustomPropertyRegistry::parseInitialValue):

Factor out initial value parsing from
DOMCSSRegisterCustomProperty::registerProperty and
CustomPropertyRegistry::registerFromStylesheet into a new function
parseInitialValue, which returns both the newly parsed
CSSCustomPropertyValue as well as whether it contained viewport unit
values.

* Source/WebCore/style/CustomPropertyRegistry.h:
(WebCore::Style::CustomPropertyRegistry::invalidatePropertiesWithViewportUnits):
* Source/WebCore/style/StyleScope.cpp:
(WebCore::Style::Scope::didChangeViewportSize):

Respond to viewport size changes by invalidating all registered custom
properties whose initial value contains viewport units.

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




More information about the webkit-changes mailing list