Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 2dd7e967bacc31172fcf228e24af776f1e2546b0
      
https://github.com/WebKit/WebKit/commit/2dd7e967bacc31172fcf228e24af776f1e2546b0
  Author: Ahmad Saleem <[email protected]>
  Date:   2026-04-13 (Mon, 13 Apr 2026)

  Changed paths:
    M 
LayoutTests/imported/w3c/web-platform-tests/css/cssom/StyleSheetList-constructable-expected.txt
    A 
LayoutTests/imported/w3c/web-platform-tests/css/cssom/StyleSheetList-constructable-shadow-expected.txt
    A 
LayoutTests/imported/w3c/web-platform-tests/css/cssom/StyleSheetList-constructable-shadow-with-style-recalc-expected.txt
    A 
LayoutTests/imported/w3c/web-platform-tests/css/cssom/StyleSheetList-constructable-shadow-with-style-recalc.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/cssom/StyleSheetList-constructable-shadow.html
    M 
LayoutTests/imported/w3c/web-platform-tests/css/cssom/StyleSheetList-constructable-with-style-recalc-expected.txt
    M Source/WebCore/style/StyleScope.cpp

  Log Message:
  -----------
  document.styleSheets and shadowRoot.styleSheets incorrectly include adopted 
style sheets
https://bugs.webkit.org/show_bug.cgi?id=312074
rdar://174583340

Reviewed by Antti Koivisto.

This patch aligns WebKit with Gecko / Firefox and Blink / Chromium.

Per CSSOM §6.2 [1], the spec defines two separate lists:

"document or shadow root CSS style sheets" — which contains:
  "Any CSS style sheets created from HTTP Link headers, in header order"
  "Any CSS style sheets associated with the DocumentOrShadowRoot, in
    tree order"

"final CSS style sheets" — which contains:
  "The document or shadow root CSS style sheets."
  "The contents of DocumentOrShadowRoot's adoptedStyleSheets' backing
    list, in array order."

The styleSheets attribute (StyleSheetList) should reflect the "document
or shadow root CSS style sheets", not the "final CSS style sheets".

StyleScope::collectActiveStyleSheets() was appending adopted sheets to
both the style resolution list and the StyleSheetList backing store.
Remove the erroneous append to styleSheetsForStyleSheetsList.

[1] https://drafts.csswg.org/cssom/#css-style-sheet-collections

This patch also add new test cases in context of ShadowRoot to ensure that
we don't regress anything.

Tests: 
imported/w3c/web-platform-tests/css/cssom/StyleSheetList-constructable-shadow-with-style-recalc.html
       
imported/w3c/web-platform-tests/css/cssom/StyleSheetList-constructable-shadow.html

* 
LayoutTests/imported/w3c/web-platform-tests/css/cssom/StyleSheetList-constructable-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/css/cssom/StyleSheetList-constructable-shadow-expected.txt:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/cssom/StyleSheetList-constructable-shadow-with-style-recalc-expected.txt:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/cssom/StyleSheetList-constructable-shadow-with-style-recalc.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/cssom/StyleSheetList-constructable-shadow.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/cssom/StyleSheetList-constructable-with-style-recalc-expected.txt:
* Source/WebCore/style/StyleScope.cpp:
(WebCore::Style::Scope::collectActiveStyleSheets):

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to