Commit a304a0cf authored by jdduke@chromium.org's avatar jdduke@chromium.org

[Android] Force showing insertion handle when paste popup activated

An unhandled context menu may result in the showing of the paste popup. However,
this paste popup notification is not well-ordered with respect to other
notifications that determine insertion handle state, namely, position and
region editability updates. Consequently, the paste popup may be shown without
a corresponding insertion handle. Resolve this by forcing an editability and
position update when the paste popup notification is received.

BUG=400304,400330,396997

Review URL: https://codereview.chromium.org/447493002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@287845 0039d316-1c4b-4281-b951-d872f2087c98
parent 734cd0bb
...@@ -612,6 +612,12 @@ ContentViewCoreImpl::CreatePopupTouchHandleDrawable() { ...@@ -612,6 +612,12 @@ ContentViewCoreImpl::CreatePopupTouchHandleDrawable() {
} }
void ContentViewCoreImpl::ShowPastePopup(int x_dip, int y_dip) { void ContentViewCoreImpl::ShowPastePopup(int x_dip, int y_dip) {
RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid();
if (!view)
return;
view->OnShowingPastePopup(gfx::PointF(x_dip, y_dip));
JNIEnv* env = AttachCurrentThread(); JNIEnv* env = AttachCurrentThread();
ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
if (obj.is_null()) if (obj.is_null())
......
...@@ -1378,6 +1378,26 @@ void RenderWidgetHostViewAndroid::HideTextHandles() { ...@@ -1378,6 +1378,26 @@ void RenderWidgetHostViewAndroid::HideTextHandles() {
selection_controller_->HideAndDisallowShowingAutomatically(); selection_controller_->HideAndDisallowShowingAutomatically();
} }
void RenderWidgetHostViewAndroid::OnShowingPastePopup(
const gfx::PointF& point) {
if (!selection_controller_)
return;
// As the paste popup may be triggered *before* the bounds and editability
// of the region have been updated, explicitly set the properties now.
// TODO(jdduke): Remove this workaround when auxiliary paste popup
// notifications are no longer required, crbug.com/398170.
gfx::RectF rect(point, gfx::SizeF());
TouchHandleOrientation orientation = TOUCH_HANDLE_CENTER;
const bool visible = true;
HideTextHandles();
ShowSelectionHandlesAutomatically();
selection_controller_->OnSelectionEditable(true);
selection_controller_->OnSelectionEmpty(true);
selection_controller_->OnSelectionBoundsChanged(
rect, orientation, visible, rect, orientation, visible);
}
SkColor RenderWidgetHostViewAndroid::GetCachedBackgroundColor() const { SkColor RenderWidgetHostViewAndroid::GetCachedBackgroundColor() const {
return cached_background_color_; return cached_background_color_;
} }
......
...@@ -233,6 +233,7 @@ class CONTENT_EXPORT RenderWidgetHostViewAndroid ...@@ -233,6 +233,7 @@ class CONTENT_EXPORT RenderWidgetHostViewAndroid
void MoveCaret(const gfx::Point& point); void MoveCaret(const gfx::Point& point);
void HideTextHandles(); void HideTextHandles();
void OnShowingPastePopup(const gfx::PointF& point);
void SynchronousFrameMetadata( void SynchronousFrameMetadata(
const cc::CompositorFrameMetadata& frame_metadata); const cc::CompositorFrameMetadata& frame_metadata);
......
...@@ -2467,6 +2467,7 @@ public class ContentViewCore ...@@ -2467,6 +2467,7 @@ public class ContentViewCore
@SuppressWarnings("unused") @SuppressWarnings("unused")
@CalledByNative @CalledByNative
private void showPastePopup(int xDip, int yDip) { private void showPastePopup(int xDip, int yDip) {
if (!mHasInsertion) return;
final float contentOffsetYPix = mRenderCoordinates.getContentOffsetYPix(); final float contentOffsetYPix = mRenderCoordinates.getContentOffsetYPix();
getPastePopup().showAt( getPastePopup().showAt(
(int) mRenderCoordinates.fromDipToPix(xDip), (int) mRenderCoordinates.fromDipToPix(xDip),
......
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