From 6b193974527a8370249764a9189b8c6e745c7d1c Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 10 Mar 2023 10:04:01 +0100 Subject: LibWeb: Avoid unnecessary work for `box-sizing: content-box` flex items --- .../LibWeb/Layout/FlexFormattingContext.cpp | 32 +++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp') diff --git a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp index 892a928aca..d145bc16e2 100644 --- a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp @@ -41,32 +41,32 @@ CSSPixels FlexFormattingContext::get_pixel_width(Box const& box, Optionalresolved(box, inner_width).to_px(box) - border_left - border_right - padding_left - padding_right; + 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, inner_width).to_px(box); + return size->resolved(box, containing_block_width).to_px(box); } -CSSPixels FlexFormattingContext::get_pixel_height(Box const& box, Optional const& length_percentage) const +CSSPixels FlexFormattingContext::get_pixel_height(Box const& box, Optional const& size) const { - if (!length_percentage.has_value()) + if (!size.has_value()) return 0; - auto inner_height = CSS::Length::make_px(containing_block_height_for(box)); - 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, inner_height).to_px(box); - auto padding_bottom = box.computed_values().padding().bottom().resolved(box, inner_height).to_px(box); + auto containing_block_height = CSS::Length::make_px(containing_block_height_for(box)); if (box.computed_values().box_sizing() == CSS::BoxSizing::BorderBox) { - return length_percentage->resolved(box, inner_height).to_px(box) - border_top - border_bottom - padding_top - padding_bottom; + 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 length_percentage->resolved(box, inner_height).to_px(box); + return size->resolved(box, containing_block_height).to_px(box); } FlexFormattingContext::FlexFormattingContext(LayoutState& state, Box const& flex_container, FormattingContext* parent) -- cgit v1.2.3