mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 19:45:12 +00:00
LibWeb: Respect the <input size> attribute a bit more :^)
We now use the size attribute to determine the width of a text input.
This commit is contained in:
parent
0d2beddc74
commit
9df71afdb3
Notes:
sideshowbarker
2024-07-19 06:59:15 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/9df71afdb3e
1 changed files with 7 additions and 0 deletions
|
@ -75,6 +75,13 @@ RefPtr<LayoutNode> HTMLInputElement::create_layout_node(const StyleProperties*)
|
|||
const_cast<HTMLInputElement*>(this)->set_attribute("value", static_cast<const GUI::TextBox&>(widget).text());
|
||||
};
|
||||
int text_width = Gfx::Font::default_font().width(value());
|
||||
auto size_value = attribute("size");
|
||||
if (!size_value.is_null()) {
|
||||
bool ok;
|
||||
auto size = size_value.to_int(ok);
|
||||
if (ok && size >= 0)
|
||||
text_width = Gfx::Font::default_font().glyph_width('x') * size;
|
||||
}
|
||||
text_box.set_relative_rect(0, 0, text_width + 20, 20);
|
||||
widget = text_box;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue