I see that there are notes in the README that this attribute may need to evolve into a list:
"this may need to be a set of elements painted"
(But I somehow doubt that this API will evolve to actually report the FULL list of all elements.)
The current specification implies that this value would be the literal last element that updates area, even by 1px, based on implementation defined paint order. (see https://wicg.github.io/container-timing/#maybe-update-last-new-painted-area and https://wicg.github.io/container-timing/#ref-for-maybe-update-the-last-new-painted-area).
We recently worked on changes to the LCP spec to try to remove paint implementation order differences w.r.t. LCP candidate reporting. We resolved this by taking two passes:
- First, taking ALL element paints in one rendering update, and find the largest overall for that paint
- Then, compare that element against the previous largest candidate from all previous paints to see if we have a new largest.
This way, the relative element paint order doesn't matter for candidate selection.
I wonder if a model like this could be borrowed for Container Timing?
I think you already observe the same stream of paints at the same moment and order as LCP. After filtering down to elements which are part of a container tree, you could iterate the elements from largest to smallest element, and find the largest element that actually does update the size of the region.
Alternatively, you could keep a copy of the previously recorded region while you are updating the new region, and consider any element that would update the old region by even 1px to be a viable candidate -- not just those elements which update the current region.
(FWIW, Container Timing right now just has a "When an element is painted" hook which is per-element, but this isn't the right integration with paint timing nor element timing, I think)
See:
I see that there are notes in the README that this attribute may need to evolve into a list:
(But I somehow doubt that this API will evolve to actually report the FULL list of all elements.)
The current specification implies that this value would be the literal last element that updates area, even by 1px, based on implementation defined paint order. (see https://wicg.github.io/container-timing/#maybe-update-last-new-painted-area and https://wicg.github.io/container-timing/#ref-for-maybe-update-the-last-new-painted-area).
We recently worked on changes to the LCP spec to try to remove paint implementation order differences w.r.t. LCP candidate reporting. We resolved this by taking two passes:
This way, the relative element paint order doesn't matter for candidate selection.
I wonder if a model like this could be borrowed for Container Timing?
I think you already observe the same stream of paints at the same moment and order as LCP. After filtering down to elements which are part of a container tree, you could iterate the elements from largest to smallest element, and find the largest element that actually does update the size of the region.
Alternatively, you could keep a copy of the previously recorded region while you are updating the new region, and consider any element that would update the old region by even 1px to be a viable candidate -- not just those elements which update the current region.
(FWIW, Container Timing right now just has a "When an element is painted" hook which is per-element, but this isn't the right integration with paint timing nor element timing, I think)
See: