mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
LibWeb: Invalidate style when media content attribute changes
Previously, we would only invalidate style when setting the `media` IDL attribute; changing the attribute via `setAttribute()` and `removeAttribute()` had no immediate effect.
This commit is contained in:
committed by
Alexander Kalenik
parent
0b0f47e320
commit
e1f6a170d5
Notes:
github-actions[bot]
2025-03-22 16:04:49 +00:00
Author: https://github.com/tcl3 Commit: https://github.com/LadybirdBrowser/ladybird/commit/e1f6a170d59 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4047
@@ -52,6 +52,16 @@ void HTMLStyleElement::removed_from(Node* old_parent, Node& old_root)
|
||||
Base::removed_from(old_parent, old_root);
|
||||
}
|
||||
|
||||
void HTMLStyleElement::attribute_changed(FlyString const& name, Optional<String> const& old_value, Optional<String> const& value, Optional<FlyString> const& namespace_)
|
||||
{
|
||||
Base::attribute_changed(name, old_value, value, namespace_);
|
||||
|
||||
if (name == HTML::AttributeNames::media) {
|
||||
if (auto* sheet = m_style_element_utils.sheet())
|
||||
sheet->set_media(value.value_or({}));
|
||||
}
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/semantics.html#dom-style-disabled
|
||||
bool HTMLStyleElement::disabled()
|
||||
{
|
||||
@@ -79,18 +89,6 @@ void HTMLStyleElement::set_disabled(bool disabled)
|
||||
sheet()->set_disabled(disabled);
|
||||
}
|
||||
|
||||
String HTMLStyleElement::media() const
|
||||
{
|
||||
return attribute(HTML::AttributeNames::media).value_or(String {});
|
||||
}
|
||||
|
||||
void HTMLStyleElement::set_media(String media)
|
||||
{
|
||||
(void)set_attribute(HTML::AttributeNames::media, media);
|
||||
if (auto sheet = m_style_element_utils.sheet())
|
||||
sheet->set_media(media);
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/cssom/#dom-linkstyle-sheet
|
||||
CSS::CSSStyleSheet* HTMLStyleElement::sheet()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user