mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-06 16:19:23 +00:00
LibWeb: Improve HTMLSelectElement spec compliance
Set default `size` value according to spec
This commit is contained in:
parent
9d4f3c938f
commit
ad7b2b7c26
Notes:
github-actions[bot]
2024-07-26 08:16:39 +00:00
Author: https://github.com/TSultanov
Commit: ad7b2b7c26
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/832
Reviewed-by: https://github.com/AtkinsSJ ✅
2 changed files with 10 additions and 3 deletions
|
@ -6,7 +6,7 @@
|
||||||
6. "Three"
|
6. "Three"
|
||||||
7. 45
|
7. 45
|
||||||
8. 0
|
8. 0
|
||||||
9. 0
|
9. 1
|
||||||
10. 3
|
10. 3
|
||||||
11. 999
|
11. 999
|
||||||
12. 10
|
12. 10
|
||||||
|
|
|
@ -71,15 +71,22 @@ void HTMLSelectElement::adjust_computed_style(CSS::StyleProperties& style)
|
||||||
style.set_property(CSS::PropertyID::Display, CSS::DisplayStyleValue::create(CSS::Display::from_short(CSS::Display::Short::InlineBlock)));
|
style.set_property(CSS::PropertyID::Display, CSS::DisplayStyleValue::create(CSS::Display::from_short(CSS::Display::Short::InlineBlock)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/form-elements.html#dom-select-size
|
// https://html.spec.whatwg.org/multipage/form-elements.html#concept-select-size
|
||||||
WebIDL::UnsignedLong HTMLSelectElement::size() const
|
WebIDL::UnsignedLong HTMLSelectElement::size() const
|
||||||
{
|
{
|
||||||
// The size IDL attribute must reflect the respective content attributes of the same name. The size IDL attribute has a default value of 0.
|
// The size IDL attribute must reflect the respective content attributes of the same name. The size IDL attribute has a default value of 0.
|
||||||
if (auto size_string = get_attribute(HTML::AttributeNames::size); size_string.has_value()) {
|
if (auto size_string = get_attribute(HTML::AttributeNames::size); size_string.has_value()) {
|
||||||
|
// The display size of a select element is the result of applying the rules for parsing non-negative integers
|
||||||
|
// to the value of element's size attribute, if it has one and parsing it is successful.
|
||||||
if (auto size = parse_non_negative_integer(*size_string); size.has_value())
|
if (auto size = parse_non_negative_integer(*size_string); size.has_value())
|
||||||
return *size;
|
return *size;
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
|
// If applying those rules to the attribute's value is not successful or if the size attribute is absent,
|
||||||
|
// then the element's display size is 4 if the element's multiple content attribute is present, and 1 otherwise.
|
||||||
|
if (has_attribute(AttributeNames::multiple))
|
||||||
|
return 4;
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebIDL::ExceptionOr<void> HTMLSelectElement::set_size(WebIDL::UnsignedLong size)
|
WebIDL::ExceptionOr<void> HTMLSelectElement::set_size(WebIDL::UnsignedLong size)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue