Skip to content

Commit

Permalink
Add some basic debug info for dumping flows.
Browse files Browse the repository at this point in the history
  • Loading branch information
larsbergstrom committed Nov 11, 2013
1 parent bdc7e98 commit b675618
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 deletions.
14 changes: 14 additions & 0 deletions src/components/main/layout/block.rs
Expand Up @@ -506,5 +506,19 @@ impl FlowContext for BlockFlow {

*first_in_flow = false;
}

fn debug_str(&self) -> ~str {
if self.is_root {
~"BlockFlow(root)"
} else {
let txt = ~"BlockFlow: ";
txt.append(match self.box {
Some(rb) => {
rb.debug_str()
}
None => { ~"" }
})
}
}
}

3 changes: 3 additions & 0 deletions src/components/main/layout/float.rs
Expand Up @@ -315,5 +315,8 @@ impl FlowContext for FloatFlow {
// Margins between a floated box and any other box do not collapse.
*collapsing = Au::new(0);
}
fn debug_str(&self) -> ~str {
~"FloatFlow"
}
}

24 changes: 22 additions & 2 deletions src/components/main/layout/flow.rs
Expand Up @@ -35,7 +35,7 @@ use layout::float_context::{FloatContext, Invalid};
use layout::incremental::RestyleDamage;
use layout::inline::InlineFlow;

use extra::dlist::{DList,MutDListIterator};
use extra::dlist::{DList, DListIterator, MutDListIterator};
use extra::container::Deque;
use geom::point::Point2D;
use geom::rect::Rect;
Expand Down Expand Up @@ -127,6 +127,11 @@ pub fn base<'a>(this: &'a FlowContext) -> &'a FlowData {
}
}

/// Iterates over the children of this immutable flow.
pub fn imm_child_iter<'a>(flow: &'a FlowContext) -> DListIterator<'a,~FlowContext:> {
base(flow).children.iter()
}

#[inline(always)]
pub fn mut_base<'a>(this: &'a mut FlowContext) -> &'a mut FlowData {
unsafe {
Expand Down Expand Up @@ -162,6 +167,9 @@ pub trait ImmutableFlowUtils {

/// Dumps the flow tree for debugging.
fn dump(self);

/// Dumps the flow tree for debugging, with a prefix to indicate that we're at the given level.
fn dump_with_level(self, level: uint);
}

pub trait MutableFlowUtils {
Expand Down Expand Up @@ -411,7 +419,19 @@ impl<'self> ImmutableFlowUtils for &'self FlowContext {

/// Dumps the flow tree for debugging.
fn dump(self) {
// TODO(pcwalton): Fill this in.
self.dump_with_level(0)
}

/// Dumps the flow tree for debugging, with a prefix to indicate that we're at the given level.
fn dump_with_level(self, level: uint) {
let mut indent = ~"";
for _ in range(0, level) {
indent.push_str("| ")
}
debug!("{}+ {}", indent, self.debug_str());
for kid in imm_child_iter(self) {
kid.dump_with_level(level + 1)
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/components/main/layout/inline.rs
Expand Up @@ -891,5 +891,9 @@ impl FlowContext for InlineFlow {
*collapsible = Au::new(0);
}
}

fn debug_str(&self) -> ~str {
~"InlineFlow"
}
}

5 comments on commit b675618

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from brson
at larsbergstrom@b675618

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging larsbergstrom/servo/dump_flows = b675618 into auto

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

larsbergstrom/servo/dump_flows = b675618 merged ok, testing candidate = 4a83051

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 4a83051

Please sign in to comment.