Adds the files and line numbers to the Profile call tree.
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 May 2008 21:09:59 +0000 (21:09 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 May 2008 21:09:59 +0000 (21:09 +0000)
<rdar://problem/5952924> Inspector needs to show file and line number
in the Profile call tree

Reviewed by Geoff Garen.

* page/JavaScriptProfileNode.cpp:
(WebCore::getFunctionName): Fixes a JSStringRef leak.
(WebCore::getURL): Call ProfileNode::url.
(WebCore::getLineNumber): Call ProfileNode::lineNumber.
(WebCore::ProfileNodeClass): Add the url and lineNumber properties.
* page/inspector/ProfileView.js:
(WebInspector.ProfileDataGridNode.prototype.createCell): Overload the
DataGridNode.createCell and add the file and lineNumber to the
cell if the column is the function column.
* page/inspector/inspector.css: New styles for the file and line.

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

WebCore/ChangeLog
WebCore/page/JavaScriptProfileNode.cpp
WebCore/page/inspector/ProfileView.js
WebCore/page/inspector/inspector.css

index 0538e79..ca35cdd 100644 (file)
@@ -1,5 +1,25 @@
 2008-05-21  Timothy Hatcher  <timothy@apple.com>
 
+        Adds the files and line numbers to the Profile call tree.
+
+        <rdar://problem/5952924> Inspector needs to show file and line number
+        in the Profile call tree
+
+        Reviewed by Geoff Garen.
+
+        * page/JavaScriptProfileNode.cpp:
+        (WebCore::getFunctionName): Fixes a JSStringRef leak.
+        (WebCore::getURL): Call ProfileNode::url.
+        (WebCore::getLineNumber): Call ProfileNode::lineNumber.
+        (WebCore::ProfileNodeClass): Add the url and lineNumber properties.
+        * page/inspector/ProfileView.js:
+        (WebInspector.ProfileDataGridNode.prototype.createCell): Overload the
+        DataGridNode.createCell and add the file and lineNumber to the
+        cell if the column is the function column.
+        * page/inspector/inspector.css: New styles for the file and line.
+
+2008-05-21  Timothy Hatcher  <timothy@apple.com>
+
         Restores logging of console calls to the STDOUT
         when Interpreter::shouldPrintExceptions() is true.
 
index a6b0cf3..491e433 100644 (file)
@@ -59,7 +59,27 @@ static JSValueRef getFunctionName(JSContextRef ctx, JSObjectRef thisObject, JSSt
         return JSValueMakeUndefined(ctx);
 
     ProfileNode* profileNode = static_cast<ProfileNode*>(JSObjectGetPrivate(thisObject));
-    return JSValueMakeString(ctx, JSStringCreateWithCharacters(profileNode->functionName().data(), profileNode->functionName().size()));
+    JSRetainPtr<JSStringRef> functionNameString(Adopt, JSStringCreateWithCharacters(profileNode->functionName().data(), profileNode->functionName().size()));
+    return JSValueMakeString(ctx, functionNameString.get());
+}
+
+static JSValueRef getURL(JSContextRef ctx, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
+{
+    if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass()))
+        return JSValueMakeUndefined(ctx);
+
+    ProfileNode* profileNode = static_cast<ProfileNode*>(JSObjectGetPrivate(thisObject));
+    JSRetainPtr<JSStringRef> urlString(Adopt, JSStringCreateWithCharacters(profileNode->url().data(), profileNode->url().size()));
+    return JSValueMakeString(ctx, urlString.get());
+}
+
+static JSValueRef getLineNumber(JSContextRef ctx, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
+{
+    if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass()))
+        return JSValueMakeUndefined(ctx);
+
+    ProfileNode* profileNode = static_cast<ProfileNode*>(JSObjectGetPrivate(thisObject));
+    return JSValueMakeNumber(ctx, profileNode->lineNumber());
 }
 
 static JSValueRef getTotalTime(JSContextRef ctx, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
@@ -262,6 +282,8 @@ JSClassRef ProfileNodeClass()
 {
     static JSStaticValue staticValues[] = {
         { "functionName", getFunctionName, 0, kJSPropertyAttributeNone },
+        { "url", getURL, 0, kJSPropertyAttributeNone },
+        { "lineNumber", getLineNumber, 0, kJSPropertyAttributeNone },
         { "totalTime", getTotalTime, 0, kJSPropertyAttributeNone },
         { "selfTime", getSelfTime, 0, kJSPropertyAttributeNone },
         { "totalPercent", getTotalPercent, 0, kJSPropertyAttributeNone },
index bc16921..9d7f3c1 100644 (file)
@@ -171,6 +171,32 @@ WebInspector.ProfileDataGridNode.prototype = {
         return data;
     },
 
+    createCell: function(columnIdentifier)
+    {
+        var cell = WebInspector.DataGridNode.prototype.createCell.call(this, columnIdentifier);
+        if (columnIdentifier !== "function")
+            return cell;
+
+        if (this.profileNode.url) {
+            var resource = WebInspector.resourceURLMap[this.profileNode.url];
+            var fileName = resource ? resource.displayName : this.profileNode.url;
+
+            var urlElement = document.createElement("a");
+            urlElement.className = "profile-node-file webkit-html-resource-link";
+            urlElement.href = this.profileNode.url;
+            urlElement.lineNumber = this.profileNode.lineNumber;
+
+            if (this.profileNode.lineNumber > 0)
+                urlElement.textContent = fileName + ":" + this.profileNode.lineNumber;
+            else
+                urlElement.textContent = fileName;
+
+            cell.insertBefore(urlElement, cell.firstChild);
+        }
+
+        return cell;
+    },
+
     expand: function()
     {
         WebInspector.DataGridNode.prototype.expand.call(this);
index ff61874..5833f8f 100644 (file)
@@ -2418,3 +2418,17 @@ body.inactive .sidebar-tree-item.selected {
 .profile-view .data-grid .calls-column {
     text-align: center;
 }
+
+.profile-node-file {
+    float: right;
+    color: gray;
+    margin-top: -1px;
+}
+
+.data-grid tr.selected .profile-node-file {
+    color: rgb(33%, 33%, 33%);
+}
+
+.data-grid:focus tr.selected .profile-node-file {
+    color: white;
+}