Repository: servo/servo
File: components/layout/traversal.rs (Rust)

Code before:
                outer_inline_content_sizes_depend_on_content.set(
                    outer_inline_content_sizes_depend_on_content.get() ||
                        base.outer_inline_content_sizes_depend_on_content
                            .load(Ordering::Relaxed),
                );
            }
        });
        if outer_inline_content_sizes_depend_on_content.get() {
            damage_for_parent.insert(LayoutDamage::recompute_inline_content_sizes())
        }
    }

    // If the box will be preserved, update the box's style and also in any fragments
    // that haven't been cleared. Meanwhile, clear the damage to avoid affecting the
    // next reflow.
    if !element_layout_damage.has_box_damage() {
        if !original_element_damage.is_empty() {
            node.repair_style(context);
        }

        element_damage = RestyleDamage::empty();
    }

    if element_damage != original_element_damage {
        element_data.borrow_mut().damage = element_damage;
    }

    damage_for_parent
}


Review comment (performance):
```suggestion
        // Only clear the cached inline content sizes on ancestors, when this node's inline content
        // sizes actually depend on content, otherwise the ancestors don't on the descendant's
        // content either.
        if outer_inline_content_sizes_depend_on_content.get() {
            damage_for_parent.insert(LayoutDamage::recompute_inline_content_sizes())
        }
```

Code after:
                    return;
                }
                *base.cached_inline_content_size.borrow_mut() = None;
            }

            // When a block container has a mix of inline-level and block-level contents,
            // the inline-level ones are wrapped inside an anonymous block associated with
            // the block container. The anonymous block has an `auto` size, so its intrinsic
            // contribution depends on content, but it can't affect the intrinsic size of
            // ancestors if the block container is sized extrinsically.
            if !base.base_fragment_info.is_anonymous() {
                // TODO: Use `Cell::update()` once it becomes stable.
                outer_inline_content_sizes_depend_on_content.set(
                    outer_inline_content_sizes_depend_on_content.get() ||
                        base.outer_inline_content_sizes_depend_on_content
                            .load(Ordering::Relaxed),
                );
            }
        });

        // If the intrinsic contributions of this node depend on content, we will need to clear
        // the cached intrinsic sizes of the parent. But if the contributions are purely extrinsic,
        // then the intrinsic sizes of the ancestors won't be affected, and we can keep the cache.
        if outer_inline_content_sizes_depend_on_content.get() {
            damage_for_parent.insert(LayoutDamage::recompute_inline_content_sizes())
        }
    }

    // If the box will be preserved, update the box's style and also in any fragments
    // that haven't been cleared. Meanwhile, clear the damage to avoid affecting the
    // next reflow.
    if !element_layout_damage.has_box_damage() {
        if !original_element_damage.is_empty() {
            node.repair_style(context);
        }

        element_damage = RestyleDamage::empty();
    }

    if element_damage != original_element_damage {
        element_data.borrow_mut().damage = element_damage;
    }

    damage_for_parent
}