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

Unified Diff: ui/android/java/src/org/chromium/ui/base/CursorAnchorInfoBuilder.java

Issue 643193003: Support InputMethodManager#updateCursorAnchorInfo for Android 5.0 (C++ version) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Send ImeCompositionRangeChanged only when necessary Created 5 years, 11 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
« no previous file with comments | « tools/metrics/histograms/histograms.xml ('k') | ui/base/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/android/java/src/org/chromium/ui/base/CursorAnchorInfoBuilder.java
diff --git a/ui/android/java/src/org/chromium/ui/base/CursorAnchorInfoBuilder.java b/ui/android/java/src/org/chromium/ui/base/CursorAnchorInfoBuilder.java
new file mode 100644
index 0000000000000000000000000000000000000000..ffa89179b37bc01beef50a2c325779dc71653621
--- /dev/null
+++ b/ui/android/java/src/org/chromium/ui/base/CursorAnchorInfoBuilder.java
@@ -0,0 +1,78 @@
+// Copyright 2014 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.ui.base;
+
+import android.graphics.Matrix;
+import android.os.Build;
+import android.view.inputmethod.CursorAnchorInfo;
+
+import org.chromium.base.CalledByNative;
+import org.chromium.base.JNINamespace;
+
+import java.lang.CharSequence;
+
+/**
+ * A simple class to allow native code to call instance methods of {@link CursorAnchorInfo.Builder}.
+ * This class itself is designed to be stateless. All the methods are thread-safe.
+ */
+@JNINamespace("ui")
+public final class CursorAnchorInfoBuilder {
+
+ private static final Matrix sMatrix = new Matrix();
+
+ @CalledByNative
+ public static CursorAnchorInfo.Builder create() {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
+ return null;
+ }
+ return new CursorAnchorInfo.Builder();
+ }
+
+ @CalledByNative
+ public static void reset(CursorAnchorInfo.Builder builder) {
+ builder.reset();
+ }
+
+ @CalledByNative
+ public static void setSelectionRange(CursorAnchorInfo.Builder builder, int newStart,
+ int newEnd) {
+ builder.setSelectionRange(newStart, newEnd);
+ }
+
+ @CalledByNative
+ public static void setComposingText(CursorAnchorInfo.Builder builder, int composingTextStart,
+ CharSequence composingText) {
+ builder.setComposingText(composingTextStart, composingText);
+ }
+
+ @CalledByNative
+ public static void setInsertionMarkerLocation(CursorAnchorInfo.Builder builder,
+ float horizontalPosition, float lineTop, float lineBaseline, float lineBottom,
+ int flags) {
+ builder.setInsertionMarkerLocation(horizontalPosition, lineTop, lineBaseline, lineBottom,
+ flags);
+ }
+
+ @CalledByNative
+ public static void addCharacterBounds(CursorAnchorInfo.Builder builder, int index, float left,
+ float top, float right, float bottom, int flags) {
+ builder.addCharacterBounds(index, left, top, right, bottom, flags);
+ }
+
+ @CalledByNative
+ public static void setScaleAndTranslate(CursorAnchorInfo.Builder builder, float scale,
+ float translateX, float translateY) {
+ synchronized (sMatrix) {
+ sMatrix.setScale(scale, scale);
+ sMatrix.postTranslate(translateX, translateY);
+ builder.setMatrix(sMatrix);
+ }
+ }
+
+ @CalledByNative
+ public static CursorAnchorInfo build(CursorAnchorInfo.Builder builder) {
+ return builder.build();
+ }
+}
« no previous file with comments | « tools/metrics/histograms/histograms.xml ('k') | ui/base/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698