Skip to content

Commit

Permalink
Dumping display list levels to rust log
Browse files Browse the repository at this point in the history
  • Loading branch information
Isabelle Carter committed Jan 23, 2014
1 parent 539cf58 commit 5663ca1
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions src/components/gfx/display_list.rs
Expand Up @@ -40,6 +40,12 @@ impl<E> DisplayList<E> {
}
}

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<E>) {
// FIXME(Issue #150): crashes
Expand All @@ -55,7 +61,8 @@ impl<E> DisplayList<E> {
//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.
Expand Down Expand Up @@ -271,6 +278,17 @@ impl<E> DisplayItem<E> {
}
}

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",
Expand All @@ -279,11 +297,7 @@ impl<E> DisplayItem<E> {
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)
}
}

13 comments on commit 5663ca1

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from metajack
at ibnc@5663ca1

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging ibnc/servo/display_list_debug = 5663ca1 into auto

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ibnc/servo/display_list_debug = 5663ca1 merged ok, testing candidate = b4026c9

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from metajack
at ibnc@5663ca1

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging ibnc/servo/display_list_debug = 5663ca1 into auto

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ibnc/servo/display_list_debug = 5663ca1 merged ok, testing candidate = 2ba5998

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from metajack
at ibnc@5663ca1

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging ibnc/servo/display_list_debug = 5663ca1 into auto

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ibnc/servo/display_list_debug = 5663ca1 merged ok, testing candidate = b28d08b

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = b28d08b

Please sign in to comment.