Chromium Code Reviews| Index: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java |
| diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java |
| index f3bd7259805dd3b53aa13dab667da64e6df83851..54d4dc1e6f4dba6a6312aeda59755507080a02c8 100644 |
| --- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java |
| +++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java |
| @@ -502,6 +502,7 @@ public class ContentViewCore implements |
| private int mPhysicalBackingHeightPix; |
| private int mTopControlsHeightPix; |
| private boolean mTopControlsShrinkBlinkSize; |
| + private int mViewportHeightWithOSKHiddenPix; |
| // Cached copy of all positions and scales as reported by the renderer. |
| private final RenderCoordinates mRenderCoordinates; |
| @@ -1088,6 +1089,14 @@ public class ContentViewCore implements |
| } |
| /** |
| + * @return Viewport height when the OSK is hidden in physical pixels as set from onSizeChanged. |
| + */ |
| + @CalledByNative |
| + public int getViewportHeightWithOSKHiddenPix() { |
| + return mViewportHeightWithOSKHiddenPix; |
| + } |
| + |
| + /** |
| * @return Width of underlying physical surface. |
| */ |
| @CalledByNative |
| @@ -1619,13 +1628,45 @@ public class ContentViewCore implements |
| public void onSizeChanged(int wPix, int hPix, int owPix, int ohPix) { |
| if (getViewportWidthPix() == wPix && getViewportHeightPix() == hPix) return; |
| + boolean displayRectChanged = false; |
| + boolean triggeredByOSKShow = false; |
| + if (!mFocusPreOSKViewportRect.isEmpty()) { |
| + Rect rect = new Rect(); |
| + getContainerView().getWindowVisibleDisplayFrame(rect); |
| + displayRectChanged = !rect.equals(mFocusPreOSKViewportRect); |
| + // Only assume the OSK triggered the onSizeChanged if width was preserved. |
| + triggeredByOSKShow = displayRectChanged |
| + && rect.width() == mFocusPreOSKViewportRect.width(); |
| + } |
| + |
| + // triggeredByOSKShow is true if we are resizing to show the OSK. In this case, |
| + // mViewportHeightWithOSKHiddenPix is mViewportHeightPix because the OSK was originally |
| + // hidden. Otherwise, we are either resizing to hide the OSK or the onSizeChanged is not |
| + // triggered by OSK, in which case mViewportHeightWithoutOSK is hPix because there's no OSK |
| + // to include in the height. |
| + if (triggeredByOSKShow) { |
| + mViewportHeightWithOSKHiddenPix = mViewportHeightPix; |
|
jdduke (slow)
2015/10/09 15:17:28
Like I said, the current heuristic is less than pe
|
| + } else { |
| + mViewportHeightWithOSKHiddenPix = hPix; |
| + } |
| + |
| mViewportWidthPix = wPix; |
| mViewportHeightPix = hPix; |
| if (mNativeContentViewCore != 0) { |
| nativeWasResized(mNativeContentViewCore); |
| } |
| - updateAfterSizeChanged(); |
| + mPopupZoomer.hide(false); |
| + |
| + // Execute a delayed form focus operation because the OSK was brought |
| + // up earlier. |
| + if (triggeredByOSKShow) { |
| + assert mWebContents != null; |
| + mWebContents.scrollFocusedEditableNodeIntoView(); |
| + } |
| + if (displayRectChanged) { |
| + cancelRequestToScrollFocusedEditableNodeIntoView(); |
| + } |
| } |
| /** |
| @@ -1647,27 +1688,8 @@ public class ContentViewCore implements |
| public void onOverdrawBottomHeightChanged(int overdrawHeightPix) { |
| } |
| - private void updateAfterSizeChanged() { |
| - mPopupZoomer.hide(false); |
| - |
| - // Execute a delayed form focus operation because the OSK was brought |
| - // up earlier. |
| - if (!mFocusPreOSKViewportRect.isEmpty()) { |
| - Rect rect = new Rect(); |
| - getContainerView().getWindowVisibleDisplayFrame(rect); |
| - if (!rect.equals(mFocusPreOSKViewportRect)) { |
| - // Only assume the OSK triggered the onSizeChanged if width was preserved. |
| - if (rect.width() == mFocusPreOSKViewportRect.width()) { |
| - assert mWebContents != null; |
| - mWebContents.scrollFocusedEditableNodeIntoView(); |
| - } |
| - cancelRequestToScrollFocusedEditableNodeIntoView(); |
| - } |
| - } |
| - } |
| - |
| private void cancelRequestToScrollFocusedEditableNodeIntoView() { |
| - // Zero-ing the rect will prevent |updateAfterSizeChanged()| from |
| + // Zero-ing the rect will prevent |onSizeChanged()| from |
| // issuing the delayed form focus event. |
| mFocusPreOSKViewportRect.setEmpty(); |
| } |