Dump display lists when debug!() is enabled for gfx::display_list

This commit is contained in:
Simon Sapin 2014-08-18 23:28:45 +01:00
parent b7401b9562
commit 36ed8d4212
2 changed files with 17 additions and 9 deletions

View file

@ -316,7 +316,6 @@ impl DisplayList {
} }
} }
/// Appends the given item to the display list. /// Appends the given item to the display list.
pub fn push(&mut self, item: DisplayItem) { pub fn push(&mut self, item: DisplayItem) {
self.list.push(item) self.list.push(item)
@ -328,6 +327,14 @@ impl DisplayList {
self.list.append(other.list) 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 /// Draws the display list into the given render context. The display list must be flattened
/// first for correct painting. /// first for correct painting.
pub fn draw_into_context(&self, render_context: &mut RenderContext) { pub fn draw_into_context(&self, render_context: &mut RenderContext) {
@ -724,14 +731,14 @@ impl DisplayItem {
} }
pub fn debug_with_level(&self, level: uint) { pub fn debug_with_level(&self, level: uint) {
let mut indent = String::new(); let mut indent = String::new();
for _ in range(0, level) { for _ in range(0, level) {
indent.push_str("| ") indent.push_str("| ")
} }
debug!("{}+ {}", indent, self); debug!("{}+ {}", indent, self);
for child in self.children() { for child in self.children() {
child.debug_with_level(level + 1); child.debug_with_level(level + 1);
} }
} }
} }

View file

@ -718,6 +718,7 @@ impl LayoutTask {
let root_display_list = let root_display_list =
mem::replace(&mut flow::mut_base(layout_root.get_mut()).display_list, mem::replace(&mut flow::mut_base(layout_root.get_mut()).display_list,
DisplayList::new()); DisplayList::new());
root_display_list.debug();
let display_list = Arc::new(root_display_list.flatten(ContentStackingLevel)); let display_list = Arc::new(root_display_list.flatten(ContentStackingLevel));
// FIXME(pcwalton): This is really ugly and can't handle overflow: scroll. Refactor // FIXME(pcwalton): This is really ugly and can't handle overflow: scroll. Refactor