mirror of
https://github.com/RGBCube/serenity
synced 2025-05-29 17:35:06 +00:00
LibWeb: Ensure preceding offset is non-negative in float_box()
When calculating the edge offset of the next floating item based on the offset of the preceding floating item, we need to ensure that the preceding offset is always > 0. This isn't explicitly written in the spec, but all other popular engines do that. Fixes https://github.com/SerenityOS/serenity/issues/21023
This commit is contained in:
parent
81ddad3fcf
commit
d1e542999c
3 changed files with 51 additions and 1 deletions
|
@ -962,7 +962,7 @@ void BlockFormattingContext::layout_floating_box(Box const& box, BlockContainer
|
|||
CSSPixels tentative_offset_from_edge = 0;
|
||||
bool fits_next_to_preceding_float = false;
|
||||
if (side == FloatSide::Left) {
|
||||
tentative_offset_from_edge = preceding_float.offset_from_edge + preceding_float_state.content_width() + preceding_float_state.margin_box_right() + box_state.margin_box_left();
|
||||
tentative_offset_from_edge = max(preceding_float.offset_from_edge + preceding_float_state.content_width() + preceding_float_state.margin_box_right(), 0) + box_state.margin_box_left();
|
||||
if (available_space.width.is_definite()) {
|
||||
fits_next_to_preceding_float = (tentative_offset_from_edge + box_state.content_width() + box_state.margin_box_right()) <= available_space.width.to_px_or_zero();
|
||||
} else if (available_space.width.is_max_content() || available_space.width.is_indefinite()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue