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 0dc13ed95d8e0d83b6b02969c7c76234bcb62276..1dd32e30fbee8c11348f8ce1ce23692ddc739625 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 |
@@ -34,6 +34,7 @@ import org.chromium.base.annotations.JNINamespace; |
import org.chromium.blink_public.web.WebInputEventModifier; |
import org.chromium.blink_public.web.WebInputEventType; |
import org.chromium.blink_public.web.WebTextInputMode; |
+import org.chromium.content.browser.RenderCoordinates; |
import org.chromium.content.browser.ViewUtils; |
import org.chromium.content.browser.picker.InputDialogContainer; |
import org.chromium.content_public.browser.ImeEventObserver; |
@@ -84,6 +85,7 @@ public class ImeAdapter { |
private final WebContents mWebContents; |
private View mContainerView; |
+ private final RenderCoordinates mRenderCoordinates; |
// This holds the information necessary for constructing CursorAnchorInfo, and notifies to |
// InputMethodManager on appropriate timing, depending on how IME requested the information |
@@ -91,6 +93,8 @@ public class ImeAdapter { |
// re-created, the monitoring status will be reset. |
private final CursorAnchorInfoController mCursorAnchorInfoController; |
+ private SuggestionsPopupWindow mSuggestionsPopupWindow; |
+ |
private final List<ImeEventObserver> mEventObservers = new ArrayList<>(); |
private int mTextInputType = TextInputType.NONE; |
@@ -147,12 +151,14 @@ public class ImeAdapter { |
* @param containerView {@link View} instance which input events are posted on. |
* @param wrapper InputMethodManagerWrapper that should receive all the call directed to |
* InputMethodManager. |
+ * @param renderCoordinates Coordinates info used to position elements. |
*/ |
- public ImeAdapter( |
- WebContents webContents, View containerView, InputMethodManagerWrapper wrapper) { |
+ public ImeAdapter(WebContents webContents, View containerView, |
+ InputMethodManagerWrapper wrapper, RenderCoordinates renderCoordinates) { |
mWebContents = webContents; |
mContainerView = containerView; |
mInputMethodManagerWrapper = wrapper; |
+ mRenderCoordinates = renderCoordinates; |
// Deep copy newConfig so that we can notice the difference. |
mCurrentConfig = new Configuration(mContainerView.getResources().getConfiguration()); |
@@ -898,6 +904,47 @@ public class ImeAdapter { |
resetAndHideKeyboard(); |
} |
+ public void hidePopups() { |
+ if (mSuggestionsPopupWindow != null && mSuggestionsPopupWindow.isShowing()) { |
+ mSuggestionsPopupWindow.dismiss(); |
+ suggestionMenuClosed(); |
+ } |
+ } |
+ |
+ @CalledByNative |
+ private void showSpellCheckSuggestionMenu( |
+ double caretX, double caretY, String markedText, String[] suggestions) { |
+ if (mSuggestionsPopupWindow == null) { |
+ mSuggestionsPopupWindow = |
+ new SuggestionsPopupWindow(mInputMethodManagerWrapper.getContext(), this, |
+ mContainerView, mCursorAnchorInfoController); |
+ } |
+ |
+ mSuggestionsPopupWindow.setHighlightedText(markedText); |
+ mSuggestionsPopupWindow.setSpellCheckSuggestions(suggestions); |
+ mSuggestionsPopupWindow.show(caretX, caretY); |
+ } |
+ |
+ public float getContentOffsetYPix() { |
aelias_OOO_until_Jul13
2017/06/16 01:25:14
Please add the offset to caretY when calling "show
|
+ return mRenderCoordinates.getContentOffsetYPix(); |
+ } |
+ |
+ public void applySpellCheckSuggestion(String suggestion) { |
aelias_OOO_until_Jul13
2017/06/16 01:25:14
If this goes in a big class, it should look like a
rlanday
2017/06/18 02:32:29
Sure, we can do this; I was thinking about how to
|
+ nativeApplySpellCheckSuggestion(mNativeImeAdapterAndroid, suggestion); |
+ } |
+ |
+ public void deleteActiveSuggestionRange() { |
+ nativeDeleteActiveSuggestionRange(mNativeImeAdapterAndroid); |
+ } |
+ |
+ public void newWordAddedToDictionary(String word) { |
+ nativeNewWordAddedToDictionary(mNativeImeAdapterAndroid, word); |
+ } |
+ |
+ public void suggestionMenuClosed() { |
aelias_OOO_until_Jul13
2017/06/16 01:25:14
Can we set mSuggestionPopupMenu = null from here o
|
+ nativeSuggestionMenuClosed(mNativeImeAdapterAndroid); |
+ } |
+ |
private native long nativeInit(WebContents webContents); |
private native boolean nativeSendKeyEvent(long nativeImeAdapterAndroid, KeyEvent event, |
int type, int modifiers, long timestampMs, int keyCode, int scanCode, |
@@ -920,4 +967,9 @@ public class ImeAdapter { |
private native boolean nativeRequestTextInputStateUpdate(long nativeImeAdapterAndroid); |
private native void nativeRequestCursorUpdate(long nativeImeAdapterAndroid, |
boolean immediateRequest, boolean monitorRequest); |
+ private native void nativeApplySpellCheckSuggestion( |
+ long nativeImeAdapterAndroid, String suggestion); |
+ private native void nativeDeleteActiveSuggestionRange(long nativeImeAdapterAndroid); |
+ private native void nativeNewWordAddedToDictionary(long nativeImeAdapterAndroid, String word); |
+ private native void nativeSuggestionMenuClosed(long nativeImeAdapterAndroid); |
} |