Skip to content

Commit

Permalink
Make DebugMethods pure; fix uses in flow and box (somewhat barbarical…
Browse files Browse the repository at this point in the history
…ly).
  • Loading branch information
Brian J. Burg committed Nov 19, 2012
1 parent ec60c58 commit d65140f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 19 deletions.
13 changes: 8 additions & 5 deletions src/servo/dom/node.rs
Expand Up @@ -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 += ~" ";
Expand All @@ -65,12 +65,15 @@ impl Node : DebugMethods {
s += self.debug_str();
debug!("%s", s);

for NodeTree.each_child(self) |kid| {
kid.dump_indent(indent + 1u)
// 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) }
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/servo/layout/box.rs
Expand Up @@ -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 += ~" ";
Expand All @@ -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",
Expand Down
12 changes: 6 additions & 6 deletions src/servo/layout/debug.rs
@@ -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;
}
13 changes: 8 additions & 5 deletions src/servo/layout/flow.rs
Expand Up @@ -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 += ~"---- ";
Expand All @@ -256,12 +256,15 @@ impl FlowContext : BoxedDebugMethods {
s += self.debug_str();
debug!("%s", s);

for FlowTree.each_child(self) |child| {
child.dump_indent(indent + 1u)
// 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| {
Expand Down

0 comments on commit d65140f

Please sign in to comment.