Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Issue 5866: Show stack trace for function calls log

  • Loading branch information...
commit 6950b501da6d47f51959883ea5ab98c03187051d 1 parent 48542c0
@janodvarko janodvarko authored
View
17 extension/content/firebug/console/console.js
@@ -13,6 +13,7 @@ define([
"firebug/chrome/searchBox",
"firebug/console/consolePanel",
"firebug/console/commandEditor",
+ "firebug/console/functionMonitor",
],
function(Obj, Firebug, Firefox, Events, Win, Search, Xml, Options) {
@@ -405,22 +406,6 @@ Firebug.Console = Obj.extend(ActivableConsole,
},
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
- // Firebug.Debugger listener
-
- onMonitorScript: function(context, frame)
- {
- Firebug.Console.log(frame, context);
- },
-
- onFunctionCall: function(context, frame, depth, calling)
- {
- if (calling)
- Firebug.Console.openGroup([frame, "depth:"+depth], context);
- else
- Firebug.Console.closeGroup(context);
- },
-
- // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// BTI
/**
View
186 extension/content/firebug/console/functionMonitor.js
@@ -0,0 +1,186 @@
+/* See license.txt for terms of usage */
+
+define([
+ "firebug/lib/trace",
+ "firebug/lib/object",
+ "firebug/lib/domplate",
+ "firebug/chrome/reps",
+ "firebug/js/stackFrame",
+ "firebug/lib/events",
+ "firebug/lib/css",
+ "firebug/lib/dom",
+],
+function(FBTrace, Obj, Domplate, Reps, StackFrame, Events, Css, Dom) { with (Domplate) {
+
+// ********************************************************************************************* //
+// Function Monitor
+
+var FunctionMonitor = Obj.extend(Firebug.Module,
+{
+ dispatchName: "functionMonitor",
+
+ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+ // Module
+
+ initialize: function()
+ {
+ Firebug.Module.initialize.apply(this, arguments);
+ Firebug.connection.addListener(this);
+ },
+
+ shutdown: function()
+ {
+ Firebug.connection.removeListener(this);
+ Firebug.Module.shutdown.apply(this, arguments);
+ },
+
+ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+ // Firebug.Debugger listener
+
+ onMonitorScript: function(context, frame)
+ {
+ var stackTrace = StackFrame.buildStackTrace(frame);
+ Firebug.Console.log(new FunctionLog(frame, stackTrace), context);
+ },
+
+ onFunctionCall: function(context, frame, depth, calling)
+ {
+ //var url = Url.normalizeURL(frame.script.fileName);
+ //var sourceFile = context.sourceFileMap[url];
+ // Firebug.errorStackTrace = StackFrame.getCorrectedStackTrace(frame, context);
+ //var sourceFile = Firebug.SourceFile.getSourceFileByScript(context, frame.script);
+ if (!Url.isSystemURL(Url.normalizeURL(frame.script.fileName)))
+ return;
+
+ // xxxHonza: traceCall and traceCallAll need to be fixed yet.
+ FBTrace.sysout("console.onFunctionCall; ", sourceFile);
+
+ if (calling)
+ Firebug.Console.openGroup([frame, "depth:" + depth], context);
+ else
+ Firebug.Console.closeGroup(context);
+ },
+});
+
+// ********************************************************************************************* //
+// Rep Object
+
+function FunctionLog(frame, stackTrace)
+{
+ this.frame = frame;
+ this.stackTrace = stackTrace;
+}
+
+// ********************************************************************************************* //
+// Function Monitor Rep
+
+var FunctionMonitorRep = domplate(Firebug.Rep,
+{
+ className: "functionCall",
+
+ tag:
+ Reps.OBJECTBLOCK({$hasTwisty: "$object|hasStackTrace", _repObject: "$object",
+ onclick: "$onToggleStackTrace"},
+ A({"class": "objectLink functionCallTitle a11yFocus", _repObject: "$object"},
+ "$object|getCallName"
+ ),
+ SPAN("("),
+ SPAN({"class": "arguments"},
+ FOR("arg", "$object|argIterator",
+ SPAN({"class": "argName"}, "$arg.name"),
+ SPAN("="),
+ TAG("$arg.tag", {object: "$arg.value"}),
+ SPAN({"class": "arrayComma"}, "$arg.delim")
+ )
+ ),
+ SPAN(")"),
+ SPAN({"class": "objectLink-sourceLink objectLink a11yFocus",
+ _repObject: "$object|getSourceLink",
+ role: "link"},
+ "$object|getSourceLinkTitle"),
+ DIV({"class": "stackTrace"})
+ ),
+
+ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+ hasStackTrace: function(object)
+ {
+ return true;
+ },
+
+ getTitle: function(object)
+ {
+ return object.frame.getFunctionName();
+ },
+
+ getCallName: function(object)
+ {
+ return this.getTitle(object);
+ },
+
+ getSourceLink: function(object)
+ {
+ return Reps.StackFrame.getSourceLink(object.frame);
+ },
+
+ getSourceLinkTitle: function(object)
+ {
+ return Reps.StackFrame.getSourceLinkTitle(object.frame);
+ },
+
+ argIterator: function(object)
+ {
+ return Reps.StackFrame.argIterator(object.frame);
+ },
+
+ onToggleStackTrace: function(event)
+ {
+ var target = event.target;
+
+ // Clicking on the source link uses default navigation.
+ if (Css.hasClass(target, "objectLink-sourceLink"))
+ return;
+
+ var objectBox = Dom.getAncestorByClass(target, "objectBox-functionCall");
+ if (!objectBox)
+ return;
+
+ var traceBox = objectBox.getElementsByClassName("stackTrace").item(0);
+ Css.toggleClass(traceBox, "opened");
+
+ if (Css.hasClass(traceBox, "opened"))
+ {
+ var functionCall = objectBox.repObject;
+ Reps.StackTrace.tag.append({object: functionCall.stackTrace}, traceBox);
+ }
+ else
+ {
+ Dom.clearNode(traceBox);
+ }
+
+ Events.cancelEvent(event);
+ },
+
+ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+ supportsObject: function(object, type)
+ {
+ return object instanceof FunctionLog;
+ },
+
+ getRealObject: function(object)
+ {
+ return object.frame;
+ },
+});
+
+// ********************************************************************************************* //
+// Registration
+
+Firebug.registerModule(FunctionMonitor);
+Firebug.registerRep(FunctionMonitorRep);
+
+return FunctionMonitor;
+
+// ********************************************************************************************* //
+}});
View
8 extension/skin/classic/callstack.css
@@ -69,3 +69,11 @@
display: none;
}
+/*************************************************************************************************/
+/* FunctionCall log */
+
+.objectBox-functionCall {
+ padding-left: 17px;
+ cursor: default;
+ position: relative;
+}
View
2  extension/skin/classic/mac/panel.css
@@ -19,6 +19,7 @@ body {
.memberRow.hasChildren > .memberLabelCell > .memberLabel,
.hasHeaders .netHrefLabel,
.objectBox-stackFrame.hasTwisty,
+.objectBox-functionCall.hasTwisty,
.netPageRow > .netCol > .netPageTitle,
.computedStyle.hasSelectors > .stylePropName,
.cookieRow > .cookieNameCol > .cookieNameLabel {
@@ -36,6 +37,7 @@ body {
.nodeBox.open > .nodeLabel > .twisty,
.netRow.opened > .netCol > .netHrefLabel,
.objectBox-stackFrame.hasTwisty.opened,
+.objectBox-functionCall.hasTwisty.opened,
.netPageRow.opened > .netCol > .netPageTitle,
.computedStyle.hasSelectors.opened > .stylePropName,
.cookieRow.opened > .cookieNameCol > .cookieNameLabel {
View
2  extension/skin/classic/win/panel.css
@@ -11,6 +11,7 @@
.memberRow.hasChildren > .memberLabelCell > .memberLabel,
.hasHeaders .netHrefLabel,
.objectBox-stackFrame.hasTwisty,
+.objectBox-functionCall.hasTwisty,
.netPageRow > .netCol > .netPageTitle,
.cssComputedHeader > .twisty,
.breakpointHeader > .twisty,
@@ -32,6 +33,7 @@
.netRow.opened > .netCol > .netHrefLabel,
.netPageRow.opened > .netCol > .netPageTitle,
.objectBox-stackFrame.hasTwisty.opened,
+.objectBox-functionCall.hasTwisty.opened,
.computedStylesGroup.opened > .cssComputedHeader > .twisty,
.breakpointBlock.opened > .breakpointHeader > .twisty,
.computedStyle.hasSelectors.opened > .stylePropName,
Please sign in to comment.
Something went wrong with that request. Please try again.