Skip to content

Commit

Permalink
Merge pull request #27 from SimonSapin/margin-collapsing
Browse files Browse the repository at this point in the history
Implement margin collapsing between siblings and with parent
  • Loading branch information
nox authored Jun 13, 2019
2 parents 21a6454 + 242984c commit 62d2574
Show file tree
Hide file tree
Showing 9 changed files with 264 additions and 90 deletions.
6 changes: 3 additions & 3 deletions tests/reftests/blocks.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<!doctype html>
<link rel=match href="blocks.png">
<div style="margin: 20px 30px; padding: 10px 20px 30px 40px; background-color: green">
<div style="margin: 20px 30px; padding: 5px 20px 30px 40px; background-color: green">
<p>
<p>
</div>
<style>
p { background-color: blue; width: 200px; height: 100px; margin: 5px }
</style>
p { background-color: blue; width: 200px; height: 100px; margin: 10px 5px 5px }
</style>
Binary file modified tests/reftests/blocks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 8 additions & 6 deletions victor/src/layout/flow/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl InlineFormattingContext {
&self,
containing_block: &ContainingBlock,
tree_rank: usize,
) -> (Vec<Fragment>, Vec<AbsolutelyPositionedFragment>, Length) {
) -> FlowChildren {
let mut ifc = InlineFormattingContextState {
containing_block,
absolutely_positioned_fragments: Vec::new(),
Expand Down Expand Up @@ -137,11 +137,12 @@ impl InlineFormattingContext {
} else {
ifc.line_boxes
.finish_line(&mut ifc.current_nesting_level, containing_block);
return (
ifc.line_boxes.boxes,
ifc.absolutely_positioned_fragments,
ifc.line_boxes.next_line_block_position,
);
return FlowChildren {
fragments: ifc.line_boxes.boxes,
absolutely_positioned_fragments: ifc.absolutely_positioned_fragments,
block_size: ifc.line_boxes.next_line_block_position,
collapsible_margins_in_children: CollapsedBlockMargins::zero(),
};
}
}
}
Expand Down Expand Up @@ -242,6 +243,7 @@ impl<'box_tree> PartialInlineBoxFragment<'box_tree> {
padding: self.padding.clone(),
border: self.border.clone(),
margin: self.margin.clone(),
block_margins_collapsed_with_children: CollapsedBlockMargins::zero(),
};
let last_fragment = self.last_box_tree_fragment && !at_line_break;
if last_fragment {
Expand Down
Loading

0 comments on commit 62d2574

Please sign in to comment.