From e10af4fc980b1d4cf497e2ef2f2f980ab5334441 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Mon, 6 Apr 2015 17:55:59 -0700 Subject: [PATCH] layout: Correctly take the inline size of cleared floats into account when estimating the inline size of block formatting contexts. The speculated inline-size of the preceding floats was forced to zero at the wrong time if the float was itself cleared, causing it to overwrite the speculated value. Shuffling the code around a bit fixes the problem. --- components/layout/block.rs | 21 +++++++------- tests/ref/basic.list | 1 + ...ck_formatting_context_cleared_float_a.html | 28 +++++++++++++++++++ ..._formatting_context_cleared_float_ref.html | 27 ++++++++++++++++++ 4 files changed, 67 insertions(+), 10 deletions(-) create mode 100644 tests/ref/block_formatting_context_cleared_float_a.html create mode 100644 tests/ref/block_formatting_context_cleared_float_ref.html diff --git a/components/layout/block.rs b/components/layout/block.rs index 980bf6b5204b..24eac4f48ea8 100644 --- a/components/layout/block.rs +++ b/components/layout/block.rs @@ -1313,6 +1313,17 @@ impl BlockFlow { kid_base.fixed_static_i_offset = fixed_static_i_offset; } + // Determine float impaction, and update the inline size speculations if necessary. + if flow::base(kid).flags.contains(CLEARS_LEFT) { + inline_start_floats_impact_child = false; + inline_size_of_preceding_left_floats = Au(0); + } + if flow::base(kid).flags.contains(CLEARS_RIGHT) { + inline_end_floats_impact_child = false; + inline_size_of_preceding_right_floats = Au(0); + } + + // Update the speculated inline size if this child is floated. match flow::base(kid).flags.float_kind() { float::T::none => {} float::T::left => { @@ -1353,16 +1364,6 @@ impl BlockFlow { } } - // Determine float impaction. - if flow::base(kid).flags.contains(CLEARS_LEFT) { - inline_start_floats_impact_child = false; - inline_size_of_preceding_left_floats = Au(0); - } - if flow::base(kid).flags.contains(CLEARS_RIGHT) { - inline_end_floats_impact_child = false; - inline_size_of_preceding_right_floats = Au(0); - } - { let kid_base = flow::mut_base(kid); inline_start_floats_impact_child = inline_start_floats_impact_child || diff --git a/tests/ref/basic.list b/tests/ref/basic.list index fa364d852374..1d814a10e875 100644 --- a/tests/ref/basic.list +++ b/tests/ref/basic.list @@ -50,6 +50,7 @@ flaky_cpu == append_style_a.html append_style_b.html == background_style_attr.html background_ref.html == basic_width_px.html basic_width_em.html == block_formatting_context_a.html block_formatting_context_ref.html +== block_formatting_context_cleared_float_a.html block_formatting_context_cleared_float_ref.html == block_formatting_context_complex_a.html block_formatting_context_complex_ref.html == block_formatting_context_containing_floats_a.html block_formatting_context_containing_floats_ref.html == block_formatting_context_relative_a.html block_formatting_context_ref.html diff --git a/tests/ref/block_formatting_context_cleared_float_a.html b/tests/ref/block_formatting_context_cleared_float_a.html new file mode 100644 index 000000000000..495a09cc1195 --- /dev/null +++ b/tests/ref/block_formatting_context_cleared_float_a.html @@ -0,0 +1,28 @@ + + + + + + + +
+
+ + + diff --git a/tests/ref/block_formatting_context_cleared_float_ref.html b/tests/ref/block_formatting_context_cleared_float_ref.html new file mode 100644 index 000000000000..88408a8e8d46 --- /dev/null +++ b/tests/ref/block_formatting_context_cleared_float_ref.html @@ -0,0 +1,27 @@ + + + + + + + +
+
+ + +