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() {
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() {
RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid();
if (view) {
......@@ -421,15 +414,6 @@ jboolean ContentViewCore::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() {
WebContentsViewAndroid* wcva = static_cast<WebContentsViewAndroid*>(
static_cast<WebContentsImpl*>(web_contents())->GetView());
......
......@@ -75,14 +75,6 @@ class ContentViewCore : public WebContentsObserver {
JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj,
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,
const base::android::JavaParamRef<jobject>& obj);
......@@ -103,8 +95,6 @@ class ContentViewCore : public WebContentsObserver {
const base::android::JavaParamRef<jobject>& obj,
jfloat dipScale);
jint GetBackgroundColor(JNIEnv* env, jobject obj);
void SetTextTrackSettings(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj,
......@@ -117,29 +107,14 @@ class ContentViewCore : public WebContentsObserver {
const base::android::JavaParamRef<jstring>& textTrackTextShadow,
const base::android::JavaParamRef<jstring>& textTrackTextSize);
void SetBackgroundOpaque(JNIEnv* env,
const base::android::JavaParamRef<jobject>& jobj,
jboolean opaque);
jboolean UsingSynchronousCompositing(
JNIEnv* env,
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
// --------------------------------------------------------------------------
void UpdateCursor(const content::CursorInfo& info);
void OnTouchDown(const base::android::ScopedJavaLocalRef<jobject>& event);
ui::ViewAndroid* GetViewAndroid() const;
......
......@@ -10,6 +10,7 @@
#include "content/browser/android/composited_touch_handle_drawable.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_view_android.h"
#include "content/public/common/context_menu_params.h"
#include "jni/SelectionPopupControllerImpl_jni.h"
#include "third_party/WebKit/public/web/WebContextMenuData.h"
......@@ -43,6 +44,9 @@ SelectionPopupController::SelectionPopupController(
WebContents* web_contents)
: RenderWidgetHostConnector(web_contents) {
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 {
......@@ -197,4 +201,13 @@ void SelectionPopupController::OnSelectWordAroundCaretAck(bool did_select,
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
......@@ -46,6 +46,7 @@ class SelectionPopupController : public RenderWidgetHostConnector {
void OnSelectWordAroundCaretAck(bool did_select,
int start_adjust,
int end_adjust);
void HidePopupsAndPreserveSelection();
std::unique_ptr<ui::TouchHandleDrawable> CreateTouchHandleDrawable();
void MoveRangeSelectionExtent(const gfx::PointF& extent);
......
......@@ -12,6 +12,7 @@
#include "content/browser/android/content_view_core.h"
#include "content/browser/android/gesture_listener_manager.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/renderer_host/display_util.h"
#include "content/browser/renderer_host/render_view_host_factory.h"
......@@ -350,8 +351,8 @@ void WebContentsViewAndroid::StartDragging(
return;
}
if (content_view_core_)
content_view_core_->HidePopupsAndPreserveSelection();
if (selection_popup_controller_)
selection_popup_controller_->HidePopupsAndPreserveSelection();
}
void WebContentsViewAndroid::UpdateDragCursor(blink::WebDragOperation op) {
......
......@@ -22,6 +22,7 @@ namespace content {
class ContentViewCore;
class RenderWidgetHostViewAndroid;
class SelectPopup;
class SelectionPopupController;
class SynchronousCompositorClient;
class WebContentsImpl;
......@@ -46,6 +47,10 @@ class WebContentsViewAndroid : public WebContentsView,
synchronous_compositor_client_ = client;
}
void set_selection_popup_controller(SelectionPopupController* controller) {
selection_popup_controller_ = controller;
}
SynchronousCompositorClient* synchronous_compositor_client() const {
return synchronous_compositor_client_;
}
......@@ -145,6 +150,8 @@ class WebContentsViewAndroid : public WebContentsView,
// Interface used to get notified of events from the synchronous compositor.
SynchronousCompositorClient* synchronous_compositor_client_;
SelectionPopupController* selection_popup_controller_ = nullptr;
// Show/hide popup UI for <select> tag.
std::unique_ptr<SelectPopup> select_popup_;
......
......@@ -475,10 +475,8 @@ public class ContentViewCoreImpl implements ContentViewCore, DisplayAndroidObser
PopupController.hideAll(mWebContents);
}
@CalledByNative
private void hidePopupsAndPreserveSelection() {
getSelectionPopupController().destroyActionModeAndKeepSelection();
PopupController.hideAll(mWebContents);
getSelectionPopupController().hidePopupsAndPreserveSelection();
}
private void resetGestureDetection() {
......
......@@ -1397,6 +1397,12 @@ public class SelectionPopupControllerImpl extends ActionModeCallbackHelper
}
}
@CalledByNative
public void hidePopupsAndPreserveSelection() {
destroyActionModeAndKeepSelection();
getPopupController().hideAllPopups();
}
public void destroyActionModeAndUnselect() {
mUnselectAllOnDismiss = true;
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