From 36ed8d4212c979bca4c4ea54644e6048c1852c23 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Mon, 18 Aug 2014 23:28:45 +0100 Subject: [PATCH] Dump display lists when debug!() is enabled for gfx::display_list --- src/components/gfx/display_list/mod.rs | 25 ++++++++++++++++--------- src/components/layout/layout_task.rs | 1 + 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/components/gfx/display_list/mod.rs b/src/components/gfx/display_list/mod.rs index 21c8c8a25b5..0ad7d945ae1 100644 --- a/src/components/gfx/display_list/mod.rs +++ b/src/components/gfx/display_list/mod.rs @@ -316,7 +316,6 @@ impl DisplayList { } } - /// Appends the given item to the display list. pub fn push(&mut self, item: DisplayItem) { self.list.push(item) @@ -328,6 +327,14 @@ impl DisplayList { self.list.append(other.list) } + pub fn debug(&self) { + if log_enabled!(::log::DEBUG) { + for item in self.list.iter() { + item.debug_with_level(0); + } + } + } + /// Draws the display list into the given render context. The display list must be flattened /// first for correct painting. pub fn draw_into_context(&self, render_context: &mut RenderContext) { @@ -724,14 +731,14 @@ impl DisplayItem { } pub fn debug_with_level(&self, level: uint) { - let mut indent = String::new(); - for _ in range(0, level) { - indent.push_str("| ") - } - debug!("{}+ {}", indent, self); - for child in self.children() { - child.debug_with_level(level + 1); - } + let mut indent = String::new(); + for _ in range(0, level) { + indent.push_str("| ") + } + debug!("{}+ {}", indent, self); + for child in self.children() { + child.debug_with_level(level + 1); + } } } diff --git a/src/components/layout/layout_task.rs b/src/components/layout/layout_task.rs index e4cba397379..90de75b8bcd 100644 --- a/src/components/layout/layout_task.rs +++ b/src/components/layout/layout_task.rs @@ -718,6 +718,7 @@ impl LayoutTask { let root_display_list = mem::replace(&mut flow::mut_base(layout_root.get_mut()).display_list, DisplayList::new()); + root_display_list.debug(); let display_list = Arc::new(root_display_list.flatten(ContentStackingLevel)); // FIXME(pcwalton): This is really ugly and can't handle overflow: scroll. Refactor