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

@ -113,14 +113,21 @@ impl FlexContainer {
.into_iter()
.map(|item| {
let box_ = match item.kind {
ModernItemKind::InFlow => ArcRefCell::new(FlexLevelBox::FlexItem(
FlexItemBox::new(item.formatting_context),
)),
ModernItemKind::OutOfFlow => {
let abs_pos_box =
ArcRefCell::new(AbsolutelyPositionedBox::new(item.formatting_context));
ModernItemKind::InFlow(independent_formatting_context) => ArcRefCell::new(
FlexLevelBox::FlexItem(FlexItemBox::new(independent_formatting_context)),
),
ModernItemKind::OutOfFlow(independent_formatting_context) => {
let abs_pos_box = ArcRefCell::new(AbsolutelyPositionedBox::new(
independent_formatting_context,
));
ArcRefCell::new(FlexLevelBox::OutOfFlowAbsolutelyPositionedBox(abs_pos_box))
},
ModernItemKind::ReusedBox(layout_box) => match layout_box {
LayoutBox::FlexLevel(flex_level_box) => flex_level_box,
_ => unreachable!(
"Undamaged flex level element should be associated with flex level box"
),
},
};
if let Some(box_slot) = item.box_slot {