Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 73c13b9ad315bd8adfc4ae51f3cfe18ae690b343
https://github.com/WebKit/WebKit/commit/73c13b9ad315bd8adfc4ae51f3cfe18ae690b343
Author: Ahmad Saleem <[email protected]>
Date: 2026-10-09 (Fri, 09 Oct 2026)
Changed paths:
A
LayoutTests/imported/w3c/web-platform-tests/css/cssom/adoptedstylesheets-observablearray-removal-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/css/cssom/adoptedstylesheets-observablearray-removal.html
M Source/WebCore/css/CSSStyleSheetObservableArray.cpp
M Source/WebCore/css/CSSStyleSheetObservableArray.h
Log Message:
-----------
adoptedStyleSheets keeps applying removed sheets after length is shrunk, and
stops picking up changes to a sheet after its duplicate is removed
https://bugs.webkit.org/show_bug.cgi?id=326925
rdar://189579103
Reviewed by Antti Koivisto.
This patch aligns WebKit with Gecko / Firefox and Blink / Chromium.
CSSStyleSheetObservableArray::shrinkTo() dropped sheets from m_sheets without
detaching them from the tree scope, so `adoptedStyleSheets.length = n` never
invalidated style and the truncated sheets stayed applied. Overwriting an entry
via `adoptedStyleSheets[i] = sheet` likewise never detached the replaced sheet.
CSSStyleSheet tracks its adopting tree scopes in a WeakHashSet with no
multiplicity, so when a sheet appeared more than once (e.g. [s, s]), removing a
single occurrence via pop() removed the tree scope from the sheet entirely.
Subsequent mutations of the still-adopted sheet (replaceSync(), insertRule())
then failed to invalidate that scope, leaving stale styles.
Replace willRemoveSheet() with didRemoveSheet(), which runs after m_sheets has
been updated and only detaches the tree scope when the sheet no longer appears
in the array. Call it from shrinkTo(), removeLast(), the overwrite path in
setValueAt(), and setSheets().
Test:
imported/w3c/web-platform-tests/css/cssom/adoptedstylesheets-observablearray-removal.html
*
LayoutTests/imported/w3c/web-platform-tests/css/cssom/adoptedstylesheets-observablearray-removal-expected.txt:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/cssom/adoptedstylesheets-observablearray-removal.html:
Added.
* Source/WebCore/css/CSSStyleSheetObservableArray.cpp:
(WebCore::CSSStyleSheetObservableArray::setValueAt):
(WebCore::CSSStyleSheetObservableArray::removeLast):
(WebCore::CSSStyleSheetObservableArray::shrinkTo):
(WebCore::CSSStyleSheetObservableArray::setSheets):
(WebCore::CSSStyleSheetObservableArray::didRemoveSheet):
(WebCore::CSSStyleSheetObservableArray::willRemoveSheet): Deleted.
* Source/WebCore/css/CSSStyleSheetObservableArray.h:
Canonical link: https://commits.webkit.org/323233@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications