LibWeb: Apply type presentational hint for HTMLUListElement

This commit is contained in:
Tim Ledbetter 2025-02-18 14:58:48 +00:00 committed by Tim Ledbetter
commit 74bf7bc28e
Notes: github-actions[bot] 2025-02-21 01:26:31 +00:00
4 changed files with 59 additions and 0 deletions

View file

@ -6,6 +6,7 @@
#include <LibWeb/Bindings/HTMLUListElementPrototype.h>
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
#include <LibWeb/HTML/HTMLUListElement.h>
namespace Web::HTML {
@ -25,4 +26,30 @@ void HTMLUListElement::initialize(JS::Realm& realm)
WEB_SET_PROTOTYPE_FOR_INTERFACE(HTMLUListElement);
}
bool HTMLUListElement::is_presentational_hint(FlyString const& name) const
{
if (Base::is_presentational_hint(name))
return true;
return name == HTML::AttributeNames::type;
}
void HTMLUListElement::apply_presentational_hints(GC::Ref<CSS::CascadedProperties> cascaded_properties) const
{
// https://html.spec.whatwg.org/multipage/rendering.html#lists
for_each_attribute([&](auto& name, auto& value) {
if (name == HTML::AttributeNames::type) {
if (value.equals_ignoring_ascii_case("none"sv)) {
cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::ListStyleType, CSS::CSSKeywordValue::create(CSS::Keyword::None));
} else if (value.equals_ignoring_ascii_case("disc"sv)) {
cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::ListStyleType, CSS::CSSKeywordValue::create(CSS::Keyword::Disc));
} else if (value.equals_ignoring_ascii_case("circle"sv)) {
cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::ListStyleType, CSS::CSSKeywordValue::create(CSS::Keyword::Circle));
} else if (value.equals_ignoring_ascii_case("square"sv)) {
cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::ListStyleType, CSS::CSSKeywordValue::create(CSS::Keyword::Square));
}
}
});
}
}

View file

@ -25,6 +25,9 @@ private:
HTMLUListElement(DOM::Document&, DOM::QualifiedName);
virtual void initialize(JS::Realm&) override;
virtual bool is_presentational_hint(FlyString const&) const override;
virtual void apply_presentational_hints(GC::Ref<CSS::CascadedProperties>) const override;
};
}