Skip to content
Browse files

Initialized variables before using them and removed unused variables

  • Loading branch information...
1 parent d0d4518 commit 3118f395a2e7d9845e663b1b6071a4b95be74c7f @SebastianZ SebastianZ committed Jan 4, 2013
Showing with 162 additions and 205 deletions.
  1. +10 −3 extension/build.js
  2. +5 −10 extension/content/firebug/accessible/a11y.js
  3. +1 −5 extension/content/firebug/bti/inProcess/browser.js
  4. +1 −7 extension/content/firebug/chrome/chrome.js
  5. +0 −1 extension/content/firebug/chrome/firefox.js
  6. +4 −2 extension/content/firebug/chrome/tabWatcher.js
  7. +7 −8 extension/content/firebug/chrome/tableRep.js
  8. +2 −2 extension/content/firebug/chrome/window.js
  9. +2 −4 extension/content/firebug/console/commandEditor.js
  10. +5 −5 extension/content/firebug/console/commandLineExposed.js
  11. +25 −26 extension/content/firebug/console/consoleExposed.js
  12. +3 −2 extension/content/firebug/console/eventMonitor.js
  13. +2 −2 extension/content/firebug/console/memoryProfiler.js
  14. +0 −1 extension/content/firebug/cookies/cookieClipboard.js
  15. +0 −1 extension/content/firebug/cookies/headerResizer.js
  16. +0 −1 extension/content/firebug/cookies/legacy.js
  17. +3 −4 extension/content/firebug/dom/toggleBranch.js
  18. +4 −4 extension/content/firebug/firefox/browserOverlayLib.js
  19. +1 −3 extension/content/firebug/firefox/customizeShortcuts.js
  20. +1 −4 extension/content/firebug/html/layout.js
  21. +7 −9 extension/content/firebug/js/breakpoint.js
  22. +14 −15 extension/content/firebug/js/sourceBox.js
  23. +5 −5 extension/content/firebug/js/stackFrame.js
  24. +1 −1 extension/content/firebug/lib/dom.js
  25. +4 −4 extension/content/firebug/lib/domplate.js
  26. +1 −1 extension/content/firebug/lib/dragdrop.js
  27. +0 −4 extension/content/firebug/lib/fonts.js
  28. +0 −4 extension/content/firebug/lib/json.js
  29. +0 −1 extension/content/firebug/lib/object.js
  30. +7 −8 extension/content/firebug/lib/options.js
  31. +2 −2 extension/content/firebug/lib/search.js
  32. +0 −1 extension/content/firebug/lib/system.js
  33. +0 −4 extension/content/firebug/lib/wrapper.js
  34. +36 −31 extension/content/firebug/lib/xml.js
  35. +0 −4 extension/content/firebug/lib/xpath.js
  36. +4 −3 extension/modules/firebug-service.js
  37. +0 −2 extension/modules/mini-require.js
  38. +3 −10 extension/modules/prefLoader.js
  39. +2 −1 extension/modules/require-debug.js
View
13 extension/build.js
@@ -414,7 +414,7 @@ function clean()
function zip(filename, directory, callback)
{
// Create final XPI package.
- var zip;
+ var zip = null;
if (os.platform() === "win32")
{
var params = "a -tzip " + filename + " " + directory + "/*";
@@ -426,10 +426,17 @@ function zip(filename, directory, callback)
//zip = spawn("zip", [ "-r", __dirname + "/" + xpiFileName, release ]);
}
- zip.on("exit", function()
+ if (zip)
+ {
+ zip.on("exit", function()
+ {
+ callback();
+ });
+ }
+ else
{
callback();
- });
+ }
}
// ********************************************************************************************* //
View
15 extension/content/firebug/accessible/a11y.js
@@ -466,7 +466,7 @@ Firebug.A11yModel = Obj.extend(Firebug.Module,
var isButton = target.nodeName.search(/(xul:)?((toolbar)?button)|(checkbox)/) != -1;
var isDropDownMenu = isButton && (target.getAttribute("type") == "menu" ||
target.id == "fbLocationList");
- var siblingTab, forward, toolbar, buttons;
+ var siblingTab, forward, toolbar;
var keyCode = event.keyCode || (event.type == "keypress" ? event.charCode : null);
if (keyCode == KeyEvent.DOM_VK_TAB)
this.ensurePanelTabStops(); //TODO: need a better solution to prevent loss of panel tabstop
@@ -1176,10 +1176,10 @@ Firebug.A11yModel = Obj.extend(Firebug.Module,
case KeyEvent.DOM_VK_RETURN:
case KeyEvent.DOM_VK_SPACE:
var isEnter = (keyCode == KeyEvent.DOM_VK_RETURN);
- var nodeLabels = null;
+ var nodeLabels = [];
if (isEnter)
{
- var nodeLabels = target.getElementsByClassName("nodeName");
+ nodeLabels = target.getElementsByClassName("nodeName");
if (nodeLabels.length > 0)
{
Firebug.Editor.startEditing(nodeLabels[0]);
@@ -1684,7 +1684,6 @@ Firebug.A11yModel = Obj.extend(Firebug.Module,
return;
}
var matchFeedback = "";
- var matchType = "";
var selector;
if (Css.hasClass(matchRow, "cssSelector"))
{
@@ -1807,7 +1806,6 @@ Firebug.A11yModel = Obj.extend(Firebug.Module,
if (!Css.hasClass(target, "focusGroup"))
return;
- var panel = Firebug.getElementPanel(target);
switch (keyCode)
{
case KeyEvent.DOM_VK_LEFT:
@@ -1872,7 +1870,7 @@ Firebug.A11yModel = Obj.extend(Firebug.Module,
switch (panelA11y.type)
{
case "html":
- var tagName= nodeName = null;
+ var nodeName = null;
var setSize = posInSet = 0; var setElems;
var label = Locale.$STR("a11y.labels.inline editor") + ": ";
if (Css.hasClass(target, "nodeName") || Css.hasClass(target, "nodeValue"))
@@ -2056,7 +2054,6 @@ Firebug.A11yModel = Obj.extend(Firebug.Module,
var lineNo = parseInt(lineNode.getElementsByClassName("sourceLine").item(0).textContent);
box.a11yCaretLine = lineNo;
box.a11yCaretOffset = caretDetails[1];
- var newLineNo = 1;
var linesToScroll = 0;
var goUp;
switch (keyCode)
@@ -2134,7 +2131,7 @@ Firebug.A11yModel = Obj.extend(Firebug.Module,
liveString += "Line " + lineNo;
if (lineNode.getAttribute("breakpoint") == "true")
{
- var breakpointStr;
+ var breakpointStr = "";
if (lineNode.getAttribute("disabledbreakpoint") == "true")
breakpointStr = "a11y.updates.has disabled breakpoint";
if (lineNode.getAttribute("condition") == "true")
@@ -2423,8 +2420,6 @@ Firebug.A11yModel = Obj.extend(Firebug.Module,
if (!panelA11y || !rows)
return;
- var setSize;
- var posInset;
var setSize = rows.length;
var posInset = 0;
for (var i = 0; i < rows.length; i++)
View
6 extension/content/firebug/bti/inProcess/browser.js
@@ -242,10 +242,8 @@ Browser.prototype.closeContext = function(context, userCommands)
if (shouldDispatch)
{
- var userCommands;
-
// TODO remove
- Events.dispatch(TabWatcher.fbListeners, "unwatchBrowser", [browser, userCommands]);
+ Events.dispatch(TabWatcher.fbListeners, "unwatchBrowser", [browser, null]);
return true;
}
return false;
@@ -689,8 +687,6 @@ Browser.EventListener = {
// ********************************************************************************************* //
-var clearContextTimeout = 0;
-
var TabWatchListener =
{
dispatchName: "TabWatchListener",
View
8 extension/content/firebug/chrome/chrome.js
@@ -70,12 +70,6 @@ createFirebugChrome: function(win)
var panelSplitter, sidePanelDeck, panelBar1, panelBar2;
- var disabledHead = null;
- var disabledCaption = null;
- var enableSiteLink = null;
- var enableSystemPagesLink = null;
- var enableAlwaysLink = null;
-
var FirebugChrome =
{
// TODO: remove this property, add getters for location, title, focusedElement, setter popup
@@ -776,7 +770,7 @@ var FirebugChrome =
getSelectedPanelURL: function()
{
- var location;
+ var location = null;
if (Firebug.currentContext)
{
var panel = Firebug.chrome.getSelectedPanel();
View
1 extension/content/firebug/chrome/firefox.js
@@ -7,7 +7,6 @@ define([], function() {
var Ci = Components.interfaces;
var Cc = Components.classes;
-var Cu = Components.utils;
var wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
// ********************************************************************************************* //
View
6 extension/content/firebug/chrome/tabWatcher.js
@@ -655,7 +655,7 @@ Firebug.TabWatcher = Obj.extend(new Firebug.Listener(),
}
Events.dispatch(this.fbListeners, "destroyContext",
- [null, (browser?browser.persistedState:null), browser]);
+ [null, (browser ? browser.persistedState : null), browser]);
return;
}
@@ -670,9 +670,11 @@ Firebug.TabWatcher = Obj.extend(new Firebug.Listener(),
Events.dispatch(this.fbListeners, "destroyContext", [context, persistedState, context.browser]);
if (FBTrace.DBG_WINDOWS || FBTrace.DBG_ACTIVATION)
+ {
FBTrace.sysout("-> tabWatcher.unwatchContext *** DESTROY *** context " + context.uid +
" for: " + (context.window && !context.window.closed?context.window.location :
"no window or closed ") + " aborted: " + context.aborted);
+ }
context.destroy(persistedState);
@@ -687,7 +689,7 @@ Firebug.TabWatcher = Obj.extend(new Firebug.Listener(),
if (!currentBrowser.showFirebug)
{
// context is null if we don't want to debug this browser
- Events.dispatch(this.fbListeners, "showContext", [browser, null]);
+ Events.dispatch(this.fbListeners, "showContext", [currentBrowser, null]);
}
},
View
15 extension/content/firebug/chrome/tableRep.js
@@ -71,6 +71,7 @@ FirebugReps.Table = domplate(Firebug.Rep,
return [row];
var cols = [];
+ var value = null;
for (var i=0; i<this.columns.length; i++)
{
var prop = this.columns[i].property;
@@ -88,7 +89,7 @@ FirebugReps.Table = domplate(Firebug.Rep,
{
var props = (typeof(prop) == "string") ? prop.split(".") : [prop];
- var value = row;
+ value = row;
for (var p in props)
value = (value && value[props[p]]) || undefined;
}
@@ -212,11 +213,11 @@ FirebugReps.Table = domplate(Firebug.Rep,
{
this.columns = columns;
- var object = object || {};
- object.data = data;
- object.columns = columns;
+ var obj = object || {};
+ obj.data = data;
+ obj.columns = columns;
- var row = Firebug.Console.log(object, context, "table", this, true);
+ var row = Firebug.Console.log(obj, context, "table", this, true);
// Set vertical height for scroll bar.
var tBody = row.querySelector(".dataTableTbody");
@@ -270,7 +271,7 @@ FirebugReps.Table = domplate(Firebug.Rep,
getHeaderColumns: function(data)
{
// Get the first row in the object.
- var firstRow;
+ var firstRow = null;
for (var p in data)
{
firstRow = data[p];
@@ -306,8 +307,6 @@ FirebugReps.Table = domplate(Firebug.Rep,
*/
domFilter: function(object, name)
{
- var domMembers = Dom.getDOMMembers(object, name);
-
if (typeof(object) == "function")
{
if (Dom.isDOMMember(object, name) && !Firebug.showDOMFuncs)
View
4 extension/content/firebug/chrome/window.js
@@ -12,7 +12,6 @@ function(FBTrace, Http, Firefox) {
var Ci = Components.interfaces;
var Cc = Components.classes;
-var Cu = Components.utils;
var wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
@@ -188,11 +187,12 @@ Win.getBrowserByWindow = function(win)
Win.getWindowId = function(win)
{
var util = win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
+ var outerWindowID = null;
var innerWindowID = "(none)";
try
{
- var outerWindowID = util.outerWindowID;
+ outerWindowID = util.outerWindowID;
innerWindowID = util.currentInnerWindowID;
}
catch(exc)
View
6 extension/content/firebug/console/commandEditor.js
@@ -15,8 +15,6 @@ function(Obj, Firebug, Events, Menu, Dom, Locale, Css, Options) {
// ********************************************************************************************* //
// Constants
-var Cc = Components.classes;
-var Ci = Components.interfaces;
var Cu = Components.utils;
var MODE_JAVASCRIPT = "js";
@@ -269,9 +267,9 @@ Firebug.CommandEditor = Obj.extend(Firebug.Module,
if (typeof(SourceEditor) != "undefined")
{
- var doc = this.editor._view._frame.contentDocument;
-
// See issue 5488
+ // var doc = this.editor._view._frame.contentDocument;
+
//doc.body.style.fontSizeAdjust = adjust;
}
else
View
10 extension/content/firebug/console/commandLineExposed.js
@@ -185,9 +185,9 @@ function createFirebugCommandLine(context, win)
function evaluate(expr, origExpr)
{
var result;
+ var line = Components.stack.lineNumber;
try
{
- var line = Components.stack.lineNumber;
@simonlindholm
Firebug Working Group member
simonlindholm added a note Jan 4, 2013

This is actually wrong - 'line' must be set just above the eval call to correct line numbers properly. I'll fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
result = contentView.eval(expr);
// See Issue 5221
@@ -198,8 +198,9 @@ function createFirebugCommandLine(context, win)
{
// change source and line number of exeptions from commandline code
// create new error since properties of nsIXPCException are not modifiable
- var shouldModify = false, isXPCException = false, dropFrames = false;
- var fileName = exc.filename || exc.fileName, lineNumber;
+ var shouldModify = false, isXPCException = false;
+ var fileName = exc.filename || exc.fileName;
+ var lineNumber = 0;
@simonlindholm
Firebug Working Group member
simonlindholm added a note Jan 4, 2013

(it's not used unless shouldModify, so I'd leave it - undefined is more obviously wrong than 0)

@SebastianZ
Firebug Working Group member
SebastianZ added a note Jan 7, 2013

I actually just did that to satisfy the JSDT validator. Otherwise it says that The local variable lineNumber may not have been initialized.
I could explicitly set var lineNumber = undefined;, which looks a bit strange in my eyes or simply ignore the warning and revert the change.
Opinions?

@simonlindholm
Firebug Working Group member
simonlindholm added a note Jan 7, 2013

I see. var lineNumber = null;?

@SebastianZ
Firebug Working Group member
SebastianZ added a note Jan 8, 2013

Yes. Changed in 944382b.

Sebastian

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
if (fileName.lastIndexOf("chrome:", 0) === 0)
{
if (fileName === Components.stack.filename)
@@ -211,7 +212,6 @@ function createFirebugCommandLine(context, win)
}
else if (exc._dropFrames)
{
- dropFrames = true;
lineNumber = findLineNumberInExceptionStack(exc.stack);
shouldModify = (lineNumber !== null);
}
@@ -265,7 +265,7 @@ function createFirebugCommandLine(context, win)
eventID + " with " + objs.length + " user objects", commandLine.userObjects);
}
- var result;
+ var result = null;
@simonlindholm
Firebug Working Group member
simonlindholm added a note Jan 4, 2013

This is visible to page scripts, right? I don't think you should make such changes. (var result = undefined; is explicit and fine, IMO.)

@SebastianZ
Firebug Working Group member
SebastianZ added a note Jan 7, 2013

This is visible to page scripts, right?

Is it? Anyway, for the sake of not changing the return value you're right that it's better to use undefined here.

Sebastian

@simonlindholm
Firebug Working Group member
simonlindholm added a note Jan 7, 2013

$0, etc.

@SebastianZ
Firebug Working Group member
SebastianZ added a note Jan 7, 2013

Ah, right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
if (Dom.getMappedData(contentView.document, "firebug-retValueType") === "array")
result = [];
View
51 extension/content/firebug/console/consoleExposed.js
@@ -195,6 +195,7 @@ function createFirebugConsole(context, win)
console.timeEnd = function(name)
{
var time = new Date().getTime();
+ var diff = 0;
@simonlindholm
Firebug Working Group member
simonlindholm added a note Jan 4, 2013

No, console.timeEnd("non-existent") should return undefined.

@SebastianZ
Firebug Working Group member
SebastianZ added a note Jan 7, 2013

Right. We should probably add an FBTest for this.

Sebastian

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
if (!this.timeCounters)
return Console.getDefaultReturnValue(win);
@@ -204,7 +205,7 @@ function createFirebugConsole(context, win)
var timeCounter = this.timeCounters[key];
if (timeCounter)
{
- var diff = time - timeCounter;
+ diff = time - timeCounter;
var label = name + ": " + diff + "ms";
this.info(label);
@@ -294,7 +295,7 @@ function createFirebugConsole(context, win)
function logFormatted(args, className, linkToSource, noThrottle)
{
- var sourceLink;
+ var sourceLink = null;
// Using JSD to get user stack is time consuming.
if (Options.get("preferJSDSourceLinks"))
@@ -316,33 +317,31 @@ function createFirebugConsole(context, win)
{
Errors.increaseCount(context);
- if (!args || !args.length || args.length == 0)
- var msg = [Locale.$STR("Assertion")];
- else
- var msg = args[0];
+ var msg = (!args || !args.length || args.length == 0) ?
+ [Locale.$STR("Assertion")] : args[0];
// If there's no error message, there's also no stack trace. See Issue 4700.
- if (!msg)
- {
- var trace = null;
- }
- else if (msg.stack)
- {
- var trace = StackFrame.parseToStackTrace(msg.stack, context);
- if (FBTrace.DBG_CONSOLE)
- FBTrace.sysout("logAssert trace from msg.stack", trace);
- }
- else if (context.stackTrace)
- {
- var trace = context.stackTrace;
- if (FBTrace.DBG_CONSOLE)
- FBTrace.sysout("logAssert trace from context.window.stackTrace", trace);
- }
- else
+ var trace = null;
+ if (msg)
{
- var trace = getJSDUserStack();
- if (FBTrace.DBG_CONSOLE)
- FBTrace.sysout("logAssert trace from getJSDUserStack", trace);
+ if (msg.stack)
+ {
+ trace = StackFrame.parseToStackTrace(msg.stack, context);
+ if (FBTrace.DBG_CONSOLE)
+ FBTrace.sysout("logAssert trace from msg.stack", trace);
+ }
+ else if (context.stackTrace)
+ {
+ trace = context.stackTrace;
+ if (FBTrace.DBG_CONSOLE)
+ FBTrace.sysout("logAssert trace from context.window.stackTrace", trace);
+ }
+ else
+ {
+ trace = getJSDUserStack();
+ if (FBTrace.DBG_CONSOLE)
+ FBTrace.sysout("logAssert trace from getJSDUserStack", trace);
+ }
}
trace = StackFrame.cleanStackTraceOfFirebug(trace);
View
5 extension/content/firebug/console/eventMonitor.js
@@ -113,10 +113,11 @@ var EventMonitor = Obj.extend(Firebug.Module,
return false;
}
+ var eventTypes = [];
@simonlindholm
Firebug Working Group member
simonlindholm added a note Jan 4, 2013

Always set, no need to create a default.

@SebastianZ
Firebug Working Group member
SebastianZ added a note Jan 7, 2013

Same reason as before. The JSDT validator complains that the variable may not be initialized.

Sebastian

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
if (!types)
- var eventTypes = Events.getEventTypes();
+ eventTypes = Events.getEventTypes();
else
- var eventTypes = typeof types == "string" ? [types] : types;
+ eventTypes = typeof types == "string" ? [types] : types;
for (var i = 0; i < eventTypes.length; ++i)
{
View
4 extension/content/firebug/console/memoryProfiler.js
@@ -22,7 +22,7 @@ var Ci = Components.interfaces;
var RETURN_CONTINUE = Ci.jsdIExecutionHook.RETURN_CONTINUE;
-var memoryReporterManager;
+var memoryReporterManager = null;
try
{
@@ -170,7 +170,7 @@ Firebug.MemoryProfiler = Obj.extend(Firebug.Module,
if (!cancelReport)
{
var title = Locale.$STR("firebug.Objects Added While Profiling");
- var row = Firebug.Console.openCollapsedGroup(title, context, "profile",
+ Firebug.Console.openCollapsedGroup(title, context, "profile",
Firebug.MemoryProfiler.ProfileCaption, true, null, true);
Firebug.Console.log(deltaObjects, context, "memoryDelta", Firebug.DOMPanel.DirTable);
View
1 extension/content/firebug/cookies/cookieClipboard.js
@@ -9,7 +9,6 @@ function(Obj, Xpcom) {
// ********************************************************************************************* //
// Constants
-var Cc = Components.classes;
var Ci = Components.interfaces;
var clipboard = Xpcom.CCSV("@mozilla.org/widget/clipboard;1", "nsIClipboard");
View
1 extension/content/firebug/cookies/headerResizer.js
@@ -121,7 +121,6 @@ var HeaderResizer =
{
var target = event.target;
var x = event.clientX;
- var y = event.clientY;
var column = Dom.getAncestorByClass(target, "cookieHeaderCell");
var offset = Dom.getClientOffset(column);
View
1 extension/content/firebug/cookies/legacy.js
@@ -11,7 +11,6 @@ function(Obj, Xpcom, Locale, Win) {
// ********************************************************************************************* //
// Constants
-var Cc = Components.classes;
var Ci = Components.interfaces;
Components.utils.import("resource://gre/modules/AddonManager.jsm");
View
7 extension/content/firebug/dom/toggleBranch.js
@@ -48,12 +48,11 @@ ToggleBranch.prototype =
get: function(name) // return the toggle branch at name
{
var metaName = this.getMeta(name);
+ var value = null;
if (metaName)
- var value = this.meta[metaName];
+ value = this.meta[metaName];
else if (this.normal.hasOwnProperty(name))
- var value = this.normal[name];
- else
- var value = null;
+ value = this.normal[name];
if (FBTrace.DBG_DOMPLATE)
if (value && !(value instanceof ToggleBranch))
View
8 extension/content/firebug/firefox/browserOverlayLib.js
@@ -11,7 +11,6 @@ function(FBTrace, Locale) {
var Cc = Components.classes;
var Ci = Components.interfaces;
-var Cu = Components.utils;
// ********************************************************************************************* //
// Overlay Helpers
@@ -138,7 +137,7 @@ var BrowserOverlayLib =
for (var i=0; i<children.length; ++i)
{
var child = children[i];
- var beforeEl;
+ var beforeEl = null;
if (child.getAttribute("position"))
{
@@ -185,7 +184,7 @@ var BrowserOverlayLib =
attrs.id = id;
// in seamonkey gNavToolbox is null onload
- var button = this.$el(doc, "toolbarbutton", attrs, children,
+ this.$el(doc, "toolbarbutton", attrs, children,
(doc.defaultView.gNavToolbox || this.$(doc, "navigator-toolbox")).palette);
var selector = "[currentset^='" + id + ",'],[currentset*='," + id +
@@ -198,7 +197,8 @@ var BrowserOverlayLib =
var currentset = toolbar.getAttribute("currentset").split(",");
var i = currentset.indexOf(id) + 1;
- var len = currentset.length, beforeEl;
+ var len = currentset.length;
+ var beforeEl = null;
while (i < len && !(beforeEl = this.$(doc, currentset[i])))
i++;
View
4 extension/content/firebug/firefox/customizeShortcuts.js
@@ -88,10 +88,8 @@ function setKeyInfo()
gPlatformKeys.accel = (window.navigator.platform.search("Mac") == 0 ? gPlatformKeys.meta : gPlatformKeys.ctrl);
}
- for ( var property in KeyEvent)
- {
+ for (var property in KeyEvent)
gVKNames[KeyEvent[property]] = property.replace("DOM_", "");
- }
gVKNames[8] = "VK_BACK";
}
View
5 extension/content/firebug/html/layout.js
@@ -299,9 +299,6 @@ LayoutPanel.prototype = Obj.extend(Firebug.Panel,
if (!view)
return this.panelNode.textContent = "";
- var prev = Dom.getPreviousElement(element.previousSibling);
- var next = Dom.getNextElement(element.nextSibling);
-
var style = view.getComputedStyle(element, "");
var args = Css.getBoxFromStyles(style, element);
@@ -352,7 +349,7 @@ LayoutPanel.prototype = Obj.extend(Firebug.Panel,
"absoluteEdge";
}
- var node;
+ var node = null;
// If the layout panel content was already created, just fill in the new values
if (this.panelNode.getElementsByClassName("outerLayoutBox").item(0))
{
View
16 extension/content/firebug/js/breakpoint.js
@@ -484,7 +484,7 @@ Firebug.Breakpoint.BreakpointsPanel.prototype = Obj.extend(Firebug.Panel,
{
if (this.context.loaded)
{
- var state;
+ var state = null;
Persist.restoreObjects(this, state);
if (state)
@@ -576,7 +576,6 @@ Firebug.Breakpoint.BreakpointsPanel.prototype = Obj.extend(Firebug.Panel,
var monitors = [];
var renamer = new SourceFileRenamer(context);
- var self = this;
var Breakpoint = Firebug.Debugger.Breakpoint;
for (var url in context.sourceFileMap)
@@ -591,6 +590,8 @@ Firebug.Breakpoint.BreakpointsPanel.prototype = Obj.extend(Firebug.Panel,
if (renamer.checkForRename(url, line, props))
return;
+ var isFuture = false;
+ var name = "";
if (scripts) // then this is a current (not future) breakpoint
{
var script = scripts[0];
@@ -600,20 +601,17 @@ Firebug.Breakpoint.BreakpointsPanel.prototype = Obj.extend(Firebug.Panel,
script.tag+(analyzer?" has analyzer":" no analyzer")+" in context "+
context.getName());
- if (analyzer)
- var name = analyzer.getFunctionDescription(script, context).name;
- else
- var name = StackFrame.guessFunctionName(url, 1, context);
-
- var isFuture = false;
+ name = analyzer ?
+ analyzer.getFunctionDescription(script, context).name :
+ StackFrame.guessFunctionName(url, 1, context);
}
else
{
if (FBTrace.DBG_BP)
FBTrace.sysout("breakpoints.refresh enumerateBreakpoints future for url@line="+
url+"@"+line+"\n");
- var isFuture = true;
+ isFuture = true;
}
var source = context.sourceCache.getLine(url, line);
View
29 extension/content/firebug/js/sourceBox.js
@@ -698,9 +698,10 @@ Firebug.SourceBoxPanel = Obj.extend(SourceBoxPanelBase,
// called for all scroll events, including any time sourcebox.scrollTop is set
reView: function(sourceBox, clearCache)
{
+ var viewRange = null;
if (sourceBox.targetedLineNumber) // then we requested a certain line
{
- var viewRange = this.getViewRangeFromTargetLine(sourceBox, sourceBox.targetedLineNumber);
+ viewRange = this.getViewRangeFromTargetLine(sourceBox, sourceBox.targetedLineNumber);
if (FBTrace.DBG_COMPILATION_UNITS)
FBTrace.sysout("reView got viewRange from target line: "+
sourceBox.targetedLineNumber, viewRange);
@@ -713,7 +714,7 @@ Firebug.SourceBoxPanel = Obj.extend(SourceBoxPanelBase,
}
else // no special line, assume scrolling
{
- var viewRange = this.getViewRangeFromScrollTop(sourceBox, sourceBox.scrollTop);
+ viewRange = this.getViewRangeFromScrollTop(sourceBox, sourceBox.scrollTop);
if (FBTrace.DBG_COMPILATION_UNITS)
FBTrace.sysout("reView got viewRange from scrollTop: "+sourceBox.scrollTop, viewRange);
}
@@ -842,7 +843,7 @@ Firebug.SourceBoxPanel = Obj.extend(SourceBoxPanelBase,
ref = topCacheLine;
}
- var newElement = Dom.appendInnerHTML(sourceBox.viewport, lineHTML, ref);
+ Dom.appendInnerHTML(sourceBox.viewport, lineHTML, ref);
}
return cacheHit;
},
@@ -1055,18 +1056,18 @@ Firebug.SourceBoxPanel = Obj.extend(SourceBoxPanelBase,
var averageLineHeight = this.getAverageLineHeight(sourceBox);
// total box will be the average line height times total lines
var virtualSourceBoxHeight = Math.floor(max * averageLineHeight);
- if (virtualSourceBoxHeight < sourceBox.clientHeight)
- {
- // the total - view-taken-up - scrollbar
- // clientHeight excludes scrollbar
- var totalPadding = sourceBox.clientHeight - sourceBox.viewport.clientHeight - 1;
- }
- else
- var totalPadding = virtualSourceBoxHeight - sourceBox.viewport.clientHeight;
+
+ // the total - view-taken-up - scrollbar
+ // clientHeight excludes scrollbar
+ var totalPadding = virtualSourceBoxHeight < sourceBox.clientHeight ?
+ sourceBox.clientHeight - 1 : virtualSourceBoxHeight;
+ totalPadding -= sourceBox.viewport.clientHeight;
if (FBTrace.DBG_COMPILATION_UNITS)
+ {
FBTrace.sysout("getTotalPadding clientHeight:"+sourceBox.viewport.clientHeight+
" max: "+max+" gives total padding "+totalPadding);
+ }
return totalPadding;
},
@@ -1099,10 +1100,8 @@ Firebug.SourceBoxPanel = Obj.extend(SourceBoxPanelBase,
// we want the bottomPadding to take up the rest
var totalPadding = this.getTotalPadding(sourceBox);
- if (totalPadding < 0)
- var bottomPadding = Math.abs(totalPadding);
- else
- var bottomPadding = Math.floor(totalPadding - topPadding);
+ var bottomPadding = totalPadding < 0 ?
+ Math.abs(totalPadding) : Math.floor(totalPadding - topPadding);
if (bottomPadding < 0)
bottomPadding = 0;
View
10 extension/content/firebug/js/stackFrame.js
@@ -27,9 +27,10 @@ StackFrame.getStackTrace = Deprecated.deprecated("name change for self-documenta
*/
StackFrame.getCorrectedStackTrace = function(frame, context)
{
+ var trace = null;
try
{
- var trace = new StackFrame.StackTrace();
+ trace = new StackFrame.StackTrace();
var newestFrame = null;
var nextOlderFrame = null;
for (; frame && frame.isValid; frame = frame.callingFrame)
@@ -641,10 +642,9 @@ StackFrame.guessFunctionNameFromLines = function(url, lineNo, sourceCache)
// Mozilla
StackFrame.getFunctionArgValues = function(frame)
{
- if (frame.isValid && frame.scope.jsClassName == "Call")
- var values = StackFrame.getArgumentsFromCallScope(frame);
- else
- var values = StackFrame.getArgumentsFromObjectScope(frame);
+ var values = (frame.isValid && frame.scope.jsClassName == "Call") ?
+ StackFrame.getArgumentsFromCallScope(frame) :
+ StackFrame.getArgumentsFromObjectScope(frame);
if (FBTrace.DBG_STACK)
FBTrace.sysout("stackFrame.getFunctionArgValues "+frame+" scope: "+frame.scope.jsClassName,
View
2 extension/content/firebug/lib/dom.js
@@ -1920,7 +1920,7 @@ domMemberMap.Event =
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-var domConstantMap = Dom.domConstantMap =
+Dom.domConstantMap =
{
"ELEMENT_NODE": 1,
"ATTRIBUTE_NODE": 1,
View
8 extension/content/firebug/lib/domplate.js
@@ -36,7 +36,7 @@ var uid = 0;
// xxxHonza: the only global should be Firebug object.
var domplate = function()
{
- var lastSubject;
+ var lastSubject = null;
for (var i = 0; i < arguments.length; ++i)
lastSubject = lastSubject ? copyObject(lastSubject, arguments[i]) : arguments[i];
@@ -256,7 +256,7 @@ DomplateTag.prototype =
if (isArray(iter) || iter instanceof NodeList)
iter = new ArrayIterator(iter);
- var value;
+ var value = null;
try
{
while (1)
@@ -483,7 +483,6 @@ DomplateTag.prototype =
return tag.tag.renderDOM.apply(tag.tag.subject, domArgs);
}
- var self = this;
function __loop__(iter, fn)
{
var nodeCount = 0;
@@ -1085,7 +1084,8 @@ var Renderer =
var parent = before.localName.toLowerCase() == "tr" ? before.parentNode : before;
var after = before.localName.toLowerCase() == "tr" ? before.nextSibling : null;
- var firstRow = tbody.firstChild, lastRow;
+ var firstRow = tbody.firstChild;
+ var lastRow = null;
while (tbody.firstChild)
{
lastRow = tbody.firstChild;
View
2 extension/content/firebug/lib/dragdrop.js
@@ -67,7 +67,7 @@ Tracker.prototype =
var newPos = absoluteCursorPostion(event);
//newPos = newPos.Add(this.elementStartPos);
- var newPos = newPos.Subtract(this.cursorStartPos);
+ newPos = newPos.Subtract(this.cursorStartPos);
//newPos = newPos.Bound(lowerBound, upperBound);
//newPos.Apply(this.element);
View
4 extension/content/firebug/lib/fonts.js
@@ -10,10 +10,6 @@ function(FBTrace, Dom, Url) {
// ********************************************************************************************* //
// Constants
-var Ci = Components.interfaces;
-var Cc = Components.classes;
-var Cu = Components.utils;
-
var Fonts = {};
// ********************************************************************************************* //
View
4 extension/content/firebug/lib/json.js
@@ -8,10 +8,6 @@ function(FBTrace) {
// ********************************************************************************************* //
// Constants
-var Ci = Components.interfaces;
-var Cc = Components.classes;
-var Cu = Components.utils;
-
var Json = {};
// ********************************************************************************************* //
View
1 extension/content/firebug/lib/object.js
@@ -119,7 +119,6 @@ Obj.hasProperties = function(ob, nonEnumProps, ownPropsOnly)
return false;
// Climb prototype chain.
- var inheritedProps = [];
var parent = Object.getPrototypeOf(ob);
if (parent)
return this.hasProperties(parent, nonEnumProps, ownPropsOnly);
View
15 extension/content/firebug/lib/options.js
@@ -245,7 +245,7 @@ var Options =
var type = prefs.getPrefType(prefName);
- var value;
+ var value = null;
if (type == nsIPrefBranch.PREF_STRING)
value = prefs.getCharPref(prefName);
else if (type == nsIPrefBranch.PREF_INT)
@@ -309,20 +309,19 @@ var Options =
getPreferenceTypeByExample: function(prefType)
{
+ var type = nsIPrefBranch.PREF_INVALID;
if (prefType)
{
if (prefType === typeof("s"))
- var type = nsIPrefBranch.PREF_STRING;
+ type = nsIPrefBranch.PREF_STRING;
else if (prefType === typeof(1))
- var type = nsIPrefBranch.PREF_INT;
- else if (prefType === typeof (true))
- var type = nsIPrefBranch.PREF_BOOL;
- else
- var type = nsIPrefBranch.PREF_INVALID;
+ type = nsIPrefBranch.PREF_INT;
+ else if (prefType === typeof(true))
+ type = nsIPrefBranch.PREF_BOOL;
}
else
{
- var type = prefs.getPrefType(prefName);
+ type = prefs.getPrefType(prefName);
}
return type;
View
4 extension/content/firebug/lib/search.js
@@ -11,7 +11,6 @@ function(FBTrace, Options) {
var Ci = Components.interfaces;
var Cc = Components.classes;
-var Cu = Components.utils;
var Search = {};
@@ -31,7 +30,8 @@ var finder = Search.finder = Cc["@mozilla.org/embedcomp/rangefind;1"].createInst
Search.TextSearch = function(rootNode, rowFinder)
{
var doc = rootNode.ownerDocument;
- var count, searchRange, startPt;
+ var searchRange = null;
+ var startPt = null;
/**
* Find the first result in the node.
View
1 extension/content/firebug/lib/system.js
@@ -11,7 +11,6 @@ function(FBTrace, Arr) {
var Ci = Components.interfaces;
var Cc = Components.classes;
-var Cu = Components.utils;
var ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
View
4 extension/content/firebug/lib/wrapper.js
@@ -5,10 +5,6 @@ define([], function() {
// ********************************************************************************************* //
// Constants
-var Ci = Components.interfaces;
-var Cc = Components.classes;
-var Cu = Components.utils;
-
var Wrapper = {};
// ********************************************************************************************* //
View
67 extension/content/firebug/lib/xml.js
@@ -11,72 +11,71 @@ function(FBTrace, Str) {
var Ci = Components.interfaces;
var Cc = Components.classes;
-var Cu = Components.utils;
var Xml = {};
// ************************************************************************************************
// HTML and XML Serialization
-var getElementType = Xml.getElementType = function(node)
+Xml.getElementType = function(node)
{
- if (isElementXUL(node))
+ if (Xml.isElementXUL(node))
return 'xul';
- else if (isElementSVG(node))
+ else if (Xml.isElementSVG(node))
return 'svg';
- else if (isElementMathML(node))
+ else if (Xml.isElementMathML(node))
return 'mathml';
- else if (isElementXHTML(node))
+ else if (Xml.isElementXHTML(node))
return 'xhtml';
- else if (isElementHTML(node))
+ else if (Xml.isElementHTML(node))
return 'html';
};
@simonlindholm
Firebug Working Group member
simonlindholm added a note Jan 4, 2013

To be fair, that makes it a bit slower (prevents inlining).

@SebastianZ
Firebug Working Group member
SebastianZ added a note Jan 8, 2013

Yes, an insensible bit. Reason was to unify the functions and to make the dependency more visible.
Though I could revert it if you feel we should do so.

Sebastian

@simonlindholm
Firebug Working Group member
simonlindholm added a note Jan 8, 2013

I guess we should, we do call these functions a lot sometimes.

@SebastianZ
Firebug Working Group member
SebastianZ added a note Jan 8, 2013

OK. Did it in bc2ea3c.

Sebastian

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
-var getElementSimpleType = Xml.getElementSimpleType = function(node)
+Xml.getElementSimpleType = function(node)
{
- if (isElementSVG(node))
+ if (Xml.isElementSVG(node))
return 'svg';
- else if (isElementMathML(node))
+ else if (Xml.isElementMathML(node))
return 'mathml';
else
return 'html';
};
-var isElementHTML = Xml.isElementHTML = function(node)
+Xml.isElementHTML = function(node)
{
return node.nodeName == node.nodeName.toUpperCase() && node.namespaceURI == 'http://www.w3.org/1999/xhtml';
};
-var isElementXHTML = Xml.isElementXHTML = function(node)
+Xml.isElementXHTML = function(node)
{
return node.nodeName != node.nodeName.toUpperCase() && node.namespaceURI == 'http://www.w3.org/1999/xhtml';
};
-var isElementMathML = Xml.isElementMathML = function(node)
+Xml.isElementMathML = function(node)
{
return node.namespaceURI == 'http://www.w3.org/1998/Math/MathML';
};
-var isElementSVG = Xml.isElementSVG = function(node)
+Xml.isElementSVG = function(node)
{
return node.namespaceURI == 'http://www.w3.org/2000/svg';
};
-var isElementXUL = Xml.isElementXUL = function(node)
+Xml.isElementXUL = function(node)
{
return node instanceof XULElement;
};
-var getNodeName = Xml.getNodeName = function(node)
+Xml.getNodeName = function(node)
{
var name = node.nodeName;
- return isElementHTML(node) ? name.toLowerCase() : name;
+ return Xml.isElementHTML(node) ? name.toLowerCase() : name;
};
-var getLocalName = Xml.getLocalName = function(node)
+Xml.getLocalName = function(node)
{
var name = node.localName;
- return isElementHTML(node) ? name.toLowerCase() : name;
+ return Xml.isElementHTML(node) ? name.toLowerCase() : name;
};
// End tags for void elements are forbidden http://wiki.whatwg.org/wiki/HTML_vs._XHTML
@@ -97,22 +96,22 @@ Xml.selfClosingTags =
Xml.isSelfClosing = function(element)
{
- if (isElementSVG(element) || isElementMathML(element))
+ if (Xml.isElementSVG(element) || Xml.isElementMathML(element))
return true;
var tag = element.localName.toLowerCase();
return (Xml.selfClosingTags.hasOwnProperty(tag));
};
Xml.getElementHTML = function(element)
{
- function toHTML(elt)
+ function toHTML(elt, html)
{
if (elt.nodeType == Node.ELEMENT_NODE)
{
if (Firebug.shouldIgnore(elt))
return;
- var nodeName = getNodeName(elt);
+ var nodeName = Xml.getNodeName(elt);
html.push('<', nodeName);
for (var i = 0; i < elt.attributes.length; ++i)
@@ -139,46 +138,52 @@ Xml.getElementHTML = function(element)
html.push('>');
for (var child = elt.firstChild; child; child = child.nextSibling)
- toHTML(child);
+ toHTML(child, html);
html.push('</', nodeName, '>');
}
- else if (isElementSVG(elt) || isElementMathML(elt))
+ else if (Xml.isElementSVG(elt) || Xml.isElementMathML(elt))
{
html.push('/>');
}
else if (Xml.isSelfClosing(elt))
{
- html.push((isElementXHTML(elt))?'/>':'>');
+ html.push((Xml.isElementXHTML(elt))?'/>':'>');
}
else
{
html.push('></', nodeName, '>');
}
}
else if (elt.nodeType == Node.TEXT_NODE)
+ {
html.push(Str.escapeForTextNode(elt.textContent));
+ }
else if (elt.nodeType == Node.CDATA_SECTION_NODE)
+ {
html.push('<![CDATA[', elt.nodeValue, ']]>');
+ }
else if (elt.nodeType == Node.COMMENT_NODE)
+ {
html.push('<!--', elt.nodeValue, '-->');
+ }
}
var html = [];
- toHTML(element);
+ toHTML(element, html);
return html.join("");
};
Xml.getElementXML = function(element)
{
- function toXML(elt)
+ function toXML(elt, xml)
{
if (elt.nodeType == Node.ELEMENT_NODE)
{
if (Firebug.shouldIgnore(elt))
return;
- var nodeName = getNodeName(elt);
+ var nodeName = Xml.getNodeName(elt);
xml.push('<', nodeName);
for (var i = 0; i < elt.attributes.length; ++i)
@@ -204,7 +209,7 @@ Xml.getElementXML = function(element)
xml.push('>');
for (var child = elt.firstChild; child; child = child.nextSibling)
- toXML(child);
+ toXML(child, xml);
xml.push('</', nodeName, '>');
}
@@ -220,7 +225,7 @@ Xml.getElementXML = function(element)
}
var xml = [];
- toXML(element);
+ toXML(element, xml);
return xml.join("");
};
@@ -298,7 +303,7 @@ Xml.isVisible = function(elt)
return false;
};
-var invisibleTags = Xml.invisibleTags =
+Xml.invisibleTags =
{
"HTML": 1,
"HEAD": 1,
View
4 extension/content/firebug/lib/xpath.js
@@ -8,10 +8,6 @@ function(Str) {
// ********************************************************************************************* //
// Constants
-var Ci = Components.interfaces;
-var Cc = Components.classes;
-var Cu = Components.utils;
-
var Xpath = {};
// ********************************************************************************************* //
View
7 extension/modules/firebug-service.js
@@ -699,11 +699,12 @@ LogFunctionStepper.prototype =
if (!frame.callingFrame)
{
- var diff = (fbs.stackDescription.oldestTag !== frame.script.tag);
-
if (FBTrace.DBG_FBS_STEP)
+ {
+ var diff = (fbs.stackDescription.oldestTag !== frame.script.tag);
FBTrace.sysout("fbs.Stack ends at depth "+fbs.stackDescription.depth +
(diff ? " NO Match on tag " : " tags match"), fbs.stackDescription.entries);
+ }
fbs.stackDescription.entries = [];
}
@@ -1355,7 +1356,7 @@ var fbs =
var index = this.findErrorBreakpoint(url, lineNo);
if (index != -1)
{
- var bp = this.removeBreakpoint(BP_NORMAL | BP_ERROR, url, lineNo);
+ this.removeBreakpoint(BP_NORMAL | BP_ERROR, url, lineNo);
errorBreakpoints.splice(index, 1);
dispatch(debuggers, "onToggleErrorBreakpoint", [url, lineNo, false, debuggr]);
View
2 extension/modules/mini-require.js
@@ -13,8 +13,6 @@ var require, define;
// Constants
var Cu = Components.utils;
-var Cc = Components.classes;
-var Ci = Components.interfaces;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://firebug/fbtrace.js");
View
13 extension/modules/prefLoader.js
@@ -119,18 +119,11 @@ var prefTypeMap = (function()
function getPref(prefDomain, name)
{
- var prefName;
- if (name == undefined)
- prefName = PrefLoader.prefDomain + prefDomain;
- else
- prefName = prefDomain + "." + name;
-
+ var prefName = (name == undefined) ?
+ PrefLoader.prefDomain + prefDomain : prefDomain + "." + name;
var prefs = Services.prefs;
var type = prefTypeMap[prefs.getPrefType(prefName)];
- if (type)
- var value = prefs["get" + type](prefName);
-
- return value;
+ return type ? prefs["get" + type](prefName) : null;
}
function setPref(name, value)
View
3 extension/modules/require-debug.js
@@ -50,6 +50,7 @@ require.originalExecCb = require.execCb;
require.execCbOFF = function (name)
{
var ret = require.originalExecCb.apply(require, arguments);
+ var value = null;
try
{
if (ret)
@@ -61,7 +62,7 @@ require.execCbOFF = function (name)
{
if (ret.hasOwnProperty(prop))
{
- var value = ret[prop];
+ value = ret[prop];
if (value !== null &&
(typeof value == "function"/* || typeof value == "object"*/))
{

0 comments on commit 3118f39

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