Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Prevent listeners from getting added more than once #3350

Merged
merged 1 commit into from
May 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public void setHistoryDelegate(GeckoSession.HistoryDelegate aDelegate) {
}

public void addNavigationListener(GeckoSession.NavigationDelegate aListener) {
mNavigationListeners.add(aListener);
mNavigationListeners.addIfAbsent(aListener);
dumpState(aListener);
}

Expand All @@ -295,7 +295,7 @@ public void removeNavigationListener(GeckoSession.NavigationDelegate aListener)
}

public void addProgressListener(GeckoSession.ProgressDelegate aListener) {
mProgressListeners.add(aListener);
mProgressListeners.addIfAbsent(aListener);
dumpState(aListener);
}

Expand All @@ -304,7 +304,7 @@ public void removeProgressListener(GeckoSession.ProgressDelegate aListener) {
}

public void addContentListener(GeckoSession.ContentDelegate aListener) {
mContentListeners.add(aListener);
mContentListeners.addIfAbsent(aListener);
dumpState(aListener);
}

Expand All @@ -313,23 +313,23 @@ public void removeContentListener(GeckoSession.ContentDelegate aListener) {
}

public void addSessionChangeListener(SessionChangeListener aListener) {
mSessionChangeListeners.add(aListener);
mSessionChangeListeners.addIfAbsent(aListener);
}

public void removeSessionChangeListener(SessionChangeListener aListener) {
mSessionChangeListeners.remove(aListener);
}

public void addTextInputListener(GeckoSession.TextInputDelegate aListener) {
mTextInputListeners.add(aListener);
mTextInputListeners.addIfAbsent(aListener);
}

public void removeTextInputListener(GeckoSession.TextInputDelegate aListener) {
mTextInputListeners.remove(aListener);
}

public void addVideoAvailabilityListener(VideoAvailabilityListener aListener) {
mVideoAvailabilityListeners.add(aListener);
mVideoAvailabilityListeners.addIfAbsent(aListener);
dumpState(aListener);
}

Expand All @@ -338,23 +338,23 @@ public void removeVideoAvailabilityListener(VideoAvailabilityListener aListener)
}

public void addSelectionActionListener(GeckoSession.SelectionActionDelegate aListener) {
mSelectionActionListeners.add(aListener);
mSelectionActionListeners.addIfAbsent(aListener);
}

public void removeSelectionActionListener(GeckoSession.ContentDelegate aListener) {
mSelectionActionListeners.remove(aListener);
}

public void addBitmapChangedListener(BitmapChangedListener aListener) {
mBitmapChangedListeners.add(aListener);
mBitmapChangedListeners.addIfAbsent(aListener);
}

public void removeBitmapChangedListener(BitmapChangedListener aListener) {
mBitmapChangedListeners.remove(aListener);
}

public void addWebXRStateChangedListener(WebXRStateChangedListener aListener) {
mWebXRStateListeners.add(aListener);
mWebXRStateListeners.addIfAbsent(aListener);
dumpState(aListener);
}

Expand All @@ -363,7 +363,7 @@ public void removeWebXRStateChangedListener(WebXRStateChangedListener aListener)
}

public void addPopUpStateChangedListener(PopUpStateChangedListener aListener) {
mPopUpStateStateListeners.add(aListener);
mPopUpStateStateListeners.addIfAbsent(aListener);
dumpState(aListener);
}

Expand All @@ -372,7 +372,7 @@ public void removePopUpStateChangedListener(PopUpStateChangedListener aListener)
}

public void addDrmStateChangedListener(DrmStateChangedListener aListener) {
mDrmStateStateListeners.add(aListener);
mDrmStateStateListeners.addIfAbsent(aListener);
dumpState(aListener);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1158,12 +1158,17 @@ public void onCurrentSessionChange(GeckoSession aOldSession, GeckoSession aSessi

@Override
public void onStackSession(Session aSession) {
if (aSession == mSession) {
Log.e(LOGTAG, "Attempting to stack same session.");
return;
}
// e.g. tab opened via window.open()
aSession.updateLastUse();
Session current = mSession;
setupListeners(aSession);
setSession(aSession);
SessionStore.get().setActiveSession(aSession);
aSession.setActive(true);
current.captureBackgroundBitmap(getWindowWidth(), getWindowHeight()).thenAccept(aVoid -> current.setActive(false));
mWidgetManager.getWindows().showTabAddedNotification();

Expand Down