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 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
495 private PastePopupMenu mPastePopupMenu; | 495 private PastePopupMenu mPastePopupMenu; |
496 private boolean mWasPastePopupShowingOnInsertionDragStart; | 496 private boolean mWasPastePopupShowingOnInsertionDragStart; |
497 | 497 |
498 // Size of the viewport in physical pixels as set from onSizeChanged. | 498 // Size of the viewport in physical pixels as set from onSizeChanged. |
499 private int mViewportWidthPix; | 499 private int mViewportWidthPix; |
500 private int mViewportHeightPix; | 500 private int mViewportHeightPix; |
501 private int mPhysicalBackingWidthPix; | 501 private int mPhysicalBackingWidthPix; |
502 private int mPhysicalBackingHeightPix; | 502 private int mPhysicalBackingHeightPix; |
503 private int mTopControlsHeightPix; | 503 private int mTopControlsHeightPix; |
504 private boolean mTopControlsShrinkBlinkSize; | 504 private boolean mTopControlsShrinkBlinkSize; |
505 private int mViewportHeightWithOSKHiddenPix; | |
505 | 506 |
506 // Cached copy of all positions and scales as reported by the renderer. | 507 // Cached copy of all positions and scales as reported by the renderer. |
507 private final RenderCoordinates mRenderCoordinates; | 508 private final RenderCoordinates mRenderCoordinates; |
508 | 509 |
509 // Provides smooth gamepad joystick-driven scrolling. | 510 // Provides smooth gamepad joystick-driven scrolling. |
510 private final JoystickScrollProvider mJoystickScrollProvider; | 511 private final JoystickScrollProvider mJoystickScrollProvider; |
511 | 512 |
512 private boolean mIsMobileOptimizedHint; | 513 private boolean mIsMobileOptimizedHint; |
513 | 514 |
514 // Tracks whether a selection is currently active. When applied to selected text, indicates | 515 // Tracks whether a selection is currently active. When applied to selected text, indicates |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1081 | 1082 |
1082 /** | 1083 /** |
1083 * @return Viewport height in physical pixels as set from onSizeChanged. | 1084 * @return Viewport height in physical pixels as set from onSizeChanged. |
1084 */ | 1085 */ |
1085 @CalledByNative | 1086 @CalledByNative |
1086 public int getViewportHeightPix() { | 1087 public int getViewportHeightPix() { |
1087 return mViewportHeightPix; | 1088 return mViewportHeightPix; |
1088 } | 1089 } |
1089 | 1090 |
1090 /** | 1091 /** |
1092 * @return Viewport height when the OSK is hidden in physical pixels as set from onSizeChanged. | |
1093 */ | |
1094 @CalledByNative | |
1095 public int getViewportHeightWithOSKHiddenPix() { | |
1096 return mViewportHeightWithOSKHiddenPix; | |
1097 } | |
1098 | |
1099 /** | |
1091 * @return Width of underlying physical surface. | 1100 * @return Width of underlying physical surface. |
1092 */ | 1101 */ |
1093 @CalledByNative | 1102 @CalledByNative |
1094 public int getPhysicalBackingWidthPix() { | 1103 public int getPhysicalBackingWidthPix() { |
1095 return mPhysicalBackingWidthPix; | 1104 return mPhysicalBackingWidthPix; |
1096 } | 1105 } |
1097 | 1106 |
1098 /** | 1107 /** |
1099 * @return Height of underlying physical surface. | 1108 * @return Height of underlying physical surface. |
1100 */ | 1109 */ |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1612 } | 1621 } |
1613 } | 1622 } |
1614 | 1623 |
1615 /** | 1624 /** |
1616 * @see View#onSizeChanged(int, int, int, int) | 1625 * @see View#onSizeChanged(int, int, int, int) |
1617 */ | 1626 */ |
1618 @SuppressWarnings("javadoc") | 1627 @SuppressWarnings("javadoc") |
1619 public void onSizeChanged(int wPix, int hPix, int owPix, int ohPix) { | 1628 public void onSizeChanged(int wPix, int hPix, int owPix, int ohPix) { |
1620 if (getViewportWidthPix() == wPix && getViewportHeightPix() == hPix) ret urn; | 1629 if (getViewportWidthPix() == wPix && getViewportHeightPix() == hPix) ret urn; |
1621 | 1630 |
1631 boolean displayRectChanged = false; | |
1632 boolean triggeredByOSKShow = false; | |
1633 if (!mFocusPreOSKViewportRect.isEmpty()) { | |
1634 Rect rect = new Rect(); | |
1635 getContainerView().getWindowVisibleDisplayFrame(rect); | |
1636 displayRectChanged = !rect.equals(mFocusPreOSKViewportRect); | |
1637 // Only assume the OSK triggered the onSizeChanged if width was pres erved. | |
1638 triggeredByOSKShow = displayRectChanged | |
1639 && rect.width() == mFocusPreOSKViewportRect.width(); | |
1640 } | |
1641 | |
1642 // triggeredByOSKShow is true if we are resizing to show the OSK. In thi s case, | |
1643 // mViewportHeightWithOSKHiddenPix is mViewportHeightPix because the OSK was originally | |
1644 // hidden. Otherwise, we are either resizing to hide the OSK or the onSi zeChanged is not | |
1645 // triggered by OSK, in which case mViewportHeightWithoutOSK is hPix bec ause there's no OSK | |
1646 // to include in the height. | |
1647 if (triggeredByOSKShow) { | |
1648 mViewportHeightWithOSKHiddenPix = mViewportHeightPix; | |
jdduke (slow)
2015/10/09 15:17:28
Like I said, the current heuristic is less than pe
| |
1649 } else { | |
1650 mViewportHeightWithOSKHiddenPix = hPix; | |
1651 } | |
1652 | |
1622 mViewportWidthPix = wPix; | 1653 mViewportWidthPix = wPix; |
1623 mViewportHeightPix = hPix; | 1654 mViewportHeightPix = hPix; |
1624 if (mNativeContentViewCore != 0) { | 1655 if (mNativeContentViewCore != 0) { |
1625 nativeWasResized(mNativeContentViewCore); | 1656 nativeWasResized(mNativeContentViewCore); |
1626 } | 1657 } |
1627 | 1658 |
1628 updateAfterSizeChanged(); | 1659 mPopupZoomer.hide(false); |
1660 | |
1661 // Execute a delayed form focus operation because the OSK was brought | |
1662 // up earlier. | |
1663 if (triggeredByOSKShow) { | |
1664 assert mWebContents != null; | |
1665 mWebContents.scrollFocusedEditableNodeIntoView(); | |
1666 } | |
1667 if (displayRectChanged) { | |
1668 cancelRequestToScrollFocusedEditableNodeIntoView(); | |
1669 } | |
1629 } | 1670 } |
1630 | 1671 |
1631 /** | 1672 /** |
1632 * Called when the underlying surface the compositor draws to changes size. | 1673 * Called when the underlying surface the compositor draws to changes size. |
1633 * This may be larger than the viewport size. | 1674 * This may be larger than the viewport size. |
1634 */ | 1675 */ |
1635 public void onPhysicalBackingSizeChanged(int wPix, int hPix) { | 1676 public void onPhysicalBackingSizeChanged(int wPix, int hPix) { |
1636 if (mPhysicalBackingWidthPix == wPix && mPhysicalBackingHeightPix == hPi x) return; | 1677 if (mPhysicalBackingWidthPix == wPix && mPhysicalBackingHeightPix == hPi x) return; |
1637 | 1678 |
1638 mPhysicalBackingWidthPix = wPix; | 1679 mPhysicalBackingWidthPix = wPix; |
1639 mPhysicalBackingHeightPix = hPix; | 1680 mPhysicalBackingHeightPix = hPix; |
1640 | 1681 |
1641 if (mNativeContentViewCore != 0) { | 1682 if (mNativeContentViewCore != 0) { |
1642 nativeWasResized(mNativeContentViewCore); | 1683 nativeWasResized(mNativeContentViewCore); |
1643 } | 1684 } |
1644 } | 1685 } |
1645 | 1686 |
1646 /* TODO(aelias): Remove this after downstream callers disappear. */ | 1687 /* TODO(aelias): Remove this after downstream callers disappear. */ |
1647 public void onOverdrawBottomHeightChanged(int overdrawHeightPix) { | 1688 public void onOverdrawBottomHeightChanged(int overdrawHeightPix) { |
1648 } | 1689 } |
1649 | 1690 |
1650 private void updateAfterSizeChanged() { | |
1651 mPopupZoomer.hide(false); | |
1652 | |
1653 // Execute a delayed form focus operation because the OSK was brought | |
1654 // up earlier. | |
1655 if (!mFocusPreOSKViewportRect.isEmpty()) { | |
1656 Rect rect = new Rect(); | |
1657 getContainerView().getWindowVisibleDisplayFrame(rect); | |
1658 if (!rect.equals(mFocusPreOSKViewportRect)) { | |
1659 // Only assume the OSK triggered the onSizeChanged if width was preserved. | |
1660 if (rect.width() == mFocusPreOSKViewportRect.width()) { | |
1661 assert mWebContents != null; | |
1662 mWebContents.scrollFocusedEditableNodeIntoView(); | |
1663 } | |
1664 cancelRequestToScrollFocusedEditableNodeIntoView(); | |
1665 } | |
1666 } | |
1667 } | |
1668 | |
1669 private void cancelRequestToScrollFocusedEditableNodeIntoView() { | 1691 private void cancelRequestToScrollFocusedEditableNodeIntoView() { |
1670 // Zero-ing the rect will prevent |updateAfterSizeChanged()| from | 1692 // Zero-ing the rect will prevent |onSizeChanged()| from |
1671 // issuing the delayed form focus event. | 1693 // issuing the delayed form focus event. |
1672 mFocusPreOSKViewportRect.setEmpty(); | 1694 mFocusPreOSKViewportRect.setEmpty(); |
1673 } | 1695 } |
1674 | 1696 |
1675 /** | 1697 /** |
1676 * @see View#onWindowFocusChanged(boolean) | 1698 * @see View#onWindowFocusChanged(boolean) |
1677 */ | 1699 */ |
1678 public void onWindowFocusChanged(boolean hasWindowFocus) { | 1700 public void onWindowFocusChanged(boolean hasWindowFocus) { |
1679 if (!hasWindowFocus) resetGestureDetection(); | 1701 if (!hasWindowFocus) resetGestureDetection(); |
1680 if (mActionMode != null) mActionMode.onWindowFocusChanged(hasWindowFocus ); | 1702 if (mActionMode != null) mActionMode.onWindowFocusChanged(hasWindowFocus ); |
(...skipping 1672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3353 private native void nativeSetTextTrackSettings(long nativeContentViewCoreImp l, | 3375 private native void nativeSetTextTrackSettings(long nativeContentViewCoreImp l, |
3354 boolean textTracksEnabled, String textTrackBackgroundColor, String t extTrackFontFamily, | 3376 boolean textTracksEnabled, String textTrackBackgroundColor, String t extTrackFontFamily, |
3355 String textTrackFontStyle, String textTrackFontVariant, String textT rackTextColor, | 3377 String textTrackFontStyle, String textTrackFontVariant, String textT rackTextColor, |
3356 String textTrackTextShadow, String textTrackTextSize); | 3378 String textTrackTextShadow, String textTrackTextSize); |
3357 | 3379 |
3358 private native void nativeExtractSmartClipData(long nativeContentViewCoreImp l, | 3380 private native void nativeExtractSmartClipData(long nativeContentViewCoreImp l, |
3359 int x, int y, int w, int h); | 3381 int x, int y, int w, int h); |
3360 | 3382 |
3361 private native void nativeSetBackgroundOpaque(long nativeContentViewCoreImpl , boolean opaque); | 3383 private native void nativeSetBackgroundOpaque(long nativeContentViewCoreImpl , boolean opaque); |
3362 } | 3384 } |
OLD | NEW |