aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout_2020/taffy/layout.rs
diff options
context:
space:
mode:
authorOriol Brufau <obrufau@igalia.com>2025-03-24 13:33:44 +0100
committerGitHub <noreply@github.com>2025-03-24 12:33:44 +0000
commitc09eed759b9533850c51ad0037fe68fab85ba6c5 (patch)
tree660dc2a9dce65c2f0d6ec7fe718d2af4be8c96c9 /components/layout_2020/taffy/layout.rs
parentefd6e8639369308715e35532b5f29e3bc399f1ce (diff)
downloadservo-c09eed759b9533850c51ad0037fe68fab85ba6c5.tar.gz
servo-c09eed759b9533850c51ad0037fe68fab85ba6c5.zip
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>
Diffstat (limited to 'components/layout_2020/taffy/layout.rs')
-rw-r--r--components/layout_2020/taffy/layout.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/components/layout_2020/taffy/layout.rs b/components/layout_2020/taffy/layout.rs
index 1e58464629f..6c1b931599c 100644
--- a/components/layout_2020/taffy/layout.rs
+++ b/components/layout_2020/taffy/layout.rs
@@ -18,7 +18,6 @@ use crate::cell::ArcRefCell;
use crate::context::LayoutContext;
use crate::formatting_contexts::{
Baselines, IndependentFormattingContext, IndependentFormattingContextContents,
- IndependentLayout,
};
use crate::fragment_tree::{
BoxFragment, CollapsedBlockMargins, Fragment, FragmentFlags, SpecificLayoutInfo,
@@ -27,6 +26,7 @@ use crate::geom::{
LogicalSides, LogicalVec2, PhysicalPoint, PhysicalRect, PhysicalSides, PhysicalSize, Size,
SizeConstraint, Sizes,
};
+use crate::layout_box_base::CacheableLayoutResult;
use crate::positioned::{AbsolutelyPositionedBox, PositioningContext, PositioningContextLength};
use crate::sizing::{ComputeInlineContentSizes, ContentSizes, InlineContentSizesResult};
use crate::style_ext::{ComputedValuesExt, LayoutStyle};
@@ -264,6 +264,7 @@ impl taffy::LayoutPartialTree for TaffyContainerContext<'_> {
&mut child_positioning_context,
&content_box_size_override,
containing_block,
+ false, /* depends_on_block_constraints */
);
// Store layout data on child for later access
@@ -425,7 +426,7 @@ impl TaffyContainer {
positioning_context: &mut PositioningContext,
content_box_size_override: &ContainingBlock,
containing_block: &ContainingBlock,
- ) -> IndependentLayout {
+ ) -> CacheableLayoutResult {
let mut container_ctx = TaffyContainerContext {
layout_context,
positioning_context,
@@ -643,7 +644,7 @@ impl TaffyContainer {
})
.collect();
- IndependentLayout {
+ CacheableLayoutResult {
fragments,
content_block_size: Au::from_f32_px(output.size.height) - pbm.padding_border_sums.block,
content_inline_size_for_table: None,
@@ -654,8 +655,8 @@ impl TaffyContainer {
// "true" is a safe default as it will prevent Servo from performing optimizations based
// on the assumption that the node's size does not depend on block constraints.
depends_on_block_constraints: true,
-
specific_layout_info: container_ctx.specific_layout_info,
+ collapsible_margins_in_children: CollapsedBlockMargins::zero(),
}
}