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
--- 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) {