mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-20 23:19:44 +00:00
Everywhere: Use Optional<T>::ensure() where useful
No functional changes.
This commit is contained in:
parent
0fe9255991
commit
c31eff6a47
Notes:
github-actions[bot]
2025-09-17 16:02:17 +00:00
Author: https://github.com/gmta
Commit: c31eff6a47
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6220
Reviewed-by: https://github.com/rmg-x
Reviewed-by: https://github.com/trflynn89 ✅
14 changed files with 53 additions and 87 deletions
|
@ -45,11 +45,9 @@ void ImageBox::prepare_for_replaced_layout()
|
|||
set_natural_height(0);
|
||||
} else {
|
||||
auto font = Platform::FontPlugin::the().default_font(12);
|
||||
CSSPixels alt_text_width = 0;
|
||||
if (!m_cached_alt_text_width.has_value())
|
||||
m_cached_alt_text_width = CSSPixels::nearest_value_for(font->width(alt));
|
||||
alt_text_width = m_cached_alt_text_width.value();
|
||||
|
||||
CSSPixels alt_text_width = m_cached_alt_text_width.ensure([&] {
|
||||
return CSSPixels::nearest_value_for(font->width(alt));
|
||||
});
|
||||
set_natural_width(alt_text_width + 16);
|
||||
set_natural_height(CSSPixels::nearest_value_for(font->pixel_size()) + 16);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue