Commit f8f4b9c6 authored by Jinsuk Kim's avatar Jinsuk Kim Committed by Commit Bot

Android: Remove references to ContentViewCore in RWHVA

Now we got only a handful of references to ContentViewCore object
left in RenderWidgetHostViewAndroid.

All but 3 are all null checks trying to see if content_view_core_
is set to null or not, which is equivalent to checking if the native
view (ViewAndroid) of ContentViewCore and its own native view form
a view tree or not. This can be replaced simply by a boolean flag.

The only 3 are significant (i.e. invoking methods of CVC)

ContentViewCore::GetViewAndroid() - RWHVA may not have an access
    to the parent native view. It should be passed to RWHVA instead.

ContentViewCore::RequestDisallowInterceptTouchEvent() - It goes up
    to Java container view to invoke
    android.view.View.requestDisallowInterceptTouchEvent.
    One more move from CVC to ViewAndroidDelegate...

ContentViewCore::GetWindowAndroid() : same WindowAndroid (or null
    if not attached to view tree) can be obtained via
    ViewAndroid::GetWindowAndroid().

Bug: 626765
Change-Id: I80088c6a9ca2ca0047184ac77f84f08f64ff0acb
Reviewed-on: https://chromium-review.googlesource.com/958646
Commit-Queue: Jinsuk Kim <jinsukkim@chromium.org>
Reviewed-by: default avatarBo <boliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542999}
parent c53673df
...@@ -233,12 +233,12 @@ void ContentViewCore::RenderViewHostChanged(RenderViewHost* old_host, ...@@ -233,12 +233,12 @@ void ContentViewCore::RenderViewHostChanged(RenderViewHost* old_host,
static_cast<RenderWidgetHostViewAndroid*>( static_cast<RenderWidgetHostViewAndroid*>(
old_host->GetWidget()->GetView()); old_host->GetWidget()->GetView());
if (view) if (view)
view->SetContentViewCore(NULL); view->UpdateNativeViewTree(nullptr);
view = static_cast<RenderWidgetHostViewAndroid*>( view = static_cast<RenderWidgetHostViewAndroid*>(
new_host->GetWidget()->GetView()); new_host->GetWidget()->GetView());
if (view) if (view)
view->SetContentViewCore(this); view->UpdateNativeViewTree(GetViewAndroid());
} }
int new_pid = int new_pid =
GetRenderProcessIdFromRenderViewHost(web_contents_->GetRenderViewHost()); GetRenderProcessIdFromRenderViewHost(web_contents_->GetRenderViewHost());
...@@ -282,13 +282,6 @@ jint ContentViewCore::GetBackgroundColor(JNIEnv* env, jobject obj) { ...@@ -282,13 +282,6 @@ jint ContentViewCore::GetBackgroundColor(JNIEnv* env, jobject obj) {
return rwhva->GetCachedBackgroundColor(); return rwhva->GetCachedBackgroundColor();
} }
void ContentViewCore::RequestDisallowInterceptTouchEvent() {
JNIEnv* env = AttachCurrentThread();
ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
if (!obj.is_null())
Java_ContentViewCoreImpl_requestDisallowInterceptTouchEvent(env, obj);
}
void ContentViewCore::SendScreenRectsAndResizeWidget() { void ContentViewCore::SendScreenRectsAndResizeWidget() {
RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid(); RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid();
if (view) { if (view) {
......
...@@ -137,8 +137,6 @@ class ContentViewCore : public WebContentsObserver { ...@@ -137,8 +137,6 @@ class ContentViewCore : public WebContentsObserver {
void HidePopupsAndPreserveSelection(); void HidePopupsAndPreserveSelection();
void RequestDisallowInterceptTouchEvent();
// Returns the context with which the ContentViewCore was created, typically // Returns the context with which the ContentViewCore was created, typically
// the Activity context. // the Activity context.
base::android::ScopedJavaLocalRef<jobject> GetContext() const; base::android::ScopedJavaLocalRef<jobject> GetContext() const;
......
...@@ -47,7 +47,6 @@ struct DidOverscrollParams; ...@@ -47,7 +47,6 @@ struct DidOverscrollParams;
} }
namespace content { namespace content {
class ContentViewCore;
class GestureListenerManager; class GestureListenerManager;
class ImeAdapterAndroid; class ImeAdapterAndroid;
class OverscrollControllerAndroid; class OverscrollControllerAndroid;
...@@ -79,7 +78,7 @@ class CONTENT_EXPORT RenderWidgetHostViewAndroid ...@@ -79,7 +78,7 @@ class CONTENT_EXPORT RenderWidgetHostViewAndroid
public viz::BeginFrameObserver { public viz::BeginFrameObserver {
public: public:
RenderWidgetHostViewAndroid(RenderWidgetHostImpl* widget, RenderWidgetHostViewAndroid(RenderWidgetHostImpl* widget,
ContentViewCore* content_view_core); gfx::NativeView parent_native_view);
~RenderWidgetHostViewAndroid() override; ~RenderWidgetHostViewAndroid() override;
// Interface used to observe the destruction of a RenderWidgetHostViewAndroid. // Interface used to observe the destruction of a RenderWidgetHostViewAndroid.
...@@ -251,7 +250,7 @@ class CONTENT_EXPORT RenderWidgetHostViewAndroid ...@@ -251,7 +250,7 @@ class CONTENT_EXPORT RenderWidgetHostViewAndroid
bool WantsAnimateOnlyBeginFrames() const override; bool WantsAnimateOnlyBeginFrames() const override;
// Non-virtual methods // Non-virtual methods
void SetContentViewCore(ContentViewCore* content_view_core); void UpdateNativeViewTree(gfx::NativeView parent_native_view);
void OnContentViewCoreDestroyed(); void OnContentViewCoreDestroyed();
SkColor GetCachedBackgroundColor() const; SkColor GetCachedBackgroundColor() const;
void SendKeyEvent(const NativeWebKeyboardEvent& event); void SendKeyEvent(const NativeWebKeyboardEvent& event);
...@@ -416,9 +415,6 @@ class CONTENT_EXPORT RenderWidgetHostViewAndroid ...@@ -416,9 +415,6 @@ class CONTENT_EXPORT RenderWidgetHostViewAndroid
// appearance of overscroll glow and the keyboard. // appearance of overscroll glow and the keyboard.
bool is_in_vr_; bool is_in_vr_;
// ContentViewCore is our interface to the view system.
ContentViewCore* content_view_core_;
ImeAdapterAndroid* ime_adapter_android_; ImeAdapterAndroid* ime_adapter_android_;
TapDisambiguator* tap_disambiguator_; TapDisambiguator* tap_disambiguator_;
SelectionPopupController* selection_popup_controller_; SelectionPopupController* selection_popup_controller_;
......
...@@ -103,7 +103,7 @@ void WebContentsViewAndroid::SetContentViewCore( ...@@ -103,7 +103,7 @@ void WebContentsViewAndroid::SetContentViewCore(
content_view_core_ = content_view_core; content_view_core_ = content_view_core;
RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid();
if (rwhv) if (rwhv)
rwhv->SetContentViewCore(content_view_core_); rwhv->UpdateNativeViewTree(&view_);
if (web_contents_->ShowingInterstitialPage()) { if (web_contents_->ShowingInterstitialPage()) {
rwhv = static_cast<RenderWidgetHostViewAndroid*>( rwhv = static_cast<RenderWidgetHostViewAndroid*>(
...@@ -113,7 +113,7 @@ void WebContentsViewAndroid::SetContentViewCore( ...@@ -113,7 +113,7 @@ void WebContentsViewAndroid::SetContentViewCore(
->GetWidget() ->GetWidget()
->GetView()); ->GetView());
if (rwhv) if (rwhv)
rwhv->SetContentViewCore(content_view_core_); rwhv->UpdateNativeViewTree(&view_);
} }
} }
...@@ -253,8 +253,9 @@ RenderWidgetHostViewBase* WebContentsViewAndroid::CreateViewForWidget( ...@@ -253,8 +253,9 @@ RenderWidgetHostViewBase* WebContentsViewAndroid::CreateViewForWidget(
// order to paint it. See ContentView::GetRenderWidgetHostViewAndroid for an // order to paint it. See ContentView::GetRenderWidgetHostViewAndroid for an
// example of how this is achieved for InterstitialPages. // example of how this is achieved for InterstitialPages.
RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(render_widget_host); RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(render_widget_host);
gfx::NativeView native_view = content_view_core_ ? &view_ : nullptr;
RenderWidgetHostViewAndroid* rwhv = RenderWidgetHostViewAndroid* rwhv =
new RenderWidgetHostViewAndroid(rwhi, content_view_core_); new RenderWidgetHostViewAndroid(rwhi, native_view);
rwhv->SetSynchronousCompositorClient(synchronous_compositor_client_); rwhv->SetSynchronousCompositorClient(synchronous_compositor_client_);
return rwhv; return rwhv;
} }
...@@ -262,7 +263,7 @@ RenderWidgetHostViewBase* WebContentsViewAndroid::CreateViewForWidget( ...@@ -262,7 +263,7 @@ RenderWidgetHostViewBase* WebContentsViewAndroid::CreateViewForWidget(
RenderWidgetHostViewBase* WebContentsViewAndroid::CreateViewForPopupWidget( RenderWidgetHostViewBase* WebContentsViewAndroid::CreateViewForPopupWidget(
RenderWidgetHost* render_widget_host) { RenderWidgetHost* render_widget_host) {
RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(render_widget_host); RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(render_widget_host);
return new RenderWidgetHostViewAndroid(rwhi, NULL); return new RenderWidgetHostViewAndroid(rwhi, nullptr);
} }
void WebContentsViewAndroid::RenderViewCreated(RenderViewHost* host) { void WebContentsViewAndroid::RenderViewCreated(RenderViewHost* host) {
......
...@@ -436,11 +436,6 @@ public class ContentViewCoreImpl implements ContentViewCore, DisplayAndroidObser ...@@ -436,11 +436,6 @@ public class ContentViewCoreImpl implements ContentViewCore, DisplayAndroidObser
return nativeGetTopControlsShrinkBlinkHeightPixForTesting(mNativeContentViewCore); return nativeGetTopControlsShrinkBlinkHeightPixForTesting(mNativeContentViewCore);
} }
@CalledByNative
private void requestDisallowInterceptTouchEvent() {
mContainerView.requestDisallowInterceptTouchEvent(true);
}
@Override @Override
public boolean isScrollInProgress() { public boolean isScrollInProgress() {
return getSelectionPopupController().getScrollInProgress() return getSelectionPopupController().getScrollInProgress()
......
...@@ -333,6 +333,12 @@ public abstract class ViewAndroidDelegate { ...@@ -333,6 +333,12 @@ public abstract class ViewAndroidDelegate {
return mTemporaryContainerLocation[1]; return mTemporaryContainerLocation[1];
} }
@CalledByNative
private void requestDisallowInterceptTouchEvent() {
ViewGroup container = getContainerView();
if (container != null) container.requestDisallowInterceptTouchEvent(true);
}
@CalledByNative @CalledByNative
private boolean hasFocus() { private boolean hasFocus() {
ViewGroup containerView = getContainerView(); ViewGroup containerView = getContainerView();
......
...@@ -277,6 +277,14 @@ void ViewAndroid::RemoveObserver(ViewAndroidObserver* observer) { ...@@ -277,6 +277,14 @@ void ViewAndroid::RemoveObserver(ViewAndroidObserver* observer) {
observer_list_.RemoveObserver(observer); observer_list_.RemoveObserver(observer);
} }
void ViewAndroid::RequestDisallowInterceptTouchEvent() {
ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate());
if (delegate.is_null())
return;
JNIEnv* env = base::android::AttachCurrentThread();
Java_ViewAndroidDelegate_requestDisallowInterceptTouchEvent(env, delegate);
}
void ViewAndroid::OnAttachedToWindow() { void ViewAndroid::OnAttachedToWindow() {
for (auto& observer : observer_list_) for (auto& observer : observer_list_)
observer.OnAttachedToWindow(); observer.OnAttachedToWindow();
......
...@@ -167,6 +167,10 @@ class UI_ANDROID_EXPORT ViewAndroid { ...@@ -167,6 +167,10 @@ class UI_ANDROID_EXPORT ViewAndroid {
void AddObserver(ViewAndroidObserver* observer); void AddObserver(ViewAndroidObserver* observer);
void RemoveObserver(ViewAndroidObserver* observer); void RemoveObserver(ViewAndroidObserver* observer);
void RequestDisallowInterceptTouchEvent();
ViewAndroid* parent() const { return parent_; }
protected: protected:
ViewAndroid* parent_; ViewAndroid* parent_;
......
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