mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 17:28:30 +00:00
LibWeb: Implement the color-scheme meta tag name
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include <LibWeb/CSS/Parser/ParsingContext.h>
|
||||
#include <LibWeb/CSS/PropertyID.h>
|
||||
#include <LibWeb/CSS/StyleValues/CSSColorValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/ColorSchemeStyleValue.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/HTML/HTMLMetaElement.h>
|
||||
#include <LibWeb/Infra/CharacterTypes.h>
|
||||
@@ -47,6 +48,23 @@ Optional<HTMLMetaElement::HttpEquivAttributeState> HTMLMetaElement::http_equiv_s
|
||||
return OptionalNone {};
|
||||
}
|
||||
|
||||
void HTMLMetaElement::update_metadata(Optional<String> const& old_name)
|
||||
{
|
||||
if (name().has_value()) {
|
||||
if (name()->equals_ignoring_ascii_case("color-scheme"sv)) {
|
||||
document().obtain_supported_color_schemes();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (old_name.has_value()) {
|
||||
if (old_name->equals_ignoring_ascii_case("color-scheme"sv)) {
|
||||
document().obtain_supported_color_schemes();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HTMLMetaElement::inserted()
|
||||
{
|
||||
Base::inserted();
|
||||
@@ -84,6 +102,8 @@ void HTMLMetaElement::inserted()
|
||||
return;
|
||||
}
|
||||
|
||||
update_metadata();
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/semantics.html#pragma-directives
|
||||
// When a meta element is inserted into the document, if its http-equiv attribute is present and represents one of
|
||||
// the above states, then the user agent must run the algorithm appropriate for that state, as described in the
|
||||
@@ -160,4 +180,20 @@ void HTMLMetaElement::inserted()
|
||||
}
|
||||
}
|
||||
|
||||
void HTMLMetaElement::removed_from(Node* parent)
|
||||
{
|
||||
Base::removed_from(parent);
|
||||
update_metadata();
|
||||
}
|
||||
|
||||
void HTMLMetaElement::attribute_changed(FlyString const& local_name, Optional<String> const& old_value, Optional<String> const& value, Optional<FlyString> const& namespace_)
|
||||
{
|
||||
Base::attribute_changed(local_name, old_value, value, namespace_);
|
||||
if (local_name == HTML::AttributeNames::name) {
|
||||
update_metadata(old_value);
|
||||
} else {
|
||||
update_metadata();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user