mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
auto merge of #1529 : ibnc/servo/display_list_debug, r=metajack
This commit is contained in:
commit
b28d08b4bc
1 changed files with 20 additions and 6 deletions
|
@ -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.
|
/// Appends the given item to the display list.
|
||||||
pub fn append_item(&mut self, item: DisplayItem<E>) {
|
pub fn append_item(&mut self, item: DisplayItem<E>) {
|
||||||
// FIXME(Issue #150): crashes
|
// FIXME(Issue #150): crashes
|
||||||
|
@ -55,7 +61,8 @@ impl<E> DisplayList<E> {
|
||||||
//debug!("drawing {}", *item);
|
//debug!("drawing {}", *item);
|
||||||
item.draw_into_context(render_context)
|
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.
|
/// Returns a preorder iterator over the given display list.
|
||||||
|
@ -276,6 +283,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 {
|
pub fn debug_str(&self) -> ~str {
|
||||||
let class = match *self {
|
let class = match *self {
|
||||||
SolidColorDisplayItemClass(_) => "SolidColor",
|
SolidColorDisplayItemClass(_) => "SolidColor",
|
||||||
|
@ -284,11 +302,7 @@ impl<E> DisplayItem<E> {
|
||||||
BorderDisplayItemClass(_) => "Border",
|
BorderDisplayItemClass(_) => "Border",
|
||||||
ClipDisplayItemClass(_) => "Clip",
|
ClipDisplayItemClass(_) => "Clip",
|
||||||
};
|
};
|
||||||
let mut string = format!("{} @ {:?}", class, self.base().bounds);
|
format!("{} @ {:?}", class, self.base().bounds)
|
||||||
for child in self.children() {
|
|
||||||
string = format!("{}\n {}", string, child.debug_str());
|
|
||||||
}
|
|
||||||
string
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue