Allow dumping the fragment tree in layout_2020

This is done when the dump-flow-tree debug option is passed.
This commit is contained in:
Martin Robinson 2020-01-13 13:00:26 +01:00
parent c6192dc286
commit ea8c635344
4 changed files with 100 additions and 5 deletions

View file

@ -45,7 +45,7 @@ pub(crate) mod flow_relative {
pub block: T,
}
#[derive(Clone, Debug)]
#[derive(Clone)]
pub(crate) struct Rect<T> {
pub start_corner: Vec2<T>,
pub size: Vec2<T>,
@ -200,6 +200,19 @@ impl flow_relative::Rect<Length> {
}
}
impl fmt::Debug for flow_relative::Rect<Length> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"Rect(i{}×b{} @ (i{},b{}))",
self.size.inline.px(),
self.size.block.px(),
self.start_corner.inline.px(),
self.start_corner.block.px(),
)
}
}
impl<T: Clone> flow_relative::Vec2<T> {
pub fn size_to_physical(&self, mode: WritingMode) -> physical::Vec2<T> {
// https://drafts.csswg.org/css-writing-modes/#logical-to-physical