1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
9 } = require("resource://devtools/shared/async-utils.js");
13 } = require("resource://devtools/shared/protocol.js");
19 } = require("resource://devtools/shared/specs/layout.js");
21 class FlexboxFront
extends FrontClassWithSpec(flexboxSpec
) {
27 * In some cases, the FlexboxActor already knows the NodeActor ID of the node where the
28 * flexbox is located. In such cases, this getter returns the NodeFront for it.
30 get containerNodeFront() {
31 if (!this._form
.containerNodeActorID
) {
35 return this.conn
.getFrontByID(this._form
.containerNodeActorID
);
39 * Get the WalkerFront instance that owns this FlexboxFront.
42 return this.parentFront
.walkerFront
;
46 * Get the computed style properties for the flex container.
49 return this._form
.properties
;
53 class FlexItemFront
extends FrontClassWithSpec(flexItemSpec
) {
59 * Get the flex item sizing data.
61 get flexItemSizing() {
62 return this._form
.flexItemSizing
;
66 * In some cases, the FlexItemActor already knows the NodeActor ID of the node where the
67 * flex item is located. In such cases, this getter returns the NodeFront for it.
70 if (!this._form
.nodeActorID
) {
74 return this.conn
.getFrontByID(this._form
.nodeActorID
);
78 * Get the WalkerFront instance that owns this FlexItemFront.
81 return this.parentFront
.walkerFront
;
85 * Get the computed style properties for the flex item.
88 return this._form
.computedStyle
;
92 * Get the style properties for the flex item.
95 return this._form
.properties
;
99 class GridFront
extends FrontClassWithSpec(gridSpec
) {
105 * In some cases, the GridActor already knows the NodeActor ID of the node where the
106 * grid is located. In such cases, this getter returns the NodeFront for it.
108 get containerNodeFront() {
109 if (!this._form
.containerNodeActorID
) {
113 return this.conn
.getFrontByID(this._form
.containerNodeActorID
);
117 * Get the WalkerFront instance that owns this GridFront.
120 return this.parentFront
.walkerFront
;
124 * Get the text direction of the grid container.
127 return this._form
.direction
;
131 * Getter for the grid fragments data.
133 get gridFragments() {
134 return this._form
.gridFragments
;
138 * Get whether or not the grid is a subgrid.
141 return !!this._form
.isSubgrid
;
145 * Get the writing mode of the grid container.
148 return this._form
.writingMode
;
152 class LayoutFront
extends FrontClassWithSpec(layoutSpec
) {
153 constructor(client
, targetFront
, parentFront
) {
154 super(client
, targetFront
, parentFront
);
156 this.getAllGrids
= safeAsyncMethod(
157 this.getAllGrids
.bind(this),
158 () => this.isDestroyed(),
163 * Get the WalkerFront instance that owns this LayoutFront.
166 return this.parentFront
;
170 if (!this.walkerFront
.rootNode
) {
173 return this.getGrids(this.walkerFront
.rootNode
);
177 exports
.FlexboxFront
= FlexboxFront
;
178 registerFront(FlexboxFront
);
179 exports
.FlexItemFront
= FlexItemFront
;
180 registerFront(FlexItemFront
);
181 exports
.GridFront
= GridFront
;
182 registerFront(GridFront
);
183 exports
.LayoutFront
= LayoutFront
;
184 registerFront(LayoutFront
);