Bug 843019 - Add VariablesViewController#setSingleVariable. r=vp, r=msucan
This commit is contained in:
@@ -65,6 +65,7 @@ Cu.import("resource:///modules/devtools/sourceeditor/source-editor.jsm");
|
|||||||
Cu.import("resource:///modules/devtools/shared/event-emitter.js");
|
Cu.import("resource:///modules/devtools/shared/event-emitter.js");
|
||||||
Cu.import("resource:///modules/devtools/SideMenuWidget.jsm");
|
Cu.import("resource:///modules/devtools/SideMenuWidget.jsm");
|
||||||
Cu.import("resource:///modules/devtools/VariablesView.jsm");
|
Cu.import("resource:///modules/devtools/VariablesView.jsm");
|
||||||
|
Cu.import("resource:///modules/devtools/VariablesViewController.jsm");
|
||||||
Cu.import("resource:///modules/devtools/ViewHelpers.jsm");
|
Cu.import("resource:///modules/devtools/ViewHelpers.jsm");
|
||||||
|
|
||||||
XPCOMUtils.defineLazyModuleGetter(this, "PluralForm",
|
XPCOMUtils.defineLazyModuleGetter(this, "PluralForm",
|
||||||
|
|||||||
@@ -1539,6 +1539,7 @@ NetworkDetailsView.prototype = {
|
|||||||
Heritage.extend(GENERIC_VARIABLES_VIEW_SETTINGS, {
|
Heritage.extend(GENERIC_VARIABLES_VIEW_SETTINGS, {
|
||||||
searchPlaceholder: L10N.getStr("jsonFilterText")
|
searchPlaceholder: L10N.getStr("jsonFilterText")
|
||||||
}));
|
}));
|
||||||
|
VariablesViewController.attach(this._json);
|
||||||
|
|
||||||
this._paramsQueryString = L10N.getStr("paramsQueryString");
|
this._paramsQueryString = L10N.getStr("paramsQueryString");
|
||||||
this._paramsFormData = L10N.getStr("paramsFormData");
|
this._paramsFormData = L10N.getStr("paramsFormData");
|
||||||
@@ -1889,9 +1890,10 @@ NetworkDetailsView.prototype = {
|
|||||||
? L10N.getFormatStr("jsonpScopeName", callbackPadding[0].slice(0, -1))
|
? L10N.getFormatStr("jsonpScopeName", callbackPadding[0].slice(0, -1))
|
||||||
: L10N.getStr("jsonScopeName");
|
: L10N.getStr("jsonScopeName");
|
||||||
|
|
||||||
let jsonScope = this._json.addScope(jsonScopeName);
|
this._json.controller.setSingleVariable({
|
||||||
jsonScope.addItem().populate(jsonObject, { expanded: true });
|
label: jsonScopeName,
|
||||||
jsonScope.expanded = true;
|
rawObject: jsonObject,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
// Malformed JSON.
|
// Malformed JSON.
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -1831,15 +1831,10 @@ ScratchpadSidebar.prototype = {
|
|||||||
*/
|
*/
|
||||||
_update: function SS__update(aObject)
|
_update: function SS__update(aObject)
|
||||||
{
|
{
|
||||||
|
let options = { objectActor: aObject };
|
||||||
let view = this.variablesView;
|
let view = this.variablesView;
|
||||||
view.empty();
|
view.empty();
|
||||||
|
return view.controller.setSingleVariable(options).expanded;
|
||||||
let scope = view.addScope();
|
|
||||||
scope.expanded = true;
|
|
||||||
scope.locked = true;
|
|
||||||
|
|
||||||
let container = scope.addItem();
|
|
||||||
return view.controller.expand(container, aObject);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ this.EXPORTED_SYMBOLS = ["VariablesViewController", "StackFrameUtils"];
|
|||||||
*
|
*
|
||||||
* @param VariablesView aView
|
* @param VariablesView aView
|
||||||
* The view to attach to.
|
* The view to attach to.
|
||||||
* @param object aOptions
|
* @param object aOptions [optional]
|
||||||
* Options for configuring the controller. Supported options:
|
* Options for configuring the controller. Supported options:
|
||||||
* - getObjectClient: callback for creating an object grip client
|
* - getObjectClient: callback for creating an object grip client
|
||||||
* - getLongStringClient: callback for creating a long string grip client
|
* - getLongStringClient: callback for creating a long string grip client
|
||||||
@@ -54,7 +54,7 @@ this.EXPORTED_SYMBOLS = ["VariablesViewController", "StackFrameUtils"];
|
|||||||
* - getterOrSetterEvalMacro: callback for creating a getter/setter eval macro
|
* - getterOrSetterEvalMacro: callback for creating a getter/setter eval macro
|
||||||
* - simpleValueEvalMacro: callback for creating a simple value eval macro
|
* - simpleValueEvalMacro: callback for creating a simple value eval macro
|
||||||
*/
|
*/
|
||||||
function VariablesViewController(aView, aOptions) {
|
function VariablesViewController(aView, aOptions = {}) {
|
||||||
this.addExpander = this.addExpander.bind(this);
|
this.addExpander = this.addExpander.bind(this);
|
||||||
|
|
||||||
this._getObjectClient = aOptions.getObjectClient;
|
this._getObjectClient = aOptions.getObjectClient;
|
||||||
@@ -442,6 +442,37 @@ VariablesViewController.prototype = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function for setting up a single Scope with a single Variable
|
||||||
|
* contained within it.
|
||||||
|
*
|
||||||
|
* @param object aOptions
|
||||||
|
* Options for the contents of the view:
|
||||||
|
* - objectActor: the grip of the new ObjectActor to show.
|
||||||
|
* - rawObject: the new raw object to show.
|
||||||
|
* - label: the new label for the inspected object.
|
||||||
|
* @return Object
|
||||||
|
* - variable: the created Variable.
|
||||||
|
* - expanded: the Promise that resolves when the variable expands.
|
||||||
|
*/
|
||||||
|
setSingleVariable: function(aOptions) {
|
||||||
|
let scope = this.view.addScope(aOptions.label);
|
||||||
|
scope.expanded = true;
|
||||||
|
scope.locked = true;
|
||||||
|
|
||||||
|
let variable = scope.addItem();
|
||||||
|
let expanded;
|
||||||
|
|
||||||
|
if (aOptions.objectActor) {
|
||||||
|
expanded = this.expand(variable, aOptions.objectActor);
|
||||||
|
} else if (aOptions.rawObject) {
|
||||||
|
variable.populate(aOptions.rawObject, { expanded: true });
|
||||||
|
expanded = promise.resolve();
|
||||||
|
}
|
||||||
|
|
||||||
|
return { variable: variable, expanded: expanded };
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3485,20 +3485,13 @@ JSTerm.prototype = {
|
|||||||
view.delete = null;
|
view.delete = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
let scope = view.addScope(aOptions.label);
|
let { variable, expanded } = view.controller.setSingleVariable(aOptions);
|
||||||
scope.expanded = true;
|
variable.evaluationMacro = simpleValueEvalMacro;
|
||||||
scope.locked = true;
|
|
||||||
|
|
||||||
let container = scope.addItem();
|
|
||||||
container.evaluationMacro = simpleValueEvalMacro;
|
|
||||||
|
|
||||||
if (aOptions.objectActor) {
|
if (aOptions.objectActor) {
|
||||||
view.controller.expand(container, aOptions.objectActor);
|
|
||||||
view._consoleLastObjectActor = aOptions.objectActor.actor;
|
view._consoleLastObjectActor = aOptions.objectActor.actor;
|
||||||
}
|
}
|
||||||
else if (aOptions.rawObject) {
|
else if (aOptions.rawObject) {
|
||||||
container.populate(aOptions.rawObject);
|
|
||||||
view.commitHierarchy();
|
|
||||||
view._consoleLastObjectActor = null;
|
view._consoleLastObjectActor = null;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -3506,7 +3499,9 @@ JSTerm.prototype = {
|
|||||||
"display.");
|
"display.");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.emit("variablesview-updated", view, aOptions);
|
expanded.then(() => {
|
||||||
|
this.emit("variablesview-updated", view, aOptions);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user