Bug 1101817 - Part 1: Remove usages of WeakMap.prototype.clear from Gecko. r=yzen,mak,yoric,gijs,jlongster

This commit is contained in:
Till Schneidereit 2016-01-04 13:06:50 +01:00
parent 43adf056d6
commit bace318903
10 changed files with 16 additions and 15 deletions

View File

@ -77,7 +77,7 @@ this.EventManager.prototype = {
Logger.debug('EventManager.stop'); Logger.debug('EventManager.stop');
AccessibilityEventObserver.removeListener(this); AccessibilityEventObserver.removeListener(this);
try { try {
this._preDialogPosition.clear(); this._preDialogPosition = new WeakMap();
this.webProgress.removeProgressListener(this); this.webProgress.removeProgressListener(this);
this.removeEventListener('wheel', this, true); this.removeEventListener('wheel', this, true);
this.removeEventListener('scroll', this, true); this.removeEventListener('scroll', this, true);
@ -618,7 +618,7 @@ const AccessibilityEventObserver = {
} }
Services.obs.removeObserver(this, 'accessible-event'); Services.obs.removeObserver(this, 'accessible-event');
// Clean up all registered event managers. // Clean up all registered event managers.
this.eventManagers.clear(); this.eventManagers = new WeakMap();
this.listenerCount = 0; this.listenerCount = 0;
this.started = false; this.started = false;
}, },

View File

@ -65,7 +65,6 @@ var FullZoom = {
} }
// This should be nulled after initialization. // This should be nulled after initialization.
this._initialLocations.clear();
this._initialLocations = null; this._initialLocations = null;
}, },

View File

@ -1693,7 +1693,7 @@ CustomizeMode.prototype = {
let draggedWrapper = document.getElementById("wrapper-" + draggedItemId); let draggedWrapper = document.getElementById("wrapper-" + draggedItemId);
let originArea = this._getCustomizableParent(draggedWrapper); let originArea = this._getCustomizableParent(draggedWrapper);
if (this._dragSizeMap) { if (this._dragSizeMap) {
this._dragSizeMap.clear(); this._dragSizeMap = new WeakMap();
} }
// Do nothing if the target area or origin area are not customizable. // Do nothing if the target area or origin area are not customizable.
if (!targetArea || !originArea) { if (!targetArea || !originArea) {

View File

@ -410,7 +410,7 @@ var DragPositionManager = {
}, },
stop: function() { stop: function() {
gManagers.clear(); gManagers = new WeakMap();
}, },
getManagerForArea: function(aArea) { getManagerForArea: function(aArea) {

View File

@ -230,7 +230,7 @@ FrameTreeInternal.prototype = {
if (stateFlags & Ci.nsIWebProgressListener.STATE_START) { if (stateFlags & Ci.nsIWebProgressListener.STATE_START) {
// Clear the list of frames until we can recollect it. // Clear the list of frames until we can recollect it.
this._frames.clear(); this._frames = new WeakMap();
// Notify observers that the frame tree has been reset. // Notify observers that the frame tree has been reset.
this.notifyObservers("onFrameTreeReset"); this.notifyObservers("onFrameTreeReset");

View File

@ -1575,7 +1575,7 @@ var SessionStoreInternal = {
} }
this._clearRestoringWindows(); this._clearRestoringWindows();
this._saveableClosedWindowData.clear(); this._saveableClosedWindowData = new WeakSet();
}, },
/** /**
@ -4330,7 +4330,7 @@ var DirtyWindows = {
}, },
clear: function (window) { clear: function (window) {
this._data.clear(); this._data = new WeakMap();
} }
}; };

View File

@ -93,6 +93,9 @@ this.UITour = {
urlbarCapture: new WeakMap(), urlbarCapture: new WeakMap(),
appMenuOpenForAnnotation: new Set(), appMenuOpenForAnnotation: new Set(),
availableTargetsCache: new WeakMap(), availableTargetsCache: new WeakMap(),
clearAvailableTargetsCache() {
this.availableTargetsCache = new WeakMap();
},
_annotationPanelMutationObservers: new WeakMap(), _annotationPanelMutationObservers: new WeakMap(),
@ -285,7 +288,7 @@ this.UITour = {
"onAreaReset", "onAreaReset",
]; ];
CustomizableUI.addListener(listenerMethods.reduce((listener, method) => { CustomizableUI.addListener(listenerMethods.reduce((listener, method) => {
listener[method] = () => this.availableTargetsCache.clear(); listener[method] = () => this.clearAvailableTargetsCache();
return listener; return listener;
}, {})); }, {}));
}, },
@ -1582,7 +1585,7 @@ this.UITour = {
popup.addEventListener("popuphidden", this.onPanelHidden); popup.addEventListener("popuphidden", this.onPanelHidden);
popup.setAttribute("noautohide", true); popup.setAttribute("noautohide", true);
this.availableTargetsCache.clear(); this.clearAvailableTargetsCache();
if (popup.state == "open") { if (popup.state == "open") {
if (aOpenCallback) { if (aOpenCallback) {
@ -1611,7 +1614,7 @@ this.UITour = {
panel.setAttribute("noautohide", true); panel.setAttribute("noautohide", true);
if (panel.state != "open") { if (panel.state != "open") {
this.recreatePopup(panel); this.recreatePopup(panel);
this.availableTargetsCache.clear(); this.clearAvailableTargetsCache();
} }
// An event object is expected but we don't want to toggle the panel with a click if the panel // An event object is expected but we don't want to toggle the panel with a click if the panel
@ -1731,7 +1734,7 @@ this.UITour = {
onPanelHidden: function(aEvent) { onPanelHidden: function(aEvent) {
aEvent.target.removeAttribute("noautohide"); aEvent.target.removeAttribute("noautohide");
UITour.recreatePopup(aEvent.target); UITour.recreatePopup(aEvent.target);
UITour.availableTargetsCache.clear(); UITour.clearAvailableTargetsCache();
}, },
recreatePopup: function(aPanel) { recreatePopup: function(aPanel) {

View File

@ -114,7 +114,7 @@ var SourceUtils = {
clearCache: function() { clearCache: function() {
this._labelsCache.clear(); this._labelsCache.clear();
this._groupsCache.clear(); this._groupsCache.clear();
this._minifiedCache.clear(); this._minifiedCache = new WeakMap();
}, },
/** /**

View File

@ -1509,7 +1509,6 @@ EventTooltip.prototype = {
editor.destroy(); editor.destroy();
} }
this._tooltip.eventEditors.clear();
this._tooltip.eventEditors = null; this._tooltip.eventEditors = null;
} }

View File

@ -155,7 +155,7 @@ VariablesView.prototype = {
} }
this._store.length = 0; this._store.length = 0;
this._itemsByElement.clear(); this._itemsByElement = new WeakMap();
this._prevHierarchy = this._currHierarchy; this._prevHierarchy = this._currHierarchy;
this._currHierarchy = new Map(); // Don't clear, this is just simple swapping. this._currHierarchy = new Map(); // Don't clear, this is just simple swapping.