Skip to content

Commit 246dc98

Browse files
committed
Fix clearance on replaced elements
1 parent cc4650a commit 246dc98

File tree

3 files changed

+69
-3
lines changed

3 files changed

+69
-3
lines changed

components/layout_2020/flow/mod.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -733,10 +733,13 @@ fn layout_in_flow_replaced_block_level<'a>(
733733

734734
let mut clearance = Length::zero();
735735
if let Some(ref mut sequential_layout_state) = sequential_layout_state {
736+
sequential_layout_state.adjoin_assign(&CollapsedMargin::new(margin.block_start));
736737
sequential_layout_state.collapse_margins();
737738
clearance = sequential_layout_state.calculate_clearance(ClearSide::from_style(style));
738-
sequential_layout_state
739-
.advance_block_position(pbm.border.block_sum() + pbm.padding.block_sum() + size.block);
739+
sequential_layout_state.advance_block_position(
740+
pbm.border.block_sum() + pbm.padding.block_sum() + size.block + clearance,
741+
);
742+
sequential_layout_state.adjoin_assign(&CollapsedMargin::new(margin.block_end));
740743
};
741744

742745
let content_rect = Rect {
@@ -756,7 +759,7 @@ fn layout_in_flow_replaced_block_level<'a>(
756759
pbm.padding,
757760
pbm.border,
758761
margin,
759-
Length::zero(),
762+
clearance,
760763
block_margins_collapsed_with_children,
761764
)
762765
}

tests/wpt/meta/MANIFEST.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61742,6 +61742,35 @@
6174261742
{}
6174361743
]
6174461744
],
61745+
"clear-on-replaced-element.html": [
61746+
"e5566b38326da17455d54c3d06d498f72bc4c693",
61747+
[
61748+
null,
61749+
[
61750+
[
61751+
"/css/CSS2/reference/ref-filled-green-100px-square.xht",
61752+
"=="
61753+
]
61754+
],
61755+
{
61756+
"fuzzy": [
61757+
[
61758+
null,
61759+
[
61760+
[
61761+
0,
61762+
2
61763+
],
61764+
[
61765+
0,
61766+
1500
61767+
]
61768+
]
61769+
]
61770+
]
61771+
}
61772+
]
61773+
],
6174561774
"clear-with-top-margin-after-cleared-empty-block.html": [
6174661775
"5d0fba7981f3f688b22442c1e8bef2ff8b146f5e",
6174761776
[
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<!DOCTYPE html>
2+
<title>Clear on block-level replaced element</title>
3+
<link rel="author" title="Oriol Brufau" href="[email protected]">
4+
<link rel="help" href="https://www.w3.org/TR/CSS22/visuren.html#flow-control" title="9.5.2 Controlling flow next to floats: the 'clear' property">
5+
<link rel="help" href="https://www.w3.org/TR/CSS22/conform.html#replaced-element">
6+
<link rel="match" href="../reference/ref-filled-green-100px-square.xht">
7+
<meta name="fuzzy" content="maxDifference=0-2;totalPixels=0-1500">
8+
<style>
9+
#wrapper {
10+
width: 90px;
11+
border: 5px solid green;
12+
background-image: linear-gradient(
13+
to bottom,
14+
red 30px, green 30px,
15+
green 50px, red 50px,
16+
red 60px, green 60px,
17+
green 70px, red 70px,
18+
red 80px, green 80px
19+
)
20+
}
21+
#wrapper > * {
22+
display: block;
23+
width: 100%;
24+
background: green content-box;
25+
}
26+
</style>
27+
28+
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
29+
<div id="wrapper">
30+
<div style="float: left; height: 20px"></div>
31+
<canvas style="clear: both; height: 10px; margin: 10px 0"></canvas>
32+
<canvas style="float: left; height: 10px; margin: 10px 0"></canvas>
33+
<div style="clear: both; height: 10px; padding-bottom: 10px"></div>
34+
</div>

0 commit comments

Comments
 (0)