From 14a544b64c28b3e51ce3f4ea969c0905a6c20ef3 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Wed, 15 Apr 2015 17:04:57 -0700 Subject: [PATCH 1/2] layout: Clip the immediate fragments of block flows that establish stacking contexts properly. The code that existed before correctly translated the clips of child elements, but not those of immediate display items belonging to the flow itself. Makes Leaflet.js maps usable. --- components/layout/display_list_builder.rs | 7 +++- .../absolute_clipping_of_own_contents_a.html | 42 +++++++++++++++++++ ...absolute_clipping_of_own_contents_ref.html | 41 ++++++++++++++++++ tests/ref/basic.list | 1 + 4 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 tests/ref/absolute_clipping_of_own_contents_a.html create mode 100644 tests/ref/absolute_clipping_of_own_contents_ref.html diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs index f440424cf1a..a8f4d8e8bd1 100644 --- a/components/layout/display_list_builder.rs +++ b/components/layout/display_list_builder.rs @@ -1253,6 +1253,11 @@ impl BlockFlowDisplayListBuilding for BlockFlow { layout_context: &LayoutContext, background_border_level: BackgroundAndBorderLevel) { // Add the box that starts the block context. + let clip = if self.fragment.establishes_stacking_context() { + self.base.clip.translate(&-self.base.stacking_relative_position) + } else { + self.base.clip.clone() + }; self.fragment.build_display_list(display_list, layout_context, &self.base.stacking_relative_position, @@ -1263,7 +1268,7 @@ impl BlockFlowDisplayListBuilding for BlockFlow { .absolute_position_info .relative_containing_block_mode, background_border_level, - &self.base.clip); + &clip); // Add children. for kid in self.base.children.iter_mut() { diff --git a/tests/ref/absolute_clipping_of_own_contents_a.html b/tests/ref/absolute_clipping_of_own_contents_a.html new file mode 100644 index 00000000000..b018d799a86 --- /dev/null +++ b/tests/ref/absolute_clipping_of_own_contents_a.html @@ -0,0 +1,42 @@ + + + + + + + + +
+
+
+
+
+ + diff --git a/tests/ref/absolute_clipping_of_own_contents_ref.html b/tests/ref/absolute_clipping_of_own_contents_ref.html new file mode 100644 index 00000000000..96608da13c9 --- /dev/null +++ b/tests/ref/absolute_clipping_of_own_contents_ref.html @@ -0,0 +1,41 @@ + + + + + + + + +
+
+
+
+
+ + diff --git a/tests/ref/basic.list b/tests/ref/basic.list index be7e36e9e89..0daa115b84e 100644 --- a/tests/ref/basic.list +++ b/tests/ref/basic.list @@ -39,6 +39,7 @@ fragment=top != ../html/acid2.html acid2_ref.html == 2dcontext/transform_a.html 2dcontext/transform_ref.html == abs_float_pref_width_a.html abs_float_pref_width_ref.html +== absolute_clipping_of_own_contents_a.html absolute_clipping_of_own_contents_ref.html == absolute_content_height_a.html absolute_content_height_ref.html == absolute_hypothetical_float_a.html absolute_hypothetical_float_ref.html == acid1_a.html acid1_b.html From 4e847c05fb119005a3a26754d12e37388c386b40 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Wed, 15 Apr 2015 17:18:10 -0700 Subject: [PATCH 2/2] gfx: Fix debug dumping of child stacking contexts. --- components/gfx/display_list/mod.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/components/gfx/display_list/mod.rs b/components/gfx/display_list/mod.rs index b5b935c88d2..c31c7b34464 100644 --- a/components/gfx/display_list/mod.rs +++ b/components/gfx/display_list/mod.rs @@ -170,7 +170,7 @@ impl DisplayList { let doit = |items: &Vec| { for item in items.iter() { match *item { - DisplayItem::SolidColorClass(ref solid_color) => println!("{:?} SolidColor. {:?}", indentation, solid_color.base.bounds), + DisplayItem::SolidColorClass(ref solid_color) => println!("{} SolidColor. {:?}", indentation, solid_color.base.bounds), DisplayItem::TextClass(ref text) => println!("{:?} Text. {:?}", indentation, text.base.bounds), DisplayItem::ImageClass(ref image) => println!("{:?} Image. {:?}", indentation, image.base.bounds), DisplayItem::BorderClass(ref border) => println!("{:?} Border. {:?}", indentation, border.base.bounds), @@ -184,14 +184,11 @@ impl DisplayList { doit(&(self.all_display_items())); if self.children.len() != 0 { - println!("{} Children stacking contexts list length: {}", indentation, self.children.len()); - for subitem in self.children.iter() { - doit(&subitem.display_list.all_display_items()); - if subitem.display_list.children.len() != 0 { - // Rant: String doesn't have a substr() method that won't overflow if the - // selected range is bigger than the string length. - subitem.display_list.print_items(indentation.clone()+&indentation[0..min_length]); - } + println!("{} Children stacking contexts list length: {}", + indentation, + self.children.len()); + for sublist in self.children.iter() { + sublist.display_list.print_items(indentation.clone()+&indentation[0..min_length]); } } }