Web Inspector: use weak collections for holding event listeners
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 Nov 2020 11:30:05 +0000 (11:30 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 Nov 2020 11:30:05 +0000 (11:30 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196956

Reviewed by Brian Burg.

Source/WebInspectorUI:

Replace the `ListMultimap`/`LinkedList` with a `Multimap` for holding listener data:
```
    Map<String eventType, Set<{Function listener, WeakRef thisObject}>> _listeners;
```
This preserves addition order while also not strongly holding any `thisObject` so they can
be GCed (and remove the `listener` along with it).

* UserInterface/Base/Object.js:
(WI.Object.addEventListener):
(WI.Object.singleFireEventListener):
(WI.Object.awaitEvent):
(WI.Object.removeEventListener):
(WI.Object.prototype.singleFireEventListener):
(WI.Object.prototype.removeEventListener):
(WI.Object.prototype.dispatchEventToListeners.dispatch):
(WI.Object.hasEventListeners):
(WI.Object.activelyListeningObjectsWithPrototype): Added.
(WI.Object.prototype.activelyListeningObjectsWithPrototype): Added.

* UserInterface/Base/SearchUtilities.js:
(WI.SearchUtilities.createSettings):
(WI.SearchUtilities.createSettingsButton):
* UserInterface/Base/Main.js:
(WI.loaded):
(WI.contentLoaded):
* UserInterface/Models/Resource.js:
(WI.Resource.prototype.requestContent):
* UserInterface/Controllers/RuntimeManager.js:
(WI.RuntimeManager):
* UserInterface/Views/AuditTestCaseContentView.js:
(WI.AuditTestCaseContentView.prototype.showRunningPlaceholder):
* UserInterface/Views/AuditTestContentView.js:
(WI.AuditTestContentView.prototype.showNoResultPlaceholder):
* UserInterface/Views/AuditTestGroupContentView.js:
(WI.AuditTestGroupContentView.prototype.showRunningPlaceholder):
* UserInterface/Views/CodeMirrorEditor.js:
(WI.CodeMirrorEditor.create):
* UserInterface/Debug/Bootstrap.js:
(WI.runBootstrapOperations):
* UserInterface/Views/ConsoleDrawer.js:
(WI.ConsoleDrawer):
* UserInterface/Views/ConsoleMessageView.js:
(WI.ConsoleMessageView.prototype.clearSessionState):
(WI.ConsoleMessageView.prototype._appendSavedResultIndex):
(WI.ConsoleMessageView.prototype._rootPropertyPathForObject):
* UserInterface/Views/ContentBrowser.js:
(WI.ContentBrowser):
(WI.ContentBrowser.prototype.async handleFindNextShortcut):
(WI.ContentBrowser.prototype.async handleFindPreviousShortcut):
* UserInterface/Views/HeapSnapshotContentView.js:
(WI.HeapSnapshotContentView):
* UserInterface/Views/LogContentView.js:
(WI.LogContentView):
* UserInterface/Views/MediaTimelineOverviewGraph.js:
(WI.MediaTimelineOverviewGraph.prototype._processRecord):
* UserInterface/Views/NetworkDetailView.js:
(WI.NetworkDetailView.prototype.initialLayout):
* UserInterface/Views/ObjectTreeView.js:
(WI.ObjectTreeView.prototype.addShowMoreIfNeeded):
* UserInterface/Views/SearchSidebarPanel.js:
(WI.SearchSidebarPanel):
(WI.SearchSidebarPanel.prototype.closed):
(WI.SearchSidebarPanel.prototype.performSearch):
* UserInterface/Views/SettingEditor.js:
(WI.SettingEditor.createForSetting):
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createGeneralSettingsView):
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
(WI.SettingsTabContentView.prototype._createExperimentalSettingsView.listenForChange):
(WI.SettingsTabContentView.prototype._createExperimentalSettingsView):
(WI.SettingsTabContentView.prototype._createDebugSettingsView):
* UserInterface/Views/ShaderProgramContentView.js:
(WI.ShaderProgramContentView):
* UserInterface/Views/SourcesNavigationSidebarPanel.js:
(WI.SourcesNavigationSidebarPanel):
(WI.SourcesNavigationSidebarPanel.prototype.closed):
(WI.SourcesNavigationSidebarPanel.prototype.createContentTreeOutline):
* UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js:
(WI.SpreadsheetCSSStyleDeclarationSection.prototype.initialLayout):
* UserInterface/Views/SpreadsheetStyleProperty.js:
(WI.SpreadsheetStyleProperty.prototype._createInlineSwatch):
* UserInterface/Views/ThreadTreeElement.js:
(WI.ThreadTreeElement.prototype._updateStatus):
* UserInterface/Views/TimelineTreeElement.js:
(WI.TimelineTreeElement.prototype._showCloseButton):
Update callers of `WI.Object.prototype.addEventListener` to always pass a `thisObject`. This
is especially important for inlined `listener`, as there needs to be a strong reference to
some "longer lived" `thisObject` (which is held by a `WeakRef`) in order for the `listener`
to not be GCed.

* UserInterface/Models/DOMNodeStyles.js:
(WI.DOMNodeStyles):
(WI.DOMNodeStyles.prototype._parseStyleDeclarationPayload):
(WI.DOMNodeStyles.prototype._parseRulePayload):
(WI.DOMNodeStyles.prototype._handleCSSStyleSheetContentDidChange): Added.
(WI.DOMNodeStyles.prototype._styleSheetContentDidChange): Deleted.
* UserInterface/Views/TimelineRecordingProgressView.js:
(WI.TimelineRecordingProgressView):
(WI.TimelineRecordingProgressView.prototype.set visible):
(WI.TimelineRecordingProgressView.prototype._updateState):
Use a global event listener instead of adding event listeners to specific objects as it's
already likely that all the objects would be listened to anyways.

* UserInterface/Models/DOMTree.js:
(WI.DOMTree.prototype.disconnect):
* UserInterface/Controllers/ApplicationCacheManager.js:
(WI.ApplicationCacheManager.prototype.disable):
* UserInterface/Controllers/CallFrameTreeController.js:
(WI.CallFrameTreeController.prototype.disconnect):
* UserInterface/Controllers/DOMStorageManager.js:
(WI.DOMStorageManager.prototype.disable):
* UserInterface/Controllers/DatabaseManager.js:
(WI.DatabaseManager.prototype.disable):
* UserInterface/Controllers/IndexedDBManager.js:
(WI.IndexedDBManager.prototype.disable):
* UserInterface/Controllers/TimelineManager.js:
(WI.TimelineManager.prototype.capturingStopped):
* UserInterface/Views/ApplicationCacheDetailsSidebarPanel.js:
(WI.ApplicationCacheDetailsSidebarPanel.prototype.closed):
* UserInterface/Views/ApplicationCacheFrameContentView.js:
(WI.ApplicationCacheFrameContentView.prototype.closed):
* UserInterface/Views/AuditNavigationSidebarPanel.js:
(WI.AuditNavigationSidebarPanel.prototype.closed):
* UserInterface/Views/AuditTreeElement.js:
(WI.AuditTreeElement.prototype.ondetach):
* UserInterface/Views/CPUTimelineView.js:
(WI.CPUTimelineView.prototype.closed):
* UserInterface/Views/CanvasContentView.js:
(WI.CanvasContentView.prototype.detached):
* UserInterface/Views/CanvasOverviewContentView.js:
(WI.CanvasOverviewContentView.prototype.detached):
* UserInterface/Views/CanvasSidebarPanel.js:
(WI.CanvasSidebarPanel.prototype.set canvas):
(WI.CanvasSidebarPanel.prototype.set recording):
(WI.CanvasSidebarPanel.prototype.hidden):
* UserInterface/Views/ClusterContentView.js:
(WI.ClusterContentView.prototype.closed):
* UserInterface/Views/CollectionContentView.js:
(WI.CollectionContentView.prototype.removeContentViewForItem):
(WI.CollectionContentView.prototype.detached):
* UserInterface/Views/ContentBrowserTabContentView.js:
(WI.ContentBrowserTabContentView.prototype.hidden):
(WI.ContentBrowserTabContentView.prototype.closed):
* UserInterface/Views/DOMNodeDetailsSidebarPanel.js:
(WI.DOMNodeDetailsSidebarPanel.prototype.closed):
* UserInterface/Views/DOMTreeContentView.js:
(WI.DOMTreeContentView.prototype.closed):
* UserInterface/Views/DOMTreeUpdater.js:
(WI.DOMTreeUpdater.prototype.close):
* UserInterface/Views/ElementsTabContentView.js:
(WI.ElementsTabContentView.prototype.closed):
* UserInterface/Views/FrameDOMTreeContentView.js:
(WI.FrameDOMTreeContentView.prototype.closed):
* UserInterface/Views/GeneralStyleDetailsSidebarPanel.js:
(WI.GeneralStyleDetailsSidebarPanel.prototype.removeEventListeners):
* UserInterface/Views/HeapAllocationsTimelineView.js:
(WI.HeapAllocationsTimelineView):
(WI.HeapAllocationsTimelineView.prototype.closed):
* UserInterface/Views/ImageResourceContentView.js:
(WI.ImageResourceContentView.prototype.closed): Deleted.
* UserInterface/Views/InlineSwatch.js:
(WI.InlineSwatch.prototype.didDismissPopover):
* UserInterface/Views/LayoutTimelineView.js:
(WI.LayoutTimelineView.prototype.closed):
* UserInterface/Views/LocalResourceOverrideWarningView.js:
(WI.LocalResourceOverrideWarningView.prototype.detached):
* UserInterface/Views/MemoryTimelineView.js:
(WI.MemoryTimelineView.prototype.closed):
* UserInterface/Views/MultipleScopeBarItem.js:
(WI.MultipleScopeBarItem.prototype.set scopeBarItems):
* UserInterface/Views/NavigationSidebarPanel.js:
(WI.NavigationSidebarPanel.prototype.closed):
* UserInterface/Views/NetworkTimelineView.js:
(WI.NetworkTimelineView.prototype.closed):
* UserInterface/Views/OverviewTimelineView.js:
(WI.OverviewTimelineView.prototype.closed):
* UserInterface/Views/ProbeDetailsSidebarPanel.js:
(WI.ProbeDetailsSidebarPanel.prototype.closed):
* UserInterface/Views/QuickConsole.js:
(WI.QuickConsole.prototype.closed):
* UserInterface/Views/RecordingContentView.js:
(WI.RecordingContentView.prototype._handleRecordingProcessedAction):
* UserInterface/Views/RenderingFrameTimelineView.js:
(WI.RenderingFrameTimelineView.prototype.closed):
* UserInterface/Views/ResourceCollectionContentView.js:
(WI.ResourceCollectionContentView.prototype.detached):
(WI.ResourceCollectionContentView.prototype.contentViewRemoved):
* UserInterface/Views/ResourceContentView.js:
(WI.ResourceContentView.prototype.closed):
* UserInterface/Views/ResourceDetailsSidebarPanel.js:
(WI.ResourceDetailsSidebarPanel.prototype.set resource):
(WI.ResourceDetailsSidebarPanel.prototype._applyResourceEventListeners):
(WI.ResourceDetailsSidebarPanel.prototype._handleResourceInitiatedResourcesDidChange): Added.
* UserInterface/Views/ResourceHeadersContentView.js:
(WI.ResourceHeadersContentView.prototype.closed):
* UserInterface/Views/ResourceSecurityContentView.js:
(WI.ResourceSecurityContentView.prototype.closed):
* UserInterface/Views/ResourceSizesContentView.js:
(WI.ResourceSizesContentView.prototype.closed):
* UserInterface/Views/ResourceTimingContentView.js:
(WI.ResourceTimingContentView.prototype.closed):
* UserInterface/Views/ScopeChainDetailsSidebarPanel.js:
(WI.ScopeChainDetailsSidebarPanel.prototype._generateCallFramesSection):
(WI.ScopeChainDetailsSidebarPanel.prototype._generateWatchExpressionsSection):
(WI.ScopeChainDetailsSidebarPanel.prototype.closed):
* UserInterface/Views/ScriptContentView.js:
(WI.ScriptContentView.prototype.closed):
* UserInterface/Views/ScriptDetailsTimelineView.js:
(WI.ScriptDetailsTimelineView.prototype.closed):
* UserInterface/Views/ScriptProfileTimelineView.js:
(WI.ScriptProfileTimelineView.prototype.closed):
* UserInterface/Views/SourceCodeTextEditor.js:
(WI.SourceCodeTextEditor.prototype.close):
(WI.SourceCodeTextEditor.prototype._showPopover):
(WI.SourceCodeTextEditor.prototype._showPopoverForObject):
(WI.SourceCodeTextEditor.prototype._dismissPopover):
(WI.SourceCodeTextEditor.prototype._trackPopoverEvents): Deleted.
* UserInterface/Views/StorageSidebarPanel.js:
(WI.StorageSidebarPanel.prototype.closed):
* UserInterface/Views/TextResourceContentView.js:
(WI.TextResourceContentView.prototype.closed):
* UserInterface/Views/TimelineOverview.js:
(WI.TimelineOverview.prototype.closed):
* UserInterface/Views/TimelineRecordingContentView.js:
(WI.TimelineRecordingContentView):
(WI.TimelineRecordingContentView.prototype.closed):
(WI.TimelineRecordingContentView.prototype._recordingUnloaded):
* UserInterface/Views/TimelineRuler.js:
(WI.TimelineRuler.prototype.clearMarkers):
* UserInterface/Views/TimelineTabContentView.js:
(WI.TimelineTabContentView.prototype.closed):
* UserInterface/Views/TreeOutlineGroup.js:
(WI.TreeOutlineGroup.prototype.itemRemoved):
Replace the `removeEventListener(null, null, this)` pattern by instead having callers remove
each event listener explicitly. This is a safer design as it can avoid situations where
parent classes inadvertently remove event listeners added by subclasses. For objects with
lots of event listeners this is also more efficient as it doesn't require as much iteration.

* UserInterface/Views/RecordingActionTreeElement.js:
(WI.RecordingActionTreeElement):
(WI.RecordingActionTreeElement.prototype._handleValidityChanged):
Use `singleFireEventListener` where possible.

* UserInterface/Controllers/DebuggerManager.js:
(WI.DebuggerManager.prototype.pause):
(WI.DebuggerManager.prototype.resume):
(WI.DebuggerManager.prototype.stepNext):
(WI.DebuggerManager.prototype.stepOver):
(WI.DebuggerManager.prototype.stepInto):
(WI.DebuggerManager.prototype.stepOut):
* UserInterface/Views/BreakpointTreeElement.js:
(WI.BreakpointTreeElement.prototype.onattach):
(WI.BreakpointTreeElement.prototype.ondetach):
(WI.BreakpointTreeElement.prototype.get listenerSet): Deleted.
* UserInterface/Views/DataGrid.js:
(WI.DataGrid.prototype.insertColumn):
(WI.DataGrid.prototype.removeColumn):
* UserInterface/Views/JavaScriptBreakpointTreeElement.js:
(WI.JavaScriptBreakpointTreeElement):
(WI.JavaScriptBreakpointTreeElement.prototype.onattach):
(WI.JavaScriptBreakpointTreeElement.prototype.ondetach):
* UserInterface/Views/ProbeSetDataGrid.js:
(WI.ProbeSetDataGrid):
(WI.ProbeSetDataGrid.prototype.closed):
(WI.ProbeSetDataGrid.prototype._setupData):
(WI.ProbeSetDataGrid.prototype._teardownData):
* UserInterface/Views/ProbeSetDetailsSection.js:
(WI.ProbeSetDetailsSection):
(WI.ProbeSetDetailsSection.prototype.closed):
Remove the legacy `WI.EventListener` and `WI.EventListenerSet` as they basically do the same
thing as `WI.Object` with extra steps.

* UserInterface/Models/WebSocketResource.js:
* UserInterface/Proxies/HeapSnapshotWorkerProxy.js:
* UserInterface/Controllers/TargetManager.js:
* UserInterface/Views/DataGridNode.js:
(WI.DataGridNode.prototype.collapse):
(WI.DataGridNode.prototype.expand):
(WI.DataGridNode.prototype.reveal):
(WI.DataGridNode.prototype.traverseNextNode):
(WI.DataGridNode.prototype.traversePreviousNode):
* UserInterface/Views/HeapSnapshotClassDataGridNode.js:
(WI.HeapSnapshotClassDataGridNode):
(WI.HeapSnapshotClassDataGridNode.prototype._populate):
* UserInterface/Views/HeapSnapshotInstanceDataGridNode.js:
(WI.HeapSnapshotInstanceDataGridNode):
* UserInterface/Views/ProfileDataGridNode.js:
(WI.ProfileDataGridNode):
(WI.ProfileDataGridNode.prototype._populate):
* UserInterface/Views/ProfileNodeDataGridNode.js:
(WI.ProfileNodeDataGridNode):
(WI.ProfileNodeDataGridNode.prototype._populate):
* UserInterface/Views/TreeOutline.js:
* UserInterface/Workers/HeapSnapshot/HeapSnapshotWorker.js:
(HeapSnapshotWorker.prototype.createSnapshot):
Ensure that all event names are strings defined on the class `Event` object.

* UserInterface/Views/Sidebar.js:
(WI.Sidebar.prototype.set selectedSidebarPanel):
Drive-by: fix an issue where `hidden` is called twice, once from the selected sidebar panel
being changed and then again when that sidebar panel is removed.

* .eslintrc:
* UserInterface/Base/EventListener.js: Removed.
* UserInterface/Base/EventListenerSet.js: Removed.
* UserInterface/Base/LinkedList.js: Removed.
* UserInterface/Base/ListMultimap.js: Removed.
* UserInterface/Main.html:
* UserInterface/Test.html:
* UserInterface/TestStub.html:
* Tools/SourceMaps/index.html:

LayoutTests:

* http/tests/inspector/dom/disconnect-dom-tree-after-main-frame-navigation.html:
Use newly named `WI.Object.prototype.activelyListeningObjectsWithPrototype` instead of the
previously named `WI.Object.prototype.retainedObjectsWithPrototype` since `WI.Object`
doesn't retain any `thisObject` anymore.

* inspector/debugger/setPauseOnMicrotasks.html:
Only remove the event listener if it didn't fire.

* inspector/dom/setEventListenerDisabled.html:
No need to remove the event listener as calling `reject` after a `Promise` is already
settled won't have any effect.

* inspector/unit-tests/event-listener.html: Removed.
* inspector/unit-tests/event-listener-expected.txt: Removed.
* inspector/unit-tests/event-listener-set.html: Removed.
* inspector/unit-tests/event-listener-set-expected.txt: Removed.
Remove the legacy `WI.EventListener` and `WI.EventListenerSet` as they basically do the same
thing as `WI.Object` with extra steps.

* inspector/unit-tests/linked-list.html: Removed.
* inspector/unit-tests/linked-list-expected.txt: Removed.
* inspector/unit-tests/list-multimap.html: Removed.
* inspector/unit-tests/list-multimap-expected.txt: Removed.
Remove `LinkedList` and `ListMultimap` as they're no longer used.

* platform/gtk/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@269359 268f45cc-cd09-0410-ab3c-d52691b4dbfc

127 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/inspector/dom/disconnect-dom-tree-after-main-frame-navigation.html
LayoutTests/inspector/debugger/setPauseOnMicrotasks.html
LayoutTests/inspector/dom/setEventListenerDisabled.html
LayoutTests/inspector/unit-tests/event-listener-expected.txt [deleted file]
LayoutTests/inspector/unit-tests/event-listener-set-expected.txt [deleted file]
LayoutTests/inspector/unit-tests/event-listener-set.html [deleted file]
LayoutTests/inspector/unit-tests/event-listener.html [deleted file]
LayoutTests/inspector/unit-tests/linked-list-expected.txt [deleted file]
LayoutTests/inspector/unit-tests/linked-list.html [deleted file]
LayoutTests/inspector/unit-tests/list-multimap-expected.txt [deleted file]
LayoutTests/inspector/unit-tests/list-multimap.html [deleted file]
LayoutTests/platform/gtk/TestExpectations
Source/WebInspectorUI/.eslintrc
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/Tools/SourceMaps/index.html
Source/WebInspectorUI/UserInterface/Base/EventListener.js [deleted file]
Source/WebInspectorUI/UserInterface/Base/EventListenerSet.js [deleted file]
Source/WebInspectorUI/UserInterface/Base/LinkedList.js [deleted file]
Source/WebInspectorUI/UserInterface/Base/ListMultimap.js [deleted file]
Source/WebInspectorUI/UserInterface/Base/Main.js
Source/WebInspectorUI/UserInterface/Base/Object.js
Source/WebInspectorUI/UserInterface/Base/SearchUtilities.js
Source/WebInspectorUI/UserInterface/Controllers/ApplicationCacheManager.js
Source/WebInspectorUI/UserInterface/Controllers/CallFrameTreeController.js
Source/WebInspectorUI/UserInterface/Controllers/DOMStorageManager.js
Source/WebInspectorUI/UserInterface/Controllers/DatabaseManager.js
Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js
Source/WebInspectorUI/UserInterface/Controllers/IndexedDBManager.js
Source/WebInspectorUI/UserInterface/Controllers/RuntimeManager.js
Source/WebInspectorUI/UserInterface/Controllers/TargetManager.js
Source/WebInspectorUI/UserInterface/Controllers/TimelineManager.js
Source/WebInspectorUI/UserInterface/Debug/Bootstrap.js
Source/WebInspectorUI/UserInterface/Main.html
Source/WebInspectorUI/UserInterface/Models/DOMNodeStyles.js
Source/WebInspectorUI/UserInterface/Models/DOMTree.js
Source/WebInspectorUI/UserInterface/Models/Resource.js
Source/WebInspectorUI/UserInterface/Models/WebSocketResource.js
Source/WebInspectorUI/UserInterface/Proxies/HeapSnapshotWorkerProxy.js
Source/WebInspectorUI/UserInterface/Test.html
Source/WebInspectorUI/UserInterface/TestStub.html
Source/WebInspectorUI/UserInterface/Views/ApplicationCacheDetailsSidebarPanel.js
Source/WebInspectorUI/UserInterface/Views/ApplicationCacheFrameContentView.js
Source/WebInspectorUI/UserInterface/Views/AuditNavigationSidebarPanel.js
Source/WebInspectorUI/UserInterface/Views/AuditTestCaseContentView.js
Source/WebInspectorUI/UserInterface/Views/AuditTestContentView.js
Source/WebInspectorUI/UserInterface/Views/AuditTestGroupContentView.js
Source/WebInspectorUI/UserInterface/Views/AuditTreeElement.js
Source/WebInspectorUI/UserInterface/Views/BreakpointTreeElement.js
Source/WebInspectorUI/UserInterface/Views/CPUTimelineView.js
Source/WebInspectorUI/UserInterface/Views/CanvasContentView.js
Source/WebInspectorUI/UserInterface/Views/CanvasOverviewContentView.js
Source/WebInspectorUI/UserInterface/Views/CanvasSidebarPanel.js
Source/WebInspectorUI/UserInterface/Views/ClusterContentView.js
Source/WebInspectorUI/UserInterface/Views/CodeMirrorEditor.js
Source/WebInspectorUI/UserInterface/Views/CollectionContentView.js
Source/WebInspectorUI/UserInterface/Views/ConsoleDrawer.js
Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js
Source/WebInspectorUI/UserInterface/Views/ContentBrowser.js
Source/WebInspectorUI/UserInterface/Views/ContentBrowserTabContentView.js
Source/WebInspectorUI/UserInterface/Views/DOMNodeDetailsSidebarPanel.js
Source/WebInspectorUI/UserInterface/Views/DOMTreeContentView.js
Source/WebInspectorUI/UserInterface/Views/DOMTreeUpdater.js
Source/WebInspectorUI/UserInterface/Views/DataGrid.js
Source/WebInspectorUI/UserInterface/Views/DataGridNode.js
Source/WebInspectorUI/UserInterface/Views/ElementsTabContentView.js
Source/WebInspectorUI/UserInterface/Views/FrameDOMTreeContentView.js
Source/WebInspectorUI/UserInterface/Views/GeneralStyleDetailsSidebarPanel.js
Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineView.js
Source/WebInspectorUI/UserInterface/Views/HeapSnapshotClassDataGridNode.js
Source/WebInspectorUI/UserInterface/Views/HeapSnapshotContentView.js
Source/WebInspectorUI/UserInterface/Views/HeapSnapshotInstanceDataGridNode.js
Source/WebInspectorUI/UserInterface/Views/ImageResourceContentView.js
Source/WebInspectorUI/UserInterface/Views/InlineSwatch.js
Source/WebInspectorUI/UserInterface/Views/JavaScriptBreakpointTreeElement.js
Source/WebInspectorUI/UserInterface/Views/LayoutTimelineView.js
Source/WebInspectorUI/UserInterface/Views/LocalResourceOverrideWarningView.js
Source/WebInspectorUI/UserInterface/Views/LogContentView.js
Source/WebInspectorUI/UserInterface/Views/MediaTimelineOverviewGraph.js
Source/WebInspectorUI/UserInterface/Views/MemoryTimelineView.js
Source/WebInspectorUI/UserInterface/Views/MultipleScopeBarItem.js
Source/WebInspectorUI/UserInterface/Views/NavigationSidebarPanel.js
Source/WebInspectorUI/UserInterface/Views/NetworkDetailView.js
Source/WebInspectorUI/UserInterface/Views/NetworkTableContentView.js
Source/WebInspectorUI/UserInterface/Views/NetworkTimelineView.js
Source/WebInspectorUI/UserInterface/Views/ObjectTreeView.js
Source/WebInspectorUI/UserInterface/Views/OverviewTimelineView.js
Source/WebInspectorUI/UserInterface/Views/ProbeDetailsSidebarPanel.js
Source/WebInspectorUI/UserInterface/Views/ProbeSetDataGrid.js
Source/WebInspectorUI/UserInterface/Views/ProbeSetDetailsSection.js
Source/WebInspectorUI/UserInterface/Views/ProfileDataGridNode.js
Source/WebInspectorUI/UserInterface/Views/ProfileNodeDataGridNode.js
Source/WebInspectorUI/UserInterface/Views/QuickConsole.js
Source/WebInspectorUI/UserInterface/Views/RecordingActionTreeElement.js
Source/WebInspectorUI/UserInterface/Views/RecordingContentView.js
Source/WebInspectorUI/UserInterface/Views/RenderingFrameTimelineView.js
Source/WebInspectorUI/UserInterface/Views/ResourceCollectionContentView.js
Source/WebInspectorUI/UserInterface/Views/ResourceContentView.js
Source/WebInspectorUI/UserInterface/Views/ResourceDetailsSidebarPanel.js
Source/WebInspectorUI/UserInterface/Views/ResourceHeadersContentView.js
Source/WebInspectorUI/UserInterface/Views/ResourceSecurityContentView.js
Source/WebInspectorUI/UserInterface/Views/ResourceSizesContentView.js
Source/WebInspectorUI/UserInterface/Views/ResourceTimingContentView.js
Source/WebInspectorUI/UserInterface/Views/ScopeChainDetailsSidebarPanel.js
Source/WebInspectorUI/UserInterface/Views/ScriptContentView.js
Source/WebInspectorUI/UserInterface/Views/ScriptDetailsTimelineView.js
Source/WebInspectorUI/UserInterface/Views/ScriptProfileTimelineView.js
Source/WebInspectorUI/UserInterface/Views/SearchSidebarPanel.js
Source/WebInspectorUI/UserInterface/Views/SettingEditor.js
Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js
Source/WebInspectorUI/UserInterface/Views/ShaderProgramContentView.js
Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js
Source/WebInspectorUI/UserInterface/Views/SourcesNavigationSidebarPanel.js
Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js
Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js
Source/WebInspectorUI/UserInterface/Views/StorageSidebarPanel.js
Source/WebInspectorUI/UserInterface/Views/TextResourceContentView.js
Source/WebInspectorUI/UserInterface/Views/ThreadTreeElement.js
Source/WebInspectorUI/UserInterface/Views/TimelineOverview.js
Source/WebInspectorUI/UserInterface/Views/TimelineRecordingContentView.js
Source/WebInspectorUI/UserInterface/Views/TimelineRecordingProgressView.js
Source/WebInspectorUI/UserInterface/Views/TimelineRuler.js
Source/WebInspectorUI/UserInterface/Views/TimelineTabContentView.js
Source/WebInspectorUI/UserInterface/Views/TimelineTreeElement.js
Source/WebInspectorUI/UserInterface/Views/TreeOutline.js
Source/WebInspectorUI/UserInterface/Views/TreeOutlineGroup.js
Source/WebInspectorUI/UserInterface/Workers/HeapSnapshot/HeapSnapshotWorker.js

index 3a54847dd93e5351591b2920d386c6a27dacc596..fcb70a359e7e614112e6cc70e0b70b39d7220e4a 100644 (file)
@@ -1,3 +1,37 @@
+2020-11-04  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: use weak collections for holding event listeners
+        https://bugs.webkit.org/show_bug.cgi?id=196956
+
+        Reviewed by Brian Burg.
+
+        * http/tests/inspector/dom/disconnect-dom-tree-after-main-frame-navigation.html:
+        Use newly named `WI.Object.prototype.activelyListeningObjectsWithPrototype` instead of the
+        previously named `WI.Object.prototype.retainedObjectsWithPrototype` since `WI.Object`
+        doesn't retain any `thisObject` anymore.
+
+        * inspector/debugger/setPauseOnMicrotasks.html:
+        Only remove the event listener if it didn't fire.
+
+        * inspector/dom/setEventListenerDisabled.html:
+        No need to remove the event listener as calling `reject` after a `Promise` is already
+        settled won't have any effect.
+
+        * inspector/unit-tests/event-listener.html: Removed.
+        * inspector/unit-tests/event-listener-expected.txt: Removed.
+        * inspector/unit-tests/event-listener-set.html: Removed.
+        * inspector/unit-tests/event-listener-set-expected.txt: Removed.
+        Remove the legacy `WI.EventListener` and `WI.EventListenerSet` as they basically do the same
+        thing as `WI.Object` with extra steps.
+
+        * inspector/unit-tests/linked-list.html: Removed.
+        * inspector/unit-tests/linked-list-expected.txt: Removed.
+        * inspector/unit-tests/list-multimap.html: Removed.
+        * inspector/unit-tests/list-multimap-expected.txt: Removed.
+        Remove `LinkedList` and `ListMultimap` as they're no longer used.
+
+        * platform/gtk/TestExpectations:
+
 2020-11-04  Diego Pino Garcia  <dpino@igalia.com>
 
         [GTK] Unreviewed test gardening. Remove text flaky failures of tests that are actually passing.
index 6f5475e34aa8a8531e4fef7d3c74de4958369392..de6e2973577c5c3581334b072aff5e3b45d13a63 100644 (file)
@@ -11,7 +11,7 @@ function test()
         name: "CheckLazyInitializationOfDOMTree",
         description: "Check that DOMTree instances are created lazily.",
         test(resolve, reject) {
-            let instances = WI.domManager.retainedObjectsWithPrototype(WI.DOMTree);
+            let instances = WI.domManager.activelyListeningObjectsWithPrototype(WI.DOMTree);
             InspectorTest.expectThat(instances.size === 0, "There should not be a DOMTree listening to DOMTreeManager events initially.");
             InspectorTest.log("DOMTree instance count: " + instances.size);
             resolve();
@@ -25,7 +25,7 @@ function test()
             let mainFrame = WI.networkManager.mainFrame;
             mainFrame.domTree; // Force creation of the root DOM tree.
 
-            let instances = WI.domManager.retainedObjectsWithPrototype(WI.DOMTree);
+            let instances = WI.domManager.activelyListeningObjectsWithPrototype(WI.DOMTree);
             InspectorTest.expectThat(instances.size === 1, "There should be a one DOMTree listening to DOMTreeManager events after creation.");
             InspectorTest.log("DOMTree instance count: " + instances.size);
 
@@ -39,7 +39,7 @@ function test()
             let childrenLevel3 = Array.from(childrenLevel2[0].childFrameCollection);
             childrenLevel3[0].domTree;
 
-            instances = WI.domManager.retainedObjectsWithPrototype(WI.DOMTree);
+            instances = WI.domManager.activelyListeningObjectsWithPrototype(WI.DOMTree);
             InspectorTest.expectThat(instances.size === 4, "There should be four DOMTrees listening to DOMTreeManager events after touching each Frame.");
             InspectorTest.log("DOMTree instance count: " + instances.size);
 
@@ -53,7 +53,7 @@ function test()
         test(resolve, reject) {
             WI.Frame.awaitEvent(WI.Frame.Event.MainResourceDidChange)
             .then((event) => {
-                let instances = WI.domManager.retainedObjectsWithPrototype(WI.DOMTree);
+                let instances = WI.domManager.activelyListeningObjectsWithPrototype(WI.DOMTree);
                 InspectorTest.expectThat(instances.size === 0, "There should not be any DOMTrees listening to DOMTreeManager events after a main frame navigation.");
                 InspectorTest.log("DOMTree instance count: " + instances.size);
             })
index b37fb56db9630c598c9a2661e35499901e0756ce..82e5df564f33f6eb8648d26c9b895094262e9c4a 100644 (file)
@@ -46,7 +46,8 @@ function test()
 
                 InspectorTest.evaluateInPage(expression, () => {
                     InspectorTest.expectThat(!didPause, "Should not have paused.");
-                    WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.Paused, listener);
+                    if (!didPause)
+                        WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.Paused, listener);
 
                     WI.debuggerManager.allMicrotasksBreakpoint.remove();
                     InspectorTest.assert(!WI.debuggerManager.allMicrotasksBreakpoint, "Should have destroyed all microtasks breakpoint.");
@@ -71,7 +72,8 @@ function test()
 
                 InspectorTest.evaluateInPage(expression, () => {
                     InspectorTest.expectThat(didPause, "Should have paused.");
-                    WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.Paused, listener);
+                    if (!didPause)
+                        WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.Paused, listener);
 
                     WI.debuggerManager.allMicrotasksBreakpoint.remove();
                     InspectorTest.assert(!WI.debuggerManager.allMicrotasksBreakpoint, "Should have destroyed all microtasks breakpoint.");
index 986bc8295c722c30a2239d64f7b96a9e86fa7cad..0a039cd6857d7a192a6caee972e9946012de5a92 100644 (file)
@@ -26,15 +26,13 @@ function test() {
     suite.addTestCase({
         name: "DOM.setEventListenerDisabled.DisabledClickEvent",
         test(resolve, reject) {
-            let listener = InspectorTest.singleFireEventListener("TestPageDocumentClicked", () => {
+            InspectorTest.singleFireEventListener("TestPageDocumentClicked", () => {
                 reject("Click event listener should not be called");
             });
 
             InspectorTest.singleFireEventListener("TestPageAfterClick", () => {
                 InspectorTest.pass("Click event listener did not fire.");
 
-                InspectorTest.removeEventListener(listener);
-
                 logListener().then(resolve, reject);
             });
 
diff --git a/LayoutTests/inspector/unit-tests/event-listener-expected.txt b/LayoutTests/inspector/unit-tests/event-listener-expected.txt
deleted file mode 100644 (file)
index aff8700..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-Testing basic functionality of WI.EventListener.
-
-Connecting the listener.
-Invoked callback for kaboom event.
-Invoked callback for kaboom event.
-Disconnecting the listener.
-Connecting the listener.
-Invoked callback for kaboom event.
-Disconnecting the listener.
-Connecting the listener.
-Disconnecting the listener.
-Connecting the single-fire listener.
-Invoked callback for kaboom event.
-Disconnecting the single-fire listener.
-Invoked callback for kaboom event.
-
diff --git a/LayoutTests/inspector/unit-tests/event-listener-set-expected.txt b/LayoutTests/inspector/unit-tests/event-listener-set-expected.txt
deleted file mode 100644 (file)
index 8151e2e..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-Testing basic functionality of WI.EventListenerSet.
-
-Registering listeners.
-Installing listeners.
-Dispatching events.
-Invoked callback for foo event.
-Invoked callback for bar event.
-Invoked callback for baz event.
-Uninstalling and disconnecting listeners.
-Registering listeners.
-Dispatching events.
-Invoked callback for foo event.
-Invoked callback for bar event.
-Invoked callback for baz event.
-Uninstalling listeners.
-Installing listeners.
-Dispatching events.
-Invoked callback for foo event.
-Invoked callback for bar event.
-Invoked callback for baz event.
-Unregistering everything.
-Dispatching events.
-Uninstalling and disconnecting listeners.
-Dispatching events.
-
diff --git a/LayoutTests/inspector/unit-tests/event-listener-set.html b/LayoutTests/inspector/unit-tests/event-listener-set.html
deleted file mode 100644 (file)
index db567bb..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-<!doctype html>
-<html>
-<head>
-<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
-<script>
-function test()
-{
-    const FooEvent = "foo";
-    const BarEvent = "bar";
-    const BazEvent = "baz";
-    var emitter1 = new WI.Object();
-    var emitter2 = new WI.Object();
-    var context1 = new WI.Object();
-    var context2 = new WI.Object();
-    var data1 = [1, 2, 3];
-    var data2 = [4, 6, 8];
-
-    function fooCallback(event)
-    {
-        InspectorTest.assert(this === context1, "Callback invoked with wrong |this| binding.");
-        InspectorTest.assert(event.target === emitter1, "Callback invoked with wrong event emitter.");
-        InspectorTest.assert(event.data === data1, "Callback invoked with wrong event data.");
-
-        InspectorTest.log("Invoked callback for foo event.");
-    }
-
-    function barCallback(event)
-    {
-        InspectorTest.assert(this === context1, "Callback invoked with wrong |this| binding.");
-        InspectorTest.assert(event.target === emitter1, "Callback invoked with wrong event emitter.");
-        InspectorTest.assert(event.data === data2, "Callback invoked with wrong event data.");
-
-        InspectorTest.log("Invoked callback for bar event.");
-    }
-
-    function bazCallback(event)
-    {
-        InspectorTest.assert(this === context2, "Callback invoked with wrong |this| binding.");
-        InspectorTest.assert(event.target === emitter2, "Callback invoked with wrong event emitter.");
-        InspectorTest.assert(event.data === data2, "Callback invoked with wrong event data.");
-
-        InspectorTest.log("Invoked callback for baz event.");
-    }
-
-    // Test for multiple firings of listeners in the set.
-
-    var listenerSet = new WI.EventListenerSet(context1);
-    InspectorTest.assert(!emitter1.hasEventListeners(FooEvent), "Emitter should not have any listeners.");
-    emitter1.dispatchEventToListeners(FooEvent, data1); // Should not fire anything.
-
-    InspectorTest.log("Registering listeners.");
-    listenerSet.register(emitter1, FooEvent, fooCallback);
-    listenerSet.register(emitter1, BarEvent, barCallback);
-    listenerSet.register(emitter2, BazEvent, bazCallback, context2);
-    InspectorTest.assert(!emitter1.hasEventListeners(FooEvent), "Emitter should not have a listener.");
-    InspectorTest.assert(!emitter1.hasEventListeners(BarEvent), "Emitter should not have a listener.");
-    InspectorTest.assert(!emitter2.hasEventListeners(BazEvent), "Emitter should not have a listener.");
-
-    InspectorTest.log("Installing listeners.");
-    listenerSet.install();
-    InspectorTest.assert(emitter1.hasEventListeners(FooEvent), "Emitter should have a listener.");
-    InspectorTest.assert(emitter1.hasEventListeners(BarEvent), "Emitter should have a listener.");
-    InspectorTest.assert(emitter2.hasEventListeners(BazEvent), "Emitter should have a listener.");
-
-    InspectorTest.log("Dispatching events.");
-    emitter1.dispatchEventToListeners(FooEvent, data1); // Should fire.
-    emitter1.dispatchEventToListeners(BarEvent, data2); // Should fire.
-    emitter2.dispatchEventToListeners(BazEvent, data2); // Should fire.
-    InspectorTest.log("Uninstalling and disconnecting listeners.");
-    listenerSet.uninstall(true);
-
-    InspectorTest.log("Registering listeners.");
-    listenerSet.register(emitter1, FooEvent, fooCallback);
-    listenerSet.register(emitter1, BarEvent, barCallback);
-    listenerSet.register(emitter2, BazEvent, bazCallback, context2);
-
-    listenerSet.install();
-    InspectorTest.log("Dispatching events.");
-    emitter1.dispatchEventToListeners(FooEvent, data1); // Should fire.
-    emitter1.dispatchEventToListeners(BarEvent, data2); // Should fire.
-    emitter2.dispatchEventToListeners(BazEvent, data2); // Should fire.
-    InspectorTest.log("Uninstalling listeners.");
-    listenerSet.uninstall();
-
-    InspectorTest.log("Installing listeners.");
-    listenerSet.install();
-    InspectorTest.log("Dispatching events.");
-    emitter1.dispatchEventToListeners(FooEvent, data1); // Should fire.
-    emitter1.dispatchEventToListeners(BarEvent, data2); // Should fire.
-    emitter2.dispatchEventToListeners(BazEvent, data2); // Should fire.
-
-    InspectorTest.log("Unregistering everything.");
-    listenerSet.unregister();
-    InspectorTest.log("Dispatching events.");
-    emitter1.dispatchEventToListeners(FooEvent, data1); // Should not fire.
-    emitter1.dispatchEventToListeners(BarEvent, data2); // Should not fire.
-    emitter2.dispatchEventToListeners(BazEvent, data2); // Should not fire.
-
-    InspectorTest.log("Uninstalling and disconnecting listeners.");
-    listenerSet.uninstall(true);
-    InspectorTest.log("Dispatching events.");
-    emitter1.dispatchEventToListeners(FooEvent, data1); // Should not fire.
-    emitter1.dispatchEventToListeners(BarEvent, data2); // Should not fire.
-    emitter2.dispatchEventToListeners(BazEvent, data2); // Should not fire.
-
-    InspectorTest.assert(!emitter1.hasEventListeners(FooEvent), "Emitter should not have a listener.");
-    InspectorTest.assert(!emitter1.hasEventListeners(BarEvent), "Emitter should not have a listener.");
-    InspectorTest.assert(!emitter2.hasEventListeners(BazEvent), "Emitter should not have a listener.");
-
-    InspectorTest.completeTest();
-}
-</script>
-</head>
-<body onload="runTest()">
-    <p>Testing basic functionality of WI.EventListenerSet.</p>
-</body>
-</html>
diff --git a/LayoutTests/inspector/unit-tests/event-listener.html b/LayoutTests/inspector/unit-tests/event-listener.html
deleted file mode 100644 (file)
index 75a1894..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-<!doctype html>
-<html>
-<head>
-<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
-<script>
-function test()
-{
-    const KaboomEvent = "kaboom";
-    var emitter = new WI.Object();
-    var context = new WI.Object();
-    var data = [1, 2, 3];
-
-    function kaboomCallback(event) {
-        InspectorTest.assert(this === context, "Callback invoked with wrong |this| binding.");
-        InspectorTest.assert(event.target === emitter, "Callback invoked with wrong event emitter.");
-        InspectorTest.assert(event.data === data, "Callback invoked with wrong event data.");
-
-        InspectorTest.log("Invoked callback for kaboom event.");
-    }
-
-    // Test for multiple firings of the listener.
-
-    var listener = new WI.EventListener(context);
-    InspectorTest.assert(!emitter.hasEventListeners(KaboomEvent), "Emitter should not have any listeners.");
-    emitter.dispatchEventToListeners(KaboomEvent, data); // Should not fire anything.
-
-    InspectorTest.log("Connecting the listener.");
-    listener.connect(emitter, KaboomEvent, kaboomCallback);
-    InspectorTest.assert(emitter.hasEventListeners(KaboomEvent), "Emitter should have a listener.");
-    emitter.dispatchEventToListeners(KaboomEvent, data); // Should fire.
-    emitter.dispatchEventToListeners(KaboomEvent, data); // Should fire.
-    InspectorTest.log("Disconnecting the listener.");
-    listener.disconnect();
-
-    emitter.dispatchEventToListeners(KaboomEvent, data); // Should not fire anything.
-    InspectorTest.assert(!emitter.hasEventListeners(KaboomEvent), "Emitter should not have any listeners.");
-
-    // Test reconnection.
-
-    InspectorTest.log("Connecting the listener.");
-    listener.connect(emitter, KaboomEvent, kaboomCallback);
-    emitter.dispatchEventToListeners(KaboomEvent, data); // Should fire.
-    InspectorTest.log("Disconnecting the listener.");
-    listener.disconnect();
-
-    // Test unused listener.
-
-    InspectorTest.log("Connecting the listener.");
-    listener.connect(emitter, KaboomEvent, kaboomCallback);
-    InspectorTest.log("Disconnecting the listener.");
-    listener.disconnect();
-
-    // Test for single firing of the listener.
-
-    var singleListener = new WI.EventListener(context, true);
-    InspectorTest.assert(!emitter.hasEventListeners(KaboomEvent), "Emitter should not have any listeners.");
-    emitter.dispatchEventToListeners(KaboomEvent, data); // Should not fire anything.
-
-    InspectorTest.log("Connecting the single-fire listener.");
-    singleListener.connect(emitter, KaboomEvent, kaboomCallback);
-    InspectorTest.assert(emitter.hasEventListeners(KaboomEvent), "Emitter should have a listener.");
-    emitter.dispatchEventToListeners(KaboomEvent, data); // Should fire.
-    InspectorTest.assert(!emitter.hasEventListeners(KaboomEvent), "Emitter should not have any listeners.");
-    emitter.dispatchEventToListeners(KaboomEvent, data); // Should not fire.
-    InspectorTest.log("Disconnecting the single-fire listener.");
-    singleListener.disconnect(); // Should cause an error.
-    emitter.dispatchEventToListeners(KaboomEvent, data); // Should not fire.
-
-    // Test for various error cases and abuse.
-
-    var badListener = new WI.EventListener(context);
-    badListener.connect(data, data, data); // Should complain about non-callable callback.
-    badListener.connect(null, KaboomEvent, kaboomCallback); // Should complain about non-callable callback.
-    badListener.connect(emitter, KaboomEvent, null); // Should complain about non-callable callback.
-    badListener.connect(emitter, null, kaboomCallback); // Should complain about null event.
-
-    var badListener2 = new WI.EventListener(context);
-    badListener2.disconnect(); // Should complain about already disconnected.
-    badListener2.connect(emitter, KaboomEvent, kaboomCallback);
-    badListener2.connect(emitter, KaboomEvent, kaboomCallback); // Should complain about already connected.
-    emitter.dispatchEventToListeners(KaboomEvent, data); // Should fire.
-    badListener2.connect(emitter, KaboomEvent, kaboomCallback); // Should complain about already connected.
-    badListener2.disconnect();
-    badListener2.disconnect(); // Should complain about already disconnected.
-
-    InspectorTest.completeTest();
-}
-</script>
-</head>
-<body onload="runTest()">
-    <p>Testing basic functionality of WI.EventListener.</p>
-</body>
-</html>
diff --git a/LayoutTests/inspector/unit-tests/linked-list-expected.txt b/LayoutTests/inspector/unit-tests/linked-list-expected.txt
deleted file mode 100644 (file)
index 865e100..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-Testing all methods of LinkedList.
-
-
-== Running test suite: LinkedList
--- Running test case: Adding items
-0
-[]
-2
-["one","two"]
-3
-["one","two","three"]
-
--- Running test case: Removing items
-3
-["one","two","three"]
-2
-["one","three"]
-
--- Running test case: Removing all items
-0
-[]
-
--- Running test case: Iterating using forEach method
-["one","two","three"]
-
diff --git a/LayoutTests/inspector/unit-tests/linked-list.html b/LayoutTests/inspector/unit-tests/linked-list.html
deleted file mode 100644 (file)
index c803257..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-<!doctype html>
-<html>
-<head>
-<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
-<script>
-function test()
-{
-    let suite = InspectorTest.createAsyncSuite("LinkedList");
-
-    suite.addTestCase({
-        name: "Adding items",
-        test(resolve, reject) {
-            let list = new LinkedList;
-
-            InspectorTest.log(list.length);
-            InspectorTest.log(list);
-
-            list.push("one");
-            list.push("two");
-            InspectorTest.log(list.length);
-            InspectorTest.log(list);
-
-            list.push("three");
-            InspectorTest.log(list.length);
-            InspectorTest.log(list);
-
-            resolve();
-        }
-    });
-
-    suite.addTestCase({
-        name: "Removing items",
-        test(resolve, reject) {
-            let list = new LinkedList;
-
-            list.push("one");
-            let nodeTwo = list.push("two");
-            list.push("three");
-            InspectorTest.log(list.length);
-            InspectorTest.log(list);
-
-            list.remove(nodeTwo);
-            InspectorTest.log(list.length);
-            InspectorTest.log(list);
-
-            resolve();
-        }
-    });
-
-    suite.addTestCase({
-        name: "Removing all items",
-        test(resolve, reject) {
-            let list = new LinkedList;
-
-            list.push("one");
-            list.push("two");
-            list.push("three");
-            list.clear();
-            InspectorTest.log(list.length);
-            InspectorTest.log(list);
-
-            resolve();
-        }
-    });
-
-    suite.addTestCase({
-        name: "Iterating using forEach method",
-        test(resolve, reject) {
-            let list = new LinkedList;
-
-            list.push("one");
-            list.push("two");
-            list.push("three");
-
-            let values = [];
-            list.forEach(function(value) {
-                values.push(value);
-            });
-            InspectorTest.log(values);
-
-            resolve();
-        }
-    });
-
-    suite.runTestCasesAndFinish();
-}
-</script>
-</head>
-<body onload="runTest()">
-    <p>Testing all methods of LinkedList.</p>
-</body>
-</html>
diff --git a/LayoutTests/inspector/unit-tests/list-multimap-expected.txt b/LayoutTests/inspector/unit-tests/list-multimap-expected.txt
deleted file mode 100644 (file)
index 7bf5fed..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-Testing all methods of ListMultimap.
-
-
-== Running test suite: ListMultimap
--- Running test case: Instantiating Multimap
-0
-[]
-
--- Running test case: Adding unique keys and values
-2
-[["zero","one"],["two","three"]]
-
--- Running test case: Adding repeating keys and unique values
-2
-[["zero","one"],["zero","two"]]
-
--- Running test case: Adding unique keys and repeating values
-3
-[["zero","one"],["two","one"],["three","one"]]
-
--- Running test case: Adding repeating keys and values
-3
-[["zero","one"],["two","one"],["zero","three"]]
-
--- Running test case: Deleting existing keys and values
-PASS: The key and the value were successfully deleted.
-1
-[[2,3]]
-PASS: The key and the value were successfully deleted.
-0
-[]
-
--- Running test case: Deleting non-existing keys and non-existing values
-PASS: Nothing was removed.
-PASS: Nothing was removed.
-PASS: Nothing was removed.
-PASS: Nothing was removed.
-PASS: Nothing was removed.
-3
-[[0,1],[2,3],[4,4]]
-
--- Running test case: Deleting values for given key
-PASS: Nothing was removed.
-3
-[["opossum","badger"],["opossum","raccoon"],["raccoon","opossum"]]
-PASS: Values were removed.
-1
-[["raccoon","opossum"]]
-
--- Running test case: Deleting all keys and values
-0
-[]
-
--- Running test case: Iterating using forEach method
-[["Platypus","Sugar glider"],["Quoll","Wallaby"]]
-
diff --git a/LayoutTests/inspector/unit-tests/list-multimap.html b/LayoutTests/inspector/unit-tests/list-multimap.html
deleted file mode 100644 (file)
index 4655422..0000000
+++ /dev/null
@@ -1,191 +0,0 @@
-<!doctype html>
-<html>
-<head>
-<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
-<script>
-function test()
-{
-    let suite = InspectorTest.createAsyncSuite("ListMultimap");
-
-    suite.addTestCase({
-        name: "Instantiating Multimap",
-        test(resolve, reject) {
-            let multimap = new ListMultimap;
-
-            InspectorTest.log(multimap.size);
-            InspectorTest.log(multimap);
-
-            resolve();
-        }
-    });
-
-    suite.addTestCase({
-        name: "Adding unique keys and values",
-        test(resolve, reject) {
-            let multimap = new ListMultimap;
-
-            multimap.add("zero", "one");
-            multimap.add("two", "three");
-
-            InspectorTest.log(multimap.size);
-            InspectorTest.log(multimap);
-
-            resolve();
-        }
-    });
-
-    suite.addTestCase({
-        name: "Adding repeating keys and unique values",
-        test(resolve, reject) {
-            let multimap = new ListMultimap;
-
-            multimap.add("zero", "one");
-            multimap.add("zero", "two");
-
-            InspectorTest.log(multimap.size);
-            InspectorTest.log(multimap);
-
-            resolve();
-        }
-    });
-
-    suite.addTestCase({
-        name: "Adding unique keys and repeating values",
-        test(resolve, reject) {
-            let multimap = new ListMultimap;
-
-            multimap.add("zero", "one");
-            multimap.add("two", "one");
-            multimap.add("three", "one");
-
-            InspectorTest.log(multimap.size);
-            InspectorTest.log(multimap);
-
-            resolve();
-        }
-    });
-
-    suite.addTestCase({
-        name: "Adding repeating keys and values",
-        test(resolve, reject) {
-            let multimap = new ListMultimap;
-
-            multimap.add("zero", "one");
-            multimap.add("two", "one");
-            multimap.add("zero", "one");
-            multimap.add("zero", "three");
-
-            InspectorTest.log(multimap.size);
-            InspectorTest.log(multimap);
-
-            resolve();
-        }
-    });
-
-    suite.addTestCase({
-        name: "Deleting existing keys and values",
-        test(resolve, reject) {
-            let multimap = new ListMultimap;
-
-            multimap.add(0, 1);
-            multimap.add(2, 3);
-            multimap.add(2, 3);
-
-            InspectorTest.expectThat(multimap.delete(0, 1), "The key and the value were successfully deleted.");
-
-            InspectorTest.log(multimap.size);
-            InspectorTest.log(multimap);
-
-            InspectorTest.expectThat(multimap.delete(2, 3), "The key and the value were successfully deleted.");
-
-            InspectorTest.log(multimap.size);
-            InspectorTest.log(multimap);
-
-            resolve();
-        }
-    });
-
-    suite.addTestCase({
-        name: "Deleting non-existing keys and non-existing values",
-        test(resolve, reject) {
-            let multimap = new ListMultimap;
-
-            multimap.add(0, 1);
-            multimap.add(2, 3);
-            multimap.add(4, 4);
-
-            InspectorTest.expectThat(!multimap.delete(0, 3), "Nothing was removed.");
-            InspectorTest.expectThat(!multimap.delete(2, 1), "Nothing was removed.");
-            InspectorTest.expectThat(!multimap.delete(3, 0), "Nothing was removed.");
-            InspectorTest.expectThat(!multimap.delete(4, 3), "Nothing was removed.");
-            InspectorTest.expectThat(!multimap.delete(0, 4), "Nothing was removed.");
-
-            InspectorTest.log(multimap.size);
-            InspectorTest.log(multimap);
-
-            resolve();
-        }
-    });
-
-    suite.addTestCase({
-        name: "Deleting values for given key",
-        test(resolve, reject) {
-            let multimap = new ListMultimap;
-
-            multimap.add("opossum", "badger");
-            multimap.add("opossum", "raccoon");
-            multimap.add("raccoon", "opossum");
-
-            InspectorTest.expectThat(!multimap.deleteAll("badger"), "Nothing was removed.");
-
-            InspectorTest.log(multimap.size);
-            InspectorTest.log(multimap);
-
-            InspectorTest.expectThat(multimap.deleteAll("opossum"), "Values were removed.");
-
-            InspectorTest.log(multimap.size);
-            InspectorTest.log(multimap);
-
-            resolve();
-        }
-    });
-
-    suite.addTestCase({
-        name: "Deleting all keys and values",
-        test(resolve, reject) {
-            let multimap = new ListMultimap;
-            multimap.add("badger", "raccoon");
-            multimap.clear();
-
-            InspectorTest.log(multimap.size);
-            InspectorTest.log(multimap);
-
-            resolve();
-        }
-    });
-
-    suite.addTestCase({
-        name: "Iterating using forEach method",
-        test(resolve, reject) {
-            let multimap = new ListMultimap;
-            multimap.add("Platypus", "Sugar glider");
-            multimap.add("Quoll", "Wallaby");
-
-            let list = [];
-            multimap.forEach(function(pair) {
-                list.push(pair);
-            });
-            InspectorTest.log(multimap);
-
-            resolve();
-        }
-    });
-
-    suite.runTestCasesAndFinish();
-}
-</script>
-</head>
-<body onload="runTest()">
-    <p>Testing all methods of ListMultimap.</p>
-</body>
-</html>
index 40269272b806915c2fdba2fcb53243130e13cd62..90a363c664c9ebbcc561c9c5bf8be67e0cd19698 100644 (file)
@@ -2047,11 +2047,7 @@ webkit.org/b/149916 inspector/page/main-frame-resource.html [ Pass Slow ]
 webkit.org/b/149916 inspector/protocol/inspector-backend-invocation-return-value.html [ Pass Slow ]
 webkit.org/b/149916 inspector/runtime/parse.html [ Pass Timeout ]
 webkit.org/b/149916 inspector/unit-tests/array-utilities.html [ Pass Slow ]
-webkit.org/b/149916 inspector/unit-tests/event-listener.html [ Pass Slow ]
-webkit.org/b/149916 inspector/unit-tests/event-listener-set.html [ Pass Slow ]
 webkit.org/b/149916 inspector/unit-tests/inspector-test-dispatch-event-to-frontend.html [ Pass Slow ]
-webkit.org/b/149916 inspector/unit-tests/linked-list.html [ Pass Slow ]
-webkit.org/b/149916 inspector/unit-tests/list-multimap.html [ Pass Slow ]
 webkit.org/b/149916 inspector/unit-tests/object.html [ Pass Slow ]
 
 webkit.org/b/149916 inspector/animation/lifecycle-web-animation.html [ Pass Slow ]
index daa6148569b16e5cb1cf189d18e3990adb303e1e..f80701ce3fcb64df71b118b0bec6a35c532ee10a 100644 (file)
@@ -49,8 +49,6 @@
         "InspectorFrontendHost": true,
         "InspectorProtocol": true,
         "InspectorTest": true,
-        "LinkedList": true,
-        "ListMultimap": true,
         "Multimap": true,
         "ProtocolTest": true,
         "ProtocolTestHarness": true,
index 373170e8f5dddc6a541bb68903c76c85ac9831cb..c03a52a11511903f287da8f1f881198e4536f4ae 100644 (file)
@@ -1,3 +1,322 @@
+2020-11-04  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: use weak collections for holding event listeners
+        https://bugs.webkit.org/show_bug.cgi?id=196956
+
+        Reviewed by Brian Burg.
+
+        Replace the `ListMultimap`/`LinkedList` with a `Multimap` for holding listener data:
+        ```
+            Map<String eventType, Set<{Function listener, WeakRef thisObject}>> _listeners;
+        ```
+        This preserves addition order while also not strongly holding any `thisObject` so they can
+        be GCed (and remove the `listener` along with it).
+
+        * UserInterface/Base/Object.js:
+        (WI.Object.addEventListener):
+        (WI.Object.singleFireEventListener):
+        (WI.Object.awaitEvent):
+        (WI.Object.removeEventListener):
+        (WI.Object.prototype.singleFireEventListener):
+        (WI.Object.prototype.removeEventListener):
+        (WI.Object.prototype.dispatchEventToListeners.dispatch):
+        (WI.Object.hasEventListeners):
+        (WI.Object.activelyListeningObjectsWithPrototype): Added.
+        (WI.Object.prototype.activelyListeningObjectsWithPrototype): Added.
+
+        * UserInterface/Base/SearchUtilities.js:
+        (WI.SearchUtilities.createSettings):
+        (WI.SearchUtilities.createSettingsButton):
+        * UserInterface/Base/Main.js:
+        (WI.loaded):
+        (WI.contentLoaded):
+        * UserInterface/Models/Resource.js:
+        (WI.Resource.prototype.requestContent):
+        * UserInterface/Controllers/RuntimeManager.js:
+        (WI.RuntimeManager):
+        * UserInterface/Views/AuditTestCaseContentView.js:
+        (WI.AuditTestCaseContentView.prototype.showRunningPlaceholder):
+        * UserInterface/Views/AuditTestContentView.js:
+        (WI.AuditTestContentView.prototype.showNoResultPlaceholder):
+        * UserInterface/Views/AuditTestGroupContentView.js:
+        (WI.AuditTestGroupContentView.prototype.showRunningPlaceholder):
+        * UserInterface/Views/CodeMirrorEditor.js:
+        (WI.CodeMirrorEditor.create):
+        * UserInterface/Debug/Bootstrap.js:
+        (WI.runBootstrapOperations):
+        * UserInterface/Views/ConsoleDrawer.js:
+        (WI.ConsoleDrawer):
+        * UserInterface/Views/ConsoleMessageView.js:
+        (WI.ConsoleMessageView.prototype.clearSessionState):
+        (WI.ConsoleMessageView.prototype._appendSavedResultIndex):
+        (WI.ConsoleMessageView.prototype._rootPropertyPathForObject):
+        * UserInterface/Views/ContentBrowser.js:
+        (WI.ContentBrowser):
+        (WI.ContentBrowser.prototype.async handleFindNextShortcut):
+        (WI.ContentBrowser.prototype.async handleFindPreviousShortcut):
+        * UserInterface/Views/HeapSnapshotContentView.js:
+        (WI.HeapSnapshotContentView):
+        * UserInterface/Views/LogContentView.js:
+        (WI.LogContentView):
+        * UserInterface/Views/MediaTimelineOverviewGraph.js:
+        (WI.MediaTimelineOverviewGraph.prototype._processRecord):
+        * UserInterface/Views/NetworkDetailView.js:
+        (WI.NetworkDetailView.prototype.initialLayout):
+        * UserInterface/Views/ObjectTreeView.js:
+        (WI.ObjectTreeView.prototype.addShowMoreIfNeeded):
+        * UserInterface/Views/SearchSidebarPanel.js:
+        (WI.SearchSidebarPanel):
+        (WI.SearchSidebarPanel.prototype.closed):
+        (WI.SearchSidebarPanel.prototype.performSearch):
+        * UserInterface/Views/SettingEditor.js:
+        (WI.SettingEditor.createForSetting):
+        * UserInterface/Views/SettingsTabContentView.js:
+        (WI.SettingsTabContentView.prototype._createGeneralSettingsView):
+        (WI.SettingsTabContentView.prototype._createConsoleSettingsView):
+        (WI.SettingsTabContentView.prototype._createExperimentalSettingsView.listenForChange):
+        (WI.SettingsTabContentView.prototype._createExperimentalSettingsView):
+        (WI.SettingsTabContentView.prototype._createDebugSettingsView):
+        * UserInterface/Views/ShaderProgramContentView.js:
+        (WI.ShaderProgramContentView):
+        * UserInterface/Views/SourcesNavigationSidebarPanel.js:
+        (WI.SourcesNavigationSidebarPanel):
+        (WI.SourcesNavigationSidebarPanel.prototype.closed):
+        (WI.SourcesNavigationSidebarPanel.prototype.createContentTreeOutline):
+        * UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js:
+        (WI.SpreadsheetCSSStyleDeclarationSection.prototype.initialLayout):
+        * UserInterface/Views/SpreadsheetStyleProperty.js:
+        (WI.SpreadsheetStyleProperty.prototype._createInlineSwatch):
+        * UserInterface/Views/ThreadTreeElement.js:
+        (WI.ThreadTreeElement.prototype._updateStatus):
+        * UserInterface/Views/TimelineTreeElement.js:
+        (WI.TimelineTreeElement.prototype._showCloseButton):
+        Update callers of `WI.Object.prototype.addEventListener` to always pass a `thisObject`. This
+        is especially important for inlined `listener`, as there needs to be a strong reference to
+        some "longer lived" `thisObject` (which is held by a `WeakRef`) in order for the `listener`
+        to not be GCed.
+
+        * UserInterface/Models/DOMNodeStyles.js:
+        (WI.DOMNodeStyles):
+        (WI.DOMNodeStyles.prototype._parseStyleDeclarationPayload):
+        (WI.DOMNodeStyles.prototype._parseRulePayload):
+        (WI.DOMNodeStyles.prototype._handleCSSStyleSheetContentDidChange): Added.
+        (WI.DOMNodeStyles.prototype._styleSheetContentDidChange): Deleted.
+        * UserInterface/Views/TimelineRecordingProgressView.js:
+        (WI.TimelineRecordingProgressView):
+        (WI.TimelineRecordingProgressView.prototype.set visible):
+        (WI.TimelineRecordingProgressView.prototype._updateState):
+        Use a global event listener instead of adding event listeners to specific objects as it's
+        already likely that all the objects would be listened to anyways.
+
+        * UserInterface/Models/DOMTree.js:
+        (WI.DOMTree.prototype.disconnect):
+        * UserInterface/Controllers/ApplicationCacheManager.js:
+        (WI.ApplicationCacheManager.prototype.disable):
+        * UserInterface/Controllers/CallFrameTreeController.js:
+        (WI.CallFrameTreeController.prototype.disconnect):
+        * UserInterface/Controllers/DOMStorageManager.js:
+        (WI.DOMStorageManager.prototype.disable):
+        * UserInterface/Controllers/DatabaseManager.js:
+        (WI.DatabaseManager.prototype.disable):
+        * UserInterface/Controllers/IndexedDBManager.js:
+        (WI.IndexedDBManager.prototype.disable):
+        * UserInterface/Controllers/TimelineManager.js:
+        (WI.TimelineManager.prototype.capturingStopped):
+        * UserInterface/Views/ApplicationCacheDetailsSidebarPanel.js:
+        (WI.ApplicationCacheDetailsSidebarPanel.prototype.closed):
+        * UserInterface/Views/ApplicationCacheFrameContentView.js:
+        (WI.ApplicationCacheFrameContentView.prototype.closed):
+        * UserInterface/Views/AuditNavigationSidebarPanel.js:
+        (WI.AuditNavigationSidebarPanel.prototype.closed):
+        * UserInterface/Views/AuditTreeElement.js:
+        (WI.AuditTreeElement.prototype.ondetach):
+        * UserInterface/Views/CPUTimelineView.js:
+        (WI.CPUTimelineView.prototype.closed):
+        * UserInterface/Views/CanvasContentView.js:
+        (WI.CanvasContentView.prototype.detached):
+        * UserInterface/Views/CanvasOverviewContentView.js:
+        (WI.CanvasOverviewContentView.prototype.detached):
+        * UserInterface/Views/CanvasSidebarPanel.js:
+        (WI.CanvasSidebarPanel.prototype.set canvas):
+        (WI.CanvasSidebarPanel.prototype.set recording):
+        (WI.CanvasSidebarPanel.prototype.hidden):
+        * UserInterface/Views/ClusterContentView.js:
+        (WI.ClusterContentView.prototype.closed):
+        * UserInterface/Views/CollectionContentView.js:
+        (WI.CollectionContentView.prototype.removeContentViewForItem):
+        (WI.CollectionContentView.prototype.detached):
+        * UserInterface/Views/ContentBrowserTabContentView.js:
+        (WI.ContentBrowserTabContentView.prototype.hidden):
+        (WI.ContentBrowserTabContentView.prototype.closed):
+        * UserInterface/Views/DOMNodeDetailsSidebarPanel.js:
+        (WI.DOMNodeDetailsSidebarPanel.prototype.closed):
+        * UserInterface/Views/DOMTreeContentView.js:
+        (WI.DOMTreeContentView.prototype.closed):
+        * UserInterface/Views/DOMTreeUpdater.js:
+        (WI.DOMTreeUpdater.prototype.close):
+        * UserInterface/Views/ElementsTabContentView.js:
+        (WI.ElementsTabContentView.prototype.closed):
+        * UserInterface/Views/FrameDOMTreeContentView.js:
+        (WI.FrameDOMTreeContentView.prototype.closed):
+        * UserInterface/Views/GeneralStyleDetailsSidebarPanel.js:
+        (WI.GeneralStyleDetailsSidebarPanel.prototype.removeEventListeners):
+        * UserInterface/Views/HeapAllocationsTimelineView.js:
+        (WI.HeapAllocationsTimelineView):
+        (WI.HeapAllocationsTimelineView.prototype.closed):
+        * UserInterface/Views/ImageResourceContentView.js:
+        (WI.ImageResourceContentView.prototype.closed): Deleted.
+        * UserInterface/Views/InlineSwatch.js:
+        (WI.InlineSwatch.prototype.didDismissPopover):
+        * UserInterface/Views/LayoutTimelineView.js:
+        (WI.LayoutTimelineView.prototype.closed):
+        * UserInterface/Views/LocalResourceOverrideWarningView.js:
+        (WI.LocalResourceOverrideWarningView.prototype.detached):
+        * UserInterface/Views/MemoryTimelineView.js:
+        (WI.MemoryTimelineView.prototype.closed):
+        * UserInterface/Views/MultipleScopeBarItem.js:
+        (WI.MultipleScopeBarItem.prototype.set scopeBarItems):
+        * UserInterface/Views/NavigationSidebarPanel.js:
+        (WI.NavigationSidebarPanel.prototype.closed):
+        * UserInterface/Views/NetworkTimelineView.js:
+        (WI.NetworkTimelineView.prototype.closed):
+        * UserInterface/Views/OverviewTimelineView.js:
+        (WI.OverviewTimelineView.prototype.closed):
+        * UserInterface/Views/ProbeDetailsSidebarPanel.js:
+        (WI.ProbeDetailsSidebarPanel.prototype.closed):
+        * UserInterface/Views/QuickConsole.js:
+        (WI.QuickConsole.prototype.closed):
+        * UserInterface/Views/RecordingContentView.js:
+        (WI.RecordingContentView.prototype._handleRecordingProcessedAction):
+        * UserInterface/Views/RenderingFrameTimelineView.js:
+        (WI.RenderingFrameTimelineView.prototype.closed):
+        * UserInterface/Views/ResourceCollectionContentView.js:
+        (WI.ResourceCollectionContentView.prototype.detached):
+        (WI.ResourceCollectionContentView.prototype.contentViewRemoved):
+        * UserInterface/Views/ResourceContentView.js:
+        (WI.ResourceContentView.prototype.closed):
+        * UserInterface/Views/ResourceDetailsSidebarPanel.js:
+        (WI.ResourceDetailsSidebarPanel.prototype.set resource):
+        (WI.ResourceDetailsSidebarPanel.prototype._applyResourceEventListeners):
+        (WI.ResourceDetailsSidebarPanel.prototype._handleResourceInitiatedResourcesDidChange): Added.
+        * UserInterface/Views/ResourceHeadersContentView.js:
+        (WI.ResourceHeadersContentView.prototype.closed):
+        * UserInterface/Views/ResourceSecurityContentView.js:
+        (WI.ResourceSecurityContentView.prototype.closed):
+        * UserInterface/Views/ResourceSizesContentView.js:
+        (WI.ResourceSizesContentView.prototype.closed):
+        * UserInterface/Views/ResourceTimingContentView.js:
+        (WI.ResourceTimingContentView.prototype.closed):
+        * UserInterface/Views/ScopeChainDetailsSidebarPanel.js:
+        (WI.ScopeChainDetailsSidebarPanel.prototype._generateCallFramesSection):
+        (WI.ScopeChainDetailsSidebarPanel.prototype._generateWatchExpressionsSection):
+        (WI.ScopeChainDetailsSidebarPanel.prototype.closed):
+        * UserInterface/Views/ScriptContentView.js:
+        (WI.ScriptContentView.prototype.closed):
+        * UserInterface/Views/ScriptDetailsTimelineView.js:
+        (WI.ScriptDetailsTimelineView.prototype.closed):
+        * UserInterface/Views/ScriptProfileTimelineView.js:
+        (WI.ScriptProfileTimelineView.prototype.closed):
+        * UserInterface/Views/SourceCodeTextEditor.js:
+        (WI.SourceCodeTextEditor.prototype.close):
+        (WI.SourceCodeTextEditor.prototype._showPopover):
+        (WI.SourceCodeTextEditor.prototype._showPopoverForObject):
+        (WI.SourceCodeTextEditor.prototype._dismissPopover):
+        (WI.SourceCodeTextEditor.prototype._trackPopoverEvents): Deleted.
+        * UserInterface/Views/StorageSidebarPanel.js:
+        (WI.StorageSidebarPanel.prototype.closed):
+        * UserInterface/Views/TextResourceContentView.js:
+        (WI.TextResourceContentView.prototype.closed):
+        * UserInterface/Views/TimelineOverview.js:
+        (WI.TimelineOverview.prototype.closed):
+        * UserInterface/Views/TimelineRecordingContentView.js:
+        (WI.TimelineRecordingContentView):
+        (WI.TimelineRecordingContentView.prototype.closed):
+        (WI.TimelineRecordingContentView.prototype._recordingUnloaded):
+        * UserInterface/Views/TimelineRuler.js:
+        (WI.TimelineRuler.prototype.clearMarkers):
+        * UserInterface/Views/TimelineTabContentView.js:
+        (WI.TimelineTabContentView.prototype.closed):
+        * UserInterface/Views/TreeOutlineGroup.js:
+        (WI.TreeOutlineGroup.prototype.itemRemoved):
+        Replace the `removeEventListener(null, null, this)` pattern by instead having callers remove
+        each event listener explicitly. This is a safer design as it can avoid situations where
+        parent classes inadvertently remove event listeners added by subclasses. For objects with
+        lots of event listeners this is also more efficient as it doesn't require as much iteration.
+
+        * UserInterface/Views/RecordingActionTreeElement.js:
+        (WI.RecordingActionTreeElement):
+        (WI.RecordingActionTreeElement.prototype._handleValidityChanged):
+        Use `singleFireEventListener` where possible.
+
+        * UserInterface/Controllers/DebuggerManager.js:
+        (WI.DebuggerManager.prototype.pause):
+        (WI.DebuggerManager.prototype.resume):
+        (WI.DebuggerManager.prototype.stepNext):
+        (WI.DebuggerManager.prototype.stepOver):
+        (WI.DebuggerManager.prototype.stepInto):
+        (WI.DebuggerManager.prototype.stepOut):
+        * UserInterface/Views/BreakpointTreeElement.js:
+        (WI.BreakpointTreeElement.prototype.onattach):
+        (WI.BreakpointTreeElement.prototype.ondetach):
+        (WI.BreakpointTreeElement.prototype.get listenerSet): Deleted.
+        * UserInterface/Views/DataGrid.js:
+        (WI.DataGrid.prototype.insertColumn):
+        (WI.DataGrid.prototype.removeColumn):
+        * UserInterface/Views/JavaScriptBreakpointTreeElement.js:
+        (WI.JavaScriptBreakpointTreeElement):
+        (WI.JavaScriptBreakpointTreeElement.prototype.onattach):
+        (WI.JavaScriptBreakpointTreeElement.prototype.ondetach):
+        * UserInterface/Views/ProbeSetDataGrid.js:
+        (WI.ProbeSetDataGrid):
+        (WI.ProbeSetDataGrid.prototype.closed):
+        (WI.ProbeSetDataGrid.prototype._setupData):
+        (WI.ProbeSetDataGrid.prototype._teardownData):
+        * UserInterface/Views/ProbeSetDetailsSection.js:
+        (WI.ProbeSetDetailsSection):
+        (WI.ProbeSetDetailsSection.prototype.closed):
+        Remove the legacy `WI.EventListener` and `WI.EventListenerSet` as they basically do the same
+        thing as `WI.Object` with extra steps.
+
+        * UserInterface/Models/WebSocketResource.js:
+        * UserInterface/Proxies/HeapSnapshotWorkerProxy.js:
+        * UserInterface/Controllers/TargetManager.js:
+        * UserInterface/Views/DataGridNode.js:
+        (WI.DataGridNode.prototype.collapse):
+        (WI.DataGridNode.prototype.expand):
+        (WI.DataGridNode.prototype.reveal):
+        (WI.DataGridNode.prototype.traverseNextNode):
+        (WI.DataGridNode.prototype.traversePreviousNode):
+        * UserInterface/Views/HeapSnapshotClassDataGridNode.js:
+        (WI.HeapSnapshotClassDataGridNode):
+        (WI.HeapSnapshotClassDataGridNode.prototype._populate):
+        * UserInterface/Views/HeapSnapshotInstanceDataGridNode.js:
+        (WI.HeapSnapshotInstanceDataGridNode):
+        * UserInterface/Views/ProfileDataGridNode.js:
+        (WI.ProfileDataGridNode):
+        (WI.ProfileDataGridNode.prototype._populate):
+        * UserInterface/Views/ProfileNodeDataGridNode.js:
+        (WI.ProfileNodeDataGridNode):
+        (WI.ProfileNodeDataGridNode.prototype._populate):
+        * UserInterface/Views/TreeOutline.js:
+        * UserInterface/Workers/HeapSnapshot/HeapSnapshotWorker.js:
+        (HeapSnapshotWorker.prototype.createSnapshot):
+        Ensure that all event names are strings defined on the class `Event` object.
+
+        * UserInterface/Views/Sidebar.js:
+        (WI.Sidebar.prototype.set selectedSidebarPanel):
+        Drive-by: fix an issue where `hidden` is called twice, once from the selected sidebar panel
+        being changed and then again when that sidebar panel is removed.
+
+        * .eslintrc:
+        * UserInterface/Base/EventListener.js: Removed.
+        * UserInterface/Base/EventListenerSet.js: Removed.
+        * UserInterface/Base/LinkedList.js: Removed.
+        * UserInterface/Base/ListMultimap.js: Removed.
+        * UserInterface/Main.html:
+        * UserInterface/Test.html:
+        * UserInterface/TestStub.html:
+        * Tools/SourceMaps/index.html:
+
 2020-11-03  Devin Rousso  <drousso@apple.com>
 
         Web Inspector: Elements: should have the option to Edit Breakpoint... or at least Reveal Breakpoint in Sources Tab
index ddafa40e9d0408881d9907eaa37856821d5ac594..bda5eb6638709386bdd20135cc5dabd3b4c7d4a7 100644 (file)
@@ -18,8 +18,7 @@
     <script src="../../UserInterface/External/CodeMirror/xml.js"></script>
 
     <script src="../../UserInterface/Base/WebInspector.js"></script>
-    <script src="../../UserInterface/Base/LinkedList.js"></script>
-    <script src="../../UserInterface/Base/ListMultimap.js"></script>
+    <script src="../../UserInterface/Base/Multimap.js"></script>
     <script src="../../UserInterface/Base/Object.js"></script>
     <script src="../../UserInterface/Base/Utilities.js"></script>
     <script src="../../UserInterface/Controllers/FormatterSourceMap.js"></script>
diff --git a/Source/WebInspectorUI/UserInterface/Base/EventListener.js b/Source/WebInspectorUI/UserInterface/Base/EventListener.js
deleted file mode 100644 (file)
index 2519551..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2014, 2015 Apple Inc. All rights reserved.
- * Copyright (C) 2013, 2014 University of Washington. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-WI.EventListener = class EventListener
-{
-    constructor(thisObject, fireOnce)
-    {
-        this._thisObject = thisObject;
-        this._emitter = null;
-        this._callback = null;
-        this._fireOnce = fireOnce;
-    }
-
-    // Public
-
-    connect(emitter, type, callback, usesCapture)
-    {
-        console.assert(!this._emitter && !this._callback, "EventListener already bound to a callback.", this);
-        console.assert(emitter, `Missing event emitter for event: ${type}.`);
-        console.assert(type, "Missing event type.");
-        console.assert(callback, `Missing callback for event: ${type}.`);
-        var emitterIsValid = emitter && (emitter instanceof WI.Object || emitter instanceof Node || (typeof emitter.addEventListener === "function"));
-        console.assert(emitterIsValid, "Event emitter ", emitter, ` (type: ${type}) is null or does not implement Node or WI.Object.`);
-
-        if (!emitterIsValid || !type || !callback)
-            return;
-
-        this._emitter = emitter;
-        this._type = type;
-        this._usesCapture = !!usesCapture;
-
-        if (emitter instanceof Node)
-            callback = callback.bind(this._thisObject);
-
-        if (this._fireOnce) {
-            var listener = this;
-            this._callback = function() {
-                listener.disconnect();
-                callback.apply(this, arguments);
-            };
-        } else
-            this._callback = callback;
-
-        if (this._emitter instanceof Node)
-            this._emitter.addEventListener(this._type, this._callback, this._usesCapture);
-        else
-            this._emitter.addEventListener(this._type, this._callback, this._thisObject);
-    }
-
-    disconnect()
-    {
-        console.assert(this._emitter && this._callback, "EventListener is not bound to a callback.", this);
-
-        if (!this._emitter || !this._callback)
-            return;
-
-        if (this._emitter instanceof Node)
-            this._emitter.removeEventListener(this._type, this._callback, this._usesCapture);
-        else
-            this._emitter.removeEventListener(this._type, this._callback, this._thisObject);
-
-        if (this._fireOnce)
-            delete this._thisObject;
-        delete this._emitter;
-        delete this._type;
-        delete this._callback;
-    }
-};
diff --git a/Source/WebInspectorUI/UserInterface/Base/EventListenerSet.js b/Source/WebInspectorUI/UserInterface/Base/EventListenerSet.js
deleted file mode 100644 (file)
index 63c3c63..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (C) 2014, 2015 Apple Inc. All rights reserved.
- * Copyright (C) 2013, 2014 University of Washington. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-// This class supports adding and removing many listeners at once.
-// Add DOM or Inspector event listeners to the set using `register()`.
-// Use `install()` and `uninstall()` to enable or disable all listeners
-// in the set at once.
-
-WI.EventListenerSet = class EventListenerSet
-{
-    constructor(defaultThisObject, name)
-    {
-        this.name = name;
-        this._defaultThisObject = defaultThisObject;
-
-        this._listeners = [];
-        this._installed = false;
-    }
-
-    // Public
-
-    register(emitter, type, callback, thisObject, usesCapture)
-    {
-        console.assert(emitter, `Missing event emitter for event: ${type}.`);
-        console.assert(type, "Missing event type.");
-        console.assert(callback, `Missing callback for event: ${type}.`);
-        var emitterIsValid = emitter && (emitter instanceof WI.Object || emitter instanceof Node || (typeof emitter.addEventListener === "function"));
-        console.assert(emitterIsValid, "Event emitter ", emitter, ` (type: ${type}) is null or does not implement Node or WI.Object.`);
-
-        if (!emitterIsValid || !type || !callback)
-            return;
-
-        this._listeners.push({listener: new WI.EventListener(thisObject || this._defaultThisObject), emitter, type, callback, usesCapture});
-    }
-
-    unregister()
-    {
-        if (this._installed)
-            this.uninstall();
-        this._listeners = [];
-    }
-
-    install()
-    {
-        console.assert(!this._installed, "Already installed listener group: " + this.name);
-        if (this._installed)
-            return;
-
-        this._installed = true;
-
-        for (var data of this._listeners)
-            data.listener.connect(data.emitter, data.type, data.callback, data.usesCapture);
-    }
-
-    uninstall(unregisterListeners)
-    {
-        console.assert(this._installed, "Trying to uninstall listener group " + this.name + ", but it isn't installed.");
-        if (!this._installed)
-            return;
-
-        this._installed = false;
-
-        for (var data of this._listeners)
-            data.listener.disconnect();
-
-        if (unregisterListeners)
-            this._listeners = [];
-    }
-};
diff --git a/Source/WebInspectorUI/UserInterface/Base/LinkedList.js b/Source/WebInspectorUI/UserInterface/Base/LinkedList.js
deleted file mode 100644 (file)
index f9978af..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (C) 2016 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-class LinkedList
-{
-    constructor()
-    {
-        this.head = new LinkedListNode;
-        this.head.next = this.head.prev = this.head;
-        this.length = 0;
-    }
-
-    clear()
-    {
-        this.head.next = this.head.prev = this.head;
-        this.length = 0;
-    }
-
-    get last()
-    {
-        return this.head.prev;
-    }
-
-    push(item)
-    {
-        let newNode = new LinkedListNode(item);
-        let last = this.last;
-        let head = this.head;
-
-        last.next = newNode;
-        newNode.next = head;
-        head.prev = newNode;
-        newNode.prev = last;
-
-        this.length++;
-
-        return newNode;
-    }
-
-    remove(node)
-    {
-        if (!node)
-            return false;
-
-        node.prev.next = node.next;
-        node.next.prev = node.prev;
-
-        this.length--;
-        return true;
-    }
-
-    forEach(callback)
-    {
-        let node = this.head;
-        for (let i = 0, length = this.length; i < length; i++) {
-            node = node.next;
-            let returnValue = callback(node.value, i);
-            if (returnValue === false)
-                return;
-        }
-    }
-
-    toArray()
-    {
-        let node = this.head;
-        let i = this.length;
-        let result = new Array(i);
-        while (i--) {
-            node = node.prev;
-            result[i] = node.value;
-        }
-        return result;
-    }
-
-    toJSON()
-    {
-        return this.toArray();
-    }
-}
-
-
-class LinkedListNode
-{
-    constructor(value)
-    {
-        this.value = value;
-        this.prev = null;
-        this.next = null;
-    }
-}
diff --git a/Source/WebInspectorUI/UserInterface/Base/ListMultimap.js b/Source/WebInspectorUI/UserInterface/Base/ListMultimap.js
deleted file mode 100644 (file)
index a415fb6..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (C) 2016 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-class ListMultimap
-{
-    constructor()
-    {
-        this._insertionOrderedEntries = new LinkedList;
-        this._keyMap = new Map;
-    }
-
-    get size()
-    {
-        return this._insertionOrderedEntries.length;
-    }
-
-    add(key, value)
-    {
-        let nodeMap = this._keyMap.get(key);
-        if (!nodeMap) {
-            nodeMap = new Map;
-            this._keyMap.set(key, nodeMap);
-        }
-
-        let node = nodeMap.get(value);
-        if (!node) {
-            node = this._insertionOrderedEntries.push([key, value]);
-            nodeMap.set(value, node);
-        }
-
-        return this;
-    }
-
-    delete(key, value)
-    {
-        let nodeMap = this._keyMap.get(key);
-        if (!nodeMap)
-            return false;
-
-        let node = nodeMap.get(value);
-        if (!node)
-            return false;
-
-        nodeMap.delete(value);
-        this._insertionOrderedEntries.remove(node);
-        return true;
-    }
-
-    deleteAll(key)
-    {
-        let nodeMap = this._keyMap.get(key);
-        if (!nodeMap)
-            return false;
-
-        let list = this._insertionOrderedEntries;
-        let didDelete = false;
-        nodeMap.forEach(function(node) {
-            list.remove(node);
-            didDelete = true;
-        });
-
-        this._keyMap.delete(key);
-        return didDelete;
-    }
-
-    has(key, value)
-    {
-        let nodeMap = this._keyMap.get(key);
-        if (!nodeMap)
-            return false;
-
-        return nodeMap.has(value);
-    }
-
-    clear()
-    {
-        this._keyMap = new Map;
-        this._insertionOrderedEntries = new LinkedList;
-    }
-
-    forEach(callback)
-    {
-        this._insertionOrderedEntries.forEach(callback);
-    }
-
-    toArray()
-    {
-        return this._insertionOrderedEntries.toArray();
-    }
-
-    toJSON()
-    {
-        return this.toArray();
-    }
-}
index 5ea7b016d3e56ba683fe4821ac2024d06efc1c15..3382a21aba2d8088869242169f3e75d410d79873 100644 (file)
@@ -98,7 +98,7 @@ WI.loaded = function()
 
     // Listen for the ProvisionalLoadStarted event before registering for events so our code gets called before any managers or sidebars.
     // This lets us save a state cookie before any managers or sidebars do any resets that would affect state (namely TimelineManager).
-    WI.Frame.addEventListener(WI.Frame.Event.ProvisionalLoadStarted, WI._provisionalLoadStarted,);
+    WI.Frame.addEventListener(WI.Frame.Event.ProvisionalLoadStarted, WI._provisionalLoadStarted, WI);
 
     // Populate any UIStrings that must be done early after localized strings have loaded.
     WI.KeyboardShortcut.Key.Space._displayName = WI.UIString("Space");
@@ -130,16 +130,16 @@ WI.loaded = function()
     ];
 
     // Register for events.
-    WI.debuggerManager.addEventListener(WI.DebuggerManager.Event.Paused, WI._debuggerDidPause);
-    WI.domManager.addEventListener(WI.DOMManager.Event.InspectModeStateChanged, WI._inspectModeStateChanged);
-    WI.domManager.addEventListener(WI.DOMManager.Event.DOMNodeWasInspected, WI._domNodeWasInspected);
-    WI.domStorageManager.addEventListener(WI.DOMStorageManager.Event.DOMStorageObjectWasInspected, WI._domStorageWasInspected);
-    WI.databaseManager.addEventListener(WI.DatabaseManager.Event.DatabaseWasInspected, WI._databaseWasInspected);
-    WI.networkManager.addEventListener(WI.NetworkManager.Event.MainFrameDidChange, WI._mainFrameDidChange);
-    WI.networkManager.addEventListener(WI.NetworkManager.Event.FrameWasAdded, WI._frameWasAdded);
+    WI.debuggerManager.addEventListener(WI.DebuggerManager.Event.Paused, WI._debuggerDidPause, WI);
+    WI.domManager.addEventListener(WI.DOMManager.Event.InspectModeStateChanged, WI._inspectModeStateChanged, WI);
+    WI.domManager.addEventListener(WI.DOMManager.Event.DOMNodeWasInspected, WI._domNodeWasInspected, WI);
+    WI.domStorageManager.addEventListener(WI.DOMStorageManager.Event.DOMStorageObjectWasInspected, WI._domStorageWasInspected, WI);
+    WI.databaseManager.addEventListener(WI.DatabaseManager.Event.DatabaseWasInspected, WI._databaseWasInspected, WI);
+    WI.networkManager.addEventListener(WI.NetworkManager.Event.MainFrameDidChange, WI._mainFrameDidChange, WI);
+    WI.networkManager.addEventListener(WI.NetworkManager.Event.FrameWasAdded, WI._frameWasAdded, WI);
     WI.browserManager.enable();
 
-    WI.Frame.addEventListener(WI.Frame.Event.MainResourceDidChange, WI._mainResourceDidChange);
+    WI.Frame.addEventListener(WI.Frame.Event.MainResourceDidChange, WI._mainResourceDidChange, WI);
 
     document.addEventListener("DOMContentLoaded", WI.contentLoaded);
 
@@ -230,26 +230,26 @@ WI.contentLoaded = function()
     WI.layoutMeasurementContainer = document.body.appendChild(document.createElement("div"));
     WI.layoutMeasurementContainer.id = "layout-measurement-container";
 
-    WI.settings.showJavaScriptTypeInformation.addEventListener(WI.Setting.Event.Changed, WI._showJavaScriptTypeInformationSettingChanged);
-    WI.settings.enableControlFlowProfiler.addEventListener(WI.Setting.Event.Changed, WI._enableControlFlowProfilerSettingChanged);
-    WI.settings.resourceCachingDisabled.addEventListener(WI.Setting.Event.Changed, WI._resourceCachingDisabledSettingChanged);
+    WI.settings.showJavaScriptTypeInformation.addEventListener(WI.Setting.Event.Changed, WI._showJavaScriptTypeInformationSettingChanged, WI);
+    WI.settings.enableControlFlowProfiler.addEventListener(WI.Setting.Event.Changed, WI._enableControlFlowProfilerSettingChanged, WI);
+    WI.settings.resourceCachingDisabled.addEventListener(WI.Setting.Event.Changed, WI._resourceCachingDisabledSettingChanged, WI);
 
     function setTabSize() {
         document.body.style.tabSize = WI.settings.tabSize.value;
     }
-    WI.settings.tabSize.addEventListener(WI.Setting.Event.Changed, setTabSize);
+    WI.settings.tabSize.addEventListener(WI.Setting.Event.Changed, setTabSize, WI);
     setTabSize();
 
     function setInvisibleCharacterClassName() {
         document.body.classList.toggle("show-invisible-characters", WI.settings.showInvisibleCharacters.value);
     }
-    WI.settings.showInvisibleCharacters.addEventListener(WI.Setting.Event.Changed, setInvisibleCharacterClassName);
+    WI.settings.showInvisibleCharacters.addEventListener(WI.Setting.Event.Changed, setInvisibleCharacterClassName, WI);
     setInvisibleCharacterClassName();
 
     function setWhitespaceCharacterClassName() {
         document.body.classList.toggle("show-whitespace-characters", WI.settings.showWhitespaceCharacters.value);
     }
-    WI.settings.showWhitespaceCharacters.addEventListener(WI.Setting.Event.Changed, setWhitespaceCharacterClassName);
+    WI.settings.showWhitespaceCharacters.addEventListener(WI.Setting.Event.Changed, setWhitespaceCharacterClassName, WI);
     setWhitespaceCharacterClassName();
 
     // Create the user interface elements.
@@ -267,8 +267,8 @@ WI.contentLoaded = function()
     WI.findPreviousKeyboardShortcut = new WI.KeyboardShortcut(WI.KeyboardShortcut.Modifier.Shift | WI.KeyboardShortcut.Modifier.CommandOrControl, "G", WI._findPrevious);
 
     WI.consoleDrawer = new WI.ConsoleDrawer(document.getElementById("console-drawer"));
-    WI.consoleDrawer.addEventListener(WI.ConsoleDrawer.Event.CollapsedStateChanged, WI._consoleDrawerCollapsedStateDidChange);
-    WI.consoleDrawer.addEventListener(WI.ConsoleDrawer.Event.Resized, WI._consoleDrawerDidResize);
+    WI.consoleDrawer.addEventListener(WI.ConsoleDrawer.Event.CollapsedStateChanged, WI._consoleDrawerCollapsedStateDidChange, WI);
+    WI.consoleDrawer.addEventListener(WI.ConsoleDrawer.Event.Resized, WI._consoleDrawerDidResize, WI);
 
     WI.quickConsole = new WI.QuickConsole(document.getElementById("quick-console"));
 
@@ -277,13 +277,13 @@ WI.contentLoaded = function()
     WI.consoleLogViewController = WI.consoleContentView.logViewController;
 
     WI.navigationSidebar = new WI.SingleSidebar(document.getElementById("navigation-sidebar"), WI.Sidebar.Sides.Leading, WI.UIString("Navigation", "Navigation @ Sidebar", "Label for the navigation sidebar."));
-    WI.navigationSidebar.addEventListener(WI.Sidebar.Event.WidthDidChange, WI._sidebarWidthDidChange);
-    WI.navigationSidebar.addEventListener(WI.Sidebar.Event.CollapsedStateDidChange, WI._sidebarWidthDidChange);
+    WI.navigationSidebar.addEventListener(WI.Sidebar.Event.WidthDidChange, WI._sidebarWidthDidChange, WI);
+    WI.navigationSidebar.addEventListener(WI.Sidebar.Event.CollapsedStateDidChange, WI._sidebarWidthDidChange, WI);
 
     WI.detailsSidebar = new WI.MultiSidebar(document.getElementById("details-sidebar"), WI.Sidebar.Sides.Trailing, WI.UIString("Details", "Details @ Sidebar", "Label for the details sidebar."));
-    WI.detailsSidebar.addEventListener(WI.Sidebar.Event.WidthDidChange, WI._sidebarWidthDidChange);
-    WI.detailsSidebar.addEventListener(WI.Sidebar.Event.CollapsedStateDidChange, WI._sidebarWidthDidChange);
-    WI.detailsSidebar.addEventListener(WI.MultiSidebar.Event.MultipleSidebarsVisibleChanged, WI._sidebarWidthDidChange);
+    WI.detailsSidebar.addEventListener(WI.Sidebar.Event.WidthDidChange, WI._sidebarWidthDidChange, WI);
+    WI.detailsSidebar.addEventListener(WI.Sidebar.Event.CollapsedStateDidChange, WI._sidebarWidthDidChange, WI);
+    WI.detailsSidebar.addEventListener(WI.MultiSidebar.Event.MultipleSidebarsVisibleChanged, WI._sidebarWidthDidChange, WI);
 
     WI.searchKeyboardShortcut = new WI.KeyboardShortcut(WI.KeyboardShortcut.Modifier.CommandOrControl | WI.KeyboardShortcut.Modifier.Shift, "F", WI._focusSearchField);
     WI._findKeyboardShortcut = new WI.KeyboardShortcut(WI.KeyboardShortcut.Modifier.CommandOrControl, "F", WI._find);
@@ -307,7 +307,7 @@ WI.contentLoaded = function()
     WI._showTabAtIndexKeyboardShortcuts = [1, 2, 3, 4, 5, 6, 7, 8, 9].map((i) => new WI.KeyboardShortcut(WI.KeyboardShortcut.Modifier.CommandOrControl | WI.KeyboardShortcut.Modifier.Option, `${i}`, (event) => { WI._showTabAtIndexFromShortcut(i); }));
 
     WI.tabBrowser = new WI.TabBrowser(document.getElementById("tab-browser"), WI.tabBar, WI.navigationSidebar, WI.detailsSidebar);
-    WI.tabBrowser.addEventListener(WI.TabBrowser.Event.SelectedTabContentViewDidChange, WI._tabBrowserSelectedTabContentViewDidChange);
+    WI.tabBrowser.addEventListener(WI.TabBrowser.Event.SelectedTabContentViewDidChange, WI._tabBrowserSelectedTabContentViewDidChange, WI);
 
     WI._reloadPageKeyboardShortcut = new WI.KeyboardShortcut(WI.KeyboardShortcut.Modifier.CommandOrControl, "R", WI._reloadPage);
     WI._reloadPageFromOriginKeyboardShortcut = new WI.KeyboardShortcut(WI.KeyboardShortcut.Modifier.CommandOrControl | WI.KeyboardShortcut.Modifier.Option, "R", WI._reloadPageFromOrigin);
@@ -352,28 +352,28 @@ WI.contentLoaded = function()
 
     if (supportsDockRight || supportsDockLeft || supportsDockBottom) {
         WI._closeTabBarButton = new WI.ButtonNavigationItem("dock-close", WI.UIString("Close"), "Images/CloseLarge.svg");
-        WI._closeTabBarButton.addEventListener(WI.ButtonNavigationItem.Event.Clicked, WI.close);
+        WI._closeTabBarButton.addEventListener(WI.ButtonNavigationItem.Event.Clicked, WI.close, WI);
         dockingConfigurationNavigationItems.push(WI._closeTabBarButton);
     }
 
     if ((supportsDockRight || supportsDockLeft) && (supportsDockBottom || supportsUndocked)) {
         WI._dockToSideTabBarButton = new WI.ButtonNavigationItem("dock-right", WI.UIString("Dock to side of window"), WI.resolvedLayoutDirection() === WI.LayoutDirection.RTL ? "Images/DockLeft.svg" : "Images/DockRight.svg", 16, 16);
         WI._dockToSideTabBarButton.element.classList.add(WI.Popover.IgnoreAutoDismissClassName);
-        WI._dockToSideTabBarButton.addEventListener(WI.ButtonNavigationItem.Event.Clicked, WI.resolvedLayoutDirection() === WI.LayoutDirection.RTL ? WI._dockLeft : WI._dockRight);
+        WI._dockToSideTabBarButton.addEventListener(WI.ButtonNavigationItem.Event.Clicked, WI.resolvedLayoutDirection() === WI.LayoutDirection.RTL ? WI._dockLeft : WI._dockRight, WI);
         dockingConfigurationNavigationItems.push(WI._dockToSideTabBarButton);
     }
 
     if (supportsDockBottom && (supportsDockRight || supportsDockLeft || supportsUndocked)) {
         WI._dockBottomTabBarButton = new WI.ButtonNavigationItem("dock-bottom", WI.UIString("Dock to bottom of window"), "Images/DockBottom.svg", 16, 16);
         WI._dockBottomTabBarButton.element.classList.add(WI.Popover.IgnoreAutoDismissClassName);
-        WI._dockBottomTabBarButton.addEventListener(WI.ButtonNavigationItem.Event.Clicked, WI._dockBottom);
+        WI._dockBottomTabBarButton.addEventListener(WI.ButtonNavigationItem.Event.Clicked, WI._dockBottom, WI);
         dockingConfigurationNavigationItems.push(WI._dockBottomTabBarButton);
     }
 
     if (supportsUndocked && (supportsDockRight || supportsDockLeft || supportsDockBottom)) {
         WI._undockTabBarButton = new WI.ButtonNavigationItem("undock", WI.UIString("Detach into separate window"), "Images/Undock.svg", 16, 16);
         WI._undockTabBarButton.element.classList.add(WI.Popover.IgnoreAutoDismissClassName);
-        WI._undockTabBarButton.addEventListener(WI.ButtonNavigationItem.Event.Clicked, WI._undock);
+        WI._undockTabBarButton.addEventListener(WI.ButtonNavigationItem.Event.Clicked, WI._undock, WI);
         dockingConfigurationNavigationItems.push(WI._undockTabBarButton);
     }
 
@@ -382,7 +382,7 @@ WI.contentLoaded = function()
     let elementSelectionToolTip = WI.UIString("Start element selection (%s)").format(WI._inspectModeKeyboardShortcut.displayName);
     let activatedElementSelectionToolTip = WI.UIString("Stop element selection (%s)").format(WI._inspectModeKeyboardShortcut.displayName);
     WI._inspectModeTabBarButton = new WI.ActivateButtonNavigationItem("inspect", elementSelectionToolTip, activatedElementSelectionToolTip, "Images/Crosshair.svg");
-    WI._inspectModeTabBarButton.addEventListener(WI.ButtonNavigationItem.Event.Clicked, WI._toggleInspectMode);
+    WI._inspectModeTabBarButton.addEventListener(WI.ButtonNavigationItem.Event.Clicked, WI._toggleInspectMode, WI);
     inspectedPageControlNavigationItems.push(WI._inspectModeTabBarButton);
 
     if (InspectorFrontendHost.isRemote || WI.isDebugUIEnabled()) {
@@ -390,7 +390,7 @@ WI.contentLoaded = function()
         if (InspectorBackend.hasCommand("Page.overrideUserAgent") && InspectorBackend.hasCommand("Page.overrideSetting")) {
             const deviceSettingsTooltip = WI.UIString("Device Settings");
             WI._deviceSettingsTabBarButton = new WI.ActivateButtonNavigationItem("device-settings", deviceSettingsTooltip, deviceSettingsTooltip, "Images/Device.svg");
-            WI._deviceSettingsTabBarButton.addEventListener(WI.ButtonNavigationItem.Event.Clicked, WI._handleDeviceSettingsTabBarButtonClicked);
+            WI._deviceSettingsTabBarButton.addEventListener(WI.ButtonNavigationItem.Event.Clicked, WI._handleDeviceSettingsTabBarButtonClicked, WI);
             inspectedPageControlNavigationItems.push(WI._deviceSettingsTabBarButton);
 
             WI._deviceSettingsPopover = null;
@@ -402,11 +402,11 @@ WI.contentLoaded = function()
         else
             reloadToolTip = WI.UIString("Reload page (%s)\nReload page ignoring cache (%s)").format(WI._reloadPageKeyboardShortcut.displayName, WI._reloadPageFromOriginKeyboardShortcut.displayName);
         WI._reloadTabBarButton = new WI.ButtonNavigationItem("reload", reloadToolTip, "Images/ReloadToolbar.svg");
-        WI._reloadTabBarButton.addEventListener(WI.ButtonNavigationItem.Event.Clicked, WI._reloadTabBarButtonClicked);
+        WI._reloadTabBarButton.addEventListener(WI.ButtonNavigationItem.Event.Clicked, WI._reloadTabBarButtonClicked, WI);
         inspectedPageControlNavigationItems.push(WI._reloadTabBarButton);
 
         WI._downloadTabBarButton = new WI.ButtonNavigationItem("download", WI.UIString("Download Web Archive"), "Images/DownloadArrow.svg");
-        WI._downloadTabBarButton.addEventListener(WI.ButtonNavigationItem.Event.Clicked, WI._downloadWebArchive);
+        WI._downloadTabBarButton.addEventListener(WI.ButtonNavigationItem.Event.Clicked, WI._downloadWebArchive, WI);
         inspectedPageControlNavigationItems.push(WI._downloadTabBarButton);
     }
 
@@ -421,7 +421,7 @@ WI.contentLoaded = function()
     WI._consoleWarningsTabBarButton = new WI.ButtonNavigationItem("console-warnings", WI.UIString("0 Console warnings"), "Images/IssuesEnabled.svg");
     WI._consoleWarningsTabBarButton.imageType = WI.ButtonNavigationItem.ImageType.IMG;
     WI._consoleWarningsTabBarButton.hidden = true;
-    WI._consoleWarningsTabBarButton.addEventListener(WI.ButtonNavigationItem.Event.Clicked, () => {
+    WI._consoleWarningsTabBarButton.addEventListener(WI.ButtonNavigationItem.Event.Clicked, function(event) {
         WI.showConsoleTab(WI.LogContentView.Scopes.Warnings, {
             initiatorHint: WI.TabBrowser.TabNavigationInitiator.Dashboard,
         });
@@ -430,7 +430,7 @@ WI.contentLoaded = function()
     WI._consoleErrorsTabBarButton = new WI.ButtonNavigationItem("console-errors", WI.UIString("0 Console errors"), "Images/ErrorsEnabled.svg");
     WI._consoleErrorsTabBarButton.imageType = WI.ButtonNavigationItem.ImageType.IMG;
     WI._consoleErrorsTabBarButton.hidden = true;
-    WI._consoleErrorsTabBarButton.addEventListener(WI.ButtonNavigationItem.Event.Clicked, () => {
+    WI._consoleErrorsTabBarButton.addEventListener(WI.ButtonNavigationItem.Event.Clicked, function(event) {
         WI.showConsoleTab(WI.LogContentView.Scopes.Errors, {
             initiatorHint: WI.TabBrowser.TabNavigationInitiator.Dashboard,
         });
@@ -535,9 +535,9 @@ WI.contentLoaded = function()
     }
 
     // Listen to the events after restoring the saved tabs to avoid recursion.
-    WI.tabBar.addEventListener(WI.TabBar.Event.TabBarItemAdded, WI._rememberOpenTabs);
-    WI.tabBar.addEventListener(WI.TabBar.Event.TabBarItemRemoved, WI._rememberOpenTabs);
-    WI.tabBar.addEventListener(WI.TabBar.Event.TabBarItemsReordered, WI._rememberOpenTabs);
+    WI.tabBar.addEventListener(WI.TabBar.Event.TabBarItemAdded, WI._rememberOpenTabs, WI);
+    WI.tabBar.addEventListener(WI.TabBar.Event.TabBarItemRemoved, WI._rememberOpenTabs, WI);
+    WI.tabBar.addEventListener(WI.TabBar.Event.TabBarItemsReordered, WI._rememberOpenTabs, WI);
 
     function updateConsoleSavedResultPrefixCSSVariable() {
         document.body.style.setProperty("--console-saved-result-prefix", "\"" + WI.RuntimeManager.preferredSavedResultPrefix() + "\"");
@@ -555,7 +555,7 @@ WI.contentLoaded = function()
 
     updateZoomFactorCSSVariable();
 
-    WI.settings.frontendAppearance.addEventListener(WI.Setting.Event.Changed, (event) => {
+    WI.settings.frontendAppearance.addEventListener(WI.Setting.Event.Changed, function(event) {
         InspectorFrontendHost.setForcedAppearance(WI.settings.frontendAppearance.value);
     }, WI);
 
index 447d64204181d8a0f2527e56756b89f2954a80c9..369b9d91b73b48c62852a3cb34ee5610ca8ff9cd 100644 (file)
@@ -34,108 +34,75 @@ WI.Object = class WebInspectorObject
 
     static addEventListener(eventType, listener, thisObject)
     {
-        thisObject = thisObject || null;
+        console.assert(typeof eventType === "string", this, eventType, listener, thisObject);
+        console.assert(typeof listener === "function", this, eventType, listener, thisObject);
+        console.assert(typeof thisObject === "object" || window.InspectorTest || window.ProtocolTest, this, eventType, listener, thisObject);
 
-        console.assert(eventType, "Object.addEventListener: invalid event type ", eventType, "(listener: ", listener, "thisObject: ", thisObject, ")");
-        if (!eventType)
-            return null;
+        thisObject ??= this;
 
-        console.assert(listener, "Object.addEventListener: invalid listener ", listener, "(event type: ", eventType, "thisObject: ", thisObject, ")");
-        if (!listener)
-            return null;
+        let data = {
+            listener,
+            thisObjectWeakRef: new WeakRef(thisObject),
+        };
 
-        if (!this._listeners)
-            this._listeners = new Map();
+        WI.Object._listenerThisObjectFinalizationRegistry.register(thisObject, {eventTarget: this, eventType, data}, data);
 
-        let listenersTable = this._listeners.get(eventType);
-        if (!listenersTable) {
-            listenersTable = new ListMultimap();
-            this._listeners.set(eventType, listenersTable);
-        }
+        this._listeners ??= new Multimap;
+        this._listeners.add(eventType, data);
+
+        console.assert(Array.from(this._listeners.get(eventType)).filter((item) => item.listener === listener && item.thisObjectWeakRef.deref() === thisObject).length === 1, this, eventType, listener, thisObject);
 
-        listenersTable.add(thisObject, listener);
         return listener;
     }
 
     static singleFireEventListener(eventType, listener, thisObject)
     {
-        let wrappedCallback = function() {
-            this.removeEventListener(eventType, wrappedCallback, null);
-            listener.apply(thisObject, arguments);
-        }.bind(this);
-
-        this.addEventListener(eventType, wrappedCallback, null);
+        let wrappedCallback = (...args) => {
+            this.removeEventListener(eventType, wrappedCallback, thisObject);
+            listener.apply(thisObject, args);
+        };
+        this.addEventListener(eventType, wrappedCallback, thisObject);
         return wrappedCallback;
     }
 
-    static removeEventListener(eventType, listener, thisObject)
+    static awaitEvent(eventType, thisObject)
     {
-        eventType = eventType || null;
-        listener = listener || null;
-        thisObject = thisObject || null;
-
-        if (!this._listeners)
-            return;
-
-        if (thisObject && !eventType) {
-            this._listeners.forEach(function(listenersTable) {
-                listenersTable.deleteAll(thisObject);
-            });
-
-            return;
-        }
-
-        let listenersTable = this._listeners.get(eventType);
-        if (!listenersTable || listenersTable.size === 0)
-            return;
-
-        let didDelete = listenersTable.delete(thisObject, listener);
-        console.assert(didDelete, "removeEventListener cannot remove " + eventType.toString() + " because it doesn't exist.");
+        return new Promise((resolve, reject) => {
+            this.singleFireEventListener(eventType, resolve, thisObject);
+        });
     }
 
-    static awaitEvent(eventType)
+    static removeEventListener(eventType, listener, thisObject)
     {
-        let wrapper = new WI.WrappedPromise;
-        this.singleFireEventListener(eventType, (event) => wrapper.resolve(event));
-        return wrapper.promise;
-    }
+        console.assert(this._listeners, this, eventType, listener, thisObject);
+        console.assert(typeof eventType === "string", this, eventType, listener, thisObject);
+        console.assert(typeof listener === "function", this, eventType, listener, thisObject);
+        console.assert(typeof thisObject === "object" || window.InspectorTest || window.ProtocolTest, this, eventType, listener, thisObject);
 
-    // Only used by tests.
-    static hasEventListeners(eventType)
-    {
-        if (!this._listeners)
-            return false;
+        thisObject ??= this;
 
-        let listenersTable = this._listeners.get(eventType);
-        return listenersTable && listenersTable.size > 0;
-    }
+        let listenersForEventType = this._listeners.get(eventType);
+        console.assert(listenersForEventType, this, eventType, listener, thisObject);
 
-    // This should only be used within regression tests to detect leaks.
-    static retainedObjectsWithPrototype(proto)
-    {
-        let results = new Set;
+        let didDelete = false;
+        for (let data of listenersForEventType) {
+            let unwrapped = data.thisObjectWeakRef.deref();
+            if (!unwrapped || unwrapped !== thisObject || data.listener !== listener)
+                continue;
 
-        if (this._listeners) {
-            this._listeners.forEach(function(listenersTable, eventType) {
-                listenersTable.forEach(function(pair) {
-                    let thisObject = pair[0];
-                    if (thisObject instanceof proto)
-                        results.add(thisObject);
-                });
-            });
+            if (this._listeners.delete(eventType, data))
+                didDelete = true;
+            WI.Object._listenerThisObjectFinalizationRegistry.unregister(data);
         }
-
-        return results;
+        console.assert(didDelete, this, eventType, listener, thisObject);
     }
 
     // Public
 
     addEventListener() { return WI.Object.addEventListener.apply(this, arguments); }
     singleFireEventListener() { return WI.Object.singleFireEventListener.apply(this, arguments); }
-    removeEventListener() { return WI.Object.removeEventListener.apply(this, arguments); }
     awaitEvent() { return WI.Object.awaitEvent.apply(this, arguments); }
-    hasEventListeners() { return WI.Object.hasEventListeners.apply(this, arguments); }
-    retainedObjectsWithPrototype() { return WI.Object.retainedObjectsWithPrototype.apply(this, arguments); }
+    removeEventListener() { return WI.Object.removeEventListener.apply(this, arguments); }
 
     dispatchEventToListeners(eventType, eventData)
     {
@@ -146,23 +113,22 @@ WI.Object = class WebInspectorObject
             if (!object || event._stoppedPropagation)
                 return;
 
-            let listenerTypesMap = object._listeners;
-            if (!listenerTypesMap || !object.hasOwnProperty("_listeners"))
+            let listeners = object._listeners;
+            if (!listeners || !object.hasOwnProperty("_listeners") || !listeners.size)
                 return;
 
-            console.assert(listenerTypesMap instanceof Map);
-
-            let listenersTable = listenerTypesMap.get(eventType);
-            if (!listenersTable)
+            let listenersForEventType = listeners.get(eventType);
+            if (!listenersForEventType)
                 return;
 
-            // Make a copy with slice so mutations during the loop doesn't affect us.
-            let listeners = listenersTable.toArray();
+            // Copy the set of listeners so we don't have to worry about mutating while iterating.
+            for (let data of Array.from(listenersForEventType)) {
+                let unwrapped = data.thisObjectWeakRef.deref();
+                if (!unwrapped)
+                    continue;
+
+                data.listener.call(unwrapped, event);
 
-            // Iterate over the listeners and call them. Stop if stopPropagation is called.
-            for (let i = 0, length = listeners.length; i < length; ++i) {
-                let [thisObject, listener] = listeners[i];
-                listener.call(thisObject, event);
                 if (event._stoppedPropagation)
                     break;
             }
@@ -187,8 +153,37 @@ WI.Object = class WebInspectorObject
 
         return event.defaultPrevented;
     }
+
+    // Test
+
+    static hasEventListeners(eventType)
+    {
+        console.assert(window.InspectorTest || window.ProtocolTest);
+        return this._listeners?.has(eventType);
+    }
+
+    static activelyListeningObjectsWithPrototype(proto)
+    {
+        console.assert(window.InspectorTest || window.ProtocolTest);
+        let results = new Set;
+        if (this._listeners) {
+            for (let data of this._listeners.values()) {
+                let unwrapped = data.thisObjectWeakRef.deref();
+                if (unwrapped instanceof proto)
+                    results.add(unwrapped);
+            }
+        }
+        return results;
+    }
+
+    hasEventListeners() { return WI.Object.hasEventListeners.apply(this, arguments); }
+    activelyListeningObjectsWithPrototype() { return WI.Object.activelyListeningObjectsWithPrototype.apply(this, arguments); }
 };
 
+WI.Object._listenerThisObjectFinalizationRegistry = new FinalizationRegistry((heldValue) => {
+    heldValue.eventTarget._listeners.delete(heldValue.eventType, heldValue.data);
+});
+
 WI.Event = class Event
 {
     constructor(target, type, data)
index d1e34ae1256b1a51a09203b3a60887caabb6aa36..b7d1b13adf9a1c3a2cf6c6f1fc10008f001cfccf 100644 (file)
@@ -32,18 +32,15 @@ WI.SearchUtilities = class SearchUtilities {
         };
     }
 
-    static createSettings(namePrefix, options = {})
+    static createSettings(namePrefix)
     {
         let settings = {};
         for (let [key, defaultSetting] of Object.entries(WI.SearchUtilities.defaultSettings)) {
             let setting = new WI.Setting(namePrefix + "-" + defaultSetting.name, defaultSetting.value);
-            defaultSetting.addEventListener(WI.Setting.Event.Changed, (event) => {
-                setting.value = defaultSetting.value;
-            });
+            defaultSetting.addEventListener(WI.Setting.Event.Changed, function(event) {
+                this.value = defaultSetting.value;
+            }, setting);
             settings[key] = setting;
-
-            if (options.handleChanged)
-                setting.addEventListener(WI.Setting.Event.Changed, options.handleChanged);
         }
         return settings;
     }
@@ -84,8 +81,8 @@ WI.SearchUtilities = class SearchUtilities {
         function toggleActive() {
             button.classList.toggle("active", Object.values(settings).some((setting) => !!setting.value));
         }
-        settings.caseSensitive.addEventListener(WI.Setting.Event.Changed, toggleActive);
-        settings.regularExpression.addEventListener(WI.Setting.Event.Changed, toggleActive);
+        settings.caseSensitive.addEventListener(WI.Setting.Event.Changed, toggleActive, button);
+        settings.regularExpression.addEventListener(WI.Setting.Event.Changed, toggleActive, button);
         toggleActive();
 
         return button;
index 69bba8137fd1021913f4fac9edeacad974851fa9..4d19d8aad3eb68883e1d42b848dc807e1f0313c3 100644 (file)
@@ -101,7 +101,8 @@ WI.ApplicationCacheManager = class ApplicationCacheManager extends WI.Object
                 target.ApplicationCacheAgent.disable();
         }
 
-        WI.Frame.removeEventListener(null, null, this);
+        WI.Frame.removeEventListener(WI.Frame.Event.MainResourceDidChange, this._mainResourceDidChange, this);
+        WI.Frame.removeEventListener(WI.Frame.Event.ChildFrameWasRemoved, this._childFrameWasRemoved, this);
 
         this._reset();
     }
index 0db5ac47c00817e58afb891f848d225d84bbdae2..8744a19b82f0f7336079be994a3536b7c58a1f76 100644 (file)
@@ -64,7 +64,10 @@ WI.CallFrameTreeController = class CallFrameTreeController extends WI.Object
 
     disconnect()
     {
-        this._treeOutline.removeEventListener(null, null, this);
+        if (this._treeOutline.selectable)
+            this._treeOutline.removeEventListener(WI.TreeOutline.Event.SelectionDidChange, this._treeSelectionDidChange, this);
+        else
+            this._treeOutline.removeEventListener(WI.TreeOutline.Event.ElementClicked, this._treeElementClicked, this);
     }
 
     // Private
index 62d99cc1e0176963f7ac725b5d01b941e297b909..b740923856577fed3417aa43da11fb2fbbb09c53 100644 (file)
@@ -99,7 +99,8 @@ WI.DOMStorageManager = class DOMStorageManager extends WI.Object
                 target.DOMStorageAgent.disable();
         }
 
-        WI.Frame.removeEventListener(null, null, this);
+        WI.Frame.removeEventListener(WI.Frame.Event.MainResourceDidChange, this._mainResourceDidChange, this);
+        WI.Frame.removeEventListener(WI.Frame.Event.SecurityOriginDidChange, this._securityOriginDidChange, this);
 
         this._reset();
     }
index 3bb61a497681b9dfafb78f7a38d4cd1a8de982ac..bc27c68cc136b9d04b25ef3b505b028740e16030 100644 (file)
@@ -90,7 +90,7 @@ WI.DatabaseManager = class DatabaseManager extends WI.Object
                 target.DatabaseAgent.disable();
         }
 
-        WI.Frame.removeEventListener(null, null, this);
+        WI.Frame.removeEventListener(WI.Frame.Event.MainResourceDidChange, this._mainResourceDidChange, this);
 
         this._reset();
     }
index 07cd2b36cf6bb691598ed2e6af728058927ad67e..eaf39d96e3cc0faeb73aa321139b76749073171b 100644 (file)
@@ -563,17 +563,10 @@ WI.DebuggerManager = class DebuggerManager extends WI.Object
 
         this.dispatchEventToListeners(WI.DebuggerManager.Event.WaitingToPause);
 
-        let listener = new WI.EventListener(this, true);
-
-        let managerResult = new Promise(function(resolve, reject) {
-            listener.connect(WI.debuggerManager, WI.DebuggerManager.Event.Paused, resolve);
-        });
-
-        let promises = [];
-        for (let [target, targetData] of this._targetDebuggerDataMap)
+        let promises = [this.awaitEvent(WI.DebuggerManager.Event.Paused, this)];
+        for (let targetData of this._targetDebuggerDataMap.values())
             promises.push(targetData.pauseIfNeeded());
-
-        return Promise.all([managerResult, ...promises]);
+        return Promise.all(promises);
     }
 
     resume()
@@ -581,17 +574,10 @@ WI.DebuggerManager = class DebuggerManager extends WI.Object
         if (!this.paused)
             return Promise.resolve();
 
-        let listener = new WI.EventListener(this, true);
-
-        let managerResult = new Promise(function(resolve, reject) {
-            listener.connect(WI.debuggerManager, WI.DebuggerManager.Event.Resumed, resolve);
-        });
-
-        let promises = [];
-        for (let [target, targetData] of this._targetDebuggerDataMap)
+        let promises = [this.awaitEvent(WI.DebuggerManager.Event.Resumed, this)];
+        for (let targetData of this._targetDebuggerDataMap.values())
             promises.push(targetData.resumeIfNeeded());
-
-        return Promise.all([managerResult, ...promises]);
+        return Promise.all(promises);
     }
 
     stepNext()
@@ -599,20 +585,10 @@ WI.DebuggerManager = class DebuggerManager extends WI.Object
         if (!this.paused)
             return Promise.reject(new Error("Cannot step next because debugger is not paused."));
 
-        let listener = new WI.EventListener(this, true);
-
-        let managerResult = new Promise(function(resolve, reject) {
-            listener.connect(WI.debuggerManager, WI.DebuggerManager.Event.ActiveCallFrameDidChange, resolve);
-        });
-
-        let protocolResult = this._activeCallFrame.target.DebuggerAgent.stepNext()
-            .catch(function(error) {
-                listener.disconnect();
-                console.error("DebuggerManager.stepNext failed: ", error);
-                throw error;
-            });
-
-        return Promise.all([managerResult, protocolResult]);
+        return Promise.all([
+            this.awaitEvent(WI.DebuggerManager.Event.ActiveCallFrameDidChange, this),
+            this._activeCallFrame.target.DebuggerAgent.stepNext(),
+        ]);
     }
 
     stepOver()
@@ -620,20 +596,10 @@ WI.DebuggerManager = class DebuggerManager extends WI.Object
         if (!this.paused)
             return Promise.reject(new Error("Cannot step over because debugger is not paused."));
 
-        let listener = new WI.EventListener(this, true);
-
-        let managerResult = new Promise(function(resolve, reject) {
-            listener.connect(WI.debuggerManager, WI.DebuggerManager.Event.ActiveCallFrameDidChange, resolve);
-        });
-
-        let protocolResult = this._activeCallFrame.target.DebuggerAgent.stepOver()
-            .catch(function(error) {
-                listener.disconnect();
-                console.error("DebuggerManager.stepOver failed: ", error);
-                throw error;
-            });
-
-        return Promise.all([managerResult, protocolResult]);
+        return Promise.all([
+            this.awaitEvent(WI.DebuggerManager.Event.ActiveCallFrameDidChange, this),
+            this._activeCallFrame.target.DebuggerAgent.stepOver(),
+        ]);
     }
 
     stepInto()
@@ -641,20 +607,10 @@ WI.DebuggerManager = class DebuggerManager extends WI.Object
         if (!this.paused)
             return Promise.reject(new Error("Cannot step into because debugger is not paused."));
 
-        let listener = new WI.EventListener(this, true);
-
-        let managerResult = new Promise(function(resolve, reject) {
-            listener.connect(WI.debuggerManager, WI.DebuggerManager.Event.ActiveCallFrameDidChange, resolve);
-        });
-
-        let protocolResult = this._activeCallFrame.target.DebuggerAgent.stepInto()
-            .catch(function(error) {
-                listener.disconnect();
-                console.error("DebuggerManager.stepInto failed: ", error);
-                throw error;
-            });
-
-        return Promise.all([managerResult, protocolResult]);
+        return Promise.all([
+            this.awaitEvent(WI.DebuggerManager.Event.ActiveCallFrameDidChange, this),
+            this._activeCallFrame.target.DebuggerAgent.stepInto(),
+        ]);
     }
 
     stepOut()
@@ -662,20 +618,10 @@ WI.DebuggerManager = class DebuggerManager extends WI.Object
         if (!this.paused)
             return Promise.reject(new Error("Cannot step out because debugger is not paused."));
 
-        let listener = new WI.EventListener(this, true);
-
-        let managerResult = new Promise(function(resolve, reject) {
-            listener.connect(WI.debuggerManager, WI.DebuggerManager.Event.ActiveCallFrameDidChange, resolve);
-        });
-
-        let protocolResult = this._activeCallFrame.target.DebuggerAgent.stepOut()
-            .catch(function(error) {
-                listener.disconnect();
-                console.error("DebuggerManager.stepOut failed: ", error);
-                throw error;
-            });
-
-        return Promise.all([managerResult, protocolResult]);
+        return Promise.all([
+            this.awaitEvent(WI.DebuggerManager.Event.ActiveCallFrameDidChange, this),
+            this._activeCallFrame.target.DebuggerAgent.stepOut(),
+        ]);
     }
 
     continueUntilNextRunLoop(target)
index f047d4eface289a95ce426255ef4682651d3d109..b6a4bbcbe45dab77257a092e6dccbd32809e1834 100644 (file)
@@ -93,7 +93,8 @@ WI.IndexedDBManager = class IndexedDBManager extends WI.Object
                 target.IndexedDBAgent.disable();
         }
 
-        WI.Frame.removeEventListener(null, null, this);
+        WI.Frame.removeEventListener(WI.Frame.Event.MainResourceDidChange, this._mainResourceDidChange, this);
+        WI.Frame.removeEventListener(WI.Frame.Event.SecurityOriginDidChange, this._securityOriginDidChange, this);
 
         this._reset();
     }
index f30f52ccbd1bc38700d0aa722b43b086584df17d..6ebfcd46a7c47a96a7f99b00516e414d5d505270 100644 (file)
@@ -31,13 +31,13 @@ WI.RuntimeManager = class RuntimeManager extends WI.Object
 
         this._activeExecutionContext = null;
 
-        WI.settings.consoleSavedResultAlias.addEventListener(WI.Setting.Event.Changed, (event) => {
+        WI.settings.consoleSavedResultAlias.addEventListener(WI.Setting.Event.Changed, function(event) {
             for (let target of WI.targets) {
                 // COMPATIBILITY (iOS 12.2): Runtime.setSavedResultAlias did not exist.
                 if (target.hasCommand("Runtime.setSavedResultAlias"))
                     target.RuntimeAgent.setSavedResultAlias(WI.settings.consoleSavedResultAlias.value);
             }
-        });
+        }, this);
     }
 
     // Static
@@ -285,7 +285,7 @@ WI.RuntimeManager.ConsoleObjectGroup = "console";
 WI.RuntimeManager.TopLevelExecutionContextIdentifier = undefined;
 
 WI.RuntimeManager.Event = {
-    DidEvaluate: Symbol("runtime-manager-did-evaluate"),
-    DefaultExecutionContextChanged: Symbol("runtime-manager-default-execution-context-changed"),
-    ActiveExecutionContextChanged: Symbol("runtime-manager-active-execution-context-changed"),
+    DidEvaluate: "runtime-manager-did-evaluate",
+    DefaultExecutionContextChanged: "runtime-manager-default-execution-context-changed",
+    ActiveExecutionContextChanged: "runtime-manager-active-execution-context-changed",
 };
index d69cc8523690a6135f2777bd4fd3693ec110f644..bebd4d54ab95f91973769c23ec770d403845e852 100644 (file)
@@ -306,7 +306,7 @@ WI.TargetManager = class TargetManager extends WI.Object
 };
 
 WI.TargetManager.Event = {
-    TargetAdded: Symbol("target-manager-target-added"),
-    TargetRemoved: Symbol("target-manager-target-removed"),
+    TargetAdded: "target-manager-target-added",
+    TargetRemoved: "target-manager-target-removed",
     DidCommitProvisionalTarget: "target-manager-provisional-target-committed",
 };
index f5028be5693ef0c2b54e1e253c64c8cf2d372d80..bcdc9b58696ec0209b919b38addc5f44bfcaeccd 100644 (file)
@@ -445,12 +445,17 @@ WI.TimelineManager = class TimelineManager extends WI.Object
         if (this._capturingState === TimelineManager.CapturingState.Inactive)
             return;
 
-        WI.DOMNode.removeEventListener(null, null, this);
-        WI.memoryManager.removeEventListener(null, null, this);
-        WI.heapManager.removeEventListener(null, null, this);
+        WI.DOMNode.removeEventListener(WI.DOMNode.Event.DidFireEvent, this._handleDOMNodeDidFireEvent, this);
+        WI.DOMNode.removeEventListener(WI.DOMNode.Event.PowerEfficientPlaybackStateChanged, this._handleDOMNodePowerEfficientPlaybackStateChanged, this);
+
+        WI.heapManager.removeEventListener(WI.HeapManager.Event.GarbageCollected, this._garbageCollected, this);
+
+        WI.memoryManager.removeEventListener(WI.MemoryManager.Event.MemoryPressure, this._memoryPressure, this);
+
         WI.Target.removeEventListener(WI.Target.Event.ResourceAdded, this._resourceWasAdded, this);
         WI.Frame.removeEventListener(WI.Frame.Event.ResourceWasAdded, this._resourceWasAdded, this);
-        WI.settings.timelinesAutoStop.removeEventListener(null, null, this);
+
+        WI.settings.timelinesAutoStop.removeEventListener(WI.Setting.Event.Changed, this._handleTimelinesAutoStopSettingChanged, this);
 
         this._activeRecording.capturingStopped(this._capturingEndTime);
 
index 826fc1532dcd8de9e60a189f9aa7d7d1e19e5913..c8b1c768a87d65bfc14c5c71c782170f9e1bd8ee 100644 (file)
 WI.isEngineeringBuild = true;
 
 // Disable Pause in Internal Scripts if Show Internal Scripts is dibbled.
-WI.settings.engineeringShowInternalScripts.addEventListener(WI.Setting.Event.Changed, (event) => {
+WI.settings.engineeringShowInternalScripts.addEventListener(WI.Setting.Event.Changed, function(event) {
     if (!WI.settings.engineeringShowInternalScripts.value)
         WI.settings.engineeringPauseForInternalScripts.value = false;
 }, WI.settings.engineeringPauseForInternalScripts);
 
 // Enable Show Internal Scripts if Pause in Internal Scripts is enabled.
-WI.settings.engineeringPauseForInternalScripts.addEventListener(WI.Setting.Event.Changed, (event) => {
+WI.settings.engineeringPauseForInternalScripts.addEventListener(WI.Setting.Event.Changed, function(event) {
     if (WI.settings.engineeringPauseForInternalScripts.value)
         WI.settings.engineeringShowInternalScripts.value = true;
 }, WI.settings.engineeringShowInternalScripts);
@@ -91,7 +91,7 @@ WI.runBootstrapOperations = function() {
         ignoreChangesToState = false;
     }
 
-    dumpMessagesTabBarNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, () => {
+    dumpMessagesTabBarNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, function(event) {
         let nextState;
         switch (dumpMessagesCurrentState()) {
         case DumpMessagesState.Off:
@@ -105,12 +105,12 @@ WI.runBootstrapOperations = function() {
             break;
         }
         applyDumpMessagesState(nextState);
-    });
-    WI.settings.protocolAutoLogMessages.addEventListener(WI.Setting.Event.Changed, () => {
+    }, dumpMessagesTabBarNavigationItem);
+    WI.settings.protocolAutoLogMessages.addEventListener(WI.Setting.Event.Changed, function(event) {
         if (ignoreChangesToState)
             return;
         applyDumpMessagesState(dumpMessagesCurrentState());
-    });
+    }, dumpMessagesTabBarNavigationItem);
     applyDumpMessagesState(dumpMessagesCurrentState());
 
     // Next Level Inspector.
@@ -118,9 +118,9 @@ WI.runBootstrapOperations = function() {
     const inspectInspectorToolTip = WI.unlocalizedString("Open Web Inspector [%d]").format(inspectionLevel + 1);
     let inspectInspectorTabBarNavigationItem = new WI.ButtonNavigationItem("inspect-inspector", inspectInspectorToolTip);
     inspectInspectorTabBarNavigationItem.element.textContent = inspectionLevel + 1;
-    inspectInspectorTabBarNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, () => {
+    inspectInspectorTabBarNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, function(event) {
         InspectorFrontendHost.inspectInspector();
-    });
+    }, inspectInspectorTabBarNavigationItem);
 
     let groupNavigationItem = new WI.GroupNavigationItem([
         dumpMessagesTabBarNavigationItem,
@@ -132,9 +132,7 @@ WI.runBootstrapOperations = function() {
     function setFocusDebugOutline() {
         document.body.classList.toggle("focus-debug", WI.settings.debugOutlineFocusedElement.value);
     }
-
-    WI.settings.debugOutlineFocusedElement.addEventListener(WI.Setting.Event.Changed, setFocusDebugOutline);
-
+    WI.settings.debugOutlineFocusedElement.addEventListener(WI.Setting.Event.Changed, setFocusDebugOutline, WI.settings.debugOutlineFocusedElement);
     setFocusDebugOutline();
 
     function updateDebugUI() {
@@ -142,9 +140,9 @@ WI.runBootstrapOperations = function() {
         WI.tabBar.needsLayout();
     }
 
-    WI.showDebugUISetting.addEventListener(WI.Setting.Event.Changed, () => {
+    WI.showDebugUISetting.addEventListener(WI.Setting.Event.Changed, function(event) {
         updateDebugUI();
-    });
+    }, groupNavigationItem);
 
     updateDebugUI();
 };
index d998d7ceed77ac98f9c3b5d2dcf0e541d9a93c2a..fae3cf8726c08776ef032a5fa49bb526dec450b8 100644 (file)
     <script src="Base/Platform.js"></script>
     <script src="Base/Debouncer.js"></script>
     <script src="Base/DebuggableType.js"></script>
-    <script src="Base/LinkedList.js"></script>
-    <script src="Base/ListMultimap.js"></script>
     <script src="Base/Multimap.js"></script>
     <script src="Base/Object.js"></script>
     <script src="Base/ReferencePage.js"></script>
 
     <script src="Base/BlobUtilities.js"></script>
     <script src="Base/DOMUtilities.js"></script>
-    <script src="Base/EventListener.js"></script>
-    <script src="Base/EventListenerSet.js"></script>
     <script src="Base/FileUtilities.js"></script>
     <script src="Base/HTTPUtilities.js"></script>
     <script src="Base/ImageUtilities.js"></script>
index 6757176280b2605be2e2d7ce4816c8a0216f7bc0..6d98099270f71208adf4be0c59647411ed908b2f 100644 (file)
@@ -47,6 +47,9 @@ WI.DOMNodeStyles = class DOMNodeStyles extends WI.Object
 
         this._pendingRefreshTask = null;
         this.refresh();
+
+        this._trackedStyleSheets = new WeakSet;
+        WI.CSSStyleSheet.addEventListener(WI.CSSStyleSheet.Event.ContentDidChange, this._handleCSSStyleSheetContentDidChange, this);
     }
 
     // Static
@@ -607,7 +610,7 @@ WI.DOMNodeStyles = class DOMNodeStyles extends WI.Object
         if (styleSheet) {
             if (type === WI.CSSStyleDeclaration.Type.Inline)
                 styleSheet.markAsInlineStyleAttributeStyleSheet();
-            styleSheet.addEventListener(WI.CSSStyleSheet.Event.ContentDidChange, this._styleSheetContentDidChange, this);
+            this._trackedStyleSheets.add(styleSheet);
         }
 
         if (inherited && !inheritedPropertyCount)
@@ -696,7 +699,7 @@ WI.DOMNodeStyles = class DOMNodeStyles extends WI.Object
         }
 
         if (styleSheet)
-            styleSheet.addEventListener(WI.CSSStyleSheet.Event.ContentDidChange, this._styleSheetContentDidChange, this);
+            this._trackedStyleSheets.add(styleSheet);
 
         rule = new WI.CSSRule(this, styleSheet, id, type, sourceCodeLocation, selectorText, selectors, matchedSelectorIndices, style, groupings);
 
@@ -712,11 +715,10 @@ WI.DOMNodeStyles = class DOMNodeStyles extends WI.Object
         this.dispatchEventToListeners(WI.DOMNodeStyles.Event.NeedsRefresh);
     }
 
-    _styleSheetContentDidChange(event)
+    _handleCSSStyleSheetContentDidChange(event)
     {
-        var styleSheet = event.target;
-        console.assert(styleSheet);
-        if (!styleSheet)
+        let styleSheet = event.target;
+        if (!this._trackedStyleSheets.has(styleSheet))
             return;
 
         // Ignore the stylesheet we know we just changed and handled above.
index 2b6ef88e78cc72a20723995446b43d7e91bdde07..27a44e8623f353b446763169d1bb7bbd4f1f5cc2 100644 (file)
@@ -51,8 +51,14 @@ WI.DOMTree = class DOMTree extends WI.Object
 
     disconnect()
     {
-        WI.domManager.removeEventListener(null, null, this);
-        this._frame.removeEventListener(null, null, this);
+        this._frame.removeEventListener(WI.Frame.Event.PageExecutionContextChanged, this._framePageExecutionContextChanged, this);
+
+        WI.domManager.removeEventListener(WI.DOMManager.Event.DocumentUpdated, this._documentUpdated, this);
+
+        if (!this._frame.isMainFrame()) {
+            WI.domManager.removeEventListener(WI.DOMManager.Event.NodeRemoved, this._nodeRemoved, this);
+            this._frame.removeEventListener(WI.Frame.Event.MainResourceDidChange, this._frameMainResourceDidChange, this);
+        }
     }
 
     invalidate()
index 98addb42b2d2c46b0fd30dafb9c4a712dec08a7b..6b9eef965f25869cfa2a83291817835c21aaa546 100644 (file)
@@ -1034,8 +1034,8 @@ WI.Resource = class Resource extends WI.SourceCode
 
         if (!this._finishThenRequestContentPromise) {
             this._finishThenRequestContentPromise = new Promise((resolve, reject) => {
-                this.addEventListener(WI.Resource.Event.LoadingDidFinish, resolve);
-                this.addEventListener(WI.Resource.Event.LoadingDidFail, reject);
+                this.singleFireEventListener(WI.Resource.Event.LoadingDidFinish, resolve, this);
+                this.singleFireEventListener(WI.Resource.Event.LoadingDidFail, reject, this);
             }).then(this.requestContent.bind(this));
         }
 
index c785d2c449b81211b6bd2aa0c405fadf3e57e2e0..3a8adcea892b70925546aa0726e354dcf1ae5bd2 100644 (file)
@@ -105,8 +105,8 @@ WI.WebSocketResource = class WebSocketResource extends WI.Resource
 };
 
 WI.WebSocketResource.Event = {
-    FrameAdded: Symbol("web-socket-frame-added"),
-    ReadyStateChanged: Symbol("web-socket-resource-ready-state-changed"),
+    FrameAdded: "web-socket-frame-added",
+    ReadyStateChanged: "web-socket-resource-ready-state-changed",
 };
 
 WI.WebSocketResource.ReadyState = {
index d4c0a882d562460e03dca7c600cb48bbdf598e03..73ee3f900f705e8edc599aed9bfc4f866282bed2 100644 (file)
@@ -23,8 +23,6 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-// Events dispatched on this class: "HeapSnapshot.CollectionEvent"
-
 WI.HeapSnapshotWorkerProxy = class HeapSnapshotWorkerProxy extends WI.Object
 {
     constructor()
@@ -146,3 +144,7 @@ WI.HeapSnapshotWorkerProxy = class HeapSnapshotWorkerProxy extends WI.Object
         console.error("Unexpected HeapSnapshotWorker message", data);
     }
 };
+
+WI.HeapSnapshotWorkerProxy.Event = {
+    Collection: "heap-snapshot-collection",
+};
index 294263831b836b99949b739e60f00157cda30cdd..8b8462f8947ca9551cb7e3f6ae4896379433bd1e 100644 (file)
@@ -39,8 +39,6 @@
     <script src="Base/Platform.js"></script>
     <script src="Base/Debouncer.js"></script>
     <script src="Base/DebuggableType.js"></script>
-    <script src="Base/LinkedList.js"></script>
-    <script src="Base/ListMultimap.js"></script>
     <script src="Base/Multimap.js"></script>
     <script src="Base/Object.js"></script>
     <script src="Base/ReferencePage.js"></script>
@@ -58,8 +56,6 @@
 
     <script src="Base/BlobUtilities.js"></script>
     <script src="Base/DOMUtilities.js"></script>
-    <script src="Base/EventListener.js"></script>
-    <script src="Base/EventListenerSet.js"></script>
     <script src="Base/FileUtilities.js"></script>
     <script src="Base/ImageUtilities.js"></script>
     <script src="Base/MIMETypeUtilities.js"></script>
index 3f522e9f64c29e2886391b656cd647d530741166..2f8406870ffa16a363b899a654ffe09261b1b2ff 100644 (file)
@@ -30,8 +30,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     These resources should match the order and groups used in Main.html and Test.html.
     -->
     <script src="Base/WebInspector.js"></script>
-    <script src="Base/LinkedList.js"></script>
-    <script src="Base/ListMultimap.js"></script>
+    <script src="Base/Multimap.js"></script>
     <script src="Base/Object.js"></script>
     <script src="Base/Utilities.js"></script>
 
index 2c9941b0cac50ecc3b742b5a7a4a6c2060aa78f9..e7cdb14b3fd1386e335920ec5ee40178da3c00e2 100644 (file)
@@ -74,7 +74,10 @@ WI.ApplicationCacheDetailsSidebarPanel = class ApplicationCacheDetailsSidebarPan
 
     closed()
     {
-        WI.applicationCacheManager.removeEventListener(null, null, this);
+        if (this.didInitialLayout) {
+            WI.applicationCacheManager.removeEventListener(WI.ApplicationCacheManager.Event.NetworkStateUpdated, this._networkStateUpdated, this);
+            WI.applicationCacheManager.removeEventListener(WI.ApplicationCacheManager.Event.FrameManifestStatusChanged, this._frameManifestStatusChanged, this);
+        }
 
         super.closed();
     }
index 5e7ba34e43528c60e0c9d6e5390990c6360a0a48..c75095f96c405a87dc16fd17f60f097ef45be5db 100644 (file)
@@ -56,7 +56,7 @@ WI.ApplicationCacheFrameContentView = class ApplicationCacheFrameContentView ext
 
     closed()
     {
-        WI.applicationCacheManager.removeEventListener(null, null, this);
+        WI.applicationCacheManager.removeEventListener(WI.ApplicationCacheManager.Event.FrameManifestStatusChanged, this._updateStatus, this);
 
         super.closed();
     }
index c13bd8f1ad0a999078481120b6f89a2b9ca84b96..8ba151fe4d40a1d14d74090bea94d278b6b0ee18 100644 (file)
@@ -185,7 +185,14 @@ WI.AuditNavigationSidebarPanel = class AuditNavigationSidebarPanel extends WI.Na
     {
         super.closed();
 
-        WI.auditManager.removeEventListener(null, null, this);
+        if (this.didInitialLayout) {
+            WI.auditManager.removeEventListener(WI.AuditManager.Event.EditingChanged, this._handleAuditManagerEditingChanged, this);
+            WI.auditManager.removeEventListener(WI.AuditManager.Event.RunningStateChanged, this._handleAuditManagerRunningStateChanged, this);
+            WI.auditManager.removeEventListener(WI.AuditManager.Event.TestAdded, this._handleAuditTestAdded, this);
+            WI.auditManager.removeEventListener(WI.AuditManager.Event.TestCompleted, this._handleAuditTestCompleted, this);
+            WI.auditManager.removeEventListener(WI.AuditManager.Event.TestRemoved, this._handleAuditTestRemoved, this);
+            WI.auditManager.removeEventListener(WI.AuditManager.Event.TestScheduled, this._handleAuditTestScheduled, this);
+        }
     }
 
     updateFilter()
index 14bc7aba1736ebdfa06d9f105f6c099e0a1d9d0b..a9998aef7c3183bdc09a310755c0e5a05bc28b37 100644 (file)
@@ -338,9 +338,9 @@ WI.AuditTestCaseContentView = class AuditTestCaseContentView extends WI.AuditTes
 
             let stopAuditNavigationItem = new WI.ButtonNavigationItem("stop-audit", WI.UIString("Stop"), "Images/AuditStop.svg", 13, 13);
             stopAuditNavigationItem.buttonStyle = WI.ButtonNavigationItem.Style.ImageAndText;
-            stopAuditNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, (event) => {
+            stopAuditNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, function(event) {
                 WI.auditManager.stop();
-            }, WI.auditManager);
+            }, stopAuditNavigationItem);
 
             let stopAuditHelpElement = WI.createNavigationItemHelp(WI.UIString("Press %s to stop running."), stopAuditNavigationItem);
             this.placeholderElement.appendChild(stopAuditHelpElement);
index 305103fc8bba2d4483bc3a6b9f82afd1ffe96f2d..37403dd675cd20fb549733a1e85b8881435158dc 100644 (file)
@@ -344,9 +344,9 @@ WI.AuditTestContentView = class AuditTestContentView extends WI.ContentView
 
             let startNavigationItem = new WI.ButtonNavigationItem("run-audit", WI.UIString("Start"), "Images/AuditStart.svg", 15, 15);
             startNavigationItem.buttonStyle = WI.ButtonNavigationItem.Style.ImageAndText;
-            startNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, () => {
+            startNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, function(event) {
                 WI.auditManager.start([this.representedObject]);
-            });
+            }, startNavigationItem);
 
             let importHelpElement = WI.createNavigationItemHelp(WI.UIString("Press %s to start running the audit."), startNavigationItem);
             this.placeholderElement.appendChild(importHelpElement);
index 38c835d62867950bbaf6b2172be9d835c446861e..6f1e667dd4208fe154894e61efb37fedad3ded0d 100644 (file)
@@ -262,9 +262,9 @@ WI.AuditTestGroupContentView = class AuditTestGroupContentView extends WI.AuditT
 
             let stopAuditNavigationItem = new WI.ButtonNavigationItem("stop-audit", WI.UIString("Stop"), "Images/AuditStop.svg", 13, 13);
             stopAuditNavigationItem.buttonStyle = WI.ButtonNavigationItem.Style.ImageAndText;
-            stopAuditNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, (event) => {
+            stopAuditNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, function(event) {
                 WI.auditManager.stop();
-            }, WI.auditManager);
+            }, stopAuditNavigationItem);
 
             let stopAuditHelpElement = WI.createNavigationItemHelp(WI.UIString("Press %s to stop running."), stopAuditNavigationItem);
             this.placeholderElement.appendChild(stopAuditHelpElement);
index 31eb7f9dd3fd8f57d60403a5c637ab56efad2e79..52e39c3fdb87741c9d099e6301b427b50dcec721 100644 (file)
@@ -97,8 +97,27 @@ WI.AuditTreeElement = class AuditTreeElement extends WI.GeneralTreeElement
 
     ondetach()
     {
-        WI.auditManager.removeEventListener(null, null, this);
-        this.representedObject.removeEventListener(null, null, this);
+        if (this.representedObject instanceof WI.AuditTestBase) {
+            this.representedObject.removeEventListener(WI.AuditTestBase.Event.DisabledChanged, this._handleTestDisabledChanged, this);
+            this.representedObject.removeEventListener(WI.AuditTestBase.Event.ResultChanged, this._handleTestResultChanged, this);
+
+            if (this.representedObject instanceof WI.AuditTestCase)
+                this.representedObject.removeEventListener(WI.AuditTestBase.Event.Scheduled, this._handleTestCaseScheduled, this);
+            else if (this.representedObject instanceof WI.AuditTestGroup)
+                this.representedObject.removeEventListener(WI.AuditTestBase.Event.Scheduled, this._handleTestGroupScheduled, this);
+
+            if (this.representedObject.editable) {
+                this.representedObject.removeEventListener(WI.AuditTestBase.Event.NameChanged, this._handleTestNameChanged, this);
+                this.representedObject.removeEventListener(WI.AuditTestBase.Event.SupportedChanged, this._handleTestSupportedChanged, this);
+
+                if (this.representedObject instanceof WI.AuditTestGroup)
+                    this.representedObject.removeEventListener(WI.AuditTestGroup.Event.TestAdded, this._handleTestGroupTestAdded, this);
+            }
+
+            WI.auditManager.removeEventListener(WI.AuditManager.Event.EditingChanged, this._handleManagerEditingChanged, this);
+            WI.auditManager.removeEventListener(WI.AuditManager.Event.TestScheduled, this._handleAuditManagerTestScheduled, this);
+            WI.auditManager.removeEventListener(WI.AuditManager.Event.TestCompleted, this._handleAuditManagerTestCompleted, this);
+        }
 
         super.ondetach();
     }
index dd5e6ab0212e1489ef8c9df5c69e27e7b6518e2c..880c8db9b362bfeb04a9f8e3a147ae5062eb14ae 100644 (file)
@@ -41,18 +41,10 @@ WI.BreakpointTreeElement = class BreakpointTreeElement extends WI.GeneralTreeEle
         this._breakpoint = breakpoint;
         this._probeSet = null;
 
-        this._listenerSet = new WI.EventListenerSet(this, "BreakpointTreeElement listeners");
-        this._listenerSet.register(breakpoint, WI.Breakpoint.Event.DisabledStateDidChange, this.updateStatus);
-        this._listenerSet.register(breakpoint, WI.Breakpoint.Event.AutoContinueDidChange, this.updateStatus);
-        this._listenerSet.register(WI.debuggerManager, WI.DebuggerManager.Event.BreakpointsEnabledDidChange, this.updateStatus);
-        this._listenerSet.register(WI.debuggerManager, WI.DebuggerManager.Event.ProbeSetAdded, this._probeSetAdded);
-        this._listenerSet.register(WI.debuggerManager, WI.DebuggerManager.Event.ProbeSetRemoved, this._probeSetRemoved);
-
         this.status = WI.ImageUtilities.useSVGSymbol("Images/Breakpoint.svg");
         this.status.className = "status-image";
-
-        this._listenerSet.register(this.status, "mousedown", this._statusImageElementMouseDown);
-        this._listenerSet.register(this.status, "click", this._statusImageElementClicked);
+        this.status.addEventListener("mousedown", this._statusImageElementMouseDown.bind(this));
+        this.status.addEventListener("click", this._statusImageElementClicked.bind(this));
 
         this.updateStatus();
 
@@ -105,7 +97,12 @@ WI.BreakpointTreeElement = class BreakpointTreeElement extends WI.GeneralTreeEle
     {
         super.onattach();
 
-        this._listenerSet.install();
+        this._breakpoint.addEventListener(WI.Breakpoint.Event.DisabledStateDidChange, this.updateStatus, this);
+        this._breakpoint.addEventListener(WI.Breakpoint.Event.AutoContinueDidChange, this.updateStatus, this);
+
+        WI.debuggerManager.addEventListener(WI.DebuggerManager.Event.BreakpointsEnabledDidChange, this.updateStatus, this);
+        WI.debuggerManager.addEventListener(WI.DebuggerManager.Event.ProbeSetAdded, this._probeSetAdded, this);
+        WI.debuggerManager.addEventListener(WI.DebuggerManager.Event.ProbeSetRemoved, this._probeSetRemoved, this);
 
         for (var probeSet of WI.debuggerManager.probeSets)
             if (probeSet.breakpoint === this._breakpoint)
@@ -116,7 +113,12 @@ WI.BreakpointTreeElement = class BreakpointTreeElement extends WI.GeneralTreeEle
     {
         super.ondetach();
 
-        this._listenerSet.uninstall();
+        this._breakpoint.removeEventListener(WI.Breakpoint.Event.DisabledStateDidChange, this.updateStatus, this);
+        this._breakpoint.removeEventListener(WI.Breakpoint.Event.AutoContinueDidChange, this.updateStatus, this);
+
+        WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.BreakpointsEnabledDidChange, this.updateStatus, this);
+        WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.ProbeSetAdded, this._probeSetAdded, this);
+        WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.ProbeSetRemoved, this._probeSetRemoved, this);
 
         if (this._probeSet)
             this._removeProbeSet(this._probeSet);
@@ -131,8 +133,6 @@ WI.BreakpointTreeElement = class BreakpointTreeElement extends WI.GeneralTreeEle
 
     // Protected
 
-    get listenerSet() { return this._listenerSet; }
-
     updateStatus()
     {
         if (!this.status)
index 25d0d35c8575467e574459890af89bbb1ce6e3c6..a38d901dbe829e633f5f9b2f0920aee0a4525205 100644 (file)
@@ -92,8 +92,7 @@ WI.CPUTimelineView = class CPUTimelineView extends WI.TimelineView
 
     closed()
     {
-        console.assert(this.representedObject instanceof WI.Timeline);
-        this.representedObject.removeEventListener(null, null, this);
+        this.representedObject.removeEventListener(WI.Timeline.Event.RecordAdded, this._cpuTimelineRecordAdded, this);
     }
 
     reset()
index 7579d6a0b5d283442e722aace08ae7b6a0f99419..4fa3887f67533fb838ea5249635b58721b092d14 100644 (file)
@@ -252,15 +252,20 @@ WI.CanvasContentView = class CanvasContentView extends WI.ContentView
 
     detached()
     {
-        this.representedObject.removeEventListener(null, null, this);
-        this.representedObject.shaderProgramCollection.removeEventListener(null, null, this);
+        this.representedObject.removeEventListener(WI.Canvas.Event.MemoryChanged, this._updateMemoryCost, this);
+        this.representedObject.removeEventListener(WI.Canvas.Event.RecordingStarted, this.needsLayout, this);
+        this.representedObject.removeEventListener(WI.Canvas.Event.RecordingProgress, this.needsLayout, this);
+        this.representedObject.removeEventListener(WI.Canvas.Event.RecordingStopped, this.needsLayout, this);
+        this.representedObject.shaderProgramCollection.removeEventListener(WI.Collection.Event.ItemAdded, this.needsLayout, this);
+        this.representedObject.shaderProgramCollection.removeEventListener(WI.Collection.Event.ItemRemoved, this.needsLayout, this);
 
         if (this._canvasNode) {
-            this._canvasNode.removeEventListener(null, null, this);
+            this._canvasNode.removeEventListener(WI.DOMNode.Event.AttributeModified, this._refreshPixelSize, this);
+            this._canvasNode.removeEventListener(WI.DOMNode.Event.AttributeRemoved, this._refreshPixelSize, this);
             this._canvasNode = null;
         }
 
-        WI.settings.showImageGrid.removeEventListener(null, null, this);
+        WI.settings.showImageGrid.removeEventListener(WI.Setting.Event.Changed, this._updateImageGrid, this);
 
         super.detached();
     }
index 332acadd6c9a532e86cfaf55988efbde027e6cf9..b87791cb89079d6935b22c618c1109134fc1e600 100644 (file)
@@ -130,10 +130,10 @@ WI.CanvasOverviewContentView = class CanvasOverviewContentView extends WI.Collec
     {
         WI.domManager.hideDOMNodeHighlight();
 
-        WI.canvasManager.removeEventListener(null, null, this);
+        WI.canvasManager.removeEventListener(WI.CanvasManager.Event.RecordingSaved, this._handleRecordingSaved, this);
 
-        WI.settings.canvasRecordingAutoCaptureFrameCount.removeEventListener(null, null, this);
-        WI.settings.canvasRecordingAutoCaptureEnabled.removeEventListener(null, null, this);
+        WI.settings.canvasRecordingAutoCaptureFrameCount.removeEventListener(WI.Setting.Event.Changed, this._handleCanvasRecordingAutoCaptureFrameCountChanged, this);
+        WI.settings.canvasRecordingAutoCaptureEnabled.removeEventListener(WI.Setting.Event.Changed, this._handleCanvasRecordingAutoCaptureEnabledChanged, this);
 
         super.detached();
     }
index f6e22ca8ed88eb93af13fe5f954c806ce24fcc3a..629d5064d26722c0fee5dbc5d1b35d468fd8a7f7 100644 (file)
@@ -92,11 +92,14 @@ WI.CanvasSidebarPanel = class CanvasSidebarPanel extends WI.NavigationSidebarPan
             return;
 
         if (this._canvas) {
-            this._canvas.removeEventListener(null, null, this);
-            this._canvas.recordingCollection.removeEventListener(null, null, this);
+            this._canvas.removeEventListener(WI.Canvas.Event.RecordingStarted, this._updateRecordNavigationItem, this);
+            this._canvas.removeEventListener(WI.Canvas.Event.RecordingStopped, this._updateRecordNavigationItem, this);
+            this._canvas.recordingCollection.removeEventListener(WI.Collection.Event.ItemAdded, this._recordingAdded, this);
+            this._canvas.recordingCollection.removeEventListener(WI.Collection.Event.ItemRemoved, this._recordingRemoved, this);
         }
 
         this._canvas = canvas;
+
         if (this._canvas) {
             this._canvas.addEventListener(WI.Canvas.Event.RecordingStarted, this._updateRecordNavigationItem, this);
             this._canvas.addEventListener(WI.Canvas.Event.RecordingStopped, this._updateRecordNavigationItem, this);
@@ -114,8 +117,10 @@ WI.CanvasSidebarPanel = class CanvasSidebarPanel extends WI.NavigationSidebarPan
         if (recording === this._recording)
             return;
 
-        if (this._recording)
-            this._recording.removeEventListener(null, null, this);
+        if (this._recording && !this._recording.ready) {
+            this._recording.removeEventListener(WI.Recording.Event.ProcessedAction, this._handleRecordingProcessedAction, this);
+            this._recording.removeEventListener(WI.Recording.Event.StartProcessingFrame, this._handleRecordingStartProcessingFrame, this);
+        }
 
         if (recording)
             this.canvas = recording.source;
@@ -230,7 +235,7 @@ WI.CanvasSidebarPanel = class CanvasSidebarPanel extends WI.NavigationSidebarPan
 
     hidden()
     {
-        this.contentBrowser.removeEventListener(null, null, this);
+        this.contentBrowser.removeEventListener(WI.ContentBrowser.Event.CurrentRepresentedObjectsDidChange, this.updateRepresentedObjects, this);
 
         super.hidden();
     }
@@ -599,7 +604,8 @@ WI.CanvasSidebarPanel = class CanvasSidebarPanel extends WI.NavigationSidebarPan
         }
 
         if (this._recording.ready) {
-            this._recording.removeEventListener(null, null, this);
+            this._recording.removeEventListener(WI.Recording.Event.ProcessedAction, this._handleRecordingProcessedAction, this);
+            this._recording.removeEventListener(WI.Recording.Event.StartProcessingFrame, this._handleRecordingStartProcessingFrame, this);
 
             if (this._recordingProcessingOptionsContainer) {
                 this._recordingProcessingOptionsContainer.remove();
index 72bce03325b886d830dcf6a07349a2d62d15e257..30cae494fe82504cec7a066c68427d7c13ff240a 100644 (file)
@@ -86,7 +86,9 @@ WI.ClusterContentView = class ClusterContentView extends WI.ContentView
 
         this._contentViewContainer.closeAllContentViews();
 
-        WI.ContentView.removeEventListener(null, null, this);
+        WI.ContentView.removeEventListener(WI.ContentView.Event.SelectionPathComponentsDidChange, this._contentViewSelectionPathComponentDidChange, this);
+        WI.ContentView.removeEventListener(WI.ContentView.Event.SupplementalRepresentedObjectsDidChange, this._contentViewSupplementalRepresentedObjectsDidChange, this);
+        WI.ContentView.removeEventListener(WI.ContentView.Event.NumberOfSearchResultsDidChange, this._contentViewNumberOfSearchResultsDidChange, this);
     }
 
     canGoBack()
index e445dd3156b209d401238b8a9b18d1bd9571af57..b90c36b9bc7cb430211c57b7597736ad4140017f 100644 (file)
@@ -47,9 +47,9 @@ WI.CodeMirrorEditor = class CodeMirrorEditor
             if (options[codeMirrorOption] !== undefined)
                 return;
 
-            setting.addEventListener(WI.Setting.Event.Changed, (event) => {
-                codeMirror.setOption(codeMirrorOption, setting.value);
-            });
+            setting.addEventListener(WI.Setting.Event.Changed, function(event) {
+                this.setOption(codeMirrorOption, setting.value);
+            }, codeMirror);
         }
         listenForChange(WI.settings.indentWithTabs, "indentWithTabs");
         listenForChange(WI.settings.indentUnit, "indentUnit");
index 505a4a7bde45523b30da4f6bca77b4d8ccd106c3..ec160f9b6e93c3fbd4e60278bff5a737710d63e9 100644 (file)
@@ -161,8 +161,6 @@ WI.CollectionContentView = class CollectionContentView extends WI.ContentView
             contentView.hidden();
         }
 
-        contentView.removeEventListener(null, null, this);
-
         if (!this.subviews.length)
             this.showContentPlaceholder();
     }
@@ -231,7 +229,8 @@ WI.CollectionContentView = class CollectionContentView extends WI.ContentView
 
     detached()
     {
-        this.representedObject.removeEventListener(null, null, this);
+        this.representedObject.removeEventListener(WI.Collection.Event.ItemAdded, this._handleItemAdded, this);
+        this.representedObject.removeEventListener(WI.Collection.Event.ItemRemoved, this._handleItemRemoved, this);
 
         super.detached();
     }
index 16929cd2276a2af5c0d9da3aa85f42ccf500bd6d..54625b94be79bbbca1b539c7d89ac91d8c3fb30b 100644 (file)
@@ -41,7 +41,9 @@ WI.ConsoleDrawer = class ConsoleDrawer extends WI.ContentBrowser
         this._toggleDrawerButton = new WI.ToggleButtonNavigationItem("toggle-drawer", WI.UIString("Hide Console"), WI.UIString("Show Console"), "Images/HideConsoleDrawer.svg", "Images/ShowConsoleDrawer.svg");
 
         this._toggleDrawerButton.visibilityPriority = WI.NavigationItem.VisibilityPriority.High;
-        this._toggleDrawerButton.addEventListener(WI.ButtonNavigationItem.Event.Clicked, () => { WI.toggleSplitConsole(); });
+        this._toggleDrawerButton.addEventListener(WI.ButtonNavigationItem.Event.Clicked, function(event) {
+            WI.toggleSplitConsole();
+        }, this._toggleDrawerButton);
         this.navigationBar.insertNavigationItem(this._toggleDrawerButton, 0);
 
         this.collapsed = true;
index 8f9560c33b43f68e3b47102dc173c54dada50db3..827cf247111fbb18557c4b550ec01fbda12edc3f 100644 (file)
@@ -256,9 +256,6 @@ WI.ConsoleMessageView = class ConsoleMessageView extends WI.Object
         if (this._objectTree instanceof WI.ObjectTreeView)
             this._objectTree.resetPropertyPath();
 
-        // FIXME: <https://webkit.org/b/196956> Web Inspector: use weak collections for holding event listeners
-        WI.settings.consoleSavedResultAlias.removeEventListener(null, null, this);
-
         WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.BlackboxChanged, this._handleDebuggerBlackboxChanged, this);
     }
 
@@ -405,7 +402,7 @@ WI.ConsoleMessageView = class ConsoleMessageView extends WI.Object
         function updateSavedVariableText() {
             savedVariableElement.textContent = " = " + WI.RuntimeManager.preferredSavedResultPrefix() + savedResultIndex;
         }
-        WI.settings.consoleSavedResultAlias.addEventListener(WI.Setting.Event.Changed, updateSavedVariableText, this);
+        WI.settings.consoleSavedResultAlias.addEventListener(WI.Setting.Event.Changed, updateSavedVariableText, savedVariableElement);
         updateSavedVariableText();
 
         if (this._objectTree)
@@ -754,10 +751,9 @@ WI.ConsoleMessageView = class ConsoleMessageView extends WI.Object
 
         let propertyPath = new WI.PropertyPath(object, prefixSavedResultIndex());
 
-        // FIXME: <https://webkit.org/b/196956> Web Inspector: use weak collections for holding event listeners
-        WI.settings.consoleSavedResultAlias.addEventListener(WI.Setting.Event.Changed, (event) => {
-            propertyPath.pathComponent = prefixSavedResultIndex();
-        }, this);
+        WI.settings.consoleSavedResultAlias.addEventListener(WI.Setting.Event.Changed, function(event) {
+            this.pathComponent = prefixSavedResultIndex();
+        }, propertyPath);
 
         return propertyPath;
     }
index 70675aa7cda80eb244712db0aeb0b0c30df66af7..185327b5715a11e106a0950ccfdd9488b5250bdf 100644 (file)
@@ -55,11 +55,11 @@ WI.ContentBrowser = class ContentBrowser extends WI.View
             let forwardButtonImage = isRTL ? leftArrow : rightArrow;
 
             this._backNavigationItem = new WI.ButtonNavigationItem("back", WI.UIString("Back (%s)").format(this._backKeyboardShortcut.displayName), backButtonImage, 8, 13);
-            this._backNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, goBack);
+            this._backNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, goBack, this);
             this._backNavigationItem.enabled = false;
 
             this._forwardNavigationItem = new WI.ButtonNavigationItem("forward", WI.UIString("Forward (%s)").format(this._forwardKeyboardShortcut.displayName), forwardButtonImage, 8, 13);
-            this._forwardNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, goForward);
+            this._forwardNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, goForward, this);
             this._forwardNavigationItem.enabled = false;
 
             let navigationButtonsGroup = new WI.GroupNavigationItem([this._backNavigationItem, this._forwardNavigationItem]);
@@ -269,7 +269,7 @@ WI.ContentBrowser = class ContentBrowser extends WI.View
             let currentContentView = this.currentContentView;
             if (currentContentView?.supportsSearch) {
                 currentContentView.performSearch(this._findBanner.searchQuery);
-                await currentContentView.awaitEvent(WI.ContentView.Event.NumberOfSearchResultsDidChange);
+                await currentContentView.awaitEvent(WI.ContentView.Event.NumberOfSearchResultsDidChange, this);
                 if (this._findBanner.searchQuery !== searchQuery || this.currentContentView !== currentContentView)
                     return;
             }
@@ -287,7 +287,7 @@ WI.ContentBrowser = class ContentBrowser extends WI.View
             let currentContentView = this.currentContentView;
             if (currentContentView?.supportsSearch) {
                 currentContentView.performSearch(this._findBanner.searchQuery);
-                await currentContentView.awaitEvent(WI.ContentView.Event.NumberOfSearchResultsDidChange);
+                await currentContentView.awaitEvent(WI.ContentView.Event.NumberOfSearchResultsDidChange, this);
                 if (this._findBanner.searchQuery !== searchQuery || this.currentContentView !== currentContentView)
                     return;
             }
index b0b0b2b0478d0263c49f0cab592a7f6da07827ca..26139cfa1ec3c93598259964f25b7434fdbe1267 100644 (file)
@@ -52,7 +52,7 @@ WI.ContentBrowserTabContentView = class ContentBrowserTabContentView extends WI.
             let image = WI.resolvedLayoutDirection() === WI.LayoutDirection.RTL ? "Images/ToggleRightSidebar.svg" : "Images/ToggleLeftSidebar.svg";
 
             this._showNavigationSidebarItem = new WI.ActivateButtonNavigationItem("toggle-navigation-sidebar", showToolTip, hideToolTip, image, 16, 16);
-            this._showNavigationSidebarItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, WI.toggleNavigationSidebar, WI);
+            this._showNavigationSidebarItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, WI.toggleNavigationSidebar, this);
             this._showNavigationSidebarItem.activated = !WI.navigationSidebar.collapsed;
             this._showNavigationSidebarItem.visibilityPriority = WI.NavigationItem.VisibilityPriority.High;
 
@@ -68,7 +68,7 @@ WI.ContentBrowserTabContentView = class ContentBrowserTabContentView extends WI.
             let image = WI.resolvedLayoutDirection() === WI.LayoutDirection.RTL ? "Images/ToggleLeftSidebar.svg" : "Images/ToggleRightSidebar.svg";
 
             this._showDetailsSidebarItem = new WI.ActivateButtonNavigationItem("toggle-details-sidebar", showToolTip, hideToolTip, image, 16, 16);
-            this._showDetailsSidebarItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, WI.toggleDetailsSidebar, WI);
+            this._showDetailsSidebarItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, WI.toggleDetailsSidebar, this);
             this._showDetailsSidebarItem.activated = !WI.detailsSidebar.collapsed;
             this._showDetailsSidebarItem.enabled = false;
             this._showDetailsSidebarItem.visibilityPriority = WI.NavigationItem.VisibilityPriority.High;
@@ -120,8 +120,13 @@ WI.ContentBrowserTabContentView = class ContentBrowserTabContentView extends WI.
     {
         super.closed();
 
-        WI.navigationSidebar.removeEventListener(null, null, this);
-        WI.detailsSidebar.removeEventListener(null, null, this);
+        if (this._navigationSidebarPanelConstructor)
+            WI.navigationSidebar.removeEventListener(WI.Sidebar.Event.CollapsedStateDidChange, this._navigationSidebarCollapsedStateDidChange, this);
+
+        if (this._detailsSidebarPanelConstructors.length) {
+            WI.detailsSidebar.removeEventListener(WI.Sidebar.Event.CollapsedStateDidChange, this._detailsSidebarCollapsedStateDidChange, this);
+            WI.detailsSidebar.removeEventListener(WI.Sidebar.Event.SidebarPanelSelected, this._detailsSidebarPanelSelected, this);
+        }
 
         if (this.navigationSidebarPanel && typeof this.navigationSidebarPanel.closed === "function")
             this.navigationSidebarPanel.closed();
index a323ec20b888b592e0273a8f8119cf8e997668a3..d43e1557bb7c3fd51b30b01eefe16dffaac80978 100644 (file)
@@ -40,7 +40,12 @@ WI.DOMNodeDetailsSidebarPanel = class DOMNodeDetailsSidebarPanel extends WI.DOMD
 
     closed()
     {
-        WI.domManager.removeEventListener(null, null, this);
+        if (this.didInitialLayout) {
+            WI.domManager.removeEventListener(WI.DOMManager.Event.AttributeModified, this._attributesChanged, this);
+            WI.domManager.removeEventListener(WI.DOMManager.Event.AttributeRemoved, this._attributesChanged, this);
+            WI.domManager.removeEventListener(WI.DOMManager.Event.CharacterDataModified, this._characterDataModified, this);
+            WI.domManager.removeEventListener(WI.DOMManager.Event.CustomElementStateChanged, this._customElementStateChanged, this);
+        }
 
         super.closed();
     }
index 3860078fec3f16997d7a266ab0dbe16f0a0ac55b..005a075acb2821db71fb77d53ed5fca4558f30e1 100644 (file)
@@ -164,11 +164,24 @@ WI.DOMTreeContentView = class DOMTreeContentView extends WI.ContentView
     {
         super.closed();
 
-        WI.settings.showRulers.removeEventListener(null, null, this);
-        WI.debuggerManager.removeEventListener(null, null, this);
-        WI.domManager.removeEventListener(null, null, this);
-        WI.domDebuggerManager.removeEventListener(null, null, this);
-        WI.DOMBreakpoint.removeEventListener(null, null, this);
+        WI.settings.showRulers.removeEventListener(WI.Setting.Event.Changed, this._showRulersChanged, this);
+
+        WI.domManager.removeEventListener(WI.DOMManager.Event.AttributeModified, this._domNodeChanged, this);
+        WI.domManager.removeEventListener(WI.DOMManager.Event.AttributeRemoved, this._domNodeChanged, this);
+        WI.domManager.removeEventListener(WI.DOMManager.Event.CharacterDataModified, this._domNodeChanged, this);
+
+        WI.cssManager.removeEventListener(WI.CSSManager.Event.DefaultAppearanceDidChange, this._defaultAppearanceDidChange, this);
+
+        if (WI.domDebuggerManager.supported) {
+            WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.BreakpointsEnabledDidChange, this._breakpointsEnabledDidChange, this);
+
+            WI.domDebuggerManager.removeEventListener(WI.DOMDebuggerManager.Event.DOMBreakpointAdded, this._domBreakpointAddedOrRemoved, this);
+            WI.domDebuggerManager.removeEventListener(WI.DOMDebuggerManager.Event.DOMBreakpointRemoved, this._domBreakpointAddedOrRemoved, this);
+
+            WI.DOMBreakpoint.removeEventListener(WI.Breakpoint.Event.DisabledStateDidChange, this._handleDOMBreakpointDisabledStateChanged, this);
+            WI.DOMBreakpoint.removeEventListener(WI.DOMBreakpoint.Event.DOMNodeWillChange, this._handleDOMBreakpointDOMNodeWillChange, this);
+            WI.DOMBreakpoint.removeEventListener(WI.DOMBreakpoint.Event.DOMNodeDidChange, this._handleDOMBreakpointDOMNodeDidChange, this);
+        }
 
         this._domTreeOutline.close();
         this._pendingBreakpointNodes.clear();
index c60168475d15318befc65180bb339d654dc16731..10f92290f1e16a589ce4a7c8be43e99d2e86d4d8 100644 (file)
@@ -57,7 +57,13 @@ WI.DOMTreeUpdater = function(treeOutline)
 WI.DOMTreeUpdater.prototype = {
     close: function()
     {
-        WI.domManager.removeEventListener(null, null, this);
+        WI.domManager.removeEventListener(WI.DOMManager.Event.NodeInserted, this._nodeInserted, this);
+        WI.domManager.removeEventListener(WI.DOMManager.Event.NodeRemoved, this._nodeRemoved, this);
+        WI.domManager.removeEventListener(WI.DOMManager.Event.AttributeModified, this._attributesUpdated, this);
+        WI.domManager.removeEventListener(WI.DOMManager.Event.AttributeRemoved, this._attributesUpdated, this);
+        WI.domManager.removeEventListener(WI.DOMManager.Event.CharacterDataModified, this._characterDataModified, this);
+        WI.domManager.removeEventListener(WI.DOMManager.Event.DocumentUpdated, this._documentUpdated, this);
+        WI.domManager.removeEventListener(WI.DOMManager.Event.ChildNodeCountUpdated, this._childNodeCountUpdated, this);
     },
 
     _documentUpdated: function(event)
index 96b5159bbe1b8f8356ac67c881837003fac5277b..1a23bb276332f05622a257b578329cd03f4d6458 100644 (file)
@@ -753,11 +753,8 @@ WI.DataGrid = class DataGrid extends WI.View
             insertionIndex = this.orderedColumns.length;
         insertionIndex = Number.constrain(insertionIndex, 0, this.orderedColumns.length);
 
-        var listeners = new WI.EventListenerSet(this, "DataGrid column DOM listeners");
-
         // Copy configuration properties instead of keeping a reference to the passed-in object.
         var column = Object.shallowCopy(columnData);
-        column["listeners"] = listeners;
         column["ordinal"] = insertionIndex;
         column["columnIdentifier"] = columnIdentifier;
 
@@ -805,7 +802,7 @@ WI.DataGrid = class DataGrid extends WI.View
         }
 
         if (column["sortable"]) {
-            listeners.register(headerCellElement, "click", this._headerCellClicked);
+            headerCellElement.addEventListener("click", this._headerCellClicked.bind(this));
             headerCellElement.classList.add(WI.DataGrid.SortableColumnStyleClassName);
         }
 
@@ -822,9 +819,9 @@ WI.DataGrid = class DataGrid extends WI.View
 
             var collapseDiv = headerCellElement.createChild("div", "collapser-button");
             collapseDiv.title = this._collapserButtonCollapseColumnsToolTip();
-            listeners.register(collapseDiv, "mouseover", this._mouseoverColumnCollapser);
-            listeners.register(collapseDiv, "mouseout", this._mouseoutColumnCollapser);
-            listeners.register(collapseDiv, "click", this._clickInColumnCollapser);
+            collapseDiv.addEventListener("mouseover", this._mouseoverColumnCollapser.bind(this));
+            collapseDiv.addEventListener("mouseout", this._mouseoutColumnCollapser.bind(this));
+            collapseDiv.addEventListener("click", this._clickInColumnCollapser.bind(this));
 
             headerCellElement.collapsesGroup = column["collapsesGroup"];
             headerCellElement.classList.add("collapser");
@@ -845,8 +842,6 @@ WI.DataGrid = class DataGrid extends WI.View
         var referenceElement = this._fillerRowElement.children[insertionIndex];
         this._fillerRowElement.insertBefore(fillerCellElement, referenceElement);
 
-        listeners.install();
-
         this.setColumnVisible(columnIdentifier, !column.hidden);
     }
 
@@ -864,8 +859,6 @@ WI.DataGrid = class DataGrid extends WI.View
                 column["ordinal"] = ordinal - 1;
         }
 
-        removedColumn["listeners"].uninstall(true);
-
         if (removedColumn["disclosure"])
             this.disclosureColumnIdentifier = undefined;
 
index 72330cf63660f8e2f3e6d625dd9330835c6899a8..a0a721d225b741950617b8dcebd0c41b87c13f91 100644 (file)
@@ -461,8 +461,6 @@ WI.DataGridNode = class DataGridNode extends WI.Object
         for (var i = 0; i < this.children.length; ++i)
             this.children[i].revealed = false;
 
-        this.dispatchEventToListeners("collapsed");
-
         if (this.dataGrid) {
             this.dataGrid.dispatchEventToListeners(WI.DataGrid.Event.CollapsedNode, {dataGridNode: this});
             this.dataGrid._noteRowsChanged();
@@ -492,7 +490,7 @@ WI.DataGridNode = class DataGridNode extends WI.Object
             for (var i = 0; i < this.children.length; ++i)
                 this.children[i]._detach();
 
-            this.dispatchEventToListeners("populate");
+            this.dispatchEventToListeners(DataGridNode.Event.Populate);
 
             if (this._attached) {
                 for (var i = 0; i < this.children.length; ++i) {
@@ -511,8 +509,6 @@ WI.DataGridNode = class DataGridNode extends WI.Object
 
         this._expanded = true;
 
-        this.dispatchEventToListeners("expanded");
-
         if (this.dataGrid) {
             this.dataGrid.dispatchEventToListeners(WI.DataGrid.Event.ExpandedNode, {dataGridNode: this});
             this.dataGrid._noteRowsChanged();
@@ -564,8 +560,6 @@ WI.DataGridNode = class DataGridNode extends WI.Object
         }
 
         this.dataGrid.updateVisibleRows(this);
-
-        this.dispatchEventToListeners("revealed");
     }
 
     select(suppressSelectedEvent)
@@ -599,7 +593,7 @@ WI.DataGridNode = class DataGridNode extends WI.Object
     traverseNextNode(skipHidden, stayWithin, dontPopulate, info)
     {
         if (!dontPopulate && this.hasChildren)
-            this.dispatchEventToListeners("populate");
+            this.dispatchEventToListeners(DataGridNode.Event.Populate);
 
         if (info)
             info.depthChange = 0;
@@ -635,11 +629,11 @@ WI.DataGridNode = class DataGridNode extends WI.Object
     {
         var node = (!skipHidden || this.revealed) ? this.previousSibling : null;
         if (!dontPopulate && node && node.hasChildren)
-            node.dispatchEventToListeners("populate");
+            node.dispatchEventToListeners(DataGridNode.Event.Populate);
 
         while (node && ((!skipHidden || (node.revealed && node.expanded)) ? node.children.lastValue : null)) {
             if (!dontPopulate && node.hasChildren)
-                node.dispatchEventToListeners("populate");
+                node.dispatchEventToListeners(DataGridNode.Event.Populate);
             node = (!skipHidden || (node.revealed && node.expanded)) ? node.children.lastValue : null;
         }
 
@@ -761,6 +755,10 @@ WI.DataGridNode = class DataGridNode extends WI.Object
     }
 };
 
+WI.DataGridNode.Event = {
+    Populate: "data-grid-node-populate",
+};
+
 // Used to create a new table row when entering new data by editing cells.
 WI.PlaceholderDataGridNode = class PlaceholderDataGridNode extends WI.DataGridNode
 {
index 2925472e6a7af1ec2c3999d6530bdae50f2408b3..44a321483edb3ea68f8a65cdca6b687ca994a9cc 100644 (file)
@@ -108,8 +108,8 @@ WI.ElementsTabContentView = class ElementsTabContentView extends WI.ContentBrows
     {
         super.closed();
 
-        WI.networkManager.removeEventListener(null, null, this);
-        WI.Frame.removeEventListener(null, null, this);
+        WI.networkManager.removeEventListener(WI.NetworkManager.Event.MainFrameDidChange, this._mainFrameDidChange, this);
+        WI.Frame.removeEventListener(WI.Frame.Event.MainResourceDidChange, this._mainResourceDidChange, this);
     }
 
     get allowMultipleDetailSidebars()
index f3291608bf614e5bac327b7c424a9340346864b5..d0885e64e57dce67ae0ffdef998460984dbb4e2b 100644 (file)
@@ -46,7 +46,7 @@ WI.FrameDOMTreeContentView = class FrameDOMTreeContentView extends WI.DOMTreeCon
 
     closed()
     {
-        this._domTree.removeEventListener(null, null, this);
+        this._domTree.removeEventListener(WI.DOMTree.Event.RootDOMNodeInvalidated, this._rootDOMNodeInvalidated, this);
 
         super.closed();
     }
index 015b6b94ff7de96725a6269b4c025fde2a55d6f0..2e270c7c9e315befeae855a605466bac547df65e 100644 (file)
@@ -128,7 +128,9 @@ WI.GeneralStyleDetailsSidebarPanel = class GeneralStyleDetailsSidebarPanel exten
         if (!effectiveDOMNode)
             return;
 
-        effectiveDOMNode.removeEventListener(null, null, this);
+        effectiveDOMNode.removeEventListener(WI.DOMNode.Event.EnabledPseudoClassesChanged, this._updatePseudoClassCheckboxes, this);
+        effectiveDOMNode.removeEventListener(WI.DOMNode.Event.AttributeModified, this._handleNodeAttributeModified, this);
+        effectiveDOMNode.removeEventListener(WI.DOMNode.Event.AttributeRemoved, this._handleNodeAttributeRemoved, this);
     }
 
     initialLayout()
index c52012116d4b1d3ddd62cba8ffe26ca5d98d3d40..8c6743770ef9061a7aa11d31ee3cada130f5a09d 100644 (file)
@@ -105,7 +105,7 @@ WI.HeapAllocationsTimelineView = class HeapAllocationsTimelineView extends WI.Ti
         timeline.addEventListener(WI.Timeline.Event.RecordAdded, this._heapAllocationsTimelineRecordAdded, this);
 
         WI.HeapSnapshotProxy.addEventListener(WI.HeapSnapshotProxy.Event.Invalidated, this._heapSnapshotInvalidated, this);
-        WI.HeapSnapshotWorkerProxy.singleton().addEventListener("HeapSnapshot.CollectionEvent", this._heapSnapshotCollectionEvent, this);
+        WI.HeapSnapshotWorkerProxy.singleton().addEventListener(WI.HeapSnapshotWorkerProxy.Event.Collection, this._heapSnapshotCollectionEvent, this);
     }
 
     // Public
@@ -252,16 +252,15 @@ WI.HeapAllocationsTimelineView = class HeapAllocationsTimelineView extends WI.Ti
 
     closed()
     {
-        console.assert(this.representedObject instanceof WI.Timeline);
-        this.representedObject.removeEventListener(null, null, this);
+        this.representedObject.removeEventListener(WI.Timeline.Event.RecordAdded, this._heapAllocationsTimelineRecordAdded, this);
 
         this._dataGrid.closed();
 
         this._contentViewContainer.closeAllContentViews();
 
-        WI.ContentView.removeEventListener(null, null, this);
-        WI.HeapSnapshotProxy.removeEventListener(null, null, this);
-        WI.HeapSnapshotWorkerProxy.singleton().removeEventListener("HeapSnapshot.CollectionEvent", this._heapSnapshotCollectionEvent, this);
+        WI.ContentView.removeEventListener(WI.ContentView.Event.SelectionPathComponentsDidChange, this._contentViewSelectionPathComponentDidChange, this);
+        WI.HeapSnapshotProxy.removeEventListener(WI.HeapSnapshotProxy.Event.Invalidated, this._heapSnapshotInvalidated, this);
+        WI.HeapSnapshotWorkerProxy.singleton().removeEventListener(WI.HeapSnapshotWorkerProxy.Event.Collection, this._heapSnapshotCollectionEvent, this);
     }
 
     layout()
index 9538b4d3caded308063c78bbb93009e66b1901b3..dc26931acab36dac5c136b7d5d86523892c71018 100644 (file)
@@ -35,7 +35,7 @@ WI.HeapSnapshotClassDataGridNode = class HeapSnapshotClassDataGridNode extends W
         this._batched = false;
         this._instances = null;
 
-        this.addEventListener("populate", this._populate, this);
+        this.addEventListener(WI.DataGridNode.Event.Populate, this._populate, this);
     }
 
     // Protected
@@ -134,7 +134,7 @@ WI.HeapSnapshotClassDataGridNode = class HeapSnapshotClassDataGridNode extends W
 
     _populate()
     {
-        this.removeEventListener("populate", this._populate, this);
+        this.removeEventListener(WI.DataGridNode.Event.Populate, this._populate, this);
 
         this._tree.heapSnapshot.instancesWithClassName(this._data.className, (instances) => {
             // FIXME: <https://webkit.org/b/157905> Web Inspector: Provide a way to toggle between showing only live objects and live+dead objects
index e108ba28714b4fa1a68e9391973e8643c22a4624..9f0e10cd3e7247dca510ee4eb00b4c41674a9e3a 100644 (file)
@@ -37,7 +37,9 @@ WI.HeapSnapshotContentView = class HeapSnapshotContentView extends WI.ContentVie
         this._exportButtonNavigationItem.tooltip = WI.UIString("Export (%s)").format(WI.saveKeyboardShortcut.displayName);
         this._exportButtonNavigationItem.buttonStyle = WI.ButtonNavigationItem.Style.ImageAndText;
         this._exportButtonNavigationItem.visibilityPriority = WI.NavigationItem.VisibilityPriority.High;
-        this._exportButtonNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, () => { this._exportSnapshot(); });
+        this._exportButtonNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, function(event) {
+            this._exportSnapshot();
+        }, this);
 
         this._dataGrid = new WI.DataGrid(columns);
         this._dataGrid.sortColumnIdentifier = "retainedSize";
index ba4f5d27310c239113113a6f6cf504287120017d..10185b8a0ad09a07b8d1ca52b7f7d2f0fba4ed86 100644 (file)
@@ -43,7 +43,7 @@ WI.HeapSnapshotInstanceDataGridNode = class HeapSnapshotInstanceDataGridNode ext
         this._base = base || null;
 
         if (hasChildren)
-            this.addEventListener("populate", this._populate, this);
+            this.addEventListener(WI.DataGridNode.Event.Populate, this._populate, this);
     }
 
     // Static
@@ -216,7 +216,7 @@ WI.HeapSnapshotInstanceDataGridNode = class HeapSnapshotInstanceDataGridNode ext
 
     _populate()
     {
-        this.removeEventListener("populate", this._populate, this);
+        this.removeEventListener(WI.DataGridNode.Event.Populate, this._populate, this);
 
         function propertyName(edge) {
             return edge ? WI.HeapSnapshotRootPath.pathComponentForIndividualEdge(edge) : "";
index 062a88e262b0da30438e37bdc933287da724be8e..06e1f0d6d04c5299aa2d890daa40e9f922541c43 100644 (file)
@@ -115,13 +115,6 @@ WI.ImageResourceContentView = class ImageResourceContentView extends WI.Resource
         super.hidden();
     }
 
-    closed()
-    {
-        WI.networkManager.removeEventListener(null, null, this);
-
-        super.closed();
-    }
-
     // DropZoneView delegate
 
     dropZoneShouldAppearForDragEvent(dropZone, event)
index dc3b31520fdfe35d2f1c1baf36f41528af4cc0ad..b18b20f66a1e5c1c4282e26ff29e8f05618bc4a8 100644 (file)
@@ -134,8 +134,16 @@ WI.InlineSwatch = class InlineSwatch extends WI.Object
         if (this._valueEditor.removeListeners)
             this._valueEditor.removeListeners();
 
-        if (this._valueEditor instanceof WI.Object)
-            this._valueEditor.removeEventListener(null, null, this);
+        if (this._valueEditor instanceof WI.BezierEditor)
+            this._valueEditor.removeEventListener(WI.BezierEditor.Event.BezierChanged, this._valueEditorValueDidChange, this);
+        else if (this._valueEditor instanceof WI.BoxShadowEditor)
+            this._valueEditor.removeEventListener(WI.BoxShadowEditor.Event.BoxShadowChanged, this._valueEditorValueDidChange, this);
+        else if (this._valueEditor instanceof WI.ColorPicker)
+            this._valueEditor.removeEventListener(WI.ColorPicker.Event.ColorChanged, this._valueEditorValueDidChange, this);
+        else if (this._valueEditor instanceof WI.GradientEditor)
+            this._valueEditor.removeEventListener(WI.GradientEditor.Event.GradientChanged, this._valueEditorValueDidChange, this);
+        else if (this._valueEditor instanceof WI.SpringEditor)
+            this._valueEditor.removeEventListener(WI.SpringEditor.Event.SpringChanged, this._valueEditorValueDidChange, this);
 
         this._valueEditor = null;
 
@@ -251,7 +259,9 @@ WI.InlineSwatch = class InlineSwatch extends WI.Object
         case WI.InlineSwatch.Type.Gradient:
             this._valueEditor = new WI.GradientEditor;
             this._valueEditor.addEventListener(WI.GradientEditor.Event.GradientChanged, this._valueEditorValueDidChange, this);
-            this._valueEditor.addEventListener(WI.GradientEditor.Event.ColorPickerToggled, (event) => popover.update());
+            this._valueEditor.addEventListener(WI.GradientEditor.Event.ColorPickerToggled, function(event) {
+                this.update();
+            }, popover);
             break;
 
         case WI.InlineSwatch.Type.Image:
index 1c96739967016aa52a15c6d7280c4ee647438c6a..e45dab3efa2c2a1c51cc66183a52bab1d535c95e 100644 (file)
@@ -37,12 +37,6 @@ WI.JavaScriptBreakpointTreeElement = class JavaScriptBreakpointTreeElement exten
             title = breakpoint.displayName;
 
         super(breakpoint, {classNames, title});
-
-        if (!breakpoint.special) {
-            this.listenerSet.register(breakpoint, WI.JavaScriptBreakpoint.Event.LocationDidChange, this._breakpointLocationDidChange);
-            this._updateTitles();
-        }
-        this.listenerSet.register(breakpoint, WI.JavaScriptBreakpoint.Event.ResolvedStateDidChange, this.updateStatus);
     }
 
     // Public
@@ -52,6 +46,26 @@ WI.JavaScriptBreakpointTreeElement = class JavaScriptBreakpointTreeElement exten
         return {text: [this.breakpoint.contentIdentifier]};
     }
 
+    onattach()
+    {
+        super.onattach();
+
+        if (!this.breakpoint.special) {
+            this.breakpoint.addEventListener(WI.JavaScriptBreakpoint.Event.LocationDidChange, this._breakpointLocationDidChange, this);
+            this._updateTitles();
+        }
+        this.breakpoint.addEventListener(WI.JavaScriptBreakpoint.Event.ResolvedStateDidChange, this.updateStatus, this);
+    }
+
+    ondetach()
+    {
+        if (!this.breakpoint.special)
+            this.breakpoint.removeEventListener(WI.JavaScriptBreakpoint.Event.LocationDidChange, this._breakpointLocationDidChange, this);
+        this.breakpoint.removeEventListener(WI.JavaScriptBreakpoint.Event.ResolvedStateDidChange, this.updateStatus, this);
+
+        super.ondetach();
+    }
+
     // Private
 
     _updateTitles()
index fc3eafc7c37dbe4b62d2c9cbda1dd086e065ff6d..2cc661e2288fc260b12a3e2bec7a954362d5c7a1 100644 (file)
@@ -147,8 +147,7 @@ WI.LayoutTimelineView = class LayoutTimelineView extends WI.TimelineView
 
     closed()
     {
-        console.assert(this.representedObject instanceof WI.Timeline);
-        this.representedObject.removeEventListener(null, null, this);
+        this.representedObject.removeEventListener(WI.Timeline.Event.RecordAdded, this._layoutTimelineRecordAdded, this);
 
         this._dataGrid.closed();
     }
index e742843eaa7d440fc837118ad4c560551965d0b3..69f1bdd2e3c889649d248e77b2be0f5223537f3c 100644 (file)
@@ -50,7 +50,8 @@ WI.LocalResourceOverrideWarningView = class LocalResourceOverrideWarningView ext
 
     detached()
     {
-        WI.networkManager.removeEventListener(null, null, this);
+        WI.networkManager.removeEventListener(WI.NetworkManager.Event.LocalResourceOverrideAdded, this._handleLocalResourceOverrideAddedOrRemoved, this);
+        WI.networkManager.removeEventListener(WI.NetworkManager.Event.LocalResourceOverrideRemoved, this._handleLocalResourceOverrideAddedOrRemoved, this);
 
         super.detached();
     }
index b81645e295a112eab20c7be6a5a29c3d2de7c81b..4654b6717de523957cd3c0a60f30de29b2db19e5 100644 (file)
@@ -72,16 +72,16 @@ WI.LogContentView = class LogContentView extends WI.ContentView
 
         this._preserveLogNavigationItem = new WI.CheckboxNavigationItem("preserve-log", WI.UIString("Preserve Log"), !WI.settings.clearLogOnNavigate.value);
         this._preserveLogNavigationItem.tooltip = WI.UIString("Do not clear the console on new page loads");
-        this._preserveLogNavigationItem.addEventListener(WI.CheckboxNavigationItem.Event.CheckedDidChange, () => {
+        this._preserveLogNavigationItem.addEventListener(WI.CheckboxNavigationItem.Event.CheckedDidChange, function(event) {
             WI.settings.clearLogOnNavigate.value = !WI.settings.clearLogOnNavigate.value;
-        });
+        }, this);
         WI.settings.clearLogOnNavigate.addEventListener(WI.Setting.Event.Changed, this._handleClearLogOnNavigateSettingChanged, this);
 
         this._emulateInUserGestureNavigationItem = new WI.CheckboxNavigationItem("emulate-in-user-gesture", WI.UIString("Emulate User Gesture"), WI.settings.emulateInUserGesture.value);
         this._emulateInUserGestureNavigationItem.tooltip = WI.UIString("Run console commands as if inside a user gesture");
-        this._emulateInUserGestureNavigationItem.addEventListener(WI.CheckboxNavigationItem.Event.CheckedDidChange, () => {
+        this._emulateInUserGestureNavigationItem.addEventListener(WI.CheckboxNavigationItem.Event.CheckedDidChange, function(event) {
             WI.settings.emulateInUserGesture.value = !WI.settings.emulateInUserGesture.value;
-        });
+        }, this);
         WI.settings.emulateInUserGesture.addEventListener(WI.Setting.Event.Changed, this._handleEmulateInUserGestureSettingChanged, this);
 
         this._checkboxesNavigationItemGroup = new WI.GroupNavigationItem([this._preserveLogNavigationItem, this._emulateInUserGestureNavigationItem, new WI.DividerNavigationItem]);
index 02846eb4b3e0501f639866defdb3f530d59b3778..cecc034e3a0513ef1efbf475bcb57ebbef66a104 100644 (file)
@@ -135,11 +135,11 @@ WI.MediaTimelineOverviewGraph = class MediaTimelineOverviewGraph extends WI.Time
 
         if (isNaN(record.startTime)) {
             this._recordsWithoutStartTime.add(record);
-            record.singleFireEventListener(WI.TimelineRecord.Event.Updated, (event) => {
+            record.singleFireEventListener(WI.TimelineRecord.Event.Updated, function(event) {
                 this._processRecord(record);
 
                 this.needsLayout();
-            });
+            }, this);
             return;
         }
 
index 908c93d77ffca2d760ad83c36cbfd869dd8d3e05..d65e4ea2538fb302bd9cd7ca628efb940915b1eb 100644 (file)
@@ -130,8 +130,7 @@ WI.MemoryTimelineView = class MemoryTimelineView extends WI.TimelineView
 
     closed()
     {
-        console.assert(this.representedObject instanceof WI.Timeline);
-        this.representedObject.removeEventListener(null, null, this);
+        this.representedObject.removeEventListener(WI.Timeline.Event.RecordAdded, this._memoryTimelineRecordAdded, this);
     }
 
     reset()
index 04a8b1ed641f65c59e320b12a1952072b60f41aa..d8b75b82db0c9e4d6940e6afab3288ea13a0e41f 100644 (file)
@@ -65,8 +65,10 @@ WI.MultipleScopeBarItem = class MultipleScopeBarItem extends WI.Object
     set scopeBarItems(scopeBarItems)
     {
         if (this._scopeBarItems) {
-            for (var scopeBarItem of this._scopeBarItems)
-                scopeBarItem.removeEventListener(null, null, this);
+            for (var scopeBarItem of this._scopeBarItems) {
+                scopeBarItem.removeEventListener(WI.ScopeBarItem.Event.SelectionChanged, this._itemSelectionDidChange, this);
+                scopeBarItem.removeEventListener(WI.ScopeBarItem.Event.HiddenChanged, this._handleItemHiddenChanged, this);
+            }
         }
 
         this._scopeBarItems = scopeBarItems || [];
index de8f3ec27ca71a65b369bef61d567d4ff32cb3cf..68165eb760aeed14a9eeed6fd5133ede6830e556 100644 (file)
@@ -84,7 +84,12 @@ WI.NavigationSidebarPanel = class NavigationSidebarPanel extends WI.SidebarPanel
     closed()
     {
         window.removeEventListener("resize", this._boundUpdateContentOverflowShadowVisibilitySoon);
-        WI.Frame.removeEventListener(null, null, this);
+
+        if (this._shouldAutoPruneStaleTopLevelResourceTreeElements) {
+            WI.Frame.removeEventListener(WI.Frame.Event.MainResourceDidChange, this._checkForStaleResources, this);
+            WI.Frame.removeEventListener(WI.Frame.Event.ChildFrameWasRemoved, this._checkForStaleResources, this);
+            WI.Frame.removeEventListener(WI.Frame.Event.ResourceWasRemoved, this._checkForStaleResources, this);
+        }
     }
 
     get contentBrowser()
index 1de0ce57e843923232c9441d30f3c8c2f02f2873..edff11a229a4ca0158adf9ed908068e4ae2796b0 100644 (file)
@@ -82,7 +82,7 @@ WI.NetworkDetailView = class NetworkDetailView extends WI.View
     initialLayout()
     {
         let closeNavigationItem = new WI.ButtonNavigationItem("close", WI.UIString("Close detail view"), "Images/CloseLarge.svg", 16, 16);
-        closeNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, this._handleCloseButton.bind(this));
+        closeNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, this._handleCloseButton, this);
         closeNavigationItem.visibilityPriority = WI.NavigationItem.VisibilityPriority.High;
 
         let contentViewNavigationItemsGroup = new WI.GroupNavigationItem;
index 30044cd8144810d2aa3107ef8454a08b366ad2d7..b5324ca627b3e03f6f650c446aec62fcacde0963 100644 (file)
@@ -114,22 +114,24 @@ WI.NetworkTableContentView = class NetworkTableContentView extends WI.ContentVie
 
         this._clearOnLoadNavigationItem = new WI.CheckboxNavigationItem("preserve-log", WI.UIString("Preserve Log"), !WI.settings.clearNetworkOnNavigate.value);
         this._clearOnLoadNavigationItem.tooltip = WI.UIString("Do not clear network items on new page loads");
-        this._clearOnLoadNavigationItem.addEventListener(WI.CheckboxNavigationItem.Event.CheckedDidChange, () => { WI.settings.clearNetworkOnNavigate.value = !WI.settings.clearNetworkOnNavigate.value; });
+        this._clearOnLoadNavigationItem.addEventListener(WI.CheckboxNavigationItem.Event.CheckedDidChange, function(event) {
+            WI.settings.clearNetworkOnNavigate.value = !WI.settings.clearNetworkOnNavigate.value;
+        }, this);
         WI.settings.clearNetworkOnNavigate.addEventListener(WI.Setting.Event.Changed, this._clearNetworkOnNavigateSettingChanged, this);
 
         this._harImportNavigationItem = new WI.ButtonNavigationItem("har-import", WI.UIString("Import"), "Images/Import.svg", 15, 15);
         this._harImportNavigationItem.buttonStyle = WI.ButtonNavigationItem.Style.ImageAndText;
         this._harImportNavigationItem.tooltip = WI.UIString("HAR Import");
-        this._harImportNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, () => {
+        this._harImportNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, function(event) {
             this._importHAR();
-        });
+        }, this);
 
         this._harExportNavigationItem = new WI.ButtonNavigationItem("har-export", WI.UIString("Export"), "Images/Export.svg", 15, 15);
         this._harExportNavigationItem.buttonStyle = WI.ButtonNavigationItem.Style.ImageAndText;
         this._harExportNavigationItem.tooltip = WI.UIString("HAR Export (%s)").format(WI.saveKeyboardShortcut.displayName);
-        this._harExportNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, () => {
+        this._harExportNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, function(event) {
             this._exportHAR();
-        });
+        }, this);
 
         this._collectionsPathNavigationItem = new WI.HierarchicalPathNavigationItem;
         this._collectionsPathNavigationItem.addEventListener(WI.HierarchicalPathNavigationItem.Event.PathComponentWasSelected, this._collectionsHierarchicalPathComponentWasSelected, this);
@@ -161,9 +163,9 @@ WI.NetworkTableContentView = class NetworkTableContentView extends WI.ContentVie
         }
 
         this._clearNetworkItemsNavigationItem = new WI.ButtonNavigationItem("clear-network-items", WI.UIString("Clear Network Items (%s)").format(WI.clearKeyboardShortcut.displayName), "Images/NavigationItemTrash.svg", 15, 15);
-        this._clearNetworkItemsNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, () => {
+        this._clearNetworkItemsNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, function(event) {
             this.reset();
-        });
+        }, this);
 
         WI.Target.addEventListener(WI.Target.Event.ResourceAdded, this._handleResourceAdded, this);
         WI.Frame.addEventListener(WI.Frame.Event.MainResourceDidChange, this._mainResourceDidChange, this);
@@ -301,11 +303,20 @@ WI.NetworkTableContentView = class NetworkTableContentView extends WI.ContentVie
         this._hidePopover();
         this._hideDetailView();
 
-        WI.Target.removeEventListener(null, null, this);
-        WI.Frame.removeEventListener(null, null, this);
-        WI.Resource.removeEventListener(null, null, this);
-        WI.settings.resourceCachingDisabled.removeEventListener(null, null, this);
-        WI.settings.clearNetworkOnNavigate.removeEventListener(null, null, this);
+        WI.settings.clearNetworkOnNavigate.removeEventListener(WI.Setting.Event.Changed, this._clearNetworkOnNavigateSettingChanged, this);
+
+        // COMPATIBILITY (iOS 10.3): Network.setDisableResourceCaching did not exist.
+        if (InspectorBackend.hasCommand("Network.setResourceCachingDisabled"))
+            WI.settings.resourceCachingDisabled.removeEventListener(WI.Setting.Event.Changed, this._resourceCachingDisabledSettingChanged, this);
+
+        WI.Target.removeEventListener(WI.Target.Event.ResourceAdded, this._handleResourceAdded, this);
+        WI.Frame.removeEventListener(WI.Frame.Event.MainResourceDidChange, this._mainResourceDidChange, this);
+        WI.Frame.removeEventListener(WI.Frame.Event.ResourceWasAdded, this._handleResourceAdded, this);
+        WI.Frame.removeEventListener(WI.Frame.Event.ChildFrameWasAdded, this._handleFrameWasAdded, this);
+        WI.Resource.removeEventListener(WI.Resource.Event.LoadingDidFinish, this._resourceLoadingDidFinish, this);
+        WI.Resource.removeEventListener(WI.Resource.Event.LoadingDidFail, this._resourceLoadingDidFail, this);
+        WI.Resource.removeEventListener(WI.Resource.Event.SizeDidChange, this._handleResourceSizeDidChange, this);
+        WI.Resource.removeEventListener(WI.Resource.Event.TransferSizeDidChange, this._resourceTransferSizeDidChange, this);
         WI.networkManager.removeEventListener(WI.NetworkManager.Event.MainFrameDidChange, this._mainFrameDidChange, this);
 
         super.closed();
index 80ae561f1cdf2a0a0677c194e4667e5ad92aaa3c..10a0f442e4249010a880bf481dc436d057159d57 100644 (file)
@@ -177,8 +177,7 @@ WI.NetworkTimelineView = class NetworkTimelineView extends WI.TimelineView
 
     closed()
     {
-        console.assert(this.representedObject instanceof WI.Timeline);
-        this.representedObject.removeEventListener(null, null, this);
+        this.representedObject.removeEventListener(WI.Timeline.Event.RecordAdded, this._networkTimelineRecordAdded, this);
 
         this._dataGrid.closed();
     }
index 265617bf66d4dda24e7e5e4a7ce6cc9cbe51db35..e626d68c34bbf988a74a997c9bf483a2251a3f68 100644 (file)
@@ -137,11 +137,11 @@ WI.ObjectTreeView = class ObjectTreeView extends WI.Object
             button.addEventListener("click", (event) => {
                 event.stop();
 
-                representation.singleFireEventListener(ObjectTreeView.Event.Updated, () => {
+                representation.singleFireEventListener(ObjectTreeView.Event.Updated, function(event) {
                     // The `treeElement` may have already been removed by some other means (e.g. `removeChildren`).
                     if (treeElement.parent === parentTreeElement)
                         parentTreeElement.removeChild(treeElement);
-                });
+                }, button);
 
                 for (let other of buttons)
                     other.disabled = true;
index a3a042118746fe077cd62b7263dd472495d63b6a..b1dfc0b65bc35ef422392bc5855b1d608a06d7f2 100644 (file)
@@ -107,9 +107,11 @@ WI.OverviewTimelineView = class OverviewTimelineView extends WI.TimelineView
     closed()
     {
         for (let timeline of this._recording.timelines.values())
-            timeline.removeEventListener(null, null, this);
+            timeline.removeEventListener(WI.Timeline.Event.RecordAdded, this._handleTimelineRecordAdded, this);
 
-        this._recording.removeEventListener(null, null, this);
+        this._recording.removeEventListener(WI.TimelineRecording.Event.SourceCodeTimelineAdded, this._sourceCodeTimelineAdded, this);
+        this._recording.removeEventListener(WI.TimelineRecording.Event.MarkerAdded, this._markerAdded, this);
+        this._recording.removeEventListener(WI.TimelineRecording.Event.Reset, this._recordingReset, this);
     }
 
     get navigationItems()
index 8830f3c1d70d781d27f5e6a107e540bcef3b31d7..b0414e1a67af97f6f56aa64a4cbf6600e8340594 100644 (file)
@@ -93,7 +93,10 @@ WI.ProbeDetailsSidebarPanel = class ProbeDetailsSidebarPanel extends WI.DetailsS
 
     closed()
     {
-        WI.debuggerManager.removeEventListener(null, null, this);
+        if (this.didInitialLayout) {
+            WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.ProbeSetAdded, this._probeSetAdded, this);
+            WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.ProbeSetRemoved, this._probeSetRemoved, this);
+        }
 
         super.closed();
     }
index 68ec419d802aadb95d90b087033b41927f9026d5..673dd8732eb713640b98f95383ac3e496b09bf38 100644 (file)
@@ -46,12 +46,11 @@ WI.ProbeSetDataGrid = class ProbeSetDataGrid extends WI.DataGrid
         this._lastUpdatedFrame = null;
         this._nodesSinceLastNavigation = [];
 
-        this._listenerSet = new WI.EventListenerSet(this, "ProbeSetDataGrid instance listeners");
-        this._listenerSet.register(probeSet, WI.ProbeSet.Event.ProbeAdded, this._setupProbe);
-        this._listenerSet.register(probeSet, WI.ProbeSet.Event.ProbeRemoved, this._teardownProbe);
-        this._listenerSet.register(probeSet, WI.ProbeSet.Event.SamplesCleared, this._setupData);
-        this._listenerSet.register(WI.Probe, WI.Probe.Event.ExpressionChanged, this._probeExpressionChanged);
-        this._listenerSet.install();
+        probeSet.addEventListener(WI.ProbeSet.Event.ProbeAdded, this._setupProbe, this);
+        probeSet.addEventListener(WI.ProbeSet.Event.ProbeRemoved, this._teardownProbe, this);
+        probeSet.addEventListener(WI.ProbeSet.Event.SamplesCleared, this._setupData, this);
+
+        WI.Probe.addEventListener(WI.Probe.Event.ExpressionChanged, this._probeExpressionChanged, this);
 
         this._setupData();
     }
@@ -70,7 +69,11 @@ WI.ProbeSetDataGrid = class ProbeSetDataGrid extends WI.DataGrid
         for (var probe of this.probeSet)
             this._teardownProbe(probe);
 
-        this._listenerSet.uninstall(true);
+        this.probeSet.removeEventListener(WI.ProbeSet.Event.ProbeAdded, this._setupProbe, this);
+        this.probeSet.removeEventListener(WI.ProbeSet.Event.ProbeRemoved, this._teardownProbe, this);
+        this.probeSet.removeEventListener(WI.ProbeSet.Event.SamplesCleared, this._setupData, this);
+
+        WI.Probe.removeEventListener(WI.Probe.Event.ExpressionChanged, this._probeExpressionChanged, this);
     }
 
     // Private
@@ -99,16 +102,17 @@ WI.ProbeSetDataGrid = class ProbeSetDataGrid extends WI.DataGrid
         for (var frame of this._data.frames)
             this._updateNodeForFrame(frame);
 
-        this._dataListeners = new WI.EventListenerSet(this, "ProbeSetDataGrid data table listeners");
-        this._dataListeners.register(this._data, WI.ProbeSetDataTable.Event.FrameInserted, this._dataFrameInserted);
-        this._dataListeners.register(this._data, WI.ProbeSetDataTable.Event.SeparatorInserted, this._dataSeparatorInserted);
-        this._dataListeners.register(this._data, WI.ProbeSetDataTable.Event.WillRemove, this._teardownData);
-        this._dataListeners.install();
+        this._data.addEventListener(WI.ProbeSetDataTable.Event.FrameInserted, this._dataFrameInserted, this);
+        this._data.addEventListener(WI.ProbeSetDataTable.Event.SeparatorInserted, this._dataSeparatorInserted, this);
+        this._data.addEventListener(WI.ProbeSetDataTable.Event.WillRemove, this._teardownData, this);
     }
 
     _teardownData()
     {
-        this._dataListeners.uninstall(true);
+        this._data.removeEventListener(WI.ProbeSetDataTable.Event.FrameInserted, this._dataFrameInserted, this);
+        this._data.removeEventListener(WI.ProbeSetDataTable.Event.SeparatorInserted, this._dataSeparatorInserted, this);
+        this._data.removeEventListener(WI.ProbeSetDataTable.Event.WillRemove, this._teardownData, this);
+
         this.removeChildren();
         this._frameNodes = new Map;
         this._lastUpdatedFrame = null;
index 806feb1ef487d2f132bc4524c7a6521ac24a49a2..521c3874152c0a47f21aeec5d1d6d32c8be02e65 100644 (file)
@@ -44,7 +44,6 @@ WI.ProbeSetDetailsSection = class ProbeSetDetailsSection extends WI.DetailsSecti
 
         this.element.classList.add("probe-set");
 
-        this._listenerSet = new WI.EventListenerSet(this, "ProbeSetDetailsSection UI listeners");
         this._probeSet = probeSet;
         this._dataGrid = dataGrid;
 
@@ -64,24 +63,28 @@ WI.ProbeSetDetailsSection = class ProbeSetDetailsSection extends WI.DetailsSecti
         this._removeProbeButtonItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, this._removeProbeButtonClicked, this);
         this._navigationBar.addNavigationItem(this._removeProbeButtonItem);
 
-        this._listenerSet.register(this._probeSet, WI.ProbeSet.Event.SampleAdded, this._probeSetSamplesChanged);
-        this._listenerSet.register(this._probeSet, WI.ProbeSet.Event.SamplesCleared, this._probeSetSamplesChanged);
+        this._probeSet.addEventListener(WI.ProbeSet.Event.SampleAdded, this._probeSetSamplesChanged, this);
+        this._probeSet.addEventListener(WI.ProbeSet.Event.SamplesCleared, this._probeSetSamplesChanged, this);
 
         if (this._probeSet.breakpoint instanceof WI.JavaScriptBreakpoint) {
             // Update the source link when the breakpoint's resolved state changes,
             // so that it can become a live location link when possible.
             this._updateLinkElement();
-            this._listenerSet.register(this._probeSet.breakpoint, WI.JavaScriptBreakpoint.Event.ResolvedStateDidChange, this._updateLinkElement);
+            this._probeSet.breakpoint.addEventListener(WI.JavaScriptBreakpoint.Event.ResolvedStateDidChange, this._updateLinkElement, this);
         }
 
-        this._listenerSet.install();
     }
 
     // Public
 
     closed()
     {
-        this._listenerSet.uninstall(true);
+        this._probeSet.removeEventListener(WI.ProbeSet.Event.SampleAdded, this._probeSetSamplesChanged, this);
+        this._probeSet.removeEventListener(WI.ProbeSet.Event.SamplesCleared, this._probeSetSamplesChanged, this);
+
+        if (this._probeSet.breakpoint instanceof WI.JavaScriptBreakpoint)
+            this._probeSet.breakpoint.removeEventListener(WI.JavaScriptBreakpoint.Event.ResolvedStateDidChange, this._updateLinkElement, this);
+
         this.element.remove();
     }
 
index 3746ee79d60c0cbe6e9f76093588ef68c1d2b987..68ff31a82455077973a1da06e2e681e1687cf63f 100644 (file)
@@ -36,7 +36,7 @@ WI.ProfileDataGridNode = class ProfileDataGridNode extends WI.DataGridNode
         this._childrenToChargeToSelf = new Set;
         this._extraSelfTimeFromChargedChildren = 0;
 
-        this.addEventListener("populate", this._populate, this);
+        this.addEventListener(WI.DataGridNode.Event.Populate, this._populate, this);
 
         this._updateChildrenForModifiers();
         this._recalculateData();
@@ -256,7 +256,7 @@ WI.ProfileDataGridNode = class ProfileDataGridNode extends WI.DataGridNode
         if (!this.shouldRefreshChildren)
             return;
 
-        this.removeEventListener("populate", this._populate, this);
+        this.removeEventListener(WI.DataGridNode.Event.Populate, this._populate, this);
 
         this._node.forEachChild((child) => {
             if (!this._childrenToChargeToSelf.has(child)) {
index 3d3969c1c17c4274335468f6356beb5f12ab89fa..20da878d3e5f99933ad21c4d32d020c2851cbcbf 100644 (file)
@@ -35,7 +35,7 @@ WI.ProfileNodeDataGridNode = class ProfileNodeDataGridNode extends WI.TimelineDa
 
         this._profileNode = profileNode;
 
-        this.addEventListener("populate", this._populate, this);
+        this.addEventListener(WI.DataGridNode.Event.Populate, this._populate, this);
     }
 
     // Public
@@ -140,7 +140,7 @@ WI.ProfileNodeDataGridNode = class ProfileNodeDataGridNode extends WI.TimelineDa
         if (!this.shouldRefreshChildren)
             return;
 
-        this.removeEventListener("populate", this._populate, this);
+        this.removeEventListener(WI.DataGridNode.Event.Populate, this._populate, this);
         this.removeChildren();
 
         for (let node of this._profileNode.childNodes)
index aebe9795d4a3e04f8bd6f97f0fea1b7a504d38c0..67627fe7106a9b3d8dce0cc40ed924a11815ebbd 100644 (file)
@@ -98,13 +98,24 @@ WI.QuickConsole = class QuickConsole extends WI.View
 
     closed()
     {
-        WI.settings.consoleSavedResultAlias.removeEventListener(null, null, this);
-        WI.Frame.removeEventListener(null, null, this);
-        WI.debuggerManager.removeEventListener(null, null, this);
-        WI.runtimeManager.removeEventListener(null, null, this);
-        WI.targetManager.removeEventListener(null, null, this);
-        WI.consoleDrawer.removeEventListener(null, null, this);
-        WI.TabBrowser.removeEventListener(null, null, this);
+        WI.settings.consoleSavedResultAlias.removeEventListener(WI.Setting.Event.Changed, this._handleConsoleSavedResultAliasSettingChanged, this);
+        WI.settings.engineeringShowInternalExecutionContexts.removeEventListener(WI.Setting.Event.Changed, this._handleEngineeringShowInternalExecutionContextsSettingChanged, this);
+
+        WI.Frame.removeEventListener(WI.Frame.Event.PageExecutionContextChanged, this._handleFramePageExecutionContextChanged, this);
+        WI.Frame.removeEventListener(WI.Frame.Event.ExecutionContextsCleared, this._handleFrameExecutionContextsCleared, this);
+
+        WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.ActiveCallFrameDidChange, this._handleDebuggerActiveCallFrameDidChange, this);
+
+        WI.runtimeManager.removeEventListener(WI.RuntimeManager.Event.ActiveExecutionContextChanged, this._handleActiveExecutionContextChanged, this);
+
+        WI.notifications.removeEventListener(WI.Notification.TransitionPageTarget, this._handleTransitionPageTarget, this);
+
+        WI.targetManager.removeEventListener(WI.TargetManager.Event.TargetRemoved, this._handleTargetRemoved, this);
+
+        WI.domManager.removeEventListener(WI.DOMManager.Event.InspectedNodeChanged, this._handleInspectedNodeChanged, this);
+
+        WI.consoleDrawer.removeEventListener(WI.ConsoleDrawer.Event.CollapsedStateChanged, this._updateStyles, this);
+        WI.TabBrowser.removeEventListener(WI.TabBrowser.Event.SelectedTabContentViewDidChange, this._updateStyles, this);
 
         super.closed();
     }
index 2696a7c1b67255b37034e47032f4196d95c12212..890b19fb47ee5f3d5193362eb5e6b7b28c1f9df4 100644 (file)
@@ -39,7 +39,7 @@ WI.RecordingActionTreeElement = class RecordingActionTreeElement extends WI.Gene
         this._copyText = copyText;
 
         if (this.representedObject.valid)
-            this.representedObject.addEventListener(WI.RecordingAction.Event.ValidityChanged, this._handleValidityChanged, this);
+            this.representedObject.singleFireEventListener(WI.RecordingAction.Event.ValidityChanged, this._handleValidityChanged, this);
     }
 
     // Static
@@ -449,7 +449,5 @@ WI.RecordingActionTreeElement = class RecordingActionTreeElement extends WI.Gene
     _handleValidityChanged(event)
     {
         this.addClassName("invalid");
-
-        this.representedObject.removeEventListener(null, null, this);
     }
 };
index 8325fb0bbf86beb4b022b1a1a20460a5b6788290..5aec18513cfd818e3432621958d34a4e7fa3aaa4 100644 (file)
@@ -531,7 +531,7 @@ WI.RecordingContentView = class RecordingContentView extends WI.ContentView
         this._updateSliderValue();
 
         if (this.representedObject.ready)
-            this.representedObject.removeEventListener(null, null, this);
+            this.representedObject.removeEventListener(WI.Recording.Event.ProcessedAction, this._handleRecordingProcessedAction, this);
     }
 };
 
index ac4d9caea409488ad0084ed512f911df3c1cea5b..cbc00b062a2bba8fccacfeba7c47cc270f5b6c67 100644 (file)
@@ -131,8 +131,7 @@ WI.RenderingFrameTimelineView = class RenderingFrameTimelineView extends WI.Time
 
     closed()
     {
-        console.assert(this.representedObject instanceof WI.Timeline);
-        this.representedObject.removeEventListener(null, null, this);
+        this.representedObject.removeEventListener(WI.Timeline.Event.RecordAdded, this._renderingFrameTimelineRecordAdded, this);
 
         this._dataGrid.closed();
     }
index fc6f57782544813bfe4210475b96286ecede0833..3cf1c1fc71fbe1786a2cf4885d27a18d9cb4428a 100644 (file)
@@ -95,7 +95,7 @@ WI.ResourceCollectionContentView = class ResourceCollectionContentView extends W
 
     detached()
     {
-        WI.settings.showImageGrid.removeEventListener(null, null, this);
+        WI.settings.showImageGrid.removeEventListener(WI.Setting.Event.Changed, this._handleShowImageGridSettingChanged, this);
 
         super.detached();
     }
@@ -124,6 +124,8 @@ WI.ResourceCollectionContentView = class ResourceCollectionContentView extends W
     contentViewRemoved(contentView)
     {
         this._updateImageTypeScopeBar();
+
+        contentView.removeEventListener(WI.ResourceContentView.Event.ContentError, this._handleContentError, this);
     }
 
     // Private
index 4ad25b1aa962c32f2f2da96d1f574c2dc1e4ba01..54527cd5774cbe2cd720cf2508cfb670cec7de8c 100644 (file)
@@ -187,11 +187,13 @@ WI.ResourceContentView = class ResourceContentView extends WI.ContentView
     {
         super.closed();
 
-        if (WI.NetworkManager.supportsOverridingResponses())
-            WI.networkManager.removeEventListener(null, null, this);
+        if (WI.NetworkManager.supportsOverridingResponses()) {
+            WI.networkManager.removeEventListener(WI.NetworkManager.Event.LocalResourceOverrideAdded, this._handleLocalResourceOverrideChanged, this);
+            WI.networkManager.removeEventListener(WI.NetworkManager.Event.LocalResourceOverrideRemoved, this._handleLocalResourceOverrideChanged, this);
+        }
 
         if (!this.managesOwnIssues)
-            WI.consoleManager.removeEventListener(null, null, this);
+            WI.consoleManager.removeEventListener(WI.ConsoleManager.Event.IssueAdded, this._issueWasAdded, this);
     }
 
     // Protected
index eef7a35bc55a8645e63508bea44281d848309994..045ae3cfba37ee50892c6a3f4c81620177834a2d 100644 (file)
@@ -82,7 +82,18 @@ WI.ResourceDetailsSidebarPanel = class ResourceDetailsSidebarPanel extends WI.De
             return;
 
         if (this._resource && this._needsToRemoveResourceEventListeners) {
-            this._resource.removeEventListener(null, null, this);
+            this._resource.removeEventListener(WI.Resource.Event.URLDidChange, this._refreshURL, this);
+            this._resource.removeEventListener(WI.Resource.Event.MIMETypeDidChange, this._refreshMIMEType, this);
+            this._resource.removeEventListener(WI.Resource.Event.TypeDidChange, this._refreshResourceType, this);
+            this._resource.removeEventListener(WI.Resource.Event.LoadingDidFail, this._refreshErrorReason, this);
+            this._resource.removeEventListener(WI.Resource.Event.RequestHeadersDidChange, this._refreshRequestHeaders, this);
+            this._resource.removeEventListener(WI.Resource.Event.ResponseReceived, this._refreshRequestAndResponse, this);
+            this._resource.removeEventListener(WI.Resource.Event.CacheStatusDidChange, this._refreshRequestAndResponse, this);
+            this._resource.removeEventListener(WI.Resource.Event.MetricsDidChange, this._refreshRequestAndResponse, this);
+            this._resource.removeEventListener(WI.Resource.Event.SizeDidChange, this._refreshDecodedSize, this);
+            this._resource.removeEventListener(WI.Resource.Event.TransferSizeDidChange, this._refreshTransferSize, this);
+            this._resource.removeEventListener(WI.Resource.Event.InitiatedResourcesDidChange, this._handleResourceInitiatedResourcesDidChange, this);
+
             this._refreshRelatedResourcesSectionThrottler.cancel();
 
             this._needsToRemoveResourceEventListeners = false;
@@ -622,10 +633,13 @@ WI.ResourceDetailsSidebarPanel = class ResourceDetailsSidebarPanel extends WI.De
         this._resource.addEventListener(WI.Resource.Event.MetricsDidChange, this._refreshRequestAndResponse, this);
         this._resource.addEventListener(WI.Resource.Event.SizeDidChange, this._refreshDecodedSize, this);
         this._resource.addEventListener(WI.Resource.Event.TransferSizeDidChange, this._refreshTransferSize, this);
-        this._resource.addEventListener(WI.Resource.Event.InitiatedResourcesDidChange, () => {
-            this._refreshRelatedResourcesSectionThrottler.fire();
-        }, this);
+        this._resource.addEventListener(WI.Resource.Event.InitiatedResourcesDidChange, this._handleResourceInitiatedResourcesDidChange, this);
 
         this._needsToRemoveResourceEventListeners = true;
     }
+
+    _handleResourceInitiatedResourcesDidChange(event)
+    {
+        this._refreshRelatedResourcesSectionThrottler.fire();
+    }
 };
index 1ff483b08203fb4df5c6429955726d15e9d9dcba..1622cc1f95cb703dcfaabd324f2f422fdfde24d4 100644 (file)
@@ -132,7 +132,9 @@ WI.ResourceHeadersContentView = class ResourceHeadersContentView extends WI.Cont
 
     closed()
     {
-        this._resource.removeEventListener(null, null, this);
+        this._resource.removeEventListener(WI.Resource.Event.MetricsDidChange, this._resourceMetricsDidChange, this);
+        this._resource.removeEventListener(WI.Resource.Event.RequestHeadersDidChange, this._resourceRequestHeadersDidChange, this);
+        this._resource.removeEventListener(WI.Resource.Event.ResponseReceived, this._resourceResponseReceived, this);
 
         super.closed();
     }
index e0cc8156b60387830bbaebdb66fa804a4f0dbae2..7d2a9e8a4f746084c5f8c7b6d10bc61e71b21ff5 100644 (file)
@@ -87,7 +87,10 @@ WI.ResourceSecurityContentView = class ResourceSecurityContentView extends WI.Co
 
     closed()
     {
-        this._resource.removeEventListener(null, null, this);
+        if (this.didInitialLayout) {
+            this._resource.removeEventListener(WI.Resource.Event.ResponseReceived, this._handleResourceResponseReceived, this);
+            this._resource.removeEventListener(WI.Resource.Event.MetricsDidChange, this._handleResourceMetricsDidChange, this);
+        }
 
         super.closed();
     }
index 3ec60fa67ba347be1a8c946a858dee9e15461527..98a7955f8dfa60b38b611b6bf8204d947d308212 100644 (file)
@@ -154,7 +154,9 @@ WI.ResourceSizesContentView = class ResourceSizesContentView extends WI.ContentV
 
     closed()
     {
-        this._resource.removeEventListener(null, null, this);
+        this._resource.removeEventListener(WI.Resource.Event.SizeDidChange, this._resourceSizeDidChange, this);
+        this._resource.removeEventListener(WI.Resource.Event.TransferSizeDidChange, this._resourceTransferSizeDidChange, this);
+        this._resource.removeEventListener(WI.Resource.Event.MetricsDidChange, this._resourceMetricsDidChange, this);
 
         super.closed();
     }
index e84a5f303017dcc0a1147ad08f428a08e9f23cd9..f1dd123d8b0fe41035aebffd2522845c7a04f3f3 100644 (file)
@@ -63,7 +63,8 @@ WI.ResourceTimingContentView = class ResourceTimingContentView extends WI.Conten
 
     closed()
     {
-        this._resource.removeEventListener(null, null, this);
+        this._resource.removeEventListener(WI.Resource.Event.MetricsDidChange, this._resourceMetricsDidChange, this);
+        this._resource.removeEventListener(WI.Resource.Event.TimestampsDidChange, this._resourceTimestampsDidChange, this);
 
         super.closed();
     }
index ca80f2b663e24743686b0c2ffa6fc87743766439..ddf2e40dc83207448eb84bfe0626e4415f856d46 100644 (file)
@@ -113,9 +113,12 @@ WI.ScopeChainDetailsSidebarPanel = class ScopeChainDetailsSidebarPanel extends W
 
     closed()
     {
-        WI.runtimeManager.removeEventListener(null, null, this);
-        WI.Frame.removeEventListener(null, null, this);
-        WI.debuggerManager.removeEventListener(null, null, this);
+        WI.runtimeManager.removeEventListener(WI.RuntimeManager.Event.DidEvaluate, this._didEvaluateExpression, this);
+        WI.runtimeManager.removeEventListener(WI.RuntimeManager.Event.ActiveExecutionContextChanged, this._activeExecutionContextChanged, this);
+
+        WI.Frame.removeEventListener(WI.Frame.Event.MainResourceDidChange, this._mainResourceDidChange, this);
+
+        WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.ActiveCallFrameDidChange, this._activeCallFrameDidChange, this);
 
         super.closed();
     }
@@ -267,8 +270,12 @@ WI.ScopeChainDetailsSidebarPanel = class ScopeChainDetailsSidebarPanel extends W
 
                 let treeOutline = objectTree.treeOutline;
                 treeOutline.registerScrollVirtualizer(this.contentView.element, 16);
-                treeOutline.addEventListener(WI.TreeOutline.Event.ElementAdded, this._treeElementAdded.bind(this, detailsSectionIdentifier), this);
-                treeOutline.addEventListener(WI.TreeOutline.Event.ElementDisclosureDidChanged, this._treeElementDisclosureDidChange.bind(this, detailsSectionIdentifier), this);
+                treeOutline.addEventListener(WI.TreeOutline.Event.ElementAdded, function(event) {
+                    this._treeElementAdded(detailsSectionIdentifier, event);
+                }, this);
+                treeOutline.addEventListener(WI.TreeOutline.Event.ElementDisclosureDidChanged, function(event) {
+                    this._treeElementDisclosureDidChange(detailsSectionIdentifier, event);
+                }, this);
 
                 rows.push(new WI.ObjectPropertiesDetailSectionRow(objectTree, detailsSection));
             }
@@ -303,8 +310,12 @@ WI.ScopeChainDetailsSidebarPanel = class ScopeChainDetailsSidebarPanel extends W
 
         let treeOutline = objectTree.treeOutline;
         const watchExpressionSectionIdentifier = "watch-expressions";
-        treeOutline.addEventListener(WI.TreeOutline.Event.ElementAdded, this._treeElementAdded.bind(this, watchExpressionSectionIdentifier), this);
-        treeOutline.addEventListener(WI.TreeOutline.Event.ElementDisclosureDidChanged, this._treeElementDisclosureDidChange.bind(this, watchExpressionSectionIdentifier), this);
+        treeOutline.addEventListener(WI.TreeOutline.Event.ElementAdded, function(event) {
+            this._treeElementAdded(watchExpressionSectionIdentifier, event);
+        }, this);
+        treeOutline.addEventListener(WI.TreeOutline.Event.ElementDisclosureDidChanged, function(event) {
+            this._treeElementDisclosureDidChange(watchExpressionSectionIdentifier, event);
+        }, this);
         treeOutline.objectTreeElementAddContextMenuItems = this._objectTreeElementAddContextMenuItems.bind(this);
 
         let promises = [];
index 8908830ed997cec61c9c4a8abf9ec232b94a4f89..b7f6138b96a7db5c21b1f606563936f15808f25c 100644 (file)
@@ -132,8 +132,8 @@ WI.ScriptContentView = class ScriptContentView extends WI.ContentView
     {
         super.closed();
 
-        WI.settings.showJavaScriptTypeInformation.removeEventListener(null, null, this);
-        WI.settings.enableControlFlowProfiler.removeEventListener(null, null, this);
+        WI.settings.showJavaScriptTypeInformation.removeEventListener(WI.Setting.Event.Changed, this._showJavaScriptTypeInformationSettingChanged, this);
+        WI.settings.enableControlFlowProfiler.removeEventListener(WI.Setting.Event.Changed, this._enableControlFlowProfilerSettingChanged, this);
 
         this._textEditor.close();
     }
index 2781241a203b6fabbf0e5dc784a6c037f35c0a18..564d5cf50d90417bdbe974b85fd74e796f512b0b 100644 (file)
@@ -106,8 +106,8 @@ WI.ScriptDetailsTimelineView = class ScriptDetailsTimelineView extends WI.Timeli
 
     closed()
     {
-        console.assert(this.representedObject instanceof WI.Timeline);
-        this.representedObject.removeEventListener(null, null, this);
+        this.representedObject.removeEventListener(WI.Timeline.Event.RecordAdded, this._scriptTimelineRecordAdded, this);
+        this.representedObject.removeEventListener(WI.Timeline.Event.Refreshed, this._scriptTimelineRecordRefreshed, this);
 
         this._dataGrid.closed();
     }
index ecb6c8078a4224ec4ca7b550c701cb068a882f3f..e8099902114525d989e9903e22d422a8e413c237 100644 (file)
@@ -82,8 +82,7 @@ WI.ScriptProfileTimelineView = class ScriptProfileTimelineView extends WI.Timeli
 
     closed()
     {
-        console.assert(this.representedObject instanceof WI.Timeline);
-        this.representedObject.removeEventListener(null, null, this);
+        this.representedObject.removeEventListener(WI.Timeline.Event.Refreshed, this._scriptTimelineRecordRefreshed, this);
     }
 
     get navigationItems()
index 0aa156663069c5c11ac17892d69ffa2a48218b64..18bc02f2e7930a0577c2cf27e5946871137d3916 100644 (file)
@@ -29,11 +29,12 @@ WI.SearchSidebarPanel = class SearchSidebarPanel extends WI.NavigationSidebarPan
     {
         super("search", WI.UIString("Search"), true, true);
 
-        this._searchInputSettings = WI.SearchUtilities.createSettings("search-sidebar", {
-            handleChanged: (event) => {
+        this._searchInputSettings = WI.SearchUtilities.createSettings("search-sidebar");
+        for (let setting of Object.values(this._searchInputSettings)) {
+            setting.addEventListener(WI.Setting.Event.Changed, function(event) {
                 this.focusSearchField(true);
-            },
-        });
+            }, this);
+        }
 
         this._inputContainer = this.element.appendChild(document.createElement("div"));
         this._inputContainer.classList.add("search-bar");
@@ -79,7 +80,7 @@ WI.SearchSidebarPanel = class SearchSidebarPanel extends WI.NavigationSidebarPan
     {
         super.closed();
 
-        WI.Frame.removeEventListener(null, null, this);
+        WI.Frame.removeEventListener(WI.Frame.Event.MainResourceDidChange, this._mainResourceDidChange, this);
     }
 
     focusSearchField(performSearch)
@@ -234,8 +235,8 @@ WI.SearchSidebarPanel = class SearchSidebarPanel extends WI.NavigationSidebarPan
             }
 
             let promises = [
-                WI.Frame.awaitEvent(WI.Frame.Event.ResourceWasAdded),
-                WI.Target.awaitEvent(WI.Target.Event.ResourceAdded)
+                WI.Frame.awaitEvent(WI.Frame.Event.ResourceWasAdded, this),
+                WI.Target.awaitEvent(WI.Target.Event.ResourceAdded, this),
             ];
             Promise.race(promises).then(this._contentChanged.bind(this));
         };
index 3d451c2fac7c4ab2f9c0aae83cb79cad476bc5aa..ef9903e85f0d5b696fd043a200a9453c80be013b 100644 (file)
@@ -56,8 +56,12 @@ WI.SettingEditor = class SettingEditor extends WI.Object
 
         let editor = new WI.SettingEditor(type, label, options);
         editor.value = setting.value;
-        editor.addEventListener(WI.SettingEditor.Event.ValueDidChange, () => { setting.value = editor.value; });
-        setting.addEventListener(WI.Setting.Event.Changed, () => { editor.value = setting.value; });
+        editor.addEventListener(WI.SettingEditor.Event.ValueDidChange, function(event) {
+            this.value = editor.value;
+        }, setting);
+        setting.addEventListener(WI.Setting.Event.Changed, function(event) {
+            this.value = setting.value;
+        }, editor);
 
         return editor;
     }
index 1290bda472c16a8350c304ed08e00e3e2b6fb287..a1463f3edb6941ebf1a54439aa824faa260192d1 100644 (file)
@@ -212,9 +212,9 @@ WI.SettingsTabContentView = class SettingsTabContentView extends WI.TabContentVi
             ];
             let appearanceEditor = generalSettingsView.addGroupWithCustomSetting(WI.UIString("Appearance:"), WI.SettingEditor.Type.Select, {values: appearanceValues});
             appearanceEditor.value = WI.settings.frontendAppearance.value;
-            appearanceEditor.addEventListener(WI.SettingEditor.Event.ValueDidChange, () => {
-                WI.settings.frontendAppearance.value = appearanceEditor.value;
-            }, WI.settings.frontendAppearance);
+            appearanceEditor.addEventListener(WI.SettingEditor.Event.ValueDidChange, function(event) {
+                WI.settings.frontendAppearance.value = this.value;
+            }, appearanceEditor);
 
             generalSettingsView.addSeparator();
         }
@@ -222,9 +222,9 @@ WI.SettingsTabContentView = class SettingsTabContentView extends WI.TabContentVi
         const indentValues = [WI.UIString("Tabs"), WI.UIString("Spaces")];
         let indentEditor = generalSettingsView.addGroupWithCustomSetting(WI.UIString("Prefer indent using:"), WI.SettingEditor.Type.Select, {values: indentValues});
         indentEditor.value = indentValues[WI.settings.indentWithTabs.value ? 0 : 1];
-        indentEditor.addEventListener(WI.SettingEditor.Event.ValueDidChange, () => {
-            WI.settings.indentWithTabs.value = indentEditor.value === indentValues[0];
-        });
+        indentEditor.addEventListener(WI.SettingEditor.Event.ValueDidChange, function(event) {
+            WI.settings.indentWithTabs.value = this.value === indentValues[0];
+        }, indentEditor);
 
         function addSpacesSetting(title, setting) {
             let editor = generalSettingsView.addSetting(title, setting, WI.UIString("spaces"), {min: 1});
@@ -232,9 +232,9 @@ WI.SettingsTabContentView = class SettingsTabContentView extends WI.TabContentVi
             function updateLabel() {
                 editor.label = setting.value === 1 ? WI.UIString("space") : WI.UIString("spaces");
             }
-            setting.addEventListener(WI.Setting.Event.Changed, (event) => {
+            setting.addEventListener(WI.Setting.Event.Changed, function(event) {
                 updateLabel();
-            });
+            }, editor);
             updateLabel();
         }
         addSpacesSetting(WI.UIString("Tab width:"), WI.settings.tabSize);
@@ -260,8 +260,12 @@ WI.SettingsTabContentView = class SettingsTabContentView extends WI.TabContentVi
 
         let zoomEditor = generalSettingsView.addGroupWithCustomSetting(WI.UIString("Zoom:"), WI.SettingEditor.Type.Select, {values: zoomValues});
         zoomEditor.value = WI.getZoomFactor();
-        zoomEditor.addEventListener(WI.SettingEditor.Event.ValueDidChange, () => { WI.setZoomFactor(zoomEditor.value); });
-        WI.settings.zoomFactor.addEventListener(WI.Setting.Event.Changed, () => { zoomEditor.value = WI.getZoomFactor().maxDecimals(2); });
+        zoomEditor.addEventListener(WI.SettingEditor.Event.ValueDidChange, function(event) {
+            WI.setZoomFactor(this.value);
+        }, zoomEditor);
+        WI.settings.zoomFactor.addEventListener(WI.Setting.Event.Changed, function(event) {
+            this.value = WI.getZoomFactor().maxDecimals(2);
+        }, zoomEditor);
 
         this._createReferenceLink(generalSettingsView);
 
@@ -359,10 +363,10 @@ WI.SettingsTabContentView = class SettingsTabContentView extends WI.TabContentVi
 
                 let logEditor = consoleSettingsView.addGroupWithCustomSetting(label, WI.SettingEditor.Type.Select, {values: logLevels});
                 logEditor.value = channel.level;
-                logEditor.addEventListener(WI.SettingEditor.Event.ValueDidChange, () => {
+                logEditor.addEventListener(WI.SettingEditor.Event.ValueDidChange, function(event) {
                     for (let target of WI.targets)
-                        target.ConsoleAgent.setLoggingChannelLevel(channel.source, logEditor.value);
-                });
+                        target.ConsoleAgent.setLoggingChannelLevel(channel.source, this.value);
+                }, logEditor);
             }
         }
 
@@ -409,9 +413,9 @@ WI.SettingsTabContentView = class SettingsTabContentView extends WI.TabContentVi
 
         function listenForChange(setting) {
             initialValues.set(setting, setting.value);
-            setting.addEventListener(WI.Setting.Event.Changed, () => {
-                reloadInspectorContainerElement.classList.toggle("hidden", Array.from(initialValues).every(([setting, initialValue]) => setting.value === initialValue));
-            });
+            setting.addEventListener(WI.Setting.Event.Changed, function(event) {
+                this.classList.toggle("hidden", Array.from(initialValues).every(([setting, initialValue]) => setting.value === initialValue));
+            }, reloadInspectorContainerElement);
         }
 
         listenForChange(WI.settings.experimentalEnablePreviewFeatures);
@@ -465,9 +469,9 @@ WI.SettingsTabContentView = class SettingsTabContentView extends WI.TabContentVi
         let protocolMessagesGroup = this._debugSettingsView.addGroup(WI.unlocalizedString("Protocol Logging:"));
 
         let protocolAutoLogMessagesEditor = protocolMessagesGroup.addSetting(WI.settings.protocolAutoLogMessages, WI.unlocalizedString("Messages"));
-        WI.settings.protocolAutoLogMessages.addEventListener(WI.Setting.Event.Changed, () => {
-            protocolAutoLogMessagesEditor.value = InspectorBackend.dumpInspectorProtocolMessages;
-        });
+        WI.settings.protocolAutoLogMessages.addEventListener(WI.Setting.Event.Changed, function(event) {
+            this.value = InspectorBackend.dumpInspectorProtocolMessages;
+        }, protocolAutoLogMessagesEditor);
 
         protocolMessagesGroup.addSetting(WI.settings.protocolAutoLogTimeStats, WI.unlocalizedString("Time Stats"));
         protocolMessagesGroup.addSetting(WI.settings.protocolLogAsText, WI.unlocalizedString("Log as Text"));
@@ -503,7 +507,9 @@ WI.SettingsTabContentView = class SettingsTabContentView extends WI.TabContentVi
 
         let layoutDirectionEditor = this._debugSettingsView.addGroupWithCustomSetting(WI.unlocalizedString("Layout Direction:"), WI.SettingEditor.Type.Select, {values: layoutDirectionValues});
         layoutDirectionEditor.value = WI.settings.debugLayoutDirection.value;
-        layoutDirectionEditor.addEventListener(WI.SettingEditor.Event.ValueDidChange, () => { WI.setLayoutDirection(layoutDirectionEditor.value); });
+        layoutDirectionEditor.addEventListener(WI.SettingEditor.Event.ValueDidChange, function(event) {
+            WI.setLayoutDirection(this.value);
+        }, layoutDirectionEditor);
 
         this._debugSettingsView.addSeparator();
 
index 0f6840b0191a82254f9894e3f5fb3fefccbc8c58..51ef61155320cd9e2094bf5371c5b3e42b8fcf8c 100644 (file)
@@ -56,9 +56,9 @@ WI.ShaderProgramContentView = class ShaderProgramContentView extends WI.ContentV
             textEditor.readOnly = false;
             textEditor.addEventListener(WI.TextEditor.Event.Focused, this._editorFocused, this);
             textEditor.addEventListener(WI.TextEditor.Event.NumberOfSearchResultsDidChange, this._numberOfSearchResultsDidChange, this);
-            textEditor.addEventListener(WI.TextEditor.Event.ContentDidChange, (event) => {
+            textEditor.addEventListener(WI.TextEditor.Event.ContentDidChange, function(event) {
                 contentDidChangeDebouncer.delayForTime(250, event);
-            }, this);
+            }, textEditor);
 
             switch (shaderType) {
             case WI.ShaderProgram.ShaderType.Compute:
index 3e96ffebbbc9450dbf97a35f53ec0fb040891f6c..9aabb3eb78e4a0282495b3e050105e4f2e63c967 100644 (file)
@@ -168,9 +168,23 @@ WI.SourceCodeTextEditor = class SourceCodeTextEditor extends WI.TextEditor
     close()
     {
         if (this._supportsDebugging) {
-            WI.JavaScriptBreakpoint.removeEventListener(null, null, this);
-            WI.debuggerManager.removeEventListener(null, null, this);
-            WI.targetManager.removeEventListener(null, null, this);
+            WI.JavaScriptBreakpoint.removeEventListener(WI.Breakpoint.Event.DisabledStateDidChange, this._breakpointStatusDidChange, this);
+            WI.JavaScriptBreakpoint.removeEventListener(WI.Breakpoint.Event.AutoContinueDidChange, this._breakpointStatusDidChange, this);
+
+            WI.JavaScriptBreakpoint.removeEventListener(WI.JavaScriptBreakpoint.Event.ResolvedStateDidChange, this._breakpointStatusDidChange, this);
+            WI.JavaScriptBreakpoint.removeEventListener(WI.JavaScriptBreakpoint.Event.LocationDidChange, this._updateBreakpointLocation, this);
+
+            WI.targetManager.removeEventListener(WI.TargetManager.Event.TargetAdded, this._targetAdded, this);
+            WI.targetManager.removeEventListener(WI.TargetManager.Event.TargetRemoved, this._targetRemoved, this);
+
+            WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.BreakpointsEnabledDidChange, this._breakpointsEnabledDidChange, this);
+            WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.BreakpointAdded, this._breakpointAdded, this);
+            WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.BreakpointRemoved, this._breakpointRemoved, this);
+            WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.CallFramesDidChange, this._callFramesDidChange, this);
+            WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.ActiveCallFrameDidChange, this._activeCallFrameDidChange, this);
+
+            WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.Paused, this._debuggerDidPause, this);
+            WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.Resumed, this._debuggerDidResume, this);
 
             if (this._activeCallFrameSourceCodeLocation) {
                 this._activeCallFrameSourceCodeLocation.removeEventListener(WI.SourceCodeLocation.Event.LocationChanged, this._activeCallFrameSourceCodeLocationChanged, this);
@@ -178,9 +192,15 @@ WI.SourceCodeTextEditor = class SourceCodeTextEditor extends WI.TextEditor
             }
         }
 
-        WI.consoleManager.removeEventListener(null, null, this);
-        WI.notifications.removeEventListener(null, null, this);
-        this._sourceCode.removeEventListener(null, null, this);
+        WI.consoleManager.removeEventListener(WI.ConsoleManager.Event.IssueAdded, this._issueWasAdded, this);
+
+        this._sourceCode.removeEventListener(WI.SourceCode.Event.FormatterDidChange, this._handleFormatterDidChange, this);
+        if (this._sourceCode instanceof WI.SourceMapResource || this._sourceCode.sourceMaps.length > 0)
+            WI.notifications.removeEventListener(WI.Notification.GlobalModifierKeysDidChange, this._updateTokenTrackingControllerState, this);
+        else
+            this._sourceCode.removeEventListener(WI.SourceCode.Event.SourceMapAdded, this._sourceCodeSourceMapAdded, this);
+
+        WI.consoleManager.removeEventListener(WI.ConsoleManager.Event.Cleared, this._logCleared, this);
     }
 
     canBeFormatted()
@@ -1866,12 +1886,16 @@ WI.SourceCodeTextEditor = class SourceCodeTextEditor extends WI.TextEditor
 
         content.classList.add(WI.SourceCodeTextEditor.PopoverDebuggerContentStyleClassName);
 
-        this._popover = this._popover || new WI.Popover(this);
+        if (!this._popover) {
+            this._popover = new WI.Popover(this);
+            this._popover.element.addEventListener("mouseover", this._popoverMouseover.bind(this));
+            this._popover.element.addEventListener("mouseout", this._popoverMouseout.bind(this));
+        }
+
         this._popover.presentNewContentWithFrame(content, bounds.pad(5), [WI.RectEdge.MIN_Y, WI.RectEdge.MAX_Y, WI.RectEdge.MAX_X]);
+
         if (shouldHighlightRange)
             this.tokenTrackingController.highlightRange(candidate.expressionRange);
-
-        this._trackPopoverEvents();
     }
 
     _showPopoverForFunction(data)
@@ -1979,10 +2003,9 @@ WI.SourceCodeTextEditor = class SourceCodeTextEditor extends WI.TextEditor
 
         // Show the popover once we have the first set of properties for the object.
         var candidate = this.tokenTrackingController.candidate;
-        objectTree.addEventListener(WI.ObjectTreeView.Event.Updated, function() {
+        objectTree.singleFireEventListener(WI.ObjectTreeView.Event.Updated, function(event) {
             if (candidate === this.tokenTrackingController.candidate)
                 this._showPopover(content);
-            objectTree.removeEventListener(null, null, this);
         }, this);
     }
 
@@ -2007,23 +2030,6 @@ WI.SourceCodeTextEditor = class SourceCodeTextEditor extends WI.TextEditor
             return;
 
         this._popover.dismiss();
-
-        if (this._popoverEventListeners && this._popoverEventListenersAreRegistered) {
-            this._popoverEventListenersAreRegistered = false;
-            this._popoverEventListeners.unregister();
-        }
-    }
-
-    _trackPopoverEvents()
-    {
-        if (!this._popoverEventListeners)
-            this._popoverEventListeners = new WI.EventListenerSet(this, "Popover listeners");
-        if (!this._popoverEventListenersAreRegistered) {
-            this._popoverEventListenersAreRegistered = true;
-            this._popoverEventListeners.register(this._popover.element, "mouseover", this._popoverMouseover);
-            this._popoverEventListeners.register(this._popover.element, "mouseout", this._popoverMouseout);
-            this._popoverEventListeners.install();
-        }
     }
 
     _popoverMouseover(event)
index f7ca3c7acff222b497168980de00dea28a05ae7e..cbdd14a7ca7e6943351d97c7d971fa5fa30b1a32 100644 (file)
@@ -359,7 +359,7 @@ WI.SourcesNavigationSidebarPanel = class SourcesNavigationSidebarPanel extends W
 
         if (WI.SourcesNavigationSidebarPanel.shouldPlaceResourcesAtTopLevel()) {
             this._resourcesTreeOutline.disclosureButtons = false;
-            WI.SourceCode.addEventListener(WI.SourceCode.Event.SourceMapAdded, () => {
+            WI.SourceCode.addEventListener(WI.SourceCode.Event.SourceMapAdded, function(event) {
                 this._resourcesTreeOutline.disclosureButtons = true;
             }, this);
         }
@@ -457,22 +457,66 @@ WI.SourcesNavigationSidebarPanel = class SourcesNavigationSidebarPanel extends W
 
     closed()
     {
-        WI.settings.resourceGroupingMode.removeEventListener(null, null, this);
-        WI.Frame.removeEventListener(null, null, this);
-        WI.Target.removeEventListener(null, null, this);
-        WI.networkManager.removeEventListener(null, null, this);
-        WI.debuggerManager.removeEventListener(null, null, this);
-        WI.domDebuggerManager.removeEventListener(null, null, this);
-        WI.JavaScriptBreakpoint.removeEventListener(null, null, this);
-        WI.IssueMessage.removeEventListener(null, null, this);
-        WI.DOMBreakpoint.removeEventListener(null, null, this);
-        WI.consoleManager.removeEventListener(null, null, this);
-        WI.timelineManager.removeEventListener(null, null, this);
-        WI.auditManager.removeEventListener(null, null, this);
-        WI.cssManager.removeEventListener(null, null, this);
-        WI.targetManager.removeEventListener(null, null, this);
-        WI.notifications.removeEventListener(null, null, this);
-        WI.SourceCode.removeEventListener(null, null, this);
+        WI.settings.resourceGroupingMode.removeEventListener(WI.Setting.Event.Changed, this._handleResourceGroupingModeChanged, this);
+
+        WI.Frame.removeEventListener(WI.Frame.Event.MainResourceDidChange, this._handleFrameMainResourceDidChange, this);
+        WI.Frame.removeEventListener(WI.Frame.Event.ResourceWasAdded, this._handleResourceAdded, this);
+        WI.Target.removeEventListener(WI.Target.Event.ResourceAdded, this._handleResourceAdded, this);
+
+        WI.networkManager.removeEventListener(WI.NetworkManager.Event.FrameWasAdded, this._handleFrameWasAdded, this);
+
+        if (WI.NetworkManager.supportsBootstrapScript()) {
+            WI.networkManager.removeEventListener(WI.NetworkManager.Event.BootstrapScriptCreated, this._handleBootstrapScriptCreated, this);
+            WI.networkManager.removeEventListener(WI.NetworkManager.Event.BootstrapScriptDestroyed, this._handleBootstrapScriptDestroyed, this);
+        }
+
+        if (WI.NetworkManager.supportsOverridingResponses()) {
+            WI.networkManager.removeEventListener(WI.NetworkManager.Event.LocalResourceOverrideAdded, this._handleLocalResourceOverrideAdded, this);
+            WI.networkManager.removeEventListener(WI.NetworkManager.Event.LocalResourceOverrideRemoved, this._handleLocalResourceOverrideRemoved, this);
+        }
+
+        WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.BreakpointAdded, this._handleDebuggerBreakpointAdded, this);
+        WI.domDebuggerManager.removeEventListener(WI.DOMDebuggerManager.Event.DOMBreakpointAdded, this._handleDebuggerBreakpointAdded, this);
+        WI.domDebuggerManager.removeEventListener(WI.DOMDebuggerManager.Event.EventBreakpointAdded, this._handleDebuggerBreakpointAdded, this);
+        WI.domDebuggerManager.removeEventListener(WI.DOMDebuggerManager.Event.URLBreakpointAdded, this._handleDebuggerBreakpointAdded, this);
+
+        WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.BreakpointRemoved, this._handleDebuggerBreakpointRemoved, this);
+        WI.domDebuggerManager.removeEventListener(WI.DOMDebuggerManager.Event.DOMBreakpointRemoved, this._handleDebuggerBreakpointRemoved, this);
+        WI.domDebuggerManager.removeEventListener(WI.DOMDebuggerManager.Event.EventBreakpointRemoved, this._handleDebuggerBreakpointRemoved, this);
+        WI.domDebuggerManager.removeEventListener(WI.DOMDebuggerManager.Event.URLBreakpointRemoved, this._handleDebuggerBreakpointRemoved, this);
+
+        WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.BreakpointsEnabledDidChange, this._handleDebuggerBreakpointsEnabledDidChange, this);
+        WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.ScriptAdded, this._handleDebuggerScriptAdded, this);
+        WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.ScriptRemoved, this._handleDebuggerScriptRemoved, this);
+        WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.ScriptsCleared, this._handleDebuggerScriptsCleared, this);
+        WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.Paused, this._handleDebuggerPaused, this);
+        WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.Resumed, this._handleDebuggerResumed, this);
+        WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.CallFramesDidChange, this._handleDebuggerCallFramesDidChange, this);
+        WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.ActiveCallFrameDidChange, this._handleDebuggerActiveCallFrameDidChange, this);
+        WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.WaitingToPause, this._handleDebuggerWaitingToPause, this);
+
+        WI.JavaScriptBreakpoint.removeEventListener(WI.JavaScriptBreakpoint.Event.DisplayLocationDidChange, this._handleDebuggerObjectDisplayLocationDidChange, this);
+        WI.IssueMessage.removeEventListener(WI.IssueMessage.Event.DisplayLocationDidChange, this._handleDebuggerObjectDisplayLocationDidChange, this);
+
+        WI.DOMBreakpoint.removeEventListener(WI.DOMBreakpoint.Event.DOMNodeWillChange, this._handleDOMBreakpointDOMNodeWillChange, this);
+        WI.DOMBreakpoint.removeEventListener(WI.DOMBreakpoint.Event.DOMNodeDidChange, this._handleDOMBreakpointDOMNodeDidChange, this);
+
+        WI.consoleManager.removeEventListener(WI.ConsoleManager.Event.IssueAdded, this._handleConsoleIssueAdded, this);
+        WI.consoleManager.removeEventListener(WI.ConsoleManager.Event.Cleared, this._handleConsoleCleared, this);
+
+        WI.timelineManager.removeEventListener(WI.TimelineManager.Event.CapturingStateChanged, this._handleTimelineCapturingStateChanged, this);
+
+        WI.auditManager.removeEventListener(WI.AuditManager.Event.TestScheduled, this._handleAuditManagerTestScheduled, this);
+        WI.auditManager.removeEventListener(WI.AuditManager.Event.TestCompleted, this._handleAuditManagerTestCompleted, this);
+
+        WI.cssManager.removeEventListener(WI.CSSManager.Event.StyleSheetAdded, this._handleCSSStyleSheetAdded, this);
+        WI.cssManager.removeEventListener(WI.CSSManager.Event.StyleSheetRemoved, this._handleCSSStyleSheetRemoved, this);
+
+        WI.targetManager.removeEventListener(WI.TargetManager.Event.TargetAdded, this._handleTargetAdded, this);
+        WI.targetManager.removeEventListener(WI.TargetManager.Event.TargetRemoved, this._handleTargetRemoved, this);
+
+        // COMPATIBILITY (iOS 14.0): Inspector.activateExtraDomains was removed in favor of a declared debuggable type
+        WI.notifications.removeEventListener(WI.Notification.ExtraDomainsActivated, this._handleExtraDomainsActivated, this);
 
         super.closed();
     }
@@ -695,7 +739,7 @@ WI.SourcesNavigationSidebarPanel = class SourcesNavigationSidebarPanel extends W
     {
         let treeOutline = super.createContentTreeOutline(options);
 
-        treeOutline.addEventListener(WI.TreeOutline.Event.ElementRevealed, (event) => {
+        treeOutline.addEventListener(WI.TreeOutline.Event.ElementRevealed, function(event) {
             let treeElement = event.data.element;
             let detailsSections = [this._pauseReasonSection, this._callStackSection, this._breakpointsSection, this._localOverridesSection];
             let detailsSection = detailsSections.find((detailsSection) => detailsSection.element.contains(treeElement.listItemElement));
@@ -709,7 +753,7 @@ WI.SourcesNavigationSidebarPanel = class SourcesNavigationSidebarPanel extends W
             let offset = detailsSection.headerElement.totalOffsetBottom - treeElement.listItemElement.totalOffsetTop;
             if (offset > 0)
                 this.scrollElement.scrollBy(0, -offset);
-        });
+        }, this);
 
         return treeOutline;
     }
index 985e0c9258e4f2746e19955e920f774615cdd117..7086785d5cd6f5046006ad8c45e0e1e4da4517b0 100644 (file)
@@ -138,12 +138,12 @@ WI.SpreadsheetCSSStyleDeclarationSection = class SpreadsheetCSSStyleDeclarationS
 
         if (this._style.selectorEditable) {
             this._selectorTextField = new WI.SpreadsheetSelectorField(this, this._selectorElement);
-            this._selectorTextField.addEventListener(WI.SpreadsheetSelectorField.Event.StartedEditing, (event) => {
+            this._selectorTextField.addEventListener(WI.SpreadsheetSelectorField.Event.StartedEditing, function(event) {
                 this._headerElement.classList.add("editing-selector");
-            });
-            this._selectorTextField.addEventListener(WI.SpreadsheetSelectorField.Event.StoppedEditing, (event) => {
+            }, this);
+            this._selectorTextField.addEventListener(WI.SpreadsheetSelectorField.Event.StoppedEditing, function(event) {
                 this._headerElement.classList.remove("editing-selector");
-            });
+            }, this);
 
             this._selectorElement.tabIndex = 0;
         }
index d4ad191cc8c06a4439a98a19fc2d4f6550932622..39c8ee6628fe09b6b2e945b2e3bcee74214712ef 100644 (file)
@@ -515,7 +515,7 @@ WI.SpreadsheetStyleProperty = class SpreadsheetStyleProperty extends WI.Object
         let readOnly = !this._isEditable();
         let swatch = new WI.InlineSwatch(type, valueObject, readOnly);
 
-        swatch.addEventListener(WI.InlineSwatch.Event.ValueChanged, (event) => {
+        swatch.addEventListener(WI.InlineSwatch.Event.ValueChanged, function(event) {
             let value = event.data.value && event.data.value.toString();
             if (!value)
                 return;
@@ -534,15 +534,15 @@ WI.SpreadsheetStyleProperty = class SpreadsheetStyleProperty extends WI.Object
         }
 
         if (this._delegate && typeof this._delegate.stylePropertyInlineSwatchActivated === "function") {
-            swatch.addEventListener(WI.InlineSwatch.Event.Activated, () => {
+            swatch.addEventListener(WI.InlineSwatch.Event.Activated, function(event) {
                 this._delegate.stylePropertyInlineSwatchActivated();
-            });
+            }, this);
         }
 
         if (this._delegate && typeof this._delegate.stylePropertyInlineSwatchDeactivated === "function") {
-            swatch.addEventListener(WI.InlineSwatch.Event.Deactivated, () => {
+            swatch.addEventListener(WI.InlineSwatch.Event.Deactivated, function(event) {
                 this._delegate.stylePropertyInlineSwatchDeactivated();
-            });
+            }, this);
         }
 
         tokenElement.append(swatch.element, innerElement);
index c063c17d424ea76ea4663fa9b18e24bb6bc1e47f..f4f22ae9a9a7d7637822fa1817aba05ae6b2edbc 100644 (file)
@@ -120,10 +120,18 @@ WI.StorageSidebarPanel = class StorageSidebarPanel extends WI.NavigationSidebarP
     {
         super.closed();
 
-        WI.domStorageManager.removeEventListener(null, null, this);
-        WI.databaseManager.removeEventListener(null, null, this);
-        WI.indexedDBManager.removeEventListener(null, null, this);
-        WI.applicationCacheManager.removeEventListener(null, null, this);
+        WI.domStorageManager.removeEventListener(WI.DOMStorageManager.Event.CookieStorageObjectWasAdded, this._cookieStorageObjectWasAdded, this);
+        WI.domStorageManager.removeEventListener(WI.DOMStorageManager.Event.DOMStorageObjectWasAdded, this._domStorageObjectWasAdded, this);
+        WI.domStorageManager.removeEventListener(WI.DOMStorageManager.Event.DOMStorageObjectWasInspected, this._domStorageObjectWasInspected, this);
+        WI.domStorageManager.removeEventListener(WI.DOMStorageManager.Event.Cleared, this._domStorageCleared, this);
+        WI.databaseManager.removeEventListener(WI.DatabaseManager.Event.DatabaseWasAdded, this._databaseWasAdded, this);
+        WI.databaseManager.removeEventListener(WI.DatabaseManager.Event.DatabaseWasInspected, this._databaseWasInspected, this);
+        WI.databaseManager.removeEventListener(WI.DatabaseManager.Event.Cleared, this._databaseCleared, this);
+        WI.indexedDBManager.removeEventListener(WI.IndexedDBManager.Event.IndexedDatabaseWasAdded, this._indexedDatabaseWasAdded, this);
+        WI.indexedDBManager.removeEventListener(WI.IndexedDBManager.Event.Cleared, this._indexedDatabaseCleared, this);
+        WI.applicationCacheManager.removeEventListener(WI.ApplicationCacheManager.Event.FrameManifestAdded, this._frameManifestAdded, this);
+        WI.applicationCacheManager.removeEventListener(WI.ApplicationCacheManager.Event.FrameManifestRemoved, this._frameManifestRemoved, this);
+        WI.applicationCacheManager.removeEventListener(WI.ApplicationCacheManager.Event.Cleared, this._applicationCacheCleared, this);
     }
 
     // Protected
index b6682079f43eafea5332ab8c35bd3d7b3197af16..74d0ce2af4d75e42f276eb17142b56adf78e4c8d 100644 (file)
@@ -132,11 +132,11 @@ WI.TextResourceContentView = class TextResourceContentView extends WI.ResourceCo
     {
         super.closed();
 
-        this.resource.removeEventListener(null, null, this);
-        WI.debuggerManager.removeEventListener(null, null, this);
-        WI.networkManager.removeEventListener(null, null, this);
-        WI.settings.showJavaScriptTypeInformation.removeEventListener(null, null, this);
-        WI.settings.enableControlFlowProfiler.removeEventListener(null, null, this);
+        this.resource.removeEventListener(WI.SourceCode.Event.ContentDidChange, this._sourceCodeContentDidChange, this);
+        WI.settings.showJavaScriptTypeInformation.removeEventListener(WI.Setting.Event.Changed, this._showJavaScriptTypeInformationSettingChanged, this);
+        WI.settings.enableControlFlowProfiler.removeEventListener(WI.Setting.Event.Changed, this._enableControlFlowProfilerSettingChanged, this);
+        WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.ProbeSetAdded, this._probeSetsChanged, this);
+        WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.ProbeSetRemoved, this._probeSetsChanged, this);
     }
 
     contentAvailable(content, base64Encoded)
index e81e97ed74b66d4486af21cc5f3f76dc5ee8843c..7a1dc1fb0847ad8a5b4591d909e4195b99ffa9a4 100644 (file)
@@ -141,7 +141,9 @@ WI.ThreadTreeElement = class ThreadTreeElement extends WI.GeneralTreeElement
         if (!this._statusButton) {
             let tooltip = WI.UIString("Resume Thread");
             this._statusButton = new WI.TreeElementStatusButton(WI.ImageUtilities.useSVGSymbol("Images/Resume.svg", "resume", tooltip));
-            this._statusButton.addEventListener(WI.TreeElementStatusButton.Event.Clicked, () => { WI.debuggerManager.continueUntilNextRunLoop(this._target); });
+            this._statusButton.addEventListener(WI.TreeElementStatusButton.Event.Clicked, function(event) {
+                WI.debuggerManager.continueUntilNextRunLoop(this._target);
+            }, this);
             this._statusButton.element.addEventListener("mousedown", (event) => {
                 // Prevent tree element from being selected.
                 event.stopPropagation();
index bff127bab4eb46ab05c657bc98da7f3a9903449b..14e4d18dafa550d2f28d9d945466e04f0013f92d 100644 (file)
@@ -381,7 +381,8 @@ WI.TimelineOverview = class TimelineOverview extends WI.View
 
     closed()
     {
-        WI.timelineManager.removeEventListener(null, null, this);
+        WI.timelineManager.removeEventListener(WI.TimelineManager.Event.CapturingStateChanged, this._handleTimelineCapturingStateChanged, this);
+        WI.timelineManager.removeEventListener(WI.TimelineManager.Event.RecordingImported, this._recordingImported, this);
 
         super.closed();
     }
index 1f91fc6c7a6b39c7c5eb3394d4f75fef5a5fc174..d5fa1e58e66561eb4df5a10d6f582546db446be7 100644 (file)
@@ -99,7 +99,7 @@ WI.TimelineRecordingContentView = class TimelineRecordingContentView extends WI.
         this._recording.addEventListener(WI.TimelineRecording.Event.InstrumentAdded, this._instrumentAdded, this);
         this._recording.addEventListener(WI.TimelineRecording.Event.InstrumentRemoved, this._instrumentRemoved, this);
         this._recording.addEventListener(WI.TimelineRecording.Event.Reset, this._recordingReset, this);
-        this._recording.addEventListener(WI.TimelineRecording.Event.Unloaded, this._recordingUnloaded, this);
+        this._recording.singleFireEventListener(WI.TimelineRecording.Event.Unloaded, this._recordingUnloaded, this);
 
         WI.timelineManager.addEventListener(WI.TimelineManager.Event.CapturingStateChanged, this._handleTimelineCapturingStateChanged, this);
 
@@ -245,11 +245,25 @@ WI.TimelineRecordingContentView = class TimelineRecordingContentView extends WI.
 
         this._timelineContentBrowser.contentViewContainer.closeAllContentViews();
 
-        this._recording.removeEventListener(null, null, this);
+        this._recording.removeEventListener(WI.TimelineRecording.Event.InstrumentAdded, this._instrumentAdded, this);
+        this._recording.removeEventListener(WI.TimelineRecording.Event.InstrumentRemoved, this._instrumentRemoved, this);
+        this._recording.removeEventListener(WI.TimelineRecording.Event.Reset, this._recordingReset, this);
+        if (!this._recording.readonly)
+            this._recording.removeEventListener(WI.TimelineRecording.Event.Unloaded, this._recordingUnloaded, this);
 
-        WI.timelineManager.removeEventListener(null, null, this);
-        WI.debuggerManager.removeEventListener(null, null, this);
-        WI.ContentView.removeEventListener(null, null, this);
+        WI.timelineManager.removeEventListener(WI.TimelineManager.Event.CapturingStateChanged, this._handleTimelineCapturingStateChanged, this);
+
+        WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.Paused, this._debuggerPaused, this);
+        WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.Resumed, this._debuggerResumed, this);
+
+        WI.ContentView.removeEventListener(WI.ContentView.Event.SelectionPathComponentsDidChange, this._contentViewSelectionPathComponentDidChange, this);
+        WI.ContentView.removeEventListener(WI.ContentView.Event.SupplementalRepresentedObjectsDidChange, this._contentViewSupplementalRepresentedObjectsDidChange, this);
+
+        WI.TimelineView.removeEventListener(WI.TimelineView.Event.RecordWasFiltered, this._handleTimelineViewRecordFiltered, this);
+        WI.TimelineView.removeEventListener(WI.TimelineView.Event.RecordWasSelected, this._handleTimelineViewRecordSelected, this);
+        WI.TimelineView.removeEventListener(WI.TimelineView.Event.ScannerShow, this._handleTimelineViewScannerShow, this);
+        WI.TimelineView.removeEventListener(WI.TimelineView.Event.ScannerHide, this._handleTimelineViewScannerHide, this);
+        WI.TimelineView.removeEventListener(WI.TimelineView.Event.NeedsEntireSelectedRange, this._handleTimelineViewNeedsEntireSelectedRange, this);
     }
 
     canGoBack()
@@ -736,7 +750,7 @@ WI.TimelineRecordingContentView = class TimelineRecordingContentView extends WI.
     {
         console.assert(!this._updating);
 
-        WI.timelineManager.removeEventListener(null, null, this);
+        WI.timelineManager.removeEventListener(WI.TimelineManager.Event.CapturingStateChanged, this._handleTimelineCapturingStateChanged, this);
     }
 
     _timeRangeSelectionChanged(event)
index 877931d971e2e126c80f9d27cf2e1e244f98adf3..c4827a93041bd2cd3c22eb5fb9901a5c8c4fe6b2 100644 (file)
@@ -43,6 +43,8 @@ WI.TimelineRecordingProgressView = class TimelineRecordingProgressView extends W
         this._stopRecordingButtonElement.textContent = WI.UIString("Stop Recording");
         this._stopRecordingButtonElement.addEventListener("click", () => WI.timelineManager.stopCapturing());
         this.element.appendChild(this._stopRecordingButtonElement);
+
+        WI.timelineManager.addEventListener(WI.TimelineManager.Event.CapturingStateChanged, this._handleTimelineCapturingStateChanged, this);
     }
 
     // Public
@@ -61,16 +63,16 @@ WI.TimelineRecordingProgressView = class TimelineRecordingProgressView extends W
         this._visible = x;
         this.element.classList.toggle("hidden", !this._visible);
 
-        if (this._visible) {
-            WI.timelineManager.addEventListener(WI.TimelineManager.Event.CapturingStateChanged, this._handleTimelineCapturingStateChanged, this);
+        if (this._visible)
             this._updateState();
-        } else
-            WI.timelineManager.removeEventListener(WI.TimelineManager.Event.CapturingStateChanged, this._handleTimelineCapturingStateChanged, this);
     }
 
     // Private
 
     _updateState() {
+        if (!this._visible)
+            return;
+
         switch (WI.timelineManager.capturingState) {
         case WI.TimelineManager.CapturingState.Starting:
         case WI.TimelineManager.CapturingState.Active:
index aa254b454be42c6b0406d2f2a48778353d47c1bf..f6cc08b77f6c92ff050d3923214d171aa67837da 100644 (file)
@@ -370,7 +370,7 @@ WI.TimelineRuler = class TimelineRuler extends WI.View
     clearMarkers()
     {
         for (let [marker, markerElement] of this._markerElementMap) {
-            marker.removeEventListener(null, null, this);
+            marker.removeEventListener(WI.TimelineMarker.Event.TimeChanged, this._timelineMarkerTimeChanged, this);
             markerElement.remove();
         }
 
index a495b18f5c1753eab02116f44e6c09eae58a6146..011c175f8b0106df7b833fbf5bae3b32fcffc545 100644 (file)
@@ -344,10 +344,14 @@ WI.TimelineTabContentView = class TimelineTabContentView extends WI.ContentBrows
         WI.memoryManager.disable();
         WI.heapManager.disable();
 
-        this.contentBrowser.navigationBar.removeEventListener(null, null, this);
-
-        WI.timelineManager.removeEventListener(null, null, this);
-        WI.notifications.removeEventListener(null, null, this);
+        if (WI.sharedApp.isWebDebuggable())
+            this.contentBrowser.navigationBar.removeEventListener(WI.NavigationBar.Event.NavigationItemSelected, this._viewModeSelected, this);
+
+        WI.timelineManager.removeEventListener(WI.TimelineManager.Event.CapturingStateChanged, this._handleTimelineCapturingStateChanged, this);
+        WI.timelineManager.removeEventListener(WI.TimelineManager.Event.RecordingCreated, this._recordingCreated, this);
+        WI.timelineManager.removeEventListener(WI.TimelineManager.Event.RecordingLoaded, this._recordingLoaded, this);
+        WI.notifications.removeEventListener(WI.Notification.VisibilityStateDidChange, this._inspectorVisibilityChanged, this);
+        WI.notifications.removeEventListener(WI.Notification.GlobalModifierKeysDidChange, this._globalModifierKeysDidChange, this);
 
         super.closed();
     }
index 94a0713321861e50754b04102926dfc88aa84e26..d588c122e72bdccb200ffba657f61f2aa9842678 100644 (file)
@@ -76,8 +76,9 @@ WI.TimelineTreeElement = class TimelineTreeElement extends WI.GeneralTreeElement
     {
         let tooltip = WI.UIString("Close %s timeline view").format(this.mainTitle);
         let button = new WI.TreeElementStatusButton(WI.ImageUtilities.useSVGSymbol("Images/CloseLarge.svg", "close-button", tooltip));
-        button.addEventListener(WI.TreeElementStatusButton.Event.Clicked, () => { this.deselect(); });
-
+        button.addEventListener(WI.TreeElementStatusButton.Event.Clicked, function(event) {
+            this.deselect();
+        }, button);
         this.status = button.element;
     }
 
index da89e20d25bd7cf352a1c75a81f6ff0723c8b58a..4116f3be0c7b1a78d3b527b22343af1ec110225c 100644 (file)
@@ -1090,14 +1090,14 @@ WI.TreeOutline.ElementStyleClassName = "tree-outline";
 WI.TreeOutline.CustomIndentStyleClassName = "custom-indent";
 
 WI.TreeOutline.Event = {
-    ElementAdded: Symbol("element-added"),
-    ElementDidChange: Symbol("element-did-change"),
-    ElementRemoved: Symbol("element-removed"),
-    ElementRevealed: Symbol("element-revealed"),
-    ElementClicked: Symbol("element-clicked"),
-    ElementDisclosureDidChanged: Symbol("element-disclosure-did-change"),
-    ElementVisibilityDidChange: Symbol("element-visbility-did-change"),
-    SelectionDidChange: Symbol("selection-did-change")
+    ElementAdded: "element-added",
+    ElementDidChange: "element-did-change",
+    ElementRemoved: "element-removed",
+    ElementRevealed: "element-revealed",
+    ElementClicked: "element-clicked",
+    ElementDisclosureDidChanged: "element-disclosure-did-change",
+    ElementVisibilityDidChange: "element-visbility-did-change",
+    SelectionDidChange: "selection-did-change",
 };
 
 WI.TreeOutline._knownTreeElementNextIdentifier = 1;
index 9b6616bd1fae6e4cb2fa7f65a423e2ad49004382..f5f3b92f9be358a3a20cfc5e98e422aadf75e2c5 100644 (file)
@@ -54,7 +54,7 @@ WI.TreeOutlineGroup = class TreeOutlineGroup extends WI.Collection
 
     itemRemoved(treeOutline)
     {
-        treeOutline.removeEventListener(null, null, this);
+        treeOutline.removeEventListener(WI.TreeOutline.Event.SelectionDidChange, this._treeOutlineSelectionDidChange, this);
     }
 
     // Private
index ce48ebf1411251a3ea2e688c22241590c221b87b..1d08a9f527f66d8e36d089e88fd9d7bdc748a13c 100644 (file)
@@ -61,7 +61,7 @@ HeapSnapshotWorker = class HeapSnapshotWorker
                     let collectionData = snapshot.updateDeadNodesAndGatherCollectionData(this._snapshots);
                     if (!collectionData || !collectionData.affectedSnapshots.length)
                         return;
-                    this.sendEvent("HeapSnapshot.CollectionEvent", collectionData);
+                    this.sendEvent(HeapSnapshotWorker.Event.Collection, collectionData);
                 }, 0);
             }
         }
@@ -120,4 +120,8 @@ HeapSnapshotWorker = class HeapSnapshotWorker
     }
 };
 
+HeapSnapshotWorker.Event = {
+    Collection: "heap-snapshot-collection",
+};
+
 self.heapSnapshotWorker = new HeapSnapshotWorker;