From 711993eb46db252057248d98fe8a17407d5ef923 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Thu, 30 Apr 2015 16:45:57 -0700 Subject: [PATCH] gfx: Print out stacking context info when dumping display lists. --- components/gfx/display_list/mod.rs | 43 +++++++++++++++++++----------- components/layout/construct.rs | 2 +- components/layout/layout_task.rs | 10 +++---- 3 files changed, 33 insertions(+), 22 deletions(-) diff --git a/components/gfx/display_list/mod.rs b/components/gfx/display_list/mod.rs index 59b8d019236..94d570949e9 100644 --- a/components/gfx/display_list/mod.rs +++ b/components/gfx/display_list/mod.rs @@ -58,6 +58,8 @@ pub mod optimizer; /// items that involve a blur. This ensures that the display item boundaries include all the ink. pub static BLUR_INFLATION_FACTOR: i32 = 3; +const MIN_INDENTATION_LENGTH: usize = 4; + /// An opaque handle to a node. The only safe operation that can be performed on this node is to /// compare it to another opaque handle or to another node. /// @@ -172,20 +174,7 @@ impl DisplayList { } // Print the display list. Only makes sense to call it after performing reflow. - pub fn print_items(&self, mut indentation: String) { - let min_length = 4; - // We cover the case of an empty string. - if indentation.len() == 0 { - indentation = String::from_str("####"); - } - - // We grow the indentation by 4 characters if needed. - // I wish to push it all as a slice, but it won't work if the string is a single char. - while indentation.len() < min_length { - let c = indentation.char_at(0); - indentation.push(c); - } - + pub fn print_items(&self, indentation: String) { // Closures are so nice! let doit = |items: &Vec| { for item in items.iter() { @@ -221,8 +210,9 @@ impl DisplayList { 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]); + for stacking_context in self.children.iter() { + stacking_context.print(indentation.clone() + + &indentation[0..MIN_INDENTATION_LENGTH]); } } } @@ -571,6 +561,27 @@ impl StackingContext { topmost_only, self.display_list.background_and_borders.iter().rev()) } + + pub fn print(&self, mut indentation: String) { + // We cover the case of an empty string. + if indentation.len() == 0 { + indentation = String::from_str("####"); + } + + // We grow the indentation by 4 characters if needed. + // I wish to push it all as a slice, but it won't work if the string is a single char. + while indentation.len() < MIN_INDENTATION_LENGTH { + let c = indentation.char_at(0); + indentation.push(c); + } + + println!("{:?} Stacking context at {:?} with overflow {:?}:", + indentation, + self.bounds, + self.overflow); + + self.display_list.print_items(indentation); + } } impl HeapSizeOf for StackingContext { diff --git a/components/layout/construct.rs b/components/layout/construct.rs index 10d5377dc66..632888b0095 100644 --- a/components/layout/construct.rs +++ b/components/layout/construct.rs @@ -229,7 +229,7 @@ impl InlineFragmentsAccumulator { mut fragments, enclosing_node, } = self; - if let Some(enclosing_style) = enclosing_style { + if let Some(enclosing_node) = enclosing_node { let frag_len = fragments.fragments.len(); for (idx, frag) in fragments.fragments.iter_mut().enumerate() { diff --git a/components/layout/layout_task.rs b/components/layout/layout_task.rs index 8c52975b515..de96ce66259 100644 --- a/components/layout/layout_task.rs +++ b/components/layout/layout_task.rs @@ -807,11 +807,6 @@ impl LayoutTask { ScrollPolicy::Scrollable)); let origin = Rect(Point2D(Au(0), Au(0)), root_size); - if opts::get().dump_display_list { - println!("#### start printing display list."); - display_list.print_items(String::from_str("#")); - } - let stacking_context = Arc::new(StackingContext::new(display_list, &origin, &origin, @@ -821,6 +816,11 @@ impl LayoutTask { mix_blend_mode::T::normal, Some(paint_layer))); + if opts::get().dump_display_list { + println!("#### start printing display list."); + stacking_context.print(String::from_str("#")); + } + rw_data.stacking_context = Some(stacking_context.clone()); debug!("Layout done!");