mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-29 15:58:47 +00:00
LibWeb: Support setting dimensions on input image buttons
Users are allowed to specify the height and width of an image button directly in the HTML.
This commit is contained in:
parent
3ea26327c7
commit
3f3db34587
Notes:
sideshowbarker
2024-07-17 06:00:02 +09:00
Author: https://github.com/trflynn89
Commit: 3f3db34587
Pull-request: https://github.com/SerenityOS/serenity/pull/23256
4 changed files with 45 additions and 9 deletions
|
@ -26,6 +26,7 @@
|
|||
#include <LibWeb/HTML/HTMLFormElement.h>
|
||||
#include <LibWeb/HTML/HTMLInputElement.h>
|
||||
#include <LibWeb/HTML/Numbers.h>
|
||||
#include <LibWeb/HTML/Parser/HTMLParser.h>
|
||||
#include <LibWeb/HTML/Scripting/Environments.h>
|
||||
#include <LibWeb/HTML/SharedImageRequest.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
|
@ -1311,6 +1312,24 @@ i32 HTMLInputElement::default_tab_index_value() const
|
|||
return 0;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/input.html#image-button-state-(type=image):the-input-element-11
|
||||
void HTMLInputElement::apply_presentational_hints(CSS::StyleProperties& style) const
|
||||
{
|
||||
// The input element supports dimension attributes.
|
||||
if (type_state() != TypeAttributeState::ImageButton)
|
||||
return;
|
||||
|
||||
for_each_attribute([&](auto& name, auto& value) {
|
||||
if (name == HTML::AttributeNames::width) {
|
||||
if (auto parsed_value = parse_dimension_value(value))
|
||||
style.set_property(CSS::PropertyID::Width, parsed_value.release_nonnull());
|
||||
} else if (name == HTML::AttributeNames::height) {
|
||||
if (auto parsed_value = parse_dimension_value(value))
|
||||
style.set_property(CSS::PropertyID::Height, parsed_value.release_nonnull());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/input.html#the-size-attribute
|
||||
unsigned HTMLInputElement::size() const
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue