mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-30 16:28:48 +00:00
LibWeb: Add support for the input size attribute
This commit is contained in:
parent
d9fb116bcc
commit
fb7b03d162
Notes:
sideshowbarker
2024-07-17 07:14:09 +09:00
Author: https://github.com/bplaat
Commit: fb7b03d162
Pull-request: https://github.com/SerenityOS/serenity/pull/22046
5 changed files with 30 additions and 9 deletions
|
@ -18,6 +18,7 @@
|
|||
#include <LibWeb/HTML/HTMLDivElement.h>
|
||||
#include <LibWeb/HTML/HTMLFormElement.h>
|
||||
#include <LibWeb/HTML/HTMLInputElement.h>
|
||||
#include <LibWeb/HTML/Numbers.h>
|
||||
#include <LibWeb/HTML/Scripting/Environments.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
#include <LibWeb/Infra/CharacterTypes.h>
|
||||
|
@ -1158,6 +1159,24 @@ i32 HTMLInputElement::default_tab_index_value() const
|
|||
return 0;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/input.html#the-size-attribute
|
||||
unsigned HTMLInputElement::size() const
|
||||
{
|
||||
// The size IDL attribute is limited to only positive numbers and has a default value of 20.
|
||||
auto maybe_size_string = get_attribute(HTML::AttributeNames::size);
|
||||
if (maybe_size_string.has_value()) {
|
||||
auto maybe_size = parse_non_negative_integer(maybe_size_string.value());
|
||||
if (maybe_size.has_value())
|
||||
return maybe_size.value();
|
||||
}
|
||||
return 20;
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<void> HTMLInputElement::set_size(unsigned value)
|
||||
{
|
||||
return set_attribute(HTML::AttributeNames::size, MUST(String::number(value)));
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/input.html#dom-input-valueasnumber
|
||||
WebIDL::ExceptionOr<double> HTMLInputElement::value_as_number() const
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue