mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:47:35 +00:00
LibWeb: Improve vertical margin collapse between adjacent blocks
Collect all the preceding block-level siblings whose vertical margins are collapsible. Both margin-top and margin-bottom now (previously, we only considered the margin-bottom of siblings.) Use the right margin in part-negative and all-negative situations.
This commit is contained in:
parent
aac4382cd1
commit
c02e6f991a
2 changed files with 41 additions and 25 deletions
|
@ -286,8 +286,9 @@ float FormattingContext::compute_auto_height_for_block_formatting_context_root(F
|
|||
|
||||
auto const& child_box_state = state.get(child_box);
|
||||
|
||||
float child_box_top = child_box_state.offset.y() - child_box_state.margin_box_top();
|
||||
float child_box_bottom = child_box_state.offset.y() + child_box_state.content_height + child_box_state.margin_box_bottom();
|
||||
// FIXME: We're ignoring negative margins here, figure out the correct thing to do.
|
||||
float child_box_top = child_box_state.offset.y() - child_box_state.border_box_top() - max(0, child_box_state.margin_top);
|
||||
float child_box_bottom = child_box_state.offset.y() + child_box_state.content_height + child_box_state.border_box_bottom() + max(0, child_box_state.margin_bottom);
|
||||
|
||||
if (!top.has_value() || child_box_top < top.value())
|
||||
top = child_box_top;
|
||||
|
@ -305,7 +306,8 @@ float FormattingContext::compute_auto_height_for_block_formatting_context_root(F
|
|||
return IterationDecision::Continue;
|
||||
|
||||
auto const& child_box_state = state.get(child_box);
|
||||
float child_box_bottom = child_box_state.offset.y() + child_box_state.content_height + child_box_state.margin_box_bottom();
|
||||
// FIXME: We're ignoring negative margins here, figure out the correct thing to do.
|
||||
float child_box_bottom = child_box_state.offset.y() + child_box_state.content_height + child_box_state.border_box_bottom() + max(0, child_box_state.margin_bottom);
|
||||
|
||||
if (!bottom.has_value() || child_box_bottom > bottom.value())
|
||||
bottom = child_box_bottom;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue