@@ -51,14 +51,18 @@ Optional<HTMLMetaElement::HttpEquivAttributeState> HTMLMetaElement::http_equiv_s
51
51
void HTMLMetaElement::update_metadata (Optional<String> const & old_name)
52
52
{
53
53
if (name ().has_value ()) {
54
- if (name ()->equals_ignoring_ascii_case (" color-scheme" sv)) {
54
+ if (name ()->equals_ignoring_ascii_case (" theme-color" sv)) {
55
+ document ().obtain_theme_color ();
56
+ } else if (name ()->equals_ignoring_ascii_case (" color-scheme" sv)) {
55
57
document ().obtain_supported_color_schemes ();
56
58
return ;
57
59
}
58
60
}
59
61
60
62
if (old_name.has_value ()) {
61
- if (old_name->equals_ignoring_ascii_case (" color-scheme" sv)) {
63
+ if (old_name->equals_ignoring_ascii_case (" theme-color" sv)) {
64
+ document ().obtain_theme_color ();
65
+ } else if (old_name->equals_ignoring_ascii_case (" color-scheme" sv)) {
62
66
document ().obtain_supported_color_schemes ();
63
67
return ;
64
68
}
@@ -69,39 +73,6 @@ void HTMLMetaElement::inserted()
69
73
{
70
74
Base::inserted ();
71
75
72
- // https://html.spec.whatwg.org/multipage/semantics.html#meta-theme-color
73
- // 1. To obtain a page's theme color, user agents must run the following steps:
74
- // * The element is in a document tree
75
- // * The element has a name attribute, whose value is an ASCII case-insensitive match for theme-color
76
- // * The element has a content attribute
77
- auto content = attribute (AttributeNames::content);
78
- if (name ().has_value () && name ()->equals_ignoring_ascii_case (" theme-color" sv) && content.has_value ()) {
79
- auto context = CSS::Parser::ParsingContext { document () };
80
-
81
- // 2. For each element in candidate elements:
82
-
83
- // 1. If element has a media attribute and the value of element's media attribute does not match the environment, then continue.
84
- auto media = attribute (AttributeNames::media);
85
- if (media.has_value ()) {
86
- auto query = parse_media_query (context, media.value ());
87
- if (document ().window () && !query->evaluate (*document ().window ()))
88
- return ;
89
- }
90
-
91
- // 2. Let value be the result of stripping leading and trailing ASCII whitespace from the value of element's content attribute.
92
- auto value = content->bytes_as_string_view ().trim (Infra::ASCII_WHITESPACE);
93
-
94
- // 3. Let color be the result of parsing value.
95
- auto css_value = parse_css_value (context, value, CSS::PropertyID::Color);
96
- if (css_value.is_null () || !css_value->is_color ())
97
- return ;
98
- auto color = css_value->to_color ({}); // TODO: Pass a layout node?
99
-
100
- // 4. If color is not failure, then return color.
101
- document ().page ().client ().page_did_change_theme_color (color);
102
- return ;
103
- }
104
-
105
76
update_metadata ();
106
77
107
78
// https://html.spec.whatwg.org/multipage/semantics.html#pragma-directives
0 commit comments