mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:27:35 +00:00
LibWeb: Add CSSPixels::nearest_value_for(FloatingPoint)
This is intended to annotate conversions from unknown floating-point values to CSSPixels, and make it more obvious the fp value will be rounded to the nearest fixed-point value.
This commit is contained in:
parent
360c0eb509
commit
71baa8c31a
28 changed files with 120 additions and 112 deletions
|
@ -34,11 +34,11 @@ void ImageBox::prepare_for_replaced_layout()
|
|||
|
||||
CSSPixels alt_text_width = 0;
|
||||
if (!m_cached_alt_text_width.has_value())
|
||||
m_cached_alt_text_width = CSSPixels(font.width(alt));
|
||||
m_cached_alt_text_width = CSSPixels::nearest_value_for(font.width(alt));
|
||||
alt_text_width = m_cached_alt_text_width.value();
|
||||
|
||||
set_natural_width(alt_text_width + 16);
|
||||
set_natural_height(CSSPixels(font.pixel_size()) + 16);
|
||||
set_natural_height(CSSPixels::nearest_value_for(font.pixel_size()) + 16);
|
||||
}
|
||||
|
||||
if (!has_natural_width() && !has_natural_height()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue