mirror of
https://github.com/servo/servo.git
synced 2025-07-23 23:33:43 +01:00
Add a flag to dump the computed style values
I used this to trace #11818 to a style bug, rather than a layout bug.
This commit is contained in:
parent
a22913569c
commit
748a573917
4 changed files with 48 additions and 0 deletions
|
@ -140,6 +140,11 @@ impl<'ln> TNode for ServoLayoutNode<'ln> {
|
|||
self.dump_indent(0);
|
||||
}
|
||||
|
||||
fn dump_style(self) {
|
||||
println!("\nDOM with computed styles:");
|
||||
self.dump_style_indent(0);
|
||||
}
|
||||
|
||||
fn opaque(&self) -> OpaqueNode {
|
||||
unsafe { self.get_jsmanaged().opaque() }
|
||||
}
|
||||
|
@ -320,11 +325,38 @@ impl<'ln> ServoLayoutNode<'ln> {
|
|||
}
|
||||
}
|
||||
|
||||
fn dump_style_indent(self, indent: u32) {
|
||||
if self.is_element() {
|
||||
let mut s = String::new();
|
||||
for _ in 0..indent {
|
||||
s.push_str(" ");
|
||||
}
|
||||
s.push_str(&self.debug_style_str());
|
||||
println!("{}", s);
|
||||
}
|
||||
|
||||
for kid in self.children() {
|
||||
kid.dump_style_indent(indent + 1);
|
||||
}
|
||||
}
|
||||
|
||||
fn debug_str(self) -> String {
|
||||
format!("{:?}: changed={} dirty={} dirty_descendants={}",
|
||||
self.script_type_id(), self.has_changed(), self.is_dirty(), self.has_dirty_descendants())
|
||||
}
|
||||
|
||||
fn debug_style_str(self) -> String {
|
||||
if let Some(data) = self.borrow_data() {
|
||||
if let Some(data) = data.style.as_ref() {
|
||||
format!("{:?}: {:?}", self.script_type_id(), data)
|
||||
} else {
|
||||
format!("{:?}: style=None", self.script_type_id())
|
||||
}
|
||||
} else {
|
||||
format!("{:?}: style_data=None", self.script_type_id())
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the interior of this node as a `LayoutJS`. This is highly unsafe for layout to
|
||||
/// call and as such is marked `unsafe`.
|
||||
unsafe fn get_jsmanaged(&self) -> &LayoutJS<Node> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue