Bug 1472140 - 2. Set text input / accessibility views with the session; r?esawin draft
authorJim Chen <nchen@mozilla.com>
Mon, 30 Jul 2018 16:38:35 -0400
changeset 824445 b99a347fbcfb6c106e28f03f06df41c7eefd6b6c
parent 824444 49ba986379cb42acf9a1ce945f54f14db80839d1
push id117906
push userbmo:nchen@mozilla.com
push dateMon, 30 Jul 2018 20:39:17 +0000
reviewersesawin
bugs1472140
milestone63.0a1
Bug 1472140 - 2. Set text input / accessibility views with the session; r?esawin Instead of changing the text input / accessibility views during window attachment / detachment, we should change them during session attachment / detachment because those views are associated with the session. MozReview-Commit-ID: G89rnc9ySS1
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoView.java
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoView.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoView.java
@@ -210,19 +210,29 @@ public class GeckoView extends FrameLayo
 
         // Cover the view while we are not drawing to the surface.
         coverUntilFirstPaint(Color.WHITE);
 
         GeckoSession session = mSession;
         mSession.releaseDisplay(mDisplay.release());
         mSession.getOverscrollEdgeEffect().setInvalidationCallback(null);
         mSession.getCompositorController().setFirstPaintCallback(null);
+
+        if (mSession.getAccessibility().getView() == this) {
+            mSession.getAccessibility().setView(null);
+        }
+
+        if (mSession.getTextInput().getView() == this) {
+            mSession.getTextInput().setView(null);
+        }
+
         if (session.getSelectionActionDelegate() == mSelectionActionDelegate) {
             mSession.setSelectionActionDelegate(null);
         }
+
         mSession = null;
         return session;
     }
 
     /**
      * Attach a session to this view. The session should be opened before
      * attaching.
      *
@@ -289,16 +299,24 @@ public class GeckoView extends FrameLayo
 
         session.getCompositorController().setFirstPaintCallback(new Runnable() {
             @Override
             public void run() {
                 coverUntilFirstPaint(Color.TRANSPARENT);
             }
         });
 
+        if (session.getTextInput().getView() == null) {
+            session.getTextInput().setView(this);
+        }
+
+        if (session.getAccessibility().getView() == null) {
+            session.getAccessibility().setView(this);
+        }
+
         if (session.getSelectionActionDelegate() == null && mSelectionActionDelegate != null) {
             session.setSelectionActionDelegate(mSelectionActionDelegate);
         }
     }
 
     public GeckoSession getSession() {
         return mSession;
     }
@@ -320,41 +338,27 @@ public class GeckoView extends FrameLayo
         if (mSession == null) {
             setSession(new GeckoSession(), GeckoRuntime.getDefault(getContext()));
         }
 
         if (!mSession.isOpen()) {
             mSession.open(mRuntime);
         }
 
-        if (mSession.getTextInput().getView() == null) {
-            mSession.getTextInput().setView(this);
-        }
-
-        mSession.getAccessibility().setView(this);
-
         super.onAttachedToWindow();
     }
 
     @Override
     public void onDetachedFromWindow() {
         super.onDetachedFromWindow();
 
         if (mSession == null) {
             return;
         }
 
-        if (mSession.getAccessibility().getView() == this) {
-            mSession.getAccessibility().setView(null);
-        }
-
-        if (mSession.getTextInput().getView() == this) {
-            mSession.getTextInput().setView(null);
-        }
-
         // If we saved state earlier, we don't want to close the window.
         if (!mStateSaved && mSession.isOpen()) {
             mSession.close();
         }
     }
 
     @Override
     public boolean gatherTransparentRegion(final Region region) {