mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
layout: Implement flow tree dumping with RUST_LOG=debug is on.
r? @pcwalton
This commit is contained in:
parent
9e94ecf99c
commit
a8f80b89f4
5 changed files with 29 additions and 10 deletions
|
@ -30,6 +30,7 @@ use gfx::render_task::{RenderInitMsg, RenderChan, RenderLayer};
|
||||||
use gfx::{render_task, color};
|
use gfx::{render_task, color};
|
||||||
use layout_traits;
|
use layout_traits;
|
||||||
use layout_traits::{LayoutControlMsg, LayoutTaskFactory};
|
use layout_traits::{LayoutControlMsg, LayoutTaskFactory};
|
||||||
|
use log;
|
||||||
use script::dom::bindings::js::JS;
|
use script::dom::bindings::js::JS;
|
||||||
use script::dom::node::{ElementNodeTypeId, LayoutDataRef, Node};
|
use script::dom::node::{ElementNodeTypeId, LayoutDataRef, Node};
|
||||||
use script::dom::element::{HTMLBodyElementTypeId, HTMLHtmlElementTypeId};
|
use script::dom::element::{HTMLBodyElementTypeId, HTMLHtmlElementTypeId};
|
||||||
|
@ -566,7 +567,9 @@ impl LayoutTask {
|
||||||
|
|
||||||
debug!("layout: received layout request for: {:s}", data.url.serialize());
|
debug!("layout: received layout request for: {:s}", data.url.serialize());
|
||||||
debug!("layout: parsed Node tree");
|
debug!("layout: parsed Node tree");
|
||||||
debug!("{:?}", node.dump());
|
if log_enabled!(log::DEBUG) {
|
||||||
|
node.dump();
|
||||||
|
}
|
||||||
|
|
||||||
let mut rw_data = self.lock_rw_data(possibly_locked_rw_data);
|
let mut rw_data = self.lock_rw_data(possibly_locked_rw_data);
|
||||||
|
|
||||||
|
|
|
@ -266,7 +266,7 @@ impl PreorderFlow for FlowTreeVerification {
|
||||||
fn process(&mut self, flow: &mut Flow) {
|
fn process(&mut self, flow: &mut Flow) {
|
||||||
let base = flow::base(flow);
|
let base = flow::base(flow);
|
||||||
if !base.flags.is_leaf() && !base.flags.is_nonleaf() {
|
if !base.flags.is_leaf() && !base.flags.is_nonleaf() {
|
||||||
println("flow tree verification failed: flow wasn't a leaf or a nonleaf!");
|
println!("flow tree verification failed: flow wasn't a leaf or a nonleaf!");
|
||||||
flow.dump();
|
flow.dump();
|
||||||
fail!("flow tree verification failed")
|
fail!("flow tree verification failed")
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,11 +126,6 @@ pub trait TLayoutNode {
|
||||||
|
|
||||||
/// Returns the first child of this node.
|
/// Returns the first child of this node.
|
||||||
fn first_child(&self) -> Option<Self>;
|
fn first_child(&self) -> Option<Self>;
|
||||||
|
|
||||||
/// Dumps this node tree, for debugging.
|
|
||||||
fn dump(&self) {
|
|
||||||
// TODO(pcwalton): Reimplement this in a way that's safe for layout to call.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A wrapper so that layout can access only the methods that it should have access to. Layout must
|
/// A wrapper so that layout can access only the methods that it should have access to. Layout must
|
||||||
|
@ -206,6 +201,28 @@ impl<'ln> LayoutNode<'ln> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn dump(self) {
|
||||||
|
self.dump_indent(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn dump_indent(self, indent: uint) {
|
||||||
|
let mut s = String::new();
|
||||||
|
for _ in range(0, indent) {
|
||||||
|
s.push_str(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
s.push_str(self.debug_str().as_slice());
|
||||||
|
error!("{:s}", s);
|
||||||
|
|
||||||
|
for kid in self.children() {
|
||||||
|
kid.dump_indent(indent + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn debug_str(self) -> String {
|
||||||
|
format!("{}: dirty={}", self.type_id(), self.is_dirty())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn flow_debug_id(self) -> uint {
|
pub fn flow_debug_id(self) -> uint {
|
||||||
let layout_data_ref = self.borrow_layout_data();
|
let layout_data_ref = self.borrow_layout_data();
|
||||||
match *layout_data_ref {
|
match *layout_data_ref {
|
||||||
|
|
|
@ -73,7 +73,7 @@ impl Reflectable for Element {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(PartialEq)]
|
#[deriving(PartialEq, Show)]
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
pub enum ElementTypeId {
|
pub enum ElementTypeId {
|
||||||
HTMLElementTypeId,
|
HTMLElementTypeId,
|
||||||
|
@ -1172,4 +1172,3 @@ impl<'a> style::TElement<'a> for JSRef<'a, Element> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -251,7 +251,7 @@ impl LayoutDataRef {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The different types of nodes.
|
/// The different types of nodes.
|
||||||
#[deriving(PartialEq)]
|
#[deriving(PartialEq, Show)]
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
pub enum NodeTypeId {
|
pub enum NodeTypeId {
|
||||||
DoctypeNodeTypeId,
|
DoctypeNodeTypeId,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue