Commit f5af1abb authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

[CompositeAfterPaint] Ensure animation timeline is attached to host

We need to attach the document animation timeline to the animation host
to make animations work. In pre-CompositeAfterPaint, this is done from
PaintLayerCompositor.

For CompositeAfterPaint, attach animation timeline from
Document::Initialize() and WebLocalFrameImpl::SetFrameWidget().

Bug: 702353
Change-Id: I5e19add5196e5b52ebcade42b58e336051b111e6
Reviewed-on: https://chromium-review.googlesource.com/c/1368994Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#615554}
parent b188cd82
......@@ -2725,6 +2725,9 @@ void Document::Initialize() {
// attached to a frame. Otherwise ContextLifecycleObserver::contextDestroyed
// wouldn't be fired.
network_state_observer_ = MakeGarbageCollected<NetworkStateObserver>(*this);
if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled())
AttachCompositorAnimationTimeline();
}
void Document::Shutdown() {
......@@ -2772,8 +2775,16 @@ void Document::Shutdown() {
markers_->PrepareForDestruction();
if (GetPage())
if (GetPage()) {
GetPage()->DocumentDetached(this);
if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) {
if (auto* compositor_timeline = Timeline().CompositorTimeline()) {
GetPage()->GetChromeClient().DetachCompositorAnimationTimeline(
compositor_timeline, frame_.Get());
}
}
}
probe::documentDetached(this);
// FIXME: consider using PausableObject.
......@@ -7174,6 +7185,14 @@ Locale& Document::GetCachedLocale(const AtomicString& locale) {
return *(result.stored_value->value);
}
void Document::AttachCompositorAnimationTimeline() {
DCHECK(RuntimeEnabledFeatures::CompositeAfterPaintEnabled());
if (auto* compositor_timeline = Timeline().CompositorTimeline()) {
GetPage()->GetChromeClient().AttachCompositorAnimationTimeline(
compositor_timeline, frame_.Get());
}
}
AnimationClock& Document::GetAnimationClock() {
DCHECK(GetPage());
return GetPage()->Animator().Clock();
......
......@@ -1237,6 +1237,11 @@ class CORE_EXPORT Document : public ContainerNode,
// Return a Locale for the default locale if the argument is null or empty.
Locale& GetCachedLocale(const AtomicString& locale = g_null_atom);
// For CompositeAfterPaint. This is called internally from Initialize(), but
// for the local frame root, the frame widget may be not set at the time,
// so this is also called from WebLocalFrameImpl::SetFrameWidget().
void AttachCompositorAnimationTimeline();
AnimationClock& GetAnimationClock();
DocumentTimeline& Timeline() const { return *timeline_; }
PendingAnimations& GetPendingAnimations() { return *pending_animations_; }
......
......@@ -2327,6 +2327,14 @@ void WebLocalFrameImpl::WillDetachParent() {
void WebLocalFrameImpl::SetFrameWidget(WebFrameWidgetBase* frame_widget) {
frame_widget_ = frame_widget;
// This is needed because the local frame root's widget may not be set when
// Document::Initialize() called AttachmentCompositorAnimationTimeline()
// (which requires frame widget to be effective).
if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled() && frame_widget) {
if (auto* document = GetFrame()->GetDocument())
document->AttachCompositorAnimationTimeline();
}
}
WebFrameWidget* WebLocalFrameImpl::FrameWidget() const {
......
......@@ -734,9 +734,10 @@ void ChromeClientImpl::AttachCompositorAnimationTimeline(
CompositorAnimationTimeline* compositor_timeline,
LocalFrame* local_frame) {
WebLocalFrameImpl* web_frame = WebLocalFrameImpl::FromFrame(local_frame);
if (CompositorAnimationHost* animation_host =
web_frame->LocalRootFrameWidget()->AnimationHost())
animation_host->AddTimeline(*compositor_timeline);
if (auto* widget = web_frame->LocalRootFrameWidget()) {
if (auto* animation_host = widget->AnimationHost())
animation_host->AddTimeline(*compositor_timeline);
}
}
void ChromeClientImpl::DetachCompositorAnimationTimeline(
......
......@@ -367,10 +367,6 @@ crbug.com/589265 fast/forms/text/input-appearance-autocomplete-very-long-value.h
crbug.com/589265 animations/svg/animated-filter-svg-element.html [ Failure ]
crbug.com/589265 virtual/threaded/animations/svg/animated-filter-svg-element.html [ Failure ]
# Some work remains to fully support composited animation and scrolling.
crbug.com/702350 virtual/threaded/transitions/opacity-transform-transitions-inside-iframe.html [ Timeout ]
crbug.com/702353 virtual/threaded/transitions/transition-end-event-destroy-iframe.html [ Timeout ]
# virtual/threaded variants of sub-directories and tests already skipped or marked as failing above.
Bug(none) virtual/threaded/http/tests/devtools/ [ Skip ]
Bug(none) virtual/threaded/fast/events/pinch/gesture-pinch-zoom-scroll-bubble.html [ Failure Crash ]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment