summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjdduke@chromium.org <jdduke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-11 01:08:10 +0000
committerjdduke@chromium.org <jdduke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-11 01:08:10 +0000
commit950a829a607e849b22b506499e84fbb7e95dd668 (patch)
tree2062e83e67b52bc1d19093aa69e6db84e3aed2f4
parent563594a497169e986ed7ba922a153faed9fafd0e (diff)
downloadchromium_src-950a829a607e849b22b506499e84fbb7e95dd668.zip
chromium_src-950a829a607e849b22b506499e84fbb7e95dd668.tar.gz
chromium_src-950a829a607e849b22b506499e84fbb7e95dd668.tar.bz2
Revert of Android-side of insertion/selection handles visibility. (https://codereview.chromium.org/188023002/)
Reason for revert: There are a number of cases where this incorrectly hides the selection/insertion handles in an editable node. Original issue's description: > Android-side of insertion/selection handles visibility. > > This patch relies on other two patches: > https://codereview.chromium.org/177903010/ > https://codereview.chromium.org/186753002/ > to correctly compute the visibility of selection and > insertion handles when editing text input, text area > and contenteditable elements. > > BUG=236033 > > Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=258839 BUG=372056 TBR=tedchoc@chromium.org Review URL: https://codereview.chromium.org/278923003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269667 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/browser/android/content_view_core_impl.cc14
-rw-r--r--content/browser/android/content_view_core_impl.h1
-rw-r--r--content/browser/renderer_host/render_widget_host_view_android.cc3
-rw-r--r--content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java35
-rw-r--r--content/public/android/java/src/org/chromium/content/browser/input/CursorController.java31
-rw-r--r--content/public/android/java/src/org/chromium/content/browser/input/HandleView.java16
-rw-r--r--content/public/android/java/src/org/chromium/content/browser/input/InsertionHandleController.java2
-rw-r--r--content/public/android/java/src/org/chromium/content/browser/input/SelectionHandleController.java2
-rw-r--r--content/public/android/javatests/src/org/chromium/content/browser/input/InsertionHandleTest.java29
-rw-r--r--content/public/android/javatests/src/org/chromium/content/browser/input/SelectionHandleTest.java93
10 files changed, 17 insertions, 209 deletions
diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core_impl.cc
index e0aa1d8..9f4ebfb 100644
--- a/content/browser/android/content_view_core_impl.cc
+++ b/content/browser/android/content_view_core_impl.cc
@@ -681,20 +681,6 @@ void ContentViewCoreImpl::OnSelectionBoundsChanged(
params.is_anchor_first);
}
-void ContentViewCoreImpl::OnSelectionRootBoundsChanged(
- const gfx::Rect& bounds) {
- JNIEnv* env = AttachCurrentThread();
-
- ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
- if (obj.is_null())
- return;
-
- ScopedJavaLocalRef<jobject> rect_object(CreateJavaRect(env, bounds));
- Java_ContentViewCore_setSelectionRootBounds(env,
- obj.obj(),
- rect_object.obj());
-}
-
void ContentViewCoreImpl::ShowPastePopup(int x_dip, int y_dip) {
JNIEnv* env = AttachCurrentThread();
ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
diff --git a/content/browser/android/content_view_core_impl.h b/content/browser/android/content_view_core_impl.h
index 4c52005..52cf643 100644
--- a/content/browser/android/content_view_core_impl.h
+++ b/content/browser/android/content_view_core_impl.h
@@ -265,7 +265,6 @@ class ContentViewCoreImpl : public ContentViewCore,
void OnSelectionChanged(const std::string& text);
void OnSelectionBoundsChanged(
const ViewHostMsg_SelectionBounds_Params& params);
- void OnSelectionRootBoundsChanged(const gfx::Rect& bounds);
void StartContentIntent(const GURL& content_url);
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 93e0ad7..1fbe093 100644
--- a/content/browser/renderer_host/render_widget_host_view_android.cc
+++ b/content/browser/renderer_host/render_widget_host_view_android.cc
@@ -660,9 +660,6 @@ void RenderWidgetHostViewAndroid::SelectionBoundsChanged(
void RenderWidgetHostViewAndroid::SelectionRootBoundsChanged(
const gfx::Rect& bounds) {
- if (content_view_core_) {
- content_view_core_->OnSelectionRootBoundsChanged(bounds);
- }
}
void RenderWidgetHostViewAndroid::ScrollOffsetChanged() {
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
index 62f9f4a..149b7862 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
@@ -265,11 +265,6 @@ public class ContentViewCore
private final RenderCoordinates.NormalizedPoint mEndHandlePoint;
private final RenderCoordinates.NormalizedPoint mInsertionHandlePoint;
- // Cached copy of the visible rectangle defined by two points. Needed to determine
- // visibility of insertion/selection handles.
- private final RenderCoordinates.NormalizedPoint mTopLeftVisibilityClippingPoint;
- private final RenderCoordinates.NormalizedPoint mBottomRightVisibilityClippingPoint;
-
// Tracks whether a selection is currently active. When applied to selected text, indicates
// whether the last selected text is still highlighted.
private boolean mHasSelection;
@@ -366,8 +361,6 @@ public class ContentViewCore
mStartHandlePoint = mRenderCoordinates.createNormalizedPoint();
mEndHandlePoint = mRenderCoordinates.createNormalizedPoint();
mInsertionHandlePoint = mRenderCoordinates.createNormalizedPoint();
- mTopLeftVisibilityClippingPoint = mRenderCoordinates.createNormalizedPoint();
- mBottomRightVisibilityClippingPoint = mRenderCoordinates.createNormalizedPoint();
mAccessibilityManager = (AccessibilityManager)
getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
mGestureStateListeners = new ObserverList<GestureStateListener>();
@@ -1923,7 +1916,6 @@ public class ContentViewCore
};
mSelectionHandleController.hideAndDisallowAutomaticShowing();
- updateInsertionSelectionVisibleBounds();
}
return mSelectionHandleController;
@@ -1962,7 +1954,6 @@ public class ContentViewCore
};
mInsertionHandleController.hideAndDisallowAutomaticShowing();
- updateInsertionSelectionVisibleBounds();
}
return mInsertionHandleController;
@@ -2462,32 +2453,6 @@ public class ContentViewCore
}
}
- @CalledByNative
- private void setSelectionRootBounds(Rect bounds) {
- mTopLeftVisibilityClippingPoint.setLocalDip(bounds.left, bounds.top);
- mBottomRightVisibilityClippingPoint.setLocalDip(bounds.right, bounds.bottom);
- updateInsertionSelectionVisibleBounds();
- }
-
- private void updateInsertionSelectionVisibleBounds() {
- if (mSelectionHandleController == null && mInsertionHandleController == null) {
- return;
- }
-
- int x1 = Math.round(mTopLeftVisibilityClippingPoint.getXPix());
- int y1 = Math.round(mTopLeftVisibilityClippingPoint.getYPix());
- int x2 = Math.round(mBottomRightVisibilityClippingPoint.getXPix());
- int y2 = Math.round(mBottomRightVisibilityClippingPoint.getYPix());
-
- if (mSelectionHandleController != null) {
- mSelectionHandleController.setVisibleClippingRectangle(x1, y1, x2, y2);
- }
-
- if (mInsertionHandleController != null) {
- mInsertionHandleController.setVisibleClippingRectangle(x1, y1, x2, y2);
- }
- }
-
@SuppressWarnings("unused")
@CalledByNative
private static void onEvaluateJavaScriptResult(
diff --git a/content/public/android/java/src/org/chromium/content/browser/input/CursorController.java b/content/public/android/java/src/org/chromium/content/browser/input/CursorController.java
index 5bf4bad..68f88bc 100644
--- a/content/public/android/java/src/org/chromium/content/browser/input/CursorController.java
+++ b/content/public/android/java/src/org/chromium/content/browser/input/CursorController.java
@@ -4,57 +4,38 @@
package org.chromium.content.browser.input;
-import android.graphics.Rect;
import android.view.ViewTreeObserver;
/**
* A CursorController instance can be used to control a cursor in the text.
*/
-abstract class CursorController implements ViewTreeObserver.OnTouchModeChangeListener {
-
- private Rect mVisibleClippingRectangle;
+interface CursorController extends ViewTreeObserver.OnTouchModeChangeListener {
/**
* Hide the cursor controller from screen.
*/
- abstract void hide();
+ void hide();
/**
* @return true if the CursorController is currently visible
*/
- abstract boolean isShowing();
+ boolean isShowing();
/**
* Called when the handle is about to start updating its position.
* @param handle
*/
- abstract void beforeStartUpdatingPosition(HandleView handle);
+ void beforeStartUpdatingPosition(HandleView handle);
/**
* Update the controller's position.
*/
- abstract void updatePosition(HandleView handle, int x, int y);
+ void updatePosition(HandleView handle, int x, int y);
/**
* Called when the view is detached from window. Perform house keeping task, such as
* stopping Runnable thread that would otherwise keep a reference on the context, thus
* preventing the activity to be recycled.
*/
- abstract void onDetached();
-
- /**
- * Sets the visible rectangle for text input elements as supplied by Blink.
- */
- public void setVisibleClippingRectangle(int left, int top, int right, int bottom) {
- if (mVisibleClippingRectangle == null) {
- mVisibleClippingRectangle = new Rect(left, top, right, bottom);
- } else {
- mVisibleClippingRectangle.set(left,top,right,bottom);
- }
- }
-
- Rect getVisibleClippingRectangle() {
- return mVisibleClippingRectangle;
- }
-
+ void onDetached();
}
diff --git a/content/public/android/java/src/org/chromium/content/browser/input/HandleView.java b/content/public/android/java/src/org/chromium/content/browser/input/HandleView.java
index b8bac44..e41efcf 100644
--- a/content/public/android/java/src/org/chromium/content/browser/input/HandleView.java
+++ b/content/public/android/java/src/org/chromium/content/browser/input/HandleView.java
@@ -18,8 +18,6 @@ import android.view.ViewParent;
import android.view.animation.AnimationUtils;
import android.widget.PopupWindow;
-import com.google.common.annotations.VisibleForTesting;
-
import org.chromium.content.browser.PositionObserver;
/**
@@ -232,8 +230,7 @@ public class HandleView extends View {
return mContainer.isShowing();
}
- @VisibleForTesting
- boolean isPositionVisible() {
+ private boolean isPositionVisible() {
// Always show a dragging handle.
if (mIsDragging) {
return true;
@@ -253,17 +250,8 @@ public class HandleView extends View {
final int posX = getContainerPositionX() + (int) mHotspotX;
final int posY = getContainerPositionY() + (int) mHotspotY;
- boolean result = posX >= clip.left && posX <= clip.right &&
+ return posX >= clip.left && posX <= clip.right &&
posY >= clip.top && posY <= clip.bottom;
-
- final Rect clippingRect = mController.getVisibleClippingRectangle();
- if (result && clippingRect != null) {
- // We need to clip against the visible areas as supplied by Blink,
- // e.g. textaread and text input elements.
- return clippingRect.contains(getAdjustedPositionX(), getAdjustedPositionY());
- }
-
- return result;
}
// x and y are in physical pixels.
diff --git a/content/public/android/java/src/org/chromium/content/browser/input/InsertionHandleController.java b/content/public/android/java/src/org/chromium/content/browser/input/InsertionHandleController.java
index f7c6f5b..bd3a464 100644
--- a/content/public/android/java/src/org/chromium/content/browser/input/InsertionHandleController.java
+++ b/content/public/android/java/src/org/chromium/content/browser/input/InsertionHandleController.java
@@ -23,7 +23,7 @@ import org.chromium.content.browser.PositionObserver;
/**
* CursorController for inserting text at the cursor position.
*/
-public abstract class InsertionHandleController extends CursorController {
+public abstract class InsertionHandleController implements CursorController {
/** The handle view, lazily created when first shown */
private HandleView mHandle;
diff --git a/content/public/android/java/src/org/chromium/content/browser/input/SelectionHandleController.java b/content/public/android/java/src/org/chromium/content/browser/input/SelectionHandleController.java
index db7efe7..0edf551 100644
--- a/content/public/android/java/src/org/chromium/content/browser/input/SelectionHandleController.java
+++ b/content/public/android/java/src/org/chromium/content/browser/input/SelectionHandleController.java
@@ -13,7 +13,7 @@ import org.chromium.content.browser.PositionObserver;
/**
* CursorController for selecting a range of text.
*/
-public abstract class SelectionHandleController extends CursorController {
+public abstract class SelectionHandleController implements CursorController {
// The following constants match the ones in
// third_party/WebKit/public/web/WebTextDirection.h
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/input/InsertionHandleTest.java b/content/public/android/javatests/src/org/chromium/content/browser/input/InsertionHandleTest.java
index b9284cb..e6d07b9 100644
--- a/content/public/android/javatests/src/org/chromium/content/browser/input/InsertionHandleTest.java
+++ b/content/public/android/javatests/src/org/chromium/content/browser/input/InsertionHandleTest.java
@@ -208,35 +208,6 @@ public class InsertionHandleTest extends ContentShellTestBase {
assertTrue(handle.getPositionX() < dragToX - 100);
}
- /**
- * Tests insertion handle visibility relative to the clipping rectangle.
- * This is currently not implemented using dragHandleTo, because of issues with
- * http://crbug.com/169648.
- */
- @MediumTest
- @Feature({"TextSelection", "TextInput", "Main"})
- public void testInsertionHandleVisiblity() throws Throwable {
- launchWithUrl(TEXTAREA_DATA_URL);
- clickNodeToShowInsertionHandle(TEXTAREA_ID);
-
- InsertionHandleController ihc = getContentViewCore().getInsertionHandleControllerForTest();
- HandleView handle = ihc.getHandleViewForTest();
-
- assertTrue(handle.isPositionVisible());
-
- ihc.setVisibleClippingRectangle(
- handle.getAdjustedPositionX() + 1, handle.getAdjustedPositionY() + 1,
- handle.getAdjustedPositionX() + 100, handle.getAdjustedPositionY() + 100);
-
- assertFalse(handle.isPositionVisible());
-
- ihc.setVisibleClippingRectangle(
- handle.getAdjustedPositionX() - 1, handle.getAdjustedPositionY() - 1,
- handle.getAdjustedPositionX() + 1, handle.getAdjustedPositionY() + 1);
-
- assertTrue(handle.isPositionVisible());
- }
-
@Override
protected void tearDown() throws Exception {
super.tearDown();
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/input/SelectionHandleTest.java b/content/public/android/javatests/src/org/chromium/content/browser/input/SelectionHandleTest.java
index 29b5631..e8ff4b2 100644
--- a/content/public/android/javatests/src/org/chromium/content/browser/input/SelectionHandleTest.java
+++ b/content/public/android/javatests/src/org/chromium/content/browser/input/SelectionHandleTest.java
@@ -5,7 +5,6 @@
package org.chromium.content.browser.input;
import android.graphics.Point;
-import android.graphics.PointF;
import android.graphics.Rect;
import android.os.SystemClock;
import android.test.FlakyTest;
@@ -29,10 +28,6 @@ import org.chromium.content_shell_apk.ContentShellTestBase;
import java.util.concurrent.Callable;
-/**
- * Tests for the selection handles that allow to select text in both editable and non-editable
- * elements.
- */
public class SelectionHandleTest extends ContentShellTestBase {
private static final String META_DISABLE_ZOOM =
"<meta name=\"viewport\" content=\"" +
@@ -156,76 +151,6 @@ public class SelectionHandleTest extends ContentShellTestBase {
doSelectionHandleTest(TestPageType.EDITABLE);
}
- /**
- * Verifies that the visibility of handles is correct when visible clipping
- * rectangle is set.
- */
- @MediumTest
- @Feature({ "TextSelection" })
- public void testEditableSelectionHandlesStartNotVisibleEndVisible() throws Throwable {
- doSelectionHandleTestVisibility(TestPageType.EDITABLE, false, true, new PointF(.5f, .5f),
- new PointF(0,1));
- }
-
- @MediumTest
- @Feature({ "TextSelection" })
- public void testEditableSelectionHandlesStartVisibleEndNotVisible() throws Throwable {
- doSelectionHandleTestVisibility(TestPageType.EDITABLE, true, false, new PointF(1,0),
- new PointF(.5f, .5f));
- }
-
- @MediumTest
- @Feature({ "TextSelection" })
- public void testEditableSelectionHandlesStartVisibleEndVisible() throws Throwable {
- doSelectionHandleTestVisibility(TestPageType.EDITABLE, true, true, new PointF(1, 0),
- new PointF(0,1));
- }
-
- @MediumTest
- @Feature({ "TextSelection" })
- public void testEditableSelectionHandlesStartNotVisibleEndNotVisible() throws Throwable {
- doSelectionHandleTestVisibility(TestPageType.EDITABLE, false, false, new PointF(1,0),
- new PointF(1, 0));
- }
-
- private void doSelectionHandleTestVisibility(TestPageType pageType,
- boolean startHandleVisible, boolean endHandleVisible,
- PointF affineTopLeft, PointF affineBottomRight) throws Throwable {
- launchWithUrl(pageType.dataUrl);
-
- clickNodeToShowSelectionHandles(pageType.nodeId);
- assertWaitForSelectionEditableEquals(pageType.selectionShouldBeEditable);
-
- HandleView startHandle = getStartHandle();
- HandleView endHandle = getEndHandle();
-
- Rect nodeWindowBounds = getNodeBoundsPix(pageType.nodeId);
-
- int visibleBoundsLeftX = Math.round(affineTopLeft.x * nodeWindowBounds.left
- + affineTopLeft.y * nodeWindowBounds.right);
- int visibleBoundsTopY = Math.round(affineTopLeft.x * nodeWindowBounds.top
- + affineTopLeft.y * nodeWindowBounds.bottom);
-
- int visibleBoundsRightX = Math.round(affineBottomRight.x * nodeWindowBounds.left
- + affineBottomRight.y * nodeWindowBounds.right);
- int visibleBoundsBottomY = Math.round(affineBottomRight.x * nodeWindowBounds.top
- + affineBottomRight.y * nodeWindowBounds.bottom);
-
- getContentViewCore().getSelectionHandleControllerForTest().setVisibleClippingRectangle(
- visibleBoundsLeftX, visibleBoundsTopY, visibleBoundsRightX, visibleBoundsBottomY);
-
- int leftX = (nodeWindowBounds.left + nodeWindowBounds.centerX()) / 2;
- int rightX = (nodeWindowBounds.right + nodeWindowBounds.centerX()) / 2;
-
- int topY = (nodeWindowBounds.top + nodeWindowBounds.centerY()) / 2;
- int bottomY = (nodeWindowBounds.bottom + nodeWindowBounds.centerY()) / 2;
-
- dragHandleAndCheckSelectionChange(startHandle, leftX, topY, -1, 0, startHandleVisible);
- dragHandleAndCheckSelectionChange(endHandle, rightX, bottomY, 0, 1, endHandleVisible);
-
- clickToDismissHandles();
- }
-
private void doSelectionHandleTest(TestPageType pageType) throws Throwable {
launchWithUrl(pageType.dataUrl);
@@ -246,25 +171,23 @@ public class SelectionHandleTest extends ContentShellTestBase {
int bottomY = (nodeWindowBounds.bottom + nodeWindowBounds.centerY()) / 2;
// Drag start handle up and to the left. The selection start should decrease.
- dragHandleAndCheckSelectionChange(startHandle, leftX, topY, -1, 0, true);
+ dragHandleAndCheckSelectionChange(startHandle, leftX, topY, -1, 0);
// Drag end handle down and to the right. The selection end should increase.
- dragHandleAndCheckSelectionChange(endHandle, rightX, bottomY, 0, 1, true);
+ dragHandleAndCheckSelectionChange(endHandle, rightX, bottomY, 0, 1);
// Drag start handle back to the middle. The selection start should increase.
- dragHandleAndCheckSelectionChange(startHandle, centerX, centerY, 1, 0, true);
+ dragHandleAndCheckSelectionChange(startHandle, centerX, centerY, 1, 0);
// Drag end handle up and to the left past the start handle. Both selection start and end
// should decrease.
- dragHandleAndCheckSelectionChange(endHandle, leftX, topY, -1, -1, true);
+ dragHandleAndCheckSelectionChange(endHandle, leftX, topY, -1, -1);
// Drag start handle down and to the right past the end handle. Both selection start and end
// should increase.
- dragHandleAndCheckSelectionChange(startHandle, rightX, bottomY, 1, 1, true);
+ dragHandleAndCheckSelectionChange(startHandle, rightX, bottomY, 1, 1);
clickToDismissHandles();
}
- private void dragHandleAndCheckSelectionChange(final HandleView handle,
- final int dragToX, final int dragToY,
- final int expectedStartChange, final int expectedEndChange,
- final boolean expectedHandleVisible) throws Throwable {
+ private void dragHandleAndCheckSelectionChange(HandleView handle, int dragToX, int dragToY,
+ final int expectedStartChange, final int expectedEndChange) throws Throwable {
String initialText = getContentViewCore().getSelectedText();
final int initialSelectionEnd = getSelectionEnd();
final int initialSelectionStart = getSelectionStart();
@@ -288,8 +211,6 @@ public class SelectionHandleTest extends ContentShellTestBase {
if ((int) Math.signum(endChange) != expectedEndChange) return false;
}
- if (expectedHandleVisible != handle.isPositionVisible()) return false;
-
return true;
}
}));