mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:07:45 +00:00
LibWeb: Simplify FFC get_pixel_{width,height} internal helper API
These took an Optional<CSS::Size> for some reason, but that was not necessary. Just take a CSS::Size.
This commit is contained in:
parent
6b19397452
commit
07f6ee9e73
2 changed files with 8 additions and 12 deletions
|
@ -37,36 +37,32 @@ static CSS::Size to_css_size(CSS::LengthPercentage const& length_percentage)
|
||||||
return CSS::Size::make_percentage(length_percentage.percentage());
|
return CSS::Size::make_percentage(length_percentage.percentage());
|
||||||
}
|
}
|
||||||
|
|
||||||
CSSPixels FlexFormattingContext::get_pixel_width(Box const& box, Optional<CSS::Size> const& size) const
|
CSSPixels FlexFormattingContext::get_pixel_width(Box const& box, CSS::Size const& size) const
|
||||||
{
|
{
|
||||||
if (!size.has_value())
|
|
||||||
return 0;
|
|
||||||
auto containing_block_width = CSS::Length::make_px(containing_block_width_for(box));
|
auto containing_block_width = CSS::Length::make_px(containing_block_width_for(box));
|
||||||
if (box.computed_values().box_sizing() == CSS::BoxSizing::BorderBox) {
|
if (box.computed_values().box_sizing() == CSS::BoxSizing::BorderBox) {
|
||||||
auto border_left = box.computed_values().border_left().width;
|
auto border_left = box.computed_values().border_left().width;
|
||||||
auto border_right = box.computed_values().border_right().width;
|
auto border_right = box.computed_values().border_right().width;
|
||||||
auto padding_left = box.computed_values().padding().left().resolved(box, containing_block_width).to_px(box);
|
auto padding_left = box.computed_values().padding().left().resolved(box, containing_block_width).to_px(box);
|
||||||
auto padding_right = box.computed_values().padding().right().resolved(box, containing_block_width).to_px(box);
|
auto padding_right = box.computed_values().padding().right().resolved(box, containing_block_width).to_px(box);
|
||||||
return size->resolved(box, containing_block_width).to_px(box) - border_left - border_right - padding_left - padding_right;
|
return size.resolved(box, containing_block_width).to_px(box) - border_left - border_right - padding_left - padding_right;
|
||||||
}
|
}
|
||||||
|
|
||||||
return size->resolved(box, containing_block_width).to_px(box);
|
return size.resolved(box, containing_block_width).to_px(box);
|
||||||
}
|
}
|
||||||
|
|
||||||
CSSPixels FlexFormattingContext::get_pixel_height(Box const& box, Optional<CSS::Size> const& size) const
|
CSSPixels FlexFormattingContext::get_pixel_height(Box const& box, CSS::Size const& size) const
|
||||||
{
|
{
|
||||||
if (!size.has_value())
|
|
||||||
return 0;
|
|
||||||
auto containing_block_height = CSS::Length::make_px(containing_block_height_for(box));
|
auto containing_block_height = CSS::Length::make_px(containing_block_height_for(box));
|
||||||
if (box.computed_values().box_sizing() == CSS::BoxSizing::BorderBox) {
|
if (box.computed_values().box_sizing() == CSS::BoxSizing::BorderBox) {
|
||||||
auto border_top = box.computed_values().border_top().width;
|
auto border_top = box.computed_values().border_top().width;
|
||||||
auto border_bottom = box.computed_values().border_bottom().width;
|
auto border_bottom = box.computed_values().border_bottom().width;
|
||||||
auto padding_top = box.computed_values().padding().top().resolved(box, containing_block_height).to_px(box);
|
auto padding_top = box.computed_values().padding().top().resolved(box, containing_block_height).to_px(box);
|
||||||
auto padding_bottom = box.computed_values().padding().bottom().resolved(box, containing_block_height).to_px(box);
|
auto padding_bottom = box.computed_values().padding().bottom().resolved(box, containing_block_height).to_px(box);
|
||||||
return size->resolved(box, containing_block_height).to_px(box) - border_top - border_bottom - padding_top - padding_bottom;
|
return size.resolved(box, containing_block_height).to_px(box) - border_top - border_bottom - padding_top - padding_bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
return size->resolved(box, containing_block_height).to_px(box);
|
return size.resolved(box, containing_block_height).to_px(box);
|
||||||
}
|
}
|
||||||
|
|
||||||
FlexFormattingContext::FlexFormattingContext(LayoutState& state, Box const& flex_container, FormattingContext* parent)
|
FlexFormattingContext::FlexFormattingContext(LayoutState& state, Box const& flex_container, FormattingContext* parent)
|
||||||
|
|
|
@ -120,8 +120,8 @@ private:
|
||||||
CSS::Size const& computed_cross_min_size(Box const&) const;
|
CSS::Size const& computed_cross_min_size(Box const&) const;
|
||||||
CSS::Size const& computed_cross_max_size(Box const&) const;
|
CSS::Size const& computed_cross_max_size(Box const&) const;
|
||||||
|
|
||||||
CSSPixels get_pixel_width(Box const& box, Optional<CSS::Size> const& length_percentage) const;
|
CSSPixels get_pixel_width(Box const&, CSS::Size const&) const;
|
||||||
CSSPixels get_pixel_height(Box const& box, Optional<CSS::Size> const& length_percentage) const;
|
CSSPixels get_pixel_height(Box const&, CSS::Size const&) const;
|
||||||
|
|
||||||
bool flex_item_is_stretched(FlexItem const&) const;
|
bool flex_item_is_stretched(FlexItem const&) const;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue