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 mViewportHeightWithoutOSKPix; | |
bokan
2015/10/08 22:38:21
This is misleading since it implies we're excludin
ymalik
2015/10/09 01:05:25
Done.
| |
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 without the OSK in physical pixels as set from on SizeChanged. | |
1093 */ | |
1094 @CalledByNative | |
1095 public int getViewportHeightWithoutOSKPix() { | |
1096 return mViewportHeightWithoutOSKPix; | |
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 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1609 } finally { | 1618 } finally { |
1610 mCurrentConfig = newConfig; | 1619 mCurrentConfig = newConfig; |
1611 TraceEvent.end("ContentViewCore.onConfigurationChanged"); | 1620 TraceEvent.end("ContentViewCore.onConfigurationChanged"); |
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) { |
bokan
2015/10/08 22:38:21
It seems we might now always get an onSizeChanged:
| |
1620 if (getViewportWidthPix() == wPix && getViewportHeightPix() == hPix) ret urn; | 1629 if (getViewportWidthPix() == wPix && getViewportHeightPix() == hPix) ret urn; |
1621 | 1630 |
1631 boolean displayRectChanged = false, triggeredByOSKShow = false; | |
bokan
2015/10/08 22:38:21
Nit: Variable declarations should get their own li
ymalik
2015/10/09 01:05:25
Done.
| |
1632 if (!mFocusPreOSKViewportRect.isEmpty()) { | |
1633 Rect rect = new Rect(); | |
1634 getContainerView().getWindowVisibleDisplayFrame(rect); | |
1635 displayRectChanged = !rect.equals(mFocusPreOSKViewportRect); | |
1636 // Only assume the OSK triggered the onSizeChanged if width was pres erved. | |
1637 triggeredByOSKShow = displayRectChanged | |
1638 && rect.width() == mFocusPreOSKViewportRect.width(); | |
1639 } | |
1640 | |
1641 // triggeredByOSKShow is true if we are resizing to show the OSK. In thi s case, | |
1642 // mViewportHeightWithoutOSK is what mViewportHeightPix was previously. Otherwise | |
1643 // we are either resizing to hide the OSK or the onSizeChanged is not tr iggered by OSK, | |
1644 // in which case the mViewportHeightWithoutOSK is hPix. | |
bokan
2015/10/08 22:38:21
Comments should describe the "why?" not the "how".
ymalik
2015/10/09 01:05:25
Thanks. Done.
| |
1645 if (triggeredByOSKShow) { | |
1646 mViewportHeightWithoutOSKPix = mViewportHeightPix; | |
1647 } else { | |
1648 mViewportHeightWithoutOSKPix = hPix; | |
1649 } | |
1650 | |
1622 mViewportWidthPix = wPix; | 1651 mViewportWidthPix = wPix; |
1623 mViewportHeightPix = hPix; | 1652 mViewportHeightPix = hPix; |
1624 if (mNativeContentViewCore != 0) { | 1653 if (mNativeContentViewCore != 0) { |
1625 nativeWasResized(mNativeContentViewCore); | 1654 nativeWasResized(mNativeContentViewCore); |
1626 } | 1655 } |
1627 | 1656 |
1628 updateAfterSizeChanged(); | 1657 mPopupZoomer.hide(false); |
1658 | |
1659 // Execute a delayed form focus operation because the OSK was brought | |
1660 // up earlier. | |
1661 if (triggeredByOSKShow) { | |
1662 assert mWebContents != null; | |
1663 mWebContents.scrollFocusedEditableNodeIntoView(); | |
1664 } | |
1665 if (displayRectChanged) { | |
1666 cancelRequestToScrollFocusedEditableNodeIntoView(); | |
1667 } | |
1668 cancelRequestToScrollFocusedEditableNodeIntoView(); | |
bokan
2015/10/08 22:38:21
Is this accidentally duplicated? It makes the abov
ymalik
2015/10/09 01:05:25
Most definitely an accident.
| |
1629 } | 1669 } |
1630 | 1670 |
1631 /** | 1671 /** |
1632 * Called when the underlying surface the compositor draws to changes size. | 1672 * Called when the underlying surface the compositor draws to changes size. |
1633 * This may be larger than the viewport size. | 1673 * This may be larger than the viewport size. |
1634 */ | 1674 */ |
1635 public void onPhysicalBackingSizeChanged(int wPix, int hPix) { | 1675 public void onPhysicalBackingSizeChanged(int wPix, int hPix) { |
1636 if (mPhysicalBackingWidthPix == wPix && mPhysicalBackingHeightPix == hPi x) return; | 1676 if (mPhysicalBackingWidthPix == wPix && mPhysicalBackingHeightPix == hPi x) return; |
1637 | 1677 |
1638 mPhysicalBackingWidthPix = wPix; | 1678 mPhysicalBackingWidthPix = wPix; |
1639 mPhysicalBackingHeightPix = hPix; | 1679 mPhysicalBackingHeightPix = hPix; |
1640 | 1680 |
1641 if (mNativeContentViewCore != 0) { | 1681 if (mNativeContentViewCore != 0) { |
1642 nativeWasResized(mNativeContentViewCore); | 1682 nativeWasResized(mNativeContentViewCore); |
1643 } | 1683 } |
1644 } | 1684 } |
1645 | 1685 |
1646 /* TODO(aelias): Remove this after downstream callers disappear. */ | 1686 /* TODO(aelias): Remove this after downstream callers disappear. */ |
1647 public void onOverdrawBottomHeightChanged(int overdrawHeightPix) { | 1687 public void onOverdrawBottomHeightChanged(int overdrawHeightPix) { |
1648 } | 1688 } |
1649 | 1689 |
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() { | 1690 private void cancelRequestToScrollFocusedEditableNodeIntoView() { |
1670 // Zero-ing the rect will prevent |updateAfterSizeChanged()| from | 1691 // Zero-ing the rect will prevent |onSizeChanged()| from |
1671 // issuing the delayed form focus event. | 1692 // issuing the delayed form focus event. |
1672 mFocusPreOSKViewportRect.setEmpty(); | 1693 mFocusPreOSKViewportRect.setEmpty(); |
1673 } | 1694 } |
1674 | 1695 |
1675 /** | 1696 /** |
1676 * @see View#onWindowFocusChanged(boolean) | 1697 * @see View#onWindowFocusChanged(boolean) |
1677 */ | 1698 */ |
1678 public void onWindowFocusChanged(boolean hasWindowFocus) { | 1699 public void onWindowFocusChanged(boolean hasWindowFocus) { |
1679 if (!hasWindowFocus) resetGestureDetection(); | 1700 if (!hasWindowFocus) resetGestureDetection(); |
1680 if (mActionMode != null) mActionMode.onWindowFocusChanged(hasWindowFocus ); | 1701 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, | 3374 private native void nativeSetTextTrackSettings(long nativeContentViewCoreImp l, |
3354 boolean textTracksEnabled, String textTrackBackgroundColor, String t extTrackFontFamily, | 3375 boolean textTracksEnabled, String textTrackBackgroundColor, String t extTrackFontFamily, |
3355 String textTrackFontStyle, String textTrackFontVariant, String textT rackTextColor, | 3376 String textTrackFontStyle, String textTrackFontVariant, String textT rackTextColor, |
3356 String textTrackTextShadow, String textTrackTextSize); | 3377 String textTrackTextShadow, String textTrackTextSize); |
3357 | 3378 |
3358 private native void nativeExtractSmartClipData(long nativeContentViewCoreImp l, | 3379 private native void nativeExtractSmartClipData(long nativeContentViewCoreImp l, |
3359 int x, int y, int w, int h); | 3380 int x, int y, int w, int h); |
3360 | 3381 |
3361 private native void nativeSetBackgroundOpaque(long nativeContentViewCoreImpl , boolean opaque); | 3382 private native void nativeSetBackgroundOpaque(long nativeContentViewCoreImpl , boolean opaque); |
3362 } | 3383 } |
OLD | NEW |