mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Make DebugMethods pure; fix uses in flow and box (somewhat barbarically).
This commit is contained in:
parent
ec60c5827b
commit
d65140f2d2
4 changed files with 25 additions and 19 deletions
|
@ -52,11 +52,11 @@ impl Node {
|
|||
|
||||
impl Node : DebugMethods {
|
||||
/* Dumps the subtree rooted at this node, for debugging. */
|
||||
fn dump(&self) {
|
||||
pure fn dump(&self) {
|
||||
self.dump_indent(0u);
|
||||
}
|
||||
/* Dumps the node tree, for debugging, with indentation. */
|
||||
fn dump_indent(&self, indent: uint) {
|
||||
pure fn dump_indent(&self, indent: uint) {
|
||||
let mut s = ~"";
|
||||
for uint::range(0u, indent) |_i| {
|
||||
s += ~" ";
|
||||
|
@ -65,12 +65,15 @@ impl Node : DebugMethods {
|
|||
s += self.debug_str();
|
||||
debug!("%s", s);
|
||||
|
||||
// FIXME: this should have a pure version?
|
||||
unsafe {
|
||||
for NodeTree.each_child(self) |kid| {
|
||||
kid.dump_indent(indent + 1u)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn debug_str(&self) -> ~str {
|
||||
pure fn debug_str(&self) -> ~str unsafe {
|
||||
do self.read |n| { fmt!("%?", n.kind) }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -576,12 +576,12 @@ impl RenderBox : RenderBoxMethods {
|
|||
}
|
||||
|
||||
impl RenderBox : BoxedDebugMethods {
|
||||
fn dump(@self) {
|
||||
pure fn dump(@self) {
|
||||
self.dump_indent(0u);
|
||||
}
|
||||
|
||||
/* Dumps the node tree, for debugging, with indentation. */
|
||||
fn dump_indent(@self, indent: uint) {
|
||||
pure fn dump_indent(@self, indent: uint) {
|
||||
let mut s = ~"";
|
||||
for uint::range(0u, indent) |_i| {
|
||||
s += ~" ";
|
||||
|
@ -591,7 +591,7 @@ impl RenderBox : BoxedDebugMethods {
|
|||
debug!("%s", s);
|
||||
}
|
||||
|
||||
fn debug_str(@self) -> ~str {
|
||||
pure fn debug_str(@self) -> ~str {
|
||||
let repr = match self {
|
||||
@GenericBox(*) => ~"GenericBox",
|
||||
@ImageBox(*) => ~"ImageBox",
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
trait BoxedDebugMethods {
|
||||
fn dump(@self);
|
||||
fn dump_indent(@self, ident: uint);
|
||||
fn debug_str(@self) -> ~str;
|
||||
pure fn dump(@self);
|
||||
pure fn dump_indent(@self, ident: uint);
|
||||
pure fn debug_str(@self) -> ~str;
|
||||
}
|
||||
|
||||
trait DebugMethods {
|
||||
fn dump(&self);
|
||||
fn dump_indent(&self, ident: uint);
|
||||
fn debug_str(&self) -> ~str;
|
||||
pure fn dump(&self);
|
||||
pure fn dump_indent(&self, ident: uint);
|
||||
pure fn debug_str(&self) -> ~str;
|
||||
}
|
||||
|
|
|
@ -242,12 +242,12 @@ impl FlowTree : tree::WriteMethods<@FlowContext> {
|
|||
|
||||
|
||||
impl FlowContext : BoxedDebugMethods {
|
||||
fn dump(@self) {
|
||||
pure fn dump(@self) {
|
||||
self.dump_indent(0u);
|
||||
}
|
||||
|
||||
/** Dumps the flow tree, for debugging, with indentation. */
|
||||
fn dump_indent(@self, indent: uint) {
|
||||
pure fn dump_indent(@self, indent: uint) {
|
||||
let mut s = ~"|";
|
||||
for uint::range(0u, indent) |_i| {
|
||||
s += ~"---- ";
|
||||
|
@ -256,12 +256,15 @@ impl FlowContext : BoxedDebugMethods {
|
|||
s += self.debug_str();
|
||||
debug!("%s", s);
|
||||
|
||||
// FIXME: this should have a pure/const version?
|
||||
unsafe {
|
||||
for FlowTree.each_child(self) |child| {
|
||||
child.dump_indent(indent + 1u)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn debug_str(@self) -> ~str {
|
||||
pure fn debug_str(@self) -> ~str {
|
||||
let repr = match *self {
|
||||
InlineFlow(*) => {
|
||||
let mut s = self.inline().boxes.foldl(~"InlineFlow(children=", |s, box| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue