Skip to content

Commit

Permalink
[view-transitions] Pseudo elements can't be captured.
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=273166
<rdar://126964779>

Reviewed by Tim Nguyen.

Pseudo elements (like ::backdrop) don't have an associated Element, so can't
be found by ViewTransition's forEachElementInPaintOrder.

Rather than holding an Element in CapturedElement, hold a Styleable instead
which can represent these pseudo elements as well.

Since the normal Styleable class uses an Element reference, introduces a
WeakStyleable object which uses a WeakPtr to an Element and can (maybe) be
converted back into a Styleable when needed.

Changes most of the ViewTransition code to operator on the RenderElement
from the Styleable, instead of the Element.

Adds capturedInViewTransition to Styleable, so that we can look this up
in cases where the renderer hasn't yet been created.

* LayoutTests/TestExpectations:
* Source/WebCore/dom/Element.cpp:
(WebCore::operator<<):
* Source/WebCore/dom/Element.h:
(WebCore::Element::capturedInViewTransition const): Deleted.
(WebCore::Element::setCapturedInViewTransition): Deleted.
* Source/WebCore/dom/Node.h:
* Source/WebCore/dom/ViewTransition.cpp:
(WebCore::effectiveViewTransitionName):
(WebCore::captureOverflowRect):
(WebCore::snapshotElementVisualOverflowClippedToViewport):
(WebCore::forEachRendererInPaintOrder):
(WebCore::ViewTransition::captureOldState):
(WebCore::ViewTransition::captureNewState):
(WebCore::ViewTransition::activateViewTransition):
(WebCore::ViewTransition::clearViewTransition):
(WebCore::ViewTransition::copyElementBaseProperties):
(WebCore::ViewTransition::updatePseudoElementStyles):
(WebCore::ViewTransition::viewTransitionNewPseudoForCapturedElement):
(WebCore::forEachElementInPaintOrder): Deleted.
* Source/WebCore/dom/ViewTransition.h:
* Source/WebCore/rendering/RenderElement.cpp:
(WebCore::RenderElement::initializeStyle):
(WebCore::RenderElement::capturedInViewTransition const): Deleted.
* Source/WebCore/rendering/RenderElement.h:
* Source/WebCore/rendering/RenderLayer.cpp:
(WebCore::RenderLayer::rebuildZOrderLists):
(WebCore::RenderLayer::paintList):
* Source/WebCore/rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::updateTransform):
(WebCore::RenderLayerBacking::updateGeometry):
* Source/WebCore/rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::collectViewTransitionNewContentLayers):
* Source/WebCore/rendering/RenderObject.h:
(WebCore::RenderObject::capturedInViewTransition const):
(WebCore::RenderObject::setCapturedInViewTransition):
* Source/WebCore/style/Styleable.cpp:
(WebCore::Styleable::capturedInViewTransition const):
* Source/WebCore/style/Styleable.h:
(WebCore::WeakStyleable::operator bool const):
(WebCore::WeakStyleable::operator=):
(WebCore::WeakStyleable::styleable const):

Canonical link: https://commits.webkit.org/278123@main
  • Loading branch information
mattwoodrow committed Apr 29, 2024
1 parent cbc7316 commit 3ba31ee
Show file tree
Hide file tree
Showing 18 changed files with 186 additions and 119 deletions.
6 changes: 1 addition & 5 deletions LayoutTests/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -6939,7 +6939,6 @@ imported/w3c/web-platform-tests/navigation-api/updateCurrentEntry-method/locatio
# Reftest failures:
imported/w3c/web-platform-tests/css/css-view-transitions/content-with-clip-root.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-view-transitions/content-with-transform-old-image.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-view-transitions/dialog-in-top-layer-during-transition-new.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-view-transitions/fractional-box-new.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-view-transitions/fractional-box-old.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-view-transitions/fractional-box-with-overflow-children-old.html [ ImageOnlyFailure ]
Expand All @@ -6958,7 +6957,7 @@ imported/w3c/web-platform-tests/css/css-view-transitions/root-to-shared-animatio
imported/w3c/web-platform-tests/css/css-view-transitions/snapshot-containing-block-absolute.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-view-transitions/span-with-overflowing-text.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-view-transitions/content-with-transform-new-image.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-view-transitions/dialog-in-top-layer-during-transition-old.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-view-transitions/dialog-in-rtl-iframe.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-view-transitions/fractional-box-with-overflow-children-new.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-view-transitions/massive-element-below-viewport-offscreen-new.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-view-transitions/massive-element-below-viewport-offscreen-old.html [ ImageOnlyFailure ]
Expand All @@ -6977,11 +6976,8 @@ imported/w3c/web-platform-tests/css/css-view-transitions/scroller.html [ ImageOn

# Timeouts
imported/w3c/web-platform-tests/css/css-view-transitions/iframe-transition.sub.html [ Skip ]
imported/w3c/web-platform-tests/css/css-view-transitions/pseudo-get-computed-style.html [ Skip ]
imported/w3c/web-platform-tests/css/css-view-transitions/pseudo-computed-style-stays-in-sync-with-new-element.html [ Skip ]
imported/w3c/web-platform-tests/css/css-view-transitions/fragmented-during-transition-skips.html [ Skip ]
imported/w3c/web-platform-tests/css/css-view-transitions/root-element-display-none-during-transition-crash.html [ Skip ]
imported/w3c/web-platform-tests/css/css-view-transitions/iframe-transition-destroyed-document-crash.html [ Skip ]
imported/w3c/web-platform-tests/css/css-view-transitions/transition-in-hidden-page.html [ Skip ]

# Flakes
Expand Down
11 changes: 11 additions & 0 deletions Source/WebCore/dom/Element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5655,4 +5655,15 @@ void Element::setVisibilityAdjustment(OptionSet<VisibilityAdjustment> adjustment
ensureElementRareData().setVisibilityAdjustment(adjustment);
}

TextStream& operator<<(TextStream& ts, ContentRelevancy relevancy)
{
switch (relevancy) {
case ContentRelevancy::OnScreen: ts << "OnScreen"; break;
case ContentRelevancy::Focused: ts << "Focused"; break;
case ContentRelevancy::IsInTopLayer: ts << "IsInTopLayer"; break;
case ContentRelevancy::Selected: ts << "Selected"; break;
}
return ts;
}

} // namespace WebCore
5 changes: 2 additions & 3 deletions Source/WebCore/dom/Element.h
Original file line number Diff line number Diff line change
Expand Up @@ -787,9 +787,6 @@ class Element : public ContainerNode {
bool hasCustomState(const AtomString& state) const;
CustomStateSet& ensureCustomStateSet();

bool capturedInViewTransition() const { return hasElementStateFlag(ElementStateFlag::CapturedInViewTransition); }
void setCapturedInViewTransition(bool captured) { setElementStateFlag(ElementStateFlag::CapturedInViewTransition, captured); }

protected:
Element(const QualifiedName&, Document&, OptionSet<TypeFlag>);

Expand Down Expand Up @@ -981,6 +978,8 @@ inline void Element::disconnectFromResizeObservers()
void invalidateForSiblingCombinators(Element* sibling);
inline bool isInTopLayerOrBackdrop(const RenderStyle&, const Element*);

WEBCORE_EXPORT WTF::TextStream& operator<<(WTF::TextStream&, ContentRelevancy);

} // namespace WebCore

SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::Element)
Expand Down
5 changes: 2 additions & 3 deletions Source/WebCore/dom/Node.h
Original file line number Diff line number Diff line change
Expand Up @@ -652,11 +652,10 @@ class Node : public EventTarget {
NeedsSVGRendererUpdate = 1 << 3,
NeedsUpdateQueryContainerDependentStyle = 1 << 4,
EverHadSmoothScroll = 1 << 5,
CapturedInViewTransition = 1 << 6,
#if ENABLE(FULLSCREEN_API)
IsFullscreen = 1 << 7,
IsFullscreen = 1 << 6,
#endif
// 8-bits free.
// 9-bits free.
};

enum class TabIndexState : uint8_t {
Expand Down
Loading

0 comments on commit 3ba31ee

Please sign in to comment.