--- a/devtools/client/shared/widgets/VariablesView.jsm
+++ b/devtools/client/shared/widgets/VariablesView.jsm
@@ -30,25 +30,25 @@ const {PluralForm} = require("devtools/s
const {LocalizationHelper, ELLIPSIS} = require("devtools/shared/l10n");
const L10N = new LocalizationHelper(DBG_STRINGS_URI);
XPCOMUtils.defineLazyServiceGetter(this, "clipboardHelper",
"@mozilla.org/widget/clipboardhelper;1",
"nsIClipboardHelper");
Object.defineProperty(this, "WebConsoleUtils", {
- get: function () {
+ get: function() {
return require("devtools/client/webconsole/utils").Utils;
},
configurable: true,
enumerable: true
});
Object.defineProperty(this, "NetworkHelper", {
- get: function () {
+ get: function() {
return require("devtools/shared/webconsole/network-helper");
},
configurable: true,
enumerable: true
});
this.EXPORTED_SYMBOLS = ["VariablesView", "escapeHTML"];
@@ -119,17 +119,17 @@ VariablesView.prototype = {
*
* @param string aName
* The scope's name (e.g. "Local", "Global" etc.).
* @param string aCustomClass
* An additional class name for the containing element.
* @return Scope
* The newly created Scope instance.
*/
- addScope: function (aName = "", aCustomClass = "") {
+ addScope: function(aName = "", aCustomClass = "") {
this._removeEmptyNotice();
this._toggleSearchVisibility(true);
let scope = new Scope(this, aName, { customClass: aCustomClass });
this._store.push(scope);
this._itemsByElement.set(scope._target, scope);
this._currHierarchy.set(aName, scope);
scope.header = !!aName;
@@ -139,17 +139,17 @@ VariablesView.prototype = {
/**
* Removes all items from this container.
*
* @param number aTimeout [optional]
* The number of milliseconds to delay the operation if
* lazy emptying of this container is enabled.
*/
- empty: function (aTimeout = this.lazyEmptyDelay) {
+ empty: function(aTimeout = this.lazyEmptyDelay) {
// If there are no items in this container, emptying is useless.
if (!this._store.length) {
return;
}
this._store.length = 0;
this._itemsByElement = new WeakMap();
this._prevHierarchy = this._currHierarchy;
@@ -179,17 +179,17 @@ VariablesView.prototype = {
* immediately attached to the parent container. The old container list
* is kept around for a short period of time, hopefully accounting for the
* data fetching delay. In the meantime, any operations can be executed
* normally.
*
* @see VariablesView.empty
* @see VariablesView.commitHierarchy
*/
- _emptySoon: function (aTimeout) {
+ _emptySoon: function(aTimeout) {
let prevList = this._list;
let currList = this._list = this.document.createElement("scrollbox");
this.window.setTimeout(() => {
prevList.removeEventListener("keydown", this._onViewKeyDown);
currList.addEventListener("keydown", this._onViewKeyDown);
currList.setAttribute("orient", "vertical");
@@ -426,17 +426,17 @@ VariablesView.prototype = {
get searchPlaceholder() {
return this._searchboxPlaceholder;
},
/**
* Enables variable and property searching in this view.
* Use the "searchEnabled" setter to enable searching.
*/
- _enableSearch: function () {
+ _enableSearch: function() {
// If searching was already enabled, no need to re-enable it again.
if (this._searchboxContainer) {
return;
}
let document = this.document;
let ownerNode = this._parent.parentNode;
let container = this._searchboxContainer = document.createElement("hbox");
@@ -457,17 +457,17 @@ VariablesView.prototype = {
container.appendChild(searchbox);
ownerNode.insertBefore(container, this._parent);
},
/**
* Disables variable and property searching in this view.
* Use the "searchEnabled" setter to disable searching.
*/
- _disableSearch: function () {
+ _disableSearch: function() {
// If searching was already disabled, no need to re-disable it again.
if (!this._searchboxContainer) {
return;
}
this._searchboxContainer.remove();
this._searchboxNode.removeEventListener("command", this._onSearchboxInput);
this._searchboxNode.removeEventListener("keydown", this._onSearchboxKeyDown);
@@ -477,55 +477,54 @@ VariablesView.prototype = {
/**
* Sets the variables searchbox container hidden or visible.
* It's hidden by default.
*
* @param boolean aVisibleFlag
* Specifies the intended visibility.
*/
- _toggleSearchVisibility: function (aVisibleFlag) {
+ _toggleSearchVisibility: function(aVisibleFlag) {
// If searching was already disabled, there's no need to hide it.
if (!this._searchboxContainer) {
return;
}
this._searchboxContainer.hidden = !aVisibleFlag;
},
/**
* Listener handling the searchbox input event.
*/
- _onSearchboxInput: function () {
+ _onSearchboxInput: function() {
this.scheduleSearch(this._searchboxNode.value);
},
/**
* Listener handling the searchbox keydown event.
*/
- _onSearchboxKeyDown: function (e) {
+ _onSearchboxKeyDown: function(e) {
switch (e.keyCode) {
case KeyCodes.DOM_VK_RETURN:
this._onSearchboxInput();
return;
case KeyCodes.DOM_VK_ESCAPE:
this._searchboxNode.value = "";
this._onSearchboxInput();
- return;
}
},
/**
* Schedules searching for variables or properties matching the query.
*
* @param string aToken
* The variable or property to search for.
* @param number aWait
* The amount of milliseconds to wait until draining.
*/
- scheduleSearch: function (aToken, aWait) {
+ scheduleSearch: function(aToken, aWait) {
// Check if this search operation may not be executed lazily.
if (!this.lazySearch) {
this._doSearch(aToken);
return;
}
// The amount of time to wait for the requests to settle.
let maxDelay = SEARCH_ACTION_MAX_DELAY;
@@ -541,17 +540,17 @@ VariablesView.prototype = {
*
* If aToken is falsy, then all the scopes are unhidden and expanded,
* while the available variables and properties inside those scopes are
* just unhidden.
*
* @param string aToken
* The variable or property to search for.
*/
- _doSearch: function (aToken) {
+ _doSearch: function(aToken) {
if (this.controller && this.controller.supportsSearch()) {
// Retrieve the main Scope in which we add attributes
let scope = this._store[0]._store.get(undefined);
if (!aToken) {
// Prune the view from old previous content
// so that we delete the intermediate search results
// we created in previous searches
for (let property of scope._store.values()) {
@@ -587,17 +586,17 @@ VariablesView.prototype = {
* user). Descends into each scope to check the scope and its children.
*
* @param function aPredicate
* A function that returns true when a match is found.
* @return Scope | Variable | Property
* The first visible scope, variable or property, or null if nothing
* is found.
*/
- _findInVisibleItems: function (aPredicate) {
+ _findInVisibleItems: function(aPredicate) {
for (let scope of this._store) {
let result = scope._findInVisibleItems(aPredicate);
if (result) {
return result;
}
}
return null;
},
@@ -609,17 +608,17 @@ VariablesView.prototype = {
* its children.
*
* @param function aPredicate
* A function that returns true when a match is found.
* @return Scope | Variable | Property
* The last visible scope, variable or property, or null if nothing
* is found.
*/
- _findInVisibleItemsReverse: function (aPredicate) {
+ _findInVisibleItemsReverse: function(aPredicate) {
for (let i = this._store.length - 1; i >= 0; i--) {
let scope = this._store[i];
let result = scope._findInVisibleItemsReverse(aPredicate);
if (result) {
return result;
}
}
return null;
@@ -628,42 +627,42 @@ VariablesView.prototype = {
/**
* Gets the scope at the specified index.
*
* @param number aIndex
* The scope's index.
* @return Scope
* The scope if found, undefined if not.
*/
- getScopeAtIndex: function (aIndex) {
+ getScopeAtIndex: function(aIndex) {
return this._store[aIndex];
},
/**
* Recursively searches this container for the scope, variable or property
* displayed by the specified node.
*
* @param nsIDOMNode aNode
* The node to search for.
* @return Scope | Variable | Property
* The matched scope, variable or property, or null if nothing is found.
*/
- getItemForNode: function (aNode) {
+ getItemForNode: function(aNode) {
return this._itemsByElement.get(aNode);
},
/**
* Gets the scope owning a Variable or Property.
*
* @param Variable | Property
* The variable or property to retrieven the owner scope for.
* @return Scope
* The owner scope.
*/
- getOwnerScopeForVariableOrProperty: function (aItem) {
+ getOwnerScopeForVariableOrProperty: function(aItem) {
if (!aItem) {
return null;
}
// If this is a Scope, return it.
if (!(aItem instanceof Variable)) {
return aItem;
}
// If this is a Variable or Property, find its owner scope.
@@ -677,78 +676,78 @@ VariablesView.prototype = {
* Gets the parent scopes for a specified Variable or Property.
* The returned list will not include the owner scope.
*
* @param Variable | Property
* The variable or property for which to find the parent scopes.
* @return array
* A list of parent Scopes.
*/
- getParentScopesForVariableOrProperty: function (aItem) {
+ getParentScopesForVariableOrProperty: function(aItem) {
let scope = this.getOwnerScopeForVariableOrProperty(aItem);
return this._store.slice(0, Math.max(this._store.indexOf(scope), 0));
},
/**
* Gets the currently focused scope, variable or property in this view.
*
* @return Scope | Variable | Property
* The focused scope, variable or property, or null if nothing is found.
*/
- getFocusedItem: function () {
+ getFocusedItem: function() {
let focused = this.document.commandDispatcher.focusedElement;
return this.getItemForNode(focused);
},
/**
* Focuses the first visible scope, variable, or property in this container.
*/
- focusFirstVisibleItem: function () {
+ focusFirstVisibleItem: function() {
let focusableItem = this._findInVisibleItems(item => item.focusable);
if (focusableItem) {
this._focusItem(focusableItem);
}
this._parent.scrollTop = 0;
this._parent.scrollLeft = 0;
},
/**
* Focuses the last visible scope, variable, or property in this container.
*/
- focusLastVisibleItem: function () {
+ focusLastVisibleItem: function() {
let focusableItem = this._findInVisibleItemsReverse(item => item.focusable);
if (focusableItem) {
this._focusItem(focusableItem);
}
this._parent.scrollTop = this._parent.scrollHeight;
this._parent.scrollLeft = 0;
},
/**
* Focuses the next scope, variable or property in this view.
*/
- focusNextItem: function () {
+ focusNextItem: function() {
this.focusItemAtDelta(+1);
},
/**
* Focuses the previous scope, variable or property in this view.
*/
- focusPrevItem: function () {
+ focusPrevItem: function() {
this.focusItemAtDelta(-1);
},
/**
* Focuses another scope, variable or property in this view, based on
* the index distance from the currently focused item.
*
* @param number aDelta
* A scalar specifying by how many items should the selection change.
*/
- focusItemAtDelta: function (aDelta) {
+ focusItemAtDelta: function(aDelta) {
let direction = aDelta > 0 ? "advanceFocus" : "rewindFocus";
let distance = Math.abs(Math[aDelta > 0 ? "ceil" : "floor"](aDelta));
while (distance--) {
if (!this._focusChange(direction)) {
break; // Out of bounds.
}
}
},
@@ -757,17 +756,17 @@ VariablesView.prototype = {
* Focuses the next or previous scope, variable or property in this view.
*
* @param string aDirection
* Either "advanceFocus" or "rewindFocus".
* @return boolean
* False if the focus went out of bounds and the first or last element
* in this view was focused instead.
*/
- _focusChange: function (aDirection) {
+ _focusChange: function(aDirection) {
let commandDispatcher = this.document.commandDispatcher;
let prevFocusedElement = commandDispatcher.focusedElement;
let currFocusedItem = null;
do {
commandDispatcher.suppressFocusScroll = true;
commandDispatcher[aDirection]();
@@ -788,32 +787,32 @@ VariablesView.prototype = {
*
* @param aItem Scope | Variable | Property
* The item to focus.
* @param boolean aCollapseFlag
* True if the focused item should also be collapsed.
* @return boolean
* True if the item was successfully focused.
*/
- _focusItem: function (aItem, aCollapseFlag) {
+ _focusItem: function(aItem, aCollapseFlag) {
if (!aItem.focusable) {
return false;
}
if (aCollapseFlag) {
aItem.collapse();
}
aItem._target.focus();
this.boxObject.ensureElementIsVisible(aItem._arrow);
return true;
},
/**
* Listener handling a key down event on the view.
*/
- _onViewKeyDown: function (e) {
+ _onViewKeyDown: function(e) {
let item = this.getFocusedItem();
// Prevent scrolling when pressing navigation keys.
ViewHelpers.preventScrolling(e);
switch (e.keyCode) {
case KeyCodes.DOM_VK_C:
// Copy current selection to clipboard.
@@ -895,17 +894,16 @@ VariablesView.prototype = {
// Delete the Variable or Property if allowed.
if (item instanceof Variable) {
item._onDelete(e);
}
return;
case KeyCodes.DOM_VK_INSERT:
item._onAddProperty(e);
- return;
}
},
/**
* Sets the text displayed in this container when there are no available items.
* @param string aValue
*/
set emptyText(aValue) {
@@ -914,33 +912,33 @@ VariablesView.prototype = {
}
this._emptyTextValue = aValue;
this._appendEmptyNotice();
},
/**
* Creates and appends a label signaling that this container is empty.
*/
- _appendEmptyNotice: function () {
+ _appendEmptyNotice: function() {
if (this._emptyTextNode || !this._emptyTextValue) {
return;
}
let label = this.document.createElement("label");
label.className = "variables-view-empty-notice";
label.setAttribute("value", this._emptyTextValue);
this._parent.appendChild(label);
this._emptyTextNode = label;
},
/**
* Removes the label signaling that this container is empty.
*/
- _removeEmptyNotice: function () {
+ _removeEmptyNotice: function() {
if (!this._emptyTextNode) {
return;
}
this._parent.removeChild(this._emptyTextNode);
this._emptyTextNode = null;
},
@@ -1057,50 +1055,50 @@ VariablesView.NON_SORTABLE_CLASSES = [
];
/**
* Determine whether an object's properties should be sorted based on its class.
*
* @param string aClassName
* The class of the object.
*/
-VariablesView.isSortable = function (aClassName) {
+VariablesView.isSortable = function(aClassName) {
return !VariablesView.NON_SORTABLE_CLASSES.includes(aClassName);
};
/**
* Generates the string evaluated when performing simple value changes.
*
* @param Variable | Property aItem
* The current variable or property.
* @param string aCurrentString
* The trimmed user inputted string.
* @param string aPrefix [optional]
* Prefix for the symbolic name.
* @return string
* The string to be evaluated.
*/
-VariablesView.simpleValueEvalMacro = function (aItem, aCurrentString, aPrefix = "") {
+VariablesView.simpleValueEvalMacro = function(aItem, aCurrentString, aPrefix = "") {
return aPrefix + aItem.symbolicName + "=" + aCurrentString;
};
/**
* Generates the string evaluated when overriding getters and setters with
* plain values.
*
* @param Property aItem
* The current getter or setter property.
* @param string aCurrentString
* The trimmed user inputted string.
* @param string aPrefix [optional]
* Prefix for the symbolic name.
* @return string
* The string to be evaluated.
*/
-VariablesView.overrideValueEvalMacro = function (aItem, aCurrentString, aPrefix = "") {
+VariablesView.overrideValueEvalMacro = function(aItem, aCurrentString, aPrefix = "") {
let property = escapeString(aItem._nameString);
let parent = aPrefix + aItem.ownerView.symbolicName || "this";
return "Object.defineProperty(" + parent + "," + property + "," +
"{ value: " + aCurrentString +
", enumerable: " + parent + ".propertyIsEnumerable(" + property + ")" +
", configurable: true" +
", writable: true" +
@@ -1114,17 +1112,17 @@ VariablesView.overrideValueEvalMacro = f
* The current getter or setter property.
* @param string aCurrentString
* The trimmed user inputted string.
* @param string aPrefix [optional]
* Prefix for the symbolic name.
* @return string
* The string to be evaluated.
*/
-VariablesView.getterOrSetterEvalMacro = function (aItem, aCurrentString, aPrefix = "") {
+VariablesView.getterOrSetterEvalMacro = function(aItem, aCurrentString, aPrefix = "") {
let type = aItem._nameString;
let propertyObject = aItem.ownerView;
let parentObject = propertyObject.ownerView;
let property = escapeString(propertyObject._nameString);
let parent = aPrefix + parentObject.symbolicName || "this";
switch (aCurrentString) {
case "":
@@ -1190,27 +1188,26 @@ VariablesView.getterOrSetterEvalMacro =
};
/**
* Function invoked when a getter or setter is deleted.
*
* @param Property aItem
* The current getter or setter property.
*/
-VariablesView.getterOrSetterDeleteCallback = function (aItem) {
+VariablesView.getterOrSetterDeleteCallback = function(aItem) {
aItem._disable();
// Make sure the right getter/setter to value override macro is applied
// to the target object.
aItem.ownerView.eval(aItem, "");
return true; // Don't hide the element.
};
-
/**
* A Scope is an object holding Variable instances.
* Iterable via "for (let [name, variable] of instance) { }".
*
* @param VariablesView aView
* The view to contain this scope.
* @param string aName
* The scope's name.
@@ -1267,17 +1264,17 @@ Scope.prototype = {
* The name of the new Property.
* @param object aDescriptor
* The variable's descriptor.
* @param object aOptions
* Options of the form accepted by addItem.
* @return Variable
* The newly created child Variable.
*/
- _createChild: function (aName, aDescriptor, aOptions) {
+ _createChild: function(aName, aDescriptor, aOptions) {
return new Variable(this, aName, aDescriptor, aOptions);
},
/**
* Adds a child to contain any inspected properties.
*
* @param string aName
* The child's name.
@@ -1303,17 +1300,17 @@ Scope.prototype = {
* * boolean internalItem true if the item is internally generated.
* This is used for special variables
* like <return> or <exception> and distinguishes
* them from ordinary properties that happen
* to have the same name
* @return Variable
* The newly created Variable instance, null if it already exists.
*/
- addItem: function (aName, aDescriptor = {}, aOptions = {}) {
+ addItem: function(aName, aDescriptor = {}, aOptions = {}) {
let {relaxed} = aOptions;
if (this._store.has(aName) && !relaxed) {
return this._store.get(aName);
}
let child = this._createChild(aName, aDescriptor, aOptions);
this._store.set(aName, child);
this._variablesView._itemsByElement.set(child._target, child);
@@ -1339,17 +1336,17 @@ Scope.prototype = {
* someProp5: { value: { type: "object", class: "Object" } },
* someProp6: { get: { type: "object", class: "Function" },
* set: { type: "undefined" } } }
* @param object aOptions [optional]
* Additional options for adding the properties. Supported options:
* - sorted: true to sort all the properties before adding them
* - callback: function invoked after each item is added
*/
- addItems: function (aItems, aOptions = {}) {
+ addItems: function(aItems, aOptions = {}) {
let names = Object.keys(aItems);
// Sort all of the properties before adding them, if preferred.
if (aOptions.sorted) {
names.sort(this._naturalSort);
}
// Add the properties to the current scope.
@@ -1361,17 +1358,17 @@ Scope.prototype = {
aOptions.callback(item, descriptor && descriptor.value);
}
}
},
/**
* Remove this Scope from its parent and remove all children recursively.
*/
- remove: function () {
+ remove: function() {
let view = this._variablesView;
view._store.splice(view._store.indexOf(this), 1);
view._itemsByElement.delete(this._target);
view._currHierarchy.delete(this._nameString);
this._target.remove();
for (let variable of this._store.values()) {
@@ -1382,30 +1379,30 @@ Scope.prototype = {
/**
* Gets the variable in this container having the specified name.
*
* @param string aName
* The name of the variable to get.
* @return Variable
* The matched variable, or null if nothing is found.
*/
- get: function (aName) {
+ get: function(aName) {
return this._store.get(aName);
},
/**
* Recursively searches for the variable or property in this container
* displayed by the specified node.
*
* @param nsIDOMNode aNode
* The node to search for.
* @return Variable | Property
* The matched variable or property, or null if nothing is found.
*/
- find: function (aNode) {
+ find: function(aNode) {
for (let [, variable] of this._store) {
let match;
if (variable._target == aNode) {
match = variable;
} else {
match = variable.find(aNode);
}
if (match) {
@@ -1419,70 +1416,70 @@ Scope.prototype = {
* Determines if this scope is a direct child of a parent variables view,
* scope, variable or property.
*
* @param VariablesView | Scope | Variable | Property
* The parent to check.
* @return boolean
* True if the specified item is a direct child, false otherwise.
*/
- isChildOf: function (aParent) {
+ isChildOf: function(aParent) {
return this.ownerView == aParent;
},
/**
* Determines if this scope is a descendant of a parent variables view,
* scope, variable or property.
*
* @param VariablesView | Scope | Variable | Property
* The parent to check.
* @return boolean
* True if the specified item is a descendant, false otherwise.
*/
- isDescendantOf: function (aParent) {
+ isDescendantOf: function(aParent) {
if (this.isChildOf(aParent)) {
return true;
}
// Recurse to parent if it is a Scope, Variable, or Property.
if (this.ownerView instanceof Scope) {
return this.ownerView.isDescendantOf(aParent);
}
return false;
},
/**
* Shows the scope.
*/
- show: function () {
+ show: function() {
this._target.hidden = false;
this._isContentVisible = true;
if (this.onshow) {
this.onshow(this);
}
},
/**
* Hides the scope.
*/
- hide: function () {
+ hide: function() {
this._target.hidden = true;
this._isContentVisible = false;
if (this.onhide) {
this.onhide(this);
}
},
/**
* Expands the scope, showing all the added details.
*/
- expand: function () {
+ expand: function() {
if (this._isExpanded || this._isLocked) {
return;
}
if (this._variablesView._enumVisible) {
this._openEnum();
}
if (this._variablesView._nonEnumVisible) {
Services.tm.dispatchToMainThread({ run: this._openNonEnum });
@@ -1496,34 +1493,34 @@ Scope.prototype = {
// and attributes are available. (Mostly used for tests)
return this.onexpand(this);
}
},
/**
* Collapses the scope, hiding all the added details.
*/
- collapse: function () {
+ collapse: function() {
if (!this._isExpanded || this._isLocked) {
return;
}
this._arrow.removeAttribute("open");
this._enum.removeAttribute("open");
this._nonenum.removeAttribute("open");
this._isExpanded = false;
if (this.oncollapse) {
this.oncollapse(this);
}
},
/**
* Toggles between the scope's collapsed and expanded state.
*/
- toggle: function (e) {
+ toggle: function(e) {
if (e && e.button != 0) {
// Only allow left-click to trigger this event.
return;
}
this.expanded ^= 1;
// Make sure the scope and its contents are visibile.
for (let [, variable] of this._store) {
@@ -1533,29 +1530,29 @@ Scope.prototype = {
if (this.ontoggle) {
this.ontoggle(this);
}
},
/**
* Shows the scope's title header.
*/
- showHeader: function () {
+ showHeader: function() {
if (this._isHeaderVisible || !this._nameString) {
return;
}
this._target.removeAttribute("untitled");
this._isHeaderVisible = true;
},
/**
* Hides the scope's title header.
* This action will automatically expand the scope.
*/
- hideHeader: function () {
+ hideHeader: function() {
if (!this._isHeaderVisible) {
return;
}
this.expand();
this._target.setAttribute("untitled", "");
this._isHeaderVisible = false;
},
@@ -1564,37 +1561,37 @@ Scope.prototype = {
* This only needs to compare non-numbers since it is dealing with an array
* which numeric-based indices are placed in order.
*
* @param string a
* @param string b
* @return number
* -1 if a is less than b, 0 if no change in order, +1 if a is greater than 0
*/
- _naturalSort: function (a, b) {
+ _naturalSort: function(a, b) {
if (isNaN(parseFloat(a)) && isNaN(parseFloat(b))) {
return a < b ? -1 : 1;
}
},
/**
* Shows the scope's expand/collapse arrow.
*/
- showArrow: function () {
+ showArrow: function() {
if (this._isArrowVisible) {
return;
}
this._arrow.removeAttribute("invisible");
this._isArrowVisible = true;
},
/**
* Hides the scope's expand/collapse arrow.
*/
- hideArrow: function () {
+ hideArrow: function() {
if (!this._isArrowVisible) {
return;
}
this._arrow.setAttribute("invisible", "");
this._isArrowVisible = false;
},
/**
@@ -1699,37 +1696,37 @@ Scope.prototype = {
}
}
return true;
},
/**
* Focus this scope.
*/
- focus: function () {
+ focus: function() {
this._variablesView._focusItem(this);
},
/**
* Adds an event listener for a certain event on this scope's title.
* @param string aName
* @param function aCallback
* @param boolean aCapture
*/
- addEventListener: function (aName, aCallback, aCapture) {
+ addEventListener: function(aName, aCallback, aCapture) {
this._title.addEventListener(aName, aCallback, aCapture);
},
/**
* Removes an event listener for a certain event on this scope's title.
* @param string aName
* @param function aCallback
* @param boolean aCapture
*/
- removeEventListener: function (aName, aCallback, aCapture) {
+ removeEventListener: function(aName, aCallback, aCapture) {
this._title.removeEventListener(aName, aCallback, aCapture);
},
/**
* Gets the id associated with this item.
* @return string
*/
get id() {
@@ -1771,17 +1768,17 @@ Scope.prototype = {
/**
* Initializes this scope's id, view and binds event listeners.
*
* @param string aName
* The scope's name.
* @param object aFlags [optional]
* Additional options or flags for this scope.
*/
- _init: function (aName, aFlags) {
+ _init: function(aName, aFlags) {
this._idString = generateId(this._nameString = aName);
this._displayScope(aName, `${this.targetClassName} ${aFlags.customClass}`,
"devtools-toolbar");
this._addEventListeners();
this.parentNode.appendChild(this._target);
},
/**
@@ -1789,17 +1786,17 @@ Scope.prototype = {
*
* @param string aName
* The scope's name.
* @param string aTargetClassName
* A custom class name for this scope's target element.
* @param string aTitleClassName [optional]
* A custom class name for this scope's title element.
*/
- _displayScope: function (aName = "", aTargetClassName, aTitleClassName = "") {
+ _displayScope: function(aName = "", aTargetClassName, aTitleClassName = "") {
let document = this.document;
let element = this._target = document.createElement("vbox");
element.id = this._idString;
element.className = aTargetClassName;
let arrow = this._arrow = document.createElement("hbox");
arrow.className = "arrow theme-twisty";
@@ -1824,47 +1821,47 @@ Scope.prototype = {
element.appendChild(title);
element.appendChild(enumerable);
element.appendChild(nonenum);
},
/**
* Adds the necessary event listeners for this scope.
*/
- _addEventListeners: function () {
+ _addEventListeners: function() {
this._title.addEventListener("mousedown", this._onClick);
},
/**
* The click listener for this scope's title.
*/
- _onClick: function (e) {
+ _onClick: function(e) {
if (this.editing ||
e.button != 0 ||
e.target == this._editNode ||
e.target == this._deleteNode ||
e.target == this._addPropertyNode) {
return;
}
this.toggle();
this.focus();
},
/**
* Opens the enumerable items container.
*/
- _openEnum: function () {
+ _openEnum: function() {
this._arrow.setAttribute("open", "");
this._enum.setAttribute("open", "");
},
/**
* Opens the non-enumerable items container.
*/
- _openNonEnum: function () {
+ _openNonEnum: function() {
this._nonenum.setAttribute("open", "");
},
/**
* Specifies if enumerable properties and variables should be displayed.
* @param boolean aFlag
*/
set _enumVisible(aFlag) {
@@ -1903,17 +1900,17 @@ Scope.prototype = {
/**
* Performs a case insensitive search for variables or properties matching
* the query, and hides non-matched items.
*
* @param string aLowerCaseQuery
* The lowercased name of the variable or property to search for.
*/
- _performSearch: function (aLowerCaseQuery) {
+ _performSearch: function(aLowerCaseQuery) {
for (let [, variable] of this._store) {
let currentObject = variable;
let lowerCaseName = variable._nameString.toLowerCase();
let lowerCaseValue = variable._valueString.toLowerCase();
// Non-matched variables or properties require a corresponding attribute.
if (!lowerCaseName.includes(aLowerCaseQuery) &&
!lowerCaseValue.includes(aLowerCaseQuery)) {
@@ -1970,17 +1967,17 @@ Scope.prototype = {
* the non-enumerable children (since they are presented in separate groups).
*
* @param function aPredicate
* A function that returns true when a match is found.
* @return Scope | Variable | Property
* The first visible scope, variable or property, or null if nothing
* is found.
*/
- _findInVisibleItems: function (aPredicate) {
+ _findInVisibleItems: function(aPredicate) {
if (aPredicate(this)) {
return this;
}
if (this._isExpanded) {
if (this._variablesView._enumVisible) {
for (let item of this._enumItems) {
let result = item._findInVisibleItems(aPredicate);
@@ -2011,17 +2008,17 @@ Scope.prototype = {
* finally tests itself.
*
* @param function aPredicate
* A function that returns true when a match is found.
* @return Scope | Variable | Property
* The last visible scope, variable or property, or null if nothing
* is found.
*/
- _findInVisibleItemsReverse: function (aPredicate) {
+ _findInVisibleItemsReverse: function(aPredicate) {
if (this._isExpanded) {
if (this._variablesView._nonEnumVisible) {
for (let i = this._nonEnumItems.length - 1; i >= 0; i--) {
let item = this._nonEnumItems[i];
let result = item._findInVisibleItemsReverse(aPredicate);
if (result) {
return result;
}
@@ -2194,24 +2191,24 @@ Variable.prototype = extend(Scope.protot
* The name of the new Property.
* @param object aDescriptor
* The property's descriptor.
* @param object aOptions
* Options of the form accepted by Scope.addItem
* @return Property
* The newly created child Property.
*/
- _createChild: function (aName, aDescriptor, aOptions) {
+ _createChild: function(aName, aDescriptor, aOptions) {
return new Property(this, aName, aDescriptor, aOptions);
},
/**
* Remove this Variable from its parent and remove all children recursively.
*/
- remove: function () {
+ remove: function() {
if (this._linkedToInspector) {
this.unhighlightDomNode();
this._valueLabel.removeEventListener("mouseover", this.highlightDomNode);
this._valueLabel.removeEventListener("mouseout", this.unhighlightDomNode);
this._openInspectorNode.removeEventListener("mousedown", this.openNodeInInspector);
}
this.ownerView._store.delete(this._nameString);
@@ -2230,17 +2227,17 @@ Variable.prototype = extend(Scope.protot
*
* @param object aObject
* The raw object you want to display.
* @param object aOptions [optional]
* Additional options for adding the properties. Supported options:
* - sorted: true to sort all the properties before adding them
* - expanded: true to expand all the properties after adding them
*/
- populate: function (aObject, aOptions = {}) {
+ populate: function(aObject, aOptions = {}) {
// Retrieve the properties only once.
if (this._fetched) {
return;
}
this._fetched = true;
let propertyNames = Object.getOwnPropertyNames(aObject);
let prototype = Object.getPrototypeOf(aObject);
@@ -2276,34 +2273,34 @@ Variable.prototype = extend(Scope.protot
* properties of an object
*
* @param Variable | Property aVar
* The target variable to populate.
* @param object aObject [optional]
* The raw object you want to display. If unspecified, the object is
* assumed to be defined in a _sourceValue property on the target.
*/
- _populateTarget: function (aVar, aObject = aVar._sourceValue) {
+ _populateTarget: function(aVar, aObject = aVar._sourceValue) {
aVar.populate(aObject);
},
/**
* Adds a property for this variable based on a raw value descriptor.
*
* @param string aName
* The property's name.
* @param object aDescriptor
* Specifies the exact property descriptor as returned by a call to
* Object.getOwnPropertyDescriptor.
* @param object aValue
* The raw property value you want to display.
* @return Property
* The newly added property instance.
*/
- _addRawValueProperty: function (aName, aDescriptor, aValue) {
+ _addRawValueProperty: function(aName, aDescriptor, aValue) {
let descriptor = Object.create(aDescriptor);
descriptor.value = VariablesView.getGrip(aValue);
let propertyItem = this.addItem(aName, descriptor);
propertyItem._sourceValue = aValue;
// Add an 'onexpand' callback for the property, lazily handling
// the addition of new child properties.
@@ -2319,17 +2316,17 @@ Variable.prototype = extend(Scope.protot
* @param string aName
* The property's name.
* @param object aDescriptor
* Specifies the exact property descriptor as returned by a call to
* Object.getOwnPropertyDescriptor.
* @return Property
* The newly added property instance.
*/
- _addRawNonValueProperty: function (aName, aDescriptor) {
+ _addRawNonValueProperty: function(aName, aDescriptor) {
let descriptor = Object.create(aDescriptor);
descriptor.get = VariablesView.getGrip(aDescriptor.get);
descriptor.set = VariablesView.getGrip(aDescriptor.set);
return this.addItem(aName, descriptor);
},
/**
@@ -2369,17 +2366,17 @@ Variable.prototype = extend(Scope.protot
},
/**
* Build this variable's path to the topmost scope in form of an array of
* strings, one for each segment of the path.
* For example, a symbolic path may look like ["0", "foo", "bar"].
* @return array
*/
- _buildSymbolicPath: function (path = []) {
+ _buildSymbolicPath: function(path = []) {
if (this.name) {
path.unshift(this.name);
if (this.ownerView instanceof Variable) {
return this.ownerView._buildSymbolicPath(path);
}
}
return path;
},
@@ -2420,17 +2417,17 @@ Variable.prototype = extend(Scope.protot
* Specifies the value and/or type & class of the variable.
* e.g. - 42
* - true
* - "nasu"
* - { type: "undefined" }
* - { type: "null" }
* - { type: "object", class: "Object" }
*/
- setGrip: function (aGrip) {
+ setGrip: function(aGrip) {
// Don't allow displaying grip information if there's no name available
// or the grip is malformed.
if (this._nameString === undefined || aGrip === undefined || aGrip === null) {
return;
}
// Getters and setters should display grip information in sub-properties.
if (this.getter || this.setter) {
return;
@@ -2440,26 +2437,23 @@ Variable.prototype = extend(Scope.protot
if (prevGrip) {
this._valueLabel.classList.remove(VariablesView.getClass(prevGrip));
}
this._valueGrip = aGrip;
if (aGrip && (aGrip.optimizedOut || aGrip.uninitialized || aGrip.missingArguments)) {
if (aGrip.optimizedOut) {
this._valueString = L10N.getStr("variablesViewOptimizedOut");
- }
- else if (aGrip.uninitialized) {
+ } else if (aGrip.uninitialized) {
this._valueString = L10N.getStr("variablesViewUninitialized");
- }
- else if (aGrip.missingArguments) {
+ } else if (aGrip.missingArguments) {
this._valueString = L10N.getStr("variablesViewMissingArgs");
}
this.eval = null;
- }
- else {
+ } else {
this._valueString = VariablesView.getString(aGrip, {
concise: true,
noEllipsis: true,
});
this.eval = this.ownerView.eval;
}
this._valueClassName = VariablesView.getClass(aGrip);
@@ -2475,31 +2469,31 @@ Variable.prototype = extend(Scope.protot
},
/**
* Marks this variable as overridden.
*
* @param boolean aFlag
* Whether this variable is overridden or not.
*/
- setOverridden: function (aFlag) {
+ setOverridden: function(aFlag) {
if (aFlag) {
this._target.setAttribute("overridden", "");
} else {
this._target.removeAttribute("overridden");
}
},
/**
* Briefly flashes this variable.
*
* @param number aDuration [optional]
* An optional flash animation duration.
*/
- flash: function (aDuration = ITEM_FLASH_DURATION) {
+ flash: function(aDuration = ITEM_FLASH_DURATION) {
let fadeInDelay = this._variablesView.lazyEmptyDelay + 1;
let fadeOutDelay = fadeInDelay + aDuration;
setNamedTimeout("vview-flash-in" + this.absoluteName,
fadeInDelay, () => this._target.setAttribute("changed", ""));
setNamedTimeout("vview-flash-out" + this.absoluteName,
fadeOutDelay, () => this._target.removeAttribute("changed"));
@@ -2508,17 +2502,17 @@ Variable.prototype = extend(Scope.protot
/**
* Initializes this variable's id, view and binds event listeners.
*
* @param string aName
* The variable's name.
* @param object aDescriptor
* The variable's descriptor.
*/
- _init: function (aName, aDescriptor) {
+ _init: function(aName, aDescriptor) {
this._idString = generateId(this._nameString = aName);
this._displayScope(aName, this.targetClassName);
this._displayVariable();
this._customizeVariable();
this._prepareTooltips();
this._setAttributes();
this._addEventListeners();
@@ -2531,17 +2525,17 @@ Variable.prototype = extend(Scope.protot
this.ownerView._nonenum.appendChild(this._target);
this.ownerView._nonEnumItems.push(this);
}
},
/**
* Creates the necessary nodes for this variable.
*/
- _displayVariable: function () {
+ _displayVariable: function() {
let document = this.document;
let descriptor = this._initialDescriptor;
let separatorLabel = this._separatorLabel = document.createElement("label");
separatorLabel.className = "plain separator";
separatorLabel.setAttribute("value", this.separatorStr + " ");
let valueLabel = this._valueLabel = document.createElement("label");
@@ -2592,17 +2586,17 @@ Variable.prototype = extend(Scope.protot
setter.hideArrow();
this.expand();
}
},
/**
* Adds specific nodes for this variable based on custom flags.
*/
- _customizeVariable: function () {
+ _customizeVariable: function() {
let ownerView = this.ownerView;
let descriptor = this._initialDescriptor;
if (ownerView.eval && this.getter || this.setter) {
let editNode = this._editNode = this.document.createElement("toolbarbutton");
editNode.className = "plain variables-view-edit";
editNode.addEventListener("mousedown", this._onEdit.bind(this));
this._title.insertBefore(editNode, this._spacer);
@@ -2664,24 +2658,24 @@ Variable.prototype = extend(Scope.protot
this._title.appendChild(nonExtensibleLabel);
}
}
},
/**
* Prepares all tooltips for this variable.
*/
- _prepareTooltips: function () {
+ _prepareTooltips: function() {
this._target.addEventListener("mouseover", this._setTooltips);
},
/**
* Sets all tooltips for this variable.
*/
- _setTooltips: function () {
+ _setTooltips: function() {
this._target.removeEventListener("mouseover", this._setTooltips);
let ownerView = this.ownerView;
if (ownerView.preventDescriptorModifiers) {
return;
}
let tooltip = this.document.createElement("tooltip");
@@ -2726,29 +2720,29 @@ Variable.prototype = extend(Scope.protot
return this._variablesView.toolbox;
},
/**
* Checks if this variable is a DOMNode and is part of a variablesview that
* has been linked to the toolbox, so that highlighting and jumping to the
* inspector can be done.
*/
- _isLinkableToInspector: function () {
+ _isLinkableToInspector: function() {
let isDomNode = this._valueGrip && this._valueGrip.preview.kind === "DOMNode";
let hasBeenLinked = this._linkedToInspector;
let hasToolbox = !!this.toolbox;
return isDomNode && !hasBeenLinked && hasToolbox;
},
/**
* If the variable is a DOMNode, and if a toolbox is set, then link it to the
* inspector (highlight on hover, and jump to markup-view on click)
*/
- _linkToInspector: function () {
+ _linkToInspector: function() {
if (!this._isLinkableToInspector()) {
return;
}
// Listen to value mouseover/click events to highlight and jump
this._valueLabel.addEventListener("mouseover", this.highlightDomNode);
this._valueLabel.addEventListener("mouseout", this.unhighlightDomNode);
@@ -2763,24 +2757,24 @@ Variable.prototype = extend(Scope.protot
/**
* In case this variable is a DOMNode and part of a variablesview that has been
* linked to the toolbox's inspector, then select the corresponding node in
* the inspector, and switch the inspector tool in the toolbox
* @return a promise that resolves when the node is selected and the inspector
* has been switched to and is ready
*/
- openNodeInInspector: function (event) {
+ openNodeInInspector: function(event) {
if (!this.toolbox) {
return promise.reject(new Error("Toolbox not available"));
}
event && event.stopPropagation();
- return (async function () {
+ return (async function() {
await this.toolbox.initInspector();
let nodeFront = this._nodeFront;
if (!nodeFront) {
nodeFront = await this.toolbox.walker.getNodeActorFromObjectActor(this._valueGrip.actor);
}
if (nodeFront) {
@@ -2793,17 +2787,17 @@ Variable.prototype = extend(Scope.protot
}
}.bind(this))();
},
/**
* In case this variable is a DOMNode and part of a variablesview that has been
* linked to the toolbox's inspector, then highlight the corresponding node
*/
- highlightDomNode: function () {
+ highlightDomNode: function() {
if (this.toolbox) {
if (this._nodeFront) {
// If the nodeFront has been retrieved before, no need to ask the server
// again for it
this.toolbox.highlighterUtils.highlightNodeFront(this._nodeFront);
return;
}
@@ -2812,28 +2806,28 @@ Variable.prototype = extend(Scope.protot
});
}
},
/**
* Unhighlight a previously highlit node
* @see highlightDomNode
*/
- unhighlightDomNode: function () {
+ unhighlightDomNode: function() {
if (this.toolbox) {
this.toolbox.highlighterUtils.unhighlight();
}
},
/**
* Sets a variable's configurable, enumerable and writable attributes,
* and specifies if it's a 'this', '<exception>', '<return>' or '__proto__'
* reference.
*/
- _setAttributes: function () {
+ _setAttributes: function() {
let ownerView = this.ownerView;
if (ownerView.preventDescriptorModifiers) {
return;
}
let descriptor = this._initialDescriptor;
let target = this._target;
let name = this._nameString;
@@ -2865,48 +2859,45 @@ Variable.prototype = extend(Scope.protot
}
if (descriptor && "getterValue" in descriptor) {
target.setAttribute("safe-getter", "");
}
if (name == "this") {
target.setAttribute("self", "");
- }
- else if (this._internalItem && name == "<exception>") {
+ } else if (this._internalItem && name == "<exception>") {
target.setAttribute("exception", "");
target.setAttribute("pseudo-item", "");
- }
- else if (this._internalItem && name == "<return>") {
+ } else if (this._internalItem && name == "<return>") {
target.setAttribute("return", "");
target.setAttribute("pseudo-item", "");
- }
- else if (name == "__proto__") {
+ } else if (name == "__proto__") {
target.setAttribute("proto", "");
target.setAttribute("pseudo-item", "");
}
if (Object.keys(descriptor).length == 0) {
target.setAttribute("pseudo-item", "");
}
},
/**
* Adds the necessary event listeners for this variable.
*/
- _addEventListeners: function () {
+ _addEventListeners: function() {
this._name.addEventListener("dblclick", this._activateNameInput);
this._valueLabel.addEventListener("mousedown", this._activateValueInput);
this._title.addEventListener("mousedown", this._onClick);
},
/**
* Makes this variable's name editable.
*/
- _activateNameInput: function (e) {
+ _activateNameInput: function(e) {
if (!this._variablesView.alignedValues) {
this._separatorLabel.hidden = true;
this._valueLabel.hidden = true;
}
EditableName.create(this, {
onSave: aKey => {
if (!this._variablesView.preventDisableOnChange) {
@@ -2921,34 +2912,34 @@ Variable.prototype = extend(Scope.protot
}
}
}, e);
},
/**
* Makes this variable's value editable.
*/
- _activateValueInput: function (e) {
+ _activateValueInput: function(e) {
EditableValue.create(this, {
onSave: aString => {
if (this._linkedToInspector) {
this.unhighlightDomNode();
}
if (!this._variablesView.preventDisableOnChange) {
this._disable();
}
this.ownerView.eval(this, aString);
}
}, e);
},
/**
* Disables this variable prior to a new name switch or value evaluation.
*/
- _disable: function () {
+ _disable: function() {
// Prevent the variable from being collapsed or expanded.
this.hideArrow();
// Hide any nodes that may offer information about the variable.
for (let node of this._title.childNodes) {
node.hidden = node != this._arrow && node != this._name;
}
this._enum.hidden = true;
@@ -2959,30 +2950,30 @@ Variable.prototype = extend(Scope.protot
* The current macro used to generate the string evaluated when performing
* a variable or property value change.
*/
evaluationMacro: VariablesView.simpleValueEvalMacro,
/**
* The click listener for the edit button.
*/
- _onEdit: function (e) {
+ _onEdit: function(e) {
if (e.button != 0) {
return;
}
e.preventDefault();
e.stopPropagation();
this._activateValueInput();
},
/**
* The click listener for the delete button.
*/
- _onDelete: function (e) {
+ _onDelete: function(e) {
if ("button" in e && e.button != 0) {
return;
}
e.preventDefault();
e.stopPropagation();
if (this.ownerView.delete) {
@@ -2990,17 +2981,17 @@ Variable.prototype = extend(Scope.protot
this.hide();
}
}
},
/**
* The click listener for the add property button.
*/
- _onAddProperty: function (e) {
+ _onAddProperty: function(e) {
if ("button" in e && e.button != 0) {
return;
}
e.preventDefault();
e.stopPropagation();
this.expanded = true;
@@ -3102,31 +3093,31 @@ Variable.prototype[Symbol.iterator] =
Property.prototype[Symbol.iterator] = function* () {
yield* this._store;
};
/**
* Forget everything recorded about added scopes, variables or properties.
* @see VariablesView.commitHierarchy
*/
-VariablesView.prototype.clearHierarchy = function () {
+VariablesView.prototype.clearHierarchy = function() {
this._prevHierarchy.clear();
this._currHierarchy.clear();
};
/**
* Perform operations on all the VariablesView Scopes, Variables and Properties
* after you've added all the items you wanted.
*
* Calling this method is optional, and does the following:
* - styles the items overridden by other items in parent scopes
* - reopens the items which were previously expanded
* - flashes the items whose values changed
*/
-VariablesView.prototype.commitHierarchy = function () {
+VariablesView.prototype.commitHierarchy = function() {
for (let [, currItem] of this._currHierarchy) {
// Avoid performing expensive operations.
if (this.commitHierarchyIgnoredItems[currItem._nameString]) {
continue;
}
let overridden = this.isOverridden(currItem);
if (overridden) {
currItem.setOverridden(true);
@@ -3157,34 +3148,34 @@ VariablesView.prototype.commitHierarchyI
* Checks if the an item was previously expanded, if it existed in a
* previous hierarchy.
*
* @param Scope | Variable | Property aItem
* The item to verify.
* @return boolean
* Whether the item was expanded.
*/
-VariablesView.prototype.wasExpanded = function (aItem) {
+VariablesView.prototype.wasExpanded = function(aItem) {
if (!(aItem instanceof Scope)) {
return false;
}
let prevItem = this._prevHierarchy.get(aItem.absoluteName || aItem._nameString);
return prevItem ? prevItem._isExpanded : false;
};
/**
* Checks if the an item's displayed value (a representation of the grip)
* has changed, if it existed in a previous hierarchy.
*
* @param Variable | Property aItem
* The item to verify.
* @return boolean
* Whether the item has changed.
*/
-VariablesView.prototype.hasChanged = function (aItem) {
+VariablesView.prototype.hasChanged = function(aItem) {
// Only analyze Variables and Properties for displayed value changes.
// Scopes are just collections of Variables and Properties and
// don't have a "value", so they can't change.
if (!(aItem instanceof Variable)) {
return false;
}
let prevItem = this._prevHierarchy.get(aItem.absoluteName);
return prevItem ? prevItem._valueString != aItem._valueString : false;
@@ -3194,17 +3185,17 @@ VariablesView.prototype.hasChanged = fun
* Checks if the an item was previously expanded, if it existed in a
* previous hierarchy.
*
* @param Scope | Variable | Property aItem
* The item to verify.
* @return boolean
* Whether the item was expanded.
*/
-VariablesView.prototype.isOverridden = function (aItem) {
+VariablesView.prototype.isOverridden = function(aItem) {
// Only analyze Variables for being overridden in different Scopes.
if (!(aItem instanceof Variable) || aItem instanceof Property) {
return false;
}
let currVariableName = aItem._nameString;
let parentScopes = this.getParentScopesForVariableOrProperty(aItem);
for (let otherScope of parentScopes) {
@@ -3219,17 +3210,17 @@ VariablesView.prototype.isOverridden = f
/**
* Returns true if the descriptor represents an undefined, null or
* primitive value.
*
* @param object aDescriptor
* The variable's descriptor.
*/
-VariablesView.isPrimitive = function (aDescriptor) {
+VariablesView.isPrimitive = function(aDescriptor) {
// For accessor property descriptors, the getter and setter need to be
// contained in 'get' and 'set' properties.
let getter = aDescriptor.get;
let setter = aDescriptor.set;
if (getter || setter) {
return false;
}
@@ -3258,17 +3249,17 @@ VariablesView.isPrimitive = function (aD
};
/**
* Returns true if the descriptor represents an undefined value.
*
* @param object aDescriptor
* The variable's descriptor.
*/
-VariablesView.isUndefined = function (aDescriptor) {
+VariablesView.isUndefined = function(aDescriptor) {
// For accessor property descriptors, the getter and setter need to be
// contained in 'get' and 'set' properties.
let getter = aDescriptor.get;
let setter = aDescriptor.set;
if (typeof getter == "object" && getter.type == "undefined" &&
typeof setter == "object" && setter.type == "undefined") {
return true;
}
@@ -3284,17 +3275,17 @@ VariablesView.isUndefined = function (aD
};
/**
* Returns true if the descriptor represents a falsy value.
*
* @param object aDescriptor
* The variable's descriptor.
*/
-VariablesView.isFalsy = function (aDescriptor) {
+VariablesView.isFalsy = function(aDescriptor) {
// As described in the remote debugger protocol, the value grip
// must be contained in a 'value' property.
let grip = aDescriptor.value;
if (typeof grip != "object") {
return !grip;
}
// For convenience, undefined, null, NaN, and -0 are all considered types.
@@ -3310,29 +3301,29 @@ VariablesView.isFalsy = function (aDescr
};
/**
* Returns true if the value is an instance of Variable or Property.
*
* @param any aValue
* The value to test.
*/
-VariablesView.isVariable = function (aValue) {
+VariablesView.isVariable = function(aValue) {
return aValue instanceof Variable;
};
/**
* Returns a standard grip for a value.
*
* @param any aValue
* The raw value to get a grip for.
* @return any
* The value's grip.
*/
-VariablesView.getGrip = function (aValue) {
+VariablesView.getGrip = function(aValue) {
switch (typeof aValue) {
case "boolean":
case "string":
return aValue;
case "number":
if (aValue === Infinity) {
return { type: "Infinity" };
} else if (aValue === -Infinity) {
@@ -3371,17 +3362,17 @@ VariablesView.getGrip = function (aValue
* Options:
* - concise: boolean that tells you want a concisely formatted string.
* - noStringQuotes: boolean that tells to not quote strings.
* - noEllipsis: boolean that tells to not add an ellipsis after the
* initial text of a longString.
* @return string
* The formatted property string.
*/
-VariablesView.getString = function (aGrip, aOptions = {}) {
+VariablesView.getString = function(aGrip, aOptions = {}) {
if (aGrip && typeof aGrip == "object") {
switch (aGrip.type) {
case "undefined":
case "null":
case "NaN":
case "Infinity":
case "-Infinity":
case "-0":
@@ -3429,116 +3420,116 @@ VariablesView.getString = function (aGri
*
* Any stringifier function must return a string. If null is returned, * then
* the default stringifier will be used. When invoked, the stringifier is
* given the same two arguments as those given to VariablesView.getString().
*/
VariablesView.stringifiers = {};
VariablesView.stringifiers.byType = {
- string: function (aGrip, {noStringQuotes}) {
+ string: function(aGrip, {noStringQuotes}) {
if (noStringQuotes) {
return aGrip;
}
return '"' + aGrip + '"';
},
- longString: function ({initial}, {noStringQuotes, noEllipsis}) {
+ longString: function({initial}, {noStringQuotes, noEllipsis}) {
let ellipsis = noEllipsis ? "" : ELLIPSIS;
if (noStringQuotes) {
return initial + ellipsis;
}
let result = '"' + initial + '"';
if (!ellipsis) {
return result;
}
return result.substr(0, result.length - 1) + ellipsis + '"';
},
- object: function (aGrip, aOptions) {
+ object: function(aGrip, aOptions) {
let {preview} = aGrip;
let stringifier;
if (aGrip.class) {
stringifier = VariablesView.stringifiers.byObjectClass[aGrip.class];
}
if (!stringifier && preview && preview.kind) {
stringifier = VariablesView.stringifiers.byObjectKind[preview.kind];
}
if (stringifier) {
return stringifier(aGrip, aOptions);
}
return null;
},
- symbol: function (aGrip, aOptions) {
+ symbol: function(aGrip, aOptions) {
const name = aGrip.name || "";
return "Symbol(" + name + ")";
},
- mapEntry: function (aGrip, {concise}) {
+ mapEntry: function(aGrip, {concise}) {
let { preview: { key, value }} = aGrip;
let keyString = VariablesView.getString(key, {
concise: true,
noStringQuotes: true,
});
let valueString = VariablesView.getString(value, { concise: true });
return keyString + " \u2192 " + valueString;
},
}; // VariablesView.stringifiers.byType
VariablesView.stringifiers.byObjectClass = {
- Function: function (aGrip, {concise}) {
+ Function: function(aGrip, {concise}) {
// TODO: Bug 948484 - support arrow functions and ES6 generators
let name = aGrip.userDisplayName || aGrip.displayName || aGrip.name || "";
name = VariablesView.getString(name, { noStringQuotes: true });
// TODO: Bug 948489 - Support functions with destructured parameters and
// rest parameters
let params = aGrip.parameterNames || "";
if (!concise) {
return "function " + name + "(" + params + ")";
}
return (name || "function ") + "(" + params + ")";
},
- RegExp: function ({displayString}) {
+ RegExp: function({displayString}) {
return VariablesView.getString(displayString, { noStringQuotes: true });
},
- Date: function ({preview}) {
+ Date: function({preview}) {
if (!preview || !("timestamp" in preview)) {
return null;
}
if (typeof preview.timestamp != "number") {
return new Date(preview.timestamp).toString(); // invalid date
}
return "Date " + new Date(preview.timestamp).toISOString();
},
- Number: function (aGrip) {
+ Number: function(aGrip) {
let {preview} = aGrip;
if (preview === undefined) {
return null;
}
return aGrip.class + " { " + VariablesView.getString(preview.wrappedValue) +
" }";
},
}; // VariablesView.stringifiers.byObjectClass
VariablesView.stringifiers.byObjectClass.Boolean =
VariablesView.stringifiers.byObjectClass.Number;
VariablesView.stringifiers.byObjectKind = {
- ArrayLike: function (aGrip, {concise}) {
+ ArrayLike: function(aGrip, {concise}) {
let {preview} = aGrip;
if (concise) {
return aGrip.class + "[" + preview.length + "]";
}
if (!preview.items) {
return null;
}
@@ -3566,17 +3557,17 @@ VariablesView.stringifiers.byObjectKind
// make sure we have the right number of commas...
result[lastHole] += ",";
}
let prefix = aGrip.class == "Array" ? "" : aGrip.class + " ";
return prefix + "[" + result.join(", ") + "]";
},
- MapLike: function (aGrip, {concise}) {
+ MapLike: function(aGrip, {concise}) {
let {preview} = aGrip;
if (concise || !preview.entries) {
let size = typeof preview.size == "number" ?
"[" + preview.size + "]" : "";
return aGrip.class + size;
}
let entries = [];
@@ -3592,35 +3583,35 @@ VariablesView.stringifiers.byObjectKind
if (typeof preview.size == "number" && preview.size > entries.length) {
let n = preview.size - entries.length;
entries.push(VariablesView.stringifiers._getNMoreString(n));
}
return aGrip.class + " {" + entries.join(", ") + "}";
},
- ObjectWithText: function (aGrip, {concise}) {
+ ObjectWithText: function(aGrip, {concise}) {
if (concise) {
return aGrip.class;
}
return aGrip.class + " " + VariablesView.getString(aGrip.preview.text);
},
- ObjectWithURL: function (aGrip, {concise}) {
+ ObjectWithURL: function(aGrip, {concise}) {
let result = aGrip.class;
let url = aGrip.preview.url;
if (!VariablesView.isFalsy({ value: url })) {
result += ` \u2192 ${getSourceNames(url)[concise ? "short" : "long"]}`;
}
return result;
},
// Stringifier for any kind of object.
- Object: function (aGrip, {concise}) {
+ Object: function(aGrip, {concise}) {
if (concise) {
return aGrip.class;
}
let {preview} = aGrip;
let props = [];
if (aGrip.class == "Promise" && aGrip.promiseState) {
@@ -3664,17 +3655,17 @@ VariablesView.stringifiers.byObjectKind
props.push(VariablesView.stringifiers._getNMoreString(diff));
}
}
let prefix = aGrip.class != "Object" ? aGrip.class + " " : "";
return prefix + "{" + props.join(", ") + "}";
}, // Object
- Error: function (aGrip, {concise}) {
+ Error: function(aGrip, {concise}) {
let {preview} = aGrip;
let name = VariablesView.getString(preview.name, { noStringQuotes: true });
if (concise) {
return name || aGrip.class;
}
let msg = name + ": " +
VariablesView.getString(preview.message, { noStringQuotes: true });
@@ -3682,17 +3673,17 @@ VariablesView.stringifiers.byObjectKind
if (!VariablesView.isFalsy({ value: preview.stack })) {
msg += "\n" + L10N.getStr("variablesViewErrorStacktrace") +
"\n" + preview.stack;
}
return msg;
},
- DOMException: function (aGrip, {concise}) {
+ DOMException: function(aGrip, {concise}) {
let {preview} = aGrip;
if (concise) {
return preview.name || aGrip.class;
}
let msg = aGrip.class + " [" + preview.name + ": " +
VariablesView.getString(preview.message) + "\n" +
"code: " + preview.code + "\n" +
@@ -3703,17 +3694,17 @@ VariablesView.stringifiers.byObjectKind
if (preview.lineNumber) {
msg += ":" + preview.lineNumber;
}
}
return msg + "]";
},
- DOMEvent: function (aGrip, {concise}) {
+ DOMEvent: function(aGrip, {concise}) {
let {preview} = aGrip;
if (!preview.type) {
return null;
}
if (concise) {
return aGrip.class + " " + preview.type;
}
@@ -3734,17 +3725,17 @@ VariablesView.stringifiers.byObjectKind
for (let prop in preview.properties) {
let value = preview.properties[prop];
props.push(prop + ": " + VariablesView.getString(value, { concise: true }));
}
return result + " {" + props.join(", ") + "}";
}, // DOMEvent
- DOMNode: function (aGrip, {concise}) {
+ DOMNode: function(aGrip, {concise}) {
let {preview} = aGrip;
switch (preview.nodeType) {
case nodeConstants.DOCUMENT_NODE: {
let result = aGrip.class;
if (preview.location) {
result += ` \u2192 ${getSourceNames(preview.location)[concise ? "short" : "long"]}`;
}
@@ -3810,39 +3801,38 @@ VariablesView.stringifiers.byObjectKind
}
default:
return null;
}
}, // DOMNode
}; // VariablesView.stringifiers.byObjectKind
-
/**
* Get the "N moreā¦" formatted string, given an N. This is used for displaying
* how many elements are not displayed in an object preview (eg. an array).
*
* @private
* @param number aNumber
* @return string
*/
-VariablesView.stringifiers._getNMoreString = function (aNumber) {
+VariablesView.stringifiers._getNMoreString = function(aNumber) {
let str = L10N.getStr("variablesViewMoreObjects");
return PluralForm.get(aNumber, str).replace("#1", aNumber);
};
/**
* Returns a custom class style for a grip.
*
* @param any aGrip
* @see Variable.setGrip
* @return string
* The custom class style.
*/
-VariablesView.getClass = function (aGrip) {
+VariablesView.getClass = function(aGrip) {
if (aGrip && typeof aGrip == "object") {
if (aGrip.preview) {
switch (aGrip.preview.kind) {
case "DOMNode":
return "token-domnode";
}
}
@@ -3876,19 +3866,19 @@ VariablesView.getClass = function (aGrip
* A monotonically-increasing counter, that guarantees the uniqueness of scope,
* variables and properties ids.
*
* @param string aName
* An optional string to prefix the id with.
* @return number
* A unique id.
*/
-var generateId = (function () {
+var generateId = (function() {
let count = 0;
- return function (aName = "") {
+ return function(aName = "") {
return aName.toLowerCase().trim().replace(/\s+/g, "-") + (++count);
};
})();
/**
* Quote and escape a string. The result will be another string containing an
* ECMAScript StringLiteral which will produce the original one when evaluated
* by `eval` or similar.
@@ -3898,18 +3888,18 @@ var generateId = (function () {
* returns an empty string.
* @return string
*/
function escapeString(aString) {
if (typeof aString !== "string") {
return "";
}
// U+2028 and U+2029 are allowed in JSON but not in ECMAScript string literals.
- return JSON.stringify(aString).replace(/\u2028/g, '\\u2028')
- .replace(/\u2029/g, '\\u2029');
+ return JSON.stringify(aString).replace(/\u2028/g, "\\u2028")
+ .replace(/\u2029/g, "\\u2029");
}
/**
* Escape some HTML special characters. We do not need full HTML serialization
* here, we just want to make strings safe to display in HTML attributes, for
* the stringifiers.
*
* @param string aString
@@ -3917,17 +3907,16 @@ function escapeString(aString) {
*/
function escapeHTML(aString) {
return aString.replace(/&/g, "&")
.replace(/"/g, """)
.replace(/</g, "<")
.replace(/>/g, ">");
}
-
/**
* An Editable encapsulates the UI of an edit box that overlays a label,
* allowing the user to edit the value.
*
* @param Variable aVariable
* The Variable or Property to make editable.
* @param object aOptions
* - onSave
@@ -3936,17 +3925,17 @@ function escapeHTML(aString) {
* The callback to call when the editable is removed for any reason.
*/
function Editable(aVariable, aOptions) {
this._variable = aVariable;
this._onSave = aOptions.onSave;
this._onCleanup = aOptions.onCleanup;
}
-Editable.create = function (aVariable, aOptions, aEvent) {
+Editable.create = function(aVariable, aOptions, aEvent) {
let editable = new this(aVariable, aOptions);
editable.activate(aEvent);
return editable;
};
Editable.prototype = {
/**
* The class name for targeting this Editable type's label element. Overridden
@@ -3967,17 +3956,17 @@ Editable.prototype = {
/**
* Activate this editable by replacing the input box it overlays and
* initialize the handlers.
*
* @param Event e [optional]
* Optionally, the Event object that was used to activate the Editable.
*/
- activate: function (e) {
+ activate: function(e) {
if (!this.shouldActivate) {
this._onCleanup && this._onCleanup();
return;
}
let { label } = this;
let initialString = label.getAttribute("value");
@@ -4018,17 +4007,17 @@ Editable.prototype = {
this._variable.locked = true;
this._variable.editing = true;
},
/**
* Remove the input box and restore the Variable or Property to its previous
* state.
*/
- deactivate: function () {
+ deactivate: function() {
this._input.removeEventListener("keydown", this._onKeydown);
this._input.removeEventListener("blur", this.deactivate);
this._input.parentNode.replaceChild(this.label, this._input);
this._input = null;
let { boxObject } = this._variable._variablesView;
boxObject.scrollBy(-this._variable._target, 0);
this._variable.locked = false;
@@ -4036,70 +4025,69 @@ Editable.prototype = {
this._variable.expanded = this._prevExpanded;
this._variable.editing = false;
this._onCleanup && this._onCleanup();
},
/**
* Save the current value and deactivate the Editable.
*/
- _save: function () {
+ _save: function() {
let initial = this.label.getAttribute("value");
let current = this._input.value.trim();
this.deactivate();
if (initial != current) {
this._onSave(current);
}
},
/**
* Called when tab is pressed, allowing subclasses to link different
* behavior to tabbing if desired.
*/
- _next: function () {
+ _next: function() {
this._save();
},
/**
* Called when escape is pressed, indicating a cancelling of editing without
* saving.
*/
- _reset: function () {
+ _reset: function() {
this.deactivate();
this._variable.focus();
},
/**
* Event handler for when the input loses focus.
*/
- _onBlur: function () {
+ _onBlur: function() {
this.deactivate();
},
/**
* Event handler for when the input receives a key press.
*/
- _onKeydown: function (e) {
+ _onKeydown: function(e) {
e.stopPropagation();
switch (e.keyCode) {
case KeyCodes.DOM_VK_TAB:
this._next();
break;
case KeyCodes.DOM_VK_RETURN:
this._save();
break;
case KeyCodes.DOM_VK_ESCAPE:
this._reset();
break;
}
},
};
-
/**
* An Editable specific to editing the name of a Variable or Property.
*/
function EditableName(aVariable, aOptions) {
Editable.call(this, aVariable, aOptions);
}
EditableName.create = Editable.create;
@@ -4111,17 +4099,16 @@ EditableName.prototype = extend(Editable
return this._variable._name;
},
get shouldActivate() {
return !!this._variable.ownerView.switch;
},
});
-
/**
* An Editable specific to editing the value of a Variable or Property.
*/
function EditableValue(aVariable, aOptions) {
Editable.call(this, aVariable, aOptions);
}
EditableValue.create = Editable.create;
@@ -4133,46 +4120,45 @@ EditableValue.prototype = extend(Editabl
return this._variable._valueLabel;
},
get shouldActivate() {
return !!this._variable.ownerView.eval;
},
});
-
/**
* An Editable specific to editing the key and value of a new property.
*/
function EditableNameAndValue(aVariable, aOptions) {
EditableName.call(this, aVariable, aOptions);
}
EditableNameAndValue.create = Editable.create;
EditableNameAndValue.prototype = extend(EditableName.prototype, {
- _reset: function (e) {
+ _reset: function(e) {
// Hide the Variable or Property if the user presses escape.
this._variable.remove();
this.deactivate();
},
- _next: function (e) {
+ _next: function(e) {
// Override _next so as to set both key and value at the same time.
let key = this._input.value;
this.label.setAttribute("value", key);
let valueEditable = EditableValue.create(this._variable, {
onSave: aValue => {
this._onSave([key, aValue]);
}
});
valueEditable._reset = () => {
this._variable.remove();
valueEditable.deactivate();
};
},
- _save: function (e) {
+ _save: function(e) {
// Both _save and _next activate the value edit box.
this._next(e);
}
});
--- a/devtools/client/shared/widgets/VariablesViewController.jsm
+++ b/devtools/client/shared/widgets/VariablesViewController.jsm
@@ -9,17 +9,17 @@ var {require} = ChromeUtils.import("reso
var {XPCOMUtils} = require("resource://gre/modules/XPCOMUtils.jsm");
var {VariablesView} = require("resource://devtools/client/shared/widgets/VariablesView.jsm");
var Services = require("Services");
var promise = require("promise");
var defer = require("devtools/shared/defer");
var {LocalizationHelper, ELLIPSIS} = require("devtools/shared/l10n");
Object.defineProperty(this, "WebConsoleUtils", {
- get: function () {
+ get: function() {
return require("devtools/client/webconsole/utils").Utils;
},
configurable: true,
enumerable: true
});
XPCOMUtils.defineLazyGetter(this, "VARIABLES_SORTING_ENABLED", () =>
Services.prefs.getBoolPref("devtools.debugger.ui.variables-sorting-enabled")
@@ -86,17 +86,17 @@ VariablesViewController.prototype = {
*
* @param object aOptions
* Options for getting the client grips. Supported options:
* - getObjectClient: callback for creating an object grip client
* - getLongStringClient: callback for creating a long string grip client
* - getEnvironmentClient: callback for creating an environment client
* - releaseActor: callback for releasing an actor when it's no longer needed
*/
- _setClientGetters: function (aOptions) {
+ _setClientGetters: function(aOptions) {
if (aOptions.getObjectClient) {
this._getObjectClient = aOptions.getObjectClient;
}
if (aOptions.getLongStringClient) {
this._getLongStringClient = aOptions.getLongStringClient;
}
if (aOptions.getEnvironmentClient) {
this._getEnvironmentClient = aOptions.getEnvironmentClient;
@@ -110,17 +110,17 @@ VariablesViewController.prototype = {
* Sets the functions used when evaluating strings in the variables view.
*
* @param object aOptions
* Options for configuring the macros. Supported options:
* - overrideValueEvalMacro: callback for creating an overriding eval macro
* - getterOrSetterEvalMacro: callback for creating a getter/setter eval macro
* - simpleValueEvalMacro: callback for creating a simple value eval macro
*/
- _setEvaluationMacros: function (aOptions) {
+ _setEvaluationMacros: function(aOptions) {
if (aOptions.overrideValueEvalMacro) {
this._overrideValueEvalMacro = aOptions.overrideValueEvalMacro;
}
if (aOptions.getterOrSetterEvalMacro) {
this._getterOrSetterEvalMacro = aOptions.getterOrSetterEvalMacro;
}
if (aOptions.simpleValueEvalMacro) {
this._simpleValueEvalMacro = aOptions.simpleValueEvalMacro;
@@ -132,17 +132,17 @@ VariablesViewController.prototype = {
*
* @param Variable aTarget
* The target Variable/Property to put the retrieved string into.
* @param LongStringActor aGrip
* The long string grip that use to retrieve the full string.
* @return Promise
* The promise that will be resolved when the string is retrieved.
*/
- _populateFromLongString: function (aTarget, aGrip) {
+ _populateFromLongString: function(aTarget, aGrip) {
let deferred = defer();
let from = aGrip.initial.length;
let to = Math.min(aGrip.length, MAX_LONG_STRING_LENGTH);
this._getLongStringClient(aGrip).substring(from, to, aResponse => {
// Stop tracking the actor because it's no longer needed.
this.releaseActor(aGrip);
@@ -162,17 +162,17 @@ VariablesViewController.prototype = {
* Adds pseudo items in case there is too many properties to display.
* Each item can expand into property slices.
*
* @param Scope aTarget
* The Scope where the properties will be placed into.
* @param object aGrip
* The property iterator grip.
*/
- _populatePropertySlices: function (aTarget, aGrip) {
+ _populatePropertySlices: function(aTarget, aGrip) {
if (aGrip.count < MAX_PROPERTY_ITEMS) {
return this._populateFromPropertyIterator(aTarget, aGrip);
}
// Divide the keys into quarters.
let items = Math.ceil(aGrip.count / 4);
let iterator = aGrip.propertyIterator;
let promises = [];
@@ -186,17 +186,17 @@ VariablesViewController.prototype = {
propertyIterator: iterator,
start: start,
count: count
};
// Query the name of the first and last items for this slice
let deferred = defer();
iterator.names([start, start + count - 1], ({ names }) => {
- let label = "[" + names[0] + ELLIPSIS + names[1] + "]";
+ let label = "[" + names[0] + ELLIPSIS + names[1] + "]";
let item = aTarget.addItem(label, {}, { internalItem: true });
item.showArrow();
this.addExpander(item, sliceGrip);
deferred.resolve();
});
promises.push(deferred.promise);
}
@@ -207,17 +207,17 @@ VariablesViewController.prototype = {
* Adds a property slice for a Variable in the view using the already
* property iterator
*
* @param Scope aTarget
* The Scope where the properties will be placed into.
* @param object aGrip
* The property iterator grip.
*/
- _populateFromPropertyIterator: function (aTarget, aGrip) {
+ _populateFromPropertyIterator: function(aTarget, aGrip) {
if (aGrip.count >= MAX_PROPERTY_ITEMS) {
// We already started to split, but there is still too many properties, split again.
return this._populatePropertySlices(aTarget, aGrip);
}
// We started slicing properties, and the slice is now small enough to be displayed
let deferred = defer();
aGrip.propertyIterator.slice(aGrip.start, aGrip.count,
({ ownProperties }) => {
@@ -240,17 +240,17 @@ VariablesViewController.prototype = {
*
* @param Scope aTarget
* The Scope where the properties will be placed into.
* @param object aGrip
* The grip to use to populate the target.
* @param string aQuery [optional]
* The query string used to fetch only a subset of properties
*/
- _populateFromObjectWithIterator: function (aTarget, aGrip, aQuery) {
+ _populateFromObjectWithIterator: function(aTarget, aGrip, aQuery) {
// FF40+ starts exposing `ownPropertyLength` on ObjectActor's grip,
// as well as `enumProperties` request.
let deferred = defer();
let objectClient = this._getObjectClient(aGrip);
let isArray = aGrip.preview && aGrip.preview.kind === "ArrayLike";
if (isArray) {
// First enumerate array items, e.g. properties from `0` to `array.length`.
let options = {
@@ -289,47 +289,46 @@ VariablesViewController.prototype = {
let sliceGrip = {
type: "property-iterator",
propertyIterator: iterator,
start: 0,
count: iterator.count
};
deferred.resolve(this._populatePropertySlices(aTarget, sliceGrip));
});
-
}
return deferred.promise;
},
/**
* Adds the given prototype in the view.
*
* @param Scope aTarget
* The Scope where the properties will be placed into.
* @param object aProtype
* The prototype grip.
*/
- _populateObjectPrototype: function (aTarget, aPrototype) {
+ _populateObjectPrototype: function(aTarget, aPrototype) {
// Add the variable's __proto__.
if (aPrototype && aPrototype.type != "null") {
let proto = aTarget.addItem("__proto__", { value: aPrototype });
this.addExpander(proto, aPrototype);
}
},
/**
* Adds properties to a Scope, Variable, or Property in the view. Triggered
* when a scope is expanded or certain variables are hovered.
*
* @param Scope aTarget
* The Scope where the properties will be placed into.
* @param object aGrip
* The grip to use to populate the target.
*/
- _populateFromObject: function (aTarget, aGrip) {
+ _populateFromObject: function(aTarget, aGrip) {
if (aGrip.class === "Proxy") {
this.addExpander(
aTarget.addItem("<target>", { value: aGrip.proxyTarget }, { internalItem: true }),
aGrip.proxyTarget);
this.addExpander(
aTarget.addItem("<handler>", { value: aGrip.proxyHandler }, { internalItem: true }),
aGrip.proxyHandler);
@@ -372,17 +371,17 @@ VariablesViewController.prototype = {
});
return deferred.promise;
});
}
return this._populateProperties(aTarget, aGrip);
},
- _populateProperties: function (aTarget, aGrip, aOptions) {
+ _populateProperties: function(aTarget, aGrip, aOptions) {
let deferred = defer();
let objectClient = this._getObjectClient(aGrip);
objectClient.getPrototypeAndProperties(aResponse => {
let ownProperties = aResponse.ownProperties || {};
let prototype = aResponse.prototype || null;
// 'safeGetterValues' is new and isn't necessary defined on old actors.
let safeGetterValues = aResponse.safeGetterValues || {};
@@ -435,17 +434,17 @@ VariablesViewController.prototype = {
/**
* Adds the scope chain elements (closures) of a function variable.
*
* @param Variable aTarget
* The variable where the properties will be placed into.
* @param Scope aScope
* The lexical environment form as specified in the protocol.
*/
- _populateWithClosure: function (aTarget, aScope) {
+ _populateWithClosure: function(aTarget, aScope) {
let objectScopes = [];
let environment = aScope;
let funcScope = aTarget.addItem("<Closure>");
funcScope.target.setAttribute("scope", "");
funcScope.showArrow();
do {
// Create a scope to contain all the inspected variables.
@@ -478,17 +477,17 @@ VariablesViewController.prototype = {
/**
* Adds nodes for every specified binding to the closure node.
*
* @param Variable aTarget
* The variable where the bindings will be placed into.
* @param object aBindings
* The bindings form as specified in the protocol.
*/
- _populateWithEnvironmentBindings: function (aTarget, aBindings) {
+ _populateWithEnvironmentBindings: function(aTarget, aBindings) {
// Add nodes for every argument in the scope.
aTarget.addItems(aBindings.arguments.reduce((accumulator, arg) => {
let name = Object.getOwnPropertyNames(arg)[0];
let descriptor = arg[name];
accumulator[name] = descriptor;
return accumulator;
}, {}), {
// Arguments aren't sorted.
@@ -501,17 +500,17 @@ VariablesViewController.prototype = {
aTarget.addItems(aBindings.variables, {
// Not all variables need to force sorted properties.
sorted: VARIABLES_SORTING_ENABLED,
// Expansion handlers must be set after the properties are added.
callback: this.addExpander
});
},
- _populateFromEntries: function (target, grip) {
+ _populateFromEntries: function(target, grip) {
let objGrip = grip.obj;
let objectClient = this._getObjectClient(objGrip);
return new promise((resolve, reject) => {
objectClient.enumEntries((response) => {
if (response.error) {
// Older server might not support the enumEntries method
console.warn(response.error + ": " + response.message);
@@ -534,17 +533,17 @@ VariablesViewController.prototype = {
* Adds an 'onexpand' callback for a variable, lazily handling
* the addition of new properties.
*
* @param Variable aTarget
* The variable where the properties will be placed into.
* @param any aSource
* The source to use to populate the target.
*/
- addExpander: function (aTarget, aSource) {
+ addExpander: function(aTarget, aSource) {
// Attach evaluation macros as necessary.
if (aTarget.getter || aTarget.setter) {
aTarget.evaluationMacro = this._overrideValueEvalMacro;
let getter = aTarget.get("get");
if (getter) {
getter.evaluationMacro = this._getterOrSetterEvalMacro;
}
let setter = aTarget.get("set");
@@ -590,17 +589,17 @@ VariablesViewController.prototype = {
*
* @param Scope aTarget
* The Scope to be expanded.
* @param object aSource
* The source to use to populate the target.
* @return Promise
* The promise that is resolved once the target has been expanded.
*/
- populate: function (aTarget, aSource) {
+ populate: function(aTarget, aSource) {
// Fetch the variables only once.
if (aTarget._fetched) {
return aTarget._fetched;
}
// Make sure the source grip is available.
if (!aSource) {
return promise.reject(new Error("No actor grip was given for the variable."));
}
@@ -676,57 +675,57 @@ VariablesViewController.prototype = {
return deferred.promise;
},
/**
* Indicates to the view if the targeted actor supports properties search
*
* @return boolean True, if the actor supports enumProperty request
*/
- supportsSearch: function () {
+ supportsSearch: function() {
// FF40+ starts exposing ownPropertyLength on object actor's grip
// as well as enumProperty which allows to query a subset of properties.
return this.objectActor && ("ownPropertyLength" in this.objectActor);
},
/**
* Try to use the actor to perform an attribute search.
*
* @param Scope aScope
* The Scope instance to populate with properties
* @param string aToken
* The query string
*/
- performSearch: function (aScope, aToken) {
+ performSearch: function(aScope, aToken) {
this._populateFromObjectWithIterator(aScope, this.objectActor, aToken)
.then(() => {
this.view.emit("fetched", "search", aScope);
});
},
/**
* Release an actor from the controller.
*
* @param object aActor
* The actor to release.
*/
- releaseActor: function (aActor) {
+ releaseActor: function(aActor) {
if (this._releaseActor) {
this._releaseActor(aActor);
}
this._actors.delete(aActor);
},
/**
* Release all the actors referenced by the controller, optionally filtered.
*
* @param function aFilter [optional]
* Callback to filter which actors are released.
*/
- releaseActors: function (aFilter) {
+ releaseActors: function(aFilter) {
for (let actor of this._actors) {
if (!aFilter || aFilter(actor)) {
this.releaseActor(actor);
}
}
},
/**
@@ -744,17 +743,17 @@ VariablesViewController.prototype = {
* Additional options for the controller:
* - overrideValueEvalMacro: @see _setEvaluationMacros
* - getterOrSetterEvalMacro: @see _setEvaluationMacros
* - simpleValueEvalMacro: @see _setEvaluationMacros
* @return Object
* - variable: the created Variable.
* - expanded: the Promise that resolves when the variable expands.
*/
- setSingleVariable: function (options, configuration = {}) {
+ setSingleVariable: function(options, configuration = {}) {
this._setEvaluationMacros(configuration);
this.view.empty();
let scope = this.view.addScope(options.label);
scope.expanded = true; // Expand the scope by default.
scope.locked = true; // Prevent collapsing the scope.
let variable = scope.addItem(undefined, { enumerable: true });
@@ -773,28 +772,27 @@ VariablesViewController.prototype = {
variable.populate(options.rawObject, { expanded: true });
populated = promise.resolve();
}
return { variable: variable, expanded: populated };
},
};
-
/**
* Attaches a VariablesViewController to a VariablesView if it doesn't already
* have one.
*
* @param VariablesView aView
* The view to attach to.
* @param object aOptions
* The options to use in creating the controller.
* @return VariablesViewController
*/
-VariablesViewController.attach = function (aView, aOptions) {
+VariablesViewController.attach = function(aView, aOptions) {
if (aView.controller) {
return aView.controller;
}
return new VariablesViewController(aView, aOptions);
};
/**
* Utility functions for handling stackframes.
@@ -802,33 +800,33 @@ VariablesViewController.attach = functio
var StackFrameUtils = this.StackFrameUtils = {
/**
* Create a textual representation for the specified stack frame
* to display in the stackframes container.
*
* @param object aFrame
* The stack frame to label.
*/
- getFrameTitle: function (aFrame) {
+ getFrameTitle: function(aFrame) {
if (aFrame.type == "call") {
let c = aFrame.callee;
return (c.name || c.userDisplayName || c.displayName || "(anonymous)");
}
return "(" + aFrame.type + ")";
},
/**
* Constructs a scope label based on its environment.
*
* @param object aEnv
* The scope's environment.
* @return string
* The scope's label.
*/
- getScopeLabel: function (aEnv) {
+ getScopeLabel: function(aEnv) {
let name = "";
// Name the outermost scope Global.
if (!aEnv.parent) {
name = L10N.getStr("globalScopeLabel");
}
// Otherwise construct the scope name.
else {