mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
LibWeb: Add MathML Element presentational hints
This commit is contained in:
parent
f1571c4217
commit
96b34ea744
Notes:
github-actions[bot]
2025-10-21 23:48:01 +00:00
Author: https://github.com/lpas
Commit: 96b34ea744
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6252
Reviewed-by: https://github.com/AtkinsSJ
Reviewed-by: https://github.com/gmta ✅
13 changed files with 380 additions and 2 deletions
41
Libraries/LibWeb/MathML/MathMLMiElement.cpp
Normal file
41
Libraries/LibWeb/MathML/MathMLMiElement.cpp
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Lorenz Ackermann, <me@lorenzackermann.xyz>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/CSS/Parser/Parser.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(GC::Ref<CSS::CascadedProperties> cascaded_properties) const
|
||||
{
|
||||
Base::apply_presentational_hints(cascaded_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)) {
|
||||
cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::TextTransform, CSS::KeywordStyleValue::create(CSS::Keyword::None));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue