From ded4a5793ea621391af560652e66de8a8933b176 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Fri, 4 Sep 2015 16:58:17 -0700 Subject: [PATCH] layout: Defend the block formatting context speculation against going wrong in the presence of blocks that overflow in the inline direction. Makes the Google search result links appear. Closes #7298. --- components/layout/block.rs | 14 ++++++++++---- tests/ref/basic.list | 1 + .../block_formatting_context_overflow_a.html | 19 +++++++++++++++++++ ...block_formatting_context_overflow_ref.html | 3 +++ 4 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 tests/ref/block_formatting_context_overflow_a.html create mode 100644 tests/ref/block_formatting_context_overflow_ref.html diff --git a/components/layout/block.rs b/components/layout/block.rs index 68b149b5c5d..fbcc5928183 100644 --- a/components/layout/block.rs +++ b/components/layout/block.rs @@ -1327,10 +1327,16 @@ impl BlockFlow { let mut inline_size_of_preceding_left_floats = Au(0); let mut inline_size_of_preceding_right_floats = Au(0); if self.formatting_context_type() == FormattingContextType::None { - inline_size_of_preceding_left_floats = - max(self.inline_size_of_preceding_left_floats - inline_start_content_edge, Au(0)); - inline_size_of_preceding_right_floats = - max(self.inline_size_of_preceding_right_floats - inline_end_content_edge, Au(0)); + if inline_start_content_edge > Au(0) { + inline_size_of_preceding_left_floats = + max(self.inline_size_of_preceding_left_floats - inline_start_content_edge, + Au(0)); + } + if inline_end_content_edge > Au(0) { + inline_size_of_preceding_right_floats = + max(self.inline_size_of_preceding_right_floats - inline_end_content_edge, + Au(0)); + } } let opaque_self = OpaqueFlow::from_flow(self); diff --git a/tests/ref/basic.list b/tests/ref/basic.list index dcb270f550b..f8caeaff30e 100644 --- a/tests/ref/basic.list +++ b/tests/ref/basic.list @@ -48,6 +48,7 @@ flaky_cpu == append_style_a.html append_style_b.html == block_formatting_context_containing_floats_a.html block_formatting_context_containing_floats_ref.html == block_formatting_context_float_placement_a.html block_formatting_context_float_placement_ref.html == block_formatting_context_max_width_a.html block_formatting_context_max_width_ref.html +== block_formatting_context_overflow_a.html block_formatting_context_overflow_ref.html == block_formatting_context_relative_a.html block_formatting_context_ref.html == block_formatting_context_translation_a.html block_formatting_context_translation_ref.html == block_formatting_context_with_margin_a.html block_formatting_context_with_margin_ref.html diff --git a/tests/ref/block_formatting_context_overflow_a.html b/tests/ref/block_formatting_context_overflow_a.html new file mode 100644 index 00000000000..c38766870cf --- /dev/null +++ b/tests/ref/block_formatting_context_overflow_a.html @@ -0,0 +1,19 @@ + + +
+ diff --git a/tests/ref/block_formatting_context_overflow_ref.html b/tests/ref/block_formatting_context_overflow_ref.html new file mode 100644 index 00000000000..3dc8ad2e08d --- /dev/null +++ b/tests/ref/block_formatting_context_overflow_ref.html @@ -0,0 +1,3 @@ + +
Hello
world!
+