summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2014-07-18 20:47:28 -0700
committerBen Murdoch <benm@google.com>2014-07-18 20:47:28 -0700
commit1f14a4515e04c9ffc9bac4dd1e2f68611626b800 (patch)
tree9a7ad88950b62125c364a281784e26c8e453e56e
parentf35c392caf6898039307022046411d05049009c4 (diff)
downloadchromium_org-1f14a4515e04c9ffc9bac4dd1e2f68611626b800.tar.gz
Cherry pick crrev.com/281310
Fix the build in master. Original description: [Android WebView] Supress focus change when temporarily detached. The AwContents container view may be "temporarily detached" by the view system during certain layout operations e.g. if it is a child of a ListView. In this case, we should ignore changes to focus to avoid unnecessary churn and loss of state, e.g. when text is selction the focus toggle results in an action bar toggle and loss of the text selection. BUG=391282 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=281310 Change-Id: I1ccd6600da05c991a68256bf08d10448afdbb015
-rw-r--r--android_webview/java/src/org/chromium/android_webview/AwContents.java24
1 files changed, 23 insertions, 1 deletions
diff --git a/android_webview/java/src/org/chromium/android_webview/AwContents.java b/android_webview/java/src/org/chromium/android_webview/AwContents.java
index 340e18cc61..03a87ed03c 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
@@ -236,6 +236,11 @@ public class AwContents {
// through the resourcethrottle. This is only used for popup windows.
private boolean mDeferredShouldOverrideUrlLoadingIsPendingForPopup;
+ // The framework may temporarily detach our container view, for example during layout if
+ // we are a child of a ListView. This may cause many toggles of View focus, which we suppress
+ // when in this state.
+ private boolean mTemporarilyDetached;
+
private static final class DestroyRunnable implements Runnable {
private final long mNativeAwContents;
private DestroyRunnable(long nativeAwContents) {
@@ -1534,6 +1539,7 @@ public class AwContents {
* @see android.view.View#onAttachedToWindow()
*/
public void onAttachedToWindow() {
+ mTemporarilyDetached = false;
mAwViewMethods.onAttachedToWindow();
}
@@ -1556,7 +1562,23 @@ public class AwContents {
* @see android.view.View#onFocusChanged()
*/
public void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
- mAwViewMethods.onFocusChanged(focused, direction, previouslyFocusedRect);
+ if (!mTemporarilyDetached) {
+ mAwViewMethods.onFocusChanged(focused, direction, previouslyFocusedRect);
+ }
+ }
+
+ /**
+ * @see android.view.View#onStartTemporaryDetach()
+ */
+ public void onStartTemporaryDetach() {
+ mTemporarilyDetached = true;
+ }
+
+ /**
+ * @see android.view.View#onFinishTemporaryDetach()
+ */
+ public void onFinishTemporaryDetach() {
+ mTemporarilyDetached = false;
}
/**