Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Issue 5866: Show stack trace for function calls log

  • Loading branch information...
commit 6950b501da6d47f51959883ea5ab98c03187051d 1 parent 48542c0
Jan Odvarko authored August 25, 2012
17  extension/content/firebug/console/console.js
@@ -13,6 +13,7 @@ define([
13 13
     "firebug/chrome/searchBox",
14 14
     "firebug/console/consolePanel",
15 15
     "firebug/console/commandEditor",
  16
+    "firebug/console/functionMonitor",
16 17
 ],
17 18
 function(Obj, Firebug, Firefox, Events, Win, Search, Xml, Options) {
18 19
 
@@ -405,22 +406,6 @@ Firebug.Console = Obj.extend(ActivableConsole,
405 406
     },
406 407
 
407 408
     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
408  
-    // Firebug.Debugger listener
409  
-
410  
-    onMonitorScript: function(context, frame)
411  
-    {
412  
-        Firebug.Console.log(frame, context);
413  
-    },
414  
-
415  
-    onFunctionCall: function(context, frame, depth, calling)
416  
-    {
417  
-        if (calling)
418  
-            Firebug.Console.openGroup([frame, "depth:"+depth], context);
419  
-        else
420  
-            Firebug.Console.closeGroup(context);
421  
-    },
422  
-
423  
-    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
424 409
     // BTI
425 410
 
426 411
     /**
186  extension/content/firebug/console/functionMonitor.js
... ...
@@ -0,0 +1,186 @@
  1
+/* See license.txt for terms of usage */
  2
+
  3
+define([
  4
+    "firebug/lib/trace",
  5
+    "firebug/lib/object",
  6
+    "firebug/lib/domplate",
  7
+    "firebug/chrome/reps",
  8
+    "firebug/js/stackFrame",
  9
+    "firebug/lib/events",
  10
+    "firebug/lib/css",
  11
+    "firebug/lib/dom",
  12
+],
  13
+function(FBTrace, Obj, Domplate, Reps, StackFrame, Events, Css, Dom) { with (Domplate) {
  14
+
  15
+// ********************************************************************************************* //
  16
+// Function Monitor
  17
+
  18
+var FunctionMonitor = Obj.extend(Firebug.Module,
  19
+{
  20
+    dispatchName: "functionMonitor",
  21
+
  22
+    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
  23
+    // Module
  24
+
  25
+    initialize: function()
  26
+    {
  27
+        Firebug.Module.initialize.apply(this, arguments);
  28
+        Firebug.connection.addListener(this);
  29
+    },
  30
+
  31
+    shutdown: function()
  32
+    {
  33
+        Firebug.connection.removeListener(this);
  34
+        Firebug.Module.shutdown.apply(this, arguments);
  35
+    },
  36
+
  37
+    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
  38
+    // Firebug.Debugger listener
  39
+
  40
+    onMonitorScript: function(context, frame)
  41
+    {
  42
+        var stackTrace = StackFrame.buildStackTrace(frame);
  43
+        Firebug.Console.log(new FunctionLog(frame, stackTrace), context);
  44
+    },
  45
+
  46
+    onFunctionCall: function(context, frame, depth, calling)
  47
+    {
  48
+        //var url = Url.normalizeURL(frame.script.fileName);
  49
+        //var sourceFile = context.sourceFileMap[url];
  50
+        // Firebug.errorStackTrace = StackFrame.getCorrectedStackTrace(frame, context);
  51
+        //var sourceFile = Firebug.SourceFile.getSourceFileByScript(context, frame.script);
  52
+        if (!Url.isSystemURL(Url.normalizeURL(frame.script.fileName)))
  53
+            return;
  54
+
  55
+        // xxxHonza: traceCall and traceCallAll need to be fixed yet.
  56
+        FBTrace.sysout("console.onFunctionCall; ", sourceFile);
  57
+
  58
+        if (calling)
  59
+            Firebug.Console.openGroup([frame, "depth:" + depth], context);
  60
+        else
  61
+            Firebug.Console.closeGroup(context);
  62
+    },
  63
+});
  64
+
  65
+// ********************************************************************************************* //
  66
+// Rep Object
  67
+
  68
+function FunctionLog(frame, stackTrace)
  69
+{
  70
+    this.frame = frame;
  71
+    this.stackTrace = stackTrace;
  72
+}
  73
+
  74
+// ********************************************************************************************* //
  75
+// Function Monitor Rep
  76
+
  77
+var FunctionMonitorRep = domplate(Firebug.Rep,
  78
+{
  79
+    className: "functionCall",
  80
+
  81
+    tag:
  82
+        Reps.OBJECTBLOCK({$hasTwisty: "$object|hasStackTrace", _repObject: "$object",
  83
+            onclick: "$onToggleStackTrace"},
  84
+            A({"class": "objectLink functionCallTitle a11yFocus", _repObject: "$object"},
  85
+                "$object|getCallName"
  86
+            ),
  87
+            SPAN("("),
  88
+            SPAN({"class": "arguments"},
  89
+                FOR("arg", "$object|argIterator",
  90
+                    SPAN({"class": "argName"}, "$arg.name"),
  91
+                    SPAN("="),
  92
+                    TAG("$arg.tag", {object: "$arg.value"}),
  93
+                    SPAN({"class": "arrayComma"}, "$arg.delim")
  94
+                )
  95
+            ),
  96
+            SPAN(")"),
  97
+            SPAN({"class": "objectLink-sourceLink objectLink a11yFocus",
  98
+                _repObject: "$object|getSourceLink",
  99
+                role: "link"},
  100
+                "$object|getSourceLinkTitle"),
  101
+            DIV({"class": "stackTrace"})
  102
+        ),
  103
+
  104
+    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
  105
+
  106
+    hasStackTrace: function(object)
  107
+    {
  108
+        return true;
  109
+    },
  110
+
  111
+    getTitle: function(object)
  112
+    {
  113
+        return object.frame.getFunctionName();
  114
+    },
  115
+
  116
+    getCallName: function(object)
  117
+    {
  118
+        return this.getTitle(object);
  119
+    },
  120
+
  121
+    getSourceLink: function(object)
  122
+    {
  123
+        return Reps.StackFrame.getSourceLink(object.frame);
  124
+    },
  125
+
  126
+    getSourceLinkTitle: function(object)
  127
+    {
  128
+        return Reps.StackFrame.getSourceLinkTitle(object.frame);
  129
+    },
  130
+
  131
+    argIterator: function(object)
  132
+    {
  133
+        return Reps.StackFrame.argIterator(object.frame);
  134
+    },
  135
+
  136
+    onToggleStackTrace: function(event)
  137
+    {
  138
+        var target = event.target;
  139
+
  140
+        // Clicking on the source link uses default navigation.
  141
+        if (Css.hasClass(target, "objectLink-sourceLink"))
  142
+            return;
  143
+
  144
+        var objectBox = Dom.getAncestorByClass(target, "objectBox-functionCall");
  145
+        if (!objectBox)
  146
+            return;
  147
+
  148
+        var traceBox = objectBox.getElementsByClassName("stackTrace").item(0);
  149
+        Css.toggleClass(traceBox, "opened");
  150
+
  151
+        if (Css.hasClass(traceBox, "opened"))
  152
+        {
  153
+            var functionCall = objectBox.repObject;
  154
+            Reps.StackTrace.tag.append({object: functionCall.stackTrace}, traceBox);
  155
+        }
  156
+        else
  157
+        {
  158
+            Dom.clearNode(traceBox);
  159
+        }
  160
+
  161
+        Events.cancelEvent(event);
  162
+    },
  163
+
  164
+    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
  165
+
  166
+    supportsObject: function(object, type)
  167
+    {
  168
+        return object instanceof FunctionLog;
  169
+    },
  170
+
  171
+    getRealObject: function(object)
  172
+    {
  173
+        return object.frame;
  174
+    },
  175
+});
  176
+
  177
+// ********************************************************************************************* //
  178
+// Registration
  179
+
  180
+Firebug.registerModule(FunctionMonitor);
  181
+Firebug.registerRep(FunctionMonitorRep);
  182
+
  183
+return FunctionMonitor;
  184
+
  185
+// ********************************************************************************************* //
  186
+}});
8  extension/skin/classic/callstack.css
@@ -69,3 +69,11 @@
69 69
     display: none;
70 70
 }
71 71
 
  72
+/*************************************************************************************************/
  73
+/* FunctionCall log */
  74
+
  75
+.objectBox-functionCall {
  76
+    padding-left: 17px;
  77
+    cursor: default;
  78
+    position: relative;
  79
+}
2  extension/skin/classic/mac/panel.css
@@ -19,6 +19,7 @@ body {
19 19
 .memberRow.hasChildren > .memberLabelCell > .memberLabel,
20 20
 .hasHeaders .netHrefLabel,
21 21
 .objectBox-stackFrame.hasTwisty,
  22
+.objectBox-functionCall.hasTwisty,
22 23
 .netPageRow > .netCol > .netPageTitle,
23 24
 .computedStyle.hasSelectors > .stylePropName,
24 25
 .cookieRow > .cookieNameCol > .cookieNameLabel {
@@ -36,6 +37,7 @@ body {
36 37
 .nodeBox.open > .nodeLabel > .twisty,
37 38
 .netRow.opened > .netCol > .netHrefLabel,
38 39
 .objectBox-stackFrame.hasTwisty.opened,
  40
+.objectBox-functionCall.hasTwisty.opened,
39 41
 .netPageRow.opened > .netCol > .netPageTitle,
40 42
 .computedStyle.hasSelectors.opened > .stylePropName,
41 43
 .cookieRow.opened > .cookieNameCol > .cookieNameLabel {
2  extension/skin/classic/win/panel.css
@@ -11,6 +11,7 @@
11 11
 .memberRow.hasChildren > .memberLabelCell > .memberLabel,
12 12
 .hasHeaders .netHrefLabel,
13 13
 .objectBox-stackFrame.hasTwisty,
  14
+.objectBox-functionCall.hasTwisty,
14 15
 .netPageRow > .netCol > .netPageTitle,
15 16
 .cssComputedHeader > .twisty,
16 17
 .breakpointHeader > .twisty,
@@ -32,6 +33,7 @@
32 33
 .netRow.opened > .netCol > .netHrefLabel,
33 34
 .netPageRow.opened > .netCol > .netPageTitle,
34 35
 .objectBox-stackFrame.hasTwisty.opened,
  36
+.objectBox-functionCall.hasTwisty.opened,
35 37
 .computedStylesGroup.opened > .cssComputedHeader > .twisty,
36 38
 .breakpointBlock.opened > .breakpointHeader > .twisty,
37 39
 .computedStyle.hasSelectors.opened > .stylePropName,

0 notes on commit 6950b50

Please sign in to comment.
Something went wrong with that request. Please try again.