mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00: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,
|
||||
non_replaced.preferred_aspect_ratio(),
|
||||
);
|
||||
non_replaced
|
||||
self.independent_formatting_context
|
||||
.inline_content_sizes(
|
||||
flex_context.layout_context,
|
||||
&constraint_space,
|
||||
|
|
|
@ -713,7 +713,7 @@ where
|
|||
);
|
||||
ArcRefCell::new(BlockLevelBox::OutsideMarker(OutsideMarker {
|
||||
marker_style,
|
||||
list_item_style: info.style.clone(),
|
||||
base: LayoutBoxBase::new(info.into(), info.style.clone()),
|
||||
block_container,
|
||||
}))
|
||||
},
|
||||
|
|
|
@ -225,12 +225,15 @@ pub(crate) struct CollapsibleWithParentStartMargin(bool);
|
|||
pub(crate) struct OutsideMarker {
|
||||
#[serde(skip_serializing)]
|
||||
pub marker_style: Arc<ComputedValues>,
|
||||
#[serde(skip_serializing)]
|
||||
pub list_item_style: Arc<ComputedValues>,
|
||||
pub base: LayoutBoxBase,
|
||||
pub block_container: BlockContainer,
|
||||
}
|
||||
|
||||
impl OutsideMarker {
|
||||
fn list_item_style(&self) -> &ComputedValues {
|
||||
&self.base.style
|
||||
}
|
||||
|
||||
fn layout(
|
||||
&self,
|
||||
layout_context: &LayoutContext<'_>,
|
||||
|
@ -243,9 +246,10 @@ impl OutsideMarker {
|
|||
&self.marker_style,
|
||||
None, /* TODO: support preferred aspect ratios on non-replaced boxes */
|
||||
);
|
||||
let content_sizes = self
|
||||
.block_container
|
||||
.inline_content_sizes(layout_context, &constraint_space);
|
||||
let content_sizes = self.base.inline_content_sizes(&constraint_space, || {
|
||||
self.block_container
|
||||
.inline_content_sizes(layout_context, &constraint_space)
|
||||
});
|
||||
let containing_block_for_children = ContainingBlock {
|
||||
size: ContainingBlockSize {
|
||||
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
|
||||
// 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.
|
||||
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 {
|
||||
start_corner: LogicalVec2 {
|
||||
inline: -max_inline_size -
|
||||
|
@ -2098,8 +2104,7 @@ impl IndependentFormattingContext {
|
|||
writing_mode,
|
||||
non_replaced.preferred_aspect_ratio(),
|
||||
);
|
||||
non_replaced
|
||||
.inline_content_sizes(layout_context, &constraint_space)
|
||||
self.inline_content_sizes(layout_context, &constraint_space)
|
||||
.sizes
|
||||
});
|
||||
|
||||
|
|
|
@ -232,7 +232,7 @@ impl taffy::LayoutPartialTree for TaffyContainerContext<'_> {
|
|||
preferred_aspect_ratio: non_replaced.preferred_aspect_ratio(),
|
||||
};
|
||||
|
||||
let result = non_replaced
|
||||
let result = independent_context
|
||||
.inline_content_sizes(self.layout_context, &constraint_space);
|
||||
let adjusted_available_space = inputs
|
||||
.available_space
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue