Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1539)

Unified Diff: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java

Issue 1164033002: Change focus status according to the change of window focus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename method Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 e79a9db4c93445a7b59a65aade38e249f0df65f9..f371caa4260f1612dc7d27d2a29bc5b1ece486da 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
@@ -1632,13 +1632,25 @@ public class ContentViewCore implements
mFocusPreOSKViewportRect.setEmpty();
}
+ private void updateNativeFocus() {
+ if (mNativeContentViewCore != 0) nativeSetFocus(mNativeContentViewCore, hasFocus());
+ }
+
/**
* @see View#onWindowFocusChanged(boolean)
*/
public void onWindowFocusChanged(boolean hasWindowFocus) {
+ // http://crbug.com/495547: View's focus status isn't changed even when Window's focus
+ // status is changed. But to receive key events, both View and its Window must have focus.
+ // So blinking a cursor in an input area doesn't make sense when Window's focus is lost
+ // even though |mContainerView| has focus.
+ updateNativeFocus();
if (!hasWindowFocus) resetGestureDetection();
}
+ /**
+ * @see View#onFocusChanged(boolean)
+ */
public void onFocusChanged(boolean gainFocus) {
if (gainFocus) {
restoreSelectionPopupsIfNecessary();
@@ -1656,7 +1668,7 @@ public class ContentViewCore implements
clearUserSelection();
}
}
- if (mNativeContentViewCore != 0) nativeSetFocus(mNativeContentViewCore, gainFocus);
+ updateNativeFocus();
}
/**
@@ -2616,14 +2628,16 @@ public class ContentViewCore implements
}
/**
- * @see View#hasFocus()
+ * ContentViewCore has focus when both mContainerView.hasFocus() and
+ * mContainerView.hasWindowFocus() are true.
+ * @see View#hasFocus() and View#hasWindowFocus()
*/
@CalledByNative
private boolean hasFocus() {
// If the container view is not focusable, we consider it always focused from
// Chromium's point of view.
if (!mContainerView.isFocusable()) return true;
- return mContainerView.hasFocus();
+ return mContainerView.hasFocus() && mContainerView.hasWindowFocus();
}
/**
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698