diff options
author | Michael Howell <michael@notriddle.com> | 2016-08-12 11:11:23 -0700 |
---|---|---|
committer | Michael Howell <michael@notriddle.com> | 2016-08-12 11:11:23 -0700 |
commit | 748a5739176f4611913e805e17338c31b439ddc0 (patch) | |
tree | 6be7ae6cd68b83c27e0a5865db1821a4529ce1ef /components/script/layout_wrapper.rs | |
parent | a22913569c2fa917015b23c27cb2f55de2a69ff2 (diff) | |
download | servo-748a5739176f4611913e805e17338c31b439ddc0.tar.gz servo-748a5739176f4611913e805e17338c31b439ddc0.zip |
Add a flag to dump the computed style values
I used this to trace #11818 to a style bug, rather than a layout bug.
Diffstat (limited to 'components/script/layout_wrapper.rs')
-rw-r--r-- | components/script/layout_wrapper.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/components/script/layout_wrapper.rs b/components/script/layout_wrapper.rs index c13db423982..7668c9ff272 100644 --- a/components/script/layout_wrapper.rs +++ b/components/script/layout_wrapper.rs @@ -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> { |