diff options
author | kozyatinskiy <kozyatinskiy@chromium.org> | 2016-03-25 16:08:17 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-25 23:09:30 +0000 |
commit | c5e228cabf7876c6f65da715a9b5bf9507a8b12b (patch) | |
tree | 851896dfa09dec606330de6262c0258aa9486a59 | |
parent | b6d78f039a327f70412ccdb2c03a341c7f1fc8af (diff) | |
download | chromium_src-c5e228cabf7876c6f65da715a9b5bf9507a8b12b.zip chromium_src-c5e228cabf7876c6f65da715a9b5bf9507a8b12b.tar.gz chromium_src-c5e228cabf7876c6f65da715a9b5bf9507a8b12b.tar.bz2 |
[DevTools] Introduced WebInspector.LiveLocationPool
R=dgozman@chromium.org,pfeldman@chromium.org
Review URL: https://codereview.chromium.org/1818533003
Cr-Commit-Position: refs/heads/master@{#383396}
11 files changed, 183 insertions, 97 deletions
diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector/elements/styles/update-locations-on-filesystem-scss-load.html b/third_party/WebKit/LayoutTests/http/tests/inspector/elements/styles/update-locations-on-filesystem-scss-load.html index f97725d..62d143f 100644 --- a/third_party/WebKit/LayoutTests/http/tests/inspector/elements/styles/update-locations-on-filesystem-scss-load.html +++ b/third_party/WebKit/LayoutTests/http/tests/inspector/elements/styles/update-locations-on-filesystem-scss-load.html @@ -35,7 +35,7 @@ function test() InspectorTest.addResult("Stylesheet was added, dumping location:"); var header = event.data; var cssLocation = new WebInspector.CSSLocation(header, 0, 1); - liveLocation = WebInspector.cssWorkspaceBinding.createLiveLocation(cssLocation, function() {}); + liveLocation = WebInspector.cssWorkspaceBinding.createLiveLocation(cssLocation, function() {}, new WebInspector.LiveLocationPool()); InspectorTest.cssModel.addEventListener(WebInspector.CSSModel.Events.SourceMapAttached, afterBind); dumpLiveLocation(); } diff --git a/third_party/WebKit/Source/devtools/front_end/bindings/BreakpointManager.js b/third_party/WebKit/Source/devtools/front_end/bindings/BreakpointManager.js index 53446c5..8671524 100644 --- a/third_party/WebKit/Source/devtools/front_end/bindings/BreakpointManager.js +++ b/third_party/WebKit/Source/devtools/front_end/bindings/BreakpointManager.js @@ -739,8 +739,7 @@ WebInspector.BreakpointManager.TargetBreakpoint = function(debuggerModel, breakp this._networkMapping = networkMapping; this._debuggerWorkspaceBinding = debuggerWorkspaceBinding; - /** @type {!Array.<!WebInspector.DebuggerWorkspaceBinding.Location>} */ - this._liveLocations = []; + this._liveLocations = new WebInspector.LiveLocationPool(); /** @type {!Object.<string, !WebInspector.UILocation>} */ this._uiLocations = {}; @@ -763,10 +762,7 @@ WebInspector.BreakpointManager.TargetBreakpoint.prototype = { this._breakpoint._removeUILocation(uiLocations[i]); this._uiLocations = {}; - - for (var i = 0; i < this._liveLocations.length; ++i) - this._liveLocations[i].dispose(); - this._liveLocations = []; + this._liveLocations.disposeAll(); }, _scheduleUpdateInDebugger: function() @@ -944,7 +940,7 @@ WebInspector.BreakpointManager.TargetBreakpoint.prototype = { this._breakpoint.remove(); return false; } - this._liveLocations.push(this._debuggerWorkspaceBinding.createLiveLocation(location, this._locationUpdated.bind(this, location))); + this._debuggerWorkspaceBinding.createLiveLocation(location, this._locationUpdated.bind(this, location), this._liveLocations); return true; }, diff --git a/third_party/WebKit/Source/devtools/front_end/bindings/CSSWorkspaceBinding.js b/third_party/WebKit/Source/devtools/front_end/bindings/CSSWorkspaceBinding.js index 044b691..41bb76a 100644 --- a/third_party/WebKit/Source/devtools/front_end/bindings/CSSWorkspaceBinding.js +++ b/third_party/WebKit/Source/devtools/front_end/bindings/CSSWorkspaceBinding.js @@ -101,12 +101,13 @@ WebInspector.CSSWorkspaceBinding.prototype = { /** * @param {!WebInspector.CSSLocation} rawLocation * @param {function(!WebInspector.LiveLocation)} updateDelegate + * @param {!WebInspector.LiveLocationPool} locationPool * @return {!WebInspector.CSSWorkspaceBinding.LiveLocation} */ - createLiveLocation: function(rawLocation, updateDelegate) + createLiveLocation: function(rawLocation, updateDelegate, locationPool) { var header = rawLocation.styleSheetId ? rawLocation.cssModel().styleSheetHeaderForId(rawLocation.styleSheetId) : null; - return new WebInspector.CSSWorkspaceBinding.LiveLocation(rawLocation.cssModel(), header, rawLocation, this, updateDelegate); + return new WebInspector.CSSWorkspaceBinding.LiveLocation(rawLocation.cssModel(), header, rawLocation, this, updateDelegate, locationPool); }, /** @@ -313,16 +314,17 @@ WebInspector.CSSWorkspaceBinding.HeaderInfo.prototype = { /** * @constructor - * @extends {WebInspector.LiveLocation} + * @extends {WebInspector.LiveLocationWithPool} * @param {!WebInspector.CSSModel} cssModel * @param {?WebInspector.CSSStyleSheetHeader} header * @param {!WebInspector.CSSLocation} rawLocation * @param {!WebInspector.CSSWorkspaceBinding} binding * @param {function(!WebInspector.LiveLocation)} updateDelegate + * @param {!WebInspector.LiveLocationPool} locationPool */ -WebInspector.CSSWorkspaceBinding.LiveLocation = function(cssModel, header, rawLocation, binding, updateDelegate) +WebInspector.CSSWorkspaceBinding.LiveLocation = function(cssModel, header, rawLocation, binding, updateDelegate, locationPool) { - WebInspector.LiveLocation.call(this, updateDelegate); + WebInspector.LiveLocationWithPool.call(this, updateDelegate, locationPool); this._cssModel = cssModel; this._rawLocation = rawLocation; this._binding = binding; @@ -392,9 +394,12 @@ WebInspector.CSSWorkspaceBinding.LiveLocation.prototype = { return uiSourceCode.uiLocation(cssLocation.lineNumber, cssLocation.columnNumber); }, + /** + * @override + */ dispose: function() { - WebInspector.LiveLocation.prototype.dispose.call(this); + WebInspector.LiveLocationWithPool.prototype.dispose.call(this); if (this._header) this._binding._removeLiveLocation(this); this._cssModel.removeEventListener(WebInspector.CSSModel.Events.StyleSheetAdded, this._styleSheetAdded, this); @@ -410,7 +415,7 @@ WebInspector.CSSWorkspaceBinding.LiveLocation.prototype = { return false; }, - __proto__: WebInspector.LiveLocation.prototype + __proto__: WebInspector.LiveLocationWithPool.prototype } /** diff --git a/third_party/WebKit/Source/devtools/front_end/bindings/DebuggerWorkspaceBinding.js b/third_party/WebKit/Source/devtools/front_end/bindings/DebuggerWorkspaceBinding.js index 313b8a4..ab89ed0 100644 --- a/third_party/WebKit/Source/devtools/front_end/bindings/DebuggerWorkspaceBinding.js +++ b/third_party/WebKit/Source/devtools/front_end/bindings/DebuggerWorkspaceBinding.js @@ -122,13 +122,14 @@ WebInspector.DebuggerWorkspaceBinding.prototype = { /** * @param {!WebInspector.DebuggerModel.Location} rawLocation * @param {function(!WebInspector.LiveLocation)} updateDelegate + * @param {!WebInspector.LiveLocationPool} locationPool * @return {!WebInspector.DebuggerWorkspaceBinding.Location} */ - createLiveLocation: function(rawLocation, updateDelegate) + createLiveLocation: function(rawLocation, updateDelegate, locationPool) { var info = this._infoForScript(rawLocation.target(), rawLocation.scriptId); console.assert(info); - var location = new WebInspector.DebuggerWorkspaceBinding.Location(info._script, rawLocation, this, updateDelegate); + var location = new WebInspector.DebuggerWorkspaceBinding.Location(info._script, rawLocation, this, updateDelegate, locationPool); info._addLocation(location); return location; }, @@ -136,12 +137,13 @@ WebInspector.DebuggerWorkspaceBinding.prototype = { /** * @param {!Array<!WebInspector.DebuggerModel.Location>} rawLocations * @param {function(!WebInspector.LiveLocation)} updateDelegate + * @param {!WebInspector.LiveLocationPool} locationPool * @return {!WebInspector.LiveLocation} */ - createStackTraceTopFrameLiveLocation: function(rawLocations, updateDelegate) + createStackTraceTopFrameLiveLocation: function(rawLocations, updateDelegate, locationPool) { console.assert(rawLocations.length); - var location = new WebInspector.DebuggerWorkspaceBinding.StackTraceTopFrameLocation(rawLocations, this, updateDelegate); + var location = new WebInspector.DebuggerWorkspaceBinding.StackTraceTopFrameLocation(rawLocations, this, updateDelegate, locationPool); location.update(); return location; }, @@ -149,13 +151,14 @@ WebInspector.DebuggerWorkspaceBinding.prototype = { /** * @param {!WebInspector.DebuggerModel.Location} location * @param {function(!WebInspector.LiveLocation)} updateDelegate + * @param {!WebInspector.LiveLocationPool} locationPool * @return {!WebInspector.DebuggerWorkspaceBinding.Location} */ - createCallFrameLiveLocation: function(location, updateDelegate) + createCallFrameLiveLocation: function(location, updateDelegate, locationPool) { var target = location.target(); this._ensureInfoForScript(location.script()); - var liveLocation = this.createLiveLocation(location, updateDelegate); + var liveLocation = this.createLiveLocation(location, updateDelegate, locationPool); this._registerCallFrameLiveLocation(target, liveLocation); return liveLocation; }, @@ -281,7 +284,7 @@ WebInspector.DebuggerWorkspaceBinding.prototype = { _reset: function(target) { var targetData = this._targetToData.get(target); - targetData.callFrameLocations.valuesArray().forEach(function(location) { location.dispose(); }); + targetData.callFrameLocations.valuesArray().forEach((location) => this._removeLiveLocation(location)); targetData.callFrameLocations.clear(); }, @@ -468,7 +471,7 @@ WebInspector.DebuggerWorkspaceBinding.ScriptInfo = function(script) /** @type {!Array.<!WebInspector.DebuggerSourceMapping>} */ this._sourceMappings = []; - /** @type {!Set.<!WebInspector.LiveLocation>} */ + /** @type {!Set<!WebInspector.LiveLocation>} */ this._locations = new Set(); } @@ -532,15 +535,16 @@ WebInspector.DebuggerWorkspaceBinding.ScriptInfo.prototype = { /** * @constructor - * @extends {WebInspector.LiveLocation} + * @extends {WebInspector.LiveLocationWithPool} * @param {!WebInspector.Script} script * @param {!WebInspector.DebuggerModel.Location} rawLocation * @param {!WebInspector.DebuggerWorkspaceBinding} binding * @param {function(!WebInspector.LiveLocation)} updateDelegate + * @param {!WebInspector.LiveLocationPool} locationPool */ -WebInspector.DebuggerWorkspaceBinding.Location = function(script, rawLocation, binding, updateDelegate) +WebInspector.DebuggerWorkspaceBinding.Location = function(script, rawLocation, binding, updateDelegate, locationPool) { - WebInspector.LiveLocation.call(this, updateDelegate); + WebInspector.LiveLocationWithPool.call(this, updateDelegate, locationPool); this._script = script; this._rawLocation = rawLocation; this._binding = binding; @@ -562,7 +566,7 @@ WebInspector.DebuggerWorkspaceBinding.Location.prototype = { */ dispose: function() { - WebInspector.LiveLocation.prototype.dispose.call(this); + WebInspector.LiveLocationWithPool.prototype.dispose.call(this); this._binding._removeLiveLocation(this); }, @@ -575,25 +579,26 @@ WebInspector.DebuggerWorkspaceBinding.Location.prototype = { return WebInspector.blackboxManager.isBlackboxedRawLocation(this._rawLocation); }, - __proto__: WebInspector.LiveLocation.prototype + __proto__: WebInspector.LiveLocationWithPool.prototype } /** * @constructor - * @extends {WebInspector.LiveLocation} + * @extends {WebInspector.LiveLocationWithPool} * @param {!Array<!WebInspector.DebuggerModel.Location>} rawLocations * @param {!WebInspector.DebuggerWorkspaceBinding} binding * @param {function(!WebInspector.LiveLocation)} updateDelegate + * @param {!WebInspector.LiveLocationPool} locationPool */ -WebInspector.DebuggerWorkspaceBinding.StackTraceTopFrameLocation = function(rawLocations, binding, updateDelegate) +WebInspector.DebuggerWorkspaceBinding.StackTraceTopFrameLocation = function(rawLocations, binding, updateDelegate, locationPool) { - WebInspector.LiveLocation.call(this, updateDelegate); + WebInspector.LiveLocationWithPool.call(this, updateDelegate, locationPool); this._updateScheduled = true; - /** @type {!Array<!WebInspector.DebuggerWorkspaceBinding.Location>} */ - this._locations = []; + /** @type {!Set<!WebInspector.LiveLocation>} */ + this._locations = new Set(); for (var location of rawLocations) - this._locations.push(binding.createLiveLocation(location, this._scheduleUpdate.bind(this))); + this._locations.add(binding.createCallFrameLiveLocation(location, this._scheduleUpdate.bind(this), locationPool)); this._updateLocation(); } @@ -604,25 +609,26 @@ WebInspector.DebuggerWorkspaceBinding.StackTraceTopFrameLocation.prototype = { */ uiLocation: function() { - return this._currentLocation().uiLocation(); + return this._current.uiLocation(); }, /** * @override + * @return {boolean} */ - dispose: function() + isBlackboxed: function() { - for (var location of this._locations) - location.dispose(); + return this._current.isBlackboxed(); }, /** * @override - * @return {boolean} */ - isBlackboxed: function() + dispose: function() { - return this._currentLocation().isBlackboxed(); + WebInspector.LiveLocationWithPool.prototype.dispose.call(this); + for (var location of this._locations) + location.dispose(); }, _scheduleUpdate: function() @@ -633,24 +639,20 @@ WebInspector.DebuggerWorkspaceBinding.StackTraceTopFrameLocation.prototype = { } }, - /** - * @return {!WebInspector.DebuggerWorkspaceBinding.Location} - */ - _currentLocation: function() - { - return this._locations[this._current < this._locations.length ? this._current : 0]; - }, - _updateLocation: function() { this._updateScheduled = false; - this._current = 0; - while (this._current < this._locations.length && this._locations[this._current].isBlackboxed()) - ++this._current; + this._current = this._locations.values().next().value; + for (var current of this._locations) { + if (!current.isBlackboxed()) { + this._current = current; + break; + } + } this.update(); }, - __proto__: WebInspector.LiveLocation.prototype + __proto__: WebInspector.LiveLocationWithPool.prototype } /** diff --git a/third_party/WebKit/Source/devtools/front_end/bindings/LiveLocation.js b/third_party/WebKit/Source/devtools/front_end/bindings/LiveLocation.js index 50bd67c..12625e1 100644 --- a/third_party/WebKit/Source/devtools/front_end/bindings/LiveLocation.js +++ b/third_party/WebKit/Source/devtools/front_end/bindings/LiveLocation.js @@ -2,22 +2,49 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +/** @interface */ +WebInspector.LiveLocation = function() {} + +WebInspector.LiveLocation.prototype = { + update: function() {}, + + /** + * @return {?WebInspector.UILocation} + */ + uiLocation: function() {}, + + dispose: function() {}, + + /** + * @return {boolean} + */ + isBlackboxed: function() {} +} + /** * @constructor + * @implements {WebInspector.LiveLocation} * @param {function(!WebInspector.LiveLocation)} updateDelegate + * @param {!WebInspector.LiveLocationPool} locationPool */ -WebInspector.LiveLocation = function(updateDelegate) +WebInspector.LiveLocationWithPool = function(updateDelegate, locationPool) { this._updateDelegate = updateDelegate; + this._locationPool = locationPool; + this._locationPool._add(this); } -WebInspector.LiveLocation.prototype = { +WebInspector.LiveLocationWithPool.prototype = { + /** + * @override + */ update: function() { this._updateDelegate(this); }, /** + * @override * @return {?WebInspector.UILocation} */ uiLocation: function() @@ -25,12 +52,17 @@ WebInspector.LiveLocation.prototype = { throw "Not implemented"; }, + /** + * @override + */ dispose: function() { - // Overridden by subclasses. + this._locationPool._delete(this); + this._updateDelegate = null; }, /** + * @override * @return {boolean} */ isBlackboxed: function() @@ -38,3 +70,35 @@ WebInspector.LiveLocation.prototype = { throw "Not implemented"; } } + +/** + * @constructor + */ +WebInspector.LiveLocationPool = function() +{ + this._locations = new Set(); +} + +WebInspector.LiveLocationPool.prototype = { + /** + * @param {!WebInspector.LiveLocation} location + */ + _add: function(location) + { + this._locations.add(location); + }, + + /** + * @param {!WebInspector.LiveLocation} location + */ + _delete: function(location) + { + this._locations.delete(location); + }, + + disposeAll: function() + { + for (var location of this._locations) + location.dispose(); + } +} diff --git a/third_party/WebKit/Source/devtools/front_end/bindings/PresentationConsoleMessageHelper.js b/third_party/WebKit/Source/devtools/front_end/bindings/PresentationConsoleMessageHelper.js index 7d54c70..77f57d9 100644 --- a/third_party/WebKit/Source/devtools/front_end/bindings/PresentationConsoleMessageHelper.js +++ b/third_party/WebKit/Source/devtools/front_end/bindings/PresentationConsoleMessageHelper.js @@ -48,6 +48,8 @@ WebInspector.PresentationConsoleMessageHelper = function(workspace) WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebInspector.DebuggerModel.Events.ParsedScriptSource, this._parsedScriptSource, this); WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebInspector.DebuggerModel.Events.FailedToParseScriptSource, this._parsedScriptSource, this); WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebInspector.DebuggerModel.Events.GlobalObjectCleared, this._debuggerReset, this); + + this._locationPool = new WebInspector.LiveLocationPool(); } WebInspector.PresentationConsoleMessageHelper.prototype = { @@ -101,7 +103,7 @@ WebInspector.PresentationConsoleMessageHelper.prototype = { */ _addConsoleMessageToScript: function(message, rawLocation) { - this._presentationConsoleMessages.push(new WebInspector.PresentationConsoleMessage(message, rawLocation)); + this._presentationConsoleMessages.push(new WebInspector.PresentationConsoleMessage(message, rawLocation, this._locationPool)); }, /** @@ -151,6 +153,7 @@ WebInspector.PresentationConsoleMessageHelper.prototype = { for (var i = 0; i < this._presentationConsoleMessages.length; ++i) this._presentationConsoleMessages[i].dispose(); this._presentationConsoleMessages = []; + this._locationPool.disposeAll(); }, _debuggerReset: function() @@ -163,12 +166,13 @@ WebInspector.PresentationConsoleMessageHelper.prototype = { * @constructor * @param {!WebInspector.ConsoleMessage} message * @param {!WebInspector.DebuggerModel.Location} rawLocation + * @param {!WebInspector.LiveLocationPool} locationPool */ -WebInspector.PresentationConsoleMessage = function(message, rawLocation) +WebInspector.PresentationConsoleMessage = function(message, rawLocation, locationPool) { this._text = message.messageText; this._level = message.level === WebInspector.ConsoleMessage.MessageLevel.Error ? WebInspector.UISourceCode.Message.Level.Error : WebInspector.UISourceCode.Message.Level.Warning; - this._liveLocation = WebInspector.debuggerWorkspaceBinding.createLiveLocation(rawLocation, this._updateLocation.bind(this)); + WebInspector.debuggerWorkspaceBinding.createLiveLocation(rawLocation, this._updateLocation.bind(this), locationPool); } WebInspector.PresentationConsoleMessage.prototype = { @@ -187,7 +191,6 @@ WebInspector.PresentationConsoleMessage.prototype = { dispose: function() { - this._liveLocation.dispose(); if (this._uiMessage) this._uiMessage.remove(); } diff --git a/third_party/WebKit/Source/devtools/front_end/components/Linkifier.js b/third_party/WebKit/Source/devtools/front_end/components/Linkifier.js index 6e70d88..fe34672 100644 --- a/third_party/WebKit/Source/devtools/front_end/components/Linkifier.js +++ b/third_party/WebKit/Source/devtools/front_end/components/Linkifier.js @@ -52,8 +52,10 @@ WebInspector.LinkifierFormatter.prototype = { WebInspector.Linkifier = function(formatter) { this._formatter = formatter || new WebInspector.Linkifier.DefaultFormatter(WebInspector.Linkifier.MaxLengthForDisplayedURLs); - /** @type {!Map.<!WebInspector.Target, !Map.<!Element, !WebInspector.LiveLocation>>}*/ - this._liveLocationsByTarget = new Map(); + /** @type {!Map<!WebInspector.Target, !Array<!Element>>} */ + this._anchorsByTarget = new Map(); + /** @type {!Map<!WebInspector.Target, !WebInspector.LiveLocationPool>} */ + this._locationPoolByTarget = new Map(); WebInspector.targetManager.observeTargets(this); } @@ -115,6 +117,7 @@ WebInspector.Linkifier.linkifyUsingRevealer = function(revealable, text, fallbac WebInspector.Linkifier._uiLocationSymbol = Symbol("uiLocation"); WebInspector.Linkifier._fallbackAnchorSymbol = Symbol("fallbackAnchor"); +WebInspector.Linkifier._liveLocationSymbol = Symbol("liveLocation"); WebInspector.Linkifier.prototype = { /** @@ -123,7 +126,8 @@ WebInspector.Linkifier.prototype = { */ targetAdded: function(target) { - this._liveLocationsByTarget.set(target, new Map()); + this._anchorsByTarget.set(target, []); + this._locationPoolByTarget.set(target, new WebInspector.LiveLocationPool()); }, /** @@ -132,12 +136,11 @@ WebInspector.Linkifier.prototype = { */ targetRemoved: function(target) { - var liveLocations = this._liveLocationsByTarget.remove(target); - var anchors = liveLocations.keysArray(); - for (var i = 0; i < anchors.length; ++i) { - var anchor = anchors[i]; - var location = liveLocations.get(anchor); - delete anchor[WebInspector.Linkifier._uiLocationSymbol]; + var locationPool = /** @type {!WebInspector.LiveLocationPool} */(this._locationPoolByTarget.remove(target)); + locationPool.disposeAll(); + var anchors = this._anchorsByTarget.remove(target); + for (var anchor of anchors) { + delete anchor[WebInspector.Linkifier._liveLocationSymbol]; var fallbackAnchor = anchor[WebInspector.Linkifier._fallbackAnchorSymbol]; if (fallbackAnchor) { anchor.href = fallbackAnchor.href; @@ -147,7 +150,6 @@ WebInspector.Linkifier.prototype = { anchor.textContent = fallbackAnchor.textContent; delete anchor[WebInspector.Linkifier._fallbackAnchorSymbol]; } - location.dispose(); } }, @@ -175,8 +177,10 @@ WebInspector.Linkifier.prototype = { return fallbackAnchor; var anchor = this._createAnchor(classes); - var liveLocation = WebInspector.debuggerWorkspaceBinding.createLiveLocation(rawLocation, this._updateAnchor.bind(this, anchor)); - this._liveLocationsByTarget.get(rawLocation.target()).set(anchor, liveLocation); + var liveLocation = WebInspector.debuggerWorkspaceBinding.createLiveLocation(rawLocation, this._updateAnchor.bind(this, anchor), /** @type {!WebInspector.LiveLocationPool} */(this._locationPoolByTarget.get(rawLocation.target()))); + var anchors = /** @type {!Array<!Element>} */(this._anchorsByTarget.get(rawLocation.target())); + anchors.push(anchor); + anchor[WebInspector.Linkifier._liveLocationSymbol] = liveLocation; anchor[WebInspector.Linkifier._fallbackAnchorSymbol] = fallbackAnchor; return anchor; }, @@ -224,8 +228,10 @@ WebInspector.Linkifier.prototype = { return fallbackAnchor; var anchor = this._createAnchor(classes); - var liveLocation = WebInspector.debuggerWorkspaceBinding.createStackTraceTopFrameLiveLocation(rawLocations, this._updateAnchor.bind(this, anchor)); - this._liveLocationsByTarget.get(target).set(anchor, liveLocation); + var liveLocation = WebInspector.debuggerWorkspaceBinding.createStackTraceTopFrameLiveLocation(rawLocations, this._updateAnchor.bind(this, anchor), /** @type {!WebInspector.LiveLocationPool} */(this._locationPoolByTarget.get(target))); + var anchors = /** @type {!Array<!Element>} */(this._anchorsByTarget.get(target)); + anchors.push(anchor); + anchor[WebInspector.Linkifier._liveLocationSymbol] = liveLocation; anchor[WebInspector.Linkifier._fallbackAnchorSymbol] = fallbackAnchor; return anchor; }, @@ -238,8 +244,10 @@ WebInspector.Linkifier.prototype = { linkifyCSSLocation: function(rawLocation, classes) { var anchor = this._createAnchor(classes); - var liveLocation = WebInspector.cssWorkspaceBinding.createLiveLocation(rawLocation, this._updateAnchor.bind(this, anchor)); - this._liveLocationsByTarget.get(rawLocation.target()).set(anchor, liveLocation); + var liveLocation = WebInspector.cssWorkspaceBinding.createLiveLocation(rawLocation, this._updateAnchor.bind(this, anchor), /** @type {!WebInspector.LiveLocationPool} */(this._locationPoolByTarget.get(rawLocation.target()))); + var anchors = /** @type {!Array<!Element>} */(this._anchorsByTarget.get(rawLocation.target())); + anchors.push(anchor); + anchor[WebInspector.Linkifier._liveLocationSymbol] = liveLocation; return anchor; }, @@ -251,12 +259,10 @@ WebInspector.Linkifier.prototype = { { delete anchor[WebInspector.Linkifier._uiLocationSymbol]; delete anchor[WebInspector.Linkifier._fallbackAnchorSymbol]; - var liveLocations = this._liveLocationsByTarget.get(target); - if (!liveLocations) - return; - var location = liveLocations.remove(anchor); - if (location) - location.dispose(); + var liveLocation = anchor[WebInspector.Linkifier._liveLocationSymbol]; + if (liveLocation) + liveLocation.dispose(); + delete anchor[WebInspector.Linkifier._liveLocationSymbol]; }, /** @@ -289,9 +295,7 @@ WebInspector.Linkifier.prototype = { reset: function() { - var targets = this._liveLocationsByTarget.keysArray(); - for (var i = 0; i < targets.length; ++i) { - var target = targets[i]; + for (var target of this._anchorsByTarget.keysArray()) { this.targetRemoved(target); this.targetAdded(target); } @@ -299,9 +303,9 @@ WebInspector.Linkifier.prototype = { dispose: function() { - this.reset(); + for (var target of this._anchorsByTarget.keysArray()) + this.targetRemoved(target); WebInspector.targetManager.unobserveTargets(this); - this._liveLocationsByTarget.clear(); }, /** diff --git a/third_party/WebKit/Source/devtools/front_end/sources/CallStackSidebarPane.js b/third_party/WebKit/Source/devtools/front_end/sources/CallStackSidebarPane.js index 6f0605b..d2232a3 100644 --- a/third_party/WebKit/Source/devtools/front_end/sources/CallStackSidebarPane.js +++ b/third_party/WebKit/Source/devtools/front_end/sources/CallStackSidebarPane.js @@ -37,6 +37,9 @@ WebInspector.CallStackSidebarPane = function() this._linkifier = new WebInspector.Linkifier(); WebInspector.moduleSetting("enableAsyncStackTraces").addChangeListener(this._asyncStackTracesStateChanged, this); WebInspector.moduleSetting("skipStackFramesPattern").addChangeListener(this._blackboxingStateChanged, this); + /** @type {!Array<!WebInspector.CallStackSidebarPane.CallFrame>} */ + this.callFrames = []; + this._locationPool = new WebInspector.LiveLocationPool(); } /** @enum {string} */ @@ -55,6 +58,7 @@ WebInspector.CallStackSidebarPane.prototype = { this.callFrameList.clear(); this._linkifier.reset(); this.element.removeChildren(); + this._locationPool.disposeAll(); if (!details) { var infoElement = this.element.createChild("div", "callstack-info"); @@ -68,7 +72,6 @@ WebInspector.CallStackSidebarPane.prototype = { delete this._statusMessageElement; delete this._hiddenCallFramesMessageElement; - /** @type {!Array.<!WebInspector.CallStackSidebarPane.CallFrame>} */ this.callFrames = []; this._hiddenCallFrames = 0; @@ -110,7 +113,7 @@ WebInspector.CallStackSidebarPane.prototype = { var callFrameItems = []; for (var i = 0, n = callFrames.length; i < n; ++i) { var callFrame = callFrames[i]; - var callFrameItem = new WebInspector.CallStackSidebarPane.CallFrame(callFrame.functionName, callFrame.location(), this._linkifier, callFrame); + var callFrameItem = new WebInspector.CallStackSidebarPane.CallFrame(callFrame.functionName, callFrame.location(), this._linkifier, callFrame, this._locationPool); callFrameItem.element.addEventListener("click", this._callFrameSelected.bind(this, callFrameItem), false); callFrameItems.push(callFrameItem); } @@ -131,7 +134,7 @@ WebInspector.CallStackSidebarPane.prototype = { var lineNumber = callFrame.lineNumber ? callFrame.lineNumber - 1 : 0; var columnNumber = callFrame.columnNumber ? callFrame.columnNumber - 1 : 0; var location = new WebInspector.DebuggerModel.Location(this._debuggerModel, callFrame.scriptId, lineNumber, columnNumber); - var callFrameItem = new WebInspector.CallStackSidebarPane.CallFrame(callFrame.functionName, location, this._linkifier, null, asyncCallFrameItem); + var callFrameItem = new WebInspector.CallStackSidebarPane.CallFrame(callFrame.functionName, location, this._linkifier, null, this._locationPool, asyncCallFrameItem); callFrameItem.element.addEventListener("click", this._asyncCallFrameClicked.bind(this, callFrameItem), false); callFrameItems.push(callFrameItem); } @@ -438,9 +441,10 @@ WebInspector.CallStackSidebarPane.prototype = { * @param {!WebInspector.DebuggerModel.Location} location * @param {!WebInspector.Linkifier} linkifier * @param {?WebInspector.DebuggerModel.CallFrame} debuggerCallFrame + * @param {!WebInspector.LiveLocationPool} locationPool * @param {!WebInspector.UIList.Item=} asyncCallFrame */ -WebInspector.CallStackSidebarPane.CallFrame = function(functionName, location, linkifier, debuggerCallFrame, asyncCallFrame) +WebInspector.CallStackSidebarPane.CallFrame = function(functionName, location, linkifier, debuggerCallFrame, locationPool, asyncCallFrame) { WebInspector.UIList.Item.call(this, WebInspector.beautifyFunctionName(functionName), ""); this._location = location; @@ -451,7 +455,8 @@ WebInspector.CallStackSidebarPane.CallFrame = function(functionName, location, l var locationElement = linkifier.linkifyRawLocation(location, location.script().sourceURL); this.subtitleElement.appendChild(locationElement); } else { - WebInspector.debuggerWorkspaceBinding.createCallFrameLiveLocation(location, this._update.bind(this)); + this._liveLocationPool = new WebInspector.LiveLocationPool(); + WebInspector.debuggerWorkspaceBinding.createCallFrameLiveLocation(location, this._update.bind(this), locationPool); } } diff --git a/third_party/WebKit/Source/devtools/front_end/sources/SourcesPanel.js b/third_party/WebKit/Source/devtools/front_end/sources/SourcesPanel.js index ff6ae63..b24be61 100644 --- a/third_party/WebKit/Source/devtools/front_end/sources/SourcesPanel.js +++ b/third_party/WebKit/Source/devtools/front_end/sources/SourcesPanel.js @@ -103,6 +103,9 @@ WebInspector.SourcesPanel = function(workspaceForTest) this._updateDebuggerButtons(); this._pauseOnExceptionEnabledChanged(); WebInspector.moduleSetting("pauseOnExceptionEnabled").addChangeListener(this._pauseOnExceptionEnabledChanged, this); + + this._liveLocationPool = new WebInspector.LiveLocationPool(); + this._setTarget(WebInspector.context.flavor(WebInspector.Target)); WebInspector.breakpointManager.addEventListener(WebInspector.BreakpointManager.Events.BreakpointsActiveStateChanged, this._breakpointsActiveStateChanged, this); WebInspector.context.addFlavorChangeListener(WebInspector.Target, this._onCurrentTargetChanged, this); @@ -291,7 +294,7 @@ WebInspector.SourcesPanel.prototype = { } } else { if (details.callFrames.length) - WebInspector.debuggerWorkspaceBinding.createCallFrameLiveLocation(details.callFrames[0].location(), didGetUILocation.bind(this)); + WebInspector.debuggerWorkspaceBinding.createCallFrameLiveLocation(details.callFrames[0].location(), didGetUILocation.bind(this), this._liveLocationPool); else console.warn("ScriptsPanel paused, but callFrames.length is zero."); // TODO remove this once we understand this case better } @@ -436,7 +439,7 @@ WebInspector.SourcesPanel.prototype = { this.sidebarPanes.scopechain.update(callFrame); this.sidebarPanes.watchExpressions.refreshExpressions(); this.sidebarPanes.callstack.setSelectedCallFrame(callFrame); - WebInspector.debuggerWorkspaceBinding.createCallFrameLiveLocation(callFrame.location(), this._executionLineChanged.bind(this)); + WebInspector.debuggerWorkspaceBinding.createCallFrameLiveLocation(callFrame.location(), this._executionLineChanged.bind(this), this._liveLocationPool); }, /** @@ -507,6 +510,7 @@ WebInspector.SourcesPanel.prototype = { if (this._switchToPausedTargetTimeout) clearTimeout(this._switchToPausedTargetTimeout); + this._liveLocationPool.disposeAll(); }, /** diff --git a/third_party/WebKit/Source/devtools/front_end/timeline/TimelinePanel.js b/third_party/WebKit/Source/devtools/front_end/timeline/TimelinePanel.js index a048529..fcd5f5b 100644 --- a/third_party/WebKit/Source/devtools/front_end/timeline/TimelinePanel.js +++ b/third_party/WebKit/Source/devtools/front_end/timeline/TimelinePanel.js @@ -119,6 +119,7 @@ WebInspector.TimelinePanel = function() this._detailsSplitWidget.hideSidebar(); WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Events.SuspendStateChanged, this._onSuspendStateChanged, this); this._showRecordingHelpMessage(); + this._locationPool = new WebInspector.LiveLocationPool(); } /** @@ -1280,7 +1281,7 @@ WebInspector.TimelinePanel.prototype = { var time = lineInfo[1]; var rawLocation = debuggerModel.createRawLocationByURL(url, line, 0); if (rawLocation) - new WebInspector.TimelineUIUtils.LineLevelProfilePresentation(rawLocation, time); + new WebInspector.TimelineUIUtils.LineLevelProfilePresentation(rawLocation, time, this._locationPool); else if (uiSourceCode) uiSourceCode.addLineDecoration(line, WebInspector.TimelineUIUtils.PerformanceLineDecorator.type, time); } @@ -1289,6 +1290,7 @@ WebInspector.TimelinePanel.prototype = { _resetLineLevelCPUProfile: function() { + this._locationPool.disposeAll(); WebInspector.workspace.uiSourceCodes().forEach(uiSourceCode => uiSourceCode.removeAllLineDecorations(WebInspector.TimelineUIUtils.PerformanceLineDecorator.type)); }, diff --git a/third_party/WebKit/Source/devtools/front_end/timeline/TimelineUIUtils.js b/third_party/WebKit/Source/devtools/front_end/timeline/TimelineUIUtils.js index dba4e5a..b0cfb04 100644 --- a/third_party/WebKit/Source/devtools/front_end/timeline/TimelineUIUtils.js +++ b/third_party/WebKit/Source/devtools/front_end/timeline/TimelineUIUtils.js @@ -2121,11 +2121,12 @@ WebInspector.TimelineUIUtils.eventWarning = function(event, warningType) * @constructor * @param {!WebInspector.DebuggerModel.Location} rawLocation * @param {number} time + * @param {!WebInspector.LiveLocationPool} locationPool */ -WebInspector.TimelineUIUtils.LineLevelProfilePresentation = function(rawLocation, time) +WebInspector.TimelineUIUtils.LineLevelProfilePresentation = function(rawLocation, time, locationPool) { this._time = time; - WebInspector.debuggerWorkspaceBinding.createLiveLocation(rawLocation, this.updateLocation.bind(this)); + WebInspector.debuggerWorkspaceBinding.createLiveLocation(rawLocation, this.updateLocation.bind(this), locationPool); } WebInspector.TimelineUIUtils.LineLevelProfilePresentation.prototype = { |