Bug 1213888 - Block LayerView descendants from interfering with focus. r=kats, a=ritu, a=sylvestre
authorJim Chen <nchen@mozilla.com>
Fri, 30 Oct 2015 08:30:00 +0100
changeset 307701 90cae878a97e5fb9a82b3fa00dd72b15edf29b7f
parent 307700 ee8a828b497498c8a4325e3007197c75af931c3b
child 307702 89e3c373b3a472f4b609c61ad1f19d793c1c9309
push id7348
push userjbruaroey@mozilla.com
push dateMon, 09 Nov 2015 21:46:36 +0000
reviewerskats, ritu, sylvestre
bugs1213888
milestone43.0
Bug 1213888 - Block LayerView descendants from interfering with focus. r=kats, a=ritu, a=sylvestre Using a hardware keyboard makes Android leave "touch mode", and when leaving touch mode from a ViewGroup that prefers descendant focusability, which is what a ScrollView is, Android will shift the focus to the next available View, and cause our LayerView to lose focus. The fix is to set the descendant focusability to blocking.
mobile/android/base/gfx/LayerView.java
--- a/mobile/android/base/gfx/LayerView.java
+++ b/mobile/android/base/gfx/LayerView.java
@@ -267,16 +267,20 @@ public class LayerView extends ScrollVie
         if (mPanZoomController != null && mPanZoomController.onMotionEvent(event)) {
             return true;
         }
         return false;
     }
 
     @Override
     protected void onAttachedToWindow() {
+        // We are adding descendants to this LayerView, but we don't want the
+        // descendants to affect the way LayerView retains its focus.
+        setDescendantFocusability(FOCUS_BLOCK_DESCENDANTS);
+
         // This check should not be done before the view is attached to a window
         // as hardware acceleration will not be enabled at that point.
         // We must create and add the SurfaceView instance before the view tree
         // is fully created to avoid flickering (see bug 801477).
         if (shouldUseTextureView()) {
             mTextureView = new TextureView(getContext());
             mTextureView.setSurfaceTextureListener(new SurfaceTextureListener());