From f4e0c5395aaa90c5a797930cb3ce906ca508d1fb Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Sun, 28 Apr 2024 16:21:25 +0100 Subject: [PATCH] LibWeb: Don't apply disabled adopted style sheets to the document Previously, we would apply any adopted style sheet to the document if its alternate flag was not set. This meant that all adopted style sheets would be applied, since constructed style sheets never have this flag set. --- .../expected/css/constructed-style-sheets.txt | 1 + .../input/css/constructed-style-sheets.html | 20 +++++++++++++++++++ Userland/Libraries/LibWeb/DOM/Document.cpp | 2 +- 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 Tests/LibWeb/Text/expected/css/constructed-style-sheets.txt create mode 100644 Tests/LibWeb/Text/input/css/constructed-style-sheets.html diff --git a/Tests/LibWeb/Text/expected/css/constructed-style-sheets.txt b/Tests/LibWeb/Text/expected/css/constructed-style-sheets.txt new file mode 100644 index 00000000000..9359dbb8690 --- /dev/null +++ b/Tests/LibWeb/Text/expected/css/constructed-style-sheets.txt @@ -0,0 +1 @@ +Disabled constructed style sheet applies to document: false diff --git a/Tests/LibWeb/Text/input/css/constructed-style-sheets.html b/Tests/LibWeb/Text/input/css/constructed-style-sheets.html new file mode 100644 index 00000000000..64de3f5f029 --- /dev/null +++ b/Tests/LibWeb/Text/input/css/constructed-style-sheets.html @@ -0,0 +1,20 @@ + + + diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index 9e065b17b52..80528f74948 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -4904,7 +4904,7 @@ void Document::for_each_css_style_sheet(Function&& ca if (m_adopted_style_sheets) { m_adopted_style_sheets->for_each([&](auto& style_sheet) { - if (!(style_sheet.is_alternate() && style_sheet.disabled())) + if (!style_sheet.disabled()) callback(style_sheet); }); }