Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 8fb1ba555ff603c2016ec4c9f70f3310052040ad
https://github.com/WebKit/WebKit/commit/8fb1ba555ff603c2016ec4c9f70f3310052040ad
Author: Ahmad Saleem <[email protected]>
Date: 2026-04-13 (Mon, 13 Apr 2026)
Changed paths:
M
LayoutTests/imported/w3c/web-platform-tests/css/cssom/preferred-stylesheet-reversed-order-expected.txt
M Source/WebCore/dom/InlineStyleSheetOwner.cpp
M Source/WebCore/html/HTMLLinkElement.cpp
M Source/WebCore/style/StyleScope.cpp
M Source/WebCore/style/StyleScope.h
Log Message:
-----------
CSSOM "add a CSS style sheet" should establish preferred style sheet set name
at creation time
https://bugs.webkit.org/show_bug.cgi?id=312077
rdar://174586058
Reviewed by Antti Koivisto.
This patch aligns WebKit with Gecko / Firefox and Blink / Chromium.
Per [1], the preferred CSS style sheet set name is set when a sheet is
added: "If the title is not the empty string, the alternate flag is unset,
and preferred CSS style sheet set name is the empty string change the
preferred CSS style sheet set name to the title."
WebKit was determining the preferred name during collectActiveStyleSheets()
by iterating candidate nodes in tree order, so a dynamically inserted
stylesheet placed before the first-added one would incorrectly override
the preferred name.
Fix this by calling establishPreferredStylesheetSetName() at sheet-creation
time in InlineStyleSheetOwner::createSheet and
HTMLLinkElement::initializeStyleSheet, preserving insertion-order semantics.
The existing tree-order determination in collectActiveStyleSheets() is
retained as a fallback for cases where the name was not established at
creation time (e.g. still-loading link elements).
[1] https://drafts.csswg.org/cssom/#add-a-css-style-sheet
*
LayoutTests/imported/w3c/web-platform-tests/css/cssom/preferred-stylesheet-reversed-order-expected.txt:
Progression
* Source/WebCore/dom/InlineStyleSheetOwner.cpp:
(WebCore::InlineStyleSheetOwner::createSheet):
* Source/WebCore/html/HTMLLinkElement.cpp:
(WebCore::HTMLLinkElement::initializeStyleSheet):
* Source/WebCore/style/StyleScope.cpp:
(WebCore::Style::Scope::establishPreferredStylesheetSetName):
* Source/WebCore/style/StyleScope.h:
Canonical link: https://commits.webkit.org/311077@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications