mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-12 02:30:30 +09:00
LibWeb: Set float Y offset using margin box bottom instead of height
When positioning floats against an edge, we are taking all current relevant floats at that side into account to determine the Y offset at which to place the new float. However, we were using the margin box height instead of the absolute bottom position, which disregards the current float's Y-position within the root, and we were setting the Y offset to that height, instead of taking the new float's Y position inside of the root into account. The new code determines the lowest margin bottom value within the root of the current floats, and adds the difference between that value and the new float's Y position to the Y offset.
This commit is contained in:
parent
0cfc7f2c8a
commit
e8bc6e9e8e
Notes:
github-actions[bot]
2025-01-28 00:13:19 +00:00
Author: https://github.com/gmta
Commit: e8bc6e9e8e
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3375
3 changed files with 39 additions and 2 deletions
|
@ -1128,10 +1128,11 @@ void BlockFormattingContext::layout_floating_box(Box const& box, BlockContainer
|
|||
float_to_edge();
|
||||
CSSPixels lowest_margin_edge = 0;
|
||||
for (auto const& current : side_data.current_boxes) {
|
||||
lowest_margin_edge = max(lowest_margin_edge, current.used_values.margin_box_height());
|
||||
auto current_rect = margin_box_rect_in_ancestor_coordinate_space(current.used_values, root());
|
||||
lowest_margin_edge = max(lowest_margin_edge, current_rect.bottom());
|
||||
}
|
||||
|
||||
side_data.y_offset += lowest_margin_edge;
|
||||
side_data.y_offset += max<CSSPixels>(0, lowest_margin_edge - y_in_root + box_state.margin_box_top());
|
||||
|
||||
// Also, forget all previous boxes floated to this side while since they're no longer relevant.
|
||||
side_data.clear();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue