Bug 1574506 - Migrate usage of gripNodeToFront to toolbox's new getNodeFrontFromNodeGrip function. r=nchevobbe

Differential Revision: https://phabricator.services.mozilla.com/D49990

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Gabriel Luong 2019-10-23 04:38:13 +00:00
parent 7fabe60cdf
commit fd32c2b962
5 changed files with 31 additions and 33 deletions

View File

@ -24,10 +24,9 @@ async function getNodeFront(gripOrFront, toolbox) {
if ("actorID" in gripOrFront) {
return new Promise(resolve => resolve(gripOrFront));
}
// TODO: Bug1574506 - Use the contextual WalkerFront for gripToNodeFront.
// Given a grip
const walkerFront = (await toolbox.target.getFront("inspector")).walker;
return walkerFront.gripToNodeFront(gripOrFront);
const inspectorFront = await toolbox.target.getFront("inspector");
return inspectorFront.getNodeFrontFromNodeGrip(gripOrFront);
}
DebuggerPanel.prototype = {

View File

@ -77,34 +77,34 @@ class DomTree extends Component {
const toolbox = DomProvider.getToolbox();
if (toolbox) {
onDOMNodeMouseOver = async (grip, options = {}) => {
// TODO: Bug1574506 - Use the contextual WalkerFront for gripToNodeFront.
const walkerFront = (await toolbox.target.getFront("inspector")).walker;
const nodeFront = await walkerFront.gripToNodeFront(grip);
const inspectorFront = await toolbox.target.getFront("inspector");
const nodeFront = await inspectorFront.getNodeFrontFromNodeGrip(grip);
const { highlighterFront } = nodeFront;
return highlighterFront.highlight(nodeFront, options);
};
onDOMNodeMouseOut = async grip => {
// TODO: Bug1574506 - Use the contextual WalkerFront for gripToNodeFront.
const walkerFront = (await toolbox.target.getFront("inspector")).walker;
const nodeFront = await walkerFront.gripToNodeFront(grip);
const inspectorFront = await toolbox.target.getFront("inspector");
const nodeFront = await inspectorFront.getNodeFrontFromNodeGrip(grip);
nodeFront.highlighterFront.unhighlight();
};
onInspectIconClick = async grip => {
// TODO: Bug1574506 - Use the contextual WalkerFront for gripToNodeFront.
const walkerFront = (await toolbox.target.getFront("inspector")).walker;
const onSelectInspector = toolbox.selectTool(
"inspector",
"inspect_dom"
);
const onGripNodeToFront = walkerFront.gripToNodeFront(grip);
const [front, inspector] = await Promise.all([
onGripNodeToFront,
const onNodeFront = toolbox.target
.getFront("inspector")
.then(inspectorFront =>
inspectorFront.getNodeFrontFromNodeGrip(grip)
);
const [nodeFront, inspectorPanel] = await Promise.all([
onNodeFront,
onSelectInspector,
]);
const onInspectorUpdated = inspector.once("inspector-updated");
const onNodeFrontSet = toolbox.selection.setNodeFront(front, {
reason: "console",
const onInspectorUpdated = inspectorPanel.once("inspector-updated");
const onNodeFrontSet = toolbox.selection.setNodeFront(nodeFront, {
reason: "dom",
});
return Promise.all([onNodeFrontSet, onInspectorUpdated]);

View File

@ -71,27 +71,26 @@ class ExtensionSidebar {
},
serviceContainer: {
highlightDomElement: async (grip, options = {}) => {
// TODO: Bug1574506 - Use the contextual WalkerFront for gripToNodeFront.
const nodeFront = await this.inspector.walker.gripToNodeFront(
const nodeFront = await this.inspector.inspectorFront.getNodeFrontFromNodeGrip(
grip
);
return nodeFront.highlighterFront.highlight(nodeFront, options);
},
unHighlightDomElement: async grip => {
// TODO: Bug1574506 - Use the contextual WalkerFront for gripToNodeFront.
const nodeFront = await this.inspector.walker.gripToNodeFront(
const nodeFront = await this.inspector.inspectorFront.getNodeFrontFromNodeGrip(
grip
);
return nodeFront.highlighterFront.unhighlight();
},
openNodeInInspector: async grip => {
const { walker } = this.inspector;
const front = await walker.gripToNodeFront(grip);
const nodeFront = await this.inspector.inspectorFront.getNodeFrontFromNodeGrip(
grip
);
const onInspectorUpdated = this.inspector.once(
"inspector-updated"
);
const onNodeFrontSet = this.inspector.toolbox.selection.setNodeFront(
front,
nodeFront,
{
reason: "inspector-extension-sidebar",
}

View File

@ -1881,8 +1881,9 @@ Inspector.prototype = {
},
async inspectNodeActor(nodeActor, inspectFromAnnotation) {
// TODO: Bug1574506 - Use the contextual WalkerFront for gripToNodeFront.
const nodeFront = await this.walker.gripToNodeFront({ actor: nodeActor });
const nodeFront = await this.inspectorFront.getNodeFrontFromNodeGrip({
actor: nodeActor,
});
if (!nodeFront) {
console.error(
"The object cannot be linked to the inspector, the " +

View File

@ -2906,9 +2906,8 @@ Variable.prototype = extend(Scope.prototype, {
return async function() {
let nodeFront = this._nodeFront;
if (!nodeFront) {
// TODO: Bug1574506 - Use the contextual WalkerFront for gripToNodeFront.
const inspectorFront = await this.toolbox.target.getFront("inspector");
nodeFront = await inspectorFront.walker.gripToNodeFront(
nodeFront = await inspectorFront.getNodeFrontFromNodeGrip(
this._valueGrip
);
}
@ -2938,10 +2937,10 @@ Variable.prototype = extend(Scope.prototype, {
}
if (!this._nodeFront) {
// TODO: Bug1574506 - Use the contextual WalkerFront for gripToNodeFront.
const walkerFront = (await this.toolbox.target.getFront("inspector"))
.walker;
this.nodeFront = await walkerFront.gripToNodeFront(this._valueGrip);
const inspectorFront = await this.toolbox.target.getFront("inspector");
this.nodeFront = await inspectorFront.getNodeFrontFromNodeGrip(
this._valueGrip
);
}
await this.nodeFront.highlighterFront.highlight(this._nodeFront);