bug 99601, add filter support to js/jsd, r=jband sr=brendan

Use the new filtering api to allow users to safely debug with initAtStartup enabled.  Also adds highlighting to source view, saves stack view state, fixes selection problems in the outliners, cleans up some strict mode issues, and refactors menu and script tags out of venkman.xul
This commit is contained in:
rginda%netscape.com 2001-10-30 14:27:10 +00:00
Родитель 04f54fb01d
Коммит 88cf3b11f7
19 изменённых файлов: 1346 добавлений и 373 удалений

Просмотреть файл

@ -133,6 +133,27 @@ function bov_scrollto (line, align)
} }
} }
BasicOView.prototype.__defineGetter__("selectedIndex", bov_getsel);
function bov_getsel()
{
if (this.outliner.selection.getRangeCount() < 1)
return -1;
var min = new Object();
this.outliner.selection.getRangeAt(0, min, {});
return min.value;
}
BasicOView.prototype.__defineSetter__("selectedIndex", bov_setsel);
function bov_setsel(i)
{
if (i == -1)
this.outliner.selection.clearSelection();
else
this.outliner.selection.timedSelect (i, 500);
return i;
}
/* /*
* functions the outliner will call to retrieve the list state (nsIOutlinerView.) * functions the outliner will call to retrieve the list state (nsIOutlinerView.)
*/ */
@ -301,6 +322,8 @@ function TreeOViewRecord(share)
* inserted into a live tree */ * inserted into a live tree */
} }
TreeOViewRecord.prototype.isContainerOpen = false;
/* /*
* walk the parent tree to find our tree container. return null if there is * walk the parent tree to find our tree container. return null if there is
* none * none
@ -640,7 +663,7 @@ function tovr_open ()
this.resort(true); this.resort(true);
this.visualFootprint += delta; this.visualFootprint += delta;
if ("parentRecord" in this) if ("parentRecord" in this)
this.parentRecord.onVisualFootprintChanged(this.calculateVisualRow(), this.parentRecord.onVisualFootprintChanged(this.calculateVisualRow() + 1,
delta); delta);
} }
@ -658,7 +681,7 @@ function tovr_close ()
var delta = 1 - this.visualFootprint; var delta = 1 - this.visualFootprint;
this.visualFootprint += delta; this.visualFootprint += delta;
if (this.parentRecord) if (this.parentRecord)
this.parentRecord.onVisualFootprintChanged(this.calculateVisualRow(), this.parentRecord.onVisualFootprintChanged(this.calculateVisualRow() + 1,
delta); delta);
if (this.onPostClose) if (this.onPostClose)
this.onPostClose(); this.onPostClose();
@ -869,6 +892,11 @@ function torr_calcrow ()
TORootRecord.prototype.resort = TORootRecord.prototype.resort =
function torr_resort () function torr_resort ()
{ {
if ("_treeView" in this && this._treeView.frozen) {
this._treeView.needsResort = true;
return;
}
if (!("childData" in this) || this.childData.length < 1 || if (!("childData" in this) || this.childData.length < 1 ||
(this.childData[0].sortCompare == tovr_sortcmp && (this.childData[0].sortCompare == tovr_sortcmp &&
!("sortColumn" in this._share) || this._share.sortDirection == 0)) !("sortColumn" in this._share) || this._share.sortDirection == 0))
@ -938,14 +966,26 @@ function torr_find (targetRow)
TORootRecord.prototype.onVisualFootprintChanged = TORootRecord.prototype.onVisualFootprintChanged =
function torr_vfpchange (start, amount) function torr_vfpchange (start, amount)
{ {
this.invalidateCache(); if (!this._treeView.frozen)
this.visualFootprint += amount;
if ("_treeView" in this && "outliner" in this._treeView)
{ {
if (amount != 0) this.invalidateCache();
this._treeView.outliner.rowCountChanged (start, amount); this.visualFootprint += amount;
if ("_treeView" in this && "outliner" in this._treeView)
{
if (amount != 0)
this._treeView.outliner.rowCountChanged (start, amount);
else
this._treeView.outliner.invalidateRow (start);
}
}
else
{
this._treeView.changeAmount += amount;
if (this._treeView.changeStart)
this._treeView.changeStart =
Math.min (start, this._treeView.changeStart);
else else
this._treeView.outliner.invalidateRow (start); this._treeView.changeStart = start;
} }
} }
@ -958,13 +998,59 @@ function TreeOView(share)
{ {
this.childData = new TORootRecord(this, share); this.childData = new TORootRecord(this, share);
this.childData.invalidateCache(); this.childData.invalidateCache();
this.frozen = 0;
} }
/* functions *you* should call to initialize and maintain the outliner state */ /* functions *you* should call to initialize and maintain the outliner state */
/*
* Changes to the tree contents will not cause the outliner to be invalidated
* until thaw() is called. All changes will be pooled into a single invalidate
* call.
*
* Freeze/thaws are nestable, the tree will not update until the number of
* thaw() calls matches the number of freeze() calls.
*/
TreeOView.prototype.freeze =
function tov_freeze ()
{
if (++this.frozen == 1)
{
this.changeStart = 0;
this.changeAmount = 0;
}
}
/*
* Reflect any changes to the tee content since the last freeze.
*/
TreeOView.prototype.thaw =
function tov_thaw ()
{
if (this.frozen == 0)
{
ASSERT (0, "not frozen");
return;
}
if (--this.frozen == 0)
{
this.childData.onVisualFootprintChanged(this.changeStart,
this.changeAmount);
}
if ("needsResort" in this) {
this.childData.resort();
delete this.needsResort;
}
delete this.changeStart;
delete this.changeAmount;
}
/* scroll the line specified by |line| to the center of the outliner */ /* scroll the line specified by |line| to the center of the outliner */
TreeOView.prototype.centerLine = TreeOView.prototype.centerLine =
function bov_ctrln (line) function tov_ctrln (line)
{ {
var first = this.outliner.getFirstVisibleRow(); var first = this.outliner.getFirstVisibleRow();
var last = this.outliner.getLastVisibleRow(); var last = this.outliner.getLastVisibleRow();
@ -1009,7 +1095,9 @@ function tov_getsel()
TreeOView.prototype.__defineSetter__("selectedIndex", tov_setsel); TreeOView.prototype.__defineSetter__("selectedIndex", tov_setsel);
function tov_setsel(i) function tov_setsel(i)
{ {
this.outliner.selection.timedSelect (i, 500); this.outliner.selection.clearSelection();
if (i != -1)
this.outliner.selection.timedSelect (i, 500);
return i; return i;
} }

Просмотреть файл

@ -133,6 +133,27 @@ function bov_scrollto (line, align)
} }
} }
BasicOView.prototype.__defineGetter__("selectedIndex", bov_getsel);
function bov_getsel()
{
if (this.outliner.selection.getRangeCount() < 1)
return -1;
var min = new Object();
this.outliner.selection.getRangeAt(0, min, {});
return min.value;
}
BasicOView.prototype.__defineSetter__("selectedIndex", bov_setsel);
function bov_setsel(i)
{
if (i == -1)
this.outliner.selection.clearSelection();
else
this.outliner.selection.timedSelect (i, 500);
return i;
}
/* /*
* functions the outliner will call to retrieve the list state (nsIOutlinerView.) * functions the outliner will call to retrieve the list state (nsIOutlinerView.)
*/ */
@ -301,6 +322,8 @@ function TreeOViewRecord(share)
* inserted into a live tree */ * inserted into a live tree */
} }
TreeOViewRecord.prototype.isContainerOpen = false;
/* /*
* walk the parent tree to find our tree container. return null if there is * walk the parent tree to find our tree container. return null if there is
* none * none
@ -640,7 +663,7 @@ function tovr_open ()
this.resort(true); this.resort(true);
this.visualFootprint += delta; this.visualFootprint += delta;
if ("parentRecord" in this) if ("parentRecord" in this)
this.parentRecord.onVisualFootprintChanged(this.calculateVisualRow(), this.parentRecord.onVisualFootprintChanged(this.calculateVisualRow() + 1,
delta); delta);
} }
@ -658,7 +681,7 @@ function tovr_close ()
var delta = 1 - this.visualFootprint; var delta = 1 - this.visualFootprint;
this.visualFootprint += delta; this.visualFootprint += delta;
if (this.parentRecord) if (this.parentRecord)
this.parentRecord.onVisualFootprintChanged(this.calculateVisualRow(), this.parentRecord.onVisualFootprintChanged(this.calculateVisualRow() + 1,
delta); delta);
if (this.onPostClose) if (this.onPostClose)
this.onPostClose(); this.onPostClose();
@ -869,6 +892,11 @@ function torr_calcrow ()
TORootRecord.prototype.resort = TORootRecord.prototype.resort =
function torr_resort () function torr_resort ()
{ {
if ("_treeView" in this && this._treeView.frozen) {
this._treeView.needsResort = true;
return;
}
if (!("childData" in this) || this.childData.length < 1 || if (!("childData" in this) || this.childData.length < 1 ||
(this.childData[0].sortCompare == tovr_sortcmp && (this.childData[0].sortCompare == tovr_sortcmp &&
!("sortColumn" in this._share) || this._share.sortDirection == 0)) !("sortColumn" in this._share) || this._share.sortDirection == 0))
@ -938,14 +966,26 @@ function torr_find (targetRow)
TORootRecord.prototype.onVisualFootprintChanged = TORootRecord.prototype.onVisualFootprintChanged =
function torr_vfpchange (start, amount) function torr_vfpchange (start, amount)
{ {
this.invalidateCache(); if (!this._treeView.frozen)
this.visualFootprint += amount;
if ("_treeView" in this && "outliner" in this._treeView)
{ {
if (amount != 0) this.invalidateCache();
this._treeView.outliner.rowCountChanged (start, amount); this.visualFootprint += amount;
if ("_treeView" in this && "outliner" in this._treeView)
{
if (amount != 0)
this._treeView.outliner.rowCountChanged (start, amount);
else
this._treeView.outliner.invalidateRow (start);
}
}
else
{
this._treeView.changeAmount += amount;
if (this._treeView.changeStart)
this._treeView.changeStart =
Math.min (start, this._treeView.changeStart);
else else
this._treeView.outliner.invalidateRow (start); this._treeView.changeStart = start;
} }
} }
@ -958,13 +998,59 @@ function TreeOView(share)
{ {
this.childData = new TORootRecord(this, share); this.childData = new TORootRecord(this, share);
this.childData.invalidateCache(); this.childData.invalidateCache();
this.frozen = 0;
} }
/* functions *you* should call to initialize and maintain the outliner state */ /* functions *you* should call to initialize and maintain the outliner state */
/*
* Changes to the tree contents will not cause the outliner to be invalidated
* until thaw() is called. All changes will be pooled into a single invalidate
* call.
*
* Freeze/thaws are nestable, the tree will not update until the number of
* thaw() calls matches the number of freeze() calls.
*/
TreeOView.prototype.freeze =
function tov_freeze ()
{
if (++this.frozen == 1)
{
this.changeStart = 0;
this.changeAmount = 0;
}
}
/*
* Reflect any changes to the tee content since the last freeze.
*/
TreeOView.prototype.thaw =
function tov_thaw ()
{
if (this.frozen == 0)
{
ASSERT (0, "not frozen");
return;
}
if (--this.frozen == 0)
{
this.childData.onVisualFootprintChanged(this.changeStart,
this.changeAmount);
}
if ("needsResort" in this) {
this.childData.resort();
delete this.needsResort;
}
delete this.changeStart;
delete this.changeAmount;
}
/* scroll the line specified by |line| to the center of the outliner */ /* scroll the line specified by |line| to the center of the outliner */
TreeOView.prototype.centerLine = TreeOView.prototype.centerLine =
function bov_ctrln (line) function tov_ctrln (line)
{ {
var first = this.outliner.getFirstVisibleRow(); var first = this.outliner.getFirstVisibleRow();
var last = this.outliner.getLastVisibleRow(); var last = this.outliner.getLastVisibleRow();
@ -1009,7 +1095,9 @@ function tov_getsel()
TreeOView.prototype.__defineSetter__("selectedIndex", tov_setsel); TreeOView.prototype.__defineSetter__("selectedIndex", tov_setsel);
function tov_setsel(i) function tov_setsel(i)
{ {
this.outliner.selection.timedSelect (i, 500); this.outliner.selection.clearSelection();
if (i != -1)
this.outliner.selection.timedSelect (i, 500);
return i; return i;
} }

Просмотреть файл

@ -46,6 +46,8 @@ const FTYPE_STD = 0;
const FTYPE_SUMMARY = 1; const FTYPE_SUMMARY = 1;
const FTYPE_ARRAY = 2; const FTYPE_ARRAY = 2;
const FILTER_SYSTEM = 0x100; /* system filter, do not show in UI */
var $ = new Array(); /* array to store results from evals in debug frames */ var $ = new Array(); /* array to store results from evals in debug frames */
console._scriptHook = { console._scriptHook = {
@ -56,14 +58,14 @@ console._scriptHook = {
realizeScript (script); realizeScript (script);
} }
}, },
onScriptDestroyed: function scripthook (script) { onScriptDestroyed: function scripthook (script) {
if (script.fileName && if (script.fileName &&
script.fileName != MSG_VAL_CONSOLE) script.fileName != MSG_VAL_CONSOLE)
{ {
unrealizeScript (script); unrealizeScript (script);
} }
} }
}; };
console._executionHook = { console._executionHook = {
@ -103,6 +105,8 @@ console._errorHook = {
function initDebugger() function initDebugger()
{ {
dd ("initDebugger {");
console._continueCodeStack = new Array(); /* top of stack is the default */ console._continueCodeStack = new Array(); /* top of stack is the default */
/* return code for the most */ /* return code for the most */
/* recent debugTrap(). */ /* recent debugTrap(). */
@ -119,25 +123,53 @@ function initDebugger()
console.jsds.debuggerHook = console._executionHook; console.jsds.debuggerHook = console._executionHook;
console.jsds.errorHook = console._errorHook; console.jsds.errorHook = console._errorHook;
console.jsds.scriptHook = console._scriptHook; console.jsds.scriptHook = console._scriptHook;
var venkmanFilter1 = { /* glob based filter goes first, because it's the */
glob: this, /* easiest to match. */
flags: FILTER_SYSTEM | jsdIFilter.FLAG_ENABLED,
urlPattern: null,
startLine: 0,
endLine: 0
};
var venkmanFilter2 = { /* url based filter for XPCOM callbacks that may */
glob: null, /* not happen under our glob. */
flags: FILTER_SYSTEM | jsdIFilter.FLAG_ENABLED,
urlPattern: "chrome://venkman/*",
startLine: 0,
endLine: 0
};
console.jsds.appendFilter (venkmanFilter1);
console.jsds.appendFilter (venkmanFilter2);
setThrowMode(TMODE_IGNORE); setThrowMode(TMODE_IGNORE);
var enumer = { var enumer = {
enumerateScript: function _es (script) { enumerateScript: function _es (script) {
realizeScript(script); realizeScript(script);
return true;
} }
}; };
console.scriptsView.freeze();
console.jsds.enumerateScripts(enumer); console.jsds.enumerateScripts(enumer);
console.scriptsView.thaw();
dd ("} initDebugger");
} }
function detachDebugger() function detachDebugger()
{ {
console.jsds.topLevelHook = null; console.jsds.topLevelHook = null;
console.jsds.functionHook = null; console.jsds.functionHook = null;
console.jsds.off(); console.jsds.breakpointHook = null;
console.jsds.debuggerHook = null;
console.jsds.errorHook = null;
console.jsds.scriptHook = null;
console.jsds.interruptHook = null;
console.jsds.clearAllBreakpoints();
console.jsds.clearFilters();
if (!console.jsds.initAtStartup)
console.jsds.off();
if (console._stopLevel > 0) if (console._stopLevel > 0)
{ {
@ -165,7 +197,7 @@ function realizeScript(script)
} }
var scriptRec = new ScriptRecord (script); var scriptRec = new ScriptRecord (script);
container.appendChild (scriptRec); container.appendScriptRecord (scriptRec);
/* check to see if this script contains a breakpoint */ /* check to see if this script contains a breakpoint */
for (var i = 0; i < console.breakpoints.childData.length; ++i) for (var i = 0; i < console.breakpoints.childData.length; ++i)
@ -363,6 +395,8 @@ function debugTrap (frame, type, rv)
console.jsds.exitNestedEventLoop(); console.jsds.exitNestedEventLoop();
} }
console.onDebugContinue();
if (tn) if (tn)
display (getMsg(MSN_CONT, tn), MT_CONT); display (getMsg(MSN_CONT, tn), MT_CONT);
@ -373,8 +407,6 @@ function debugTrap (frame, type, rv)
delete console.frames; delete console.frames;
delete console.trapType; delete console.trapType;
console.onDebugContinue();
return console._continueCodeStack.pop(); return console._continueCodeStack.pop();
} }
@ -555,8 +587,6 @@ function formatValue (v, formatType)
case jsdIValue.TYPE_STRING: case jsdIValue.TYPE_STRING:
type = MSG_TYPE_STRING; type = MSG_TYPE_STRING;
value = v.stringValue.quote(); value = v.stringValue.quote();
if (value.length > MAX_STR_LEN)
value = getMsg(MSN_FMT_LONGSTR, value.length);
break; break;
case jsdIValue.TYPE_VOID: case jsdIValue.TYPE_VOID:
type = MSG_TYPE_VOID; type = MSG_TYPE_VOID;
@ -801,7 +831,7 @@ function setBreakpoint (fileName, line)
for (var i = 0; i < ary.length; ++i) for (var i = 0; i < ary.length; ++i)
{ {
if (ary[i].containsLine(line) && ary[i].isLineExecutable(line)) if (ary[i].containsLine(line) && ary[i].script.isLineExecutable(line))
{ {
found = true; found = true;
bpr.addScriptRecord(ary[i]); bpr.addScriptRecord(ary[i]);

Просмотреть файл

@ -0,0 +1,123 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is The JavaScript Debugger
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation
* Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation.
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the MPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the MPL or the GPL.
*
* Contributor(s):
* Robert Ginda, <rginda@netscape.com>, original author
*
*/
function startupTests()
{
if (0)
{
var w = openDialog("chrome://venkman/content/tests/tree.xul", "", "");
var testsFilter = {
glob: w,
flags: jsdIFilter.FLAG_ENABLED | jsdIFilter.FLAG_PASS,
urlPattern: null,
startLine: 0,
endLine: 0
};
/* make sure this filter goes at the top, so the system
* "chrome://venkman/ *" filter doesn't get to it first.
*/
console.jsds.insertFilter (testsFilter, null);
}
}
function dumpFilters()
{
var i = 0;
var enumer = {
enumerateFilter: function enum_f (filter) {
dd ((i++) + ": " + filter.glob +
" '" + filter.urlPattern + "'");
}
};
console.jsds.enumerateFilters (enumer);
}
function testFilters ()
{
var filter1 = {
glob: null,
flags: jsdIFilter.FLAG_ENABLED,
urlPattern: "1",
startLine: 0,
endLine: 0
};
var filter2 = {
glob: null,
flags: jsdIFilter.FLAG_ENABLED,
urlPattern: "*2",
startLine: 0,
endLine: 0
};
var filter3 = {
glob: null,
flags: jsdIFilter.FLAG_ENABLED,
urlPattern: "3*",
startLine: 0,
endLine: 0
};
var filter4 = {
glob: null,
flags: jsdIFilter.FLAG_ENABLED,
urlPattern: "*4*",
startLine: 0,
endLine: 0
};
console.jsds.clearFilters();
dd ("append f3 into an empty list.");
console.jsds.appendFilter (filter3);
console.jsds.GC();
dd("insert f1 at the top");
console.jsds.insertFilter (filter1, null);
console.jsds.GC();
dd("insert f2 after f1");
console.jsds.insertFilter (filter2, filter1);
console.jsds.GC();
dd("swap f4 in, f3 out");
console.jsds.swapFilters (filter3, filter4);
console.jsds.GC();
dd("append f3");
console.jsds.appendFilter (filter3);
console.jsds.GC();
dd("swap f4 and f3");
console.jsds.swapFilters (filter3, filter4);
console.jsds.GC();
dumpFilters();
}

Просмотреть файл

@ -110,7 +110,10 @@ function con_ondt ()
{ {
var frame = setCurrentFrameByIndex(0); var frame = setCurrentFrameByIndex(0);
var type = console.trapType; var type = console.trapType;
var frameRec = console.stackView.stack.childData[0];
console.pushStatus (getMsg(MSN_STATUS_STOPPED, [frameRec.functionName,
frameRec.location]));
if (type != jsdIExecutionHook.TYPE_INTERRUPTED || if (type != jsdIExecutionHook.TYPE_INTERRUPTED ||
console._lastStackDepth != console.frames.length) console._lastStackDepth != console.frames.length)
{ {
@ -121,7 +124,8 @@ function con_ondt ()
(type == jsdIExecutionHook.TYPE_INTERRUPTED) ? 0 : 2); (type == jsdIExecutionHook.TYPE_INTERRUPTED) ? 0 : 2);
console._lastStackDepth = console.frames.length; console._lastStackDepth = console.frames.length;
console.stackView.restoreState();
enableDebugCommands() enableDebugCommands()
} }
@ -129,6 +133,7 @@ function con_ondt ()
console.onDebugContinue = console.onDebugContinue =
function con_ondc () function con_ondc ()
{ {
console.popStatus();
console.sourceView.outliner.invalidate(); console.sourceView.outliner.invalidate();
} }
@ -620,7 +625,14 @@ function con_slkeypress (e)
console.onProjectSelect = console.onProjectSelect =
function con_projsel (e) function con_projsel (e)
{ {
if (console.projectView.selectedIndex == -1)
return;
console.scriptsView.selectedIndex = -1;
console.stackView.selectedIndex = -1;
console.sourceView.selectedIndex = -1;
var rowIndex = console.projectView.selectedIndex; var rowIndex = console.projectView.selectedIndex;
if (rowIndex == -1 || rowIndex > console.projectView.rowCount) if (rowIndex == -1 || rowIndex > console.projectView.rowCount)
return; return;
@ -660,6 +672,13 @@ function con_projsel (e)
console.onStackSelect = console.onStackSelect =
function con_stacksel (e) function con_stacksel (e)
{ {
if (console.stackView.selectedIndex == -1)
return;
console.scriptsView.selectedIndex = -1;
console.projectView.selectedIndex = -1;
console.sourceView.selectedIndex = -1;
var rowIndex = console.stackView.selectedIndex; var rowIndex = console.stackView.selectedIndex;
if (rowIndex == -1 || rowIndex > console.stackView.rowCount) if (rowIndex == -1 || rowIndex > console.stackView.rowCount)
return; return;
@ -690,36 +709,62 @@ function con_stacksel (e)
} }
sourceView.displaySource(source); sourceView.displaySource(source);
sourceView.softScrollTo(row.frame.line); sourceView.softScrollTo(row.frame.line);
var script = row.frame.script;
console.highlightFile = script.fileName;
console.highlightStart = script.baseLineNumber - 1;
console.highlightEnd = script.baseLineNumber - 1 + script.lineExtent;
} }
else if (row instanceof ValueRecord && row.jsType == jsdIValue.TYPE_OBJECT) else if (row instanceof ValueRecord && row.jsType == jsdIValue.TYPE_OBJECT)
{ {
if (row.parentRecord instanceof FrameRecord &&
row == row.parentRecord.scopeRec)
return;
var objVal = row.value.objectValue; var objVal = row.value.objectValue;
if (!objVal.creatorURL) var creatorURL = objVal.creatorURL;
if (!creatorURL)
{ {
dd ("object with no creator"); dd ("object with no creator");
return; return;
} }
if (!(objVal.creatorURL in console.scripts)) if (!(creatorURL in console.scripts))
{ {
dd ("object from unknown source"); dd ("object from unknown source ``" + creatorURL + "''");
return; return;
} }
sourceView.displaySource(console.scripts[objVal.creatorURL]); sourceView.displaySource(console.scripts[creatorURL]);
sourceView.scrollTo (objVal.creatorLine); console.highlightFile = creatorURL;
if (sourceView.childData && sourceView.childData.isLoaded) var creatorLine = objVal.creatorLine;
{ sourceView.scrollTo (creatorLine);
sourceView.outliner.selection.timedSelect (objVal.creatorLine - console.highlightStart = console.highlightEnd = creatorLine - 1;
1, 500); console.sourceView.outliner.invalidate();
}
else
{
sourceView.pendingSelect = objVal.creatorLine - 1;
}
} }
} }
console.onScriptSelect =
function con_scptsel (e)
{
if (console.scriptsView.selectedIndex == -1)
return;
console.projectView.selectedIndex = -1;
console.stackView.selectedIndex = -1;
console.sourceView.selectedIndex = -1;
var rowIndex = console.scriptsView.selectedIndex;
if (rowIndex == -1 || rowIndex > console.scriptsView.rowCount)
return;
var row =
console.scriptsView.childData.locateChildByVisualRow(rowIndex);
ASSERT (row, "bogus row");
row.makeCurrent();
}
console.onScriptClick = console.onScriptClick =
function con_scptclick (e) function con_scptclick (e)
{ {
@ -754,19 +799,26 @@ function con_scptclick (e)
} }
} }
console.onScriptSelect = console.onSourceSelect =
function con_scptsel (e) function con_sourcesel (e)
{ {
var rowIndex = console.scriptsView.selectedIndex; if (console.sourceView.selectedIndex == -1)
if (rowIndex == -1 || rowIndex > console.scriptsView.rowCount)
return; return;
var row =
console.scriptsView.childData.locateChildByVisualRow(rowIndex);
ASSERT (row, "bogus row");
row.makeCurrent(); console.scriptsView.selectedIndex = -1;
console.stackView.selectedIndex = -1;
console.projectView.selectedIndex = -1;
if (console.sourceView.outliner.selection.getRangeCount() > 1)
{
var row = new Object();
var colID = new Object();
var childElt = new Object();
var outliner = console.sourceView.outliner;
outliner.getCellAt(e.clientX, e.clientY, row, colID, childElt);
console.sourceView.selectedIndex = row.value;
}
} }
console.onSourceClick = console.onSourceClick =

Просмотреть файл

@ -0,0 +1,253 @@
<?xml version="1.0"?>
<!--
-
- The contents of this file are subject to the Mozilla Public License
- Version 1.1 (the "License"); you may not use this file except in
- compliance with the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
-
- Software distributed under the License is distributed on an "AS IS" basis,
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- for the specific language governing rights and limitations under the
- License.
-
- The Original Code is The JavaScript Debugger
-
- The Initial Developer of the Original Code is
- Netscape Communications Corporation
- Portions created by Netscape are
- Copyright (C) 1998 Netscape Communications Corporation.
- All Rights Reserved.
-
- Alternatively, the contents of this file may be used under the
- terms of the GNU Public License (the "GPL"), in which case the
- provisions of the GPL are applicable instead of those above.
- If you wish to allow use of your version of this file only
- under the terms of the GPL and not to allow others to use your
- version of this file under the MPL, indicate your decision by
- deleting the provisions above and replace them with the notice
- and other provisions required by the GPL. If you do not delete
- the provisions above, a recipient may use your version of this
- file under either the MPL or the GPL.
-
- Contributor(s):
- Robert Ginda, <rginda@netscape.com>, original author
-
-->
<!DOCTYPE window SYSTEM "chrome://venkman/locale/venkman.dtd" >
<?xul-overlay href="chrome://communicator/content/tasksOverlay.xul"?>
<overlay id="venkman-menu-overlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<overlaytarget id="menu-overlay-target">
<!-- Commands -->
<commandset id="venkmanCommands">
<!-- File commands -->
<command id="cmd_close" oncommand="window.close();"/>
<command id="cmd_quit"/>
<!-- Edit Menu -->
<commandset id="selectEditMenuItems"/>
<commandset id="globalEditMenuItems"/>
<commandset id="undoEditMenuItems"/>
<commandset id="clipboardEditMenuItems"/>
<command id="cmd_undo"/>
<command id="cmd_redo"/>
<command id="cmd_cut"/>
<command id="cmd_copy"/>
<command id="cmd_paste"/>
<command id="cmd_delete"/>
<command id="cmd_selectAll"/>
<!-- Debug commands -->
<command id="cmd_reload_ui"
oncommand="if (DEBUG) window.location.href = window.location.href;"/>
<command id="cmd_focus" oncommand="console._slInputElement.focus();"/>
<command id="cmd_tmode_cycle" oncommand="cycleThrowMode();"/>
<command id="cmd_tmode_ignore" oncommand="setThrowMode(TMODE_IGNORE);"/>
<command id="cmd_tmode_trace" oncommand="setThrowMode(TMODE_TRACE);"/>
<command id="cmd_tmode_break" oncommand="setThrowMode(TMODE_BREAK);"/>
<command id="cmd_stop" oncommand="console.doCommandToggleStop();"/>
<command id="cmd_reload" oncommand="console.doCommandReload();"/>
<!-- Tasks commands, from overlay -->
<commandset id="tasksCommands"/>
</commandset>
<commandset id="venkmanStackCommands">
<!-- commands in this set will only be enabled when we have a stack -->
<command id="cmd_step_over" oncommand="console.doCommandNext();"/>
<command id="cmd_step_in" oncommand="console.doCommandStep();"/>
<command id="cmd_step_out" oncommand="console.doCommandStepOut();"/>
<command id="cmd_cont" oncommand="console.doCommandCont();"/>
</commandset>
<!-- Keys -->
<keyset id="venkmanKeys">
<!-- Hidden keys -->
<key id="key_reload_ui" observes="cmd_reload_ui"
modifiers="accel alt" key="R"/>
<!-- File keys -->
<key id="key_close"/>
<!-- Edit keys -->
<key id="key_undo"/>
<key id="key_redo"/>
<key id="key_cut"/>
<key id="key_copy"/>
<key id="key_paste"/>
<key id="key_delete"/>
<key id="key_selectAll"/>
<!-- View keys -->
<key id="key_reload" observes="cmd_reload"
modifiers="accel" key="R"/>
<!-- Debug keys -->
<key id="key_focus" observes="cmd_focus" keycode="VK_TAB"/>
<key id="key_stop" observes="cmd_stop" keycode="VK_F4"/>
<key id="key_cont" observes="cmd_cont" keycode="VK_F5"/>
<key id="key_step_over" observes="cmd_step_over" keycode="VK_F10"/>
<key id="key_step_in" observes="cmd_step_in" keycode="VK_F11"/>
<key id="key_step_out" observes="cmd_step_out" modifiers="shift"
keycode="VK_F11"/>
<key id="key_tmode_cycle" observes="cmd_tmode_cycle"
modifiers="accel" key="T"/>
<!-- Tasks keys, from overlay -->
<keyset id="tasksKeys"/>
</keyset>
<!-- Tooltips -->
<popupset id="aTooltipSet"/>
<!-- Main menu bar -->
<toolbox flex="1">
<menubar id="main-menubar" persist="collapsed" grippytooltip="aTooltip"
grippytooltiptext="&MenuBar.tooltip;">
<!-- File menu -->
<menu id="menu_File">
<menupopup id="menu_FilePopup">
<menuitem id="menu_close"/>
</menupopup>
</menu>
<!-- Edit menu -->
<menu id="menu_Edit">
<menupopup id="menu_Edit_Popup">
<menuitem id="menu_undo"/>
<menuitem id="menu_redo"/>
<menuseparator/>
<menuitem id="menu_cut"/>
<menuitem id="menu_copy"/>
<menuitem id="menu_paste"/>
<menuitem id="menu_delete"/>
<menuseparator/>
<menuitem id="menu_selectAll"/>
<menuseparator/>
<menuitem id="menu_preferences"
oncommand="goPreferences('navigator.xul', 'chrome://communicator/content/pref/pref-navigator.xul', 'navigator');"/>
</menupopup>
</menu>
<!-- View menu -->
<menu id="menu_View">
<menupopup id="menu_ViewPopup">
<menuitem id="menu_Reload" key="key_reload" observes="cmd_reload"
label="&Reload.label;" accesskey="&Reload.aKey;"/>
</menupopup>
</menu>
<!-- Debug menu -->
<menu id="menu_Debug" label="&Debug.label;" accesskey="&Debug.aKey;">
<menupopup id="menu_DebugPopup">
<menuitem id="menu_Stop" key="key_stop"
observes="cmd_stop"
label="&Stop.label;" accesskey="&Stop.aKey;"/>
<menuitem id="menu_Cont" key="key_cont"
observes="cmd_cont"
label="&Cont.label;" accesskey="&Cont.aKey;"/>
<menuitem id="menu_StepOver" key="key_step_over"
observes="cmd_step_over"
label="&StepOver.label;" accesskey="&StepOver.aKey;"/>
<menuitem id="menu_StepInto" key="key_step_in"
observes="cmd_step_in"
label="&StepIn.label;" accesskey="&StepIn.aKey;"/>
<menuitem id="menu_StepOut" key="key_step_out"
observes="cmd_step_out"
label="&StepOut.label;" accesskey="&StepOut.aKey;"/>
<menuseparator/>
<menu id="menu_ThrowMode" label="&TModeMenu.label;"
accesskey="&TModeMenu.aKey;">
<menupopup onpopupshowing="console.onTModeMenuCreate();">
<menuitem id="menu_TModeIgnore"
observes="cmd_tmode_ignore" type="radio"
label="&TModeIgnore.label;"
accesskey="&TModeIgnore.aKey;"/>
<menuitem id="menu_TModeTrace"
observes="cmd_tmode_trace" type="radio"
label="&TModeTrace.label;"
accesskey="&TModeTrace.aKey;"/>
<menuitem id="menu_TModeBreak"
observes="cmd_tmode_break" type="radio"
label="&TModeBreak.label;"
accesskey="&TModeBreak.aKey;"/>
<menuseparator/>
<menuitem id="menu_TModeCycle" label = "&TModeCycle.label;"
observes="cmd_tmode_cycle" key="key_tmode_cycle"
accesskey="&TModeCycle.aKey;"/>
</menupopup>
</menu>
</menupopup>
</menu>
<!-- Tasks menu -->
<menu id="tasksMenu"/>
</menubar>
<!-- Debug toolbar -->
<toolbar class="toolbar-primary chromeclass-toolbar" id="main-toolbar"
grippytooltip="aTooltip" grippytooltiptext="&DebugBar.tooltip;">
<hbox id="main-toolbar-buttons">
<toolbarbutton class="toolbarbutton-1" id="stop-button"
label="&Stop.label;" observes="cmd_stop"
tooltip="aTooltip" tooltiptext="&Stop.tooltip;"/>
<toolbarseparator class="toolbarseparator-primary"/>
<toolbarbutton class="toolbarbutton-1" id="cont-button"
label="&Cont.label;" observes="cmd_cont"
tooltip="aTooltip" tooltiptext="&Cont.tooltip;"/>
<toolbarbutton class="toolbarbutton-1" id="step-over-button"
label="&StepOver.label;" observes="cmd_step_over"
tooltip="aTooltip" tooltiptext="&StepOver.tooltip;"/>
<toolbarbutton class="toolbarbutton-1" id="step-in-button"
label="&StepIn.label;" observes="cmd_step_in"
tooltip="aTooltip" tooltiptext="&StepIn.tooltip;"/>
<toolbarbutton class="toolbarbutton-1" id="step-out-button"
label="&StepOut.label;" observes="cmd_step_out"
tooltip="aTooltip" tooltiptext="&StepOut.tooltip;"/>
</hbox>
</toolbar>
</toolbox>
</overlaytarget>
<!-- Statusbar (hey, it's /almost/ a menu) -->
<overlaytarget id="statusbar-overlay-target">
<statusbar id="status-bar" flex="1">
<hbox id="component-bar"/>
<statusbarpanel id="status-text" label="&StatusText.label;" flex="1"
crop="right"/>
<statusbarpanel class="statusbarpanel-icononly" id="offline-status"
hidden="true" offline="true"/>
</statusbar>
</overlaytarget>
</overlay>

Просмотреть файл

@ -143,6 +143,8 @@ const MSG_VF_HINTED = getMsg("vf.hinted");
const MSG_HELLO = getMsg("msg.hello"); const MSG_HELLO = getMsg("msg.hello");
const MSG_STATUS_DEFAULT = getMsg("msg.status.default");
const MSG_TIP_HELP = getMsg("msg.tip.help"); const MSG_TIP_HELP = getMsg("msg.tip.help");
const MSG_NO_BREAKPOINTS_SET = getMsg("msg.no.breakpoints.set"); const MSG_NO_BREAKPOINTS_SET = getMsg("msg.no.breakpoints.set");
const MSG_NO_FBREAKS_SET = getMsg("msg.no.fbreaks.set"); const MSG_NO_FBREAKS_SET = getMsg("msg.no.fbreaks.set");
@ -260,3 +262,7 @@ const MSN_EVAL_ERROR = "msg.eval.error";
const MSN_EVAL_THREW = "msg.eval.threw"; const MSN_EVAL_THREW = "msg.eval.threw";
const MSN_STOP = "msg.stop"; const MSN_STOP = "msg.stop";
const MSN_SUBSCRIPT_LOADED = "msg.subscript.load"; const MSN_SUBSCRIPT_LOADED = "msg.subscript.load";
const MSN_STATUS_LOADING = "msg.status.loading";
const MSN_STATUS_MARKING = "msg.status.marking";
const MSN_STATUS_STOPPED = "msg.status.stopped";

Просмотреть файл

@ -75,12 +75,13 @@ function initOutliners()
var atomsvc = var atomsvc =
Components.classes[ATOM_CTRID].getService(nsIAtomService); Components.classes[ATOM_CTRID].getService(nsIAtomService);
console.sourceView.atomCurrent = atomsvc.getAtom("current-line"); console.sourceView.atomCurrent = atomsvc.getAtom("current-line");
console.sourceView.atomBreakpoint = atomsvc.getAtom("breakpoint"); console.sourceView.atomHighlightStart = atomsvc.getAtom("highlight-start");
console.sourceView.atomFunctionStart = atomsvc.getAtom("func-start"); console.sourceView.atomHighlightRange = atomsvc.getAtom("highlight-range");
console.sourceView.atomFunctionLine = atomsvc.getAtom("func-line"); console.sourceView.atomHighlightEnd = atomsvc.getAtom("highlight-end");
console.sourceView.atomFunctionEnd = atomsvc.getAtom("func-end"); console.sourceView.atomBreakpoint = atomsvc.getAtom("breakpoint");
console.sourceView.atomFunctionAfter = atomsvc.getAtom("func-after"); console.sourceView.atomCode = atomsvc.getAtom("code");
console.sourceView.atomWhitespace = atomsvc.getAtom("whitespace");
var outliner = document.getElementById("source-outliner"); var outliner = document.getElementById("source-outliner");
outliner.outlinerBoxObject.view = console.sourceView; outliner.outlinerBoxObject.view = console.sourceView;
@ -97,6 +98,9 @@ function initOutliners()
outliner = document.getElementById("script-list-outliner"); outliner = document.getElementById("script-list-outliner");
outliner.outlinerBoxObject.view = console.scriptsView; outliner.outlinerBoxObject.view = console.scriptsView;
outliner.setAttribute ("ondraggesture",
"nsDragAndDrop.startDrag(event, " +
"console.scriptsView);");
outliner = document.getElementById("stack-outliner"); outliner = document.getElementById("stack-outliner");
outliner.outlinerBoxObject.view = console.stackView; outliner.outlinerBoxObject.view = console.stackView;
@ -164,7 +168,7 @@ function sv_scrollto (line, align)
} }
/* /*
* pass in a ScriptContainer to be displayed on this outliner * pass in a SourceRecord to be displayed on this outliner
*/ */
console.sourceView.displaySource = console.sourceView.displaySource =
function sov_dsource (source) function sov_dsource (source)
@ -272,33 +276,57 @@ function sv_rowprops (row, properties)
{ {
properties.AppendElement(this.atomCurrent); properties.AppendElement(this.atomCurrent);
} }
} }
/* nsIOutlinerView */ /* nsIOutlinerView */
console.sourceView.getCellProperties = console.sourceView.getCellProperties =
function sv_cellprops (row, colID, properties) function sv_cellprops (row, colID, properties)
{ {
if (!this.childData.isLoaded) if (!("childData" in this) || !this.childData.isLoaded ||
row < 0 || row > this.childData.sourceText.length)
return; return;
var line = this.childData.sourceText[row]; var line = this.childData.sourceText[row];
if (!line) if (!line)
return; return;
if (colID == "breakpoint-col" && if (colID == "breakpoint-col")
this.childData.sourceText[row].bpRecord)
properties.AppendElement(this.atomBreakpoint);
if (line.functionLine)
{ {
properties.AppendElement(this.atomFunctionLine); if (this.childData.sourceText[row].bpRecord)
if (line.functionStart) properties.AppendElement(this.atomBreakpoint);
properties.AppendElement(this.atomFunctionStart); else if (this.childData.lineMap[row])
if (linefunctionEnd) properties.AppendElement(this.atomCode);
properties.AppendElement(this.atomFunctionEnd); else
} else if (row > 0 && this.childData.sourceText[row - 1].functionEnd) properties.AppendElement(this.atomWhitespace);
properties.AppendElement(this.atomFunctionAfter); }
if ("highlightStart" in console)
{
var atom;
if (row == console.highlightStart)
{
atom = this.atomHighlightStart;
}
else if (row == console.highlightEnd)
{
atom = this.atomHighlightEnd;
}
else if (row > console.highlightStart && row < console.highlightEnd)
{
atom = this.atomHighlightRange;
}
if (atom && console.highlightFile == this.childData.fileName)
{
properties.AppendElement(atom);
}
}
if (row == console.stopLine - 1 &&
console.stopFile == this.childData.fileName)
{
properties.AppendElement(this.atomCurrent);
}
} }
/* nsIOutlinerView */ /* nsIOutlinerView */
@ -372,6 +400,52 @@ function SourceRecord(fileName)
SourceRecord.prototype = new TreeOViewRecord(scriptShare); SourceRecord.prototype = new TreeOViewRecord(scriptShare);
SourceRecord.prototype.onDragStart =
function sr_dragstart (e, transferData, dragAction)
{
transferData.data = new TransferData();
transferData.data.addDataForFlavour("text/x-venkman-file", this.fileName);
transferData.data.addDataForFlavour("text/x-moz-url", this.fileName);
transferData.data.addDataForFlavour("text/unicode", this.fileName);
transferData.data.addDataForFlavour("text/html",
"<a href='" + this.fileName +
"'>" + this.fileName + "</a>");
return true;
}
SourceRecord.prototype.appendScriptRecord =
function sr_addscript(scriptRec)
{
this.appendChild (scriptRec);
}
SourceRecord.prototype.__defineGetter__ ("lineMap", sr_getmap);
function sr_getmap ()
{
if (!("_lineMap" in this))
{
console.pushStatus (getMsg(MSN_STATUS_MARKING, this.shortName));
this._lineMap = new Array();
for (var i = 0; i < this.childData.length; ++i)
{
var scriptRec = this.childData[i];
var end = scriptRec.baseLineNumber + scriptRec.lineExtent;
for (var j = scriptRec.baseLineNumber; j < end; ++j)
{
if (!this._lineMap[j] &&
scriptRec.script.isLineExecutable(j + 1))
{
this._lineMap[j] = true;
}
}
}
console.popStatus();
}
return this._lineMap;
}
SourceRecord.prototype.isLoaded = false; SourceRecord.prototype.isLoaded = false;
SourceRecord.prototype.sortCompare = SourceRecord.prototype.sortCompare =
@ -417,6 +491,11 @@ function sr_makecur ()
else else
console.sourceView.scrollTo (0, -1); console.sourceView.scrollTo (0, -1);
} }
console.sourceView.outliner.invalidate();
delete console.highlightFile;
delete console.highlightStart;
delete console.highlightEnd;
} }
SourceRecord.prototype.reloadSource = SourceRecord.prototype.reloadSource =
@ -536,6 +615,7 @@ function sr_loadsrc (cb)
console.scriptsView.outliner.invalidate(); console.scriptsView.outliner.invalidate();
callall(status); callall(status);
console.popStatus();
} }
}; };
@ -550,6 +630,7 @@ function sr_loadsrc (cb)
catch (ex) catch (ex)
{ {
/* if we can't load it now, try to load it later */ /* if we can't load it now, try to load it later */
console.pushStatus (getMsg(MSN_STATUS_LOADING, this.fileName));
loadURLAsync (this.fileName, observer); loadURLAsync (this.fileName, observer);
} }
@ -578,38 +659,49 @@ function ScriptRecord(script)
this.baseLineNumber = script.baseLineNumber; this.baseLineNumber = script.baseLineNumber;
this.lineExtent = script.lineExtent; this.lineExtent = script.lineExtent;
this.script = script; this.script = script;
this.jsdurl = "jsd:sourcetext?url=" + escape(this.script.fileName) +
"&base=" + this.baseLineNumber + "&" + "extent=" + this.lineExtent +
"&name=" + this.functionName;
} }
ScriptRecord.prototype = new TreeOViewRecord(scriptShare); ScriptRecord.prototype = new TreeOViewRecord(scriptShare);
ScriptRecord.prototype.onDragStart =
function sr_dragstart (e, transferData, dragAction)
{
var fileName = this.script.fileName;
transferData.data = new TransferData();
transferData.data.addDataForFlavour("text/x-jsd-url", this.jsdurl);
transferData.data.addDataForFlavour("text/x-moz-url", fileName);
transferData.data.addDataForFlavour("text/unicode", fileName);
transferData.data.addDataForFlavour("text/html",
"<a href='" + fileName +
"'>" + fileName + "</a>");
return true;
}
ScriptRecord.prototype.makeCurrent = ScriptRecord.prototype.makeCurrent =
function sr_makecur () function sr_makecur ()
{ {
console.sourceView.displaySource(this.parentRecord); console.sourceView.displaySource(this.parentRecord);
console.sourceView.scrollTo (this.baseLineNumber - 2, -1); console.sourceView.scrollTo (this.baseLineNumber - 2, -1);
if (this.parentRecord.isLoaded) console.highlightFile = this.script.fileName;
console.sourceView.selection.timedSelect (this.baseLineNumber - 1, 500); console.highlightStart = this.baseLineNumber - 1;
else console.highlightEnd = this.baseLineNumber - 1 + this.lineExtent;
console.sourceView.pendingSelect = this.baseLineNumber - 1; console.sourceView.outliner.invalidate();
} }
ScriptRecord.prototype.containsLine = ScriptRecord.prototype.containsLine =
function sr_containsl (line) function sr_containsl (line)
{ {
if (this.script.baseLineNumber <= line && if (this.script.baseLineNumber <= line &&
this.script.baseLineNumber + this.script.lineExtent > line) this.script.baseLineNumber + this.lineExtent > line)
return true; return true;
return false; return false;
} }
ScriptRecord.prototype.isLineExecutable =
function sr_isexecutable (line)
{
var pc = this.script.lineToPc (line);
return (line == this.script.pcToLine (pc));
}
ScriptRecord.prototype.__defineGetter__ ("bpcount", sr_getbpcount); ScriptRecord.prototype.__defineGetter__ ("bpcount", sr_getbpcount);
function sr_getbpcount () function sr_getbpcount ()
{ {
@ -701,6 +793,26 @@ function sr_guessname ()
console.scriptsView = new TreeOView(scriptShare); console.scriptsView = new TreeOView(scriptShare);
console.scriptsView.onDragStart = Prophylactic(console.scriptsView,
scv_dstart);
function scv_dstart (e, transferData, dragAction)
{
var row = new Object();
var colID = new Object();
var childElt = new Object();
this.outliner.getCellAt(e.clientX, e.clientY, row, colID, childElt);
if (!colID.value)
return false;
row = this.childData.locateChildByVisualRow (row.value);
var rv = false;
if (row && ("onDragStart" in row))
rv = row.onDragStart (e, transferData, dragAction);
return rv;
}
console.scriptsView.fullNameMode = false; console.scriptsView.fullNameMode = false;
console.scriptsView.setFullNameMode = console.scriptsView.setFullNameMode =
@ -766,7 +878,7 @@ function ValueRecord (value, name, flags)
{ {
if (!(value instanceof jsdIValue)) if (!(value instanceof jsdIValue))
throw new BadMojo (ERR_INVALID_PARAM, "value", String(value)); throw new BadMojo (ERR_INVALID_PARAM, "value", String(value));
this.setColumnPropertyName ("stack-col-0", "displayName"); this.setColumnPropertyName ("stack-col-0", "displayName");
this.setColumnPropertyName ("stack-col-1", "displayType"); this.setColumnPropertyName ("stack-col-1", "displayType");
this.setColumnPropertyName ("stack-col-2", "displayValue"); this.setColumnPropertyName ("stack-col-2", "displayValue");
@ -774,6 +886,7 @@ function ValueRecord (value, name, flags)
this.displayName = name; this.displayName = name;
this.displayFlags = flags; this.displayFlags = flags;
this.value = value; this.value = value;
this.jsType = null;
this.refresh(); this.refresh();
} }
@ -805,7 +918,7 @@ function vr_refresh ()
++sizeDelta; ++sizeDelta;
} }
if (this.jsType != jsdIValue.TYPE_OBJECT && this.childData) if (this.jsType != jsdIValue.TYPE_OBJECT && "childData" in this)
{ {
/* if we're not an object but we have child data, then we must have just /* if we're not an object but we have child data, then we must have just
* turned into something other than an object. */ * turned into something other than an object. */
@ -1035,7 +1148,6 @@ function vr_create()
} }
this.childData = new Array(); this.childData = new Array();
this.isContainerOpen = false;
var p = new Object(); var p = new Object();
this.value.getProperties (p, {}); this.value.getProperties (p, {});
@ -1085,8 +1197,62 @@ function vr_destroy()
console.stackView = new TreeOView(stackShare); console.stackView = new TreeOView(stackShare);
console.stackView.restoreState =
function sv_restore ()
{
function restoreBranch (target, source)
{
for (var i in source)
{
if (typeof source[i] == "object")
{
var name = source[i].name;
var len = target.length;
for (var j = 0; j < len; ++j)
{
if (target[j]._colValues["stack-col-0"] == name &&
"childData" in target[j])
{
//dd ("opening " + name);
target[j].open();
restoreBranch (target[j].childData, source[i]);
}
}
}
}
}
if ("savedState" in this) {
restoreBranch (this.stack.childData, this.savedState);
this.scrollTo (this.savedState.firstVisible, -1);
}
}
console.stackView.saveState =
function sv_save ()
{
function saveBranch (target, source)
{
var len = source.length;
for (var i = 0; i < len; ++i)
{
if (source[i].isContainerOpen)
{
target[i] = new Object();
target[i].name = source[i]._colValues["stack-col-0"];
saveBranch (target[i], source[i].childData);
}
}
}
this.savedState = new Object();
this.savedState.firstVisible = this.outliner.getFirstVisibleRow() + 1;
saveBranch (this.savedState, this.stack.childData);
//dd ("saved as\n" + dumpObjectTree(this.savedState, 10));
}
console.stackView.refresh = console.stackView.refresh =
function wv_refresh() function sv_refresh()
{ {
var sk = this.stack; var sk = this.stack;
var delta = 0; var delta = 0;
@ -1287,7 +1453,7 @@ function bpr_matchrec (scriptRec)
{ {
return (scriptRec.script.fileName.indexOf(this.fileName) != -1 && return (scriptRec.script.fileName.indexOf(this.fileName) != -1 &&
scriptRec.containsLine(this.line) && scriptRec.containsLine(this.line) &&
scriptRec.isLineExecutable(this.line)); scriptRec.script.isLineExecutable(this.line));
} }
BPRecord.prototype.addScriptRecord = BPRecord.prototype.addScriptRecord =

Просмотреть файл

@ -0,0 +1,80 @@
<?xml version="1.0"?>
<!--
-
- The contents of this file are subject to the Mozilla Public License
- Version 1.1 (the "License"); you may not use this file except in
- compliance with the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
-
- Software distributed under the License is distributed on an "AS IS" basis,
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- for the specific language governing rights and limitations under the
- License.
-
- The Original Code is The JavaScript Debugger
-
- The Initial Developer of the Original Code is
- Netscape Communications Corporation
- Portions created by Netscape are
- Copyright (C) 1998 Netscape Communications Corporation.
- All Rights Reserved.
-
- Alternatively, the contents of this file may be used under the
- terms of the GNU Public License (the "GPL"), in which case the
- provisions of the GPL are applicable instead of those above.
- If you wish to allow use of your version of this file only
- under the terms of the GPL and not to allow others to use your
- version of this file under the MPL, indicate your decision by
- deleting the provisions above and replace them with the notice
- and other provisions required by the GPL. If you do not delete
- the provisions above, a recipient may use your version of this
- file under either the MPL or the GPL.
-
- Contributor(s):
- Robert Ginda, <rginda@netscape.com>, original author
-
-->
<overlay id="venkman-scripts-overlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<overlaytarget id="scripts-overlay-target">
<script>
<![CDATA[
/* set this to false to turn off dd() messages */
var DEBUG = true;
]]>
</script>
<script src="chrome://navigator/content/tooltip.js"/>
<script src="chrome://global/content/nsJSSupportsUtils.js"/>
<script src="chrome://global/content/nsJSComponentManager.js"/>
<script src="chrome://global/content/nsUserSettings.js"/>
<script src="chrome://global/content/nsTransferable.js"/>
<script src="chrome://global/content/nsClipboard.js"/>
<script src="chrome://global/content/nsDragAndDrop.js"/>
<script src="chrome://communicator/content/contentAreaUtils.js"/>
<script src="chrome://communicator/content/contentAreaDD.js"/>
<script src="chrome://global/content/strres.js"/>
<script src="chrome://venkman/content/outliner-utils.js"/>
<script src="chrome://venkman/content/html-consts.js"/>
<script src="chrome://venkman/content/command-manager.js"/>
<script src="chrome://venkman/content/venkman-utils.js"/>
<script src="chrome://venkman/content/venkman-static.js"/>
<script src="chrome://venkman/content/venkman-handlers.js"/>
<script src="chrome://venkman/content/venkman-debugger.js"/>
<script src="chrome://venkman/content/venkman-url-loader.js"/>
<script src="chrome://venkman/content/venkman-commands.js"/>
<script src="chrome://venkman/content/venkman-prefs.js"/>
<script src="chrome://venkman/content/venkman-eval.js"/>
<script src="chrome://venkman/content/venkman-msg.js"/>
<script src="chrome://venkman/content/venkman-munger.js"/>
<script src="chrome://venkman/content/venkman-outliners.js"/>
<script src="chrome://venkman/content/venkman-dev.js"/>
</overlaytarget>
</overlay>

Просмотреть файл

@ -39,8 +39,8 @@ var ASSERT;
if (DEBUG) if (DEBUG)
{ {
dd = function (msg) { dumpln("-*- venkman: " + msg); } _dd_pfx = "vnk: ";
warn = function (msg) { dd ("** WARNING " + msg + " **"); } warn = function (msg) { dumpln ("** WARNING " + msg + " **"); }
ASSERT = function (expr, msg) { ASSERT = function (expr, msg) {
if (!expr) if (!expr)
dump ("** ASSERTION FAILED: " + msg + " **\n" + getStackTrace() + dump ("** ASSERTION FAILED: " + msg + " **\n" + getStackTrace() +
@ -62,21 +62,14 @@ console.version = "0.6.1";
/* |this|less functions */ /* |this|less functions */
function startupTests() const jsdIFilter = Components.interfaces.jsdIFilter;
{
if (0)
{
openDialog("chrome://venkman/content/tests/tree.xul", "", "");
}
}
function cont () function cont ()
{ {
disableDebugCommands(); disableDebugCommands();
--console._stopLevel; --console._stopLevel;
console.stackView.saveState();
console.jsds.exitNestedEventLoop(); console.jsds.exitNestedEventLoop();
return true;
} }
function next () function next ()
@ -93,6 +86,7 @@ function step ()
console._stepPast = topFrame.script.fileName + topFrame.line; console._stepPast = topFrame.script.fileName + topFrame.line;
disableDebugCommands() disableDebugCommands()
--console._stopLevel; --console._stopLevel;
console.stackView.saveState();
console.jsds.exitNestedEventLoop(); console.jsds.exitNestedEventLoop();
} }
@ -103,6 +97,7 @@ function stepOut ()
console.jsds.functionHook = console._callHook; console.jsds.functionHook = console._callHook;
disableDebugCommands() disableDebugCommands()
--console._stopLevel; --console._stopLevel;
console.stackView.saveState();
console.jsds.exitNestedEventLoop(); console.jsds.exitNestedEventLoop();
} }
@ -143,7 +138,7 @@ function disableReloadCommand()
function enableDebugCommands() function enableDebugCommands()
{ {
var cmds = document.getElementById("venkmanDebuggerCommands"); var cmds = document.getElementById("venkmanStackCommands");
var sib = cmds.firstChild; var sib = cmds.firstChild;
while (sib) while (sib)
@ -163,7 +158,7 @@ function enableDebugCommands()
function disableDebugCommands() function disableDebugCommands()
{ {
var cmds = document.getElementById("venkmanDebuggerCommands"); var cmds = document.getElementById("venkmanStackCommands");
var sib = cmds.firstChild; var sib = cmds.firstChild;
while (sib) while (sib)
{ {
@ -374,7 +369,7 @@ function htmlVA (attribs, href, contents)
} }
function init() function init()
{ {
initPrefs(); initPrefs();
initCommands(); initCommands();
initOutliners(); initOutliners();
@ -407,7 +402,9 @@ function init()
display(MSG_HELLO, MT_HELLO); display(MSG_HELLO, MT_HELLO);
display(getMsg(MSN_VERSION, console.version), MT_HELLO); display(getMsg(MSN_VERSION, console.version), MT_HELLO);
displayCommands(); displayCommands();
console._statusElement = document.getElementById ("status-text");
console._statusStack = new Array();
startupTests(); startupTests();
} }
@ -498,6 +495,35 @@ function stringToDOM (message)
return span; return span;
} }
/* some of the drag and drop code has an annoying apetite for exceptions. any
* exception raised during a dnd operation causes the operation to fail silently.
* passing the function through one of these adapters lets you use "return
* false on planned failure" symantics, and dumps any exceptions caught
* to the console. */
function Prophylactic (parent, fun)
{
function adapter ()
{
var ex;
var rv = false;
try
{
rv = fun.apply (parent, arguments);
}
catch (ex)
{
dd ("Prophylactic caught an exception:\n" +
dumpObjectTree(ex));
}
if (!rv)
throw "goodger";
}
return adapter;
}
/* exceptions */ /* exceptions */
/* keep this list in sync with exceptionMsgNames in venkman-msg.js */ /* keep this list in sync with exceptionMsgNames in venkman-msg.js */
@ -541,6 +567,34 @@ console._lastTabUp = new Date();
console.display = display; console.display = display;
console.load = load; console.load = load;
console.__defineGetter__ ("status", con_getstatus);
function con_getstatus ()
{
return console._statusElement.getAttribute ("label");
}
console.__defineSetter__ ("status", con_setstatus);
function con_setstatus (msg)
{
if (!msg)
msg = console._statusStack[console._statusStack.length - 1];
console._statusElement.setAttribute ("label", msg);
}
console.pushStatus =
function con_pushstatus (msg)
{
console._statusStack.push (console.status);
console.status = msg;
}
console.popStatus =
function con_popstatus ()
{
console.status = console._statusStack.pop();
}
console.scrollDown = console.scrollDown =
function con_scrolldn () function con_scrolldn ()
{ {

Просмотреть файл

@ -75,12 +75,13 @@ function initOutliners()
var atomsvc = var atomsvc =
Components.classes[ATOM_CTRID].getService(nsIAtomService); Components.classes[ATOM_CTRID].getService(nsIAtomService);
console.sourceView.atomCurrent = atomsvc.getAtom("current-line"); console.sourceView.atomCurrent = atomsvc.getAtom("current-line");
console.sourceView.atomBreakpoint = atomsvc.getAtom("breakpoint"); console.sourceView.atomHighlightStart = atomsvc.getAtom("highlight-start");
console.sourceView.atomFunctionStart = atomsvc.getAtom("func-start"); console.sourceView.atomHighlightRange = atomsvc.getAtom("highlight-range");
console.sourceView.atomFunctionLine = atomsvc.getAtom("func-line"); console.sourceView.atomHighlightEnd = atomsvc.getAtom("highlight-end");
console.sourceView.atomFunctionEnd = atomsvc.getAtom("func-end"); console.sourceView.atomBreakpoint = atomsvc.getAtom("breakpoint");
console.sourceView.atomFunctionAfter = atomsvc.getAtom("func-after"); console.sourceView.atomCode = atomsvc.getAtom("code");
console.sourceView.atomWhitespace = atomsvc.getAtom("whitespace");
var outliner = document.getElementById("source-outliner"); var outliner = document.getElementById("source-outliner");
outliner.outlinerBoxObject.view = console.sourceView; outliner.outlinerBoxObject.view = console.sourceView;
@ -97,6 +98,9 @@ function initOutliners()
outliner = document.getElementById("script-list-outliner"); outliner = document.getElementById("script-list-outliner");
outliner.outlinerBoxObject.view = console.scriptsView; outliner.outlinerBoxObject.view = console.scriptsView;
outliner.setAttribute ("ondraggesture",
"nsDragAndDrop.startDrag(event, " +
"console.scriptsView);");
outliner = document.getElementById("stack-outliner"); outliner = document.getElementById("stack-outliner");
outliner.outlinerBoxObject.view = console.stackView; outliner.outlinerBoxObject.view = console.stackView;
@ -164,7 +168,7 @@ function sv_scrollto (line, align)
} }
/* /*
* pass in a ScriptContainer to be displayed on this outliner * pass in a SourceRecord to be displayed on this outliner
*/ */
console.sourceView.displaySource = console.sourceView.displaySource =
function sov_dsource (source) function sov_dsource (source)
@ -272,33 +276,57 @@ function sv_rowprops (row, properties)
{ {
properties.AppendElement(this.atomCurrent); properties.AppendElement(this.atomCurrent);
} }
} }
/* nsIOutlinerView */ /* nsIOutlinerView */
console.sourceView.getCellProperties = console.sourceView.getCellProperties =
function sv_cellprops (row, colID, properties) function sv_cellprops (row, colID, properties)
{ {
if (!this.childData.isLoaded) if (!("childData" in this) || !this.childData.isLoaded ||
row < 0 || row > this.childData.sourceText.length)
return; return;
var line = this.childData.sourceText[row]; var line = this.childData.sourceText[row];
if (!line) if (!line)
return; return;
if (colID == "breakpoint-col" && if (colID == "breakpoint-col")
this.childData.sourceText[row].bpRecord)
properties.AppendElement(this.atomBreakpoint);
if (line.functionLine)
{ {
properties.AppendElement(this.atomFunctionLine); if (this.childData.sourceText[row].bpRecord)
if (line.functionStart) properties.AppendElement(this.atomBreakpoint);
properties.AppendElement(this.atomFunctionStart); else if (this.childData.lineMap[row])
if (linefunctionEnd) properties.AppendElement(this.atomCode);
properties.AppendElement(this.atomFunctionEnd); else
} else if (row > 0 && this.childData.sourceText[row - 1].functionEnd) properties.AppendElement(this.atomWhitespace);
properties.AppendElement(this.atomFunctionAfter); }
if ("highlightStart" in console)
{
var atom;
if (row == console.highlightStart)
{
atom = this.atomHighlightStart;
}
else if (row == console.highlightEnd)
{
atom = this.atomHighlightEnd;
}
else if (row > console.highlightStart && row < console.highlightEnd)
{
atom = this.atomHighlightRange;
}
if (atom && console.highlightFile == this.childData.fileName)
{
properties.AppendElement(atom);
}
}
if (row == console.stopLine - 1 &&
console.stopFile == this.childData.fileName)
{
properties.AppendElement(this.atomCurrent);
}
} }
/* nsIOutlinerView */ /* nsIOutlinerView */
@ -372,6 +400,52 @@ function SourceRecord(fileName)
SourceRecord.prototype = new TreeOViewRecord(scriptShare); SourceRecord.prototype = new TreeOViewRecord(scriptShare);
SourceRecord.prototype.onDragStart =
function sr_dragstart (e, transferData, dragAction)
{
transferData.data = new TransferData();
transferData.data.addDataForFlavour("text/x-venkman-file", this.fileName);
transferData.data.addDataForFlavour("text/x-moz-url", this.fileName);
transferData.data.addDataForFlavour("text/unicode", this.fileName);
transferData.data.addDataForFlavour("text/html",
"<a href='" + this.fileName +
"'>" + this.fileName + "</a>");
return true;
}
SourceRecord.prototype.appendScriptRecord =
function sr_addscript(scriptRec)
{
this.appendChild (scriptRec);
}
SourceRecord.prototype.__defineGetter__ ("lineMap", sr_getmap);
function sr_getmap ()
{
if (!("_lineMap" in this))
{
console.pushStatus (getMsg(MSN_STATUS_MARKING, this.shortName));
this._lineMap = new Array();
for (var i = 0; i < this.childData.length; ++i)
{
var scriptRec = this.childData[i];
var end = scriptRec.baseLineNumber + scriptRec.lineExtent;
for (var j = scriptRec.baseLineNumber; j < end; ++j)
{
if (!this._lineMap[j] &&
scriptRec.script.isLineExecutable(j + 1))
{
this._lineMap[j] = true;
}
}
}
console.popStatus();
}
return this._lineMap;
}
SourceRecord.prototype.isLoaded = false; SourceRecord.prototype.isLoaded = false;
SourceRecord.prototype.sortCompare = SourceRecord.prototype.sortCompare =
@ -417,6 +491,11 @@ function sr_makecur ()
else else
console.sourceView.scrollTo (0, -1); console.sourceView.scrollTo (0, -1);
} }
console.sourceView.outliner.invalidate();
delete console.highlightFile;
delete console.highlightStart;
delete console.highlightEnd;
} }
SourceRecord.prototype.reloadSource = SourceRecord.prototype.reloadSource =
@ -536,6 +615,7 @@ function sr_loadsrc (cb)
console.scriptsView.outliner.invalidate(); console.scriptsView.outliner.invalidate();
callall(status); callall(status);
console.popStatus();
} }
}; };
@ -550,6 +630,7 @@ function sr_loadsrc (cb)
catch (ex) catch (ex)
{ {
/* if we can't load it now, try to load it later */ /* if we can't load it now, try to load it later */
console.pushStatus (getMsg(MSN_STATUS_LOADING, this.fileName));
loadURLAsync (this.fileName, observer); loadURLAsync (this.fileName, observer);
} }
@ -578,38 +659,49 @@ function ScriptRecord(script)
this.baseLineNumber = script.baseLineNumber; this.baseLineNumber = script.baseLineNumber;
this.lineExtent = script.lineExtent; this.lineExtent = script.lineExtent;
this.script = script; this.script = script;
this.jsdurl = "jsd:sourcetext?url=" + escape(this.script.fileName) +
"&base=" + this.baseLineNumber + "&" + "extent=" + this.lineExtent +
"&name=" + this.functionName;
} }
ScriptRecord.prototype = new TreeOViewRecord(scriptShare); ScriptRecord.prototype = new TreeOViewRecord(scriptShare);
ScriptRecord.prototype.onDragStart =
function sr_dragstart (e, transferData, dragAction)
{
var fileName = this.script.fileName;
transferData.data = new TransferData();
transferData.data.addDataForFlavour("text/x-jsd-url", this.jsdurl);
transferData.data.addDataForFlavour("text/x-moz-url", fileName);
transferData.data.addDataForFlavour("text/unicode", fileName);
transferData.data.addDataForFlavour("text/html",
"<a href='" + fileName +
"'>" + fileName + "</a>");
return true;
}
ScriptRecord.prototype.makeCurrent = ScriptRecord.prototype.makeCurrent =
function sr_makecur () function sr_makecur ()
{ {
console.sourceView.displaySource(this.parentRecord); console.sourceView.displaySource(this.parentRecord);
console.sourceView.scrollTo (this.baseLineNumber - 2, -1); console.sourceView.scrollTo (this.baseLineNumber - 2, -1);
if (this.parentRecord.isLoaded) console.highlightFile = this.script.fileName;
console.sourceView.selection.timedSelect (this.baseLineNumber - 1, 500); console.highlightStart = this.baseLineNumber - 1;
else console.highlightEnd = this.baseLineNumber - 1 + this.lineExtent;
console.sourceView.pendingSelect = this.baseLineNumber - 1; console.sourceView.outliner.invalidate();
} }
ScriptRecord.prototype.containsLine = ScriptRecord.prototype.containsLine =
function sr_containsl (line) function sr_containsl (line)
{ {
if (this.script.baseLineNumber <= line && if (this.script.baseLineNumber <= line &&
this.script.baseLineNumber + this.script.lineExtent > line) this.script.baseLineNumber + this.lineExtent > line)
return true; return true;
return false; return false;
} }
ScriptRecord.prototype.isLineExecutable =
function sr_isexecutable (line)
{
var pc = this.script.lineToPc (line);
return (line == this.script.pcToLine (pc));
}
ScriptRecord.prototype.__defineGetter__ ("bpcount", sr_getbpcount); ScriptRecord.prototype.__defineGetter__ ("bpcount", sr_getbpcount);
function sr_getbpcount () function sr_getbpcount ()
{ {
@ -701,6 +793,26 @@ function sr_guessname ()
console.scriptsView = new TreeOView(scriptShare); console.scriptsView = new TreeOView(scriptShare);
console.scriptsView.onDragStart = Prophylactic(console.scriptsView,
scv_dstart);
function scv_dstart (e, transferData, dragAction)
{
var row = new Object();
var colID = new Object();
var childElt = new Object();
this.outliner.getCellAt(e.clientX, e.clientY, row, colID, childElt);
if (!colID.value)
return false;
row = this.childData.locateChildByVisualRow (row.value);
var rv = false;
if (row && ("onDragStart" in row))
rv = row.onDragStart (e, transferData, dragAction);
return rv;
}
console.scriptsView.fullNameMode = false; console.scriptsView.fullNameMode = false;
console.scriptsView.setFullNameMode = console.scriptsView.setFullNameMode =
@ -766,7 +878,7 @@ function ValueRecord (value, name, flags)
{ {
if (!(value instanceof jsdIValue)) if (!(value instanceof jsdIValue))
throw new BadMojo (ERR_INVALID_PARAM, "value", String(value)); throw new BadMojo (ERR_INVALID_PARAM, "value", String(value));
this.setColumnPropertyName ("stack-col-0", "displayName"); this.setColumnPropertyName ("stack-col-0", "displayName");
this.setColumnPropertyName ("stack-col-1", "displayType"); this.setColumnPropertyName ("stack-col-1", "displayType");
this.setColumnPropertyName ("stack-col-2", "displayValue"); this.setColumnPropertyName ("stack-col-2", "displayValue");
@ -774,6 +886,7 @@ function ValueRecord (value, name, flags)
this.displayName = name; this.displayName = name;
this.displayFlags = flags; this.displayFlags = flags;
this.value = value; this.value = value;
this.jsType = null;
this.refresh(); this.refresh();
} }
@ -805,7 +918,7 @@ function vr_refresh ()
++sizeDelta; ++sizeDelta;
} }
if (this.jsType != jsdIValue.TYPE_OBJECT && this.childData) if (this.jsType != jsdIValue.TYPE_OBJECT && "childData" in this)
{ {
/* if we're not an object but we have child data, then we must have just /* if we're not an object but we have child data, then we must have just
* turned into something other than an object. */ * turned into something other than an object. */
@ -1035,7 +1148,6 @@ function vr_create()
} }
this.childData = new Array(); this.childData = new Array();
this.isContainerOpen = false;
var p = new Object(); var p = new Object();
this.value.getProperties (p, {}); this.value.getProperties (p, {});
@ -1085,8 +1197,62 @@ function vr_destroy()
console.stackView = new TreeOView(stackShare); console.stackView = new TreeOView(stackShare);
console.stackView.restoreState =
function sv_restore ()
{
function restoreBranch (target, source)
{
for (var i in source)
{
if (typeof source[i] == "object")
{
var name = source[i].name;
var len = target.length;
for (var j = 0; j < len; ++j)
{
if (target[j]._colValues["stack-col-0"] == name &&
"childData" in target[j])
{
//dd ("opening " + name);
target[j].open();
restoreBranch (target[j].childData, source[i]);
}
}
}
}
}
if ("savedState" in this) {
restoreBranch (this.stack.childData, this.savedState);
this.scrollTo (this.savedState.firstVisible, -1);
}
}
console.stackView.saveState =
function sv_save ()
{
function saveBranch (target, source)
{
var len = source.length;
for (var i = 0; i < len; ++i)
{
if (source[i].isContainerOpen)
{
target[i] = new Object();
target[i].name = source[i]._colValues["stack-col-0"];
saveBranch (target[i], source[i].childData);
}
}
}
this.savedState = new Object();
this.savedState.firstVisible = this.outliner.getFirstVisibleRow() + 1;
saveBranch (this.savedState, this.stack.childData);
//dd ("saved as\n" + dumpObjectTree(this.savedState, 10));
}
console.stackView.refresh = console.stackView.refresh =
function wv_refresh() function sv_refresh()
{ {
var sk = this.stack; var sk = this.stack;
var delta = 0; var delta = 0;
@ -1287,7 +1453,7 @@ function bpr_matchrec (scriptRec)
{ {
return (scriptRec.script.fileName.indexOf(this.fileName) != -1 && return (scriptRec.script.fileName.indexOf(this.fileName) != -1 &&
scriptRec.containsLine(this.line) && scriptRec.containsLine(this.line) &&
scriptRec.isLineExecutable(this.line)); scriptRec.script.isLineExecutable(this.line));
} }
BPRecord.prototype.addScriptRecord = BPRecord.prototype.addScriptRecord =

Просмотреть файл

@ -45,10 +45,43 @@ else
dumpln = function () {} /* no suitable function */ dumpln = function () {} /* no suitable function */
} }
if (DEBUG) if (DEBUG) {
dd = dumpln; var _dd_pfx = "";
else var _dd_singleIndent = " ";
var _dd_indentLength = _dd_singleIndent.length;
var _dd_currentIndent = "";
var _dd_lastDumpWasOpen = false;
var _dd_timeStack = new Array();
dd = function _dd (str) {
if (typeof str != "string") {
dumpln (str);
} else if (str[str.length - 1] == "{") {
_dd_timeStack.push (new Date());
if (_dd_lastDumpWasOpen)
dump("\n");
dump (_dd_pfx + _dd_currentIndent + str);
_dd_currentIndent += _dd_singleIndent;
_dd_lastDumpWasOpen = true;
} else if (str[0] == "}") {
var sufx = (new Date() - _dd_timeStack.pop()) / 1000 + " sec";
_dd_currentIndent =
_dd_currentIndent.substr (0, _dd_currentIndent.length -
_dd_indentLength);
if (_dd_lastDumpWasOpen)
dumpln ("} " + sufx);
else
dumpln (_dd_pfx + _dd_currentIndent + str + " " + sufx);
_dd_lastDumpWasOpen = false;
} else {
if (_dd_lastDumpWasOpen)
dump ("\n");
dumpln (_dd_pfx + _dd_currentIndent + str);
_dd_lastDumpWasOpen = false;
}
}
} else {
dd = function (){}; dd = function (){};
}
var jsenv = new Object(); var jsenv = new Object();
jsenv.HAS_SECURITYMANAGER = ((typeof netscape == "object") && jsenv.HAS_SECURITYMANAGER = ((typeof netscape == "object") &&

Просмотреть файл

@ -41,10 +41,11 @@
<?xml-stylesheet href="chrome://venkman/skin/venkman.css" type="text/css"?> <?xml-stylesheet href="chrome://venkman/skin/venkman.css" type="text/css"?>
<?xul-overlay href="chrome://global/content/globalOverlay.xul"?> <?xul-overlay href="chrome://global/content/globalOverlay.xul"?>
<?xul-overlay href="chrome://venkman/content/venkman-menus.xul"?>
<?xul-overlay href="chrome://venkman/content/venkman-scripts.xul"?>
<?xul-overlay href="chrome://communicator/content/utilityOverlay.xul"?> <?xul-overlay href="chrome://communicator/content/utilityOverlay.xul"?>
<?xul-overlay href="chrome://communicator/content/tasksOverlay.xul"?>
<window id="main-window" orient="vertical" <window id="venkman-window" orient="vertical"
xmlns:html="http://www.w3.org/1999/xhtml" xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="console.onLoad();" onunload="return console.onUnload();" onload="console.onLoad();" onunload="return console.onUnload();"
@ -52,177 +53,8 @@
persist="width height screenX screenY" title="&MainWindow.title;" persist="width height screenX screenY" title="&MainWindow.title;"
windowtype="mozapp:venkman"> windowtype="mozapp:venkman">
<script> <overlaytarget id="scripts-overlay-target"/>
<![CDATA[ <overlaytarget id="menu-overlay-target"/>
/* set this to false to turn off dd() messages */
var DEBUG = true;
]]>
</script>
<script src="chrome://navigator/content/tooltip.js"/>
<script src="chrome://global/content/nsJSSupportsUtils.js"/>
<script src="chrome://global/content/nsJSComponentManager.js"/>
<script src="chrome://global/content/nsUserSettings.js"/>
<script src="chrome://global/content/nsTransferable.js"/>
<script src="chrome://global/content/nsClipboard.js"/>
<script src="chrome://global/content/nsDragAndDrop.js"/>
<script src="chrome://communicator/content/contentAreaUtils.js"/>
<script src="chrome://communicator/content/contentAreaDD.js"/>
<script src="chrome://global/content/strres.js"/>
<script src="chrome://venkman/content/outliner-utils.js"/>
<script src="chrome://venkman/content/html-consts.js"/>
<script src="chrome://venkman/content/command-manager.js"/>
<script src="chrome://venkman/content/venkman-utils.js"/>
<script src="chrome://venkman/content/venkman-static.js"/>
<script src="chrome://venkman/content/venkman-handlers.js"/>
<script src="chrome://venkman/content/venkman-debugger.js"/>
<script src="chrome://venkman/content/venkman-url-loader.js"/>
<script src="chrome://venkman/content/venkman-commands.js"/>
<script src="chrome://venkman/content/venkman-prefs.js"/>
<script src="chrome://venkman/content/venkman-eval.js"/>
<script src="chrome://venkman/content/venkman-msg.js"/>
<script src="chrome://venkman/content/venkman-munger.js"/>
<script src="chrome://venkman/content/venkman-outliners.js"/>
<commandset id="tasksCommands">
<command id="cmd_close" oncommand="window.close();"/>
<command id="cmd_quit"/>
</commandset>
<keyset id="tasksKeys">
<key id="key_close"/>
<key id="key_quit"/>
</keyset>
<!--
Step into = F11
Step out of = Shift+F11
Step over is F10 then?
-->
<commandset id="venkmanCommands">
<command id="cmd_reload_ui"
oncommand="if (DEBUG) window.location.href = window.location.href;"/>
<command id="cmd_focus" oncommand="console._slInputElement.focus();"/>
<command id="cmd_tmode_cycle" oncommand="cycleThrowMode();"/>
<command id="cmd_tmode_ignore" oncommand="setThrowMode(TMODE_IGNORE);"/>
<command id="cmd_tmode_trace" oncommand="setThrowMode(TMODE_TRACE);"/>
<command id="cmd_tmode_break" oncommand="setThrowMode(TMODE_BREAK);"/>
<command id="cmd_stop" oncommand="console.doCommandToggleStop();"/>
<command id="cmd_reload" oncommand="console.doCommandReload();"/>
</commandset>
<commandset id="venkmanDebuggerCommands">
<!-- commands in this set will be disabled when we're not stopped -->
<command id="cmd_step_over" oncommand="console.doCommandNext();"/>
<command id="cmd_step_in" oncommand="console.doCommandStep();"/>
<command id="cmd_step_out" oncommand="console.doCommandStepOut();"/>
<command id="cmd_cont" oncommand="console.doCommandCont();"/>
</commandset>
<keyset id="venkmanKeys">
<key id="key_reload_ui" observes="cmd_reload_ui"
modifiers="control alt" key="R"/>
<key id="key_reload" observes="cmd_reload"
modifiers="control" key="R"/>
<key id="key_focus" observes="cmd_focus" keycode="VK_TAB"/>
<key id="key_stop" observes="cmd_stop" keycode="VK_F4"/>
<key id="key_cont" observes="cmd_cont" keycode="VK_F5"/>
<key id="key_step_over" observes="cmd_step_over" keycode="VK_F10"/>
<key id="key_step_in" observes="cmd_step_in" keycode="VK_F11"/>
<key id="key_step_out" observes="cmd_step_out" modifiers="shift"
keycode="VK_F11"/>
<key id="key_tmode_cycle" observes="cmd_tmode_cycle"
modifiers="control" key="T"/>
</keyset>
<popupset id="tooltip-set">
<popup id="tooltip-popup" class="tooltip"
onpopupshowing="return fillInTooltip(document.tooltipNode);">
<box id="tooltipBox" orient="vertical"/>
</popup>
</popupset>
<popupset id="aTooltipSet"/>
<toolbox>
<menubar id="main-menubar" persist="collapsed" grippytooltip="aTooltip" grippytooltiptext="&MenuBar.tooltip;">
<menu id="menu_File">
<menupopup id="menu_FilePopup">
<menuitem id="menu_close"/>
</menupopup>
</menu>
<menu id="menu_View">
<menupopup id="menu_ViewPopup">
<menuitem id="menu_Reload" key="key_reload" observes="cmd_reload"
label="&Reload.label;" accesskey="&Reload.aKey;"/>
</menupopup>
</menu>
<menu id="menu_Debug" label="&Debug.label;" accesskey="&Debug.aKey;">
<menupopup id="menu_DebugPopup">
<menuitem id="menu_Stop" key="key_stop"
observes="cmd_stop"
label="&Stop.label;" accesskey="&Stop.aKey;"/>
<menuitem id="menu_Cont" key="key_cont"
observes="cmd_cont"
label="&Cont.label;" accesskey="&Cont.aKey;"/>
<menuitem id="menu_StepOver" key="key_step_over"
observes="cmd_step_over"
label="&StepOver.label;" accesskey="&StepOver.aKey;"/>
<menuitem id="menu_StepInto" key="key_step_in"
observes="cmd_step_in"
label="&StepIn.label;" accesskey="&StepIn.aKey;"/>
<menuitem id="menu_StepOut" key="key_step_out"
observes="cmd_step_out"
label="&StepOut.label;" accesskey="&StepOut.aKey;"/>
<menuseparator/>
<menu id="menu_ThrowMode" label="&TModeMenu.label;"
accesskey="&TModeMenu.aKey;">
<menupopup onpopupshowing="console.onTModeMenuCreate();">
<menuitem id="menu_TModeIgnore"
observes="cmd_tmode_ignore" type="radio"
label="&TModeIgnore.label;"
accesskey="&TModeIgnore.aKey;"/>
<menuitem id="menu_TModeTrace"
observes="cmd_tmode_trace" type="radio"
label="&TModeTrace.label;"
accesskey="&TModeTrace.aKey;"/>
<menuitem id="menu_TModeBreak"
observes="cmd_tmode_break" type="radio"
label="&TModeBreak.label;"
accesskey="&TModeBreak.aKey;"/>
<menuseparator/>
<menuitem id="menu_TModeCycle" label = "&TModeCycle.label;"
observes="cmd_tmode_cycle" key="key_tmode_cycle"
accesskey="&TModeCycle.aKey;"/>
</menupopup>
</menu>
</menupopup>
</menu>
<menu id="tasksMenu"/>
</menubar>
<toolbar class="toolbar-primary chromeclass-toolbar" id="main-toolbar" grippytooltip="aTooltip" grippytooltiptext="&DebugBar.tooltip;">
<hbox id="main-toolbar-buttons">
<toolbarbutton class="toolbarbutton-1" id="stop-button"
label="&Stop.label;" observes="cmd_stop" tooltip="aTooltip" tooltiptext="&Stop.tooltip;"/>
<toolbarseparator class="toolbarseparator-primary"/>
<toolbarbutton class="toolbarbutton-1" id="cont-button"
label="&Cont.label;" observes="cmd_cont" tooltip="aTooltip" tooltiptext="&Cont.tooltip;"/>
<toolbarbutton class="toolbarbutton-1" id="step-over-button"
label="&StepOver.label;" observes="cmd_step_over" tooltip="aTooltip" tooltiptext="&StepOver.tooltip;"/>
<toolbarbutton class="toolbarbutton-1" id="step-in-button"
label="&StepIn.label;" observes="cmd_step_in" tooltip="aTooltip" tooltiptext="&StepIn.tooltip;"/>
<toolbarbutton class="toolbarbutton-1" id="step-out-button"
label="&StepOut.label;" observes="cmd_step_out" tooltip="aTooltip" tooltiptext="&StepOut.tooltip;"/>
</hbox>
</toolbar>
</toolbox>
<box flex="1" orient="vertical"> <box flex="1" orient="vertical">
<hbox flex="1" id="top-hbox" persist="height"> <hbox flex="1" id="top-hbox" persist="height">
@ -274,9 +106,10 @@
<!-- source view --> <!-- source view -->
<outliner id="source-outliner" flex="50" persist="width" <outliner id="source-outliner" flex="50" persist="width"
onselect="console.onSourceSelect(event);"
onclick="console.onSourceClick(event);"> onclick="console.onSourceClick(event);">
<outlinercol id="breakpoint-col" width="20px" <outlinercol id="breakpoint-col" flex="3"
display="&SourceCol0.display;" persist="hidden"/> display="&SourceCol0.display;" persist="hidden width"/>
<splitter class="tree-splitter"/> <splitter class="tree-splitter"/>
<outlinercol id="source-line-number" flex="7" <outlinercol id="source-line-number" flex="7"
display="&SourceCol1.display;" persist="hidden width"/> display="&SourceCol1.display;" persist="hidden width"/>
@ -319,7 +152,7 @@
<!-- console view --> <!-- console view -->
<vbox id="console-box" flex="50" persist="width"> <vbox id="console-box" flex="50" persist="width">
<iframe id="output-iframe" flex="1" tooltip="tooltip-popup" <iframe id="output-iframe" flex="1" tooltip="aTooltip"
ondraggesture= ondraggesture=
"nsDragAndDrop.startDrag(event, contentAreaDNDObserver);" "nsDragAndDrop.startDrag(event, contentAreaDNDObserver);"
src="chrome://venkman/content/venkman-output-window.html" src="chrome://venkman/content/venkman-output-window.html"
@ -331,5 +164,7 @@
</hbox> </hbox>
</box> </box>
<overlaytarget id="statusbar-overlay-target"/>
</window> </window>

Просмотреть файл

@ -3,7 +3,10 @@ venkman.jar:
locale/en-US/venkman/contents.rdf (locale/en-US/contents.rdf) locale/en-US/venkman/contents.rdf (locale/en-US/contents.rdf)
skin/modern/venkman/contents.rdf (skin/contents.rdf) skin/modern/venkman/contents.rdf (skin/contents.rdf)
content/venkman/venkman.xul (content/venkman.xul) content/venkman/venkman.xul (content/venkman.xul)
content/venkman/venkman-menus.xul (content/venkman-menus.xul)
content/venkman/venkman-scripts.xul (content/venkman-scripts.xul)
content/venkman/venkman-utils.js (content/venkman-utils.js) content/venkman/venkman-utils.js (content/venkman-utils.js)
content/venkman/venkman-dev.js (content/venkman-dev.js)
content/venkman/venkman-handlers.js (content/venkman-handlers.js) content/venkman/venkman-handlers.js (content/venkman-handlers.js)
content/venkman/venkman-static.js (content/venkman-static.js) content/venkman/venkman-static.js (content/venkman-static.js)
content/venkman/venkman-debugger.js (content/venkman-debugger.js) content/venkman/venkman-debugger.js (content/venkman-debugger.js)
@ -45,18 +48,19 @@ venkman.jar:
skin/modern/venkman/images/step-over-hov.png (skin/images/step-over-hov.png) skin/modern/venkman/images/step-over-hov.png (skin/images/step-over-hov.png)
skin/modern/venkman/images/step-over-act.png (skin/images/step-over-act.png) skin/modern/venkman/images/step-over-act.png (skin/images/step-over-act.png)
skin/modern/venkman/images/step-over-dis.png (skin/images/step-over-dis.png) skin/modern/venkman/images/step-over-dis.png (skin/images/step-over-dis.png)
skin/modern/venkman/images/step-out.png (skin/images/step-out.png) skin/modern/venkman/images/step-out.png (skin/images/step-out.png)
skin/modern/venkman/images/step-out-hov.png (skin/images/step-out-hov.png) skin/modern/venkman/images/step-out-hov.png (skin/images/step-out-hov.png)
skin/modern/venkman/images/step-out-act.png (skin/images/step-out-act.png) skin/modern/venkman/images/step-out-act.png (skin/images/step-out-act.png)
skin/modern/venkman/images/step-out-dis.png (skin/images/step-out-dis.png) skin/modern/venkman/images/step-out-dis.png (skin/images/step-out-dis.png)
skin/modern/venkman/images/breakpoint-line.gif (skin/images/breakpoint-line.gif) skin/modern/venkman/images/breakpoint-line.gif (skin/images/breakpoint-line.gif)
skin/modern/venkman/images/proj-blacklist.png (skin/images/proj-blacklist.png) skin/modern/venkman/images/code-line.gif (skin/images/code-line.gif)
skin/modern/venkman/images/proj-bl-item.png (skin/images/proj-bl-item.png) skin/modern/venkman/images/proj-blacklist.png (skin/images/proj-blacklist.png)
skin/modern/venkman/images/proj-bl-item.png (skin/images/proj-bl-item.png)
skin/modern/venkman/images/proj-breakpoints.png (skin/images/proj-breakpoints.png) skin/modern/venkman/images/proj-breakpoints.png (skin/images/proj-breakpoints.png)
skin/modern/venkman/images/proj-breakpoint.png (skin/images/proj-breakpoint.png) skin/modern/venkman/images/proj-breakpoint.png (skin/images/proj-breakpoint.png)
skin/modern/venkman/images/file-function.png (skin/images/file-function.png) skin/modern/venkman/images/file-function.png (skin/images/file-function.png)
skin/modern/venkman/images/file-function-bp.png (skin/images/file-function-bp.png) skin/modern/venkman/images/file-function-bp.png (skin/images/file-function-bp.png)
skin/modern/venkman/images/file-function-guess.png (skin/images/file-function-guess.png) skin/modern/venkman/images/file-function-guess.png (skin/images/file-function-guess.png)
skin/modern/venkman/images/file-function-guess-bp.png (skin/images/file-function-guess-bp.png) skin/modern/venkman/images/file-function-guess-bp.png (skin/images/file-function-guess-bp.png)
skin/modern/venkman/images/file-unknown.png (skin/images/file-unknown.png) skin/modern/venkman/images/file-unknown.png (skin/images/file-unknown.png)
skin/modern/venkman/images/file-js.png (skin/images/file-js.png) skin/modern/venkman/images/file-js.png (skin/images/file-js.png)

Просмотреть файл

@ -73,6 +73,8 @@
<!ENTITY DebugBar.tooltip "Debugging Toolbar"> <!ENTITY DebugBar.tooltip "Debugging Toolbar">
<!ENTITY MenuBar.tooltip "Menu Bar"> <!ENTITY MenuBar.tooltip "Menu Bar">
<!ENTITY StatusText.label "Welcome to the JavaScript Debugger">
<!-- source outliner --> <!-- source outliner -->
<!ENTITY SourceCol0.display "Margin"> <!ENTITY SourceCol0.display "Margin">
<!ENTITY SourceCol1.display "Line Number"> <!ENTITY SourceCol1.display "Line Number">

Просмотреть файл

@ -63,6 +63,11 @@ msg.break.rec = Breakpoints
msg.callstack = Call Stack msg.callstack = Call Stack
## messages ## ## messages ##
msg.status.default = Welcome to the JavaScript Debugger
msg.status.loading = Loading source for ``%1$S''
msg.status.marking = Marking source for ``%1$S''
msg.status.stopped = Stopped in %1$S, %2$S
msg.stop = Stopped for %1$S. msg.stop = Stopped for %1$S.
msg.cont = Continuing from %1$S. msg.cont = Continuing from %1$S.
msg.subscript.load = <%1$S> Subscript loaded. msg.subscript.load = <%1$S> Subscript loaded.

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 111 B

После

Ширина:  |  Высота:  |  Размер: 110 B

Двоичные данные
extensions/venkman/resources/skin/images/code-line.gif Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 73 B

Просмотреть файл

@ -149,49 +149,36 @@
outlinerbody:-moz-outliner-cell(breakpoint-col) { outlinerbody:-moz-outliner-cell(breakpoint-col) {
background: #CCCCCC; background: #CCCCCC;
} border-right: 1px grey solid;
outlinerbody:-moz-outliner-cell(breakpoint-col, func-line) {
background: #EEEEEE;
}
outlinerbody:-moz-outliner-cell(breakpoint-col, func-start) {
border-top: 1px grey solid;
}
outlinerbody:-moz-outliner-cell(breakpoint-col, func-after) {
border-top: 1px grey solid;
} }
outlinerbody:-moz-outliner-cell(source-line-number) { outlinerbody:-moz-outliner-cell(source-line-number) {
border-left: 1px grey solid; border-right: 2px #CCCCCC solid;
border-right: 3px #CCCCCC solid;
text-align: right; text-align: right;
background: #EEEEEE; background: #EEEEEE;
} }
outlinerbody:-moz-outliner-cell(source-line-number, func-line) { outlinerbody:-moz-outliner-row(current-line, selected) {
border-right: 3px #EEEEEE solid; background: green !important;
background: white;
} }
outlinerbody:-moz-outliner-cell(source-line-number, func-start) { outlinerbody:-moz-outliner-cell(source-line-number, highlight-start),
border-top: 1px grey solid; outlinerbody:-moz-outliner-cell(source-line-number, highlight-range),
outlinerbody:-moz-outliner-cell(source-line-number, highlight-end) {
border-right: 2px #919bd6 solid;
background: #d5d5e0;
} }
outlinerbody:-moz-outliner-cell(source-line-number, func-after) { outlinerbody:-moz-outliner-cell(source-line-text, highlight-start),
border-top: 1px grey solid; outlinerbody:-moz-outliner-cell(source-line-text, highlight-range),
outlinerbody:-moz-outliner-cell(source-line-text, highlight-end) {
border-left: 1px black solid;
background: #EEEEEE;
} }
outlinerbody:-moz-outliner-cell(source-line-number,current-line) { outlinerbody:-moz-outliner-cell(source-line-text, selected),
background: yellow; outlinerbody:-moz-outliner-cell(source-line-number, selected) {
} border-left: inherit !important;
outlinerbody:-moz-outliner-cell(source-line-number,current-line,current) {
background: green;
}
outlinerbody:-moz-outliner-cell(source-line-number,current) {
background: inherit !important; background: inherit !important;
} }
@ -199,15 +186,16 @@ outlinerbody:-moz-outliner-row {
border: 0px; border: 0px;
} }
outlinerbody:-moz-outliner-row(current-line) { outlinerbody:-moz-outliner-cell(source-line-number, current-line),
background: yellow; outlinerbody:-moz-outliner-cell(source-line-text, current-line) {
background: #ecef34;
} }
outlinerbody:-moz-outliner-row(current-line,current) { outlinerbody:-moz-outliner-image(breakpoint-col, code) {
background: green; list-style-image: url("chrome://venkman/skin/images/code-line.gif");
} }
outlinerbody:-moz-outliner-image(breakpoint) { outlinerbody:-moz-outliner-image(breakpoint-col, breakpoint) {
list-style-image: url("chrome://venkman/skin/images/breakpoint-line.gif"); list-style-image: url("chrome://venkman/skin/images/breakpoint-line.gif");
} }