mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-22 01:08:56 +00:00
LibWeb: Apply type
presentational hint for HTMLOListElement
This commit is contained in:
parent
1b46a52cfc
commit
7612f2161c
Notes:
github-actions[bot]
2025-02-21 01:26:37 +00:00
Author: https://github.com/tcl3
Commit: 7612f2161c
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3614
4 changed files with 66 additions and 0 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <LibWeb/Bindings/HTMLOListElementPrototype.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
|
||||
#include <LibWeb/HTML/HTMLOListElement.h>
|
||||
#include <LibWeb/HTML/Numbers.h>
|
||||
|
||||
|
@ -36,4 +37,32 @@ WebIDL::Long HTMLOListElement::start()
|
|||
return 1;
|
||||
}
|
||||
|
||||
bool HTMLOListElement::is_presentational_hint(FlyString const& name) const
|
||||
{
|
||||
if (Base::is_presentational_hint(name))
|
||||
return true;
|
||||
|
||||
return name == HTML::AttributeNames::type;
|
||||
}
|
||||
|
||||
void HTMLOListElement::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 == "1"sv) {
|
||||
cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::ListStyleType, CSS::CSSKeywordValue::create(CSS::Keyword::Decimal));
|
||||
} else if (value == "a"sv) {
|
||||
cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::ListStyleType, CSS::CSSKeywordValue::create(CSS::Keyword::LowerAlpha));
|
||||
} else if (value == "A"sv) {
|
||||
cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::ListStyleType, CSS::CSSKeywordValue::create(CSS::Keyword::UpperAlpha));
|
||||
} else if (value == "i"sv) {
|
||||
cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::ListStyleType, CSS::CSSKeywordValue::create(CSS::Keyword::LowerRoman));
|
||||
} else if (value == "I"sv) {
|
||||
cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::ListStyleType, CSS::CSSKeywordValue::create(CSS::Keyword::UpperRoman));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,6 +32,9 @@ private:
|
|||
HTMLOListElement(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;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue