Chromium Code Reviews| OLD | NEW |
|---|---|
| 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.Activity; | 9 import android.app.Activity; |
| 10 import android.app.SearchManager; | 10 import android.app.SearchManager; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 import org.chromium.base.VisibleForTesting; | 54 import org.chromium.base.VisibleForTesting; |
| 55 import org.chromium.base.annotations.CalledByNative; | 55 import org.chromium.base.annotations.CalledByNative; |
| 56 import org.chromium.base.annotations.JNINamespace; | 56 import org.chromium.base.annotations.JNINamespace; |
| 57 import org.chromium.content.R; | 57 import org.chromium.content.R; |
| 58 import org.chromium.content.browser.ScreenOrientationListener.ScreenOrientationO bserver; | 58 import org.chromium.content.browser.ScreenOrientationListener.ScreenOrientationO bserver; |
| 59 import org.chromium.content.browser.accessibility.BrowserAccessibilityManager; | 59 import org.chromium.content.browser.accessibility.BrowserAccessibilityManager; |
| 60 import org.chromium.content.browser.accessibility.captioning.CaptioningBridgeFac tory; | 60 import org.chromium.content.browser.accessibility.captioning.CaptioningBridgeFac tory; |
| 61 import org.chromium.content.browser.accessibility.captioning.SystemCaptioningBri dge; | 61 import org.chromium.content.browser.accessibility.captioning.SystemCaptioningBri dge; |
| 62 import org.chromium.content.browser.accessibility.captioning.TextTrackSettings; | 62 import org.chromium.content.browser.accessibility.captioning.TextTrackSettings; |
| 63 import org.chromium.content.browser.input.AdapterInputConnection; | 63 import org.chromium.content.browser.input.AdapterInputConnection; |
| 64 import org.chromium.content.browser.input.ChromiumBaseInputConnection; | |
| 65 import org.chromium.content.browser.input.ChromiumBaseInputConnectionFactory; | |
| 64 import org.chromium.content.browser.input.FloatingPastePopupMenu; | 66 import org.chromium.content.browser.input.FloatingPastePopupMenu; |
| 65 import org.chromium.content.browser.input.GamepadList; | 67 import org.chromium.content.browser.input.GamepadList; |
| 66 import org.chromium.content.browser.input.ImeAdapter; | 68 import org.chromium.content.browser.input.ImeAdapter; |
| 67 import org.chromium.content.browser.input.ImeAdapter.AdapterInputConnectionFacto ry; | |
| 68 import org.chromium.content.browser.input.InputMethodManagerWrapper; | 69 import org.chromium.content.browser.input.InputMethodManagerWrapper; |
| 69 import org.chromium.content.browser.input.JoystickScrollProvider; | 70 import org.chromium.content.browser.input.JoystickScrollProvider; |
| 70 import org.chromium.content.browser.input.LegacyPastePopupMenu; | 71 import org.chromium.content.browser.input.LegacyPastePopupMenu; |
| 71 import org.chromium.content.browser.input.PastePopupMenu; | 72 import org.chromium.content.browser.input.PastePopupMenu; |
| 72 import org.chromium.content.browser.input.PastePopupMenu.PastePopupMenuDelegate; | 73 import org.chromium.content.browser.input.PastePopupMenu.PastePopupMenuDelegate; |
| 73 import org.chromium.content.browser.input.SelectPopup; | 74 import org.chromium.content.browser.input.SelectPopup; |
| 74 import org.chromium.content.browser.input.SelectPopupDialog; | 75 import org.chromium.content.browser.input.SelectPopupDialog; |
| 75 import org.chromium.content.browser.input.SelectPopupDropdown; | 76 import org.chromium.content.browser.input.SelectPopupDropdown; |
| 76 import org.chromium.content.browser.input.SelectPopupItem; | 77 import org.chromium.content.browser.input.SelectPopupItem; |
| 77 import org.chromium.content.common.ContentSwitches; | 78 import org.chromium.content.common.ContentSwitches; |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 480 private PopupZoomer mPopupZoomer; | 481 private PopupZoomer mPopupZoomer; |
| 481 private SelectPopup mSelectPopup; | 482 private SelectPopup mSelectPopup; |
| 482 private long mNativeSelectPopupSourceFrame = 0; | 483 private long mNativeSelectPopupSourceFrame = 0; |
| 483 | 484 |
| 484 private OverscrollRefreshHandler mOverscrollRefreshHandler; | 485 private OverscrollRefreshHandler mOverscrollRefreshHandler; |
| 485 | 486 |
| 486 private Runnable mFakeMouseMoveRunnable = null; | 487 private Runnable mFakeMouseMoveRunnable = null; |
| 487 | 488 |
| 488 // Only valid when focused on a text / password field. | 489 // Only valid when focused on a text / password field. |
| 489 private ImeAdapter mImeAdapter; | 490 private ImeAdapter mImeAdapter; |
| 490 private ImeAdapter.AdapterInputConnectionFactory mAdapterInputConnectionFact ory; | 491 private ChromiumBaseInputConnectionFactory mInputConnectionFactory; |
| 491 private AdapterInputConnection mInputConnection; | 492 private ChromiumBaseInputConnection mInputConnection; |
| 492 private InputMethodManagerWrapper mInputMethodManagerWrapper; | 493 private InputMethodManagerWrapper mInputMethodManagerWrapper; |
| 493 | 494 |
| 494 // Lazily created paste popup menu, triggered either via long press in an | 495 // Lazily created paste popup menu, triggered either via long press in an |
| 495 // editable region or from tapping the insertion handle. | 496 // editable region or from tapping the insertion handle. |
| 496 private PastePopupMenu mPastePopupMenu; | 497 private PastePopupMenu mPastePopupMenu; |
| 497 private boolean mWasPastePopupShowingOnInsertionDragStart; | 498 private boolean mWasPastePopupShowingOnInsertionDragStart; |
| 498 | 499 |
| 499 // Size of the viewport in physical pixels as set from onSizeChanged. | 500 // Size of the viewport in physical pixels as set from onSizeChanged. |
| 500 private int mViewportWidthPix; | 501 private int mViewportWidthPix; |
| 501 private int mViewportHeightPix; | 502 private int mViewportHeightPix; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 630 | 631 |
| 631 /** | 632 /** |
| 632 * Constructs a new ContentViewCore. Embedders must call initialize() after constructing | 633 * Constructs a new ContentViewCore. Embedders must call initialize() after constructing |
| 633 * a ContentViewCore and before using it. | 634 * a ContentViewCore and before using it. |
| 634 * | 635 * |
| 635 * @param context The context used to create this. | 636 * @param context The context used to create this. |
| 636 */ | 637 */ |
| 637 public ContentViewCore(Context context) { | 638 public ContentViewCore(Context context) { |
| 638 mContext = context; | 639 mContext = context; |
| 639 | 640 |
| 640 mAdapterInputConnectionFactory = new AdapterInputConnectionFactory(); | 641 mInputConnectionFactory = new ChromiumBaseInputConnectionFactory(); |
| 641 mInputMethodManagerWrapper = new InputMethodManagerWrapper(mContext); | 642 mInputMethodManagerWrapper = new InputMethodManagerWrapper(mContext); |
| 642 | 643 |
| 643 mRenderCoordinates = new RenderCoordinates(); | 644 mRenderCoordinates = new RenderCoordinates(); |
| 644 mJoystickScrollProvider = new JoystickScrollProvider(this); | 645 mJoystickScrollProvider = new JoystickScrollProvider(this); |
| 645 float deviceScaleFactor = getContext().getResources().getDisplayMetrics( ).density; | 646 float deviceScaleFactor = getContext().getResources().getDisplayMetrics( ).density; |
| 646 String forceScaleFactor = CommandLine.getInstance().getSwitchValue( | 647 String forceScaleFactor = CommandLine.getInstance().getSwitchValue( |
| 647 ContentSwitches.FORCE_DEVICE_SCALE_FACTOR); | 648 ContentSwitches.FORCE_DEVICE_SCALE_FACTOR); |
| 648 if (forceScaleFactor != null) { | 649 if (forceScaleFactor != null) { |
| 649 deviceScaleFactor = Float.valueOf(forceScaleFactor); | 650 deviceScaleFactor = Float.valueOf(forceScaleFactor); |
| 650 } | 651 } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 731 public void setImeAdapterForTest(ImeAdapter imeAdapter) { | 732 public void setImeAdapterForTest(ImeAdapter imeAdapter) { |
| 732 mImeAdapter = imeAdapter; | 733 mImeAdapter = imeAdapter; |
| 733 } | 734 } |
| 734 | 735 |
| 735 @VisibleForTesting | 736 @VisibleForTesting |
| 736 public ImeAdapter getImeAdapterForTest() { | 737 public ImeAdapter getImeAdapterForTest() { |
| 737 return mImeAdapter; | 738 return mImeAdapter; |
| 738 } | 739 } |
| 739 | 740 |
| 740 @VisibleForTesting | 741 @VisibleForTesting |
| 741 public void setAdapterInputConnectionFactory(AdapterInputConnectionFactory f actory) { | 742 public void setInputConnectionFactory(ChromiumBaseInputConnectionFactory fac tory) { |
| 742 mAdapterInputConnectionFactory = factory; | 743 mInputConnectionFactory = factory; |
| 743 } | 744 } |
| 744 | 745 |
| 745 @VisibleForTesting | 746 @VisibleForTesting |
| 746 public void setInputMethodManagerWrapperForTest(InputMethodManagerWrapper im mw) { | 747 public void setInputMethodManagerWrapperForTest(InputMethodManagerWrapper im mw) { |
| 747 mInputMethodManagerWrapper = immw; | 748 mInputMethodManagerWrapper = immw; |
| 748 } | 749 } |
| 749 | 750 |
| 750 @VisibleForTesting | 751 @VisibleForTesting |
| 751 public AdapterInputConnection getInputConnectionForTest() { | 752 public ChromiumBaseInputConnection getInputConnectionForTest() { |
| 752 return mInputConnection; | 753 return mInputConnection; |
| 753 } | 754 } |
| 754 | 755 |
| 755 private ImeAdapter createImeAdapter() { | 756 private ImeAdapter createImeAdapter() { |
| 756 return new ImeAdapter(mInputMethodManagerWrapper, | 757 return new ImeAdapter(mInputMethodManagerWrapper, |
| 757 new ImeAdapter.ImeAdapterDelegate() { | 758 new ImeAdapter.ImeAdapterDelegate() { |
| 758 @Override | 759 @Override |
| 759 public void onImeEvent() { | 760 public void onImeEvent() { |
| 760 mPopupZoomer.hide(true); | 761 mPopupZoomer.hide(true); |
| 761 getContentViewClient().onImeEvent(); | 762 getContentViewClient().onImeEvent(); |
| (...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1476 hidePopups(); | 1477 hidePopups(); |
| 1477 } | 1478 } |
| 1478 | 1479 |
| 1479 private void hidePopupsAndPreserveSelection() { | 1480 private void hidePopupsAndPreserveSelection() { |
| 1480 mUnselectAllOnActionModeDismiss = false; | 1481 mUnselectAllOnActionModeDismiss = false; |
| 1481 hidePopups(); | 1482 hidePopups(); |
| 1482 } | 1483 } |
| 1483 | 1484 |
| 1484 private void clearUserSelection() { | 1485 private void clearUserSelection() { |
| 1485 if (mFocusedNodeEditable) { | 1486 if (mFocusedNodeEditable) { |
| 1486 if (mInputConnection != null) { | 1487 if (mInputConnection != null |
| 1488 && AdapterInputConnection.class.isInstance(mInputConnection) ) { | |
| 1487 int selectionEnd = Selection.getSelectionEnd(mEditable); | 1489 int selectionEnd = Selection.getSelectionEnd(mEditable); |
| 1488 mInputConnection.setSelection(selectionEnd, selectionEnd); | 1490 mInputConnection.setSelection(selectionEnd, selectionEnd); |
| 1489 } | 1491 } |
| 1490 } else if (mWebContents != null) { | 1492 } else if (mWebContents != null) { |
| 1491 mWebContents.unselect(); | 1493 mWebContents.unselect(); |
| 1492 } | 1494 } |
| 1493 } | 1495 } |
| 1494 | 1496 |
| 1495 private void hidePopups() { | 1497 private void hidePopups() { |
| 1496 hideSelectActionMode(); | 1498 hideSelectActionMode(); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1569 /** | 1571 /** |
| 1570 * @see View#onCreateInputConnection(EditorInfo) | 1572 * @see View#onCreateInputConnection(EditorInfo) |
| 1571 */ | 1573 */ |
| 1572 public InputConnection onCreateInputConnection(EditorInfo outAttrs) { | 1574 public InputConnection onCreateInputConnection(EditorInfo outAttrs) { |
| 1573 if (!mImeAdapter.hasTextInputType()) { | 1575 if (!mImeAdapter.hasTextInputType()) { |
| 1574 // Although onCheckIsTextEditor will return false in this case, the EditorInfo | 1576 // Although onCheckIsTextEditor will return false in this case, the EditorInfo |
| 1575 // is still used by the InputMethodService. Need to make sure the IM E doesn't | 1577 // is still used by the InputMethodService. Need to make sure the IM E doesn't |
| 1576 // enter fullscreen mode. | 1578 // enter fullscreen mode. |
| 1577 outAttrs.imeOptions = EditorInfo.IME_FLAG_NO_FULLSCREEN; | 1579 outAttrs.imeOptions = EditorInfo.IME_FLAG_NO_FULLSCREEN; |
| 1578 } | 1580 } |
| 1579 mInputConnection = mAdapterInputConnectionFactory.get(mContainerView, mI meAdapter, | 1581 mInputConnection = |
| 1580 mEditable, outAttrs); | 1582 mInputConnectionFactory.get(mContainerView, mImeAdapter, mEditab le, outAttrs); |
|
AKV
2015/11/04 17:20:49
Is this factory stuff really needed ?, Can we remo
Changwan Ryu
2016/01/19 07:31:52
Since the AdapterInputConnection and ChromiumInput
| |
| 1581 return mInputConnection; | 1583 return mInputConnection; |
| 1582 } | 1584 } |
| 1583 | 1585 |
| 1584 @VisibleForTesting | |
| 1585 public AdapterInputConnection getAdapterInputConnectionForTest() { | |
| 1586 return mInputConnection; | |
| 1587 } | |
| 1588 | |
| 1589 @VisibleForTesting | 1586 @VisibleForTesting |
| 1590 public Editable getEditableForTest() { | 1587 public Editable getEditableForTest() { |
| 1591 return mEditable; | 1588 return mEditable; |
| 1592 } | 1589 } |
| 1593 | 1590 |
| 1594 /** | 1591 /** |
| 1595 * @see View#onCheckIsTextEditor() | 1592 * @see View#onCheckIsTextEditor() |
| 1596 */ | 1593 */ |
| 1597 public boolean onCheckIsTextEditor() { | 1594 public boolean onCheckIsTextEditor() { |
| 1598 return mImeAdapter.hasTextInputType(); | 1595 return mImeAdapter.hasTextInputType(); |
| 1599 } | 1596 } |
| 1600 | 1597 |
| 1601 /** | 1598 /** |
| 1602 * @see View#onConfigurationChanged(Configuration) | 1599 * @see View#onConfigurationChanged(Configuration) |
| 1603 */ | 1600 */ |
| 1604 @SuppressWarnings("javadoc") | 1601 @SuppressWarnings("javadoc") |
| 1605 public void onConfigurationChanged(Configuration newConfig) { | 1602 public void onConfigurationChanged(Configuration newConfig) { |
| 1606 try { | 1603 try { |
| 1607 TraceEvent.begin("ContentViewCore.onConfigurationChanged"); | 1604 TraceEvent.begin("ContentViewCore.onConfigurationChanged"); |
| 1608 | 1605 |
| 1609 if (mCurrentConfig.keyboard != newConfig.keyboard | 1606 if (mCurrentConfig.keyboard != newConfig.keyboard |
| 1610 || mCurrentConfig.keyboardHidden != newConfig.keyboardHidden | 1607 || mCurrentConfig.keyboardHidden != newConfig.keyboardHidden |
| 1611 || mCurrentConfig.hardKeyboardHidden != newConfig.hardKeyboa rdHidden) { | 1608 || mCurrentConfig.hardKeyboardHidden != newConfig.hardKeyboa rdHidden) { |
| 1612 if (mNativeContentViewCore != 0) { | 1609 if (mNativeContentViewCore != 0) { |
| 1613 mImeAdapter.attach(nativeGetNativeImeAdapter(mNativeContentV iewCore)); | 1610 mImeAdapter.attach(nativeGetNativeImeAdapter(mNativeContentV iewCore)); |
| 1614 } | 1611 } |
| 1615 mInputMethodManagerWrapper.restartInput(mContainerView); | 1612 mImeAdapter.restartInput(); |
| 1616 // By default, we show soft keyboard on keyboard changes. This i s useful | 1613 // By default, we show soft keyboard on keyboard changes. This i s useful |
| 1617 // when the user transitions from hardware keyboard to software keyboard. | 1614 // when the user transitions from hardware keyboard to software keyboard. |
| 1618 mImeAdapter.showSoftKeyboard(); | 1615 mImeAdapter.showSoftKeyboard(); |
| 1619 } | 1616 } |
| 1620 mContainerViewInternals.super_onConfigurationChanged(newConfig); | 1617 mContainerViewInternals.super_onConfigurationChanged(newConfig); |
| 1621 | 1618 |
| 1622 // To request layout has side effect, but it seems OK as it only hap pen in | 1619 // To request layout has side effect, but it seems OK as it only hap pen in |
| 1623 // onConfigurationChange and layout has to be changed in most case. | 1620 // onConfigurationChange and layout has to be changed in most case. |
| 1624 mContainerView.requestLayout(); | 1621 mContainerView.requestLayout(); |
| 1625 } finally { | 1622 } finally { |
| (...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2472 try { | 2469 try { |
| 2473 TraceEvent.begin("ContentViewCore.updateImeAdapter"); | 2470 TraceEvent.begin("ContentViewCore.updateImeAdapter"); |
| 2474 boolean focusedNodeEditable = (textInputType != TextInputType.NONE); | 2471 boolean focusedNodeEditable = (textInputType != TextInputType.NONE); |
| 2475 boolean focusedNodeIsPassword = (textInputType == TextInputType.PASS WORD); | 2472 boolean focusedNodeIsPassword = (textInputType == TextInputType.PASS WORD); |
| 2476 if (!focusedNodeEditable) hidePastePopup(); | 2473 if (!focusedNodeEditable) hidePastePopup(); |
| 2477 | 2474 |
| 2478 mImeAdapter.updateKeyboardVisibility( | 2475 mImeAdapter.updateKeyboardVisibility( |
| 2479 nativeImeAdapterAndroid, textInputType, textInputFlags, show ImeIfNeeded); | 2476 nativeImeAdapterAndroid, textInputType, textInputFlags, show ImeIfNeeded); |
| 2480 | 2477 |
| 2481 if (mInputConnection != null) { | 2478 if (mInputConnection != null) { |
| 2482 mInputConnection.updateState(text, selectionStart, selectionEnd, compositionStart, | 2479 // TODO |
| 2483 compositionEnd, isNonImeChange); | 2480 if (mImeAdapter.mInputConnection != null) { |
| 2481 mImeAdapter.mInputConnection.updateState(text, selectionStar t, selectionEnd, | |
| 2482 compositionStart, compositionEnd, isNonImeChange); | |
| 2483 } | |
| 2484 } | 2484 } |
| 2485 | 2485 |
| 2486 if (mActionMode != null) { | 2486 if (mActionMode != null) { |
| 2487 final boolean actionModeConfigurationChanged = | 2487 final boolean actionModeConfigurationChanged = |
| 2488 focusedNodeEditable != mFocusedNodeEditable | 2488 focusedNodeEditable != mFocusedNodeEditable |
| 2489 || focusedNodeIsPassword != mFocusedNodeIsPassword; | 2489 || focusedNodeIsPassword != mFocusedNodeIsPassword; |
| 2490 if (actionModeConfigurationChanged) mActionMode.invalidate(); | 2490 if (actionModeConfigurationChanged) mActionMode.invalidate(); |
| 2491 } | 2491 } |
| 2492 | 2492 |
| 2493 mFocusedNodeIsPassword = focusedNodeIsPassword; | 2493 mFocusedNodeIsPassword = focusedNodeIsPassword; |
| (...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3354 private native void nativeSetTextTrackSettings(long nativeContentViewCoreImp l, | 3354 private native void nativeSetTextTrackSettings(long nativeContentViewCoreImp l, |
| 3355 boolean textTracksEnabled, String textTrackBackgroundColor, String t extTrackFontFamily, | 3355 boolean textTracksEnabled, String textTrackBackgroundColor, String t extTrackFontFamily, |
| 3356 String textTrackFontStyle, String textTrackFontVariant, String textT rackTextColor, | 3356 String textTrackFontStyle, String textTrackFontVariant, String textT rackTextColor, |
| 3357 String textTrackTextShadow, String textTrackTextSize); | 3357 String textTrackTextShadow, String textTrackTextSize); |
| 3358 | 3358 |
| 3359 private native void nativeExtractSmartClipData(long nativeContentViewCoreImp l, | 3359 private native void nativeExtractSmartClipData(long nativeContentViewCoreImp l, |
| 3360 int x, int y, int w, int h); | 3360 int x, int y, int w, int h); |
| 3361 | 3361 |
| 3362 private native void nativeSetBackgroundOpaque(long nativeContentViewCoreImpl , boolean opaque); | 3362 private native void nativeSetBackgroundOpaque(long nativeContentViewCoreImpl , boolean opaque); |
| 3363 } | 3363 } |
| OLD | NEW |