Skip to content

Commit 13792e5

Browse files
committed
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.)
1 parent d5d1146 commit 13792e5

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

Userland/Libraries/LibWeb/Layout/LayoutState.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,14 +220,16 @@ void LayoutState::UsedValues::set_node(NodeWithStyleAndBoxModelMetrics& node, Us
220220
}
221221

222222
if (size.is_length() && size.length().is_calculated()) {
223-
if (width && size.length().calculated_style_value()->contains_percentage() && containing_block_has_definite_size) {
223+
if (size.length().calculated_style_value()->contains_percentage()) {
224+
if (!containing_block_has_definite_size)
225+
return false;
224226
auto& calc_value = *size.length().calculated_style_value();
225-
auto containing_block_width_as_length = CSS::Length::make_px(containing_block_used_values->content_width());
226-
resolved_definite_size = calc_value.resolve_length_percentage(node, containing_block_width_as_length).value_or(CSS::Length::make_auto()).to_px(node);
227-
return false;
227+
auto containing_block_size_as_length = width
228+
? CSS::Length::make_px(containing_block_used_values->content_width())
229+
: CSS::Length::make_px(containing_block_used_values->content_height());
230+
resolved_definite_size = calc_value.resolve_length_percentage(node, containing_block_size_as_length).value_or(CSS::Length::make_auto()).to_px(node);
231+
return true;
228232
}
229-
if (size.length().calculated_style_value()->contains_percentage())
230-
return false;
231233
resolved_definite_size = size.length().to_px(node);
232234
return true;
233235
}

0 commit comments

Comments
 (0)