summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2023-04-17 17:31:18 +0200
committerAndreas Kling <kling@serenityos.org>2023-04-17 18:22:53 +0200
commitc710575f886dbca9fed966edf35ed53d400f8189 (patch)
tree27d6b734511624aee795088749c55b806f8089fe /Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
parent7f79208759f7b788cde8aeeeec4ff0cdb34171db (diff)
downloadserenity-c710575f886dbca9fed966edf35ed53d400f8189.zip
LibWeb: Honor box-sizing in flex item "specified size suggestion"
Although the spec doesn't mention it, if a flex item has box-sizing: border-box, and the specified size suggestion is a definite size, we have to subtract the borders and padding from the size before using it. This fixes an issue seen in "This Week in Ladybird #4" where the screenshots ended up in one long vertical stack instead of paired up 2 by 2.
Diffstat (limited to 'Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp')
-rw-r--r--Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
index 803c62a8b1..57100e1ac6 100644
--- a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
@@ -705,8 +705,10 @@ Optional<CSSPixels> FlexFormattingContext::specified_size_suggestion(FlexItem co
{
// If the itemโ€™s preferred main size is definite and not automatic,
// then the specified size suggestion is that size. It is otherwise undefined.
- if (has_definite_main_size(item.box))
- return inner_main_size(item.box);
+ if (has_definite_main_size(item.box)) {
+ // NOTE: We use get_pixel_{width,height} to ensure that CSS box-sizing is respected.
+ return is_row_layout() ? get_pixel_width(item.box, computed_main_size(item.box)) : get_pixel_height(item.box, computed_main_size(item.box));
+ }
return {};
}