-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
layout: Add incremental box tree construction for inline boxes #38084
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
layout: Add incremental box tree construction for inline boxes #38084
Conversation
🔨 Triggering try run (#16294456385) for Linux (WPT) |
Test results for linux-wpt from try job (#16294456385): Flaky unexpected result (16)
Stable unexpected results that are known to be intermittent (18)
Stable unexpected results (1)
|
|
🔨 Triggering try run (#16413162149) for Linux (WPT) |
InlineItem::StartInlineBox(inline_box) => Some(inline_box.clone()), | ||
_ => None, | ||
}) | ||
.collect(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.iter().rev().filter_map(...).collect()
builds a new vector even if there are no matches
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's true. But it should be unlikely.
Test results for linux-wpt from try job (#16413162149): Flaky unexpected result (20)
Stable unexpected results that are known to be intermittent (17)
|
✨ Try run (#16413162149) succeeded. |
block_in_inline_splits: Vec<Vec<ArcRefCell<InlineItem>>>, | ||
|
||
/// If the [`InlineBox`] of an inline-level element is not damaged, it can be reused | ||
/// to support incremental layout. Since an [`InlineBox`] can be split by block |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Since" introduces a subordinated clause, but here there wouldn't be an independent clause owning it.
/// to support incremental layout. Since an [`InlineBox`] can be split by block | |
/// to support incremental layout. An [`InlineBox`] can be split by block |
if let Some(LayoutBox::InlineLevel(inline_level_box)) = old_layout_box { | ||
let old_block_in_inline_splits: Vec<ArcRefCell<InlineBox>> = inline_level_box | ||
.iter() | ||
.rev() // reverse to facilate the `Vec::pop` operation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this better than using a VecDeque
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is unnecessary to introduce the new data structure. No push
operation is needed for old_block_in_inline_splits
.
self.push_control_character_string(inline_box.borrow().base.style.bidi_control_chars().0); | ||
|
||
// Don't push a `SharedInlineStyles` if we are pushing this box when splitting | ||
// an IFC for a block-in-inline split. Shared styles are pushed as part of setting | ||
// up the second split of the IFC. | ||
if inline_box.is_first_split { | ||
if inline_box.borrow().is_first_split { | ||
self.shared_inline_styles_stack | ||
.push(inline_box.shared_inline_styles.clone()); | ||
.push(inline_box.borrow().shared_inline_styles.clone()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better just borrow once?
self.push_control_character_string(inline_box.borrow().base.style.bidi_control_chars().0); | |
// Don't push a `SharedInlineStyles` if we are pushing this box when splitting | |
// an IFC for a block-in-inline split. Shared styles are pushed as part of setting | |
// up the second split of the IFC. | |
if inline_box.is_first_split { | |
if inline_box.borrow().is_first_split { | |
self.shared_inline_styles_stack | |
.push(inline_box.shared_inline_styles.clone()); | |
.push(inline_box.borrow().shared_inline_styles.clone()); | |
} | |
let borrowed_inline_box = inline_box.borrow(); | |
self.push_control_character_string(borrowed_inline_box.base.style.bidi_control_chars().0); | |
// Don't push a `SharedInlineStyles` if we are pushing this box when splitting | |
// an IFC for a block-in-inline split. Shared styles are pushed as part of setting | |
// up the second split of the IFC. | |
if borrowed_inline_box.is_first_split { | |
self.shared_inline_styles_stack | |
.push(borrowed_inline_box.shared_inline_styles.clone()); | |
} | |
std::mem::drop(borrowed_inline_box); |
izip!(self.inline_box_stack.iter(), block_in_inline_splits) | ||
{ | ||
let old_block_in_inline_splits = std::mem::take(&mut self.old_block_in_inline_splits); | ||
for (identifier, historical_inline_boxes, old_inline_boxes) in izip!( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think "historical" and "old" aren't clearly telling these apart.
Signed-off-by: sharpshooter_pt <ibluegalaxy_taoj@163.com>
4bdbdfc
to
8e000e4
Compare
…#38084) This changes extend the incremental box tree construction for inline boxes. Since an `InlineItem` can be split into multiple `InlineItem`s by a block element, the reason such an inline item is marked as damaged may simply be the removal of the block element or the need to reconstruct its box tree. Therefore, under the current LayoutDamage design, theoretically, even damaged inline items might still have some of their splits reusable. However, based on the principle of simplicity and effectiveness, this PR only considers reusing undamaged inline boxes. 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 changes extend the incremental box tree construction for inline boxes. Since an
InlineItem
can be split into multipleInlineItem
s by a block element, the reason such an inline item is marked as damaged may simply be the removal of the block element or the need to reconstruct its box tree. Therefore, under the current LayoutDamage design, theoretically, even damaged inline items might still have some of their splits reusable. However, based on the principle of simplicity and effectiveness, this PR only considers reusing undamaged inline boxes.Testing: This should not change observable behavior and is thus covered by existing WPT tests.