1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-11 10:18:15 +09:00

LibWeb: Invalidate style when CSSStyleRule selectorText changes

Previously, any change to the selectorText of a CSSStyleRule was not
reflected in the document style.
This commit is contained in:
Tim Ledbetter 2024-04-14 23:05:05 +01:00 committed by Andreas Kling
parent 69fa1d1b6e
commit 99b2eff988
Notes: sideshowbarker 2024-07-17 08:25:15 +09:00
4 changed files with 57 additions and 1 deletions

View file

@ -8,6 +8,7 @@
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/CSS/CSSStyleRule.h>
#include <LibWeb/CSS/Parser/Parser.h>
#include <LibWeb/CSS/StyleComputer.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::CSS {
@ -102,8 +103,16 @@ void CSSStyleRule::set_selector_text(StringView selector_text)
auto parsed_selectors = parse_selector(Parser::ParsingContext { realm() }, selector_text);
// 2. If the algorithm returns a non-null value replace the associated group of selectors with the returned value.
if (parsed_selectors.has_value())
if (parsed_selectors.has_value()) {
m_selectors = parsed_selectors.release_value();
if (auto* sheet = parent_style_sheet()) {
if (auto style_sheet_list = sheet->style_sheet_list()) {
auto& document = style_sheet_list->document();
document.style_computer().invalidate_rule_cache();
document.invalidate_style();
}
}
}
// 3. Otherwise, if the algorithm returns a null value, do nothing.
}