layout: Add incremental box tree construction for inline floats and abspos (#37892)

Layout: Add incremental box tree construction for inline floats and
abspos

Due to false positives in the memory benchmark on CI, the previous PR
[37868](https://github.com/servo/servo/pull/37868) reverted. Now it is
resubmitted.

Signed-off-by: sharpshooter_pt <ibluegalaxy_taoj@163.com>
This commit is contained in:
JoeDow 2025-07-05 16:33:04 +08:00 committed by GitHub
parent c65cd1eadd
commit 864c877be5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 66 additions and 28 deletions

View file

@ -604,13 +604,17 @@ impl<'dom> BlockContainerBuilder<'dom, '_> {
) {
if let Some(builder) = self.inline_formatting_context_builder.as_mut() {
if !builder.is_empty() {
let inline_level_box =
builder.push_absolutely_positioned_box(AbsolutelyPositionedBox::construct(
let constructor = || {
ArcRefCell::new(AbsolutelyPositionedBox::construct(
self.context,
info,
display_inside,
contents,
));
))
};
let old_layout_box = box_slot.take_layout_box_if_undamaged(info.damage);
let inline_level_box =
builder.push_absolutely_positioned_box(constructor, old_layout_box);
box_slot.set(LayoutBox::InlineLevel(vec![inline_level_box]));
return;
}
@ -637,13 +641,17 @@ impl<'dom> BlockContainerBuilder<'dom, '_> {
) {
if let Some(builder) = self.inline_formatting_context_builder.as_mut() {
if !builder.is_empty() {
let inline_level_box = builder.push_float_box(FloatBox::construct(
self.context,
info,
display_inside,
contents,
self.propagated_data,
));
let constructor = || {
ArcRefCell::new(FloatBox::construct(
self.context,
info,
display_inside,
contents,
self.propagated_data,
))
};
let old_layout_box = box_slot.take_layout_box_if_undamaged(info.damage);
let inline_level_box = builder.push_float_box(constructor, old_layout_box);
box_slot.set(LayoutBox::InlineLevel(vec![inline_level_box]));
return;
}