mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
layout: optimize the propagation and cleanup of RestyleDamage (#38199)
This change optimizes `RestyleDamage` propagation and cleanup to reduce unnecessary box reconstruction and relayouts, while preventing damage from the current reflow affecting subsequent ones. Improvements include: - For box damage caused by `NodeDamage`, `RestyleDamage::RELAYOUT` is no longer marked immediately—avoiding erroneous propagation of `LayoutDamage::RECOLLECT_BOX_TREE_CHILDREN` to descendants during `RestyleDamage` propagation. - Clearing damage for nodes whose boxes will be preserved, preventing it from carrying over to the next reflow and increasing its workload. Testing: This should not change observable behavior and is thus covered by existing WPT tests. Although Servo lacks performance test cases, manual testing shows that this modification reduces reflow time by nearly 250ms, representing a decrease of approximately 25%. Signed-off-by: sharpshooter_pt <ibluegalaxy_taoj@163.com>
This commit is contained in:
parent
87bbe0b374
commit
9d29017c0d
2 changed files with 29 additions and 11 deletions
|
@ -21,12 +21,11 @@ bitflags! {
|
|||
|
||||
impl LayoutDamage {
|
||||
pub fn recollect_box_tree_children() -> RestyleDamage {
|
||||
RestyleDamage::from_bits_retain(LayoutDamage::RECOLLECT_BOX_TREE_CHILDREN.bits()) |
|
||||
RestyleDamage::RELAYOUT
|
||||
RestyleDamage::from_bits_retain(LayoutDamage::RECOLLECT_BOX_TREE_CHILDREN.bits())
|
||||
}
|
||||
|
||||
pub fn rebuild_box_tree() -> RestyleDamage {
|
||||
RestyleDamage::from_bits_retain(LayoutDamage::REBUILD_BOX.bits()) | RestyleDamage::RELAYOUT
|
||||
RestyleDamage::from_bits_retain(LayoutDamage::REBUILD_BOX.bits())
|
||||
}
|
||||
|
||||
pub fn has_box_damage(&self) -> bool {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue