mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Auto merge of #12831 - notriddle:master, r=Manishearth
Add a flag to dump the computed style values I used this to trace #11818 to a style bug, rather than a layout bug. --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes do not fix any issues - [X] These changes do not require tests because debugging <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12831) <!-- Reviewable:end -->
This commit is contained in:
commit
7b1f75b605
5 changed files with 52 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