SubtreeVisibility: optimize nested lock case.
This patch fixes the "double render" problem that occurs when we have auto locks inside a container that becomes hidden. Previously: - When outer element becomes hidden, intersection observer tells inner locks that they are not visible, causing them to lock and invalidate their own layout (which propagates up to the outer element). - When outer element becomes visible, we process the dirty tree (render 1) - If inner elements are visible: - Then we run intersection observer which notifies the auto locks that they are visible, causing them to unlock and invalidate their own layout - Next lifecycle, we clean the layout state (render 2) - If not: - Nothing happens since intersection observer does not run on already hidden elements. Overall, we have at least 1 render. In the worst case, 2 renders. Now: - When outer element becomes hidden, intersection observer tells inner locks that they are not visible. The inner locks discover they are nested, and register themselves for lifecycle notifications but don't invalidate layout. - When outer element becomes visible, we don't do anything (I'm not counting the element itself updating its layout; since the important thing is the subtree) - If inner elements are visible: - Nothing happens; the next intersection observer that lets them know they are visible will be ignored since they are unlocked. - If inner elements are not visible: - At the start of the next lifecycle, the element determines that it should be not visible and that its not nested; it locks itself causing layout invalidations. This same lifecycle is render 1. Overall, we can have no renders. In the worst case, 1 render. R=chrishtr@chromium.org, flackr@chromium.org Change-Id: Id9a75a7a68d5208c49839f9f2adb9ee8ae6734e8 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2092196Reviewed-by:Robert Flack <flackr@chromium.org> Commit-Queue: vmpstr <vmpstr@chromium.org> Cr-Commit-Position: refs/heads/master@{#749229}
Showing
This diff is collapsed.
Please register or sign in to comment