diff --git content/browser/renderer_host/input/fling_scheduler.cc content/browser/renderer_host/input/fling_scheduler.cc index 431df5d50debe..0fcc9ea8fbb1a 100644 --- content/browser/renderer_host/input/fling_scheduler.cc +++ content/browser/renderer_host/input/fling_scheduler.cc @@ -68,6 +68,9 @@ void FlingScheduler::ProgressFlingOnBeginFrameIfneeded( } ui::Compositor* FlingScheduler::GetCompositor() { + if (compositor_) { + return compositor_; + } if (!host_->GetView()) { return nullptr; } diff --git content/browser/renderer_host/render_widget_host_impl.cc content/browser/renderer_host/render_widget_host_impl.cc index 6902bb7ea90f7..c57b43fe0fce2 100644 --- content/browser/renderer_host/render_widget_host_impl.cc +++ content/browser/renderer_host/render_widget_host_impl.cc @@ -3216,6 +3216,11 @@ void RenderWidgetHostImpl::OnInvalidInputEventSource() { GetProcess(), bad_message::INPUT_ROUTER_INVALID_EVENT_SOURCE); } +void RenderWidgetHostImpl::SetCompositorForFlingScheduler( + ui::Compositor* compositor) { + GetRenderInputRouter()->fling_scheduler()->SetCompositor(compositor); +} + void RenderWidgetHostImpl::AddPendingUserActivation( const WebInputEvent& event) { if ((base::FeatureList::IsEnabled( diff --git content/browser/renderer_host/render_widget_host_impl.h content/browser/renderer_host/render_widget_host_impl.h index b3218a69a1d9e..a7b8e6c20659a 100644 --- content/browser/renderer_host/render_widget_host_impl.h +++ content/browser/renderer_host/render_widget_host_impl.h @@ -806,6 +806,7 @@ class CONTENT_EXPORT RenderWidgetHostImpl void ProgressFlingIfNeeded(base::TimeTicks current_time); void StopFling(); + void SetCompositorForFlingScheduler(ui::Compositor* compositor); RenderWidgetHostViewBase* GetRenderWidgetHostViewBase(); diff --git content/common/input/fling_scheduler_base.h content/common/input/fling_scheduler_base.h index e8ee63f3abc2e..765ea358e093a 100644 --- content/common/input/fling_scheduler_base.h +++ content/common/input/fling_scheduler_base.h @@ -5,14 +5,26 @@ #ifndef CONTENT_COMMON_INPUT_FLING_SCHEDULER_BASE_H_ #define CONTENT_COMMON_INPUT_FLING_SCHEDULER_BASE_H_ +#include "base/memory/raw_ptr.h" #include "content/common/input/fling_controller.h" +namespace ui { +class Compositor; +} + namespace content { class FlingSchedulerBase : public FlingControllerSchedulerClient { public: virtual void ProgressFlingOnBeginFrameIfneeded( base::TimeTicks current_time) = 0; + + void SetCompositor(ui::Compositor* compositor) { + compositor_ = compositor; + } + +protected: + raw_ptr compositor_ = nullptr; }; } // namespace content diff --git content/common/input/render_input_router.h content/common/input/render_input_router.h index 9e94dc720f9c9..c3ad0d7d2e6c2 100644 --- content/common/input/render_input_router.h +++ content/common/input/render_input_router.h @@ -60,6 +60,7 @@ class CONTENT_EXPORT RenderInputRouter : public InputRouterImplClient { InputRouter* input_router() { return input_router_.get(); } RenderInputRouterDelegate* delegate() { return delegate_; } + FlingSchedulerBase* fling_scheduler() { return fling_scheduler_.get(); } void SetForceEnableZoom(bool); void SetDeviceScaleFactor(float device_scale_factor);