1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
|
/* 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 {
safeAsyncMethod,
} = require("resource://devtools/shared/async-utils.js");
const {
FrontClassWithSpec,
registerFront,
} = require("resource://devtools/shared/protocol.js");
const {
flexboxSpec,
flexItemSpec,
gridSpec,
layoutSpec,
} = require("resource://devtools/shared/specs/layout.js");
class FlexboxFront extends FrontClassWithSpec(flexboxSpec) {
form(form) {
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.getFrontByID(this._form.containerNodeActorID);
}
/**
* Get the WalkerFront instance that owns this FlexboxFront.
*/
get walkerFront() {
return this.parentFront.walkerFront;
}
/**
* Get the computed style properties for the flex container.
*/
get properties() {
return this._form.properties;
}
}
class FlexItemFront extends FrontClassWithSpec(flexItemSpec) {
form(form) {
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.getFrontByID(this._form.nodeActorID);
}
/**
* Get the WalkerFront instance that owns this FlexItemFront.
*/
get walkerFront() {
return this.parentFront.walkerFront;
}
/**
* 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;
}
}
class GridFront extends FrontClassWithSpec(gridSpec) {
form(form) {
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.getFrontByID(this._form.containerNodeActorID);
}
/**
* Get the WalkerFront instance that owns this GridFront.
*/
get walkerFront() {
return this.parentFront.walkerFront;
}
/**
* Get the text direction of the grid container.
*/
get direction() {
return this._form.direction;
}
/**
* Getter for the grid fragments data.
*/
get gridFragments() {
return this._form.gridFragments;
}
/**
* Get whether or not the grid is a subgrid.
*/
get isSubgrid() {
return !!this._form.isSubgrid;
}
/**
* Get the writing mode of the grid container.
*/
get writingMode() {
return this._form.writingMode;
}
}
class LayoutFront extends FrontClassWithSpec(layoutSpec) {
constructor(client, targetFront, parentFront) {
super(client, targetFront, parentFront);
this.getAllGrids = safeAsyncMethod(
this.getAllGrids.bind(this),
() => this.isDestroyed(),
[]
);
}
/**
* Get the WalkerFront instance that owns this LayoutFront.
*/
get walkerFront() {
return this.parentFront;
}
getAllGrids() {
if (!this.walkerFront.rootNode) {
return [];
}
return this.getGrids(this.walkerFront.rootNode);
}
}
exports.FlexboxFront = FlexboxFront;
registerFront(FlexboxFront);
exports.FlexItemFront = FlexItemFront;
registerFront(FlexItemFront);
exports.GridFront = GridFront;
registerFront(GridFront);
exports.LayoutFront = LayoutFront;
registerFront(LayoutFront);
|