mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 06:48:49 +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
Notes:
sideshowbarker
2024-07-19 05:41:49 +09:00
Author: https://github.com/awesomekling
Commit: fdfda6dec2
55 changed files with 354 additions and 455 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue