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:
Andreas Kling 2020-06-12 21:07:52 +02:00
commit fdfda6dec2
Notes: sideshowbarker 2024-07-19 05:41:49 +09:00
55 changed files with 354 additions and 455 deletions

View file

@ -47,22 +47,12 @@ HTMLCanvasElement::~HTMLCanvasElement()
int HTMLCanvasElement::requested_width() const
{
bool ok = false;
unsigned width = attribute(HTML::AttributeNames::width).to_int(ok);
if (ok)
return width;
return 300;
return attribute(HTML::AttributeNames::width).to_int().value_or(300);
}
int HTMLCanvasElement::requested_height() const
{
bool ok = false;
unsigned height = attribute(HTML::AttributeNames::height).to_int(ok);
if (ok)
return height;
return 150;
return attribute(HTML::AttributeNames::height).to_int().value_or(150);
}
RefPtr<LayoutNode> HTMLCanvasElement::create_layout_node(const StyleProperties* parent_style) const