Permalink
Browse files

Breapoint persistence: storing

  • Loading branch information...
1 parent 9ac8218 commit ada19c9cf6e25f02892ccd890c956aa92f78b3e3 @janodvarko janodvarko committed Sep 20, 2012
@@ -114,4 +114,4 @@ ConditionEditor.prototype = domplate(Firebug.JSEditor.prototype,
return ConditionEditor;
// ********************************************************************************************* //
-});
+}});
@@ -45,13 +45,17 @@ BreakpointPanel.prototype = Obj.extend(Firebug.Panel,
this.groupOpened = [];
Firebug.Panel.initialize.apply(this, arguments);
+
+ BreakpointStore.addListener(this);
},
destroy: function(state)
{
state.groupOpened = this.groupOpened;
Firebug.Panel.destroy.apply(this, arguments);
+
+ BreakpointStore.removeListener(this);
},
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@@ -383,6 +387,19 @@ BreakpointPanel.prototype = Obj.extend(Firebug.Panel,
{
FBTrace.sysout("breakpointPanel.onStartDebugging;");
},
+
+ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+ // BreakpointStore Listener
+
+ onBreakpointAdded: function(bp)
+ {
+ this.refresh();
+ },
+
+ onBreakpointRemoved: function(bp)
+ {
+ this.refresh();
+ },
});
// ********************************************************************************************* //
@@ -88,7 +88,7 @@ Firebug.JSD2.Breakpoint.BreakpointRep = domplate(Firebug.Rep,
"aria-checked": "$bp.checked", _repObject: "$bp", onclick: "$onClick"},
DIV({"class": "breakpointBlockHead"},
INPUT({"class": "breakpointCheckbox", type: "checkbox",
- _checked: "$bp.checked", tabindex : '-1'}),
+ _checked: "$bp|isEnabled", tabindex : '-1'}),
SPAN({"class": "breakpointName"}, "$bp.name"),
TAG(FirebugReps.SourceLink.tag, {object: "$bp|getSourceLink"}),
IMG({"class": "closeButton", src: "blank.gif"})
@@ -121,9 +121,14 @@ Firebug.JSD2.Breakpoint.BreakpointRep = domplate(Firebug.Rep,
FBS.disableBreakpoint(href, lineNumber);
},
+ isEnabled: function(bp)
+ {
+ return !bp.disabled;
+ },
+
isDisabled: function(bp)
{
- return !bp.checked;
+ return bp.disabled;
},
getContextMenuItems: function(breakpoint, target)
@@ -67,19 +67,118 @@ var BreakpointStore = Obj.extend(Firebug.Module,
var url = urls[i];
var bps = this.storage.getItem(url);
- // Do not restore "Run unit this line" breakpoints. This should solve complaints
+ // Do not restore "Run until this line" breakpoints. This should solve complaints
// about Firebug breaking in the source even if there are no breakpoints in
// Firebug UI.
- if (bps.type == BP_UNTIL)
- continue;
+ bps = bps.filter(function(element, index, array)
+ {
+ return (element.type != BP_UNTIL);
+ });
this.breakpoints[url] = bps;
}
},
- save: function()
+ save: function(url)
+ {
+ var bps = this.getBreakpoints(url);
+ if (!bps)
+ return;
+
+ var cleanBPs = [];
+ for (var i=0; i<bps.length; i++)
+ {
+ var bp = bps[i];
+
+ if (bp.type == BP_UNTIL)
+ continue;
+
+ var cleanBP = {};
+ for (var p in bp)
+ cleanBP[p] = bp[p];
+
+ delete cleanBP.params;
+
+ cleanBPs.push(cleanBP);
+ }
+
+ this.storage.setItem(url, cleanBPs);
+
+ FBTrace.sysout("breakpointStore.save;", this.storage);
+ },
+
+ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+ addBreakpoint: function(url, lineNo, params)
+ {
+ if (this.findBreakpoint(url, lineNo))
+ {
+ if (FBTrace.DBG_ERRORS)
+ FBTrace.sysout("breakpointStore.addBreakpoint; ERROR There is alread a bp");
+ return;
+ }
+
+ if (!this.breakpoints[url])
+ this.breakpoints[url] = [];
+
+ var bp = {
+ href: url,
+ lineNo: lineNo,
+ type: BP_NORMAL,
+ disabled: false,
+ hitCount: -1,
+ hit: 0,
+ params: params,
+ };
+
+ this.breakpoints[url].push(bp);
+
+ this.save(url);
+
+ this.dispatch("onBreakpointAdded", [bp]);
+ },
+
+ removeBreakpoint: function(url, lineNo)
{
-
+ var bps = this.getBreakpoints(url);
+ if (!bps)
+ return null;
+
+ var removedBp = null;
+ for (var i=0; i<bps.length; i++)
+ {
+ var bp = bps[i];
+ if (bp.lineNumber === lineNo)
+ {
+ bps.splice(i, 1);
+ removedBp = bp;
+ break;
+ }
+ }
+
+ if (!removedBp)
+ return;
+
+ this.dispatch("onBreakpointRemoved", [removedBp]);
+ this.save(url);
+
+ return removedBp;
+ },
+
+ findBreakpoint: function(url, lineNo)
+ {
+ var bps = this.getBreakpoints(url);
+ if (!bps)
+ return null;
+
+ for (var i=0; i<bps.length; i++)
+ {
+ var bp = bps[i];
+ if (bp.lineNumber === lineNo)
+ return bp;
+ }
+
+ return null;
},
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@@ -4,6 +4,7 @@ define([
"firebug/lib/trace",
"firebug/debugger/debugger",
"firebug/debugger/scriptPanel",
+ "firebug/debugger/breakpointStore",
"firebug/debugger/breakpointModule",
"firebug/debugger/breakpointPanel",
"firebug/debugger/debuggerTool",

0 comments on commit ada19c9

Please sign in to comment.