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 | |
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.
-rw-r--r-- | Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp | 16 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Layout/FlexFormattingContext.h | 4 |
2 files changed, 8 insertions, 12 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) diff --git a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.h b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.h index 8cc3abfa67..020d8f9253 100644 --- a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.h +++ b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.h @@ -120,8 +120,8 @@ private: CSS::Size const& computed_cross_min_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_height(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&, CSS::Size const&) const; bool flex_item_is_stretched(FlexItem const&) const; |