mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
layout: Cache IndependentNonReplacedContents::layout()
(#36082)
This replaces `IndependentLayout` with `CacheableLayoutResult` and stores it in `LayoutBoxBase` so it can be reused when we need to lay out a box multiple times. This is a generalization of the caching that we had for flexbox, which is now removed in favor of the new one. With this, the number of runs per second in the Chromium perf test `flexbox-deeply-nested-column-flow.html` are multiplied by 3. Signed-off-by: Oriol Brufau <obrufau@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
efd6e86393
commit
c09eed759b
12 changed files with 216 additions and 160 deletions
|
@ -29,7 +29,7 @@ use super::{
|
|||
TableLayoutStyle, TableSlot, TableSlotCell, TableSlotCoordinates, TableTrack, TableTrackGroup,
|
||||
};
|
||||
use crate::context::LayoutContext;
|
||||
use crate::formatting_contexts::{Baselines, IndependentLayout};
|
||||
use crate::formatting_contexts::Baselines;
|
||||
use crate::fragment_tree::{
|
||||
BaseFragmentInfo, BoxFragment, CollapsedBlockMargins, ExtraBackground, Fragment, FragmentFlags,
|
||||
PositioningFragment, SpecificLayoutInfo,
|
||||
|
@ -38,6 +38,7 @@ use crate::geom::{
|
|||
LogicalRect, LogicalSides, LogicalSides1D, LogicalVec2, PhysicalPoint, PhysicalRect,
|
||||
PhysicalSides, PhysicalVec, Size, SizeConstraint, ToLogical, ToLogicalWithContainingBlock,
|
||||
};
|
||||
use crate::layout_box_base::CacheableLayoutResult;
|
||||
use crate::positioned::{PositioningContext, PositioningContextLength, relative_adjustement};
|
||||
use crate::sizing::{ComputeInlineContentSizes, ContentSizes, InlineContentSizesResult};
|
||||
use crate::style_ext::{
|
||||
|
@ -51,7 +52,7 @@ use crate::{
|
|||
/// the table. Note that this is only done for slots that are not
|
||||
/// covered by spans or empty.
|
||||
struct CellLayout {
|
||||
layout: IndependentLayout,
|
||||
layout: CacheableLayoutResult,
|
||||
padding: LogicalSides<Au>,
|
||||
border: LogicalSides<Au>,
|
||||
positioning_context: PositioningContext,
|
||||
|
@ -1137,6 +1138,7 @@ impl<'a> TableLayout<'a> {
|
|||
layout_context,
|
||||
&mut positioning_context,
|
||||
&containing_block_for_children,
|
||||
false, /* depends_on_block_constraints */
|
||||
);
|
||||
|
||||
Some(CellLayout {
|
||||
|
@ -1539,13 +1541,15 @@ impl<'a> TableLayout<'a> {
|
|||
positioning_context: &mut PositioningContext,
|
||||
containing_block_for_children: &ContainingBlock,
|
||||
containing_block_for_table: &ContainingBlock,
|
||||
) -> IndependentLayout {
|
||||
depends_on_block_constraints: bool,
|
||||
) -> CacheableLayoutResult {
|
||||
let table_writing_mode = containing_block_for_children.style.writing_mode;
|
||||
self.compute_border_collapse(table_writing_mode);
|
||||
let layout_style = self.table.layout_style(Some(&self));
|
||||
let depends_on_block_constraints = layout_style
|
||||
.content_box_sizes_and_padding_border_margin(&containing_block_for_table.into())
|
||||
.depends_on_block_constraints;
|
||||
let depends_on_block_constraints = depends_on_block_constraints ||
|
||||
layout_style
|
||||
.content_box_sizes_and_padding_border_margin(&containing_block_for_table.into())
|
||||
.depends_on_block_constraints;
|
||||
|
||||
self.pbm = layout_style
|
||||
.padding_border_margin_with_writing_mode_and_containing_block_inline_size(
|
||||
|
@ -1579,13 +1583,14 @@ impl<'a> TableLayout<'a> {
|
|||
let offset_from_wrapper = -self.pbm.padding - self.pbm.border;
|
||||
let mut current_block_offset = offset_from_wrapper.block_start;
|
||||
|
||||
let mut table_layout = IndependentLayout {
|
||||
let mut table_layout = CacheableLayoutResult {
|
||||
fragments: Vec::new(),
|
||||
content_block_size: Zero::zero(),
|
||||
content_inline_size_for_table: None,
|
||||
baselines: Baselines::default(),
|
||||
depends_on_block_constraints,
|
||||
specific_layout_info: Some(SpecificLayoutInfo::TableWrapper),
|
||||
collapsible_margins_in_children: CollapsedBlockMargins::zero(),
|
||||
};
|
||||
|
||||
table_layout
|
||||
|
@ -2664,12 +2669,14 @@ impl Table {
|
|||
positioning_context: &mut PositioningContext,
|
||||
containing_block_for_children: &ContainingBlock,
|
||||
containing_block_for_table: &ContainingBlock,
|
||||
) -> IndependentLayout {
|
||||
depends_on_block_constraints: bool,
|
||||
) -> CacheableLayoutResult {
|
||||
TableLayout::new(self).layout(
|
||||
layout_context,
|
||||
positioning_context,
|
||||
containing_block_for_children,
|
||||
containing_block_for_table,
|
||||
depends_on_block_constraints,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue