Consider using the layout viewport instead of the visual viewport
Nobody has claimed this yet.
- Dominant language
- Bikeshed
- Stars
- 72
- Forks
- 10
- Avg merge
- 9d 15h
- Merged PRs (30d)
- 3
Description
In Container Timing, we are using the same definition of intersectionRect that comes from Element Timing. For each paint, we calculate the intersection of that paint with the browser viewport.
We use that rectangle to then record the damaged area for a container timing. Anything painted offscreen is not reported. This is a limitation of Container Timing as is that is not going to report paints offscreen, that may be later visible to the user when the scroll down.
Now, checking at https://drafts.csswg.org/cssom-view/#visual-viewport there is the concept of visual viewport and layout viewport.
The proposal is:
- Use the layout viewport for the internal damage recording and the
sizeattribute. - Expose a new field
layoutIntersectionRectthat exposes the bounding box of the damaged areas related to the layout viewport. - Have a new attribute
viewportIntersectionRectthat is calculated whenPerformanceContainerTimingis created. MakeintersectionRectexpose that same value, for compatibility with the current proposal. Or just directly dropintersectionRectcompletely and avoid exposing the viewport intersection. - (Optional) Should we do the same change in ElementTiming?
With this proposal we would have some advantages:
- We could report paints that are not in the visible area for the user.
- We would be a bit more stable in the case of viewport scrolls or zoom, as those would not affect coordinates.
Potential problems:
- Is the layout viewport really well defined? Is that information useful for the developer to know where a paint has really happened? Will it be possible to add overlays from web using that?
- We already have a Chromium implementation using the visual viewport. So if we change and there are assumptions on where the visual viewport is painted, those would be broken.
- The polyfill is based on the element timing intersectionRect.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Container Timing definition of intersectionRect and the CSSOM View visual-viewport section linked in the issue. Compare the proposed layoutIntersectionRect, viewportIntersectionRect, and compatibility options with the existing Chromium implementation and Element Timing polyfill. Done means reaching a decision on the viewport model and documenting the resulting proposal.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- css
- Domain
- performance, web-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100