Skip to content

Commit

Permalink
Make sure session listeners are set when LoadRequest is called (#3265)
Browse files Browse the repository at this point in the history
  • Loading branch information
keianhzo committed Apr 28, 2020
1 parent 6ee1a8e commit fe05ee7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Expand Up @@ -1117,12 +1117,9 @@ public void setSession(@NonNull Session aSession, @OldSessionDisplayAction int a
} else {
onCurrentSessionChange(null, aSession.getGeckoSession());
}
setupListeners(mSession);
for (WindowListener listener: mListeners) {
listener.onSessionChanged(oldSession, aSession);
}


}
mCaptureOnPageStop = false;
hideLibraryPanels();
Expand Down Expand Up @@ -1152,6 +1149,7 @@ public void onStackSession(Session aSession) {
// e.g. tab opened via window.open()
aSession.updateLastUse();
Session current = mSession;
setupListeners(aSession);
setSession(aSession);
SessionStore.get().setActiveSession(aSession);
current.captureBackgroundBitmap(getWindowWidth(), getWindowHeight()).thenAccept(aVoid -> current.setActive(false));
Expand All @@ -1164,6 +1162,7 @@ public void onStackSession(Session aSession) {
public void onUnstackSession(Session aSession, Session aParent) {
if (mSession == aSession) {
aParent.setActive(true);
setupListeners(aParent);
setSession(aParent);
SessionStore.get().setActiveSession(aParent);
SessionStore.get().destroySession(aSession);
Expand Down
Expand Up @@ -1211,7 +1211,9 @@ public void onTabSelect(Session aTab) {
Session moveTo = targetWindow.getSession();
moveFrom.surfaceDestroyed();
moveTo.surfaceDestroyed();
windowToMove.setupListeners(moveTo);
windowToMove.setSession(moveTo, WindowWidget.SESSION_DO_NOT_RELEASE_DISPLAY);
targetWindow.setupListeners(moveFrom);
targetWindow.setSession(moveFrom, WindowWidget.SESSION_DO_NOT_RELEASE_DISPLAY);
SessionStore.get().setActiveSession(targetWindow.getSession());
windowToMove.setActiveWindow(false);
Expand All @@ -1220,6 +1222,7 @@ public void onTabSelect(Session aTab) {
} else {
setFirstPaint(targetWindow, aTab);
targetWindow.getSession().setActive(false);
targetWindow.setupListeners(aTab);
aTab.setActive(true);
targetWindow.setSession(aTab);
SessionStore.get().setActiveSession(aTab);
Expand All @@ -1234,6 +1237,7 @@ public void addTab(@NonNull WindowWidget targetWindow, @Nullable String aUri) {
Session session = SessionStore.get().createSuspendedSession(aUri, targetWindow.getSession().isPrivateMode());
setFirstPaint(targetWindow, session);
targetWindow.getSession().setActive(false);
targetWindow.setupListeners(session);
session.setActive(true);
targetWindow.setSession(session);
if (aUri == null || aUri.isEmpty()) {
Expand Down Expand Up @@ -1297,6 +1301,7 @@ public void onTabsClose(ArrayList<Session> aTabs) {
Session tab = available.get(0);
if (tab != null) {
setFirstPaint(window, tab);
window.setupListeners(tab);
tab.setActive(true);
window.setSession(tab);
}
Expand Down Expand Up @@ -1336,6 +1341,7 @@ public void onTabsReceived(@NonNull List<TabData> aTabs) {
if (i == 0 && !fullscreen) {
// Set the first received tab of the list the current one.
SessionStore.get().setActiveSession(session);
targetWindow.setupListeners(session);
targetWindow.getSession().setActive(false);
targetWindow.setSession(session);
}
Expand Down

0 comments on commit fe05ee7

Please sign in to comment.