From bace318903d5028e2c88842ee5ad1378131a7bac Mon Sep 17 00:00:00 2001 From: Till Schneidereit Date: Mon, 4 Jan 2016 13:06:50 +0100 Subject: [PATCH] Bug 1101817 - Part 1: Remove usages of WeakMap.prototype.clear from Gecko. r=yzen,mak,yoric,gijs,jlongster --- accessible/jsat/EventManager.jsm | 4 ++-- browser/base/content/browser-fullZoom.js | 1 - browser/components/customizableui/CustomizeMode.jsm | 2 +- .../components/customizableui/DragPositionManager.jsm | 2 +- browser/components/sessionstore/FrameTree.jsm | 2 +- browser/components/sessionstore/SessionStore.jsm | 4 ++-- browser/components/uitour/UITour.jsm | 11 +++++++---- devtools/client/debugger/utils.js | 2 +- devtools/client/shared/widgets/Tooltip.js | 1 - devtools/client/shared/widgets/VariablesView.jsm | 2 +- 10 files changed, 16 insertions(+), 15 deletions(-) diff --git a/accessible/jsat/EventManager.jsm b/accessible/jsat/EventManager.jsm index c3766ce6cb3..18675747c71 100644 --- a/accessible/jsat/EventManager.jsm +++ b/accessible/jsat/EventManager.jsm @@ -77,7 +77,7 @@ this.EventManager.prototype = { Logger.debug('EventManager.stop'); AccessibilityEventObserver.removeListener(this); try { - this._preDialogPosition.clear(); + this._preDialogPosition = new WeakMap(); this.webProgress.removeProgressListener(this); this.removeEventListener('wheel', this, true); this.removeEventListener('scroll', this, true); @@ -618,7 +618,7 @@ const AccessibilityEventObserver = { } Services.obs.removeObserver(this, 'accessible-event'); // Clean up all registered event managers. - this.eventManagers.clear(); + this.eventManagers = new WeakMap(); this.listenerCount = 0; this.started = false; }, diff --git a/browser/base/content/browser-fullZoom.js b/browser/base/content/browser-fullZoom.js index edd172aeb8b..090fc555524 100644 --- a/browser/base/content/browser-fullZoom.js +++ b/browser/base/content/browser-fullZoom.js @@ -65,7 +65,6 @@ var FullZoom = { } // This should be nulled after initialization. - this._initialLocations.clear(); this._initialLocations = null; }, diff --git a/browser/components/customizableui/CustomizeMode.jsm b/browser/components/customizableui/CustomizeMode.jsm index b585b6e047a..db9a76770ae 100644 --- a/browser/components/customizableui/CustomizeMode.jsm +++ b/browser/components/customizableui/CustomizeMode.jsm @@ -1693,7 +1693,7 @@ CustomizeMode.prototype = { let draggedWrapper = document.getElementById("wrapper-" + draggedItemId); let originArea = this._getCustomizableParent(draggedWrapper); if (this._dragSizeMap) { - this._dragSizeMap.clear(); + this._dragSizeMap = new WeakMap(); } // Do nothing if the target area or origin area are not customizable. if (!targetArea || !originArea) { diff --git a/browser/components/customizableui/DragPositionManager.jsm b/browser/components/customizableui/DragPositionManager.jsm index b39eda8da82..146d6ecf462 100644 --- a/browser/components/customizableui/DragPositionManager.jsm +++ b/browser/components/customizableui/DragPositionManager.jsm @@ -410,7 +410,7 @@ var DragPositionManager = { }, stop: function() { - gManagers.clear(); + gManagers = new WeakMap(); }, getManagerForArea: function(aArea) { diff --git a/browser/components/sessionstore/FrameTree.jsm b/browser/components/sessionstore/FrameTree.jsm index 8d5796f1d98..e8ed12a8fff 100644 --- a/browser/components/sessionstore/FrameTree.jsm +++ b/browser/components/sessionstore/FrameTree.jsm @@ -230,7 +230,7 @@ FrameTreeInternal.prototype = { if (stateFlags & Ci.nsIWebProgressListener.STATE_START) { // 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. this.notifyObservers("onFrameTreeReset"); diff --git a/browser/components/sessionstore/SessionStore.jsm b/browser/components/sessionstore/SessionStore.jsm index 6c6356f0e33..d4286de76fe 100644 --- a/browser/components/sessionstore/SessionStore.jsm +++ b/browser/components/sessionstore/SessionStore.jsm @@ -1575,7 +1575,7 @@ var SessionStoreInternal = { } this._clearRestoringWindows(); - this._saveableClosedWindowData.clear(); + this._saveableClosedWindowData = new WeakSet(); }, /** @@ -4330,7 +4330,7 @@ var DirtyWindows = { }, clear: function (window) { - this._data.clear(); + this._data = new WeakMap(); } }; diff --git a/browser/components/uitour/UITour.jsm b/browser/components/uitour/UITour.jsm index b797a23eac6..728e9be8fa8 100644 --- a/browser/components/uitour/UITour.jsm +++ b/browser/components/uitour/UITour.jsm @@ -93,6 +93,9 @@ this.UITour = { urlbarCapture: new WeakMap(), appMenuOpenForAnnotation: new Set(), availableTargetsCache: new WeakMap(), + clearAvailableTargetsCache() { + this.availableTargetsCache = new WeakMap(); + }, _annotationPanelMutationObservers: new WeakMap(), @@ -285,7 +288,7 @@ this.UITour = { "onAreaReset", ]; CustomizableUI.addListener(listenerMethods.reduce((listener, method) => { - listener[method] = () => this.availableTargetsCache.clear(); + listener[method] = () => this.clearAvailableTargetsCache(); return listener; }, {})); }, @@ -1582,7 +1585,7 @@ this.UITour = { popup.addEventListener("popuphidden", this.onPanelHidden); popup.setAttribute("noautohide", true); - this.availableTargetsCache.clear(); + this.clearAvailableTargetsCache(); if (popup.state == "open") { if (aOpenCallback) { @@ -1611,7 +1614,7 @@ this.UITour = { panel.setAttribute("noautohide", true); if (panel.state != "open") { 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 @@ -1731,7 +1734,7 @@ this.UITour = { onPanelHidden: function(aEvent) { aEvent.target.removeAttribute("noautohide"); UITour.recreatePopup(aEvent.target); - UITour.availableTargetsCache.clear(); + UITour.clearAvailableTargetsCache(); }, recreatePopup: function(aPanel) { diff --git a/devtools/client/debugger/utils.js b/devtools/client/debugger/utils.js index fbf3c30d250..617c555806c 100644 --- a/devtools/client/debugger/utils.js +++ b/devtools/client/debugger/utils.js @@ -114,7 +114,7 @@ var SourceUtils = { clearCache: function() { this._labelsCache.clear(); this._groupsCache.clear(); - this._minifiedCache.clear(); + this._minifiedCache = new WeakMap(); }, /** diff --git a/devtools/client/shared/widgets/Tooltip.js b/devtools/client/shared/widgets/Tooltip.js index db2ea67f488..f2355ea61ed 100644 --- a/devtools/client/shared/widgets/Tooltip.js +++ b/devtools/client/shared/widgets/Tooltip.js @@ -1509,7 +1509,6 @@ EventTooltip.prototype = { editor.destroy(); } - this._tooltip.eventEditors.clear(); this._tooltip.eventEditors = null; } diff --git a/devtools/client/shared/widgets/VariablesView.jsm b/devtools/client/shared/widgets/VariablesView.jsm index 42e684b6684..1dfd7a359ab 100644 --- a/devtools/client/shared/widgets/VariablesView.jsm +++ b/devtools/client/shared/widgets/VariablesView.jsm @@ -155,7 +155,7 @@ VariablesView.prototype = { } this._store.length = 0; - this._itemsByElement.clear(); + this._itemsByElement = new WeakMap(); this._prevHierarchy = this._currHierarchy; this._currHierarchy = new Map(); // Don't clear, this is just simple swapping.