From 5663ca1eef9b2aefbfe9f924c3e0505f1b0266fc Mon Sep 17 00:00:00 2001 From: Isabelle Carter Date: Thu, 16 Jan 2014 15:00:37 -0600 Subject: [PATCH] Dumping display list levels to rust log --- src/components/gfx/display_list.rs | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/components/gfx/display_list.rs b/src/components/gfx/display_list.rs index 7a5004c0325..8d0864db3ee 100644 --- a/src/components/gfx/display_list.rs +++ b/src/components/gfx/display_list.rs @@ -40,6 +40,12 @@ impl DisplayList { } } + fn dump(&self) { + for item in self.list.iter() { + item.debug_with_level(0); + } + } + /// Appends the given item to the display list. pub fn append_item(&mut self, item: DisplayItem) { // FIXME(Issue #150): crashes @@ -55,7 +61,8 @@ impl DisplayList { //debug!("drawing {}", *item); item.draw_into_context(render_context) } - debug!("Ending display list.") + debug!("Ending display list."); + debug!("{:?}", self.dump()); } /// Returns a preorder iterator over the given display list. @@ -271,6 +278,17 @@ impl DisplayItem { } } + pub fn debug_with_level(&self, level: uint) { + let mut indent = ~""; + for _ in range(0, level) { + indent.push_str("| ") + } + debug!("{}+ {}", indent, self.debug_str()); + for child in self.children() { + child.debug_with_level(level + 1); + } + } + pub fn debug_str(&self) -> ~str { let class = match *self { SolidColorDisplayItemClass(_) => "SolidColor", @@ -279,11 +297,7 @@ impl DisplayItem { BorderDisplayItemClass(_) => "Border", ClipDisplayItemClass(_) => "Clip", }; - let mut string = format!("{} @ {:?}", class, self.base().bounds); - for child in self.children() { - string = format!("{}\n {}", string, child.debug_str()); - } - string + format!("{} @ {:?}", class, self.base().bounds) } }