From 2aad4047e5acf7411016e3a68678196090abee25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Riku=20Palom=C3=A4ki?= Date: Tue, 26 Nov 2019 19:04:19 +0000 Subject: [PATCH] Fix OSR scrolling by passing our compositor to the fling scheduler (fixes issue #2745) --- .../osr/render_widget_host_view_osr.cc | 5 ++ patch/patch.cfg | 8 ++- patch/patches/osr_fling_2745.patch | 70 +++++++++++++++++++ 3 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 patch/patches/osr_fling_2745.patch diff --git a/libcef/browser/osr/render_widget_host_view_osr.cc b/libcef/browser/osr/render_widget_host_view_osr.cc index 45942c637..4aa97ed22 100644 --- a/libcef/browser/osr/render_widget_host_view_osr.cc +++ b/libcef/browser/osr/render_widget_host_view_osr.cc @@ -228,6 +228,11 @@ CefRenderWidgetHostViewOSR::CefRenderWidgetHostViewOSR( compositor_->SetRootLayer(root_layer_.get()); compositor_->AddChildFrameSink(GetFrameSinkId()); + content::RenderWidgetHostImpl* render_widget_host_impl = + content::RenderWidgetHostImpl::From(render_widget_host_); + if (render_widget_host_impl) + render_widget_host_impl->SetCompositorForFlingScheduler(compositor_.get()); + if (browser_impl_.get()) ResizeRootLayer(false); diff --git a/patch/patch.cfg b/patch/patch.cfg index 1809b460b..6dd5dc000 100644 --- a/patch/patch.cfg +++ b/patch/patch.cfg @@ -451,5 +451,11 @@ patches = [ # message loop. # https://bitbucket.org/chromiumembedded/cef/issues/2798 'name': 'content_app_shutdown_2798', - } + }, + { + # Add RenderWidgetHostImpl::SetCompositorForFlingScheduler to fix fling + # scrolling in OSR mode. + # https://bitbucket.org/chromiumembedded/cef/issues/2745 + 'name': 'osr_fling_2745', + }, ] diff --git a/patch/patches/osr_fling_2745.patch b/patch/patches/osr_fling_2745.patch new file mode 100644 index 000000000..8cfe604b4 --- /dev/null +++ b/patch/patches/osr_fling_2745.patch @@ -0,0 +1,70 @@ +diff --git content/browser/renderer_host/input/fling_scheduler.cc content/browser/renderer_host/input/fling_scheduler.cc +index cf220cb41b00..5ebff06e6031 100644 +--- content/browser/renderer_host/input/fling_scheduler.cc ++++ content/browser/renderer_host/input/fling_scheduler.cc +@@ -71,6 +71,9 @@ void FlingScheduler::ProgressFlingOnBeginFrameIfneeded( + } + + ui::Compositor* FlingScheduler::GetCompositor() { ++ if (compositor_) { ++ return compositor_; ++ } + #if defined(USE_AURA) + if (host_->GetView() && host_->GetView()->GetNativeView() && + host_->GetView()->GetNativeView()->GetHost() && +diff --git content/browser/renderer_host/input/fling_scheduler_base.h content/browser/renderer_host/input/fling_scheduler_base.h +index cc4b13a7b9c6..84f3b9ed7cf4 100644 +--- content/browser/renderer_host/input/fling_scheduler_base.h ++++ content/browser/renderer_host/input/fling_scheduler_base.h +@@ -7,12 +7,23 @@ + + #include "content/browser/renderer_host/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: ++ ui::Compositor* compositor_ = nullptr; + }; + + } // namespace content +diff --git content/browser/renderer_host/render_widget_host_impl.cc content/browser/renderer_host/render_widget_host_impl.cc +index e9e0afaa606c..d8edeaac94bf 100644 +--- content/browser/renderer_host/render_widget_host_impl.cc ++++ content/browser/renderer_host/render_widget_host_impl.cc +@@ -2676,6 +2676,11 @@ void RenderWidgetHostImpl::SetNeedsBeginFrameForFlingProgress() { + SetNeedsBeginFrame(true); + } + ++void RenderWidgetHostImpl::SetCompositorForFlingScheduler(ui::Compositor* compositor) ++{ ++ fling_scheduler_->SetCompositor(compositor); ++} ++ + void RenderWidgetHostImpl::AddPendingUserActivation( + const WebInputEvent& event) { + if (base::FeatureList::IsEnabled(features::kBrowserVerifiedUserActivation) && +diff --git content/browser/renderer_host/render_widget_host_impl.h content/browser/renderer_host/render_widget_host_impl.h +index 3620b4616a6e..42b9af5228b5 100644 +--- content/browser/renderer_host/render_widget_host_impl.h ++++ content/browser/renderer_host/render_widget_host_impl.h +@@ -717,6 +717,7 @@ class CONTENT_EXPORT RenderWidgetHostImpl + void ProgressFlingIfNeeded(base::TimeTicks current_time); + void StopFling(); + void SetNeedsBeginFrameForFlingProgress(); ++ void SetCompositorForFlingScheduler(ui::Compositor* compositor); + + // The RenderWidgetHostImpl will keep showing the old page (for a while) after + // navigation until the first frame of the new page arrives. This reduces