mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-30 06:06:48 +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/HTMLOListElementPrototype.h>
|
||||||
#include <LibWeb/Bindings/Intrinsics.h>
|
#include <LibWeb/Bindings/Intrinsics.h>
|
||||||
|
#include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
|
||||||
#include <LibWeb/HTML/HTMLOListElement.h>
|
#include <LibWeb/HTML/HTMLOListElement.h>
|
||||||
#include <LibWeb/HTML/Numbers.h>
|
#include <LibWeb/HTML/Numbers.h>
|
||||||
|
|
||||||
|
@ -36,4 +37,32 @@ WebIDL::Long HTMLOListElement::start()
|
||||||
return 1;
|
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);
|
HTMLOListElement(DOM::Document&, DOM::QualifiedName);
|
||||||
|
|
||||||
virtual void initialize(JS::Realm&) override;
|
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;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
<!doctype html>
|
||||||
|
<meta charset=utf-8>
|
||||||
|
<title>ol@type: supported types</title>
|
||||||
|
<style>
|
||||||
|
.decimal {
|
||||||
|
list-style-type: decimal;
|
||||||
|
}
|
||||||
|
.lower-alpha {
|
||||||
|
list-style-type: lower-alpha;
|
||||||
|
}
|
||||||
|
.upper-alpha {
|
||||||
|
list-style-type: upper-alpha;
|
||||||
|
}
|
||||||
|
.lower-roman {
|
||||||
|
list-style-type: lower-roman;
|
||||||
|
}
|
||||||
|
.upper-roman {
|
||||||
|
list-style-type: upper-roman;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<ol class=decimal><li>1<li>2</ol>
|
||||||
|
<ol class=lower-alpha><li>a<li>b</ol>
|
||||||
|
<ol class=upper-alpha><li>A<li>B</ol>
|
||||||
|
<ol class=lower-roman><li>i<li>ii</ol>
|
||||||
|
<ol class=upper-roman><li>I<li>II</ol>
|
|
@ -0,0 +1,9 @@
|
||||||
|
<!doctype html>
|
||||||
|
<meta charset=utf-8>
|
||||||
|
<title>ol@type: supported types</title>
|
||||||
|
<link rel=match href=../../../../../../expected/wpt-import/html/rendering/non-replaced-elements/lists/ol-type-supported-ref.html>
|
||||||
|
<ol type=1><li>1<li>2</ol>
|
||||||
|
<ol type=a><li>a<li>b</ol>
|
||||||
|
<ol type=A><li>A<li>B</ol>
|
||||||
|
<ol type=i><li>i<li>ii</ol>
|
||||||
|
<ol type=I><li>I<li>II</ol>
|
Loading…
Add table
Add a link
Reference in a new issue