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 296657 90cae878a97e
parent 296656 ee8a828b4974
child 296658 89e3c373b3a4
push id5276
push usercbook@mozilla.com
push date2015-11-09 10:31 +0000
treeherdermozilla-beta@be9dcc3b97b3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
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());