Commit 14a6a9bf authored by Jinsuk Kim's avatar Jinsuk Kim Committed by Commit Bot

Android: Let SelectionPopupController handle clearSelection..

Another case SelectionPopupController gets a native->Java
flow handed over from ContentViewCore. The feature is relevant
to selection controller, which is now is fully capable of
taking care of it without relying on ContentViewCore thanks
to https://crbug.com/c/956786.

Not related, but did some clean up in content_view_core.h
for method declarations left unused.

Bug: 598880
Change-Id: I5010644a67021632b1e2625167e02c3c4ab947d8
Reviewed-on: https://chromium-review.googlesource.com/963155Reviewed-by: default avatarBo <boliu@chromium.org>
Commit-Queue: Jinsuk Kim <jinsukkim@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543557}
parent dd97510d
...@@ -266,13 +266,6 @@ ScopedJavaLocalRef<jobject> ContentViewCore::GetJavaObject() { ...@@ -266,13 +266,6 @@ ScopedJavaLocalRef<jobject> ContentViewCore::GetJavaObject() {
return java_ref_.get(env); return java_ref_.get(env);
} }
jint ContentViewCore::GetBackgroundColor(JNIEnv* env, jobject obj) {
RenderWidgetHostViewAndroid* rwhva = GetRenderWidgetHostViewAndroid();
if (!rwhva)
return SK_ColorWHITE;
return rwhva->GetCachedBackgroundColor();
}
void ContentViewCore::SendScreenRectsAndResizeWidget() { void ContentViewCore::SendScreenRectsAndResizeWidget() {
RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid(); RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid();
if (view) { if (view) {
...@@ -421,15 +414,6 @@ jboolean ContentViewCore::UsingSynchronousCompositing( ...@@ -421,15 +414,6 @@ jboolean ContentViewCore::UsingSynchronousCompositing(
return content::GetContentClient()->UsingSynchronousCompositing(); return content::GetContentClient()->UsingSynchronousCompositing();
} }
void ContentViewCore::HidePopupsAndPreserveSelection() {
JNIEnv* env = AttachCurrentThread();
ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
if (obj.is_null())
return;
Java_ContentViewCoreImpl_hidePopupsAndPreserveSelection(env, obj);
}
void ContentViewCore::WebContentsDestroyed() { void ContentViewCore::WebContentsDestroyed() {
WebContentsViewAndroid* wcva = static_cast<WebContentsViewAndroid*>( WebContentsViewAndroid* wcva = static_cast<WebContentsViewAndroid*>(
static_cast<WebContentsImpl*>(web_contents())->GetView()); static_cast<WebContentsImpl*>(web_contents())->GetView());
......
...@@ -75,14 +75,6 @@ class ContentViewCore : public WebContentsObserver { ...@@ -75,14 +75,6 @@ class ContentViewCore : public WebContentsObserver {
JNIEnv* env, JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj, const base::android::JavaParamRef<jobject>& obj,
jint orientation); jint orientation);
jboolean SendMouseWheelEvent(JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj,
jlong time_ms,
jfloat x,
jfloat y,
jfloat ticks_x,
jfloat ticks_y,
jfloat pixels_per_tick);
void ResetGestureDetection(JNIEnv* env, void ResetGestureDetection(JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj); const base::android::JavaParamRef<jobject>& obj);
...@@ -103,8 +95,6 @@ class ContentViewCore : public WebContentsObserver { ...@@ -103,8 +95,6 @@ class ContentViewCore : public WebContentsObserver {
const base::android::JavaParamRef<jobject>& obj, const base::android::JavaParamRef<jobject>& obj,
jfloat dipScale); jfloat dipScale);
jint GetBackgroundColor(JNIEnv* env, jobject obj);
void SetTextTrackSettings( void SetTextTrackSettings(
JNIEnv* env, JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj, const base::android::JavaParamRef<jobject>& obj,
...@@ -117,29 +107,14 @@ class ContentViewCore : public WebContentsObserver { ...@@ -117,29 +107,14 @@ class ContentViewCore : public WebContentsObserver {
const base::android::JavaParamRef<jstring>& textTrackTextShadow, const base::android::JavaParamRef<jstring>& textTrackTextShadow,
const base::android::JavaParamRef<jstring>& textTrackTextSize); const base::android::JavaParamRef<jstring>& textTrackTextSize);
void SetBackgroundOpaque(JNIEnv* env,
const base::android::JavaParamRef<jobject>& jobj,
jboolean opaque);
jboolean UsingSynchronousCompositing( jboolean UsingSynchronousCompositing(
JNIEnv* env, JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj); const base::android::JavaParamRef<jobject>& obj);
// --------------------------------------------------------------------------
// Public methods that call to Java via JNI
// --------------------------------------------------------------------------
void HidePopupsAndPreserveSelection();
// Returns the context with which the ContentViewCore was created, typically
// the Activity context.
base::android::ScopedJavaLocalRef<jobject> GetContext() const;
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// Methods called from native code // Methods called from native code
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
void UpdateCursor(const content::CursorInfo& info);
void OnTouchDown(const base::android::ScopedJavaLocalRef<jobject>& event); void OnTouchDown(const base::android::ScopedJavaLocalRef<jobject>& event);
ui::ViewAndroid* GetViewAndroid() const; ui::ViewAndroid* GetViewAndroid() const;
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "content/browser/android/composited_touch_handle_drawable.h" #include "content/browser/android/composited_touch_handle_drawable.h"
#include "content/browser/renderer_host/render_widget_host_view_android.h" #include "content/browser/renderer_host/render_widget_host_view_android.h"
#include "content/browser/web_contents/web_contents_impl.h" #include "content/browser/web_contents/web_contents_impl.h"
#include "content/browser/web_contents/web_contents_view_android.h"
#include "content/public/common/context_menu_params.h" #include "content/public/common/context_menu_params.h"
#include "jni/SelectionPopupControllerImpl_jni.h" #include "jni/SelectionPopupControllerImpl_jni.h"
#include "third_party/WebKit/public/web/WebContextMenuData.h" #include "third_party/WebKit/public/web/WebContextMenuData.h"
...@@ -43,6 +44,9 @@ SelectionPopupController::SelectionPopupController( ...@@ -43,6 +44,9 @@ SelectionPopupController::SelectionPopupController(
WebContents* web_contents) WebContents* web_contents)
: RenderWidgetHostConnector(web_contents) { : RenderWidgetHostConnector(web_contents) {
java_obj_ = JavaObjectWeakGlobalRef(env, obj); java_obj_ = JavaObjectWeakGlobalRef(env, obj);
auto* wcva = static_cast<WebContentsViewAndroid*>(
static_cast<WebContentsImpl*>(web_contents)->GetView());
wcva->set_selection_popup_controller(this);
} }
ScopedJavaLocalRef<jobject> SelectionPopupController::GetContext() const { ScopedJavaLocalRef<jobject> SelectionPopupController::GetContext() const {
...@@ -197,4 +201,13 @@ void SelectionPopupController::OnSelectWordAroundCaretAck(bool did_select, ...@@ -197,4 +201,13 @@ void SelectionPopupController::OnSelectWordAroundCaretAck(bool did_select,
env, obj, did_select, start_adjust, end_adjust); env, obj, did_select, start_adjust, end_adjust);
} }
void SelectionPopupController::HidePopupsAndPreserveSelection() {
JNIEnv* env = AttachCurrentThread();
ScopedJavaLocalRef<jobject> obj = java_obj_.get(env);
if (obj.is_null())
return;
Java_SelectionPopupControllerImpl_hidePopupsAndPreserveSelection(env, obj);
}
} // namespace content } // namespace content
...@@ -46,6 +46,7 @@ class SelectionPopupController : public RenderWidgetHostConnector { ...@@ -46,6 +46,7 @@ class SelectionPopupController : public RenderWidgetHostConnector {
void OnSelectWordAroundCaretAck(bool did_select, void OnSelectWordAroundCaretAck(bool did_select,
int start_adjust, int start_adjust,
int end_adjust); int end_adjust);
void HidePopupsAndPreserveSelection();
std::unique_ptr<ui::TouchHandleDrawable> CreateTouchHandleDrawable(); std::unique_ptr<ui::TouchHandleDrawable> CreateTouchHandleDrawable();
void MoveRangeSelectionExtent(const gfx::PointF& extent); void MoveRangeSelectionExtent(const gfx::PointF& extent);
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "content/browser/android/content_view_core.h" #include "content/browser/android/content_view_core.h"
#include "content/browser/android/gesture_listener_manager.h" #include "content/browser/android/gesture_listener_manager.h"
#include "content/browser/android/select_popup.h" #include "content/browser/android/select_popup.h"
#include "content/browser/android/selection_popup_controller.h"
#include "content/browser/frame_host/interstitial_page_impl.h" #include "content/browser/frame_host/interstitial_page_impl.h"
#include "content/browser/renderer_host/display_util.h" #include "content/browser/renderer_host/display_util.h"
#include "content/browser/renderer_host/render_view_host_factory.h" #include "content/browser/renderer_host/render_view_host_factory.h"
...@@ -350,8 +351,8 @@ void WebContentsViewAndroid::StartDragging( ...@@ -350,8 +351,8 @@ void WebContentsViewAndroid::StartDragging(
return; return;
} }
if (content_view_core_) if (selection_popup_controller_)
content_view_core_->HidePopupsAndPreserveSelection(); selection_popup_controller_->HidePopupsAndPreserveSelection();
} }
void WebContentsViewAndroid::UpdateDragCursor(blink::WebDragOperation op) { void WebContentsViewAndroid::UpdateDragCursor(blink::WebDragOperation op) {
......
...@@ -22,6 +22,7 @@ namespace content { ...@@ -22,6 +22,7 @@ namespace content {
class ContentViewCore; class ContentViewCore;
class RenderWidgetHostViewAndroid; class RenderWidgetHostViewAndroid;
class SelectPopup; class SelectPopup;
class SelectionPopupController;
class SynchronousCompositorClient; class SynchronousCompositorClient;
class WebContentsImpl; class WebContentsImpl;
...@@ -46,6 +47,10 @@ class WebContentsViewAndroid : public WebContentsView, ...@@ -46,6 +47,10 @@ class WebContentsViewAndroid : public WebContentsView,
synchronous_compositor_client_ = client; synchronous_compositor_client_ = client;
} }
void set_selection_popup_controller(SelectionPopupController* controller) {
selection_popup_controller_ = controller;
}
SynchronousCompositorClient* synchronous_compositor_client() const { SynchronousCompositorClient* synchronous_compositor_client() const {
return synchronous_compositor_client_; return synchronous_compositor_client_;
} }
...@@ -145,6 +150,8 @@ class WebContentsViewAndroid : public WebContentsView, ...@@ -145,6 +150,8 @@ class WebContentsViewAndroid : public WebContentsView,
// Interface used to get notified of events from the synchronous compositor. // Interface used to get notified of events from the synchronous compositor.
SynchronousCompositorClient* synchronous_compositor_client_; SynchronousCompositorClient* synchronous_compositor_client_;
SelectionPopupController* selection_popup_controller_ = nullptr;
// Show/hide popup UI for <select> tag. // Show/hide popup UI for <select> tag.
std::unique_ptr<SelectPopup> select_popup_; std::unique_ptr<SelectPopup> select_popup_;
......
...@@ -475,10 +475,8 @@ public class ContentViewCoreImpl implements ContentViewCore, DisplayAndroidObser ...@@ -475,10 +475,8 @@ public class ContentViewCoreImpl implements ContentViewCore, DisplayAndroidObser
PopupController.hideAll(mWebContents); PopupController.hideAll(mWebContents);
} }
@CalledByNative
private void hidePopupsAndPreserveSelection() { private void hidePopupsAndPreserveSelection() {
getSelectionPopupController().destroyActionModeAndKeepSelection(); getSelectionPopupController().hidePopupsAndPreserveSelection();
PopupController.hideAll(mWebContents);
} }
private void resetGestureDetection() { private void resetGestureDetection() {
......
...@@ -1397,6 +1397,12 @@ public class SelectionPopupControllerImpl extends ActionModeCallbackHelper ...@@ -1397,6 +1397,12 @@ public class SelectionPopupControllerImpl extends ActionModeCallbackHelper
} }
} }
@CalledByNative
public void hidePopupsAndPreserveSelection() {
destroyActionModeAndKeepSelection();
getPopupController().hideAllPopups();
}
public void destroyActionModeAndUnselect() { public void destroyActionModeAndUnselect() {
mUnselectAllOnDismiss = true; mUnselectAllOnDismiss = true;
finishActionMode(); finishActionMode();
......
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