mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 17:14:58 +00:00
AK: Make string-to-number conversion helpers return Optional
Get rid of the weird old signature: - int StringType::to_int(bool& ok) const And replace it with sensible new signature: - Optional<int> StringType::to_int() const
This commit is contained in:
parent
15f4043a7a
commit
fdfda6dec2
55 changed files with 354 additions and 455 deletions
|
@ -85,10 +85,9 @@ RefPtr<LayoutNode> HTMLInputElement::create_layout_node(const StyleProperties*)
|
|||
int text_width = Gfx::Font::default_font().width(value());
|
||||
auto size_value = attribute(HTML::AttributeNames::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;
|
||||
auto size = size_value.to_uint();
|
||||
if (size.has_value())
|
||||
text_width = Gfx::Font::default_font().glyph_width('x') * size.value();
|
||||
}
|
||||
text_box.set_relative_rect(0, 0, text_width + 20, 20);
|
||||
widget = text_box;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue