Skip to content

Commit

Permalink
Add trace logs when assigning inline/block sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
Wu Yu Wei committed Apr 17, 2022
1 parent a80b962 commit b978f83
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 8 deletions.
24 changes: 17 additions & 7 deletions components/layout/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1994,6 +1994,7 @@ impl BlockFlow {
"block"
}
);
trace!("BlockFlow before assigning: {:?}", &self);

self.base.floats = Floats::new(self.base.writing_mode);

Expand All @@ -2003,7 +2004,9 @@ impl BlockFlow {
// Now compute the real value.
self.propagate_and_compute_used_inline_size(shared_context);

self.guess_inline_size_for_block_formatting_context_if_necessary()
self.guess_inline_size_for_block_formatting_context_if_necessary();

trace!("BlockFlow after assigning: {:?}", &self);
}

/// If this is the root flow, initialize values that would normally be set by the parent.
Expand Down Expand Up @@ -2304,25 +2307,32 @@ impl Flow for BlockFlow {
self.base.flags.contains(FlowFlags::MARGINS_CANNOT_COLLAPSE)
{
// Root element margins should never be collapsed according to CSS § 8.3.1.
debug!("{}", self.is_root());
debug!(
"assign_block_size: assigning block_size for root flow {:?}",
"assign_block_size: assigning block_size for root flow {:#x?}",
self.base().debug_id()
);
self.assign_block_size_block_base(
trace!("BlockFlow before assigning: {:?}", &self);
let flow = self.assign_block_size_block_base(
layout_context,
fragmentation_context,
MarginsMayCollapseFlag::MarginsMayNotCollapse,
)
);
trace!("BlockFlow after assigning: {:?}", &self);
flow
} else {
debug!(
"assign_block_size: assigning block_size for block {:?}",
"assign_block_size: assigning block_size for block {:#x?}",
self.base().debug_id()
);
self.assign_block_size_block_base(
trace!("BlockFlow before assigning: {:?}", &self);
let flow = self.assign_block_size_block_base(
layout_context,
fragmentation_context,
MarginsMayCollapseFlag::MarginsMayCollapse,
)
);
trace!("BlockFlow after assigning: {:?}", &self);
flow
}
}

Expand Down
14 changes: 14 additions & 0 deletions components/layout/multicol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ impl Flow for MulticolFlow {
"assign_inline_sizes({}): assigning inline_size for flow",
"multicol"
);
trace!("MulticolFlow before assigning: {:?}", &self);

let shared_context = layout_context.shared_context();
self.block_flow.compute_inline_sizes(shared_context);

Expand Down Expand Up @@ -146,10 +148,13 @@ impl Flow for MulticolFlow {
column_width,
|_, _, _, _, _, _| {},
);

trace!("MulticolFlow after assigning: {:?}", &self);
}

fn assign_block_size(&mut self, ctx: &LayoutContext) {
debug!("assign_block_size: assigning block_size for multicol");
trace!("MulticolFlow before assigning: {:?}", &self);

let fragmentation_context = Some(FragmentationContext {
this_fragment_is_empty: true,
Expand Down Expand Up @@ -193,6 +198,8 @@ impl Flow for MulticolFlow {
None => break,
};
}

trace!("MulticolFlow after assigning: {:?}", &self);
}

fn compute_stacking_relative_position(&mut self, layout_context: &LayoutContext) {
Expand Down Expand Up @@ -289,12 +296,19 @@ impl Flow for MulticolColumnFlow {
"assign_inline_sizes({}): assigning inline_size for flow",
"multicol column"
);
trace!("MulticolFlow before assigning: {:?}", &self);

self.block_flow.assign_inline_sizes(layout_context);
trace!("MulticolFlow after assigning: {:?}", &self);
}

fn assign_block_size(&mut self, ctx: &LayoutContext) {
debug!("assign_block_size: assigning block_size for multicol column");
trace!("MulticolFlow before assigning: {:?}", &self);

self.block_flow.assign_block_size(ctx);

trace!("MulticolFlow after assigning: {:?}", &self);
}

fn fragment(
Expand Down
9 changes: 8 additions & 1 deletion components/layout/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ impl Flow for TableFlow {
"assign_inline_sizes({}): assigning inline_size for flow",
"table"
);
trace!("TableFlow before assigning: {:?}", &self);

let shared_context = layout_context.shared_context();
// The position was set to the containing block by the flow's parent.
Expand Down Expand Up @@ -544,13 +545,19 @@ impl Flow for TableFlow {
}
},
);

trace!("TableFlow after assigning: {:?}", &self);
}

fn assign_block_size(&mut self, lc: &LayoutContext) {
debug!("assign_block_size: assigning block_size for table");
trace!("TableFlow before assigning: {:?}", &self);

let vertical_spacing = self.spacing().vertical();
self.block_flow
.assign_block_size_for_table_like_flow(vertical_spacing, lc)
.assign_block_size_for_table_like_flow(vertical_spacing, lc);

trace!("TableFlow after assigning: {:?}", &self);
}

fn compute_stacking_relative_position(&mut self, layout_context: &LayoutContext) {
Expand Down
8 changes: 8 additions & 0 deletions components/layout/table_caption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,20 @@ impl Flow for TableCaptionFlow {
"assign_inline_sizes({}): assigning inline_size for flow",
"table_caption"
);
trace!("TableCaptionFlow before assigning: {:?}", &self);

self.block_flow.assign_inline_sizes(layout_context);

trace!("TableCaptionFlow after assigning: {:?}", &self);
}

fn assign_block_size(&mut self, layout_context: &LayoutContext) {
debug!("assign_block_size: assigning block_size for table_caption");
trace!("TableCaptionFlow before assigning: {:?}", &self);

self.block_flow.assign_block_size(layout_context);

trace!("TableCaptionFlow after assigning: {:?}", &self);
}

fn compute_stacking_relative_position(&mut self, layout_context: &LayoutContext) {
Expand Down
7 changes: 7 additions & 0 deletions components/layout/table_cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ impl Flow for TableCellFlow {
"assign_inline_sizes({}): assigning inline_size for flow",
"table_cell"
);
trace!("TableCellFlow before assigning: {:?}", &self);

let shared_context = layout_context.shared_context();
// The position was set to the column inline-size by the parent flow, table row flow.
Expand Down Expand Up @@ -280,11 +281,17 @@ impl Flow for TableCellFlow {
content_inline_size,
|_, _, _, _, _, _| {},
);

trace!("TableCellFlow after assigning: {:?}", &self);
}

fn assign_block_size(&mut self, layout_context: &LayoutContext) {
debug!("assign_block_size: assigning block_size for table_cell");
trace!("TableCellFlow before assigning: {:?}", &self);

self.assign_block_size_table_cell_base(layout_context);

trace!("TableCellFlow after assigning: {:?}", &self);
}

fn compute_stacking_relative_position(&mut self, layout_context: &LayoutContext) {
Expand Down
7 changes: 7 additions & 0 deletions components/layout/table_rowgroup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ impl Flow for TableRowGroupFlow {
"assign_inline_sizes({}): assigning inline_size for flow",
"table_rowgroup"
);
trace!("TableRowGroupFlow before assigning: {:?}", &self);

let shared_context = layout_context.shared_context();
// The position was set to the containing block by the flow's parent.
Expand Down Expand Up @@ -184,12 +185,18 @@ impl Flow for TableRowGroupFlow {
}
},
);

trace!("TableRowGroupFlow after assigning: {:?}", &self);
}

fn assign_block_size(&mut self, lc: &LayoutContext) {
debug!("assign_block_size: assigning block_size for table_rowgroup");
trace!("TableRowGroupFlow before assigning: {:?}", &self);

self.block_flow
.assign_block_size_for_table_like_flow(self.spacing.vertical(), lc);

trace!("TableRowGroupFlow after assigning: {:?}", &self);
}

fn compute_stacking_relative_position(&mut self, layout_context: &LayoutContext) {
Expand Down
7 changes: 7 additions & 0 deletions components/layout/table_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ impl Flow for TableWrapperFlow {
"table_wrapper"
}
);
trace!("TableWrapperFlow before assigning: {:?}", &self);

let shared_context = layout_context.shared_context();
self.block_flow
Expand Down Expand Up @@ -454,16 +455,22 @@ impl Flow for TableWrapperFlow {
)
},
}

trace!("TableWrapperFlow after assigning: {:?}", &self);
}

fn assign_block_size(&mut self, layout_context: &LayoutContext) {
debug!("assign_block_size: assigning block_size for table_wrapper");
trace!("TableWrapperFlow before assigning: {:?}", &self);

let remaining = self.block_flow.assign_block_size_block_base(
layout_context,
None,
MarginsMayCollapseFlag::MarginsMayNotCollapse,
);
debug_assert!(remaining.is_none());

trace!("TableWrapperFlow after assigning: {:?}", &self);
}

fn compute_stacking_relative_position(&mut self, layout_context: &LayoutContext) {
Expand Down

0 comments on commit b978f83

Please sign in to comment.