LibWeb/MathML: Parse mathcolor and mathbackground as <color>

The difference is that parsing as the `color` property's value also
allows the CSS-wide keywords, which we don't want here.

The added test cases make sure that those keywords are *not* valid:
- `color` should inherit its parent value of `orange`
- `background-color` doesn't inherit, so should be its initial value of
  `transparent`
This commit is contained in:
Sam Atkins 2025-11-13 14:53:02 +00:00
parent 2512a934d6
commit e561749164
Notes: github-actions[bot] 2025-11-14 09:56:21 +00:00
3 changed files with 8 additions and 4 deletions

View file

@ -91,10 +91,10 @@ void MathMLElement::apply_presentational_hints(GC::Ref<CSS::CascadedProperties>
// The mathcolor and mathbackground attributes, if present, must have a value that is a <color>. In that case,
// the user agent is expected to treat these attributes as a presentational hint setting the element's color
// and background-color properties to the corresponding values.
if (auto parsed_value = parse_css_value(CSS::Parser::ParsingParams { document() }, value, CSS::PropertyID::Color))
if (auto parsed_value = parse_css_type(CSS::Parser::ParsingParams { document() }, value, CSS::ValueType::Color))
cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::Color, parsed_value.release_nonnull());
} else if (name == AttributeNames::mathbackground) {
if (auto parsed_value = parse_css_value(CSS::Parser::ParsingParams { document() }, value, CSS::PropertyID::BackgroundColor))
if (auto parsed_value = parse_css_type(CSS::Parser::ParsingParams { document() }, value, CSS::ValueType::Color))
cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::BackgroundColor, parsed_value.release_nonnull());
} else if (name == AttributeNames::mathsize) {
// https://w3c.github.io/mathml-core/#dfn-mathsize