auto merge of #3618 : mrobinson/servo/layer-sizing, r=pcwalton

Extra size from margins should be included in block size, so that
layers are large enough to include the entire block. This is typically
hidden by large tile sizes (512x512), but fitted tiles makes the issue
a lot more common.
This commit is contained in:
bors-servo 2014-10-13 10:48:45 -06:00
commit 7f26c67137
3 changed files with 22 additions and 9 deletions

View file

@ -1041,8 +1041,7 @@ impl BlockFlow {
let info = PlacementInfo {
size: LogicalSize::new(
self.fragment.style.writing_mode,
self.base.position.size.inline + self.fragment.margin.inline_start_end() +
self.fragment.border_padding.inline_start_end(),
self.base.position.size.inline,
block_size + self.fragment.margin.block_start_end()),
ceiling: clearance + float_info.float_ceiling,
max_inline_size: float_info.containing_inline_size,
@ -1619,10 +1618,6 @@ impl Flow for BlockFlow {
let padding_and_borders = self.fragment.border_padding.inline_start_end();
let content_inline_size = self.fragment.border_box.size.inline - padding_and_borders;
if self.is_float() {
self.base.position.size.inline = content_inline_size;
}
self.propagate_assigned_inline_size_to_children(inline_start_content_edge, content_inline_size, None);
}
@ -1955,6 +1950,7 @@ pub trait ISizeAndMarginsComputer {
block: &mut BlockFlow,
solution: ISizeConstraintSolution) {
let inline_size;
let extra_inline_size_from_margin;
{
let fragment = block.fragment();
fragment.margin.inline_start = solution.margin_inline_start;
@ -1965,14 +1961,19 @@ pub trait ISizeAndMarginsComputer {
// The associated fragment has the border box of this flow.
inline_size = solution.inline_size + fragment.border_padding.inline_start_end();
fragment.border_box.size.inline = inline_size
fragment.border_box.size.inline = inline_size;
// 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);
}
// We also resize the block itself, to ensure that overflow is not calculated
// as the inline-size of our parent. We might be smaller and we might be larger if we
// overflow.
let flow = flow::mut_base(block);
flow.position.size.inline = inline_size;
flow::mut_base(block).position.size.inline = inline_size + extra_inline_size_from_margin;
}
/// Set the x coordinate of the given flow if it is absolutely positioned.

View file

@ -62,6 +62,7 @@
== position_fixed_overflow_a.html position_fixed_overflow_b.html
== position_fixed_tile_edge.html position_fixed_tile_edge_ref.html
== position_fixed_tile_edge_2.html position_fixed_tile_edge_ref.html
== position_fixed_tile_edge_3.html position_fixed_tile_edge_ref.html
== position_relative_a.html position_relative_b.html
== position_relative_top_percentage_a.html position_relative_top_percentage_b.html
== background_none_a.html background_none_b.html

View file

@ -0,0 +1,11 @@
<html>
<body>
<div style="position: absolute; top: 0px; left: 0px;">
<div style="position: absolute; background: green; margin-left: 512px; width: 20px; height: 20px;"></div>
<!-- This position:fixed sibling should force its sibling to be layerized. -->
<div style="position: fixed;"></div>
</div>
</body>
</html>