Chromium Code Reviews| Index: content/browser/renderer_host/render_widget_host_view_android.cc |
| diff --git a/content/browser/renderer_host/render_widget_host_view_android.cc b/content/browser/renderer_host/render_widget_host_view_android.cc |
| index c0daedb3742ad67bd53a166e75877f14c7c4db38..713f18fb83a449343b96f6f4681b2ce1674d65f0 100644 |
| --- a/content/browser/renderer_host/render_widget_host_view_android.cc |
| +++ b/content/browser/renderer_host/render_widget_host_view_android.cc |
| @@ -55,6 +55,7 @@ |
| #include "content/browser/renderer_host/input/synthetic_gesture_target_android.h" |
| #include "content/browser/renderer_host/input/web_input_event_builders_android.h" |
| #include "content/browser/renderer_host/render_process_host_impl.h" |
| +#include "content/browser/renderer_host/render_view_host_delegate_view.h" |
| #include "content/browser/renderer_host/render_view_host_impl.h" |
| #include "content/browser/renderer_host/render_widget_host_impl.h" |
| #include "content/common/gpu_host_messages.h" |
| @@ -336,13 +337,6 @@ std::unique_ptr<ui::TouchSelectionController> CreateSelectionController( |
| return base::MakeUnique<ui::TouchSelectionController>(client, config); |
| } |
| -std::unique_ptr<OverscrollControllerAndroid> CreateOverscrollController( |
| - ContentViewCoreImpl* content_view_core, |
| - float dpi_scale) { |
| - return base::MakeUnique<OverscrollControllerAndroid>(content_view_core, |
| - dpi_scale); |
| -} |
| - |
| gfx::RectF GetSelectionRect(const ui::TouchSelectionController& controller) { |
| gfx::RectF rect = controller.GetRectBetweenBounds(); |
| if (rect.IsEmpty()) |
| @@ -469,6 +463,8 @@ RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid( |
| host_->SetView(this); |
| SetContentViewCore(content_view_core); |
| + CreateOverscrollControllerIfPossible(); |
| + |
| if (GetTextInputManager()) |
| GetTextInputManager()->AddObserver(this); |
| } |
| @@ -1220,6 +1216,11 @@ void RenderWidgetHostViewAndroid::SetSynchronousCompositorClient( |
| } |
| } |
| +void RenderWidgetHostViewAndroid::OnOverscrollRefreshHandlerSet() { |
| + overscroll_controller_.reset(); |
|
boliu
2016/12/06 23:24:16
this can be set multiple times? did this fix a uni
rlanday
2016/12/07 00:07:48
We were discussing how in the current version of t
boliu
2016/12/07 00:33:15
Wording.. it's not CVC can be set multiple times,
|
| + CreateOverscrollControllerIfPossible(); |
| +} |
| + |
| bool RenderWidgetHostViewAndroid::SupportsAnimation() const { |
| // The synchronous (WebView) compositor does not have a proper browser |
| // compositor with which to drive animations. |
| @@ -1768,7 +1769,6 @@ void RenderWidgetHostViewAndroid::SetContentViewCore( |
| bool resize = false; |
| if (content_view_core != content_view_core_) { |
| - overscroll_controller_.reset(); |
| selection_controller_.reset(); |
| ReleaseLocksOnSurface(); |
| // TODO(yusufo) : Get rid of the below conditions and have a better handling |
| @@ -1815,12 +1815,6 @@ void RenderWidgetHostViewAndroid::SetContentViewCore( |
| if (!selection_controller_) |
| selection_controller_ = CreateSelectionController(this, content_view_core_); |
| - |
| - if (!overscroll_controller_ && |
| - view_.GetWindowAndroid()->GetCompositor()) { |
| - overscroll_controller_ = CreateOverscrollController( |
| - content_view_core_, ui::GetScaleFactorForNativeView(GetNativeView())); |
| - } |
| } |
| void RenderWidgetHostViewAndroid::RunAckCallbacks() { |
| @@ -1884,9 +1878,7 @@ void RenderWidgetHostViewAndroid::OnDetachedFromWindow() { |
| void RenderWidgetHostViewAndroid::OnAttachCompositor() { |
| DCHECK(content_view_core_); |
| - if (!overscroll_controller_) |
| - overscroll_controller_ = CreateOverscrollController( |
| - content_view_core_, ui::GetScaleFactorForNativeView(GetNativeView())); |
| + CreateOverscrollControllerIfPossible(); |
| ui::WindowAndroidCompositor* compositor = |
| view_.GetWindowAndroid()->GetCompositor(); |
| delegated_frame_host_->RegisterFrameSinkHierarchy( |
| @@ -2000,4 +1992,32 @@ void RenderWidgetHostViewAndroid::ComputeEventLatencyOSTouchHistograms( |
| } |
| } |
| +void RenderWidgetHostViewAndroid::CreateOverscrollControllerIfPossible() { |
| + // an OverscrollController is already set |
| + if (overscroll_controller_) { |
|
boliu
2016/12/06 23:24:16
style: for if blocks where the both the condition
rlanday
2016/12/07 00:07:48
Ok
|
| + return; |
| + } |
| + |
| + RenderWidgetHostDelegate* delegate = host_->delegate(); |
| + if (!delegate) { |
| + return; |
| + } |
| + |
| + RenderViewHostDelegateView* delegate_view = delegate->GetDelegateView(); |
| + if (!delegate_view) { |
|
boliu
2016/12/06 23:24:16
can this happen? Pretty sure WebContentsImpl alway
rlanday
2016/12/07 00:07:48
This is actually what the test case was failing on
boliu
2016/12/07 00:33:15
Ok.. Do you have the full stack of when that happe
rlanday
2016/12/07 00:46:00
I 8.385s Main signal 11 (SIGSEGV), code 1 (SEG
boliu
2016/12/07 00:50:19
meh, MockRenderWidgetHostDelegate doesn't have a D
|
| + return; |
| + } |
| + |
| + ui::OverscrollRefreshHandler* overscroll_refresh_handler = |
| + delegate_view->GetOverscrollRefreshHandler(); |
| + if (!overscroll_refresh_handler) { |
| + return; |
| + } |
| + |
| + overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( |
| + overscroll_refresh_handler, |
| + content_view_core_->GetWindowAndroid()->GetCompositor(), |
|
boliu
2016/12/06 23:24:16
also need to null check GetCompositor
boliu
2016/12/06 23:26:57
actually, need to null check content_view_core_ as
rlanday
2016/12/07 00:07:48
Hmm, this check doesn't already exist in the curre
boliu
2016/12/07 00:33:15
Line 1820 on the left
boliu
2016/12/07 00:35:46
Oh wait you mean null check for CVC? Well, in theo
|
| + ui::GetScaleFactorForNativeView(GetNativeView())); |
| +} |
| + |
| } // namespace content |