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

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

Issue 313053007: Passing BackgroundColorSpan and UnderlineSpan from Clank to Blink. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync. Created 6 years, 6 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/ImeAdapter.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java b/content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java
index bfc8ea5b419112ed1af2c03d68581aa3ce044af8..0bbf8e431b40f868c197f011220299957b5d97d7 100644
--- a/content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java
+++ b/content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java
@@ -8,6 +8,8 @@ import android.os.Handler;
import android.os.ResultReceiver;
import android.os.SystemClock;
import android.text.Editable;
+import android.text.SpannableString;
+import android.text.style.BackgroundColorSpan;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import android.view.View;
@@ -328,14 +330,15 @@ public class ImeAdapter {
// Calls from Java to C++
- boolean checkCompositionQueueAndCallNative(String text, int newCursorPosition,
+ boolean checkCompositionQueueAndCallNative(CharSequence text, int newCursorPosition,
boolean isCommit) {
if (mNativeImeAdapterAndroid == 0) return false;
+ String textStr = text.toString();
// Committing an empty string finishes the current composition.
- boolean isFinish = text.isEmpty();
+ boolean isFinish = textStr.isEmpty();
mViewEmbedder.onImeEvent(isFinish);
- int keyCode = shouldSendKeyEventWithKeyCode(text);
+ int keyCode = shouldSendKeyEventWithKeyCode(textStr);
long timeStampMs = SystemClock.uptimeMillis();
if (keyCode != COMPOSITION_KEY_CODE) {
@@ -345,9 +348,17 @@ public class ImeAdapter {
nativeSendSyntheticKeyEvent(mNativeImeAdapterAndroid, sEventTypeRawKeyDown,
timeStampMs, keyCode, 0);
if (isCommit) {
- nativeCommitText(mNativeImeAdapterAndroid, text);
+ nativeCommitText(mNativeImeAdapterAndroid, textStr);
} else {
- nativeSetComposingText(mNativeImeAdapterAndroid, text, newCursorPosition);
+ SpannableString ss = null;
+ Object[] spans = null;
+ if (text instanceof SpannableString) {
+ ss = ((SpannableString) text);
+ // Retrieves spans since it's much easier here than using JNI.
+ spans = ss.getSpans(0, textStr.length(), Object.class);
+ }
+ nativeSetComposingText(mNativeImeAdapterAndroid, textStr, newCursorPosition,
+ ss, spans);
}
nativeSendSyntheticKeyEvent(mNativeImeAdapterAndroid, sEventTypeKeyUp,
timeStampMs, keyCode, 0);
@@ -539,7 +550,7 @@ public class ImeAdapter {
int unicodeChar);
private native void nativeSetComposingText(long nativeImeAdapterAndroid, String text,
- int newCursorPosition);
+ int newCursorPosition, SpannableString spannableString, Object[] spanObjArray);
private native void nativeCommitText(long nativeImeAdapterAndroid, String text);

Powered by Google App Engine
This is Rietveld 408576698