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

Side by Side Diff: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java

Issue 2931443003: Add support for Android spellcheck menu in Chrome/WebViews (Closed)
Patch Set: Simplify Mojo binding based on rockot@'s advice Created 3 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.content.browser; 5 package org.chromium.content.browser;
6 6
7 import android.annotation.SuppressLint; 7 import android.annotation.SuppressLint;
8 import android.annotation.TargetApi; 8 import android.annotation.TargetApi;
9 import android.app.assist.AssistStructure.ViewNode; 9 import android.app.assist.AssistStructure.ViewNode;
10 import android.content.Context; 10 import android.content.Context;
(...skipping 30 matching lines...) Expand all
41 import org.chromium.content.browser.accessibility.WebContentsAccessibility; 41 import org.chromium.content.browser.accessibility.WebContentsAccessibility;
42 import org.chromium.content.browser.accessibility.captioning.CaptioningBridgeFac tory; 42 import org.chromium.content.browser.accessibility.captioning.CaptioningBridgeFac tory;
43 import org.chromium.content.browser.accessibility.captioning.SystemCaptioningBri dge; 43 import org.chromium.content.browser.accessibility.captioning.SystemCaptioningBri dge;
44 import org.chromium.content.browser.accessibility.captioning.TextTrackSettings; 44 import org.chromium.content.browser.accessibility.captioning.TextTrackSettings;
45 import org.chromium.content.browser.input.ImeAdapter; 45 import org.chromium.content.browser.input.ImeAdapter;
46 import org.chromium.content.browser.input.InputMethodManagerWrapper; 46 import org.chromium.content.browser.input.InputMethodManagerWrapper;
47 import org.chromium.content.browser.input.SelectPopup; 47 import org.chromium.content.browser.input.SelectPopup;
48 import org.chromium.content.browser.input.SelectPopupDialog; 48 import org.chromium.content.browser.input.SelectPopupDialog;
49 import org.chromium.content.browser.input.SelectPopupDropdown; 49 import org.chromium.content.browser.input.SelectPopupDropdown;
50 import org.chromium.content.browser.input.SelectPopupItem; 50 import org.chromium.content.browser.input.SelectPopupItem;
51 import org.chromium.content.browser.input.TextSuggestionHost;
51 import org.chromium.content_public.browser.AccessibilitySnapshotCallback; 52 import org.chromium.content_public.browser.AccessibilitySnapshotCallback;
52 import org.chromium.content_public.browser.AccessibilitySnapshotNode; 53 import org.chromium.content_public.browser.AccessibilitySnapshotNode;
53 import org.chromium.content_public.browser.ActionModeCallbackHelper; 54 import org.chromium.content_public.browser.ActionModeCallbackHelper;
54 import org.chromium.content_public.browser.GestureStateListener; 55 import org.chromium.content_public.browser.GestureStateListener;
55 import org.chromium.content_public.browser.ImeEventObserver; 56 import org.chromium.content_public.browser.ImeEventObserver;
56 import org.chromium.content_public.browser.WebContents; 57 import org.chromium.content_public.browser.WebContents;
57 import org.chromium.content_public.browser.WebContentsObserver; 58 import org.chromium.content_public.browser.WebContentsObserver;
58 import org.chromium.device.gamepad.GamepadList; 59 import org.chromium.device.gamepad.GamepadList;
59 import org.chromium.ui.base.DeviceFormFactor; 60 import org.chromium.ui.base.DeviceFormFactor;
60 import org.chromium.ui.base.EventForwarder; 61 import org.chromium.ui.base.EventForwarder;
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 private final ObserverList<GestureStateListener> mGestureStateListeners; 212 private final ObserverList<GestureStateListener> mGestureStateListeners;
212 private final RewindableIterator<GestureStateListener> mGestureStateListener sIterator; 213 private final RewindableIterator<GestureStateListener> mGestureStateListener sIterator;
213 214
214 private PopupZoomer mPopupZoomer; 215 private PopupZoomer mPopupZoomer;
215 private SelectPopup mSelectPopup; 216 private SelectPopup mSelectPopup;
216 private long mNativeSelectPopupSourceFrame; 217 private long mNativeSelectPopupSourceFrame;
217 218
218 // Only valid when focused on a text / password field. 219 // Only valid when focused on a text / password field.
219 private ImeAdapter mImeAdapter; 220 private ImeAdapter mImeAdapter;
220 221
222 private TextSuggestionHost mTextSuggestionHost;
223
221 // Size of the viewport in physical pixels as set from onSizeChanged. 224 // Size of the viewport in physical pixels as set from onSizeChanged.
222 private int mViewportWidthPix; 225 private int mViewportWidthPix;
223 private int mViewportHeightPix; 226 private int mViewportHeightPix;
224 private int mTopControlsHeightPix; 227 private int mTopControlsHeightPix;
225 private int mBottomControlsHeightPix; 228 private int mBottomControlsHeightPix;
226 private boolean mTopControlsShrinkBlinkSize; 229 private boolean mTopControlsShrinkBlinkSize;
227 230
228 // Cached copy of all positions and scales as reported by the renderer. 231 // Cached copy of all positions and scales as reported by the renderer.
229 private final RenderCoordinates mRenderCoordinates; 232 private final RenderCoordinates mRenderCoordinates;
230 233
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 @VisibleForTesting 365 @VisibleForTesting
363 public SelectionPopupController getSelectionPopupControllerForTesting() { 366 public SelectionPopupController getSelectionPopupControllerForTesting() {
364 return mSelectionPopupController; 367 return mSelectionPopupController;
365 } 368 }
366 369
367 @VisibleForTesting 370 @VisibleForTesting
368 public void setSelectionPopupControllerForTesting(SelectionPopupController a ctionMode) { 371 public void setSelectionPopupControllerForTesting(SelectionPopupController a ctionMode) {
369 mSelectionPopupController = actionMode; 372 mSelectionPopupController = actionMode;
370 } 373 }
371 374
375 /**
376 * @return The TextSuggestionHost that handles displaying the text suggestio n menu.
377 */
378 @VisibleForTesting
379 public TextSuggestionHost getTextSuggestionHostForTesting() {
380 return mTextSuggestionHost;
381 }
382
383 @VisibleForTesting
384 public void setTextSuggestionHostForTesting(TextSuggestionHost textSuggestio nHost) {
385 mTextSuggestionHost = textSuggestionHost;
386 }
387
372 @Override 388 @Override
373 public void addWindowAndroidChangedObserver(WindowAndroidChangedObserver obs erver) { 389 public void addWindowAndroidChangedObserver(WindowAndroidChangedObserver obs erver) {
374 mWindowAndroidChangedObservers.addObserver(observer); 390 mWindowAndroidChangedObservers.addObserver(observer);
375 } 391 }
376 392
377 @Override 393 @Override
378 public void removeWindowAndroidChangedObserver(WindowAndroidChangedObserver observer) { 394 public void removeWindowAndroidChangedObserver(WindowAndroidChangedObserver observer) {
379 mWindowAndroidChangedObservers.removeObserver(observer); 395 mWindowAndroidChangedObservers.removeObserver(observer);
380 } 396 }
381 397
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 468
453 mNativeContentViewCore = nativeInit(webContents, mViewAndroidDelegate, w indowNativePointer, 469 mNativeContentViewCore = nativeInit(webContents, mViewAndroidDelegate, w indowNativePointer,
454 dipScale, mRetainedJavaScriptObjects); 470 dipScale, mRetainedJavaScriptObjects);
455 mWebContents = nativeGetWebContentsAndroid(mNativeContentViewCore); 471 mWebContents = nativeGetWebContentsAndroid(mNativeContentViewCore);
456 472
457 setContainerViewInternals(internalDispatcher); 473 setContainerViewInternals(internalDispatcher);
458 474
459 initPopupZoomer(mContext); 475 initPopupZoomer(mContext);
460 mImeAdapter = new ImeAdapter( 476 mImeAdapter = new ImeAdapter(
461 mWebContents, mContainerView, new InputMethodManagerWrapper(mCon text)); 477 mWebContents, mContainerView, new InputMethodManagerWrapper(mCon text));
478 mTextSuggestionHost = new TextSuggestionHost(
479 mContext, mWebContents, mContainerView, this, mRenderCoordinates );
462 mImeAdapter.addEventObserver(this); 480 mImeAdapter.addEventObserver(this);
463 481
464 mSelectionPopupController = new SelectionPopupController( 482 mSelectionPopupController = new SelectionPopupController(
465 mContext, windowAndroid, webContents, mContainerView, mRenderCoo rdinates); 483 mContext, windowAndroid, webContents, mContainerView, mRenderCoo rdinates);
466 mSelectionPopupController.setCallback(ActionModeCallbackHelper.EMPTY_CAL LBACK); 484 mSelectionPopupController.setCallback(ActionModeCallbackHelper.EMPTY_CAL LBACK);
467 mSelectionPopupController.setContainerView(mContainerView); 485 mSelectionPopupController.setContainerView(mContainerView);
468 486
469 mWebContentsObserver = new ContentViewWebContentsObserver(this); 487 mWebContentsObserver = new ContentViewWebContentsObserver(this);
470 488
471 mShouldRequestUnbufferedDispatch = Build.VERSION.SDK_INT >= Build.VERSIO N_CODES.LOLLIPOP 489 mShouldRequestUnbufferedDispatch = Build.VERSION.SDK_INT >= Build.VERSIO N_CODES.LOLLIPOP
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 assert mWebContents != null; 1001 assert mWebContents != null;
984 hidePopupsAndPreserveSelection(); 1002 hidePopupsAndPreserveSelection();
985 mWebContents.onHide(); 1003 mWebContents.onHide();
986 } 1004 }
987 1005
988 private void hidePopupsAndClearSelection() { 1006 private void hidePopupsAndClearSelection() {
989 mSelectionPopupController.destroyActionModeAndUnselect(); 1007 mSelectionPopupController.destroyActionModeAndUnselect();
990 destroyPastePopup(); 1008 destroyPastePopup();
991 hideSelectPopupWithCancelMessage(); 1009 hideSelectPopupWithCancelMessage();
992 mPopupZoomer.hide(false); 1010 mPopupZoomer.hide(false);
1011 mTextSuggestionHost.hidePopups();
993 if (mWebContents != null) mWebContents.dismissTextHandles(); 1012 if (mWebContents != null) mWebContents.dismissTextHandles();
994 } 1013 }
995 1014
996 @CalledByNative 1015 @CalledByNative
997 private void hidePopupsAndPreserveSelection() { 1016 private void hidePopupsAndPreserveSelection() {
998 mSelectionPopupController.destroyActionModeAndKeepSelection(); 1017 mSelectionPopupController.destroyActionModeAndKeepSelection();
999 destroyPastePopup(); 1018 destroyPastePopup();
1000 hideSelectPopupWithCancelMessage(); 1019 hideSelectPopupWithCancelMessage();
1001 mPopupZoomer.hide(false); 1020 mPopupZoomer.hide(false);
1021 mTextSuggestionHost.hidePopups();
1002 } 1022 }
1003 1023
1004 private void restoreSelectionPopupsIfNecessary() { 1024 private void restoreSelectionPopupsIfNecessary() {
1005 mSelectionPopupController.restoreSelectionPopupsIfNecessary(); 1025 mSelectionPopupController.restoreSelectionPopupsIfNecessary();
1006 } 1026 }
1007 1027
1008 /** 1028 /**
1009 * Hide action mode and put into destroyed state. 1029 * Hide action mode and put into destroyed state.
1010 */ 1030 */
1011 public void destroySelectActionMode() { 1031 public void destroySelectActionMode() {
(...skipping 1121 matching lines...) Expand 10 before | Expand all | Expand 10 after
2133 @Override 2153 @Override
2134 public void onRotationChanged(int rotation) { 2154 public void onRotationChanged(int rotation) {
2135 // ActionMode#invalidate() won't be able to re-layout the floating 2155 // ActionMode#invalidate() won't be able to re-layout the floating
2136 // action mode menu items according to the new rotation. So Chrome 2156 // action mode menu items according to the new rotation. So Chrome
2137 // has to re-create the action mode. 2157 // has to re-create the action mode.
2138 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M 2158 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
2139 && mSelectionPopupController.isActionModeValid()) { 2159 && mSelectionPopupController.isActionModeValid()) {
2140 hidePopupsAndPreserveSelection(); 2160 hidePopupsAndPreserveSelection();
2141 showSelectActionMode(); 2161 showSelectActionMode();
2142 } 2162 }
2163 mTextSuggestionHost.hidePopups();
2143 2164
2144 int rotationDegrees = 0; 2165 int rotationDegrees = 0;
2145 switch (rotation) { 2166 switch (rotation) {
2146 case Surface.ROTATION_0: 2167 case Surface.ROTATION_0:
2147 rotationDegrees = 0; 2168 rotationDegrees = 0;
2148 break; 2169 break;
2149 case Surface.ROTATION_90: 2170 case Surface.ROTATION_90:
2150 rotationDegrees = 90; 2171 rotationDegrees = 90;
2151 break; 2172 break;
2152 case Surface.ROTATION_180: 2173 case Surface.ROTATION_180:
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
2290 2311
2291 private native void nativeWasResized(long nativeContentViewCore); 2312 private native void nativeWasResized(long nativeContentViewCore);
2292 2313
2293 private native void nativeSetTextTrackSettings(long nativeContentViewCore, 2314 private native void nativeSetTextTrackSettings(long nativeContentViewCore,
2294 boolean textTracksEnabled, String textTrackBackgroundColor, String t extTrackFontFamily, 2315 boolean textTracksEnabled, String textTrackBackgroundColor, String t extTrackFontFamily,
2295 String textTrackFontStyle, String textTrackFontVariant, String textT rackTextColor, 2316 String textTrackFontStyle, String textTrackFontVariant, String textT rackTextColor,
2296 String textTrackTextShadow, String textTrackTextSize); 2317 String textTrackTextShadow, String textTrackTextSize);
2297 2318
2298 private native void nativeSetBackgroundOpaque(long nativeContentViewCore, bo olean opaque); 2319 private native void nativeSetBackgroundOpaque(long nativeContentViewCore, bo olean opaque);
2299 } 2320 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698