mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
layout: Take negative margins of floats into account when placing them.
Removes extraneous inline space on GitHub pull requests.
This commit is contained in:
parent
95269bba39
commit
95c9d3cefe
4 changed files with 43 additions and 4 deletions
|
@ -1058,10 +1058,17 @@ impl BlockFlow {
|
|||
};
|
||||
|
||||
let float_info: FloatedBlockInfo = (**self.float.as_ref().unwrap()).clone();
|
||||
|
||||
// Our `position` field accounts for positive margins, but not negative margins. (See
|
||||
// calculation of `extra_inline_size_from_margin` below.) Negative margins must be taken
|
||||
// into account for float placement, however. So we add them in here.
|
||||
let inline_size_for_float_placement = self.base.position.size.inline +
|
||||
min(Au(0), self.fragment.margin.inline_start_end());
|
||||
|
||||
let info = PlacementInfo {
|
||||
size: LogicalSize::new(
|
||||
self.fragment.style.writing_mode,
|
||||
self.base.position.size.inline,
|
||||
inline_size_for_float_placement,
|
||||
block_size + self.fragment.margin.block_start_end())
|
||||
.convert(self.fragment.style.writing_mode, self.base.floats.writing_mode),
|
||||
ceiling: clearance + float_info.float_ceiling,
|
||||
|
@ -2214,9 +2221,9 @@ pub trait ISizeAndMarginsComputer {
|
|||
container_size - inline_size - fragment.margin.inline_end
|
||||
};
|
||||
|
||||
// To calculate the total size of this block, we also need to account for any additional
|
||||
// size contribution from positive margins. Negative margins means the block isn't made
|
||||
// larger at all by the margin.
|
||||
// To calculate the total size of this block, we also need to account for any
|
||||
// additional size contribution from positive margins. Negative margins means the block
|
||||
// isn't made larger at all by the margin.
|
||||
extra_inline_size_from_margin = max(Au(0), fragment.margin.inline_start) +
|
||||
max(Au(0), fragment.margin.inline_end);
|
||||
}
|
||||
|
|
|
@ -99,6 +99,7 @@ flaky_cpu == append_style_a.html append_style_b.html
|
|||
== float_under_top_margin_a.html float_under_top_margin_ref.html
|
||||
== floated_generated_content_a.html floated_generated_content_b.html
|
||||
== floated_list_item_a.html floated_list_item_ref.html
|
||||
== floated_negative_margins_a.html floated_negative_margins_ref.html
|
||||
== floated_table_with_margin_a.html floated_table_with_margin_ref.html
|
||||
== focus_selector.html focus_selector_ref.html
|
||||
== font_advance.html font_advance_ref.html
|
||||
|
|
16
tests/ref/floated_negative_margins_a.html
Normal file
16
tests/ref/floated_negative_margins_a.html
Normal file
|
@ -0,0 +1,16 @@
|
|||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
#a {
|
||||
float: left;
|
||||
margin-left: -64px;
|
||||
width: 128px;
|
||||
height: 128px;
|
||||
background: purple;
|
||||
}
|
||||
</style>
|
||||
<body>
|
||||
<div id=a></div>Hello
|
||||
|
15
tests/ref/floated_negative_margins_ref.html
Normal file
15
tests/ref/floated_negative_margins_ref.html
Normal file
|
@ -0,0 +1,15 @@
|
|||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
#a {
|
||||
float: left;
|
||||
width: 64px;
|
||||
height: 128px;
|
||||
background: purple;
|
||||
}
|
||||
</style>
|
||||
<body>
|
||||
<div id=a></div>Hello
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue