diff options
author | Andreas Kling <kling@serenityos.org> | 2023-03-10 10:12:02 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-03-10 13:15:45 +0100 |
commit | 07f6ee9e73d03549c7ac0e61754f6667a230c259 (patch) | |
tree | d88195684505a2a8644f47ac50a9821ed4cf61ca /Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp | |
parent | 6b193974527a8370249764a9189b8c6e745c7d1c (diff) | |
download | serenity-07f6ee9e73d03549c7ac0e61754f6667a230c259.zip |
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.
Diffstat (limited to 'Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp')
-rw-r--r-- | Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp index d145bc16e2..6d946e2065 100644 --- a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp @@ -37,36 +37,32 @@ static CSS::Size to_css_size(CSS::LengthPercentage const& length_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)); if (box.computed_values().box_sizing() == CSS::BoxSizing::BorderBox) { auto border_left = box.computed_values().border_left().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_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)); if (box.computed_values().box_sizing() == CSS::BoxSizing::BorderBox) { auto border_top = box.computed_values().border_top().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_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) |