Skip to content

Commit

Permalink
web/core: Fix positioning of replaced elements in block flow
Browse files Browse the repository at this point in the history
The offset code was just plain wrong.
  • Loading branch information
simonwuelker committed Dec 18, 2023
1 parent a417de5 commit aa6cbb5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions crates/web/core/src/css/layout/flow/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,14 +504,15 @@ impl<'box_tree, 'formatting_context> BlockFlowState<'box_tree, 'formatting_conte
.block_formatting_context
.get_collapsed_margin(margins.bottom);

// Advance the flow state
self.cursor.y += margins.vertical_sum() + content_size.height;

// Create a fragment for at the calculated position
let content_position = Vec2D::new(margins.top, margins.right);
let content_position = Vec2D::new(margins.left, self.cursor.y + margins.top);
let fragment = replaced_element
.content()
.create_fragment(content_position, content_size);

// Advance the flow state
self.cursor.y += margins.vertical_sum() + content_size.height;

self.fragments_so_far.push(fragment);
}
}
Expand Down

0 comments on commit aa6cbb5

Please sign in to comment.