Diff
Modified: trunk/Source/WebInspectorUI/ChangeLog (184552 => 184553)
--- trunk/Source/WebInspectorUI/ChangeLog 2015-05-19 06:49:56 UTC (rev 184552)
+++ trunk/Source/WebInspectorUI/ChangeLog 2015-05-19 07:12:40 UTC (rev 184553)
@@ -1,3 +1,40 @@
+2015-05-19 Nikita Vasilyev <nvasil...@apple.com>
+
+ Web Inspector: Convert stackTrace from raw payload data to an array of CallFrames
+ https://bugs.webkit.org/show_bug.cgi?id=144982
+
+ Reviewed by Joseph Pecoraro.
+
+ * UserInterface/Controllers/LogManager.js:
+ * UserInterface/Main.html:
+ * UserInterface/Models/CallFrame.js:
+ (WebInspector.CallFrame.fromPayload):
+ Consider an empty string url as a native code as it was in
+ WebInspector.ConsoleMessageView.prototype._firstNonNativeCallFrame
+
+ * UserInterface/Models/ConsoleMessage.js:
+ (WebInspector.ConsoleMessage):
+ Convert _stackTrace from an array of payload objects to WebInspector.StackTrace model.
+
+ * UserInterface/Models/StackTrace.js: Added.
+ (WebInspector.StackTrace):
+ (WebInspector.StackTrace.prototype.get callFrames):
+ (WebInspector.StackTrace.prototype.get firstNonNativeCallFrame): Added.
+ (WebInspector.StackTrace.fromPayload):
+ * UserInterface/Test.html:
+ * UserInterface/Views/CallFrameView.js:
+ (WebInspector.CallFrameView):
+ Don't show a URL when sourceCodeLocation is missing, fix webkit.org/b/145071.
+
+ * UserInterface/Views/ConsoleMessageView.js:
+ (WebInspector.ConsoleMessageView):
+ (WebInspector.ConsoleMessageView.prototype.toClipboardString):
+ (WebInspector.ConsoleMessageView.prototype._appendLocationLink):
+ (WebInspector.ConsoleMessageView.prototype._appendStackTrace):
+ (WebInspector.ConsoleMessageView.prototype._shouldShowStackTrace):
+ (WebInspector.ConsoleMessageView.prototype._linkifyCallFrame):
+ (WebInspector.ConsoleMessageView.prototype._firstNonNativeCallFrame): Deleted.
+
2015-05-18 Joseph Pecoraro <pecor...@apple.com>
Web Inspector: Improve Reliability of Closing and Reopening Elements Tab
Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/LogManager.js (184552 => 184553)
--- trunk/Source/WebInspectorUI/UserInterface/Controllers/LogManager.js 2015-05-19 06:49:56 UTC (rev 184552)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/LogManager.js 2015-05-19 07:12:40 UTC (rev 184553)
@@ -38,7 +38,6 @@
{
// Called from WebInspector.ConsoleObserver.
- // FIXME: stackTrace should be converted to a model object.
// FIXME: Get a request from request ID.
if (parameters)
Modified: trunk/Source/WebInspectorUI/UserInterface/Main.html (184552 => 184553)
--- trunk/Source/WebInspectorUI/UserInterface/Main.html 2015-05-19 06:49:56 UTC (rev 184552)
+++ trunk/Source/WebInspectorUI/UserInterface/Main.html 2015-05-19 07:12:40 UTC (rev 184553)
@@ -299,6 +299,7 @@
<script src=""
<script src=""
<script src=""
+ <script src=""
<script src=""
<script src=""
<script src=""
Modified: trunk/Source/WebInspectorUI/UserInterface/Models/CallFrame.js (184552 => 184553)
--- trunk/Source/WebInspectorUI/UserInterface/Models/CallFrame.js 2015-05-19 06:49:56 UTC (rev 184552)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/CallFrame.js 2015-05-19 07:12:40 UTC (rev 184553)
@@ -108,20 +108,23 @@
var url = ""
var nativeCode = false;
+ var sourceCodeLocation = null;
- if (url ="" "[native code]") {
+ if (!url || url ="" "[native code]") {
nativeCode = true;
url = ""
+ } else {
+ var sourceCode = WebInspector.frameResourceManager.resourceForURL(url);
+ if (!sourceCode)
+ sourceCode = WebInspector.debuggerManager.scriptsForURL(url)[0];
+
+ if (sourceCode) {
+ // The lineNumber is 1-based, but we expect 0-based.
+ var lineNumber = payload.lineNumber - 1;
+ sourceCodeLocation = sourceCode.createLazySourceCodeLocation(lineNumber, payload.columnNumber);
+ }
}
- var sourceCode = WebInspector.frameResourceManager.resourceForURL(url);
- if (!sourceCode)
- sourceCode = WebInspector.debuggerManager.scriptsForURL(url)[0];
-
- // The lineNumber is 1-based, but we expect 0-based.
- var lineNumber = payload.lineNumber - 1;
-
- var sourceCodeLocation = sourceCode ? sourceCode.createLazySourceCodeLocation(lineNumber, payload.columnNumber) : null;
var functionName = payload.functionName !== "global code" ? payload.functionName : null;
return new WebInspector.CallFrame(null, sourceCodeLocation, functionName, null, null, nativeCode);
Modified: trunk/Source/WebInspectorUI/UserInterface/Models/ConsoleMessage.js (184552 => 184553)
--- trunk/Source/WebInspectorUI/UserInterface/Models/ConsoleMessage.js 2015-05-19 06:49:56 UTC (rev 184552)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/ConsoleMessage.js 2015-05-19 07:12:40 UTC (rev 184553)
@@ -44,7 +44,9 @@
this._repeatCount = repeatCount || 0;
this._parameters = parameters;
- this._stackTrace = stackTrace;
+
+ this._stackTrace = WebInspector.StackTrace.fromPayload(stackTrace || []);
+
this._request = request;
}
Added: trunk/Source/WebInspectorUI/UserInterface/Models/StackTrace.js (0 => 184553)
--- trunk/Source/WebInspectorUI/UserInterface/Models/StackTrace.js (rev 0)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/StackTrace.js 2015-05-19 07:12:40 UTC (rev 184553)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2015 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.
+ */
+
+WebInspector.StackTrace = class StackTrace extends WebInspector.Object
+{
+ constructor(callFrames)
+ {
+ super();
+
+ console.assert(callFrames && callFrames.every(function(callFrame) { return callFrame instanceof WebInspector.CallFrame; }));
+
+ this._callFrames = callFrames;
+ }
+
+ get callFrames()
+ {
+ return this._callFrames;
+ }
+
+ get firstNonNativeCallFrame()
+ {
+ for (var frame of this._callFrames) {
+ if (!frame.nativeCode)
+ return frame;
+ }
+
+ return null;
+ }
+
+ // Static
+
+ static fromPayload(payload)
+ {
+ var callFrames = payload.map(WebInspector.CallFrame.fromPayload);
+ return new WebInspector.StackTrace(callFrames);
+ }
+};
Modified: trunk/Source/WebInspectorUI/UserInterface/Test.html (184552 => 184553)
--- trunk/Source/WebInspectorUI/UserInterface/Test.html 2015-05-19 06:49:56 UTC (rev 184552)
+++ trunk/Source/WebInspectorUI/UserInterface/Test.html 2015-05-19 07:12:40 UTC (rev 184553)
@@ -123,6 +123,7 @@
<script src=""
<script src=""
<script src=""
+ <script src=""
<script src=""
<script src=""
<script src=""
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/CallFrameView.js (184552 => 184553)
--- trunk/Source/WebInspectorUI/UserInterface/Views/CallFrameView.js 2015-05-19 06:49:56 UTC (rev 184552)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/CallFrameView.js 2015-05-19 07:12:40 UTC (rev 184553)
@@ -27,23 +27,26 @@
{
constructor(callFrame)
{
- console.assert(callFrame.sourceCodeLocation && callFrame.sourceCodeLocation.sourceCode);
+ console.assert(callFrame instanceof WebInspector.CallFrame);
var callFrameElement = document.createElement("div");
callFrameElement.classList.add("call-frame", WebInspector.CallFrameView.iconClassNameForCallFrame(callFrame));
+ var subtitleElement = document.createElement("span");
+ subtitleElement.classList.add("subtitle");
+
var sourceCodeLocation = callFrame.sourceCodeLocation;
- WebInspector.linkifyElement(callFrameElement, sourceCodeLocation);
+ if (sourceCodeLocation) {
+ WebInspector.linkifyElement(callFrameElement, sourceCodeLocation);
- var linkElement = document.createElement("a");
- linkElement.className = "source-link";
- linkElement.href = ""
- sourceCodeLocation.populateLiveDisplayLocationTooltip(linkElement);
- sourceCodeLocation.populateLiveDisplayLocationString(linkElement, "textContent");
+ var linkElement = document.createElement("a");
+ linkElement.className = "source-link";
+ linkElement.href = ""
+ subtitleElement.appendChild(linkElement);
- var subtitleElement = document.createElement("span");
- subtitleElement.classList.add("subtitle");
- subtitleElement.appendChild(linkElement);
+ sourceCodeLocation.populateLiveDisplayLocationTooltip(linkElement);
+ sourceCodeLocation.populateLiveDisplayLocationString(linkElement, "textContent");
+ }
if (callFrame.functionName) {
var imgElement = document.createElement("img");
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js (184552 => 184553)
--- trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js 2015-05-19 06:49:56 UTC (rev 184552)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js 2015-05-19 07:12:40 UTC (rev 184553)
@@ -191,7 +191,7 @@
var hasStackTrace = this._shouldShowStackTrace();
if (hasStackTrace) {
- this._message.stackTrace.forEach(function(frame) {
+ this._message.stackTrace.callFrames.forEach(function(frame) {
clipboardString += "\n\t" + (frame.functionName || WebInspector.UIString("(anonymous function)"));
if (frame.url)
clipboardString += " (" + WebInspector.displayNameForURL(frame.url) + ", line " + frame.lineNumber + ")";
@@ -286,12 +286,12 @@
if (this._message.source === WebInspector.ConsoleMessage.MessageSource.Network || this._message.request)
return;
- var firstNonNativeCallFrame = this._firstNonNativeCallFrame();
+ var firstNonNativeCallFrame = this._message.stackTrace.firstNonNativeCallFrame;
var callFrame;
if (firstNonNativeCallFrame) {
// _javascript_ errors and console.* methods.
- callFrame = WebInspector.CallFrame.fromPayload(firstNonNativeCallFrame);
+ callFrame = firstNonNativeCallFrame;
} else if (this._message.url && !this._shouldHideURL(this._message.url)) {
// CSS warnings have no stack traces.
callFrame = WebInspector.CallFrame.fromPayload({
@@ -346,11 +346,12 @@
this._stackTraceElement.classList.add("console-message-stack-trace-container");
this._stackTraceElement.classList.add("console-message-text");
- for (var callFrame of this._message.stackTrace) {
+ for (var callFrame of this._message.stackTrace.callFrames) {
var callFrameElement = this._stackTraceElement.appendChild(document.createElement("li"));
callFrameElement.classList.add("console-message-stack-trace-call-frame");
callFrameElement.textContent = callFrame.functionName || WebInspector.UIString("(anonymous function)");
- if (callFrame.url && !this._shouldHideURL(callFrame.url))
+ var url = "" && callFrame.sourceCodeLocation.sourceCode && callFrame.sourceCodeLocation.sourceCode.url) || "";
+ if (url && !this._shouldHideURL(url))
callFrameElement.appendChild(this._linkifyCallFrame(callFrame));
}
}
@@ -594,7 +595,7 @@
_shouldShowStackTrace()
{
- if (!this._message.stackTrace || !this._message.stackTrace.length)
+ if (!this._message.stackTrace.callFrames.length)
return false;
return this._message.source === WebInspector.ConsoleMessage.MessageSource.Network
@@ -607,21 +608,6 @@
return url ="" "undefined" || url ="" "[native code]";
}
- _firstNonNativeCallFrame()
- {
- if (!this._message.stackTrace)
- return null;
-
- for (var i = 0; i < this._message.stackTrace.length; i++) {
- var frame = this._message.stackTrace[i];
- if (!frame.url || frame.url ="" "[native code]")
- continue;
- return frame;
- }
-
- return null;
- }
-
_linkifyLocation(url, lineNumber, columnNumber)
{
// ConsoleMessage stack trace line numbers are one-based.
@@ -632,7 +618,18 @@
_linkifyCallFrame(callFrame)
{
- return this._linkifyLocation(callFrame.url, callFrame.lineNumber, callFrame.columnNumber);
+ var url = ""
+ var lineNumber = 0;
+ var columnNumber = 0;
+
+ var sourceCodeLocation = callFrame._sourceCodeLocation;
+ if (sourceCodeLocation) {
+ lineNumber = sourceCodeLocation.lineNumber;
+ columnNumber = sourceCodeLocation.columnNumber;
+ url = "" && sourceCodeLocation.sourceCode.url || "";
+ }
+
+ return this._linkifyLocation(url, lineNumber, columnNumber);
}
_userProvidedColumnNames(columnNamesArgument)