layout: Remove IndependentNonReplacedContents (#37971)

With the work to unify the layout logic for replaced and non-replaced
boxes (#37942), I think the `IndependentNonReplacedContents` enum does
no longer make much sense.

Therefore, this removes `IndependentNonReplacedContents`, merging its
values into `IndependentFormattingContextContents`.

The methods defined on `IndependentFormattingContextContents` can now be
on `IndependentFormattingContext`, in particular this implies that the
layout results of a replaced box will now be cached.

Testing: Unneeded (no behavior change)
This part of #37942

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
Oriol Brufau 2025-07-10 09:46:04 +02:00 committed by GitHub
parent 07247cd4fd
commit ff050b71fa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 245 additions and 323 deletions

View file

@ -25,7 +25,6 @@ use crate::dom_traversal::{Contents, NodeAndStyleInfo, NonReplacedContents, Trav
use crate::flow::{BlockContainerBuilder, BlockFormattingContext};
use crate::formatting_contexts::{
IndependentFormattingContext, IndependentFormattingContextContents,
IndependentNonReplacedContents,
};
use crate::fragment_tree::BaseFragmentInfo;
use crate::layout_box_base::LayoutBoxBase;
@ -121,9 +120,7 @@ impl Table {
let ifc = IndependentFormattingContext {
base: LayoutBoxBase::new((&table_info).into(), table_style),
contents: IndependentFormattingContextContents::NonReplaced(
IndependentNonReplacedContents::Table(table),
),
contents: IndependentFormattingContextContents::Table(table),
};
(table_info, ifc)
@ -875,7 +872,7 @@ impl<'dom> TraversalHandler<'dom> for TableBuilderTraversal<'_, 'dom> {
});
let caption = old_caption.unwrap_or_else(|| {
let contents = IndependentNonReplacedContents::Flow(
let contents = IndependentFormattingContextContents::Flow(
BlockFormattingContext::construct(
self.context,
info,
@ -888,9 +885,7 @@ impl<'dom> TraversalHandler<'dom> for TableBuilderTraversal<'_, 'dom> {
ArcRefCell::new(TableCaption {
context: IndependentFormattingContext {
base: LayoutBoxBase::new(info.into(), info.style.clone()),
contents: IndependentFormattingContextContents::NonReplaced(
contents,
),
contents,
},
})
});