LibWeb/MathML: Parse mathml attributes as <length>s

`HTML::parse_dimension_value()` doesn't parse units except for `%` for
percentages; it just ignores them and treats it as a number of pixels.
Now that we can parse `<length>` and pals directly, do that instead,
which makes non-px units work.
This commit is contained in:
Sam Atkins 2025-11-13 14:40:25 +00:00
parent 7aef3245ea
commit 1dfdfa37ea
Notes: github-actions[bot] 2025-11-14 09:56:34 +00:00
4 changed files with 16 additions and 4 deletions

View file

@ -101,7 +101,7 @@ void MathMLElement::apply_presentational_hints(GC::Ref<CSS::CascadedProperties>
// The mathsize attribute, if present, must have a value that is a valid <length-percentage>.
// In that case, the user agent is expected to treat the attribute as a presentational hint setting the
// element's font-size property to the corresponding value.
if (auto parsed_value = HTML::parse_dimension_value(value))
if (auto parsed_value = parse_css_type(CSS::Parser::ParsingParams { document() }, value, CSS::ValueType::LengthPercentage))
cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::FontSize, parsed_value.release_nonnull());
} else if (name == AttributeNames::displaystyle) {
// https://w3c.github.io/mathml-core/#dfn-displaystyle