Skip to content

Commit

Permalink
[view-transitions] Names should be tree-scoped
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=273883
rdar://127995859

Reviewed by Antti Koivisto.

Corresponding spec issue: w3c/csswg-drafts#10145
Corresponding spec PR: w3c/csswg-drafts#10306

This ignores view-transition names from shadow DOM, given the pseudo-elements are linked to the document element,
exposing shadow DOM names to the view transition pseudo-elements would be a violation of shadow DOM principles.

We don't check for the tree scope directly in `forEachRendererInPaintOrder` because a shadow DOM element might have
flat tree descendants that have an outer tree scope.

We also use the `Styleable`'s element instead of `RenderElement`'s element because for pseudo-elements we want to consider
the associated element's tree scope.

* LayoutTests/TestExpectations:
* LayoutTests/platform/glib/TestExpectations:
* Source/WebCore/dom/ViewTransition.cpp:
(WebCore::ViewTransition::captureOldState):
(WebCore::ViewTransition::captureNewState):

Canonical link: https://commits.webkit.org/278704@main
  • Loading branch information
nt1m committed May 13, 2024
1 parent c216b09 commit 9f0a444
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 0 additions & 1 deletion LayoutTests/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -6929,7 +6929,6 @@ imported/w3c/web-platform-tests/css/css-view-transitions/snapshot-containing-blo
imported/w3c/web-platform-tests/css/css-view-transitions/fractional-translation-from-position.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-view-transitions/scroller-child.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-view-transitions/scroller.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-view-transitions/names-are-tree-scoped.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-view-transitions/iframe-and-main-frame-transition-new-main-new-iframe.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-view-transitions/iframe-and-main-frame-transition-old-main-new-iframe.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-view-transitions/iframe-and-main-frame-transition-old-main-old-iframe.html [ ImageOnlyFailure ]
Expand Down
1 change: 1 addition & 0 deletions LayoutTests/platform/glib/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -4145,6 +4145,7 @@ imported/w3c/web-platform-tests/css/css-view-transitions/massive-element-on-top-
imported/w3c/web-platform-tests/css/css-view-transitions/massive-element-right-of-viewport-offscreen-old.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-view-transitions/massive-element-below-viewport-offscreen-old.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-view-transitions/massive-element-left-of-viewport-offscreen-old.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-view-transitions/names-are-tree-scoped.html [ ImageOnlyFailure ]

imported/w3c/web-platform-tests/svg/text/reftests/transform-dynamic-change.html [ ImageOnlyFailure ]

Expand Down
7 changes: 4 additions & 3 deletions Source/WebCore/dom/ViewTransition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,8 @@ ExceptionOr<void> ViewTransition::captureOldState()
m_initialLargeViewportSize = view->sizeForCSSLargeViewportUnits();

auto result = forEachRendererInPaintOrder([&](RenderLayerModelObject& renderer) -> ExceptionOr<void> {
if (!Styleable::fromRenderer(renderer))
auto styleable = Styleable::fromRenderer(renderer);
if (!styleable || &styleable->element.treeScope() != document())
return { };

if (auto name = effectiveViewTransitionName(renderer); !name.isNull()) {
Expand Down Expand Up @@ -394,8 +395,8 @@ ExceptionOr<void> ViewTransition::captureNewState()
ListHashSet<AtomString> usedTransitionNames;
if (CheckedPtr view = document()->renderView()) {
auto result = forEachRendererInPaintOrder([&](RenderLayerModelObject& renderer) -> ExceptionOr<void> {
std::optional<const Styleable> styleable = Styleable::fromRenderer(renderer);
if (!styleable)
auto styleable = Styleable::fromRenderer(renderer);
if (!styleable || &styleable->element.treeScope() != document())
return { };

if (auto name = effectiveViewTransitionName(renderer); !name.isNull()) {
Expand Down

0 comments on commit 9f0a444

Please sign in to comment.