Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1453)

Unified Diff: content/public/android/java/src/org/chromium/content/browser/input/CursorAnchorInfoWrapper.java

Issue 699333003: Support InputMethodManager#updateCursorAnchorInfo for Android 5.0 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase before splitting this CL. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/public/android/java/src/org/chromium/content/browser/input/CursorAnchorInfoWrapper.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/input/CursorAnchorInfoWrapper.java b/content/public/android/java/src/org/chromium/content/browser/input/CursorAnchorInfoWrapper.java
new file mode 100644
index 0000000000000000000000000000000000000000..babeee00ccf69b19c51e061302826755219044dd
--- /dev/null
+++ b/content/public/android/java/src/org/chromium/content/browser/input/CursorAnchorInfoWrapper.java
@@ -0,0 +1,74 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.content.browser.input;
+
+import android.graphics.Matrix;
+import android.graphics.RectF;
+import android.view.inputmethod.CursorAnchorInfo;
+
+/**
+ * Wrapper around Android's {@link android.view.inputmethod.CursorAnchorInfo}.
+ * <p>This wrapper class is introduced so that we can write unit test for
+ * {@link CursorAnchorInfoController} without directly depending on {@link CursorAnchorInfo},
+ * which is available on Android 5.0 and later only. We can remove this wrapper class once
+ * we stop supporting Android 4.4 and prior.
+ */
+public interface CursorAnchorInfoWrapper {
+ public static final int FLAG_HAS_VISIBLE_REGION = 0x01;
+ public static final int FLAG_HAS_INVISIBLE_REGION = 0x02;
+ public static final int FLAG_IS_RTL = 0x04;
+
+ /**
+ * Wrapper around Android's {@link android.view.inputmethod.CursorAnchorInfo.Builder}.
+ */
+ interface Builder {
+ Builder setSelectionRange(int newStart, int newEnd);
+
+ Builder setComposingText(int composingTextStart, CharSequence composingText);
+
+ Builder setInsertionMarkerLocation(float horizontalPosition, float lineTop,
+ float lineBaseline, float lineBottom, int flags);
+
+ Builder addCharacterBounds(int index, float left, float top, float right, float bottom,
+ int flags);
+
+ Builder setMatrix(Matrix matrix);
+
+ CursorAnchorInfoWrapper build();
+
+ void reset();
+ }
+
+ int getSelectionStart();
+
+ int getSelectionEnd();
+
+ int getComposingTextStart();
+
+ CharSequence getComposingText();
+
+ int getInsertionMarkerFlags();
+
+ float getInsertionMarkerHorizontal();
+
+ float getInsertionMarkerTop();
+
+ float getInsertionMarkerBaseline();
+
+ float getInsertionMarkerBottom();
+
+ RectF getCharacterBounds(final int index);
+
+ int getCharacterBoundsFlags(final int index);
+
+ Matrix getMatrix();
+
+ /**
+ * @return The real {@link CursorAnchorInfo} object if it is available. Otherwise {@code null}
+ * is returned. <p>Note that {@link CursorAnchorInfo} was introduced in Android 5.0
+ * (API Level 21) and this method always returns {@code null} on those older platforms.
+ */
+ Object unwrap();
+}

Powered by Google App Engine
This is Rietveld 408576698