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
parent 15f4043a7a
commit fdfda6dec2
Notes: sideshowbarker 2024-07-19 05:41:49 +09:00
55 changed files with 354 additions and 455 deletions

View file

@ -122,28 +122,12 @@ void HTMLImageElement::animate()
int HTMLImageElement::preferred_width() const
{
bool ok = false;
int width = attribute(HTML::AttributeNames::width).to_int(ok);
if (ok)
return width;
if (m_image_decoder)
return m_image_decoder->width();
return 0;
return attribute(HTML::AttributeNames::width).to_int().value_or(m_image_decoder ? m_image_decoder->width() : 0);
}
int HTMLImageElement::preferred_height() const
{
bool ok = false;
int height = attribute(HTML::AttributeNames::height).to_int(ok);
if (ok)
return height;
if (m_image_decoder)
return m_image_decoder->height();
return 0;
return attribute(HTML::AttributeNames::height).to_int().value_or(m_image_decoder ? m_image_decoder->height() : 0);
}
RefPtr<LayoutNode> HTMLImageElement::create_layout_node(const StyleProperties* parent_style) const