Files
firefox/devtools/shared/fronts/changes.js
T
Razvan Caliman 71aa5a2dcf Bug 1599728 - Create ChangesFront/Actor pair for each target in inspector. r=jdescottes
Request a ChangesFront for each target as soon as is becomes available.

The on-demand approach in D54725 is abandoned because it introduces a client-server round trip on _every_ CSS mutation operation due to the need to ensure the ChangesActor is instantiated. By awaiting `changesFront.setup()` on every mutation, needless slowdown is introduced after the actor becomes available. Furthermore, the approach in D54725 spreads the knowledge about the ChangesFront in too many places in the codebase, something that will only get worse over time as the ChangesActor gains capabilities to track CSS changes from other sources or supports tracking DOM changes.

Differential Revision: https://phabricator.services.mozilla.com/D55945
2019-12-12 15:50:44 +00:00

34 lines
1.0 KiB
JavaScript

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const {
FrontClassWithSpec,
registerFront,
} = require("devtools/shared/protocol");
const { changesSpec } = require("devtools/shared/specs/changes");
/**
* ChangesFront, the front object for the ChangesActor
*/
class ChangesFront extends FrontClassWithSpec(changesSpec) {
constructor(client, targetFront, parentFront) {
super(client, targetFront, parentFront);
// Attribute name from which to retrieve the actorID out of the target actor's form
this.formAttributeName = "changesActor";
}
async initialize() {
// Ensure the corresponding ChangesActor is immediately available and ready to track
// changes by calling a method on it. Actors are lazy and won't be created until
// actually used.
await super.start();
}
}
exports.ChangesFront = ChangesFront;
registerFront(ChangesFront);