From be5c866b8f69281ba1a129f77826c41318dc6ad6 Mon Sep 17 00:00:00 2001 From: kozyatinskiy Date: Thu, 18 Feb 2016 13:49:27 -0800 Subject: [PATCH] [DevTools] Blackboxing in LiveLocations is supported in Linkifier R=dgozman@chromium.org BUG=583193 Review URL: https://codereview.chromium.org/1688283002 Cr-Commit-Position: refs/heads/master@{#376278} --- front_end/bindings/BlackboxManager.js | 7 ++-- front_end/bindings/BreakpointManager.js | 7 ++-- front_end/bindings/CSSWorkspaceBinding.js | 13 ++++++-- .../bindings/DebuggerWorkspaceBinding.js | 19 ++++++++--- front_end/bindings/LiveLocation.js | 16 +++++---- .../PresentationConsoleMessageHelper.js | 7 ++-- front_end/components/Linkifier.js | 33 +++++++++---------- front_end/sources/CallStackSidebarPane.js | 7 ++-- front_end/sources/SourcesPanel.js | 14 +++++--- 9 files changed, 80 insertions(+), 43 deletions(-) diff --git a/front_end/bindings/BlackboxManager.js b/front_end/bindings/BlackboxManager.js index e69c3e4d84..f542c5927c 100644 --- a/front_end/bindings/BlackboxManager.js +++ b/front_end/bindings/BlackboxManager.js @@ -24,7 +24,6 @@ WebInspector.BlackboxManager = function(debuggerWorkspaceBinding, networkMapping } WebInspector.BlackboxManager.prototype = { - /** * @param {function(!WebInspector.Event)} listener * @param {!Object=} thisObject @@ -308,10 +307,12 @@ WebInspector.BlackboxManager.prototype = { */ function updateState(success) { - if (success) + if (success) { this._scriptIdToPositions.set(script.scriptId, positions); - else if (!this._scriptIdToPositions.has(script.scriptId)) + this._debuggerWorkspaceBinding.updateLocations(script); + } else if (!this._scriptIdToPositions.has(script.scriptId)) { this._scriptIdToPositions.set(script.scriptId, []); + } } }, diff --git a/front_end/bindings/BreakpointManager.js b/front_end/bindings/BreakpointManager.js index 4e665e068d..53446c5b79 100644 --- a/front_end/bindings/BreakpointManager.js +++ b/front_end/bindings/BreakpointManager.js @@ -919,10 +919,13 @@ WebInspector.BreakpointManager.TargetBreakpoint.prototype = { /** * @param {!WebInspector.DebuggerModel.Location} location - * @param {!WebInspector.UILocation} uiLocation + * @param {!WebInspector.LiveLocation} liveLocation */ - _locationUpdated: function(location, uiLocation) + _locationUpdated: function(location, liveLocation) { + var uiLocation = liveLocation.uiLocation(); + if (!uiLocation) + return; var oldUILocation = this._uiLocations[location.id()] || null; this._uiLocations[location.id()] = uiLocation; this._breakpoint._replaceUILocation(oldUILocation, uiLocation); diff --git a/front_end/bindings/CSSWorkspaceBinding.js b/front_end/bindings/CSSWorkspaceBinding.js index 1502aa0ad9..62835f65bb 100644 --- a/front_end/bindings/CSSWorkspaceBinding.js +++ b/front_end/bindings/CSSWorkspaceBinding.js @@ -100,7 +100,7 @@ WebInspector.CSSWorkspaceBinding.prototype = { /** * @param {!WebInspector.CSSLocation} rawLocation - * @param {function(!WebInspector.UILocation):(boolean|undefined)} updateDelegate + * @param {function(!WebInspector.LiveLocation)} updateDelegate * @return {!WebInspector.CSSWorkspaceBinding.LiveLocation} */ createLiveLocation: function(rawLocation, updateDelegate) @@ -314,7 +314,7 @@ WebInspector.CSSWorkspaceBinding.HeaderInfo.prototype = { * @param {?WebInspector.CSSStyleSheetHeader} header * @param {!WebInspector.CSSLocation} rawLocation * @param {!WebInspector.CSSWorkspaceBinding} binding - * @param {function(!WebInspector.UILocation):(boolean|undefined)} updateDelegate + * @param {function(!WebInspector.LiveLocation)} updateDelegate */ WebInspector.CSSWorkspaceBinding.LiveLocation = function(cssModel, header, rawLocation, binding, updateDelegate) { @@ -397,6 +397,15 @@ WebInspector.CSSWorkspaceBinding.LiveLocation.prototype = { this._cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.StyleSheetRemoved, this._styleSheetRemoved, this); }, + /** + * @override + * @return {boolean} + */ + isBlackboxed: function() + { + return false; + }, + __proto__: WebInspector.LiveLocation.prototype } diff --git a/front_end/bindings/DebuggerWorkspaceBinding.js b/front_end/bindings/DebuggerWorkspaceBinding.js index 0e90c6fc8a..6d22ee76e9 100644 --- a/front_end/bindings/DebuggerWorkspaceBinding.js +++ b/front_end/bindings/DebuggerWorkspaceBinding.js @@ -121,7 +121,7 @@ WebInspector.DebuggerWorkspaceBinding.prototype = { /** * @param {!WebInspector.DebuggerModel.Location} rawLocation - * @param {function(!WebInspector.UILocation):(boolean|undefined)} updateDelegate + * @param {function(!WebInspector.LiveLocation)} updateDelegate * @return {!WebInspector.DebuggerWorkspaceBinding.Location} */ createLiveLocation: function(rawLocation, updateDelegate) @@ -135,7 +135,7 @@ WebInspector.DebuggerWorkspaceBinding.prototype = { /** * @param {!WebInspector.DebuggerModel.CallFrame} callFrame - * @param {function(!WebInspector.UILocation):(boolean|undefined)} updateDelegate + * @param {function(!WebInspector.LiveLocation)} updateDelegate * @return {!WebInspector.DebuggerWorkspaceBinding.Location} */ createCallFrameLiveLocation: function(callFrame, updateDelegate) @@ -469,7 +469,7 @@ WebInspector.DebuggerWorkspaceBinding.ScriptInfo.prototype = { }, /** - * @param {!WebInspector.LiveLocation} location + * @param {!WebInspector.DebuggerWorkspaceBinding.Location} location */ _addLocation: function(location) { @@ -478,7 +478,7 @@ WebInspector.DebuggerWorkspaceBinding.ScriptInfo.prototype = { }, /** - * @param {!WebInspector.LiveLocation} location + * @param {!WebInspector.DebuggerWorkspaceBinding.Location} location */ _removeLocation: function(location) { @@ -512,7 +512,7 @@ WebInspector.DebuggerWorkspaceBinding.ScriptInfo.prototype = { * @param {!WebInspector.Script} script * @param {!WebInspector.DebuggerModel.Location} rawLocation * @param {!WebInspector.DebuggerWorkspaceBinding} binding - * @param {function(!WebInspector.UILocation):(boolean|undefined)} updateDelegate + * @param {function(!WebInspector.LiveLocation)} updateDelegate */ WebInspector.DebuggerWorkspaceBinding.Location = function(script, rawLocation, binding, updateDelegate) { @@ -539,6 +539,15 @@ WebInspector.DebuggerWorkspaceBinding.Location.prototype = { this._binding._removeLiveLocation(this); }, + /** + * @override + * @return {boolean} + */ + isBlackboxed: function() + { + return WebInspector.blackboxManager.isBlackboxedRawLocation(this._rawLocation); + }, + __proto__: WebInspector.LiveLocation.prototype } diff --git a/front_end/bindings/LiveLocation.js b/front_end/bindings/LiveLocation.js index 2cc65c3a03..50bd67c120 100644 --- a/front_end/bindings/LiveLocation.js +++ b/front_end/bindings/LiveLocation.js @@ -4,7 +4,7 @@ /** * @constructor - * @param {function(!WebInspector.UILocation):(boolean|undefined)} updateDelegate + * @param {function(!WebInspector.LiveLocation)} updateDelegate */ WebInspector.LiveLocation = function(updateDelegate) { @@ -14,11 +14,7 @@ WebInspector.LiveLocation = function(updateDelegate) WebInspector.LiveLocation.prototype = { update: function() { - var uiLocation = this.uiLocation(); - if (!uiLocation) - return; - if (this._updateDelegate(uiLocation)) - this.dispose(); + this._updateDelegate(this); }, /** @@ -32,5 +28,13 @@ WebInspector.LiveLocation.prototype = { dispose: function() { // Overridden by subclasses. + }, + + /** + * @return {boolean} + */ + isBlackboxed: function() + { + throw "Not implemented"; } } diff --git a/front_end/bindings/PresentationConsoleMessageHelper.js b/front_end/bindings/PresentationConsoleMessageHelper.js index 0f66b56b22..7d54c7041d 100644 --- a/front_end/bindings/PresentationConsoleMessageHelper.js +++ b/front_end/bindings/PresentationConsoleMessageHelper.js @@ -173,12 +173,15 @@ WebInspector.PresentationConsoleMessage = function(message, rawLocation) WebInspector.PresentationConsoleMessage.prototype = { /** - * @param {!WebInspector.UILocation} uiLocation + * @param {!WebInspector.LiveLocation} liveLocation */ - _updateLocation: function(uiLocation) + _updateLocation: function(liveLocation) { if (this._uiMessage) this._uiMessage.remove(); + var uiLocation = liveLocation.uiLocation(); + if (!uiLocation) + return; this._uiMessage = uiLocation.uiSourceCode.addLineMessage(this._level, this._text, uiLocation.lineNumber, uiLocation.columnNumber); }, diff --git a/front_end/components/Linkifier.js b/front_end/components/Linkifier.js index f7804d5f9d..ef8b827405 100644 --- a/front_end/components/Linkifier.js +++ b/front_end/components/Linkifier.js @@ -39,8 +39,9 @@ WebInspector.LinkifierFormatter.prototype = { /** * @param {!Element} anchor * @param {!WebInspector.UILocation} uiLocation + * @param {boolean} isBlackboxed */ - formatLiveAnchor: function(anchor, uiLocation) { } + formatLiveAnchor: function(anchor, uiLocation, isBlackboxed) { } } /** @@ -202,16 +203,7 @@ WebInspector.Linkifier.prototype = { // FIXME(62725): console stack trace line/column numbers are one-based. var lineNumber = callFrame.lineNumber ? callFrame.lineNumber - 1 : 0; var columnNumber = callFrame.columnNumber ? callFrame.columnNumber - 1 : 0; - var anchor = this.linkifyScriptLocation(target, callFrame.scriptId, callFrame.url, lineNumber, columnNumber, classes); - var debuggerModel = WebInspector.DebuggerModel.fromTarget(target); - var location = debuggerModel && debuggerModel.createRawLocationByScriptId(callFrame.scriptId, callFrame.lineNumber, callFrame.columnNumber); - var blackboxed = location ? - WebInspector.blackboxManager.isBlackboxedRawLocation(location) : - WebInspector.blackboxManager.isBlackboxedURL(callFrame.url); - if (blackboxed) - anchor.classList.add("webkit-html-blackbox-link"); - - return anchor; + return this.linkifyScriptLocation(target, callFrame.scriptId, callFrame.url, lineNumber, columnNumber, classes); }, /** @@ -290,12 +282,15 @@ WebInspector.Linkifier.prototype = { /** * @param {!Element} anchor - * @param {!WebInspector.UILocation} uiLocation + * @param {!WebInspector.LiveLocation} liveLocation */ - _updateAnchor: function(anchor, uiLocation) + _updateAnchor: function(anchor, liveLocation) { + var uiLocation = liveLocation.uiLocation(); + if (!uiLocation) + return; anchor[WebInspector.Linkifier._uiLocationSymbol] = uiLocation; - this._formatter.formatLiveAnchor(anchor, uiLocation); + this._formatter.formatLiveAnchor(anchor, uiLocation, liveLocation.isBlackboxed()); } } @@ -323,8 +318,9 @@ WebInspector.Linkifier.DefaultFormatter.prototype = { * @override * @param {!Element} anchor * @param {!WebInspector.UILocation} uiLocation + * @param {boolean} isBlackboxed */ - formatLiveAnchor: function(anchor, uiLocation) + formatLiveAnchor: function(anchor, uiLocation, isBlackboxed) { var text = uiLocation.linkText(); text = text.replace(/([a-f0-9]{7})[a-f0-9]{13}[a-f0-9]*/g, "$1\u2026"); @@ -336,6 +332,8 @@ WebInspector.Linkifier.DefaultFormatter.prototype = { if (typeof uiLocation.lineNumber === "number") titleText += ":" + (uiLocation.lineNumber + 1); anchor.title = titleText; + + anchor.classList.toggle("webkit-html-blackbox-link", isBlackboxed); } } @@ -355,10 +353,11 @@ WebInspector.Linkifier.DefaultCSSFormatter.prototype = { * @override * @param {!Element} anchor * @param {!WebInspector.UILocation} uiLocation + * @param {boolean} isBlackboxed */ - formatLiveAnchor: function(anchor, uiLocation) + formatLiveAnchor: function(anchor, uiLocation, isBlackboxed) { - WebInspector.Linkifier.DefaultFormatter.prototype.formatLiveAnchor.call(this, anchor, uiLocation); + WebInspector.Linkifier.DefaultFormatter.prototype.formatLiveAnchor.call(this, anchor, uiLocation, isBlackboxed); anchor.classList.add("webkit-html-resource-link"); anchor.setAttribute("data-uncopyable", anchor.textContent); anchor.textContent = ""; diff --git a/front_end/sources/CallStackSidebarPane.js b/front_end/sources/CallStackSidebarPane.js index 23ddc267dc..588a449d52 100644 --- a/front_end/sources/CallStackSidebarPane.js +++ b/front_end/sources/CallStackSidebarPane.js @@ -425,10 +425,13 @@ WebInspector.CallStackSidebarPane.CallFrame = function(callFrame, asyncCallFrame WebInspector.CallStackSidebarPane.CallFrame.prototype = { /** - * @param {!WebInspector.UILocation} uiLocation + * @param {!WebInspector.LiveLocation} liveLocation */ - _update: function(uiLocation) + _update: function(liveLocation) { + var uiLocation = liveLocation.uiLocation(); + if (!uiLocation) + return; var text = uiLocation.linkText(); this.setSubtitle(text.trimMiddle(30)); this.subtitleElement.title = text; diff --git a/front_end/sources/SourcesPanel.js b/front_end/sources/SourcesPanel.js index b99dda493a..efc8026cea 100644 --- a/front_end/sources/SourcesPanel.js +++ b/front_end/sources/SourcesPanel.js @@ -242,11 +242,14 @@ WebInspector.SourcesPanel.prototype = { } /** - * @param {!WebInspector.UILocation} uiLocation + * @param {!WebInspector.LiveLocation} liveLocation * @this {WebInspector.SourcesPanel} */ - function didGetUILocation(uiLocation) + function didGetUILocation(liveLocation) { + var uiLocation = liveLocation.uiLocation(); + if (!uiLocation) + return; var breakpoint = WebInspector.breakpointManager.findBreakpointOnLine(uiLocation.uiSourceCode, uiLocation.lineNumber); if (!breakpoint) return; @@ -388,10 +391,13 @@ WebInspector.SourcesPanel.prototype = { }, /** - * @param {!WebInspector.UILocation} uiLocation + * @param {!WebInspector.LiveLocation} liveLocation */ - _executionLineChanged: function(uiLocation) + _executionLineChanged: function(liveLocation) { + var uiLocation = liveLocation.uiLocation(); + if (!uiLocation) + return; this._sourcesView.clearCurrentExecutionLine(); this._sourcesView.setExecutionLocation(uiLocation); if (window.performance.now() - this._lastModificationTime < WebInspector.SourcesPanel._lastModificationTimeout)