layout: Make the output of flow tree dumping easier to read when there

are many fragments.
This commit is contained in:
Patrick Walton 2015-07-06 13:56:59 -07:00
parent 352ad53775
commit c84368b703
2 changed files with 20 additions and 3 deletions

View file

@ -208,6 +208,19 @@ impl SpecificFragmentInfo {
}
}
impl fmt::Debug for SpecificFragmentInfo {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
SpecificFragmentInfo::ScannedText(ref info) => {
write!(f, " \"{}\"", info.run.text.slice_chars(info.range.begin().get() as usize,
info.range.end().get() as usize));
}
_ => {}
}
Ok(())
}
}
/// Clamp a value obtained from style_length, based on min / max lengths.
fn clamp_size(size: Au,
min_size: LengthOrPercentage,
@ -2120,10 +2133,11 @@ impl Fragment {
impl fmt::Debug for Fragment {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
try!(write!(f, "({} {} ", self.debug_id(), self.specific.get_type()));
try!(write!(f, "bb {:?} bp {:?} m {:?}",
try!(write!(f, "bb {:?} bp {:?} m {:?}{:?}",
self.border_box,
self.border_padding,
self.margin));
self.margin,
self.specific));
write!(f, ")")
}
}

View file

@ -689,7 +689,10 @@ pub struct InlineFragments {
impl fmt::Debug for InlineFragments {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}", self.fragments)
for fragment in self.fragments.iter() {
try!(write!(f, "\n * {:?}", fragment))
}
Ok(())
}
}