mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-21 17:51:52 +00:00
LibWeb: Add select element size property
This commit is contained in:
parent
abb4b6d117
commit
4e5ce7b63e
Notes:
sideshowbarker
2024-07-17 02:05:41 +09:00
Author: https://github.com/bplaat
Commit: 4e5ce7b63e
Pull-request: https://github.com/SerenityOS/serenity/pull/23895
Reviewed-by: https://github.com/shannonbooth
5 changed files with 46 additions and 1 deletions
|
@ -18,6 +18,7 @@
|
|||
#include <LibWeb/HTML/HTMLOptGroupElement.h>
|
||||
#include <LibWeb/HTML/HTMLOptionElement.h>
|
||||
#include <LibWeb/HTML/HTMLSelectElement.h>
|
||||
#include <LibWeb/HTML/Numbers.h>
|
||||
#include <LibWeb/Infra/Strings.h>
|
||||
#include <LibWeb/Layout/Node.h>
|
||||
#include <LibWeb/Namespace.h>
|
||||
|
@ -67,6 +68,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)));
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/form-elements.html#dom-select-size
|
||||
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.
|
||||
if (auto size_string = get_attribute(HTML::AttributeNames::size); size_string.has_value()) {
|
||||
if (auto size = parse_non_negative_integer(*size_string); size.has_value())
|
||||
return *size;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<void> HTMLSelectElement::set_size(WebIDL::UnsignedLong size)
|
||||
{
|
||||
return set_attribute(HTML::AttributeNames::size, MUST(String::number(size)));
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/form-elements.html#dom-select-options
|
||||
JS::GCPtr<HTMLOptionsCollection> const& HTMLSelectElement::options()
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue