[webkit-changes] [WebKit/WebKit] 080d12: Correct getComputedStyle() for invalid pseudo-elem...

Anne van Kesteren noreply at github.com
Sun Dec 31 09:33:55 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 080d12dea41b1cb711e6e941f8e04b5a820b8a62
      https://github.com/WebKit/WebKit/commit/080d12dea41b1cb711e6e941f8e04b5a820b8a62
  Author: Anne van Kesteren <annevk at annevk.nl>
  Date:   2023-12-31 (Sun, 31 Dec 2023)

  Changed paths:
    M LayoutTests/fast/css/getComputedStyle/getComputedStyle-with-pseudo-element-expected.txt
    M LayoutTests/fast/css/getComputedStyle/getComputedStyle-with-pseudo-element.html
    M LayoutTests/imported/w3c/web-platform-tests/css/css-highlight-api/highlight-pseudo-computed-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo/highlight-currentcolor-computed-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo/highlight-currentcolor-computed-inheritance-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo/highlight-currentcolor-computed-visited-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo/highlight-pseudos-inheritance-computed-001-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo/highlight-pseudos-visited-computed-001-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-view-transitions/mix-blend-mode-only-on-transition-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-view-transitions/only-child-group-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-view-transitions/only-child-image-pair-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-view-transitions/only-child-new-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-view-transitions/only-child-old-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-view-transitions/style-inheritance-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/cssom/getComputedStyle-pseudo-expected.txt
    M Source/WebCore/css/CSSComputedStyleDeclaration.cpp
    M Source/WebCore/css/CSSComputedStyleDeclaration.h
    M Source/WebCore/page/LocalDOMWindow.cpp

  Log Message:
  -----------
  Correct getComputedStyle() for invalid pseudo-elements
https://bugs.webkit.org/show_bug.cgi?id=243539
rdar://98504661

Reviewed by Tim Nguyen.

Give CSSComputedStyleDeclaration separate constructors for its distinct
callers. Then make CSSComputedStyleDeclaration account for invalid
pseudo-elements by allowing std::nullopt as value for
m_pseudoElementSpecifier. In this state CSSComputedStyleDeclaration
serves as an empty immutable CSSStyleDeclaration.

This appears to be the most straightforward way to create an empty
immutable CSSStyleDeclaration that is exposed to JavaScript in WebKit.
(Various other attempts were made in the creation of this patch, in
particular quite some time went into researching making
ImmutableStyleProperties have some of the features of
MutableStyleProperties.)

The pseudo-element parsing logic is moved to getComputedStyle() as it's
somewhat separate from the function of a CSSComputedStyleDeclaration.
This also matches the model of the specification better.

* LayoutTests/fast/css/getComputedStyle/getComputedStyle-with-pseudo-element-expected.txt:
* LayoutTests/fast/css/getComputedStyle/getComputedStyle-with-pseudo-element.html:
* LayoutTests/imported/w3c/web-platform-tests/css/css-highlight-api/highlight-pseudo-computed-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo/highlight-currentcolor-computed-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo/highlight-currentcolor-computed-inheritance-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo/highlight-currentcolor-computed-visited-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo/highlight-pseudos-inheritance-computed-001-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo/highlight-pseudos-visited-computed-001-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-view-transitions/mix-blend-mode-only-on-transition-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-view-transitions/only-child-group-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-view-transitions/only-child-image-pair-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-view-transitions/only-child-new-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-view-transitions/only-child-old-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-view-transitions/style-inheritance-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/cssom/getComputedStyle-pseudo-expected.txt:
* Source/WebCore/css/CSSComputedStyleDeclaration.cpp:
(WebCore::CSSComputedStyleDeclaration::CSSComputedStyleDeclaration):
(WebCore::CSSComputedStyleDeclaration::create):
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue const):
(WebCore::CSSComputedStyleDeclaration::copyProperties const):
(WebCore::CSSComputedStyleDeclaration::getPropertyValue const):
(WebCore::CSSComputedStyleDeclaration::length const):
(WebCore::CSSComputedStyleDeclaration::item const):
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
(WebCore::CSSComputedStyleDeclaration::getPropertyValue):
* Source/WebCore/css/CSSComputedStyleDeclaration.h:
* Source/WebCore/page/LocalDOMWindow.cpp:
(WebCore::LocalDOMWindow::getComputedStyle const):

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




More information about the webkit-changes mailing list