From 4c453ac519128b84e5c4dea9394e18b65d325c5b Mon Sep 17 00:00:00 2001 From: Martin Robinson Date: Sat, 11 Oct 2014 11:15:11 -0700 Subject: [PATCH] Include leading margin in inline block size According to the documentation for Fragment::position, the inline axis should include margin size, so we include it for blocks. Also fix place_float which assumed that it was not included and assign_inline_sizes which overrode the size set in set_inline_size_constraint_solutions. Typically this issue was hidden by large tile sizes, but fitted tiles makes it more common. --- components/layout/block.rs | 19 ++++++++++--------- tests/ref/basic.list | 1 + tests/ref/position_fixed_tile_edge_3.html | 11 +++++++++++ 3 files changed, 22 insertions(+), 9 deletions(-) create mode 100644 tests/ref/position_fixed_tile_edge_3.html diff --git a/components/layout/block.rs b/components/layout/block.rs index 158a6e6bdbd..b38595289a5 100644 --- a/components/layout/block.rs +++ b/components/layout/block.rs @@ -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. diff --git a/tests/ref/basic.list b/tests/ref/basic.list index 036140ecd55..72cecd257f8 100644 --- a/tests/ref/basic.list +++ b/tests/ref/basic.list @@ -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 diff --git a/tests/ref/position_fixed_tile_edge_3.html b/tests/ref/position_fixed_tile_edge_3.html new file mode 100644 index 00000000000..dcf2341c170 --- /dev/null +++ b/tests/ref/position_fixed_tile_edge_3.html @@ -0,0 +1,11 @@ + + +
+
+ + +
+
+ + +