Files
firefox/devtools/shared/fronts/layout.js
T
Patrick Brosset 68112a7c1d Bug 1374587 - Avoid getting NodeActors for grids when we already know them and filter reflows; r=gl
Here we make updates on reflow slower (with a throttle) cause we don't
really need to update live.
We also filter all reflows that do not cause either the list of grids or
the current outline to change.
Finally, we also attach NodeActors to GridActor forms (when they are know)
in order to avoid one more round-trip to the server.

Globally, this makes performance of the grid panel far better on pages that
cause many reflows.

Note that this commit also fixes a debounce vs. throttle confusion that
existed in an inspector utils file. The throttle function there was actually
a debounce function, so it was renamed, and an actual throttle function
was added.

MozReview-Commit-ID: GeqgZR0o0E6
2017-06-27 12:02:53 -07:00

43 lines
1.1 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 } = require("devtools/shared/protocol");
const { gridSpec, layoutSpec } = require("devtools/shared/specs/layout");
const GridFront = FrontClassWithSpec(gridSpec, {
form: function (form, detail) {
if (detail === "actorid") {
this.actorID = form;
return;
}
this._form = form;
},
/**
* In some cases, the GridActor already knows the NodeActor ID of the node where the
* grid is located. In such cases, this getter returns the NodeFront for it.
*/
get containerNodeFront() {
if (!this._form.containerNodeActorID) {
return null;
}
return this.conn.getActor(this._form.containerNodeActorID);
},
/**
* Getter for the grid fragments data.
*/
get gridFragments() {
return this._form.gridFragments;
}
});
const LayoutFront = FrontClassWithSpec(layoutSpec, {});
exports.GridFront = GridFront;
exports.LayoutFront = LayoutFront;