mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-11 17:37:33 +02:00
Previously, presentational hints bypassed the regular cascade pipeline and wrote directly into `CascadedProperties` under `CascadeOrigin::Author`. That meant `var()` substitution and the invalid-at-computed-value-time fallback had to be duplicated in a separate per-element pass, which in practice missed the IACVT step and could leave a `GuaranteedInvalidStyleValue` in the cascaded properties. This caused a crash in downstream code that assumed the value had been resolved. This introduces an `AuthorPresentationalHint` cascade origin and feeds them through the cascade as normal declarations. This means that `var()` resolution now happens in only one place.
43 lines
1.6 KiB
C++
43 lines
1.6 KiB
C++
/*
|
|
* Copyright (c) 2025, Lorenz Ackermann, <me@lorenzackermann.xyz>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <LibWeb/CSS/Parser/Parser.h>
|
|
#include <LibWeb/CSS/PropertyID.h>
|
|
#include <LibWeb/CSS/StyleValues/KeywordStyleValue.h>
|
|
#include <LibWeb/HTML/Parser/HTMLParser.h>
|
|
#include <LibWeb/MathML/AttributeNames.h>
|
|
#include <LibWeb/MathML/MathMLMiElement.h>
|
|
|
|
namespace Web::MathML {
|
|
|
|
GC_DEFINE_ALLOCATOR(MathMLMiElement);
|
|
|
|
MathMLMiElement::MathMLMiElement(DOM::Document& document, DOM::QualifiedName qualified_name)
|
|
: MathMLElement(document, move(qualified_name))
|
|
{
|
|
}
|
|
|
|
bool MathMLMiElement::is_presentational_hint(FlyString const& name) const
|
|
{
|
|
if (Base::is_presentational_hint(name))
|
|
return true;
|
|
return first_is_one_of(name, AttributeNames::mathvariant);
|
|
}
|
|
|
|
void MathMLMiElement::apply_presentational_hints(Vector<CSS::StyleProperty>& properties) const
|
|
{
|
|
Base::apply_presentational_hints(properties);
|
|
// https://w3c.github.io/mathml-core/#dfn-mathvariant
|
|
// The mathvariant attribute, if present, must be an ASCII case-insensitive match of normal. In that case, the user
|
|
// agent is expected to treat the attribute as a presentational hint setting the element's text-transform property
|
|
// to none. Otherwise it has no effects.
|
|
if (auto mathvariant = attribute(AttributeNames::mathvariant); mathvariant.has_value() && mathvariant.value().equals_ignoring_ascii_case("normal"sv)) {
|
|
properties.append({ .property_id = CSS::PropertyID::TextTransform, .value = CSS::KeywordStyleValue::create(CSS::Keyword::None) });
|
|
}
|
|
}
|
|
|
|
}
|