Skip to content
Permalink
Browse files

Make DebugMethods pure; fix uses in flow and box (somewhat barbarical…

…ly).
  • Loading branch information
Brian J. Burg
Brian J. Burg committed Nov 19, 2012
1 parent ec60c58 commit d65140f2d265cf7a1e9dec305ba97b0db7010769
Showing with 25 additions and 19 deletions.
  1. +8 −5 src/servo/dom/node.rs
  2. +3 −3 src/servo/layout/box.rs
  3. +6 −6 src/servo/layout/debug.rs
  4. +8 −5 src/servo/layout/flow.rs
@@ -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);

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) }
}
}
@@ -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);

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| {

0 comments on commit d65140f

Please sign in to comment.
You can’t perform that action at this time.