| 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();
|
| +}
|
|
|