mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
Make sure to cache inline_content_sizes()
(#34586)
The refactoring in 264c0f972f
stopped
caching the `inline_content_sizes()` calls from:
- `FlexItemBox::layout_for_block_content_size()`
- `IndependentFormattingContext::layout_float_or_atomic_inline()`
- `TaffyContainerContext::compute_child_layout()`
Also, the call from `OutsideMarker::layout()` was never cached.
This patch caches all of them.
It's not clear at all which `inline_content_sizes()` are cached and
which aren't, so I plan to improve the situation in a follow-up.
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
parent
7b160700d0
commit
41e3c321e5
4 changed files with 16 additions and 11 deletions
|
@ -2799,7 +2799,7 @@ impl FlexItemBox {
|
||||||
style.writing_mode,
|
style.writing_mode,
|
||||||
non_replaced.preferred_aspect_ratio(),
|
non_replaced.preferred_aspect_ratio(),
|
||||||
);
|
);
|
||||||
non_replaced
|
self.independent_formatting_context
|
||||||
.inline_content_sizes(
|
.inline_content_sizes(
|
||||||
flex_context.layout_context,
|
flex_context.layout_context,
|
||||||
&constraint_space,
|
&constraint_space,
|
||||||
|
|
|
@ -713,7 +713,7 @@ where
|
||||||
);
|
);
|
||||||
ArcRefCell::new(BlockLevelBox::OutsideMarker(OutsideMarker {
|
ArcRefCell::new(BlockLevelBox::OutsideMarker(OutsideMarker {
|
||||||
marker_style,
|
marker_style,
|
||||||
list_item_style: info.style.clone(),
|
base: LayoutBoxBase::new(info.into(), info.style.clone()),
|
||||||
block_container,
|
block_container,
|
||||||
}))
|
}))
|
||||||
},
|
},
|
||||||
|
|
|
@ -225,12 +225,15 @@ pub(crate) struct CollapsibleWithParentStartMargin(bool);
|
||||||
pub(crate) struct OutsideMarker {
|
pub(crate) struct OutsideMarker {
|
||||||
#[serde(skip_serializing)]
|
#[serde(skip_serializing)]
|
||||||
pub marker_style: Arc<ComputedValues>,
|
pub marker_style: Arc<ComputedValues>,
|
||||||
#[serde(skip_serializing)]
|
pub base: LayoutBoxBase,
|
||||||
pub list_item_style: Arc<ComputedValues>,
|
|
||||||
pub block_container: BlockContainer,
|
pub block_container: BlockContainer,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl OutsideMarker {
|
impl OutsideMarker {
|
||||||
|
fn list_item_style(&self) -> &ComputedValues {
|
||||||
|
&self.base.style
|
||||||
|
}
|
||||||
|
|
||||||
fn layout(
|
fn layout(
|
||||||
&self,
|
&self,
|
||||||
layout_context: &LayoutContext<'_>,
|
layout_context: &LayoutContext<'_>,
|
||||||
|
@ -243,9 +246,10 @@ impl OutsideMarker {
|
||||||
&self.marker_style,
|
&self.marker_style,
|
||||||
None, /* TODO: support preferred aspect ratios on non-replaced boxes */
|
None, /* TODO: support preferred aspect ratios on non-replaced boxes */
|
||||||
);
|
);
|
||||||
let content_sizes = self
|
let content_sizes = self.base.inline_content_sizes(&constraint_space, || {
|
||||||
.block_container
|
self.block_container
|
||||||
.inline_content_sizes(layout_context, &constraint_space);
|
.inline_content_sizes(layout_context, &constraint_space)
|
||||||
|
});
|
||||||
let containing_block_for_children = ContainingBlock {
|
let containing_block_for_children = ContainingBlock {
|
||||||
size: ContainingBlockSize {
|
size: ContainingBlockSize {
|
||||||
inline: content_sizes.sizes.max_content,
|
inline: content_sizes.sizes.max_content,
|
||||||
|
@ -292,7 +296,9 @@ impl OutsideMarker {
|
||||||
// TODO: This is the wrong containing block, as it should be the containing block of the
|
// TODO: This is the wrong containing block, as it should be the containing block of the
|
||||||
// parent of this list item. What this means in practice is that the writing mode could be
|
// parent of this list item. What this means in practice is that the writing mode could be
|
||||||
// wrong and padding defined as a percentage will be resolved incorrectly.
|
// wrong and padding defined as a percentage will be resolved incorrectly.
|
||||||
let pbm_of_list_item = self.list_item_style.padding_border_margin(containing_block);
|
let pbm_of_list_item = self
|
||||||
|
.list_item_style()
|
||||||
|
.padding_border_margin(containing_block);
|
||||||
let content_rect = LogicalRect {
|
let content_rect = LogicalRect {
|
||||||
start_corner: LogicalVec2 {
|
start_corner: LogicalVec2 {
|
||||||
inline: -max_inline_size -
|
inline: -max_inline_size -
|
||||||
|
@ -2098,8 +2104,7 @@ impl IndependentFormattingContext {
|
||||||
writing_mode,
|
writing_mode,
|
||||||
non_replaced.preferred_aspect_ratio(),
|
non_replaced.preferred_aspect_ratio(),
|
||||||
);
|
);
|
||||||
non_replaced
|
self.inline_content_sizes(layout_context, &constraint_space)
|
||||||
.inline_content_sizes(layout_context, &constraint_space)
|
|
||||||
.sizes
|
.sizes
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -232,7 +232,7 @@ impl taffy::LayoutPartialTree for TaffyContainerContext<'_> {
|
||||||
preferred_aspect_ratio: non_replaced.preferred_aspect_ratio(),
|
preferred_aspect_ratio: non_replaced.preferred_aspect_ratio(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let result = non_replaced
|
let result = independent_context
|
||||||
.inline_content_sizes(self.layout_context, &constraint_space);
|
.inline_content_sizes(self.layout_context, &constraint_space);
|
||||||
let adjusted_available_space = inputs
|
let adjusted_available_space = inputs
|
||||||
.available_space
|
.available_space
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue