summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-10-13 11:16:54 +0200
committerAndreas Kling <kling@serenityos.org>2022-10-14 19:50:14 +0200
commit13792e572c32659e5c60401dd830cddb310a2693 (patch)
tree7f3827dbd31ddaaf7738ba9ab420818631eb3b33
parentd5d1146cc31e1a9b7cdf2a10daa63013fa129d05 (diff)
downloadserenity-13792e572c32659e5c60401dd830cddb310a2693.zip
LibWeb: Mark percentage heights as initially definite when appropriate
Percentage heights are now considered definite when their containing block has a definite height. This makes profile pictures have geometry on Twitter. (We still don't load the images themselves though.)
-rw-r--r--Userland/Libraries/LibWeb/Layout/LayoutState.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/LayoutState.cpp b/Userland/Libraries/LibWeb/Layout/LayoutState.cpp
index 40b699d195..e245c2459d 100644
--- a/Userland/Libraries/LibWeb/Layout/LayoutState.cpp
+++ b/Userland/Libraries/LibWeb/Layout/LayoutState.cpp
@@ -220,14 +220,16 @@ void LayoutState::UsedValues::set_node(NodeWithStyleAndBoxModelMetrics& node, Us
}
if (size.is_length() && size.length().is_calculated()) {
- if (width && size.length().calculated_style_value()->contains_percentage() && containing_block_has_definite_size) {
+ if (size.length().calculated_style_value()->contains_percentage()) {
+ if (!containing_block_has_definite_size)
+ return false;
auto& calc_value = *size.length().calculated_style_value();
- auto containing_block_width_as_length = CSS::Length::make_px(containing_block_used_values->content_width());
- resolved_definite_size = calc_value.resolve_length_percentage(node, containing_block_width_as_length).value_or(CSS::Length::make_auto()).to_px(node);
- return false;
+ auto containing_block_size_as_length = width
+ ? CSS::Length::make_px(containing_block_used_values->content_width())
+ : CSS::Length::make_px(containing_block_used_values->content_height());
+ resolved_definite_size = calc_value.resolve_length_percentage(node, containing_block_size_as_length).value_or(CSS::Length::make_auto()).to_px(node);
+ return true;
}
- if (size.length().calculated_style_value()->contains_percentage())
- return false;
resolved_definite_size = size.length().to_px(node);
return true;
}