gecko-dev/devtools/shared/fronts/layout.js
Patrick Brosset 1be47d2001 Bug 1501066 - part 2 - Simplify flexibility info and bail out when useless; r=mtigley
In cases where an item did not grow or shrink, devtools doesn't really have access
to any useful information about how the item might have wanted to flex.
So in this change, I'm just making sure we don't attempt to display this info at
all, because it's basically incorrect otherwise.

Depends on D10235

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

--HG--
extra : moz-landing-system : lando
2018-10-31 17:49:14 +00:00

146 lines
3.2 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 {
flexboxSpec,
flexItemSpec,
gridSpec,
layoutSpec,
} = require("devtools/shared/specs/layout");
const FlexboxFront = FrontClassWithSpec(flexboxSpec, {
form: function(form, detail) {
if (detail === "actorid") {
this.actorID = form;
return;
}
this._form = form;
},
/**
* In some cases, the FlexboxActor already knows the NodeActor ID of the node where the
* flexbox 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);
},
/**
* Get the computed style properties for the flex container.
*/
get properties() {
return this._form.properties;
},
});
const FlexItemFront = FrontClassWithSpec(flexItemSpec, {
form: function(form, detail) {
if (detail === "actorid") {
this.actorID = form;
return;
}
this._form = form;
},
/**
* Get the flex item sizing data.
*/
get flexItemSizing() {
return this._form.flexItemSizing;
},
/**
* In some cases, the FlexItemActor already knows the NodeActor ID of the node where the
* flex item is located. In such cases, this getter returns the NodeFront for it.
*/
get nodeFront() {
if (!this._form.nodeActorID) {
return null;
}
return this.conn.getActor(this._form.nodeActorID);
},
/**
* Get the computed style properties for the flex item.
*/
get computedStyle() {
return this._form.computedStyle;
},
/**
* Get the style properties for the flex item.
*/
get properties() {
return this._form.properties;
},
});
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);
},
/**
* Get the text direction of the grid container.
* Added in Firefox 60.
*/
get direction() {
if (!this._form.direction) {
return "ltr";
}
return this._form.direction;
},
/**
* Getter for the grid fragments data.
*/
get gridFragments() {
return this._form.gridFragments;
},
/**
* Get the writing mode of the grid container.
* Added in Firefox 60.
*/
get writingMode() {
if (!this._form.writingMode) {
return "horizontal-tb";
}
return this._form.writingMode;
},
});
const LayoutFront = FrontClassWithSpec(layoutSpec, {});
exports.FlexboxFront = FlexboxFront;
exports.FlexItemFront = FlexItemFront;
exports.GridFront = GridFront;
exports.LayoutFront = LayoutFront;