mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +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 {
|
impl Node : DebugMethods {
|
||||||
/* Dumps the subtree rooted at this node, for debugging. */
|
/* Dumps the subtree rooted at this node, for debugging. */
|
||||||
fn dump(&self) {
|
pure fn dump(&self) {
|
||||||
self.dump_indent(0u);
|
self.dump_indent(0u);
|
||||||
}
|
}
|
||||||
/* Dumps the node tree, for debugging, with indentation. */
|
/* Dumps the node tree, for debugging, with indentation. */
|
||||||
fn dump_indent(&self, indent: uint) {
|
pure fn dump_indent(&self, indent: uint) {
|
||||||
let mut s = ~"";
|
let mut s = ~"";
|
||||||
for uint::range(0u, indent) |_i| {
|
for uint::range(0u, indent) |_i| {
|
||||||
s += ~" ";
|
s += ~" ";
|
||||||
|
@ -65,12 +65,15 @@ impl Node : DebugMethods {
|
||||||
s += self.debug_str();
|
s += self.debug_str();
|
||||||
debug!("%s", s);
|
debug!("%s", s);
|
||||||
|
|
||||||
|
// FIXME: this should have a pure version?
|
||||||
|
unsafe {
|
||||||
for NodeTree.each_child(self) |kid| {
|
for NodeTree.each_child(self) |kid| {
|
||||||
kid.dump_indent(indent + 1u)
|
kid.dump_indent(indent + 1u)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn debug_str(&self) -> ~str {
|
pure fn debug_str(&self) -> ~str unsafe {
|
||||||
do self.read |n| { fmt!("%?", n.kind) }
|
do self.read |n| { fmt!("%?", n.kind) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -576,12 +576,12 @@ impl RenderBox : RenderBoxMethods {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderBox : BoxedDebugMethods {
|
impl RenderBox : BoxedDebugMethods {
|
||||||
fn dump(@self) {
|
pure fn dump(@self) {
|
||||||
self.dump_indent(0u);
|
self.dump_indent(0u);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Dumps the node tree, for debugging, with indentation. */
|
/* Dumps the node tree, for debugging, with indentation. */
|
||||||
fn dump_indent(@self, indent: uint) {
|
pure fn dump_indent(@self, indent: uint) {
|
||||||
let mut s = ~"";
|
let mut s = ~"";
|
||||||
for uint::range(0u, indent) |_i| {
|
for uint::range(0u, indent) |_i| {
|
||||||
s += ~" ";
|
s += ~" ";
|
||||||
|
@ -591,7 +591,7 @@ impl RenderBox : BoxedDebugMethods {
|
||||||
debug!("%s", s);
|
debug!("%s", s);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn debug_str(@self) -> ~str {
|
pure fn debug_str(@self) -> ~str {
|
||||||
let repr = match self {
|
let repr = match self {
|
||||||
@GenericBox(*) => ~"GenericBox",
|
@GenericBox(*) => ~"GenericBox",
|
||||||
@ImageBox(*) => ~"ImageBox",
|
@ImageBox(*) => ~"ImageBox",
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
trait BoxedDebugMethods {
|
trait BoxedDebugMethods {
|
||||||
fn dump(@self);
|
pure fn dump(@self);
|
||||||
fn dump_indent(@self, ident: uint);
|
pure fn dump_indent(@self, ident: uint);
|
||||||
fn debug_str(@self) -> ~str;
|
pure fn debug_str(@self) -> ~str;
|
||||||
}
|
}
|
||||||
|
|
||||||
trait DebugMethods {
|
trait DebugMethods {
|
||||||
fn dump(&self);
|
pure fn dump(&self);
|
||||||
fn dump_indent(&self, ident: uint);
|
pure fn dump_indent(&self, ident: uint);
|
||||||
fn debug_str(&self) -> ~str;
|
pure fn debug_str(&self) -> ~str;
|
||||||
}
|
}
|
||||||
|
|
|
@ -242,12 +242,12 @@ impl FlowTree : tree::WriteMethods<@FlowContext> {
|
||||||
|
|
||||||
|
|
||||||
impl FlowContext : BoxedDebugMethods {
|
impl FlowContext : BoxedDebugMethods {
|
||||||
fn dump(@self) {
|
pure fn dump(@self) {
|
||||||
self.dump_indent(0u);
|
self.dump_indent(0u);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Dumps the flow tree, for debugging, with indentation. */
|
/** Dumps the flow tree, for debugging, with indentation. */
|
||||||
fn dump_indent(@self, indent: uint) {
|
pure fn dump_indent(@self, indent: uint) {
|
||||||
let mut s = ~"|";
|
let mut s = ~"|";
|
||||||
for uint::range(0u, indent) |_i| {
|
for uint::range(0u, indent) |_i| {
|
||||||
s += ~"---- ";
|
s += ~"---- ";
|
||||||
|
@ -256,12 +256,15 @@ impl FlowContext : BoxedDebugMethods {
|
||||||
s += self.debug_str();
|
s += self.debug_str();
|
||||||
debug!("%s", s);
|
debug!("%s", s);
|
||||||
|
|
||||||
|
// FIXME: this should have a pure/const version?
|
||||||
|
unsafe {
|
||||||
for FlowTree.each_child(self) |child| {
|
for FlowTree.each_child(self) |child| {
|
||||||
child.dump_indent(indent + 1u)
|
child.dump_indent(indent + 1u)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn debug_str(@self) -> ~str {
|
pure fn debug_str(@self) -> ~str {
|
||||||
let repr = match *self {
|
let repr = match *self {
|
||||||
InlineFlow(*) => {
|
InlineFlow(*) => {
|
||||||
let mut s = self.inline().boxes.foldl(~"InlineFlow(children=", |s, box| {
|
let mut s = self.inline().boxes.foldl(~"InlineFlow(children=", |s, box| {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue