diff options
author | 2011-11-08 15:00:17 -0800 | |
---|---|---|
committer | 2011-11-08 15:00:17 -0800 | |
commit | d6ac727234b9be45c3df4021dc83584e9849c00a (patch) | |
tree | 6daff8b7d20b17c1eb9c385cc185eadb356a9ca5 | |
parent | 99015a2464a40097c3e23e07cdf69da0f886aa66 (diff) |
Fix determining find on page overlap
Bug: 5572138
Change-Id: Ie528e1cf9df363307018e01a898e8d9dfff1cd45
-rw-r--r-- | core/java/android/webkit/FindActionModeCallback.java | 15 | ||||
-rw-r--r-- | core/java/android/webkit/WebView.java | 19 |
2 files changed, 29 insertions, 5 deletions
diff --git a/core/java/android/webkit/FindActionModeCallback.java b/core/java/android/webkit/FindActionModeCallback.java index b85fd17f78de..fffa90b5518a 100644 --- a/core/java/android/webkit/FindActionModeCallback.java +++ b/core/java/android/webkit/FindActionModeCallback.java @@ -18,6 +18,8 @@ package android.webkit; import android.content.Context; import android.content.res.Resources; +import android.graphics.Point; +import android.graphics.Rect; import android.text.Editable; import android.text.Selection; import android.text.Spannable; @@ -254,13 +256,18 @@ class FindActionModeCallback implements ActionMode.Callback, TextWatcher, // Does nothing. Needed to implement TextWatcher. } - public int getActionModeHeight() { + private Rect mGlobalVisibleRect = new Rect(); + private Point mGlobalVisibleOffset = new Point(); + public int getActionModeGlobalBottom() { if (mActionMode == null) { return 0; } - View parent = (View) mCustomView.getParent(); - return parent != null ? parent.getMeasuredHeight() - : mCustomView.getMeasuredHeight(); + View view = (View) mCustomView.getParent(); + if (view == null) { + view = mCustomView; + } + view.getGlobalVisibleRect(mGlobalVisibleRect, mGlobalVisibleOffset); + return mGlobalVisibleRect.bottom; } } diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 55f345fb95e7..35efabcb6d81 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -1484,7 +1484,21 @@ public class WebView extends AbsoluteLayout private int getVisibleTitleHeightImpl() { // need to restrict mScrollY due to over scroll return Math.max(getTitleHeight() - Math.max(0, mScrollY), - mFindCallback != null ? mFindCallback.getActionModeHeight() : 0); + getOverlappingActionModeHeight()); + } + + private int mCachedOverlappingActionModeHeight = -1; + + private int getOverlappingActionModeHeight() { + if (mFindCallback == null) { + return 0; + } + if (mCachedOverlappingActionModeHeight < 0) { + getGlobalVisibleRect(mGlobalVisibleRect, mGlobalVisibleOffset); + mCachedOverlappingActionModeHeight = Math.max(0, + mFindCallback.getActionModeGlobalBottom() - mGlobalVisibleRect.top); + } + return mCachedOverlappingActionModeHeight; } /* @@ -3375,6 +3389,7 @@ public class WebView extends AbsoluteLayout // Could not start the action mode, so end Find on page return false; } + mCachedOverlappingActionModeHeight = -1; mFindCallback = callback; setFindIsUp(true); mFindCallback.setWebView(this); @@ -3492,6 +3507,7 @@ public class WebView extends AbsoluteLayout */ void notifyFindDialogDismissed() { mFindCallback = null; + mCachedOverlappingActionModeHeight = -1; if (mWebViewCore == null) { return; } @@ -4341,6 +4357,7 @@ public class WebView extends AbsoluteLayout @Override protected void onConfigurationChanged(Configuration newConfig) { + mCachedOverlappingActionModeHeight = -1; if (mSelectingText && mOrientation != newConfig.orientation) { selectionDone(); } |