Scoped View Transitions for WebKit

GitHub: PR #81741 (draft), tip 4904b70990 updated 2026-11-20 Bugzilla: to be filed css-view-transitions-2 flag: ScopedViewTransitionsEnabled

CSS View Transitions Level 2 adds Element.startViewTransition(): a view transition scoped to one element instead of the whole document. The pseudo-element tree (::view-transition, ::view-transition-group(), ...) is generated on the scope element, only its subtree participates, and the rest of the page keeps running -- including other scoped transitions at the same time.

const transition = card.startViewTransition(() => updateCard());
await transition.finished;
93/93scoped tests pass, wpt upstream rev 536ae94
93/93scoped tests pass, in-tree import (same rev)
0unexpected results in css/css-view-transitions/ (482 run)
1flag, default off

93/93 is this build on the current upstream suite (wpt rev 536ae94, 77 tests + 16 crashtests), scored wpt.fyi-style: a test counts as passing if its status is PASS, or OK with zero failing subtests. WebKit's in-tree import of the scoped directory is at the same revision, so both numbers agree. The suite is fully green: per-scope rendering suppression (pause-rendering, pause-rendering-resize, ink-overflow-on-target), pseudo trees on replaced and MathML scope renderers (scope-replaced-elements, scope-mathml-root), fractional-border snapshot geometry (fractional-border-shift), and all 8 tentative shadowRoots-option tests pass.

Before / after

Same build, same demo page, screenshot taken mid-transition with every animation parked at 50% (animation-play-state: paused plus a negative animation-delay, in the stylesheet before startViewTransition() runs). Before (flag off, the shipping behavior today): the DOM mutation applies instantly, there is nothing to animate. After: tiles morph inside the scope while the spinner and ticker outside the scope keep running -- parked at the same angle in both captures, so the only difference is the transition itself.

before -- no Element.startViewTransition, instant swapflag off
before: end state applied instantly
after -- mid-transition, scope morphing, outside liveflag on
after: tiles cross-fading and morphing
before -- clipping/overflow demo, instant swapflag off
before: end state, no transition
after -- escape past the scope, clipped by the ancestor, scroll stays 0,0flag on
after: group outside scope bounds, cut at ancestor clip

Video

The same transition as video, assembled from 25 per-frame captures of the same build with the flag on (animations stepped through animation-delay, 1.5s duration). The before video is the flag-off behavior: a few frames of the old state, then the end state.

before -- instant swapflag off
after -- scoped morph, 25 captured framesflag on

A second capture page exercises the clipping and overflow rules: the pseudo tree escapes the scope's own bounds but stays clipped by an ancestor overflow: hidden, and a scope with overflow: auto gains no scroll range from the overlay.

before -- instant swapflag off
after -- escape + ancestor clip, no scroll rangeflag on

Nested clip demo (vt project video pair)

The cross-browser overview page embeds one video pair per engine of the same nested-clip scenario (ported from the Firefox demo): both #clipper and #card are named, the clipper's group has overflow: clip + border-radius, and with view-transition-group: contain the card's group nests inside ::view-transition-group-children(clipper) and stays clipped while the clipper flies across the panel.

before -- flag off, instant swapflag off
after -- nested group clipped by its container, forward then back (same cycle as the live demo)flag on

Live sampler - canonical cross-engine cases

The four scenarios every engine sampler in the cross-browser VT project captures with identical ids, so the Rendered / Before / After tabs line up across Chromium, Firefox and WebKit.

case-list · reorder a 3-item list, view-transition-name per row
alpha
beta
gamma
before
after
Three named rows swap order inside the scope; each row's group morphs to its new slot while old and new text cross-fade.
case-image · swap an img source inside the scope
before
after
The same <img> keeps its view-transition-name while its source swaps, so the old and new images cross-fade in place.
case-nested · named descendants inside a named scope
n1
n2
before
after
The scope itself and two descendants carry view-transition-name; the names resolve per scope, so all three groups animate inside one scoped transition.
case-clip · transition inside a clipped region
VT
before
after
The scope sits inside an ancestor with clip-path + overflow: hidden (amber dashed): the overlay escapes the green scope bounds but stays cut at the clipped region's rounded edge.

Live sampler - WebKit patch details

Element-scoped morph · card.startViewTransition(mutate)
A
B
C
D
before
after
Four named tiles re-grid inside the scope. With the flag on the old and new snapshots cross-fade and the groups morph between the two layouts; without it the mutation applies instantly (the Rendered tab falls back to that).
Scope inside a shadow root · adopted stylesheet styles the pseudos
before
after
The scope lives inside a shadow root and its view-transition-name comes from an adopted stylesheet. The dynamic ::view-transition styles resolve in the shadow root's style scope, so the part morphs from square to circle across the card.
Scope clip escaped, ancestor clip applied
VT
scope
before
after
The tile flies beyond the green scope bounds -- the pseudo tree escapes the scope's own clip -- but the dashed amber ancestor with overflow: hidden still cuts it at the edge. Mid-flight the circle is visibly outside the scope and clipped by the ancestor.
Overlay adds no scrollable overflow to the scope
VT
scroll 0,0
before
after
The scope has overflow: auto with styled (non-overlay) scrollbars. The flying group leaves the content box during the morph, yet no scrollbars appear and scrollLeft/scrollTop stay 0,0: the overlay is excluded from the scope's scrollable overflow.

What is in the pull request

One feature-flagged implementation pass, developed as an 18-commit branch on top of main (PR #81741, draft while under development): the Element.startViewTransition() API and scoped lifecycle, the pseudo-element tree on arbitrary scope elements, the snapshot containing block and its layout (no scrollable-overflow contribution to the scope), clip escape past the scope with ancestor clips still applied, scoped capture and paint order, UA styles and dynamic ::view-transition styles resolved in the scope's (possibly shadow) style scope, concurrent scoped transitions, the view-transition-group property with nested groups and ::view-transition-group-children(), the tentative shadowRoots option with match-element name masking, and UA-sheet parsing of the new pseudos with the flag off.

Result

beforeafter
wpt css/css-view-transitions/scoped at rev 536ae94 (93 tests, in-tree import)suite skipped, 0 passing93 of 93 pass, including per-scope rendering suppression, replaced and MathML scope roots, and fractional-border geometry
full css-view-transitions suite (482 run)as expectedas expected, 0 unexpected results, no document-transition regressions
tentative shadowRoots option (8 tests)0 passing8 of 8 pass, including cross-tree morph and match-element masking
Gecko implementation (bug 2075158, same suite rev)77 of 93 at the same wpt revision: Gecko does not implement the tentative shadowRoots option yet. The Firefox sampler runs the same four cases with the same capture recipe: two independent implementations, same output.
Commands behind the numbers and captures
# test counts
Tools/Scripts/run-webkit-tests -2 --release --pixel-tests \
    imported/w3c/web-platform-tests/css/css-view-transitions/scoped
Tools/Scripts/run-webkit-tests -2 --release --pixel-tests \
    imported/w3c/web-platform-tests/css/css-view-transitions

# 93/93: WebKit's in-tree import of the scoped directory matches wpt upstream
# rev 536ae94 (github.com/web-platform-tests/wpt, 77 tests + 16 crashtests);
# scored wpt.fyi-style (test passes if PASS, or OK with zero failing subtests)

# captures: same build, WebKitTestRunner pixel output; the capture page parks
# every animation at frame t/24 via animation-play-state: paused and a negative
# animation-delay in the stylesheet before startViewTransition() runs; the flag
# (ScopedViewTransitionsEnabled, via a webkit-test-runner header comment) is the
# only variable between before and after. WKTR's pixel dump renders the live
# frame including the ::view-transition overlay -- beware that DOM-snapshot APIs
# can re-rasterize without the overlay and show the end state instead.
Tools/Scripts/run-webkit-tests -2 --release --pixel-tests --reset-results tmp-cap
# the PNG lands next to each page as -expected.png

# videos from the 25 per-frame captures
ffmpeg -framerate 16 -i after-main-%02d.png -c:v libx264 -pix_fmt yuv420p after-main.mp4
ffmpeg -framerate 16 -i after-main-%02d.png -vf format=yuv420p -c:v libvpx-vp9 -b:v 0 -crf 32 after-main.webm

# per-case crops, identical geometry within each before/after pair
magick after-main-still.png -crop 420x460+0+0 +repage after-a.png