Files
Seokho Song a2f8d26092 Bug 2070610 [wpt PR 62527] - Store container selector cache in ContainerQueryList, a=testonly
Automatic update from web-platform-tests
Store container selector cache in ContainerQueryList

The selector cache maps each container selector to its resolved
container element, reducing container lookup from O(N) in tree
depth to O(1) once the cache is set.

Hold the cache on each ContainerQueryList instance and use it when
evaluating the query list. The cache is not used while the element
is in a display:none subtree.

Invalidate the cache when the resolved container may change:
- A style change affects container query evaluation
  (DiffAffectsContainerQueries). This bumps a controller cache
  generation, invalidating all caches.
- The element's layout tree is detached. This invalidates the caches
  of the lists on that element.

A local microbenchmark reading matches on 500 lists under a 1000-deep
ancestor chain:

---Before---

Time:
avg 8.175000011920929 ms
median 8.149999976158142 ms
stdev 0.19432745050615563 ms
min 7.800000071525574 ms
max 8.600000023841858 ms

---After---

Time:
avg 1.0600000083446501 ms
median 1.0499999523162842 ms
stdev 0.1698296159003472 ms
min 0.8999999761581421 ms
max 1.6999999284744263 ms

Bug: 40887402
Change-Id: I38d4be957c61067d615046dddc41487fa97c7d1a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8255022
Commit-Queue: Seokho Song <seokho@chromium.org>
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1693827}

--

wpt-commits: 7926f3ca1cd9f7f1df88db0bb0cee14f278a559b
wpt-pr: 62527
2026-09-11 14:48:06 +00:00
..
…
…