Skip to content

[css-view-transitions-1] Positioning of ::view-transition (the root pseudo) #8070

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jakearchibald opened this issue Nov 14, 2022 · 8 comments

Comments

@jakearchibald
Copy link
Contributor

jakearchibald commented Nov 14, 2022

In #7859 we resolved on the concept of a "snapshot viewport", which would be consistent regardless of things like URL bar, virtual keyboard, and scrollbars, meaning animations would be stable, even if those things only existed on one side of the transition.

This means ::view-transition would fill this snapshot viewport throughout the transition.

We see two options to achieve this:

Option 1: Position ::view-transition per frame

::view-transition would use regular position: fixed positioning. inset: 0 would only fill the layout viewport, which is often smaller than the snaphshot viewport. So, to fix this, negative inset values would be used to make ::view-transition fill the snapshot viewport. These values would be updated per frame, to ensure the positioning is correct during any state changes (eg url bar hiding/showing).

This would be developer-visible via getComputedStyle, and would behave differently if the position was set to a non-fixed value.

In browsers that use a compositor to manage position: fixed items, there's a worry that there may be rendering instability in frames where the compositor is 'ahead' of the main thread's updates to the inset.

Option 2: Layout ::view-transition within the "snapshot viewport"

The ::view-transition would have position: fixed; inset: 0. However, we would use spec prose to say this pseudo is laid out in the snapshot viewport, so position: fixed; inset: 0 would cause ::view-transition to fill the snapshot viewport, rather than the layout viewport.

This wouldn't have the compositor issues, as it isn't dependent on main thread style updates. However, it's perhaps a bit weird for this one pseudo to appear to treat layout differently. Is there anything else that does something similar?


We're leaning towards "option 2".

@bokand
Copy link
Contributor

bokand commented Nov 23, 2022

Assuming we go with option 2, a related issue is what happens if author style does something else, e.g. position: absolute. Should that work and what does it mean? Is it possible to say author style cannot affect the position of this element? Or else, can we spec that this lives in its own formatting context with absolute & fixed containing blocks being the "snapshot viewport"?

@jakearchibald
Copy link
Contributor Author

Or else, can we spec that this lives in its own formatting context with absolute & fixed containing blocks being the "snapshot viewport"?

That's my preference.

@khushalsagar
Copy link
Member

+1 to author style can not change the computed position of ::view-transition.

@jakearchibald
Copy link
Contributor Author

Isn't it better to just say the snapshot viewport is ::view-transition's containing block? Then, even if the position value is changed, it's still laid out in the snapshot viewport.

@khushalsagar
Copy link
Member

Fair. So ::view-transition's containing block is the snapshot viewport which has no ancestor containing block. No matter what its position value is, the containing block remains the same.

@astearns astearns added Async Resolution: Proposed Candidate for auto-resolve with stated time limit and removed Agenda+ labels Dec 15, 2022
@astearns
Copy link
Member

Since this change has consensus here and will get wider review once we commit the change, we likely do not need to spend meeting time on it.

The CSSWG will automatically accept this resolution one week from now if no objections are raised here. Anyone can add an emoji to this comment to express support. If you do not support this resolution, please add a new comment.

Proposed Resolution: ::view-transition's containing block is the snapshot viewport

@astearns
Copy link
Member

RESOLVED: ::view-transition's containing block is the snapshot viewport

@khushalsagar
Copy link
Member

Edits landed in #8126.

chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Jan 23, 2023
The ::view-transition is positioned behind viewport-insetting UI such as
the mobile URL bar, RTL/left-side vertical scrollbars, and virtual
keyboards. The ::view-transition needs to have its size and position set
to match the "snapshot root rect"[0].

Currently this is achieved by directly setting the size and location on
the ::view-transition's style in the UA stylesheet. However, this comes
with several drawbacks:

 * Requires the main thread to perform an update to change the position.
   The mobile URL bar can animate in on the compositor thread without a
   Blink update.
 * Makes it difficult for authors to style ::view-transition themselves.
   E.g. to shift the transition they'd have to use getComputedStyle and
   add their own value, which could be overwritten by the UA.
 * Is visible to authors via getComputedStyle which could complicate
   making changes in this area in the future.

w3c/csswg-drafts#8070 resolved and specified
that the containing block of `::view-transition` should be the
snapshot root rect.

This CL removes replaces the styles on ::view-transition with
`position:fixed; inset: 0` and special cases the containing block for
the ::view-transition pseudo element to match the geometry of the
snapshot root rect.

[0] https://chromium.googlesource.com/chromium/src/+/main/third_party/blink/renderer/core/view_transition/README.md#viewport-sizes

Bug: 1383980
Change-Id: Ie05de201dd3775717d4e231d08299471d68a2de4
aarongable pushed a commit to chromium/chromium that referenced this issue Jan 24, 2023
The ::view-transition is positioned behind viewport-insetting UI such as
the mobile URL bar, RTL/left-side vertical scrollbars, and virtual
keyboards. The ::view-transition needs to have its size and position set
to match the "snapshot root rect"[0].

Currently this is achieved by directly setting the size and location on
the ::view-transition's style in the UA stylesheet. However, this comes
with several drawbacks:

 * Requires the main thread to perform an update to change the position.
   The mobile URL bar can animate in on the compositor thread without a
   Blink update.
 * Makes it difficult for authors to style ::view-transition themselves.
   E.g. to shift the transition they'd have to use getComputedStyle and
   add their own value, which could be overwritten by the UA.
 * Is visible to authors via getComputedStyle which could complicate
   making changes in this area in the future.

w3c/csswg-drafts#8070 resolved and specified
that the containing block of `::view-transition` should be the
snapshot root rect.

This CL removes replaces the styles on ::view-transition with
`position:fixed; inset: 0` and special cases the containing block for
the ::view-transition pseudo element to match the geometry of the
snapshot root rect.

[0] https://chromium.googlesource.com/chromium/src/+/main/third_party/blink/renderer/core/view_transition/README.md#viewport-sizes

Bug: 1383980
Change-Id: Ie05de201dd3775717d4e231d08299471d68a2de4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4166263
Reviewed-by: Vladimir Levin <vmpstr@chromium.org>
Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: David Bokan <bokan@chromium.org>
Reviewed-by: Khushal Sagar <khushalsagar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1096264}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Jan 24, 2023
The ::view-transition is positioned behind viewport-insetting UI such as
the mobile URL bar, RTL/left-side vertical scrollbars, and virtual
keyboards. The ::view-transition needs to have its size and position set
to match the "snapshot root rect"[0].

Currently this is achieved by directly setting the size and location on
the ::view-transition's style in the UA stylesheet. However, this comes
with several drawbacks:

 * Requires the main thread to perform an update to change the position.
   The mobile URL bar can animate in on the compositor thread without a
   Blink update.
 * Makes it difficult for authors to style ::view-transition themselves.
   E.g. to shift the transition they'd have to use getComputedStyle and
   add their own value, which could be overwritten by the UA.
 * Is visible to authors via getComputedStyle which could complicate
   making changes in this area in the future.

w3c/csswg-drafts#8070 resolved and specified
that the containing block of `::view-transition` should be the
snapshot root rect.

This CL removes replaces the styles on ::view-transition with
`position:fixed; inset: 0` and special cases the containing block for
the ::view-transition pseudo element to match the geometry of the
snapshot root rect.

[0] https://chromium.googlesource.com/chromium/src/+/main/third_party/blink/renderer/core/view_transition/README.md#viewport-sizes

Bug: 1383980
Change-Id: Ie05de201dd3775717d4e231d08299471d68a2de4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4166263
Reviewed-by: Vladimir Levin <vmpstr@chromium.org>
Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: David Bokan <bokan@chromium.org>
Reviewed-by: Khushal Sagar <khushalsagar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1096264}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Jan 24, 2023
The ::view-transition is positioned behind viewport-insetting UI such as
the mobile URL bar, RTL/left-side vertical scrollbars, and virtual
keyboards. The ::view-transition needs to have its size and position set
to match the "snapshot root rect"[0].

Currently this is achieved by directly setting the size and location on
the ::view-transition's style in the UA stylesheet. However, this comes
with several drawbacks:

 * Requires the main thread to perform an update to change the position.
   The mobile URL bar can animate in on the compositor thread without a
   Blink update.
 * Makes it difficult for authors to style ::view-transition themselves.
   E.g. to shift the transition they'd have to use getComputedStyle and
   add their own value, which could be overwritten by the UA.
 * Is visible to authors via getComputedStyle which could complicate
   making changes in this area in the future.

w3c/csswg-drafts#8070 resolved and specified
that the containing block of `::view-transition` should be the
snapshot root rect.

This CL removes replaces the styles on ::view-transition with
`position:fixed; inset: 0` and special cases the containing block for
the ::view-transition pseudo element to match the geometry of the
snapshot root rect.

[0] https://chromium.googlesource.com/chromium/src/+/main/third_party/blink/renderer/core/view_transition/README.md#viewport-sizes

Bug: 1383980
Change-Id: Ie05de201dd3775717d4e231d08299471d68a2de4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4166263
Reviewed-by: Vladimir Levin <vmpstr@chromium.org>
Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: David Bokan <bokan@chromium.org>
Reviewed-by: Khushal Sagar <khushalsagar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1096264}
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Feb 1, 2023
…r ::view-transition, a=testonly

Automatic update from web-platform-tests
vt: Snapshot rect is containing block for ::view-transition

The ::view-transition is positioned behind viewport-insetting UI such as
the mobile URL bar, RTL/left-side vertical scrollbars, and virtual
keyboards. The ::view-transition needs to have its size and position set
to match the "snapshot root rect"[0].

Currently this is achieved by directly setting the size and location on
the ::view-transition's style in the UA stylesheet. However, this comes
with several drawbacks:

 * Requires the main thread to perform an update to change the position.
   The mobile URL bar can animate in on the compositor thread without a
   Blink update.
 * Makes it difficult for authors to style ::view-transition themselves.
   E.g. to shift the transition they'd have to use getComputedStyle and
   add their own value, which could be overwritten by the UA.
 * Is visible to authors via getComputedStyle which could complicate
   making changes in this area in the future.

w3c/csswg-drafts#8070 resolved and specified
that the containing block of `::view-transition` should be the
snapshot root rect.

This CL removes replaces the styles on ::view-transition with
`position:fixed; inset: 0` and special cases the containing block for
the ::view-transition pseudo element to match the geometry of the
snapshot root rect.

[0] https://chromium.googlesource.com/chromium/src/+/main/third_party/blink/renderer/core/view_transition/README.md#viewport-sizes

Bug: 1383980
Change-Id: Ie05de201dd3775717d4e231d08299471d68a2de4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4166263
Reviewed-by: Vladimir Levin <vmpstr@chromium.org>
Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: David Bokan <bokan@chromium.org>
Reviewed-by: Khushal Sagar <khushalsagar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1096264}

--

wpt-commits: aed10a113c9fc16605ea2ba2df218e6f3dec3f54
wpt-pr: 38131
jamienicol pushed a commit to jamienicol/gecko that referenced this issue Feb 3, 2023
…r ::view-transition, a=testonly

Automatic update from web-platform-tests
vt: Snapshot rect is containing block for ::view-transition

The ::view-transition is positioned behind viewport-insetting UI such as
the mobile URL bar, RTL/left-side vertical scrollbars, and virtual
keyboards. The ::view-transition needs to have its size and position set
to match the "snapshot root rect"[0].

Currently this is achieved by directly setting the size and location on
the ::view-transition's style in the UA stylesheet. However, this comes
with several drawbacks:

 * Requires the main thread to perform an update to change the position.
   The mobile URL bar can animate in on the compositor thread without a
   Blink update.
 * Makes it difficult for authors to style ::view-transition themselves.
   E.g. to shift the transition they'd have to use getComputedStyle and
   add their own value, which could be overwritten by the UA.
 * Is visible to authors via getComputedStyle which could complicate
   making changes in this area in the future.

w3c/csswg-drafts#8070 resolved and specified
that the containing block of `::view-transition` should be the
snapshot root rect.

This CL removes replaces the styles on ::view-transition with
`position:fixed; inset: 0` and special cases the containing block for
the ::view-transition pseudo element to match the geometry of the
snapshot root rect.

[0] https://chromium.googlesource.com/chromium/src/+/main/third_party/blink/renderer/core/view_transition/README.md#viewport-sizes

Bug: 1383980
Change-Id: Ie05de201dd3775717d4e231d08299471d68a2de4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4166263
Reviewed-by: Vladimir Levin <vmpstr@chromium.org>
Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: David Bokan <bokan@chromium.org>
Reviewed-by: Khushal Sagar <khushalsagar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1096264}

--

wpt-commits: aed10a113c9fc16605ea2ba2df218e6f3dec3f54
wpt-pr: 38131
marcoscaceres pushed a commit to web-platform-tests/wpt that referenced this issue Mar 28, 2023
The ::view-transition is positioned behind viewport-insetting UI such as
the mobile URL bar, RTL/left-side vertical scrollbars, and virtual
keyboards. The ::view-transition needs to have its size and position set
to match the "snapshot root rect"[0].

Currently this is achieved by directly setting the size and location on
the ::view-transition's style in the UA stylesheet. However, this comes
with several drawbacks:

 * Requires the main thread to perform an update to change the position.
   The mobile URL bar can animate in on the compositor thread without a
   Blink update.
 * Makes it difficult for authors to style ::view-transition themselves.
   E.g. to shift the transition they'd have to use getComputedStyle and
   add their own value, which could be overwritten by the UA.
 * Is visible to authors via getComputedStyle which could complicate
   making changes in this area in the future.

w3c/csswg-drafts#8070 resolved and specified
that the containing block of `::view-transition` should be the
snapshot root rect.

This CL removes replaces the styles on ::view-transition with
`position:fixed; inset: 0` and special cases the containing block for
the ::view-transition pseudo element to match the geometry of the
snapshot root rect.

[0] https://chromium.googlesource.com/chromium/src/+/main/third_party/blink/renderer/core/view_transition/README.md#viewport-sizes

Bug: 1383980
Change-Id: Ie05de201dd3775717d4e231d08299471d68a2de4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4166263
Reviewed-by: Vladimir Levin <vmpstr@chromium.org>
Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: David Bokan <bokan@chromium.org>
Reviewed-by: Khushal Sagar <khushalsagar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1096264}
i3roly pushed a commit to i3roly/firefox-dynasty that referenced this issue Jun 1, 2024
…r ::view-transition, a=testonly

Automatic update from web-platform-tests
vt: Snapshot rect is containing block for ::view-transition

The ::view-transition is positioned behind viewport-insetting UI such as
the mobile URL bar, RTL/left-side vertical scrollbars, and virtual
keyboards. The ::view-transition needs to have its size and position set
to match the "snapshot root rect"[0].

Currently this is achieved by directly setting the size and location on
the ::view-transition's style in the UA stylesheet. However, this comes
with several drawbacks:

 * Requires the main thread to perform an update to change the position.
   The mobile URL bar can animate in on the compositor thread without a
   Blink update.
 * Makes it difficult for authors to style ::view-transition themselves.
   E.g. to shift the transition they'd have to use getComputedStyle and
   add their own value, which could be overwritten by the UA.
 * Is visible to authors via getComputedStyle which could complicate
   making changes in this area in the future.

w3c/csswg-drafts#8070 resolved and specified
that the containing block of `::view-transition` should be the
snapshot root rect.

This CL removes replaces the styles on ::view-transition with
`position:fixed; inset: 0` and special cases the containing block for
the ::view-transition pseudo element to match the geometry of the
snapshot root rect.

[0] https://chromium.googlesource.com/chromium/src/+/main/third_party/blink/renderer/core/view_transition/README.md#viewport-sizes

Bug: 1383980
Change-Id: Ie05de201dd3775717d4e231d08299471d68a2de4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4166263
Reviewed-by: Vladimir Levin <vmpstr@chromium.org>
Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: David Bokan <bokan@chromium.org>
Reviewed-by: Khushal Sagar <khushalsagar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1096264}

--

wpt-commits: aed10a113c9fc16605ea2ba2df218e6f3dec3f54
wpt-pr: 38131
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants