Layout: Continue support incremental box tree reconstruction for flex&taffy level box (#37854)

Layout: Continue support incremental box tree reconstruction for
flex&taffy level box

This change reuse the flex/taffy level box from old box slot if the box
slot is valid and there is no LayoutDamage to the element.

Testing: This should not change observable behavior and is thus covered
by existing WPT tests.

Signed-off-by: sharpshooter_pt <ibluegalaxy_taoj@163.com>
This commit is contained in:
JoeDow 2025-07-04 17:35:09 +08:00 committed by GitHub
parent 934b3341d7
commit 068406ee6e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 59 additions and 32 deletions

View file

@ -46,16 +46,23 @@ impl TaffyContainer {
.into_iter()
.map(|item| {
let box_ = match item.kind {
ModernItemKind::InFlow => ArcRefCell::new(TaffyItemBox::new(
TaffyItemBoxInner::InFlowBox(item.formatting_context),
)),
ModernItemKind::OutOfFlow => {
let abs_pos_box =
ArcRefCell::new(AbsolutelyPositionedBox::new(item.formatting_context));
ModernItemKind::InFlow(independent_formatting_context) => {
ArcRefCell::new(TaffyItemBox::new(TaffyItemBoxInner::InFlowBox(
independent_formatting_context,
)))
},
ModernItemKind::OutOfFlow(independent_formatting_context) => {
let abs_pos_box = ArcRefCell::new(AbsolutelyPositionedBox::new(
independent_formatting_context,
));
ArcRefCell::new(TaffyItemBox::new(
TaffyItemBoxInner::OutOfFlowAbsolutelyPositionedBox(abs_pos_box),
))
},
ModernItemKind::ReusedBox(layout_box) => match layout_box {
LayoutBox::TaffyItemBox(taffy_item_box) => taffy_item_box,
_ => unreachable!("Undamaged taffy level element should be associated with taffy level box"),
},
};
if let Some(box_slot) = item.box_slot {