Distinguish cached inline_content_sizes() from uncached ones (#34595)

Several structs and enums had a `inline_content_sizes()` method, but it
wasn't clear which ones would try to cache the result, and which ones
would always compute it.

Therefore, this performs some clarifying renaming:
 - Cached ones stay as `inline_content_sizes()`
 - Uncached ones become `compute_inline_content_sizes()`

Also, to simplify calls to `LayoutBoxBase::inline_content_sizes()`,
`compute_inline_content_sizes()` is moved into a new trait.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
Oriol Brufau 2024-12-12 16:39:51 +01:00 committed by GitHub
parent 874e106924
commit f7e2ec3a0f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 152 additions and 125 deletions

View file

@ -126,7 +126,7 @@ use crate::fragment_tree::{
};
use crate::geom::{LogicalRect, LogicalVec2, ToLogical};
use crate::positioned::{AbsolutelyPositionedBox, PositioningContext};
use crate::sizing::{ContentSizes, InlineContentSizesResult};
use crate::sizing::{ComputeInlineContentSizes, ContentSizes, InlineContentSizesResult};
use crate::style_ext::{ComputedValuesExt, PaddingBorderMargin};
use crate::{ConstraintSpace, ContainingBlock};
@ -1579,17 +1579,6 @@ impl InlineFormattingContext {
}
}
// This works on an already-constructed `InlineFormattingContext`,
// Which would have to change if/when
// `BlockContainer::construct` parallelize their construction.
pub(super) fn inline_content_sizes(
&self,
layout_context: &LayoutContext,
constraint_space: &ConstraintSpace,
) -> InlineContentSizesResult {
ContentSizesComputation::compute(self, layout_context, constraint_space)
}
pub(super) fn layout(
&self,
layout_context: &LayoutContext,
@ -2194,6 +2183,19 @@ fn inline_container_needs_strut(
.unwrap_or(false)
}
impl ComputeInlineContentSizes for InlineFormattingContext {
// This works on an already-constructed `InlineFormattingContext`,
// Which would have to change if/when
// `BlockContainer::construct` parallelize their construction.
fn compute_inline_content_sizes(
&self,
layout_context: &LayoutContext,
constraint_space: &ConstraintSpace,
) -> InlineContentSizesResult {
ContentSizesComputation::compute(self, layout_context, constraint_space)
}
}
/// A struct which takes care of computing [`ContentSizes`] for an [`InlineFormattingContext`].
struct ContentSizesComputation<'layout_data> {
layout_context: &'layout_data LayoutContext<'layout_data>,