mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:47:34 +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
|
@ -500,7 +500,7 @@ CSSPixels FormattingContext::tentative_height_for_replaced_element(Box const& bo
|
|||
//
|
||||
// (used width) / (intrinsic ratio)
|
||||
if (computed_height.is_auto() && box.has_preferred_aspect_ratio())
|
||||
return CSSPixels(m_state.get(box).content_width() / static_cast<double>(box.preferred_aspect_ratio().value()));
|
||||
return CSSPixels::nearest_value_for(m_state.get(box).content_width() / static_cast<double>(box.preferred_aspect_ratio().value()));
|
||||
|
||||
// Otherwise, if 'height' has a computed value of 'auto', and the element has an intrinsic height, then that intrinsic height is the used value of 'height'.
|
||||
if (computed_height.is_auto() && box.has_natural_height())
|
||||
|
@ -1403,7 +1403,7 @@ CSSPixels FormattingContext::calculate_min_content_height(Layout::Box const& box
|
|||
CSSPixels FormattingContext::calculate_max_content_height(Layout::Box const& box, CSSPixels width) const
|
||||
{
|
||||
if (box.has_preferred_aspect_ratio())
|
||||
return CSSPixels(width / static_cast<double>(*box.preferred_aspect_ratio()));
|
||||
return CSSPixels::nearest_value_for(width / static_cast<double>(*box.preferred_aspect_ratio()));
|
||||
|
||||
if (box.has_natural_height())
|
||||
return *box.natural_height();
|
||||
|
@ -1711,10 +1711,10 @@ CSSPixels FormattingContext::box_baseline(Box const& box) const
|
|||
return box_state.content_height() + box_state.margin_box_top();
|
||||
case CSS::VerticalAlign::TextTop:
|
||||
// TextTop: Align the top of the box with the top of the parent's content area (see 10.6.1).
|
||||
return CSSPixels(box.computed_values().font_size());
|
||||
return CSSPixels::nearest_value_for(box.computed_values().font_size());
|
||||
case CSS::VerticalAlign::TextBottom:
|
||||
// TextTop: Align the bottom of the box with the bottom of the parent's content area (see 10.6.1).
|
||||
return box_state.content_height() - CSSPixels(box.containing_block()->font().pixel_metrics().descent * 2);
|
||||
return box_state.content_height() - CSSPixels::nearest_value_for(box.containing_block()->font().pixel_metrics().descent * 2);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue