forked from servo/servo
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some basic debug info for dumping flows.
- Loading branch information
1 parent
bdc7e98
commit b675618
Showing
4 changed files
with
43 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 => { ~"" } | ||
}) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
huonw
|
||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -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:> { | ||
This comment has been minimized.
Sorry, something went wrong.
kmcallister
|
||
base(flow).children.iter() | ||
} | ||
|
||
#[inline(always)] | ||
pub fn mut_base<'a>(this: &'a mut FlowContext) -> &'a mut FlowData { | ||
unsafe { | ||
|
@@ -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 { | ||
|
@@ -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) | ||
} | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 comment
on commit b675618
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r+
Since each arm is a single expression I'd go with
Or use the
Option
methods, but I don't remember offhand which one is appropriate here, since they keep changing.