8000 Layout: Continue support incremental box tree reconstruction for flex&taffy level box by coding-joedow · Pull Request #37854 · servo/servo · GitHub
[go: up one dir, main page]

Skip to content

Conversation

coding-joedow
8000 Copy link
Contributor

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.

Comment on lines 103 to 115
if is_abspos {
return Some(ModernItem {
kind: ModernItemKind::ReusedBox(layout_box),
order: 0,
box_slot: Some(box_slot),
});
} else {
return Some(ModernItem {
kind: ModernItemKind::ReusedBox(layout_box),
order: info.style.clone_order(),
box_slot: Some(box_slot),
});
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems simpler to not repeat:

Suggested change
box_slot: Some(box_slot),
if is_abspos {
return Some(ModernItem {
kind: ModernItemKind::ReusedBox(layout_box),
order: 0,
box_slot: Some(box_slot),
});
} else {
return Some(ModernItem {
kind: ModernItemKind::ReusedBox(layout_box),
order: info.style.clone_order(),
});
}
let order = if is_abspos {
0
} else {
info.style.clone_order()
};
return Some(ModernItem {
kind: ModernItemKind::ReusedBox(layout_box),
order,
box_slot: Some(box_slot),
});

Comment on lines 134 to 146
if is_abspos {
Some(ModernItem {
kind: ModernItemKind::OutOfFlow,
kind: ModernItemKind::OutOfFlow(formatting_context),
order: 0,
box_slot: Some(box_slot),
formatting_context,
})
} else {
Some(ModernItem {
kind: ModernItemKind::InFlow,
kind: ModernItemKind::InFlow(formatting_context),
order: info.style.clone_order(),
box_slot: Some(box_slot),
formatting_context,
})
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, while you are at it

ArcRefCell::new(FlexLevelBox::OutOfFlowAbsolutelyPositionedBox(abs_pos_box))
},
ModernItemKind::ReusedBox(layout_box) => match layout_box {
LayoutBox::FlexLevel(flex_level_box) => flex_level_box.clone(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The clone() seems unnecessary

))
},
ModernItemKind::ReusedBox(layout_box) => match layout_box {
LayoutBox::TaffyItemBox(taffy_item_box) => taffy_item_box.clone(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The clone() seems unnecessary

.take_layout_box_if_undamaged(info.damage)
.and_then(|layout_box| match &layout_box {
LayoutBox::FlexLevel(_) | LayoutBox::TaffyItemBox(_) => {
return Some(layout_box);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lint is complaining

@coding-joedow coding-joedow force-pushed the incremental-box-tree-update-for-flex branch from 0d8f385 to 134d947 Compare July 3, 2025 16:18
@Loirooriol
Copy link
Contributor

Lint still failing

@coding-joedow coding-joedow force-pushed the incremental-box-tree-update-for-flex branch from 134d947 to 4b663fc Compare July 3, 2025 16:57
@Loirooriol
Copy link
Contributor

Still failing 😅
Just run ./mach fmt

…evel 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.

Signed-off-by: sharpshooter_pt <ibluegalaxy_taoj@163.com>
@coding-joedow coding-joedow force-pushed the incremental-box-tree-update-for-flex branch from 4b663fc to edd0d82 Compare July 4, 2025 01:13
@coding-joedow
Copy link
Contributor Author

Still failing 😅 Just run ./mach fmt

I left too late last night and didn't have a computer on hand, so I had to try to make changes on my phone. As expected, I couldn't make all the changes.

@mrobinson mrobinson added this pull request to the merge queue Jul 4, 2025
@mrobinson mrobinson removed this pull request from the merge queue due to a manual request Jul 4, 2025
@mrobinson mrobinson added this pull request to the merge queue Jul 4, 2025
Merged via the queue into servo:main with commit 068406e Jul 4, 2025
21 checks passed
@coding-joedow coding-joedow deleted the incremental-box-tree-update-for-flex branch July 4, 2025 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0