@alchemy.run/sigil 0.0.0-alpha.1 → 0.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +299 -299
- package/dist/ansi.d.ts +223 -0
- package/dist/ansi.js +2 -0
- package/dist/{devtools-QpCMm9JH.mjs → devtools-BhYGjb7h.js} +1 -1
- package/dist/index-DDVME65c.d.ts +919 -0
- package/dist/index.d.ts +1657 -0
- package/dist/index.js +4643 -0
- package/dist/sgr-CMfEpjSk.d.ts +91 -0
- package/dist/truncate-CBiyyZzw.js +2156 -0
- package/dist/yoga-5jKhYCJC.js +3465 -0
- package/dist/yoga.d.ts +2 -0
- package/dist/yoga.js +2 -0
- package/package.json +37 -17
- package/src/ansi/chalk.ts +179 -0
- package/src/ansi/cursor.ts +48 -0
- package/src/ansi/east-asian-width.ts +215 -0
- package/src/ansi/escapes.ts +128 -0
- package/src/ansi/index.ts +27 -0
- package/src/ansi/sgr.ts +237 -0
- package/src/ansi/slice.ts +43 -0
- package/src/ansi/string-width.ts +236 -0
- package/src/ansi/strip.ts +33 -0
- package/src/ansi/supports-color.ts +213 -0
- package/src/ansi/tokenize.ts +453 -0
- package/src/ansi/truncate.ts +194 -0
- package/src/ansi/widest-line.ts +12 -0
- package/src/ansi/wrap.ts +766 -0
- package/src/ansi-tokenizer.ts +510 -0
- package/src/auto-bind.ts +41 -0
- package/src/boxes.ts +100 -0
- package/src/code-excerpt.ts +39 -0
- package/src/colorize.ts +60 -0
- package/src/components/AccessibilityContext.ts +5 -0
- package/src/components/AnimationContext.ts +24 -0
- package/src/components/App.tsx +781 -0
- package/src/components/AppContext.ts +111 -0
- package/src/components/BackgroundContext.ts +8 -0
- package/src/components/Box.tsx +116 -0
- package/src/components/CursorContext.ts +19 -0
- package/src/components/ErrorBoundary.tsx +38 -0
- package/src/components/ErrorOverview.tsx +133 -0
- package/src/components/FocusContext.ts +30 -0
- package/src/components/Newline.tsx +15 -0
- package/src/components/Spacer.tsx +10 -0
- package/src/components/Static.tsx +59 -0
- package/src/components/StderrContext.ts +26 -0
- package/src/components/StdinContext.ts +49 -0
- package/src/components/StdoutContext.ts +28 -0
- package/src/components/Text.tsx +144 -0
- package/src/components/Transform.tsx +37 -0
- package/src/cursor-position.ts +103 -0
- package/src/devtools-window-polyfill.ts +73 -0
- package/src/devtools.ts +43 -0
- package/src/dom.ts +292 -0
- package/src/get-max-width.ts +11 -0
- package/src/global.d.ts +36 -0
- package/src/hooks/use-animation.ts +142 -0
- package/src/hooks/use-app.ts +8 -0
- package/src/hooks/use-box-metrics.ts +134 -0
- package/src/hooks/use-cursor.ts +33 -0
- package/src/hooks/use-focus-manager.ts +62 -0
- package/src/hooks/use-focus.ts +83 -0
- package/src/hooks/use-input.ts +267 -0
- package/src/hooks/use-is-screen-reader-enabled.ts +12 -0
- package/src/hooks/use-paste.ts +78 -0
- package/src/hooks/use-stderr.ts +8 -0
- package/src/hooks/use-stdin.ts +10 -0
- package/src/hooks/use-stdout.ts +8 -0
- package/src/hooks/use-window-size.ts +41 -0
- package/src/indent-string.ts +16 -0
- package/src/index.ts +44 -0
- package/src/ink.tsx +1506 -0
- package/src/input-parser.ts +283 -0
- package/src/instances.ts +9 -0
- package/src/is-in-ci.ts +7 -0
- package/src/kitty-keyboard.ts +57 -0
- package/src/log-update.ts +370 -0
- package/src/measure-element.ts +62 -0
- package/src/measure-text.ts +31 -0
- package/src/output.ts +308 -0
- package/src/parse-keypress.ts +516 -0
- package/src/parse-stack-line.ts +139 -0
- package/src/patch-console.ts +62 -0
- package/src/quick-lru.ts +85 -0
- package/src/reconciler.ts +451 -0
- package/src/render-background.ts +38 -0
- package/src/render-border.ts +134 -0
- package/src/render-node-to-output.ts +191 -0
- package/src/render-to-string.ts +131 -0
- package/src/render.ts +276 -0
- package/src/renderer.ts +73 -0
- package/src/sanitize-ansi.ts +33 -0
- package/src/signal-exit.ts +107 -0
- package/src/squash-text-nodes.ts +40 -0
- package/src/stream.ts +30 -0
- package/src/styles.ts +748 -0
- package/src/terminal-size.ts +57 -0
- package/src/throttle.ts +73 -0
- package/src/types.ts +15 -0
- package/src/utils.ts +40 -0
- package/src/wrap-text.ts +50 -0
- package/src/write-synchronized.ts +9 -0
- package/src/yoga/config.ts +57 -0
- package/src/yoga/core/absoluteLayout.ts +626 -0
- package/src/yoga/core/baseline.ts +66 -0
- package/src/yoga/core/cache.ts +136 -0
- package/src/yoga/core/calculateLayout.ts +2920 -0
- package/src/yoga/core/config.ts +104 -0
- package/src/yoga/core/flexLine.ts +177 -0
- package/src/yoga/core/helpers.ts +293 -0
- package/src/yoga/core/layoutResults.ts +167 -0
- package/src/yoga/core/node.ts +611 -0
- package/src/yoga/core/numeric.ts +44 -0
- package/src/yoga/core/pixelGrid.ts +151 -0
- package/src/yoga/core/style.ts +887 -0
- package/src/yoga/core/types.ts +224 -0
- package/src/yoga/generated/YGEnums.ts +263 -0
- package/src/yoga/index.ts +19 -0
- package/src/yoga/node.ts +1140 -0
- package/dist/index.d.mts +0 -2379
- package/dist/index.mjs +0 -10072
|
@@ -0,0 +1,3465 @@
|
|
|
1
|
+
//#region src/yoga/generated/YGEnums.ts
|
|
2
|
+
const Align = {
|
|
3
|
+
Auto: 0,
|
|
4
|
+
FlexStart: 1,
|
|
5
|
+
Center: 2,
|
|
6
|
+
FlexEnd: 3,
|
|
7
|
+
Stretch: 4,
|
|
8
|
+
Baseline: 5,
|
|
9
|
+
SpaceBetween: 6,
|
|
10
|
+
SpaceAround: 7,
|
|
11
|
+
SpaceEvenly: 8,
|
|
12
|
+
Start: 9,
|
|
13
|
+
End: 10
|
|
14
|
+
};
|
|
15
|
+
const BoxSizing = {
|
|
16
|
+
BorderBox: 0,
|
|
17
|
+
ContentBox: 1
|
|
18
|
+
};
|
|
19
|
+
const Dimension = {
|
|
20
|
+
Width: 0,
|
|
21
|
+
Height: 1
|
|
22
|
+
};
|
|
23
|
+
const Direction = {
|
|
24
|
+
Inherit: 0,
|
|
25
|
+
LTR: 1,
|
|
26
|
+
RTL: 2
|
|
27
|
+
};
|
|
28
|
+
const Display = {
|
|
29
|
+
Flex: 0,
|
|
30
|
+
None: 1,
|
|
31
|
+
Contents: 2,
|
|
32
|
+
Grid: 3
|
|
33
|
+
};
|
|
34
|
+
const Edge = {
|
|
35
|
+
Left: 0,
|
|
36
|
+
Top: 1,
|
|
37
|
+
Right: 2,
|
|
38
|
+
Bottom: 3,
|
|
39
|
+
Start: 4,
|
|
40
|
+
End: 5,
|
|
41
|
+
Horizontal: 6,
|
|
42
|
+
Vertical: 7,
|
|
43
|
+
All: 8
|
|
44
|
+
};
|
|
45
|
+
const Errata = {
|
|
46
|
+
None: 0,
|
|
47
|
+
StretchFlexBasis: 1,
|
|
48
|
+
AbsolutePositionWithoutInsetsExcludesPadding: 2,
|
|
49
|
+
AbsolutePercentAgainstInnerSize: 4,
|
|
50
|
+
MinSizeUndefinedInsteadOfAuto: 8,
|
|
51
|
+
All: 2147483647,
|
|
52
|
+
Classic: 2147483646
|
|
53
|
+
};
|
|
54
|
+
const ExperimentalFeature = {
|
|
55
|
+
WebFlexBasis: 0,
|
|
56
|
+
FixFlexBasisFitContent: 1
|
|
57
|
+
};
|
|
58
|
+
const FlexDirection = {
|
|
59
|
+
Column: 0,
|
|
60
|
+
ColumnReverse: 1,
|
|
61
|
+
Row: 2,
|
|
62
|
+
RowReverse: 3
|
|
63
|
+
};
|
|
64
|
+
const GridTrackType = {
|
|
65
|
+
Auto: 0,
|
|
66
|
+
Points: 1,
|
|
67
|
+
Percent: 2,
|
|
68
|
+
Fr: 3,
|
|
69
|
+
Minmax: 4
|
|
70
|
+
};
|
|
71
|
+
const Gutter = {
|
|
72
|
+
Column: 0,
|
|
73
|
+
Row: 1,
|
|
74
|
+
All: 2
|
|
75
|
+
};
|
|
76
|
+
const Justify = {
|
|
77
|
+
Auto: 0,
|
|
78
|
+
FlexStart: 1,
|
|
79
|
+
Center: 2,
|
|
80
|
+
FlexEnd: 3,
|
|
81
|
+
SpaceBetween: 4,
|
|
82
|
+
SpaceAround: 5,
|
|
83
|
+
SpaceEvenly: 6,
|
|
84
|
+
Stretch: 7,
|
|
85
|
+
Start: 8,
|
|
86
|
+
End: 9
|
|
87
|
+
};
|
|
88
|
+
const LogLevel = {
|
|
89
|
+
Error: 0,
|
|
90
|
+
Warn: 1,
|
|
91
|
+
Info: 2,
|
|
92
|
+
Debug: 3,
|
|
93
|
+
Verbose: 4,
|
|
94
|
+
Fatal: 5
|
|
95
|
+
};
|
|
96
|
+
const MeasureMode = {
|
|
97
|
+
Undefined: 0,
|
|
98
|
+
Exactly: 1,
|
|
99
|
+
AtMost: 2
|
|
100
|
+
};
|
|
101
|
+
const NodeType = {
|
|
102
|
+
Default: 0,
|
|
103
|
+
Text: 1
|
|
104
|
+
};
|
|
105
|
+
const Overflow = {
|
|
106
|
+
Visible: 0,
|
|
107
|
+
Hidden: 1,
|
|
108
|
+
Scroll: 2
|
|
109
|
+
};
|
|
110
|
+
const PositionType = {
|
|
111
|
+
Static: 0,
|
|
112
|
+
Relative: 1,
|
|
113
|
+
Absolute: 2
|
|
114
|
+
};
|
|
115
|
+
const Unit = {
|
|
116
|
+
Undefined: 0,
|
|
117
|
+
Point: 1,
|
|
118
|
+
Percent: 2,
|
|
119
|
+
Auto: 3,
|
|
120
|
+
MaxContent: 4,
|
|
121
|
+
FitContent: 5,
|
|
122
|
+
Stretch: 6
|
|
123
|
+
};
|
|
124
|
+
const Wrap = {
|
|
125
|
+
NoWrap: 0,
|
|
126
|
+
Wrap: 1,
|
|
127
|
+
WrapReverse: 2
|
|
128
|
+
};
|
|
129
|
+
const constants = {
|
|
130
|
+
ALIGN_AUTO: Align.Auto,
|
|
131
|
+
ALIGN_FLEX_START: Align.FlexStart,
|
|
132
|
+
ALIGN_CENTER: Align.Center,
|
|
133
|
+
ALIGN_FLEX_END: Align.FlexEnd,
|
|
134
|
+
ALIGN_STRETCH: Align.Stretch,
|
|
135
|
+
ALIGN_BASELINE: Align.Baseline,
|
|
136
|
+
ALIGN_SPACE_BETWEEN: Align.SpaceBetween,
|
|
137
|
+
ALIGN_SPACE_AROUND: Align.SpaceAround,
|
|
138
|
+
ALIGN_SPACE_EVENLY: Align.SpaceEvenly,
|
|
139
|
+
ALIGN_START: Align.Start,
|
|
140
|
+
ALIGN_END: Align.End,
|
|
141
|
+
BOX_SIZING_BORDER_BOX: BoxSizing.BorderBox,
|
|
142
|
+
BOX_SIZING_CONTENT_BOX: BoxSizing.ContentBox,
|
|
143
|
+
DIMENSION_WIDTH: Dimension.Width,
|
|
144
|
+
DIMENSION_HEIGHT: Dimension.Height,
|
|
145
|
+
DIRECTION_INHERIT: Direction.Inherit,
|
|
146
|
+
DIRECTION_LTR: Direction.LTR,
|
|
147
|
+
DIRECTION_RTL: Direction.RTL,
|
|
148
|
+
DISPLAY_FLEX: Display.Flex,
|
|
149
|
+
DISPLAY_NONE: Display.None,
|
|
150
|
+
DISPLAY_CONTENTS: Display.Contents,
|
|
151
|
+
DISPLAY_GRID: Display.Grid,
|
|
152
|
+
EDGE_LEFT: Edge.Left,
|
|
153
|
+
EDGE_TOP: Edge.Top,
|
|
154
|
+
EDGE_RIGHT: Edge.Right,
|
|
155
|
+
EDGE_BOTTOM: Edge.Bottom,
|
|
156
|
+
EDGE_START: Edge.Start,
|
|
157
|
+
EDGE_END: Edge.End,
|
|
158
|
+
EDGE_HORIZONTAL: Edge.Horizontal,
|
|
159
|
+
EDGE_VERTICAL: Edge.Vertical,
|
|
160
|
+
EDGE_ALL: Edge.All,
|
|
161
|
+
ERRATA_NONE: Errata.None,
|
|
162
|
+
ERRATA_STRETCH_FLEX_BASIS: Errata.StretchFlexBasis,
|
|
163
|
+
ERRATA_ABSOLUTE_POSITION_WITHOUT_INSETS_EXCLUDES_PADDING: Errata.AbsolutePositionWithoutInsetsExcludesPadding,
|
|
164
|
+
ERRATA_ABSOLUTE_PERCENT_AGAINST_INNER_SIZE: Errata.AbsolutePercentAgainstInnerSize,
|
|
165
|
+
ERRATA_MIN_SIZE_UNDEFINED_INSTEAD_OF_AUTO: Errata.MinSizeUndefinedInsteadOfAuto,
|
|
166
|
+
ERRATA_ALL: Errata.All,
|
|
167
|
+
ERRATA_CLASSIC: Errata.Classic,
|
|
168
|
+
EXPERIMENTAL_FEATURE_WEB_FLEX_BASIS: ExperimentalFeature.WebFlexBasis,
|
|
169
|
+
EXPERIMENTAL_FEATURE_FIX_FLEX_BASIS_FIT_CONTENT: ExperimentalFeature.FixFlexBasisFitContent,
|
|
170
|
+
FLEX_DIRECTION_COLUMN: FlexDirection.Column,
|
|
171
|
+
FLEX_DIRECTION_COLUMN_REVERSE: FlexDirection.ColumnReverse,
|
|
172
|
+
FLEX_DIRECTION_ROW: FlexDirection.Row,
|
|
173
|
+
FLEX_DIRECTION_ROW_REVERSE: FlexDirection.RowReverse,
|
|
174
|
+
GRID_TRACK_TYPE_AUTO: GridTrackType.Auto,
|
|
175
|
+
GRID_TRACK_TYPE_POINTS: GridTrackType.Points,
|
|
176
|
+
GRID_TRACK_TYPE_PERCENT: GridTrackType.Percent,
|
|
177
|
+
GRID_TRACK_TYPE_FR: GridTrackType.Fr,
|
|
178
|
+
GRID_TRACK_TYPE_MINMAX: GridTrackType.Minmax,
|
|
179
|
+
GUTTER_COLUMN: Gutter.Column,
|
|
180
|
+
GUTTER_ROW: Gutter.Row,
|
|
181
|
+
GUTTER_ALL: Gutter.All,
|
|
182
|
+
JUSTIFY_AUTO: Justify.Auto,
|
|
183
|
+
JUSTIFY_FLEX_START: Justify.FlexStart,
|
|
184
|
+
JUSTIFY_CENTER: Justify.Center,
|
|
185
|
+
JUSTIFY_FLEX_END: Justify.FlexEnd,
|
|
186
|
+
JUSTIFY_SPACE_BETWEEN: Justify.SpaceBetween,
|
|
187
|
+
JUSTIFY_SPACE_AROUND: Justify.SpaceAround,
|
|
188
|
+
JUSTIFY_SPACE_EVENLY: Justify.SpaceEvenly,
|
|
189
|
+
JUSTIFY_STRETCH: Justify.Stretch,
|
|
190
|
+
JUSTIFY_START: Justify.Start,
|
|
191
|
+
JUSTIFY_END: Justify.End,
|
|
192
|
+
LOG_LEVEL_ERROR: LogLevel.Error,
|
|
193
|
+
LOG_LEVEL_WARN: LogLevel.Warn,
|
|
194
|
+
LOG_LEVEL_INFO: LogLevel.Info,
|
|
195
|
+
LOG_LEVEL_DEBUG: LogLevel.Debug,
|
|
196
|
+
LOG_LEVEL_VERBOSE: LogLevel.Verbose,
|
|
197
|
+
LOG_LEVEL_FATAL: LogLevel.Fatal,
|
|
198
|
+
MEASURE_MODE_UNDEFINED: MeasureMode.Undefined,
|
|
199
|
+
MEASURE_MODE_EXACTLY: MeasureMode.Exactly,
|
|
200
|
+
MEASURE_MODE_AT_MOST: MeasureMode.AtMost,
|
|
201
|
+
NODE_TYPE_DEFAULT: NodeType.Default,
|
|
202
|
+
NODE_TYPE_TEXT: NodeType.Text,
|
|
203
|
+
OVERFLOW_VISIBLE: Overflow.Visible,
|
|
204
|
+
OVERFLOW_HIDDEN: Overflow.Hidden,
|
|
205
|
+
OVERFLOW_SCROLL: Overflow.Scroll,
|
|
206
|
+
POSITION_TYPE_STATIC: PositionType.Static,
|
|
207
|
+
POSITION_TYPE_RELATIVE: PositionType.Relative,
|
|
208
|
+
POSITION_TYPE_ABSOLUTE: PositionType.Absolute,
|
|
209
|
+
UNIT_UNDEFINED: Unit.Undefined,
|
|
210
|
+
UNIT_POINT: Unit.Point,
|
|
211
|
+
UNIT_PERCENT: Unit.Percent,
|
|
212
|
+
UNIT_AUTO: Unit.Auto,
|
|
213
|
+
UNIT_MAX_CONTENT: Unit.MaxContent,
|
|
214
|
+
UNIT_FIT_CONTENT: Unit.FitContent,
|
|
215
|
+
UNIT_STRETCH: Unit.Stretch,
|
|
216
|
+
WRAP_NO_WRAP: Wrap.NoWrap,
|
|
217
|
+
WRAP_WRAP: Wrap.Wrap,
|
|
218
|
+
WRAP_WRAP_REVERSE: Wrap.WrapReverse
|
|
219
|
+
};
|
|
220
|
+
//#endregion
|
|
221
|
+
//#region src/yoga/core/config.ts
|
|
222
|
+
function configUpdateInvalidatesLayout(oldConfig, newConfig) {
|
|
223
|
+
return oldConfig.getErrata() !== newConfig.getErrata() || oldConfig.getEnabledExperiments() !== newConfig.getEnabledExperiments() || oldConfig.getPointScaleFactor() !== newConfig.getPointScaleFactor() || oldConfig.useWebDefaults() !== newConfig.useWebDefaults();
|
|
224
|
+
}
|
|
225
|
+
var Config$1 = class {
|
|
226
|
+
useWebDefaults_ = false;
|
|
227
|
+
version_ = 0;
|
|
228
|
+
experimentalFeatures_ = 0;
|
|
229
|
+
errata_ = Errata.MinSizeUndefinedInsteadOfAuto;
|
|
230
|
+
pointScaleFactor_ = 1;
|
|
231
|
+
setUseWebDefaults(useWebDefaults) {
|
|
232
|
+
this.useWebDefaults_ = useWebDefaults;
|
|
233
|
+
}
|
|
234
|
+
useWebDefaults() {
|
|
235
|
+
return this.useWebDefaults_;
|
|
236
|
+
}
|
|
237
|
+
setExperimentalFeatureEnabled(feature, enabled) {
|
|
238
|
+
if (this.isExperimentalFeatureEnabled(feature) !== enabled) {
|
|
239
|
+
this.experimentalFeatures_ = enabled ? this.experimentalFeatures_ | 1 << feature : this.experimentalFeatures_ & ~(1 << feature);
|
|
240
|
+
this.version_++;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
isExperimentalFeatureEnabled(feature) {
|
|
244
|
+
return (this.experimentalFeatures_ & 1 << feature) !== 0;
|
|
245
|
+
}
|
|
246
|
+
getEnabledExperiments() {
|
|
247
|
+
return this.experimentalFeatures_;
|
|
248
|
+
}
|
|
249
|
+
setErrata(errata) {
|
|
250
|
+
if (this.errata_ !== errata) {
|
|
251
|
+
this.errata_ = errata;
|
|
252
|
+
this.version_++;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
addErrata(errata) {
|
|
256
|
+
if (!this.hasErrata(errata)) {
|
|
257
|
+
this.errata_ |= errata;
|
|
258
|
+
this.version_++;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
removeErrata(errata) {
|
|
262
|
+
if (this.hasErrata(errata)) {
|
|
263
|
+
this.errata_ &= ~errata;
|
|
264
|
+
this.version_++;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
getErrata() {
|
|
268
|
+
return this.errata_;
|
|
269
|
+
}
|
|
270
|
+
hasErrata(errata) {
|
|
271
|
+
return (this.errata_ & errata) !== Errata.None;
|
|
272
|
+
}
|
|
273
|
+
setPointScaleFactor(pointScaleFactor) {
|
|
274
|
+
const value = pointScaleFactor;
|
|
275
|
+
if (this.pointScaleFactor_ !== value) {
|
|
276
|
+
this.pointScaleFactor_ = value;
|
|
277
|
+
this.version_++;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
getPointScaleFactor() {
|
|
281
|
+
return this.pointScaleFactor_;
|
|
282
|
+
}
|
|
283
|
+
getVersion() {
|
|
284
|
+
return this.version_;
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
let defaultConfig = null;
|
|
288
|
+
function getDefaultConfig() {
|
|
289
|
+
if (defaultConfig === null) defaultConfig = new Config$1();
|
|
290
|
+
return defaultConfig;
|
|
291
|
+
}
|
|
292
|
+
//#endregion
|
|
293
|
+
//#region src/yoga/config.ts
|
|
294
|
+
/**
|
|
295
|
+
* Public Config wrapper over the core config, exposing the same surface as
|
|
296
|
+
* the WASM binding's ConfigImpl.
|
|
297
|
+
*/
|
|
298
|
+
var Config = class Config {
|
|
299
|
+
/** @internal */
|
|
300
|
+
core = new Config$1();
|
|
301
|
+
static create() {
|
|
302
|
+
return new Config();
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
@deprecated No-op in the TypeScript port: the garbage collector owns this
|
|
306
|
+
config's lifetime. Kept only for yoga-layout binding compatibility.
|
|
307
|
+
*/
|
|
308
|
+
free() {}
|
|
309
|
+
setExperimentalFeatureEnabled(feature, enabled) {
|
|
310
|
+
this.core.setExperimentalFeatureEnabled(feature, enabled);
|
|
311
|
+
}
|
|
312
|
+
isExperimentalFeatureEnabled(feature) {
|
|
313
|
+
return this.core.isExperimentalFeatureEnabled(feature);
|
|
314
|
+
}
|
|
315
|
+
setPointScaleFactor(factor) {
|
|
316
|
+
if (!(factor >= 0)) throw new Error("Scale factor should not be less than zero");
|
|
317
|
+
this.core.setPointScaleFactor(factor);
|
|
318
|
+
}
|
|
319
|
+
getErrata() {
|
|
320
|
+
return this.core.getErrata();
|
|
321
|
+
}
|
|
322
|
+
setErrata(errata) {
|
|
323
|
+
this.core.setErrata(errata);
|
|
324
|
+
}
|
|
325
|
+
useWebDefaults() {
|
|
326
|
+
return this.core.useWebDefaults();
|
|
327
|
+
}
|
|
328
|
+
setUseWebDefaults(useWebDefaults) {
|
|
329
|
+
this.core.setUseWebDefaults(useWebDefaults);
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
//#endregion
|
|
333
|
+
//#region src/yoga/core/numeric.ts
|
|
334
|
+
function isUndefined(value) {
|
|
335
|
+
return Number.isNaN(value);
|
|
336
|
+
}
|
|
337
|
+
function isDefined(value) {
|
|
338
|
+
return !Number.isNaN(value);
|
|
339
|
+
}
|
|
340
|
+
function maxOrDefined(a, b) {
|
|
341
|
+
if (isDefined(a) && isDefined(b)) return Math.max(a, b);
|
|
342
|
+
return isUndefined(a) ? b : a;
|
|
343
|
+
}
|
|
344
|
+
function minOrDefined(a, b) {
|
|
345
|
+
if (isDefined(a) && isDefined(b)) return Math.min(a, b);
|
|
346
|
+
return isUndefined(a) ? b : a;
|
|
347
|
+
}
|
|
348
|
+
function inexactEquals(a, b) {
|
|
349
|
+
if (isDefined(a) && isDefined(b)) return Math.abs(a - b) < 1e-4;
|
|
350
|
+
return isUndefined(a) && isUndefined(b);
|
|
351
|
+
}
|
|
352
|
+
function optionalEquals(a, b) {
|
|
353
|
+
return a === b || isUndefined(a) && isUndefined(b);
|
|
354
|
+
}
|
|
355
|
+
//#endregion
|
|
356
|
+
//#region src/yoga/core/helpers.ts
|
|
357
|
+
const PhysicalEdge = {
|
|
358
|
+
Left: 0,
|
|
359
|
+
Top: 1,
|
|
360
|
+
Right: 2,
|
|
361
|
+
Bottom: 3
|
|
362
|
+
};
|
|
363
|
+
const SizingMode = {
|
|
364
|
+
StretchFit: 0,
|
|
365
|
+
MaxContent: 1,
|
|
366
|
+
FitContent: 2
|
|
367
|
+
};
|
|
368
|
+
function measureMode(mode) {
|
|
369
|
+
switch (mode) {
|
|
370
|
+
case SizingMode.StretchFit: return MeasureMode.Exactly;
|
|
371
|
+
case SizingMode.MaxContent: return MeasureMode.Undefined;
|
|
372
|
+
case SizingMode.FitContent: return MeasureMode.AtMost;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
function isRow(flexDirection) {
|
|
376
|
+
return (flexDirection & FlexDirection.Row) !== 0;
|
|
377
|
+
}
|
|
378
|
+
function isColumn(flexDirection) {
|
|
379
|
+
return (flexDirection & FlexDirection.Row) === 0;
|
|
380
|
+
}
|
|
381
|
+
function resolveDirection(flexDirection, direction) {
|
|
382
|
+
if (direction === Direction.RTL) {
|
|
383
|
+
if (flexDirection === FlexDirection.Row) return FlexDirection.RowReverse;
|
|
384
|
+
else if (flexDirection === FlexDirection.RowReverse) return FlexDirection.Row;
|
|
385
|
+
}
|
|
386
|
+
return flexDirection;
|
|
387
|
+
}
|
|
388
|
+
function resolveCrossDirection(flexDirection, direction) {
|
|
389
|
+
return isColumn(flexDirection) ? resolveDirection(FlexDirection.Row, direction) : FlexDirection.Column;
|
|
390
|
+
}
|
|
391
|
+
const FLEX_START_EDGE = [
|
|
392
|
+
PhysicalEdge.Top,
|
|
393
|
+
PhysicalEdge.Bottom,
|
|
394
|
+
PhysicalEdge.Left,
|
|
395
|
+
PhysicalEdge.Right
|
|
396
|
+
];
|
|
397
|
+
const FLEX_END_EDGE = [
|
|
398
|
+
PhysicalEdge.Bottom,
|
|
399
|
+
PhysicalEdge.Top,
|
|
400
|
+
PhysicalEdge.Right,
|
|
401
|
+
PhysicalEdge.Left
|
|
402
|
+
];
|
|
403
|
+
const DIMENSION_OF_AXIS = [
|
|
404
|
+
Dimension.Height,
|
|
405
|
+
Dimension.Height,
|
|
406
|
+
Dimension.Width,
|
|
407
|
+
Dimension.Width
|
|
408
|
+
];
|
|
409
|
+
function flexStartEdge(flexDirection) {
|
|
410
|
+
return FLEX_START_EDGE[flexDirection];
|
|
411
|
+
}
|
|
412
|
+
function flexEndEdge(flexDirection) {
|
|
413
|
+
return FLEX_END_EDGE[flexDirection];
|
|
414
|
+
}
|
|
415
|
+
function inlineStartEdge(flexDirection, direction) {
|
|
416
|
+
if (isRow(flexDirection)) return direction === Direction.RTL ? PhysicalEdge.Right : PhysicalEdge.Left;
|
|
417
|
+
return PhysicalEdge.Top;
|
|
418
|
+
}
|
|
419
|
+
function inlineEndEdge(flexDirection, direction) {
|
|
420
|
+
if (isRow(flexDirection)) return direction === Direction.RTL ? PhysicalEdge.Left : PhysicalEdge.Right;
|
|
421
|
+
return PhysicalEdge.Bottom;
|
|
422
|
+
}
|
|
423
|
+
function dimension(flexDirection) {
|
|
424
|
+
return DIMENSION_OF_AXIS[flexDirection];
|
|
425
|
+
}
|
|
426
|
+
function resolveChildAlignment(node, child) {
|
|
427
|
+
const align = child.style.alignSelf() === Align.Auto ? node.style.alignItems() : child.style.alignSelf();
|
|
428
|
+
if (node.style.display() === Display.Flex && align === Align.Baseline && isColumn(node.style.flexDirection())) return Align.FlexStart;
|
|
429
|
+
return align;
|
|
430
|
+
}
|
|
431
|
+
function resolveChildJustification(node, child) {
|
|
432
|
+
return child.style.justifySelf() === Justify.Auto ? node.style.justifyItems() : child.style.justifySelf();
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Fallback alignment to use on overflow
|
|
436
|
+
* https://www.w3.org/TR/css-align-3/#distribution-values
|
|
437
|
+
*/
|
|
438
|
+
function fallbackAlignment(align) {
|
|
439
|
+
switch (align) {
|
|
440
|
+
case Align.SpaceBetween:
|
|
441
|
+
case Align.Stretch: return Align.FlexStart;
|
|
442
|
+
case Align.SpaceAround:
|
|
443
|
+
case Align.SpaceEvenly: return Align.FlexStart;
|
|
444
|
+
default: return align;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
function fallbackJustification(align) {
|
|
448
|
+
switch (align) {
|
|
449
|
+
case Justify.SpaceBetween: return Justify.FlexStart;
|
|
450
|
+
case Justify.SpaceAround:
|
|
451
|
+
case Justify.SpaceEvenly: return Justify.FlexStart;
|
|
452
|
+
default: return align;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
function paddingAndBorderForAxis(node, axis, direction, widthSize) {
|
|
456
|
+
if (!node.style.hasPaddingOrBorder()) return 0;
|
|
457
|
+
return node.style.computeInlineStartPaddingAndBorder(axis, direction, widthSize) + node.style.computeInlineEndPaddingAndBorder(axis, direction, widthSize);
|
|
458
|
+
}
|
|
459
|
+
function boundAxisWithinMinAndMax(node, direction, axis, value, axisSize, widthSize) {
|
|
460
|
+
let min = NaN;
|
|
461
|
+
let max = NaN;
|
|
462
|
+
if (isColumn(axis)) {
|
|
463
|
+
min = node.style.resolvedMinDimension(direction, Dimension.Height, axisSize, widthSize);
|
|
464
|
+
max = node.style.resolvedMaxDimension(direction, Dimension.Height, axisSize, widthSize);
|
|
465
|
+
} else if (isRow(axis)) {
|
|
466
|
+
min = node.style.resolvedMinDimension(direction, Dimension.Width, axisSize, widthSize);
|
|
467
|
+
max = node.style.resolvedMaxDimension(direction, Dimension.Width, axisSize, widthSize);
|
|
468
|
+
}
|
|
469
|
+
if (max >= 0 && value > max) return max;
|
|
470
|
+
if (min >= 0 && value < min) return min;
|
|
471
|
+
return value;
|
|
472
|
+
}
|
|
473
|
+
function boundAxis(node, axis, direction, value, axisSize, widthSize) {
|
|
474
|
+
return maxOrDefined(boundAxisWithinMinAndMax(node, direction, axis, value, axisSize, widthSize), paddingAndBorderForAxis(node, axis, direction, widthSize));
|
|
475
|
+
}
|
|
476
|
+
function getPositionOfOppositeEdge(position, axis, containingNode, node) {
|
|
477
|
+
return containingNode.layout.measuredDimension(dimension(axis)) - node.layout.measuredDimension(dimension(axis)) - position;
|
|
478
|
+
}
|
|
479
|
+
function setChildTrailingPosition(node, child, axis) {
|
|
480
|
+
child.setLayoutPosition(getPositionOfOppositeEdge(child.layout.position(flexStartEdge(axis)), axis, node, child), flexEndEdge(axis));
|
|
481
|
+
}
|
|
482
|
+
function needsTrailingPosition(axis) {
|
|
483
|
+
return axis === FlexDirection.RowReverse || axis === FlexDirection.ColumnReverse;
|
|
484
|
+
}
|
|
485
|
+
//#endregion
|
|
486
|
+
//#region src/yoga/core/absoluteLayout.ts
|
|
487
|
+
function setFlexStartLayoutPosition(parent, child, direction, axis, containingBlockWidth) {
|
|
488
|
+
let position = child.style.computeFlexStartMargin(axis, direction, containingBlockWidth) + parent.layout.border(flexStartEdge(axis));
|
|
489
|
+
if (!child.hasErrata(Errata.AbsolutePositionWithoutInsetsExcludesPadding) && parent.style.display() !== Display.Grid) position += parent.layout.padding(flexStartEdge(axis));
|
|
490
|
+
child.setLayoutPosition(position, flexStartEdge(axis));
|
|
491
|
+
}
|
|
492
|
+
function setFlexEndLayoutPosition(parent, child, direction, axis, containingBlockWidth) {
|
|
493
|
+
let flexEndPosition = parent.layout.border(flexEndEdge(axis)) + child.style.computeFlexEndMargin(axis, direction, containingBlockWidth);
|
|
494
|
+
if (!child.hasErrata(Errata.AbsolutePositionWithoutInsetsExcludesPadding) && parent.style.display() !== Display.Grid) flexEndPosition += parent.layout.padding(flexEndEdge(axis));
|
|
495
|
+
child.setLayoutPosition(getPositionOfOppositeEdge(flexEndPosition, axis, parent, child), flexStartEdge(axis));
|
|
496
|
+
}
|
|
497
|
+
function setCenterLayoutPosition(parent, child, direction, axis, containingBlockWidth) {
|
|
498
|
+
let parentContentBoxSize = parent.layout.measuredDimension(dimension(axis)) - parent.layout.border(flexStartEdge(axis)) - parent.layout.border(flexEndEdge(axis));
|
|
499
|
+
if (!child.hasErrata(Errata.AbsolutePositionWithoutInsetsExcludesPadding) && parent.style.display() !== Display.Grid) {
|
|
500
|
+
parentContentBoxSize -= parent.layout.padding(flexStartEdge(axis));
|
|
501
|
+
parentContentBoxSize -= parent.layout.padding(flexEndEdge(axis));
|
|
502
|
+
}
|
|
503
|
+
const childOuterSize = child.layout.measuredDimension(dimension(axis)) + child.style.computeMarginForAxis(axis, containingBlockWidth);
|
|
504
|
+
let position = (parentContentBoxSize - childOuterSize) / 2 + parent.layout.border(flexStartEdge(axis)) + child.style.computeFlexStartMargin(axis, direction, containingBlockWidth);
|
|
505
|
+
if (!child.hasErrata(Errata.AbsolutePositionWithoutInsetsExcludesPadding) && parent.style.display() !== Display.Grid) position += parent.layout.padding(flexStartEdge(axis));
|
|
506
|
+
child.setLayoutPosition(position, flexStartEdge(axis));
|
|
507
|
+
}
|
|
508
|
+
function justifyAbsoluteChild(parent, child, direction, mainAxis, containingBlockWidth) {
|
|
509
|
+
switch (parent.style.display() === Display.Grid ? resolveChildJustification(parent, child) : parent.style.justifyContent()) {
|
|
510
|
+
case Justify.Start:
|
|
511
|
+
case Justify.Auto:
|
|
512
|
+
case Justify.Stretch:
|
|
513
|
+
case Justify.FlexStart:
|
|
514
|
+
case Justify.SpaceBetween:
|
|
515
|
+
setFlexStartLayoutPosition(parent, child, direction, mainAxis, containingBlockWidth);
|
|
516
|
+
break;
|
|
517
|
+
case Justify.End:
|
|
518
|
+
case Justify.FlexEnd:
|
|
519
|
+
setFlexEndLayoutPosition(parent, child, direction, mainAxis, containingBlockWidth);
|
|
520
|
+
break;
|
|
521
|
+
case Justify.Center:
|
|
522
|
+
case Justify.SpaceAround:
|
|
523
|
+
case Justify.SpaceEvenly: setCenterLayoutPosition(parent, child, direction, mainAxis, containingBlockWidth);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
function alignAbsoluteChild(parent, child, direction, crossAxis, containingBlockWidth) {
|
|
527
|
+
let itemAlign = resolveChildAlignment(parent, child);
|
|
528
|
+
if (parent.style.flexWrap() === Wrap.WrapReverse) {
|
|
529
|
+
if (itemAlign === Align.FlexEnd) itemAlign = Align.FlexStart;
|
|
530
|
+
else if (itemAlign !== Align.Center) itemAlign = Align.FlexEnd;
|
|
531
|
+
}
|
|
532
|
+
switch (itemAlign) {
|
|
533
|
+
case Align.Start:
|
|
534
|
+
case Align.Auto:
|
|
535
|
+
case Align.FlexStart:
|
|
536
|
+
case Align.Baseline:
|
|
537
|
+
case Align.SpaceAround:
|
|
538
|
+
case Align.SpaceBetween:
|
|
539
|
+
case Align.Stretch:
|
|
540
|
+
case Align.SpaceEvenly:
|
|
541
|
+
setFlexStartLayoutPosition(parent, child, direction, crossAxis, containingBlockWidth);
|
|
542
|
+
break;
|
|
543
|
+
case Align.End:
|
|
544
|
+
case Align.FlexEnd:
|
|
545
|
+
setFlexEndLayoutPosition(parent, child, direction, crossAxis, containingBlockWidth);
|
|
546
|
+
break;
|
|
547
|
+
case Align.Center: setCenterLayoutPosition(parent, child, direction, crossAxis, containingBlockWidth);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
function positionAbsoluteChild(containingNode, parent, child, direction, axis, isMainAxis, containingBlockWidth, containingBlockHeight) {
|
|
551
|
+
const containingBlockSize = isRow(axis) ? containingBlockWidth : containingBlockHeight;
|
|
552
|
+
if (child.style.isInlineStartPositionDefined(axis, direction) && !child.style.isInlineStartPositionAuto(axis, direction)) {
|
|
553
|
+
const positionRelativeToInlineStart = child.style.computeInlineStartPosition(axis, direction, containingBlockSize) + containingNode.style.computeInlineStartBorder(axis, direction) + child.style.computeInlineStartMargin(axis, direction, containingBlockSize);
|
|
554
|
+
const positionRelativeToFlexStart = inlineStartEdge(axis, direction) !== flexStartEdge(axis) ? getPositionOfOppositeEdge(positionRelativeToInlineStart, axis, containingNode, child) : positionRelativeToInlineStart;
|
|
555
|
+
child.setLayoutPosition(positionRelativeToFlexStart, flexStartEdge(axis));
|
|
556
|
+
} else if (child.style.isInlineEndPositionDefined(axis, direction) && !child.style.isInlineEndPositionAuto(axis, direction)) {
|
|
557
|
+
const positionRelativeToInlineStart = containingNode.layout.measuredDimension(dimension(axis)) - child.layout.measuredDimension(dimension(axis)) - containingNode.style.computeInlineEndBorder(axis, direction) - child.style.computeInlineEndMargin(axis, direction, containingBlockSize) - child.style.computeInlineEndPosition(axis, direction, containingBlockSize);
|
|
558
|
+
const positionRelativeToFlexStart = inlineStartEdge(axis, direction) !== flexStartEdge(axis) ? getPositionOfOppositeEdge(positionRelativeToInlineStart, axis, containingNode, child) : positionRelativeToInlineStart;
|
|
559
|
+
child.setLayoutPosition(positionRelativeToFlexStart, flexStartEdge(axis));
|
|
560
|
+
} else if (isMainAxis) justifyAbsoluteChild(parent, child, direction, axis, containingBlockWidth);
|
|
561
|
+
else alignAbsoluteChild(parent, child, direction, axis, containingBlockWidth);
|
|
562
|
+
}
|
|
563
|
+
function layoutAbsoluteChild(containingNode, node, child, containingBlockWidth, containingBlockHeight, widthMode, direction, layoutMarkerData, depth, generationCount) {
|
|
564
|
+
const mainAxis = node.style.display() === Display.Grid ? resolveDirection(FlexDirection.Row, direction) : resolveDirection(node.style.flexDirection(), direction);
|
|
565
|
+
const crossAxis = node.style.display() === Display.Grid ? FlexDirection.Column : resolveCrossDirection(mainAxis, direction);
|
|
566
|
+
const isMainAxisRow = isRow(mainAxis);
|
|
567
|
+
let childWidth = NaN;
|
|
568
|
+
let childHeight = NaN;
|
|
569
|
+
let childWidthSizingMode = SizingMode.MaxContent;
|
|
570
|
+
let childHeightSizingMode = SizingMode.MaxContent;
|
|
571
|
+
const marginRow = child.style.computeMarginForAxis(FlexDirection.Row, containingBlockWidth);
|
|
572
|
+
const marginColumn = child.style.computeMarginForAxis(FlexDirection.Column, containingBlockWidth);
|
|
573
|
+
if (child.hasDefiniteLength(Dimension.Width, containingBlockWidth)) childWidth = child.getResolvedDimension(direction, Dimension.Width, containingBlockWidth, containingBlockWidth) + marginRow;
|
|
574
|
+
else if (child.style.isFlexStartPositionDefined(FlexDirection.Row, direction) && child.style.isFlexEndPositionDefined(FlexDirection.Row, direction) && !child.style.isFlexStartPositionAuto(FlexDirection.Row, direction) && !child.style.isFlexEndPositionAuto(FlexDirection.Row, direction)) {
|
|
575
|
+
childWidth = containingNode.layout.measuredDimension(Dimension.Width) - (containingNode.style.computeFlexStartBorder(FlexDirection.Row, direction) + containingNode.style.computeFlexEndBorder(FlexDirection.Row, direction)) - (child.style.computeFlexStartPosition(FlexDirection.Row, direction, containingBlockWidth) + child.style.computeFlexEndPosition(FlexDirection.Row, direction, containingBlockWidth));
|
|
576
|
+
childWidth = boundAxis(child, FlexDirection.Row, direction, childWidth, containingBlockWidth, containingBlockWidth);
|
|
577
|
+
}
|
|
578
|
+
if (child.hasDefiniteLength(Dimension.Height, containingBlockHeight)) childHeight = child.getResolvedDimension(direction, Dimension.Height, containingBlockHeight, containingBlockWidth) + marginColumn;
|
|
579
|
+
else if (child.style.isFlexStartPositionDefined(FlexDirection.Column, direction) && child.style.isFlexEndPositionDefined(FlexDirection.Column, direction) && !child.style.isFlexStartPositionAuto(FlexDirection.Column, direction) && !child.style.isFlexEndPositionAuto(FlexDirection.Column, direction)) {
|
|
580
|
+
childHeight = containingNode.layout.measuredDimension(Dimension.Height) - (containingNode.style.computeFlexStartBorder(FlexDirection.Column, direction) + containingNode.style.computeFlexEndBorder(FlexDirection.Column, direction)) - (child.style.computeFlexStartPosition(FlexDirection.Column, direction, containingBlockHeight) + child.style.computeFlexEndPosition(FlexDirection.Column, direction, containingBlockHeight));
|
|
581
|
+
childHeight = boundAxis(child, FlexDirection.Column, direction, childHeight, containingBlockHeight, containingBlockWidth);
|
|
582
|
+
}
|
|
583
|
+
const childStyle = child.style;
|
|
584
|
+
if (isUndefined(childWidth) !== isUndefined(childHeight)) {
|
|
585
|
+
if (isDefined(childStyle.aspectRatio())) {
|
|
586
|
+
if (isUndefined(childWidth)) childWidth = marginRow + (childHeight - marginColumn) * childStyle.aspectRatio();
|
|
587
|
+
else if (isUndefined(childHeight)) childHeight = marginColumn + (childWidth - marginRow) / childStyle.aspectRatio();
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
if (isUndefined(childWidth) || isUndefined(childHeight)) {
|
|
591
|
+
childWidthSizingMode = isUndefined(childWidth) ? SizingMode.MaxContent : SizingMode.StretchFit;
|
|
592
|
+
childHeightSizingMode = isUndefined(childHeight) ? SizingMode.MaxContent : SizingMode.StretchFit;
|
|
593
|
+
if (!isMainAxisRow && isUndefined(childWidth) && widthMode !== SizingMode.MaxContent && isDefined(containingBlockWidth) && containingBlockWidth > 0) {
|
|
594
|
+
childWidth = containingBlockWidth;
|
|
595
|
+
childWidthSizingMode = SizingMode.FitContent;
|
|
596
|
+
}
|
|
597
|
+
calculateLayoutInternal(child, childWidth, childHeight, direction, childWidthSizingMode, childHeightSizingMode, containingBlockWidth, containingBlockHeight, false, LayoutPassReason.AbsMeasureChild, layoutMarkerData, depth, generationCount);
|
|
598
|
+
childWidth = child.layout.measuredDimension(Dimension.Width) + child.style.computeMarginForAxis(FlexDirection.Row, containingBlockWidth);
|
|
599
|
+
childHeight = child.layout.measuredDimension(Dimension.Height) + child.style.computeMarginForAxis(FlexDirection.Column, containingBlockWidth);
|
|
600
|
+
}
|
|
601
|
+
calculateLayoutInternal(child, childWidth, childHeight, direction, SizingMode.StretchFit, SizingMode.StretchFit, containingBlockWidth, containingBlockHeight, true, LayoutPassReason.AbsLayout, layoutMarkerData, depth, generationCount);
|
|
602
|
+
positionAbsoluteChild(containingNode, node, child, direction, mainAxis, true, containingBlockWidth, containingBlockHeight);
|
|
603
|
+
positionAbsoluteChild(containingNode, node, child, direction, crossAxis, false, containingBlockWidth, containingBlockHeight);
|
|
604
|
+
}
|
|
605
|
+
function layoutAbsoluteDescendants(containingNode, currentNode, widthSizingMode, currentNodeDirection, layoutMarkerData, currentDepth, generationCount, currentNodeLeftOffsetFromContainingBlock, currentNodeTopOffsetFromContainingBlock, containingNodeAvailableInnerWidth, containingNodeAvailableInnerHeight) {
|
|
606
|
+
let hasNewLayout = false;
|
|
607
|
+
for (const child of currentNode.getLayoutChildren()) if (child.style.display() === Display.None) continue;
|
|
608
|
+
else if (child.style.positionType() === PositionType.Absolute) {
|
|
609
|
+
const absoluteErrata = currentNode.hasErrata(Errata.AbsolutePercentAgainstInnerSize);
|
|
610
|
+
layoutAbsoluteChild(containingNode, currentNode, child, absoluteErrata ? containingNodeAvailableInnerWidth : containingNode.layout.measuredDimension(Dimension.Width) - containingNode.style.computeBorderForAxis(FlexDirection.Row), absoluteErrata ? containingNodeAvailableInnerHeight : containingNode.layout.measuredDimension(Dimension.Height) - containingNode.style.computeBorderForAxis(FlexDirection.Column), widthSizingMode, currentNodeDirection, layoutMarkerData, currentDepth, generationCount);
|
|
611
|
+
hasNewLayout = hasNewLayout || child.hasNewLayout_;
|
|
612
|
+
const parentMainAxis = resolveDirection(currentNode.style.flexDirection(), currentNodeDirection);
|
|
613
|
+
const parentCrossAxis = resolveCrossDirection(parentMainAxis, currentNodeDirection);
|
|
614
|
+
if (needsTrailingPosition(parentMainAxis)) setChildTrailingPosition((isRow(parentMainAxis) ? child.style.horizontalInsetsDefined() : child.style.verticalInsetsDefined()) ? containingNode : currentNode, child, parentMainAxis);
|
|
615
|
+
if (needsTrailingPosition(parentCrossAxis)) setChildTrailingPosition((isRow(parentCrossAxis) ? child.style.horizontalInsetsDefined() : child.style.verticalInsetsDefined()) ? containingNode : currentNode, child, parentCrossAxis);
|
|
616
|
+
const childLeftPosition = child.layout.position(PhysicalEdge.Left);
|
|
617
|
+
const childTopPosition = child.layout.position(PhysicalEdge.Top);
|
|
618
|
+
const childLeftOffsetFromParent = child.style.horizontalInsetsDefined() ? childLeftPosition - currentNodeLeftOffsetFromContainingBlock : childLeftPosition;
|
|
619
|
+
const childTopOffsetFromParent = child.style.verticalInsetsDefined() ? childTopPosition - currentNodeTopOffsetFromContainingBlock : childTopPosition;
|
|
620
|
+
child.setLayoutPosition(childLeftOffsetFromParent, PhysicalEdge.Left);
|
|
621
|
+
child.setLayoutPosition(childTopOffsetFromParent, PhysicalEdge.Top);
|
|
622
|
+
} else if (child.style.positionType() === PositionType.Static && !child.alwaysFormsContainingBlock) {
|
|
623
|
+
child.cloneChildrenIfNeeded();
|
|
624
|
+
const childDirection = child.resolveDirection(currentNodeDirection);
|
|
625
|
+
const childLeftOffsetFromContainingBlock = currentNodeLeftOffsetFromContainingBlock + child.layout.position(PhysicalEdge.Left);
|
|
626
|
+
const childTopOffsetFromContainingBlock = currentNodeTopOffsetFromContainingBlock + child.layout.position(PhysicalEdge.Top);
|
|
627
|
+
hasNewLayout = layoutAbsoluteDescendants(containingNode, child, widthSizingMode, childDirection, layoutMarkerData, currentDepth + 1, generationCount, childLeftOffsetFromContainingBlock, childTopOffsetFromContainingBlock, containingNodeAvailableInnerWidth, containingNodeAvailableInnerHeight) || hasNewLayout;
|
|
628
|
+
cleanupContentsNodesRecursively(child, hasNewLayout);
|
|
629
|
+
if (hasNewLayout) child.hasNewLayout_ = hasNewLayout;
|
|
630
|
+
}
|
|
631
|
+
return hasNewLayout;
|
|
632
|
+
}
|
|
633
|
+
//#endregion
|
|
634
|
+
//#region src/yoga/core/baseline.ts
|
|
635
|
+
function calculateBaseline(node) {
|
|
636
|
+
if (node.hasBaselineFunc()) {
|
|
637
|
+
const baseline = node.baseline(node.layout.measuredDimension(Dimension.Width), node.layout.measuredDimension(Dimension.Height));
|
|
638
|
+
if (Number.isNaN(baseline)) throw new Error("Expect custom baseline function to not return NaN");
|
|
639
|
+
return baseline;
|
|
640
|
+
}
|
|
641
|
+
let baselineChild = null;
|
|
642
|
+
for (const child of node.getLayoutChildren()) {
|
|
643
|
+
if (child.lineIndex > 0) break;
|
|
644
|
+
if (child.style.positionType() === PositionType.Absolute) continue;
|
|
645
|
+
if (resolveChildAlignment(node, child) === Align.Baseline || child.isReferenceBaseline_) {
|
|
646
|
+
baselineChild = child;
|
|
647
|
+
break;
|
|
648
|
+
}
|
|
649
|
+
if (baselineChild === null) baselineChild = child;
|
|
650
|
+
}
|
|
651
|
+
if (baselineChild === null) return node.layout.measuredDimension(Dimension.Height);
|
|
652
|
+
return calculateBaseline(baselineChild) + baselineChild.layout.position(PhysicalEdge.Top);
|
|
653
|
+
}
|
|
654
|
+
function isBaselineLayout(node) {
|
|
655
|
+
if (isColumn(node.style.flexDirection())) return false;
|
|
656
|
+
if (node.style.alignItems() === Align.Baseline) return true;
|
|
657
|
+
for (const child of node.getLayoutChildren()) if (child.style.positionType() !== PositionType.Absolute && child.style.alignSelf() === Align.Baseline) return true;
|
|
658
|
+
return false;
|
|
659
|
+
}
|
|
660
|
+
//#endregion
|
|
661
|
+
//#region src/yoga/core/pixelGrid.ts
|
|
662
|
+
function roundValueToPixelGrid(value, pointScaleFactor, forceCeil, forceFloor) {
|
|
663
|
+
if (pointScaleFactor === 1 && Number.isInteger(value)) return value === 0 ? 0 : value;
|
|
664
|
+
let scaledValue = value * pointScaleFactor;
|
|
665
|
+
let fractial = scaledValue % 1;
|
|
666
|
+
if (fractial < 0) ++fractial;
|
|
667
|
+
if (fractial < 1e-4) scaledValue = scaledValue - fractial;
|
|
668
|
+
else if (fractial - 1 > -1e-4) scaledValue = scaledValue - fractial + 1;
|
|
669
|
+
else if (forceCeil) scaledValue = scaledValue - fractial + 1;
|
|
670
|
+
else if (forceFloor) scaledValue = scaledValue - fractial;
|
|
671
|
+
else scaledValue = scaledValue - fractial + (fractial - .5 > -1e-4 ? 1 : 0);
|
|
672
|
+
return Number.isNaN(scaledValue) || Number.isNaN(pointScaleFactor) ? NaN : scaledValue / pointScaleFactor;
|
|
673
|
+
}
|
|
674
|
+
function roundLayoutResultsToPixelGrid(node, absoluteLeft, absoluteTop) {
|
|
675
|
+
const layout = node.layout;
|
|
676
|
+
const pointScaleFactor = node.config.getPointScaleFactor();
|
|
677
|
+
if (!layout.roundingDirty && layout.roundedAbsLeft === absoluteLeft && layout.roundedAbsTop === absoluteTop && layout.roundedScale === pointScaleFactor) return;
|
|
678
|
+
layout.roundedAbsLeft = absoluteLeft;
|
|
679
|
+
layout.roundedAbsTop = absoluteTop;
|
|
680
|
+
layout.roundedScale = pointScaleFactor;
|
|
681
|
+
layout.roundingDirty = false;
|
|
682
|
+
const nodeLeft = layout.position(PhysicalEdge.Left);
|
|
683
|
+
const nodeTop = layout.position(PhysicalEdge.Top);
|
|
684
|
+
const nodeWidth = layout.dimension(Dimension.Width);
|
|
685
|
+
const nodeHeight = layout.dimension(Dimension.Height);
|
|
686
|
+
const absoluteNodeLeft = absoluteLeft + nodeLeft;
|
|
687
|
+
const absoluteNodeTop = absoluteTop + nodeTop;
|
|
688
|
+
const absoluteNodeRight = absoluteNodeLeft + nodeWidth;
|
|
689
|
+
const absoluteNodeBottom = absoluteNodeTop + nodeHeight;
|
|
690
|
+
if (pointScaleFactor !== 0) {
|
|
691
|
+
const textRounding = node.nodeType === NodeType.Text;
|
|
692
|
+
layout.setPosition(PhysicalEdge.Left, roundValueToPixelGrid(nodeLeft, pointScaleFactor, false, textRounding));
|
|
693
|
+
layout.setPosition(PhysicalEdge.Top, roundValueToPixelGrid(nodeTop, pointScaleFactor, false, textRounding));
|
|
694
|
+
const scaledNodeWidth = nodeWidth * pointScaleFactor;
|
|
695
|
+
const hasFractionalWidth = !inexactEquals(Math.round(scaledNodeWidth), scaledNodeWidth);
|
|
696
|
+
const scaledNodeHeight = nodeHeight * pointScaleFactor;
|
|
697
|
+
const hasFractionalHeight = !inexactEquals(Math.round(scaledNodeHeight), scaledNodeHeight);
|
|
698
|
+
node.layout.setDimension(Dimension.Width, roundValueToPixelGrid(absoluteNodeRight, pointScaleFactor, textRounding && hasFractionalWidth, textRounding && !hasFractionalWidth) - roundValueToPixelGrid(absoluteNodeLeft, pointScaleFactor, false, textRounding));
|
|
699
|
+
node.layout.setDimension(Dimension.Height, roundValueToPixelGrid(absoluteNodeBottom, pointScaleFactor, textRounding && hasFractionalHeight, textRounding && !hasFractionalHeight) - roundValueToPixelGrid(absoluteNodeTop, pointScaleFactor, false, textRounding));
|
|
700
|
+
}
|
|
701
|
+
roundChildren(node, absoluteNodeLeft, absoluteNodeTop);
|
|
702
|
+
}
|
|
703
|
+
function roundChildren(node, absoluteNodeLeft, absoluteNodeTop) {
|
|
704
|
+
for (const child of node.children) {
|
|
705
|
+
const childLayout = child.layout;
|
|
706
|
+
if (childLayout.roundingDirty || childLayout.roundedAbsLeft !== absoluteNodeLeft || childLayout.roundedAbsTop !== absoluteNodeTop || childLayout.roundedScale !== child.config.getPointScaleFactor()) roundLayoutResultsToPixelGrid(child, absoluteNodeLeft, absoluteNodeTop);
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
//#endregion
|
|
710
|
+
//#region src/yoga/core/cache.ts
|
|
711
|
+
function sizeIsExactAndMatchesOldMeasuredSize(sizeMode, size, lastComputedSize) {
|
|
712
|
+
return sizeMode === SizingMode.StretchFit && inexactEquals(size, lastComputedSize);
|
|
713
|
+
}
|
|
714
|
+
function oldSizeIsMaxContentAndStillFits(sizeMode, size, lastSizeMode, lastComputedSize) {
|
|
715
|
+
return sizeMode === SizingMode.FitContent && lastSizeMode === SizingMode.MaxContent && (size >= lastComputedSize || inexactEquals(size, lastComputedSize));
|
|
716
|
+
}
|
|
717
|
+
function newSizeIsStricterAndStillValid(sizeMode, size, lastSizeMode, lastSize, lastComputedSize) {
|
|
718
|
+
return lastSizeMode === SizingMode.FitContent && sizeMode === SizingMode.FitContent && isDefined(lastSize) && isDefined(size) && isDefined(lastComputedSize) && lastSize > size && (lastComputedSize <= size || inexactEquals(size, lastComputedSize));
|
|
719
|
+
}
|
|
720
|
+
function canUseCachedMeasurement(widthMode, availableWidth, heightMode, availableHeight, lastWidthMode, lastAvailableWidth, lastHeightMode, lastAvailableHeight, lastComputedWidth, lastComputedHeight, marginRow, marginColumn, config) {
|
|
721
|
+
if (isDefined(lastComputedHeight) && lastComputedHeight < 0 || isDefined(lastComputedWidth) && lastComputedWidth < 0) return false;
|
|
722
|
+
const pointScaleFactor = config.getPointScaleFactor();
|
|
723
|
+
const useRoundedComparison = pointScaleFactor !== 0;
|
|
724
|
+
const effectiveWidth = useRoundedComparison ? roundValueToPixelGrid(availableWidth, pointScaleFactor, false, false) : availableWidth;
|
|
725
|
+
const effectiveHeight = useRoundedComparison ? roundValueToPixelGrid(availableHeight, pointScaleFactor, false, false) : availableHeight;
|
|
726
|
+
const effectiveLastWidth = useRoundedComparison ? roundValueToPixelGrid(lastAvailableWidth, pointScaleFactor, false, false) : lastAvailableWidth;
|
|
727
|
+
const effectiveLastHeight = useRoundedComparison ? roundValueToPixelGrid(lastAvailableHeight, pointScaleFactor, false, false) : lastAvailableHeight;
|
|
728
|
+
const hasSameWidthSpec = lastWidthMode === widthMode && inexactEquals(effectiveLastWidth, effectiveWidth);
|
|
729
|
+
const hasSameHeightSpec = lastHeightMode === heightMode && inexactEquals(effectiveLastHeight, effectiveHeight);
|
|
730
|
+
const widthIsCompatible = hasSameWidthSpec || sizeIsExactAndMatchesOldMeasuredSize(widthMode, availableWidth - marginRow, lastComputedWidth) || oldSizeIsMaxContentAndStillFits(widthMode, availableWidth - marginRow, lastWidthMode, lastComputedWidth) || newSizeIsStricterAndStillValid(widthMode, availableWidth - marginRow, lastWidthMode, lastAvailableWidth, lastComputedWidth);
|
|
731
|
+
const heightIsCompatible = hasSameHeightSpec || sizeIsExactAndMatchesOldMeasuredSize(heightMode, availableHeight - marginColumn, lastComputedHeight) || oldSizeIsMaxContentAndStillFits(heightMode, availableHeight - marginColumn, lastHeightMode, lastComputedHeight) || newSizeIsStricterAndStillValid(heightMode, availableHeight - marginColumn, lastHeightMode, lastAvailableHeight, lastComputedHeight);
|
|
732
|
+
return widthIsCompatible && heightIsCompatible;
|
|
733
|
+
}
|
|
734
|
+
//#endregion
|
|
735
|
+
//#region src/yoga/core/flexLine.ts
|
|
736
|
+
function calculateFlexLine(node, ownerDirection, ownerWidth, mainAxisOwnerSize, availableInnerWidth, availableInnerMainDim, layoutChildren, startIndex, lineCount, flexLine) {
|
|
737
|
+
const itemsInFlow = flexLine.itemsInFlow;
|
|
738
|
+
itemsInFlow.length = 0;
|
|
739
|
+
let sizeConsumed = 0;
|
|
740
|
+
let totalFlexGrowFactors = 0;
|
|
741
|
+
let totalFlexShrinkScaledFactors = 0;
|
|
742
|
+
let numberOfAutoMargins = 0;
|
|
743
|
+
let firstElementInLine = null;
|
|
744
|
+
let sizeConsumedIncludingMinConstraint = 0;
|
|
745
|
+
const direction = node.resolveDirection(ownerDirection);
|
|
746
|
+
const mainAxis = resolveDirection(node.style.flexDirection(), direction);
|
|
747
|
+
const isNodeFlexWrap = node.style.flexWrap() !== Wrap.NoWrap;
|
|
748
|
+
const gap = node.style.computeGapForAxis(mainAxis, availableInnerMainDim);
|
|
749
|
+
let index = startIndex;
|
|
750
|
+
for (; index < layoutChildren.length; index++) {
|
|
751
|
+
const child = layoutChildren[index];
|
|
752
|
+
if (child.style.display() === Display.None || child.style.positionType() === PositionType.Absolute) continue;
|
|
753
|
+
if (firstElementInLine === null) firstElementInLine = child;
|
|
754
|
+
if (child.style.flexStartMarginIsAuto(mainAxis, ownerDirection)) numberOfAutoMargins++;
|
|
755
|
+
if (child.style.flexEndMarginIsAuto(mainAxis, ownerDirection)) numberOfAutoMargins++;
|
|
756
|
+
child.lineIndex = lineCount;
|
|
757
|
+
const childMarginMainAxis = child.style.computeMarginForAxis(mainAxis, availableInnerWidth);
|
|
758
|
+
const childLeadingGapMainAxis = child === firstElementInLine ? 0 : gap;
|
|
759
|
+
const flexBasisWithMinAndMaxConstraints = boundAxisWithinMinAndMax(child, direction, mainAxis, child.layout.computedFlexBasis, mainAxisOwnerSize, ownerWidth);
|
|
760
|
+
if (sizeConsumedIncludingMinConstraint + flexBasisWithMinAndMaxConstraints + childMarginMainAxis + childLeadingGapMainAxis > availableInnerMainDim && isNodeFlexWrap && itemsInFlow.length > 0) break;
|
|
761
|
+
sizeConsumedIncludingMinConstraint += flexBasisWithMinAndMaxConstraints + childMarginMainAxis + childLeadingGapMainAxis;
|
|
762
|
+
sizeConsumed += flexBasisWithMinAndMaxConstraints + childMarginMainAxis + childLeadingGapMainAxis;
|
|
763
|
+
if (child.isNodeFlexible()) {
|
|
764
|
+
totalFlexGrowFactors += child.resolveFlexGrow();
|
|
765
|
+
totalFlexShrinkScaledFactors += -child.resolveFlexShrink() * child.layout.computedFlexBasis;
|
|
766
|
+
}
|
|
767
|
+
itemsInFlow.push(child);
|
|
768
|
+
}
|
|
769
|
+
if (totalFlexGrowFactors > 0 && totalFlexGrowFactors < 1) totalFlexGrowFactors = 1;
|
|
770
|
+
if (totalFlexShrinkScaledFactors > 0 && totalFlexShrinkScaledFactors < 1) totalFlexShrinkScaledFactors = 1;
|
|
771
|
+
flexLine.sizeConsumed = sizeConsumed;
|
|
772
|
+
flexLine.numberOfAutoMargins = numberOfAutoMargins;
|
|
773
|
+
flexLine.endIndex = index;
|
|
774
|
+
flexLine.layout.totalFlexGrowFactors = totalFlexGrowFactors;
|
|
775
|
+
flexLine.layout.totalFlexShrinkScaledFactors = totalFlexShrinkScaledFactors;
|
|
776
|
+
flexLine.layout.remainingFreeSpace = 0;
|
|
777
|
+
flexLine.layout.mainDim = 0;
|
|
778
|
+
flexLine.layout.crossDim = 0;
|
|
779
|
+
}
|
|
780
|
+
//#endregion
|
|
781
|
+
//#region src/yoga/core/layoutResults.ts
|
|
782
|
+
var CachedMeasurement = class {
|
|
783
|
+
availableWidth = -1;
|
|
784
|
+
availableHeight = -1;
|
|
785
|
+
widthSizingMode = SizingMode.MaxContent;
|
|
786
|
+
heightSizingMode = SizingMode.MaxContent;
|
|
787
|
+
computedWidth = -1;
|
|
788
|
+
computedHeight = -1;
|
|
789
|
+
equals(measurement) {
|
|
790
|
+
let isEqual = this.widthSizingMode === measurement.widthSizingMode && this.heightSizingMode === measurement.heightSizingMode;
|
|
791
|
+
if (!isUndefined(this.availableWidth) || !isUndefined(measurement.availableWidth)) isEqual = isEqual && this.availableWidth === measurement.availableWidth;
|
|
792
|
+
if (!isUndefined(this.availableHeight) || !isUndefined(measurement.availableHeight)) isEqual = isEqual && this.availableHeight === measurement.availableHeight;
|
|
793
|
+
if (!isUndefined(this.computedWidth) || !isUndefined(measurement.computedWidth)) isEqual = isEqual && this.computedWidth === measurement.computedWidth;
|
|
794
|
+
if (!isUndefined(this.computedHeight) || !isUndefined(measurement.computedHeight)) isEqual = isEqual && this.computedHeight === measurement.computedHeight;
|
|
795
|
+
return isEqual;
|
|
796
|
+
}
|
|
797
|
+
};
|
|
798
|
+
var LayoutResults = class {
|
|
799
|
+
static MaxCachedMeasurements = 8;
|
|
800
|
+
computedFlexBasisGeneration = 0;
|
|
801
|
+
computedFlexBasis = NaN;
|
|
802
|
+
computedAutoMinMainSize = NaN;
|
|
803
|
+
generationCount = 0;
|
|
804
|
+
configVersion = 0;
|
|
805
|
+
lastOwnerDirection = Direction.Inherit;
|
|
806
|
+
nextCachedMeasurementsIndex = 0;
|
|
807
|
+
cachedMeasurements = [];
|
|
808
|
+
roundingDirty = true;
|
|
809
|
+
roundedAbsLeft = NaN;
|
|
810
|
+
roundedAbsTop = NaN;
|
|
811
|
+
roundedScale = NaN;
|
|
812
|
+
cachedLayout = new CachedMeasurement();
|
|
813
|
+
flexLine = null;
|
|
814
|
+
flexLineStarts = null;
|
|
815
|
+
direction_ = Direction.Inherit;
|
|
816
|
+
hadOverflow_ = false;
|
|
817
|
+
values_ = initialLayoutValues();
|
|
818
|
+
direction() {
|
|
819
|
+
return this.direction_;
|
|
820
|
+
}
|
|
821
|
+
setDirection(direction) {
|
|
822
|
+
this.direction_ = direction;
|
|
823
|
+
}
|
|
824
|
+
hadOverflow() {
|
|
825
|
+
return this.hadOverflow_;
|
|
826
|
+
}
|
|
827
|
+
setHadOverflow(hadOverflow) {
|
|
828
|
+
this.hadOverflow_ = hadOverflow;
|
|
829
|
+
}
|
|
830
|
+
dimension(axis) {
|
|
831
|
+
return this.values_[axis];
|
|
832
|
+
}
|
|
833
|
+
setDimension(axis, dimension) {
|
|
834
|
+
this.values_[axis] = dimension;
|
|
835
|
+
}
|
|
836
|
+
measuredDimension(axis) {
|
|
837
|
+
return this.values_[2 + axis];
|
|
838
|
+
}
|
|
839
|
+
rawDimension(axis) {
|
|
840
|
+
return this.values_[4 + axis];
|
|
841
|
+
}
|
|
842
|
+
setMeasuredDimension(axis, dimension) {
|
|
843
|
+
this.values_[2 + axis] = dimension;
|
|
844
|
+
}
|
|
845
|
+
setRawDimension(axis, dimension) {
|
|
846
|
+
this.values_[4 + axis] = dimension;
|
|
847
|
+
}
|
|
848
|
+
position(physicalEdge) {
|
|
849
|
+
return this.values_[6 + physicalEdge];
|
|
850
|
+
}
|
|
851
|
+
setPosition(physicalEdge, dimension) {
|
|
852
|
+
this.values_[6 + physicalEdge] = dimension;
|
|
853
|
+
}
|
|
854
|
+
margin(physicalEdge) {
|
|
855
|
+
return this.values_[10 + physicalEdge];
|
|
856
|
+
}
|
|
857
|
+
setMargin(physicalEdge, dimension) {
|
|
858
|
+
this.values_[10 + physicalEdge] = dimension;
|
|
859
|
+
}
|
|
860
|
+
border(physicalEdge) {
|
|
861
|
+
return this.values_[14 + physicalEdge];
|
|
862
|
+
}
|
|
863
|
+
setBorder(physicalEdge, dimension) {
|
|
864
|
+
this.values_[14 + physicalEdge] = dimension;
|
|
865
|
+
}
|
|
866
|
+
padding(physicalEdge) {
|
|
867
|
+
return this.values_[18 + physicalEdge];
|
|
868
|
+
}
|
|
869
|
+
setPadding(physicalEdge, dimension) {
|
|
870
|
+
this.values_[18 + physicalEdge] = dimension;
|
|
871
|
+
}
|
|
872
|
+
};
|
|
873
|
+
function initialLayoutValues() {
|
|
874
|
+
return [
|
|
875
|
+
NaN,
|
|
876
|
+
NaN,
|
|
877
|
+
NaN,
|
|
878
|
+
NaN,
|
|
879
|
+
NaN,
|
|
880
|
+
NaN,
|
|
881
|
+
0,
|
|
882
|
+
0,
|
|
883
|
+
0,
|
|
884
|
+
0,
|
|
885
|
+
0,
|
|
886
|
+
0,
|
|
887
|
+
0,
|
|
888
|
+
0,
|
|
889
|
+
0,
|
|
890
|
+
0,
|
|
891
|
+
0,
|
|
892
|
+
0,
|
|
893
|
+
0,
|
|
894
|
+
0,
|
|
895
|
+
0,
|
|
896
|
+
0
|
|
897
|
+
];
|
|
898
|
+
}
|
|
899
|
+
//#endregion
|
|
900
|
+
//#region src/yoga/core/calculateLayout.ts
|
|
901
|
+
const LayoutPassReason = {
|
|
902
|
+
Initial: 0,
|
|
903
|
+
AbsLayout: 1,
|
|
904
|
+
Stretch: 2,
|
|
905
|
+
MultilineStretch: 3,
|
|
906
|
+
FlexLayout: 4,
|
|
907
|
+
MeasureChild: 5,
|
|
908
|
+
AbsMeasureChild: 6,
|
|
909
|
+
FlexMeasure: 7
|
|
910
|
+
};
|
|
911
|
+
function newLayoutData() {
|
|
912
|
+
return {
|
|
913
|
+
layouts: 0,
|
|
914
|
+
measures: 0,
|
|
915
|
+
maxMeasureCache: 0,
|
|
916
|
+
cachedLayouts: 0,
|
|
917
|
+
cachedMeasures: 0,
|
|
918
|
+
measureCallbacks: 0
|
|
919
|
+
};
|
|
920
|
+
}
|
|
921
|
+
let gCurrentGenerationCount = 0;
|
|
922
|
+
function hasAutoHorizontalMargin(style) {
|
|
923
|
+
for (const direction of [Direction.LTR, Direction.RTL]) if (style.flexStartMarginIsAuto(FlexDirection.Row, direction) || style.flexEndMarginIsAuto(FlexDirection.Row, direction)) return true;
|
|
924
|
+
return false;
|
|
925
|
+
}
|
|
926
|
+
function isColumnStretchEdge(owner, child) {
|
|
927
|
+
if (owner === null || child === null) return false;
|
|
928
|
+
const ownerStyle = owner.style;
|
|
929
|
+
const childStyle = child.style;
|
|
930
|
+
const childWidth = child.getProcessedDimension(Dimension.Width);
|
|
931
|
+
return ownerStyle.display() === Display.Flex && isColumn(ownerStyle.flexDirection()) && ownerStyle.flexWrap() === Wrap.NoWrap && childStyle.positionType() !== PositionType.Absolute && !isDefined(childStyle.aspectRatio()) && (childWidth.isAuto() || childWidth.isUndefined()) && !hasAutoHorizontalMargin(childStyle) && resolveChildAlignment(owner, child) === Align.Stretch;
|
|
932
|
+
}
|
|
933
|
+
function isInColumnStretchScrollSubtree(node) {
|
|
934
|
+
let current = node;
|
|
935
|
+
while (current !== null) {
|
|
936
|
+
let owner = current.owner;
|
|
937
|
+
while (owner !== null && owner.style.display() === Display.Contents) owner = owner.owner;
|
|
938
|
+
if (owner === null || !isColumnStretchEdge(owner, current)) return false;
|
|
939
|
+
if (owner.style.overflow() === Overflow.Scroll) return true;
|
|
940
|
+
current = owner;
|
|
941
|
+
}
|
|
942
|
+
return false;
|
|
943
|
+
}
|
|
944
|
+
function isNonZeroLength(length) {
|
|
945
|
+
return length.isAuto() || isDefined(length.value) && length.value !== 0;
|
|
946
|
+
}
|
|
947
|
+
function hasNonZeroVerticalSpacing(style) {
|
|
948
|
+
const verticalEdges = [
|
|
949
|
+
Edge.Top,
|
|
950
|
+
Edge.Bottom,
|
|
951
|
+
Edge.Vertical,
|
|
952
|
+
Edge.All
|
|
953
|
+
];
|
|
954
|
+
for (const edge of verticalEdges) if (isNonZeroLength(style.margin(edge)) || isNonZeroLength(style.padding(edge)) || isNonZeroLength(style.border(edge))) return true;
|
|
955
|
+
return false;
|
|
956
|
+
}
|
|
957
|
+
function hasPercentageLength(style) {
|
|
958
|
+
const edges = [
|
|
959
|
+
Edge.Left,
|
|
960
|
+
Edge.Top,
|
|
961
|
+
Edge.Right,
|
|
962
|
+
Edge.Bottom,
|
|
963
|
+
Edge.Start,
|
|
964
|
+
Edge.End,
|
|
965
|
+
Edge.Horizontal,
|
|
966
|
+
Edge.Vertical,
|
|
967
|
+
Edge.All
|
|
968
|
+
];
|
|
969
|
+
for (const edge of edges) if (style.margin(edge).isPercent() || style.position(edge).isPercent() || style.padding(edge).isPercent() || style.border(edge).isPercent()) return true;
|
|
970
|
+
for (const dim of [Dimension.Width, Dimension.Height]) if (style.dimension(dim).isPercent() || style.minDimension(dim).isPercent() || style.maxDimension(dim).isPercent()) return true;
|
|
971
|
+
return style.flexBasis().isPercent() || style.gap(Gutter.Column).isPercent() || style.gap(Gutter.Row).isPercent() || style.gap(Gutter.All).isPercent();
|
|
972
|
+
}
|
|
973
|
+
function hasNonZeroFlex(node) {
|
|
974
|
+
const style = node.style;
|
|
975
|
+
const flex = style.flex();
|
|
976
|
+
const flexGrow = style.flexGrow();
|
|
977
|
+
const flexShrink = style.flexShrink();
|
|
978
|
+
const config = node.config;
|
|
979
|
+
const canGrow = isDefined(flexGrow) ? flexGrow !== 0 : isDefined(flex) && flex > 0;
|
|
980
|
+
const canShrink = isDefined(flexShrink) ? flexShrink !== 0 : config.useWebDefaults() || isDefined(flex) && flex < 0;
|
|
981
|
+
return canGrow || canShrink;
|
|
982
|
+
}
|
|
983
|
+
function isHeightFitContentIndependent(node) {
|
|
984
|
+
const style = node.style;
|
|
985
|
+
const height = style.dimension(Dimension.Height);
|
|
986
|
+
const flexBasis = style.flexBasis();
|
|
987
|
+
const hasRelativePercentPosition = style.position(Edge.Top).isPercent() || style.position(Edge.Bottom).isPercent() || style.position(Edge.Vertical).isPercent() || style.position(Edge.All).isPercent();
|
|
988
|
+
return !node.hasMeasureFunc() && !node.hasBaselineFunc() && !node.isReferenceBaseline_ && (height.isAuto() || height.isUndefined()) && style.minDimension(Dimension.Height).isUndefined() && style.maxDimension(Dimension.Height).isUndefined() && (flexBasis.isAuto() || flexBasis.isUndefined()) && !hasNonZeroFlex(node) && style.boxSizing() === 0 && !isDefined(style.aspectRatio()) && style.positionType() !== PositionType.Absolute && style.overflow() !== Overflow.Scroll && style.display() === Display.Flex && isColumn(style.flexDirection()) && style.alignItems() === Align.Stretch && (style.alignSelf() === Align.Auto || style.alignSelf() === Align.Stretch) && style.justifyContent() === Justify.FlexStart && style.flexWrap() === Wrap.NoWrap && !style.gap(Gutter.All).isDefined() && !style.gap(Gutter.Row).isDefined() && !hasRelativePercentPosition && !hasNonZeroVerticalSpacing(style) && !hasPercentageLength(style);
|
|
989
|
+
}
|
|
990
|
+
function canSkipHeightFitContent(root) {
|
|
991
|
+
if (root === null) return false;
|
|
992
|
+
const maxPendingNodes = 64;
|
|
993
|
+
const stack = [root];
|
|
994
|
+
while (stack.length > 0) {
|
|
995
|
+
const node = stack.pop();
|
|
996
|
+
if (!isHeightFitContentIndependent(node)) return false;
|
|
997
|
+
for (const child of node.getLayoutChildren()) {
|
|
998
|
+
if (stack.length === maxPendingNodes) return false;
|
|
999
|
+
stack.push(child);
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
return true;
|
|
1003
|
+
}
|
|
1004
|
+
const scratchModeA = {
|
|
1005
|
+
mode: SizingMode.StretchFit,
|
|
1006
|
+
size: 0
|
|
1007
|
+
};
|
|
1008
|
+
const scratchModeB = {
|
|
1009
|
+
mode: SizingMode.StretchFit,
|
|
1010
|
+
size: 0
|
|
1011
|
+
};
|
|
1012
|
+
function constrainMaxSizeForMode(node, direction, axis, ownerAxisSize, ownerWidth, modeAndSize) {
|
|
1013
|
+
const maxSize = node.style.resolvedMaxDimension(direction, dimension(axis), ownerAxisSize, ownerWidth) + node.style.computeMarginForAxis(axis, ownerWidth);
|
|
1014
|
+
switch (modeAndSize.mode) {
|
|
1015
|
+
case SizingMode.StretchFit:
|
|
1016
|
+
case SizingMode.FitContent:
|
|
1017
|
+
modeAndSize.size = isUndefined(maxSize) || modeAndSize.size < maxSize ? modeAndSize.size : maxSize;
|
|
1018
|
+
break;
|
|
1019
|
+
case SizingMode.MaxContent: if (isDefined(maxSize)) {
|
|
1020
|
+
modeAndSize.mode = SizingMode.FitContent;
|
|
1021
|
+
modeAndSize.size = maxSize;
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
function computeFlexBasisForChild(node, child, width, widthMode, height, ownerWidth, ownerHeight, heightMode, direction, layoutMarkerData, depth, generationCount) {
|
|
1026
|
+
const mainAxis = resolveDirection(node.style.flexDirection(), direction);
|
|
1027
|
+
const isMainAxisRow = isRow(mainAxis);
|
|
1028
|
+
const mainAxisSize = isMainAxisRow ? width : height;
|
|
1029
|
+
const mainAxisOwnerSize = isMainAxisRow ? ownerWidth : ownerHeight;
|
|
1030
|
+
let childWidth = NaN;
|
|
1031
|
+
let childHeight = NaN;
|
|
1032
|
+
let childWidthSizingMode;
|
|
1033
|
+
let childHeightSizingMode;
|
|
1034
|
+
const resolvedFlexBasis = child.resolveFlexBasis(direction, mainAxis, mainAxisOwnerSize, ownerWidth);
|
|
1035
|
+
const isRowStyleDimDefined = child.hasDefiniteLength(Dimension.Width, ownerWidth);
|
|
1036
|
+
const isColumnStyleDimDefined = child.hasDefiniteLength(Dimension.Height, ownerHeight);
|
|
1037
|
+
const fixFlexBasisFitContent = node.config.isExperimentalFeatureEnabled(ExperimentalFeature.FixFlexBasisFitContent);
|
|
1038
|
+
if (isDefined(resolvedFlexBasis) && isDefined(mainAxisSize)) {
|
|
1039
|
+
if (isUndefined(child.layout.computedFlexBasis) || child.config.isExperimentalFeatureEnabled(ExperimentalFeature.WebFlexBasis) && child.layout.computedFlexBasisGeneration !== generationCount) {
|
|
1040
|
+
const paddingAndBorder = paddingAndBorderForAxis(child, mainAxis, direction, ownerWidth);
|
|
1041
|
+
child.setLayoutComputedFlexBasis(maxOrDefined(resolvedFlexBasis, paddingAndBorder));
|
|
1042
|
+
}
|
|
1043
|
+
} else if (isMainAxisRow && isRowStyleDimDefined) {
|
|
1044
|
+
const paddingAndBorder = paddingAndBorderForAxis(child, FlexDirection.Row, direction, ownerWidth);
|
|
1045
|
+
child.setLayoutComputedFlexBasis(maxOrDefined(child.getResolvedDimension(direction, Dimension.Width, ownerWidth, ownerWidth), paddingAndBorder));
|
|
1046
|
+
} else if (!isMainAxisRow && isColumnStyleDimDefined) {
|
|
1047
|
+
const paddingAndBorder = paddingAndBorderForAxis(child, FlexDirection.Column, direction, ownerWidth);
|
|
1048
|
+
child.setLayoutComputedFlexBasis(maxOrDefined(child.getResolvedDimension(direction, Dimension.Height, ownerHeight, ownerWidth), paddingAndBorder));
|
|
1049
|
+
} else {
|
|
1050
|
+
childWidthSizingMode = SizingMode.MaxContent;
|
|
1051
|
+
childHeightSizingMode = SizingMode.MaxContent;
|
|
1052
|
+
const marginRow = child.style.computeMarginForAxis(FlexDirection.Row, ownerWidth);
|
|
1053
|
+
const marginColumn = child.style.computeMarginForAxis(FlexDirection.Column, ownerWidth);
|
|
1054
|
+
if (isRowStyleDimDefined) {
|
|
1055
|
+
childWidth = child.getResolvedDimension(direction, Dimension.Width, ownerWidth, ownerWidth) + marginRow;
|
|
1056
|
+
childWidthSizingMode = SizingMode.StretchFit;
|
|
1057
|
+
}
|
|
1058
|
+
if (isColumnStyleDimDefined) {
|
|
1059
|
+
childHeight = child.getResolvedDimension(direction, Dimension.Height, ownerHeight, ownerWidth) + marginColumn;
|
|
1060
|
+
childHeightSizingMode = SizingMode.StretchFit;
|
|
1061
|
+
}
|
|
1062
|
+
if (!isMainAxisRow && node.style.overflow() === Overflow.Scroll || node.style.overflow() !== Overflow.Scroll) {
|
|
1063
|
+
if (isUndefined(childWidth) && isDefined(width)) {
|
|
1064
|
+
childWidth = width;
|
|
1065
|
+
childWidthSizingMode = SizingMode.FitContent;
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
const parentDoesNotScroll = node.style.overflow() !== Overflow.Scroll;
|
|
1069
|
+
let applyHeightFitContent = isMainAxisRow || parentDoesNotScroll;
|
|
1070
|
+
if (fixFlexBasisFitContent) {
|
|
1071
|
+
const childHadOverflow = child.isDirty() && child.layout.hadOverflow();
|
|
1072
|
+
const hasHeightIndependentSubtree = !isMainAxisRow && parentDoesNotScroll && isUndefined(childHeight) && isDefined(height) && isColumnStretchEdge(node, child) && isInColumnStretchScrollSubtree(node) && canSkipHeightFitContent(child);
|
|
1073
|
+
if (hasHeightIndependentSubtree && childHadOverflow) child.setLayoutHadOverflow(false);
|
|
1074
|
+
if (hasHeightIndependentSubtree) applyHeightFitContent = false;
|
|
1075
|
+
}
|
|
1076
|
+
if (applyHeightFitContent && isUndefined(childHeight) && isDefined(height)) {
|
|
1077
|
+
childHeight = height;
|
|
1078
|
+
childHeightSizingMode = SizingMode.FitContent;
|
|
1079
|
+
}
|
|
1080
|
+
const childStyle = child.style;
|
|
1081
|
+
if (isDefined(childStyle.aspectRatio())) {
|
|
1082
|
+
if (!isMainAxisRow && childWidthSizingMode === SizingMode.StretchFit) {
|
|
1083
|
+
childHeight = marginColumn + (childWidth - marginRow) / childStyle.aspectRatio();
|
|
1084
|
+
childHeightSizingMode = SizingMode.StretchFit;
|
|
1085
|
+
} else if (isMainAxisRow && childHeightSizingMode === SizingMode.StretchFit) {
|
|
1086
|
+
childWidth = marginRow + (childHeight - marginColumn) * childStyle.aspectRatio();
|
|
1087
|
+
childWidthSizingMode = SizingMode.StretchFit;
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
const hasExactWidth = isDefined(width) && widthMode === SizingMode.StretchFit;
|
|
1091
|
+
const childWidthStretch = resolveChildAlignment(node, child) === Align.Stretch && childWidthSizingMode !== SizingMode.StretchFit;
|
|
1092
|
+
if (!isMainAxisRow && !isRowStyleDimDefined && hasExactWidth && childWidthStretch) {
|
|
1093
|
+
childWidth = width;
|
|
1094
|
+
childWidthSizingMode = SizingMode.StretchFit;
|
|
1095
|
+
if (isDefined(childStyle.aspectRatio())) {
|
|
1096
|
+
childHeight = (childWidth - marginRow) / childStyle.aspectRatio();
|
|
1097
|
+
childHeightSizingMode = SizingMode.StretchFit;
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
const hasExactHeight = isDefined(height) && heightMode === SizingMode.StretchFit;
|
|
1101
|
+
const childHeightStretch = resolveChildAlignment(node, child) === Align.Stretch && childHeightSizingMode !== SizingMode.StretchFit;
|
|
1102
|
+
if (isMainAxisRow && !isColumnStyleDimDefined && hasExactHeight && childHeightStretch) {
|
|
1103
|
+
childHeight = height;
|
|
1104
|
+
childHeightSizingMode = SizingMode.StretchFit;
|
|
1105
|
+
if (isDefined(childStyle.aspectRatio())) {
|
|
1106
|
+
childWidth = (childHeight - marginColumn) * childStyle.aspectRatio();
|
|
1107
|
+
childWidthSizingMode = SizingMode.StretchFit;
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
const widthModeAndSize = scratchModeA;
|
|
1111
|
+
widthModeAndSize.mode = childWidthSizingMode;
|
|
1112
|
+
widthModeAndSize.size = childWidth;
|
|
1113
|
+
constrainMaxSizeForMode(child, direction, FlexDirection.Row, ownerWidth, ownerWidth, widthModeAndSize);
|
|
1114
|
+
const heightModeAndSize = scratchModeB;
|
|
1115
|
+
heightModeAndSize.mode = childHeightSizingMode;
|
|
1116
|
+
heightModeAndSize.size = childHeight;
|
|
1117
|
+
constrainMaxSizeForMode(child, direction, FlexDirection.Column, ownerHeight, ownerWidth, heightModeAndSize);
|
|
1118
|
+
calculateLayoutInternal(child, widthModeAndSize.size, heightModeAndSize.size, direction, widthModeAndSize.mode, heightModeAndSize.mode, ownerWidth, ownerHeight, false, LayoutPassReason.MeasureChild, layoutMarkerData, depth, generationCount);
|
|
1119
|
+
child.setLayoutComputedFlexBasis(maxOrDefined(child.layout.measuredDimension(dimension(mainAxis)), paddingAndBorderForAxis(child, mainAxis, direction, ownerWidth)));
|
|
1120
|
+
}
|
|
1121
|
+
child.setLayoutComputedFlexBasisGeneration(generationCount);
|
|
1122
|
+
}
|
|
1123
|
+
function measureNodeWithMeasureFunc(node, direction, availableWidth, availableHeight, widthSizingMode, heightSizingMode, ownerWidth, ownerHeight, layoutMarkerData) {
|
|
1124
|
+
if (widthSizingMode === SizingMode.MaxContent) availableWidth = NaN;
|
|
1125
|
+
if (heightSizingMode === SizingMode.MaxContent) availableHeight = NaN;
|
|
1126
|
+
const layout = node.layout;
|
|
1127
|
+
const paddingAndBorderAxisRow = layout.padding(PhysicalEdge.Left) + layout.padding(PhysicalEdge.Right) + layout.border(PhysicalEdge.Left) + layout.border(PhysicalEdge.Right);
|
|
1128
|
+
const paddingAndBorderAxisColumn = layout.padding(PhysicalEdge.Top) + layout.padding(PhysicalEdge.Bottom) + layout.border(PhysicalEdge.Top) + layout.border(PhysicalEdge.Bottom);
|
|
1129
|
+
const innerWidth = isUndefined(availableWidth) ? availableWidth : maxOrDefined(0, availableWidth - paddingAndBorderAxisRow);
|
|
1130
|
+
const innerHeight = isUndefined(availableHeight) ? availableHeight : maxOrDefined(0, availableHeight - paddingAndBorderAxisColumn);
|
|
1131
|
+
if (widthSizingMode === SizingMode.StretchFit && heightSizingMode === SizingMode.StretchFit) {
|
|
1132
|
+
node.setLayoutMeasuredDimension(boundAxis(node, FlexDirection.Row, direction, availableWidth, ownerWidth, ownerWidth), Dimension.Width);
|
|
1133
|
+
node.setLayoutMeasuredDimension(boundAxis(node, FlexDirection.Column, direction, availableHeight, ownerHeight, ownerWidth), Dimension.Height);
|
|
1134
|
+
} else {
|
|
1135
|
+
const measuredSize = node.measure(innerWidth, measureMode(widthSizingMode), innerHeight, measureMode(heightSizingMode));
|
|
1136
|
+
layoutMarkerData.measureCallbacks += 1;
|
|
1137
|
+
node.setLayoutMeasuredDimension(boundAxis(node, FlexDirection.Row, direction, widthSizingMode === SizingMode.MaxContent || widthSizingMode === SizingMode.FitContent ? measuredSize.width + paddingAndBorderAxisRow : availableWidth, ownerWidth, ownerWidth), Dimension.Width);
|
|
1138
|
+
node.setLayoutMeasuredDimension(boundAxis(node, FlexDirection.Column, direction, heightSizingMode === SizingMode.MaxContent || heightSizingMode === SizingMode.FitContent ? measuredSize.height + paddingAndBorderAxisColumn : availableHeight, ownerHeight, ownerWidth), Dimension.Height);
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
function measureNodeWithoutChildren(node, direction, availableWidth, availableHeight, widthSizingMode, heightSizingMode, ownerWidth, ownerHeight) {
|
|
1142
|
+
const layout = node.layout;
|
|
1143
|
+
let width = availableWidth;
|
|
1144
|
+
if (widthSizingMode === SizingMode.MaxContent || widthSizingMode === SizingMode.FitContent) width = layout.padding(PhysicalEdge.Left) + layout.padding(PhysicalEdge.Right) + layout.border(PhysicalEdge.Left) + layout.border(PhysicalEdge.Right);
|
|
1145
|
+
node.setLayoutMeasuredDimension(boundAxis(node, FlexDirection.Row, direction, width, ownerWidth, ownerWidth), Dimension.Width);
|
|
1146
|
+
let height = availableHeight;
|
|
1147
|
+
if (heightSizingMode === SizingMode.MaxContent || heightSizingMode === SizingMode.FitContent) height = layout.padding(PhysicalEdge.Top) + layout.padding(PhysicalEdge.Bottom) + layout.border(PhysicalEdge.Top) + layout.border(PhysicalEdge.Bottom);
|
|
1148
|
+
node.setLayoutMeasuredDimension(boundAxis(node, FlexDirection.Column, direction, height, ownerHeight, ownerWidth), Dimension.Height);
|
|
1149
|
+
}
|
|
1150
|
+
function isFixedSize(dim, sizingMode) {
|
|
1151
|
+
return sizingMode === SizingMode.StretchFit || isDefined(dim) && sizingMode === SizingMode.FitContent && dim <= 0;
|
|
1152
|
+
}
|
|
1153
|
+
function measureNodeWithFixedSize(node, direction, availableWidth, availableHeight, widthSizingMode, heightSizingMode, ownerWidth, ownerHeight) {
|
|
1154
|
+
if (isFixedSize(availableWidth, widthSizingMode) && isFixedSize(availableHeight, heightSizingMode)) {
|
|
1155
|
+
node.setLayoutMeasuredDimension(boundAxis(node, FlexDirection.Row, direction, isUndefined(availableWidth) || widthSizingMode === SizingMode.FitContent && availableWidth < 0 ? 0 : availableWidth, ownerWidth, ownerWidth), Dimension.Width);
|
|
1156
|
+
node.setLayoutMeasuredDimension(boundAxis(node, FlexDirection.Column, direction, isUndefined(availableHeight) || heightSizingMode === SizingMode.FitContent && availableHeight < 0 ? 0 : availableHeight, ownerHeight, ownerWidth), Dimension.Height);
|
|
1157
|
+
return true;
|
|
1158
|
+
}
|
|
1159
|
+
return false;
|
|
1160
|
+
}
|
|
1161
|
+
function zeroOutLayoutRecursively(node) {
|
|
1162
|
+
node.layout = new LayoutResults();
|
|
1163
|
+
node.setLayoutDimension(0, Dimension.Width);
|
|
1164
|
+
node.setLayoutDimension(0, Dimension.Height);
|
|
1165
|
+
node.hasNewLayout_ = true;
|
|
1166
|
+
node.cloneChildrenIfNeeded();
|
|
1167
|
+
for (const child of node.children) zeroOutLayoutRecursively(child);
|
|
1168
|
+
}
|
|
1169
|
+
function cleanupContentsNodesRecursively(node, didPerformLayout) {
|
|
1170
|
+
if (node.hasContentsChildren()) {
|
|
1171
|
+
node.cloneContentsChildrenIfNeeded();
|
|
1172
|
+
for (const child of node.children) if (child.style.display() === Display.Contents) {
|
|
1173
|
+
child.layout = new LayoutResults();
|
|
1174
|
+
child.setLayoutDimension(0, Dimension.Width);
|
|
1175
|
+
child.setLayoutDimension(0, Dimension.Height);
|
|
1176
|
+
if (didPerformLayout) child.hasNewLayout_ = true;
|
|
1177
|
+
child.setDirty(false);
|
|
1178
|
+
child.cloneChildrenIfNeeded();
|
|
1179
|
+
cleanupContentsNodesRecursively(child, didPerformLayout);
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
function calculateAvailableInnerDimension(node, direction, dim, availableDim, paddingAndBorder, ownerDim, ownerWidth) {
|
|
1184
|
+
let availableInnerDim = availableDim - paddingAndBorder;
|
|
1185
|
+
if (isDefined(availableInnerDim)) {
|
|
1186
|
+
const minDimensionOptional = node.style.resolvedMinDimension(direction, dim, ownerDim, ownerWidth);
|
|
1187
|
+
const minInnerDim = isUndefined(minDimensionOptional) ? 0 : minDimensionOptional - paddingAndBorder;
|
|
1188
|
+
const maxDimensionOptional = node.style.resolvedMaxDimension(direction, dim, ownerDim, ownerWidth);
|
|
1189
|
+
const maxInnerDim = isUndefined(maxDimensionOptional) ? Number.MAX_VALUE : maxDimensionOptional - paddingAndBorder;
|
|
1190
|
+
availableInnerDim = maxOrDefined(minOrDefined(availableInnerDim, maxInnerDim), minInnerDim);
|
|
1191
|
+
}
|
|
1192
|
+
return availableInnerDim;
|
|
1193
|
+
}
|
|
1194
|
+
function computeFlexBasisForChildren(node, layoutChildren, availableInnerWidth, availableInnerHeight, ownerWidth, ownerHeight, widthSizingMode, heightSizingMode, direction, mainAxis, performLayout, layoutMarkerData, depth, generationCount) {
|
|
1195
|
+
let totalOuterFlexBasis = 0;
|
|
1196
|
+
let singleFlexChild = null;
|
|
1197
|
+
if ((isRow(mainAxis) ? widthSizingMode : heightSizingMode) === SizingMode.StretchFit) {
|
|
1198
|
+
for (const child of layoutChildren) if (child.isNodeFlexible()) {
|
|
1199
|
+
if (singleFlexChild !== null || inexactEquals(child.resolveFlexGrow(), 0) || inexactEquals(child.resolveFlexShrink(), 0)) {
|
|
1200
|
+
singleFlexChild = null;
|
|
1201
|
+
break;
|
|
1202
|
+
} else singleFlexChild = child;
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
for (const child of layoutChildren) {
|
|
1206
|
+
child.processDimensions();
|
|
1207
|
+
if (child.style.display() === Display.None) {
|
|
1208
|
+
if (performLayout) {
|
|
1209
|
+
zeroOutLayoutRecursively(child);
|
|
1210
|
+
child.hasNewLayout_ = true;
|
|
1211
|
+
child.setDirty(false);
|
|
1212
|
+
}
|
|
1213
|
+
continue;
|
|
1214
|
+
}
|
|
1215
|
+
if (performLayout) {
|
|
1216
|
+
const childDirection = child.resolveDirection(direction);
|
|
1217
|
+
child.setPositionFromStyle(childDirection, availableInnerWidth, availableInnerHeight);
|
|
1218
|
+
}
|
|
1219
|
+
if (child.style.positionType() === PositionType.Absolute) continue;
|
|
1220
|
+
if (child === singleFlexChild) {
|
|
1221
|
+
child.setLayoutComputedFlexBasisGeneration(generationCount);
|
|
1222
|
+
child.setLayoutComputedFlexBasis(0);
|
|
1223
|
+
} else computeFlexBasisForChild(node, child, availableInnerWidth, widthSizingMode, availableInnerHeight, ownerWidth, ownerHeight, heightSizingMode, direction, layoutMarkerData, depth, generationCount);
|
|
1224
|
+
totalOuterFlexBasis += child.layout.computedFlexBasis + child.style.computeMarginForAxis(mainAxis, availableInnerWidth);
|
|
1225
|
+
}
|
|
1226
|
+
return totalOuterFlexBasis;
|
|
1227
|
+
}
|
|
1228
|
+
function computeMinContentMainSize(node, requestedAxis, ownerDirection, ownerWidth, ownerHeight) {
|
|
1229
|
+
const wantRow = isRow(requestedAxis);
|
|
1230
|
+
if (node.hasMeasureFunc()) {
|
|
1231
|
+
const size = node.measure(wantRow ? 0 : NaN, wantRow ? MeasureMode.AtMost : MeasureMode.Undefined, wantRow ? NaN : 0, wantRow ? MeasureMode.Undefined : MeasureMode.AtMost);
|
|
1232
|
+
const leafDirection = node.resolveDirection(ownerDirection);
|
|
1233
|
+
const paddingAndBorder = node.style.computeFlexStartPaddingAndBorder(requestedAxis, leafDirection, ownerWidth) + node.style.computeFlexEndPaddingAndBorder(requestedAxis, leafDirection, ownerWidth);
|
|
1234
|
+
return (wantRow ? size.width : size.height) + paddingAndBorder;
|
|
1235
|
+
}
|
|
1236
|
+
if (node.getChildCount() === 0) return 0;
|
|
1237
|
+
const direction = node.resolveDirection(ownerDirection);
|
|
1238
|
+
const nodeMainAxis = resolveDirection(node.style.flexDirection(), direction);
|
|
1239
|
+
const nodeCrossAxis = resolveCrossDirection(nodeMainAxis, direction);
|
|
1240
|
+
let mainTotal = 0;
|
|
1241
|
+
let crossMax = 0;
|
|
1242
|
+
for (let i = 0; i < node.getChildCount(); i++) {
|
|
1243
|
+
const child = node.getChild(i);
|
|
1244
|
+
if (child.style.display() === Display.None || child.style.positionType() === PositionType.Absolute) continue;
|
|
1245
|
+
let childMain = computeMinContentMainSize(child, nodeMainAxis, direction, ownerWidth, ownerHeight);
|
|
1246
|
+
childMain += child.style.computeMarginForAxis(nodeMainAxis, ownerWidth);
|
|
1247
|
+
let childCross = computeMinContentMainSize(child, nodeCrossAxis, direction, ownerWidth, ownerHeight);
|
|
1248
|
+
childCross += child.style.computeMarginForAxis(nodeCrossAxis, ownerWidth);
|
|
1249
|
+
mainTotal += childMain;
|
|
1250
|
+
crossMax = Math.max(crossMax, childCross);
|
|
1251
|
+
}
|
|
1252
|
+
mainTotal += node.style.computeFlexStartPaddingAndBorder(nodeMainAxis, direction, ownerWidth) + node.style.computeFlexEndPaddingAndBorder(nodeMainAxis, direction, ownerWidth);
|
|
1253
|
+
crossMax += node.style.computeFlexStartPaddingAndBorder(nodeCrossAxis, direction, ownerWidth) + node.style.computeFlexEndPaddingAndBorder(nodeCrossAxis, direction, ownerWidth);
|
|
1254
|
+
const nodeMainIsRow = isRow(nodeMainAxis);
|
|
1255
|
+
return wantRow ? nodeMainIsRow ? mainTotal : crossMax : nodeMainIsRow ? crossMax : mainTotal;
|
|
1256
|
+
}
|
|
1257
|
+
function computeAutoMinMainSize(child, mainAxis, direction, ownerMainAxisSize, ownerWidth, ownerHeight) {
|
|
1258
|
+
if (child.hasErrata(Errata.MinSizeUndefinedInsteadOfAuto)) return NaN;
|
|
1259
|
+
if (child.style.display() === Display.None) return NaN;
|
|
1260
|
+
if (child.style.minDimension(dimension(mainAxis)).isDefined()) return NaN;
|
|
1261
|
+
if (child.style.overflow() !== Overflow.Visible) return 0;
|
|
1262
|
+
const mainDim = dimension(mainAxis);
|
|
1263
|
+
const crossDim = isRow(mainAxis) ? Dimension.Height : Dimension.Width;
|
|
1264
|
+
const isMainAxisRow = isRow(mainAxis);
|
|
1265
|
+
const specifiedMain = child.getResolvedDimension(direction, mainDim, ownerMainAxisSize, ownerWidth);
|
|
1266
|
+
let transferredMain = NaN;
|
|
1267
|
+
const aspectRatio = child.style.aspectRatio();
|
|
1268
|
+
if (isDefined(aspectRatio)) {
|
|
1269
|
+
const crossOwner = isMainAxisRow ? ownerHeight : ownerWidth;
|
|
1270
|
+
const crossResolved = child.getResolvedDimension(direction, crossDim, crossOwner, ownerWidth);
|
|
1271
|
+
if (isDefined(crossResolved)) transferredMain = isMainAxisRow ? crossResolved * aspectRatio : crossResolved / aspectRatio;
|
|
1272
|
+
}
|
|
1273
|
+
let floor = computeMinContentMainSize(child, mainAxis, direction, ownerWidth, ownerHeight);
|
|
1274
|
+
if (isDefined(specifiedMain)) {
|
|
1275
|
+
if (isUndefined(floor) || specifiedMain < floor) floor = specifiedMain;
|
|
1276
|
+
} else if (isDefined(transferredMain)) {
|
|
1277
|
+
if (isUndefined(floor) || transferredMain < floor) floor = transferredMain;
|
|
1278
|
+
}
|
|
1279
|
+
const maxMain = child.style.resolvedMaxDimension(direction, mainDim, ownerMainAxisSize, ownerWidth);
|
|
1280
|
+
if (isDefined(maxMain) && floor > maxMain) floor = maxMain;
|
|
1281
|
+
if (isUndefined(floor) || floor < 0) floor = 0;
|
|
1282
|
+
return floor;
|
|
1283
|
+
}
|
|
1284
|
+
function boundAxisWithAutoMin(child, axis, direction, value, axisSize, widthSize) {
|
|
1285
|
+
let bounded = boundAxis(child, axis, direction, value, axisSize, widthSize);
|
|
1286
|
+
const autoMin = child.layout.computedAutoMinMainSize;
|
|
1287
|
+
if (isDefined(autoMin) && bounded < autoMin) bounded = autoMin;
|
|
1288
|
+
return bounded;
|
|
1289
|
+
}
|
|
1290
|
+
function distributeFreeSpaceSecondPass(flexLine, node, mainAxis, crossAxis, direction, ownerWidth, mainAxisOwnerSize, availableInnerMainDim, availableInnerCrossDim, availableInnerWidth, availableInnerHeight, mainAxisOverflows, sizingModeCrossDim, performLayout, layoutMarkerData, depth, generationCount) {
|
|
1291
|
+
let childFlexBasis = 0;
|
|
1292
|
+
let flexShrinkScaledFactor = 0;
|
|
1293
|
+
let flexGrowFactor = 0;
|
|
1294
|
+
let deltaFreeSpace = 0;
|
|
1295
|
+
const isMainAxisRow = isRow(mainAxis);
|
|
1296
|
+
const isNodeFlexWrap = node.style.flexWrap() !== Wrap.NoWrap;
|
|
1297
|
+
for (const currentLineChild of flexLine.itemsInFlow) {
|
|
1298
|
+
childFlexBasis = boundAxisWithinMinAndMax(currentLineChild, direction, mainAxis, currentLineChild.layout.computedFlexBasis, mainAxisOwnerSize, ownerWidth);
|
|
1299
|
+
let updatedMainSize = childFlexBasis;
|
|
1300
|
+
if (isDefined(flexLine.layout.remainingFreeSpace) && flexLine.layout.remainingFreeSpace < 0) {
|
|
1301
|
+
flexShrinkScaledFactor = -currentLineChild.resolveFlexShrink() * childFlexBasis;
|
|
1302
|
+
if (flexShrinkScaledFactor !== 0) {
|
|
1303
|
+
let childSize = NaN;
|
|
1304
|
+
if (isDefined(flexLine.layout.totalFlexShrinkScaledFactors) && flexLine.layout.totalFlexShrinkScaledFactors === 0) childSize = childFlexBasis + flexShrinkScaledFactor;
|
|
1305
|
+
else childSize = childFlexBasis + flexLine.layout.remainingFreeSpace / flexLine.layout.totalFlexShrinkScaledFactors * flexShrinkScaledFactor;
|
|
1306
|
+
updatedMainSize = boundAxisWithAutoMin(currentLineChild, mainAxis, direction, childSize, availableInnerMainDim, availableInnerWidth);
|
|
1307
|
+
}
|
|
1308
|
+
} else if (isDefined(flexLine.layout.remainingFreeSpace) && flexLine.layout.remainingFreeSpace > 0) {
|
|
1309
|
+
flexGrowFactor = currentLineChild.resolveFlexGrow();
|
|
1310
|
+
if (!Number.isNaN(flexGrowFactor) && flexGrowFactor !== 0) updatedMainSize = boundAxisWithAutoMin(currentLineChild, mainAxis, direction, childFlexBasis + flexLine.layout.remainingFreeSpace / flexLine.layout.totalFlexGrowFactors * flexGrowFactor, availableInnerMainDim, availableInnerWidth);
|
|
1311
|
+
}
|
|
1312
|
+
deltaFreeSpace += updatedMainSize - childFlexBasis;
|
|
1313
|
+
const marginMain = currentLineChild.style.computeMarginForAxis(mainAxis, availableInnerWidth);
|
|
1314
|
+
const marginCross = currentLineChild.style.computeMarginForAxis(crossAxis, availableInnerWidth);
|
|
1315
|
+
let childCrossSize = NaN;
|
|
1316
|
+
const childMainSize = updatedMainSize + marginMain;
|
|
1317
|
+
let childCrossSizingMode;
|
|
1318
|
+
const childMainSizingMode = SizingMode.StretchFit;
|
|
1319
|
+
const crossDim = dimension(crossAxis);
|
|
1320
|
+
const hasDefiniteCrossLength = currentLineChild.hasDefiniteLength(crossDim, availableInnerCrossDim);
|
|
1321
|
+
const childAlignment = resolveChildAlignment(node, currentLineChild);
|
|
1322
|
+
const crossStartMarginIsAuto = currentLineChild.style.flexStartMarginIsAuto(crossAxis, direction);
|
|
1323
|
+
const crossEndMarginIsAuto = currentLineChild.style.flexEndMarginIsAuto(crossAxis, direction);
|
|
1324
|
+
const childStyle = currentLineChild.style;
|
|
1325
|
+
if (isDefined(childStyle.aspectRatio())) {
|
|
1326
|
+
childCrossSize = isMainAxisRow ? (childMainSize - marginMain) / childStyle.aspectRatio() : (childMainSize - marginMain) * childStyle.aspectRatio();
|
|
1327
|
+
childCrossSizingMode = SizingMode.StretchFit;
|
|
1328
|
+
childCrossSize += marginCross;
|
|
1329
|
+
} else if (!Number.isNaN(availableInnerCrossDim) && !hasDefiniteCrossLength && sizingModeCrossDim === SizingMode.StretchFit && !(isNodeFlexWrap && mainAxisOverflows) && childAlignment === Align.Stretch && !crossStartMarginIsAuto && !crossEndMarginIsAuto) {
|
|
1330
|
+
childCrossSize = availableInnerCrossDim;
|
|
1331
|
+
childCrossSizingMode = SizingMode.StretchFit;
|
|
1332
|
+
} else if (!hasDefiniteCrossLength) {
|
|
1333
|
+
childCrossSize = availableInnerCrossDim;
|
|
1334
|
+
childCrossSizingMode = isUndefined(childCrossSize) ? SizingMode.MaxContent : SizingMode.FitContent;
|
|
1335
|
+
} else {
|
|
1336
|
+
childCrossSize = currentLineChild.getResolvedDimension(direction, crossDim, availableInnerCrossDim, availableInnerWidth) + marginCross;
|
|
1337
|
+
const isLoosePercentageMeasurement = currentLineChild.getProcessedDimension(crossDim).isPercent() && sizingModeCrossDim !== SizingMode.StretchFit;
|
|
1338
|
+
childCrossSizingMode = isUndefined(childCrossSize) || isLoosePercentageMeasurement ? SizingMode.MaxContent : SizingMode.StretchFit;
|
|
1339
|
+
}
|
|
1340
|
+
const mainModeAndSize = scratchModeA;
|
|
1341
|
+
mainModeAndSize.mode = childMainSizingMode;
|
|
1342
|
+
mainModeAndSize.size = childMainSize;
|
|
1343
|
+
constrainMaxSizeForMode(currentLineChild, direction, mainAxis, availableInnerMainDim, availableInnerWidth, mainModeAndSize);
|
|
1344
|
+
const crossModeAndSize = scratchModeB;
|
|
1345
|
+
crossModeAndSize.mode = childCrossSizingMode;
|
|
1346
|
+
crossModeAndSize.size = childCrossSize;
|
|
1347
|
+
constrainMaxSizeForMode(currentLineChild, direction, crossAxis, availableInnerCrossDim, availableInnerWidth, crossModeAndSize);
|
|
1348
|
+
const requiresStretchLayout = !hasDefiniteCrossLength && childAlignment === Align.Stretch && !crossStartMarginIsAuto && !crossEndMarginIsAuto;
|
|
1349
|
+
const childWidth = isMainAxisRow ? mainModeAndSize.size : crossModeAndSize.size;
|
|
1350
|
+
const childHeight = !isMainAxisRow ? mainModeAndSize.size : crossModeAndSize.size;
|
|
1351
|
+
const childWidthSizingMode = isMainAxisRow ? mainModeAndSize.mode : crossModeAndSize.mode;
|
|
1352
|
+
const childHeightSizingMode = !isMainAxisRow ? mainModeAndSize.mode : crossModeAndSize.mode;
|
|
1353
|
+
const isLayoutPass = performLayout && !requiresStretchLayout;
|
|
1354
|
+
calculateLayoutInternal(currentLineChild, childWidth, childHeight, node.layout.direction(), childWidthSizingMode, childHeightSizingMode, availableInnerWidth, availableInnerHeight, isLayoutPass, isLayoutPass ? LayoutPassReason.FlexLayout : LayoutPassReason.FlexMeasure, layoutMarkerData, depth, generationCount);
|
|
1355
|
+
node.setLayoutHadOverflow(node.layout.hadOverflow() || currentLineChild.layout.hadOverflow());
|
|
1356
|
+
}
|
|
1357
|
+
return deltaFreeSpace;
|
|
1358
|
+
}
|
|
1359
|
+
function distributeFreeSpaceFirstPass(flexLine, direction, mainAxis, ownerWidth, mainAxisOwnerSize, availableInnerMainDim, availableInnerWidth) {
|
|
1360
|
+
let flexShrinkScaledFactor = 0;
|
|
1361
|
+
let flexGrowFactor = 0;
|
|
1362
|
+
let baseMainSize = 0;
|
|
1363
|
+
let boundMainSize = 0;
|
|
1364
|
+
let deltaFreeSpace = 0;
|
|
1365
|
+
for (const currentLineChild of flexLine.itemsInFlow) {
|
|
1366
|
+
const childFlexBasis = boundAxisWithinMinAndMax(currentLineChild, direction, mainAxis, currentLineChild.layout.computedFlexBasis, mainAxisOwnerSize, ownerWidth);
|
|
1367
|
+
if (flexLine.layout.remainingFreeSpace < 0) {
|
|
1368
|
+
flexShrinkScaledFactor = -currentLineChild.resolveFlexShrink() * childFlexBasis;
|
|
1369
|
+
if (isDefined(flexShrinkScaledFactor) && flexShrinkScaledFactor !== 0) {
|
|
1370
|
+
baseMainSize = childFlexBasis + flexLine.layout.remainingFreeSpace / flexLine.layout.totalFlexShrinkScaledFactors * flexShrinkScaledFactor;
|
|
1371
|
+
boundMainSize = boundAxisWithAutoMin(currentLineChild, mainAxis, direction, baseMainSize, availableInnerMainDim, availableInnerWidth);
|
|
1372
|
+
if (isDefined(baseMainSize) && isDefined(boundMainSize) && baseMainSize !== boundMainSize) {
|
|
1373
|
+
deltaFreeSpace += boundMainSize - childFlexBasis;
|
|
1374
|
+
flexLine.layout.totalFlexShrinkScaledFactors -= -currentLineChild.resolveFlexShrink() * currentLineChild.layout.computedFlexBasis;
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
} else if (isDefined(flexLine.layout.remainingFreeSpace) && flexLine.layout.remainingFreeSpace > 0) {
|
|
1378
|
+
flexGrowFactor = currentLineChild.resolveFlexGrow();
|
|
1379
|
+
if (isDefined(flexGrowFactor) && flexGrowFactor !== 0) {
|
|
1380
|
+
baseMainSize = childFlexBasis + flexLine.layout.remainingFreeSpace / flexLine.layout.totalFlexGrowFactors * flexGrowFactor;
|
|
1381
|
+
boundMainSize = boundAxis(currentLineChild, mainAxis, direction, baseMainSize, availableInnerMainDim, availableInnerWidth);
|
|
1382
|
+
if (isDefined(baseMainSize) && isDefined(boundMainSize) && baseMainSize !== boundMainSize) {
|
|
1383
|
+
deltaFreeSpace += boundMainSize - childFlexBasis;
|
|
1384
|
+
flexLine.layout.totalFlexGrowFactors -= flexGrowFactor;
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
flexLine.layout.remainingFreeSpace -= deltaFreeSpace;
|
|
1390
|
+
}
|
|
1391
|
+
function resolveFlexibleLength(node, flexLine, mainAxis, crossAxis, direction, ownerWidth, mainAxisOwnerSize, availableInnerMainDim, availableInnerCrossDim, availableInnerWidth, availableInnerHeight, mainAxisOverflows, sizingModeCrossDim, performLayout, layoutMarkerData, depth, generationCount) {
|
|
1392
|
+
const originalFreeSpace = flexLine.layout.remainingFreeSpace;
|
|
1393
|
+
if (!node.hasErrata(Errata.MinSizeUndefinedInsteadOfAuto)) for (const currentLineChild of flexLine.itemsInFlow) currentLineChild.layout.computedAutoMinMainSize = computeAutoMinMainSize(currentLineChild, mainAxis, direction, mainAxisOwnerSize, availableInnerWidth, availableInnerHeight);
|
|
1394
|
+
else for (const currentLineChild of flexLine.itemsInFlow) currentLineChild.layout.computedAutoMinMainSize = NaN;
|
|
1395
|
+
distributeFreeSpaceFirstPass(flexLine, direction, mainAxis, ownerWidth, mainAxisOwnerSize, availableInnerMainDim, availableInnerWidth);
|
|
1396
|
+
const distributedFreeSpace = distributeFreeSpaceSecondPass(flexLine, node, mainAxis, crossAxis, direction, ownerWidth, mainAxisOwnerSize, availableInnerMainDim, availableInnerCrossDim, availableInnerWidth, availableInnerHeight, mainAxisOverflows, sizingModeCrossDim, performLayout, layoutMarkerData, depth, generationCount);
|
|
1397
|
+
flexLine.layout.remainingFreeSpace = originalFreeSpace - distributedFreeSpace;
|
|
1398
|
+
}
|
|
1399
|
+
function justifyMainAxis(node, flexLine, mainAxis, crossAxis, direction, sizingModeMainDim, sizingModeCrossDim, mainAxisOwnerSize, ownerWidth, availableInnerMainDim, availableInnerCrossDim, availableInnerWidth, performLayout) {
|
|
1400
|
+
const style = node.style;
|
|
1401
|
+
const leadingPaddingAndBorderMain = node.style.computeFlexStartPaddingAndBorder(mainAxis, direction, ownerWidth);
|
|
1402
|
+
const trailingPaddingAndBorderMain = node.style.computeFlexEndPaddingAndBorder(mainAxis, direction, ownerWidth);
|
|
1403
|
+
const gap = node.style.computeGapForAxis(mainAxis, availableInnerMainDim);
|
|
1404
|
+
if (sizingModeMainDim === SizingMode.FitContent && flexLine.layout.remainingFreeSpace > 0) {
|
|
1405
|
+
if (style.minDimension(dimension(mainAxis)).isDefined() && isDefined(style.resolvedMinDimension(direction, dimension(mainAxis), mainAxisOwnerSize, ownerWidth))) {
|
|
1406
|
+
const minAvailableMainDim = style.resolvedMinDimension(direction, dimension(mainAxis), mainAxisOwnerSize, ownerWidth) - leadingPaddingAndBorderMain - trailingPaddingAndBorderMain;
|
|
1407
|
+
const occupiedSpaceByChildNodes = availableInnerMainDim - flexLine.layout.remainingFreeSpace;
|
|
1408
|
+
flexLine.layout.remainingFreeSpace = maxOrDefined(0, minAvailableMainDim - occupiedSpaceByChildNodes);
|
|
1409
|
+
} else flexLine.layout.remainingFreeSpace = 0;
|
|
1410
|
+
}
|
|
1411
|
+
let leadingMainDim = 0;
|
|
1412
|
+
let betweenMainDim = gap;
|
|
1413
|
+
const justifyContent = flexLine.layout.remainingFreeSpace >= 0 ? node.style.justifyContent() : fallbackJustification(node.style.justifyContent());
|
|
1414
|
+
if (flexLine.numberOfAutoMargins === 0) switch (justifyContent) {
|
|
1415
|
+
case Justify.Start:
|
|
1416
|
+
case Justify.End:
|
|
1417
|
+
case Justify.Auto: break;
|
|
1418
|
+
case Justify.Stretch: break;
|
|
1419
|
+
case Justify.Center:
|
|
1420
|
+
leadingMainDim = flexLine.layout.remainingFreeSpace / 2;
|
|
1421
|
+
break;
|
|
1422
|
+
case Justify.FlexEnd:
|
|
1423
|
+
leadingMainDim = flexLine.layout.remainingFreeSpace;
|
|
1424
|
+
break;
|
|
1425
|
+
case Justify.SpaceBetween:
|
|
1426
|
+
if (flexLine.itemsInFlow.length > 1) betweenMainDim += flexLine.layout.remainingFreeSpace / (flexLine.itemsInFlow.length - 1);
|
|
1427
|
+
break;
|
|
1428
|
+
case Justify.SpaceEvenly:
|
|
1429
|
+
leadingMainDim = flexLine.layout.remainingFreeSpace / (flexLine.itemsInFlow.length + 1);
|
|
1430
|
+
betweenMainDim += leadingMainDim;
|
|
1431
|
+
break;
|
|
1432
|
+
case Justify.SpaceAround:
|
|
1433
|
+
leadingMainDim = .5 * flexLine.layout.remainingFreeSpace / flexLine.itemsInFlow.length;
|
|
1434
|
+
betweenMainDim += leadingMainDim * 2;
|
|
1435
|
+
break;
|
|
1436
|
+
case Justify.FlexStart:
|
|
1437
|
+
}
|
|
1438
|
+
flexLine.layout.mainDim = leadingPaddingAndBorderMain + leadingMainDim;
|
|
1439
|
+
flexLine.layout.crossDim = 0;
|
|
1440
|
+
let maxAscentForCurrentLine = 0;
|
|
1441
|
+
let maxDescentForCurrentLine = 0;
|
|
1442
|
+
const isNodeBaselineLayout = isBaselineLayout(node);
|
|
1443
|
+
for (const child of flexLine.itemsInFlow) {
|
|
1444
|
+
const childLayout = child.layout;
|
|
1445
|
+
if (child.style.flexStartMarginIsAuto(mainAxis, direction) && flexLine.layout.remainingFreeSpace > 0) flexLine.layout.mainDim += flexLine.layout.remainingFreeSpace / flexLine.numberOfAutoMargins;
|
|
1446
|
+
if (performLayout) child.setLayoutPosition(childLayout.position(flexStartEdge(mainAxis)) + flexLine.layout.mainDim, flexStartEdge(mainAxis));
|
|
1447
|
+
if (child !== flexLine.itemsInFlow[flexLine.itemsInFlow.length - 1]) flexLine.layout.mainDim += betweenMainDim;
|
|
1448
|
+
if (child.style.flexEndMarginIsAuto(mainAxis, direction) && flexLine.layout.remainingFreeSpace > 0) flexLine.layout.mainDim += flexLine.layout.remainingFreeSpace / flexLine.numberOfAutoMargins;
|
|
1449
|
+
if (!performLayout && sizingModeCrossDim === SizingMode.StretchFit) {
|
|
1450
|
+
flexLine.layout.mainDim += child.style.computeMarginForAxis(mainAxis, availableInnerWidth) + boundAxisWithinMinAndMax(child, direction, mainAxis, childLayout.computedFlexBasis, mainAxisOwnerSize, ownerWidth);
|
|
1451
|
+
flexLine.layout.crossDim = availableInnerCrossDim;
|
|
1452
|
+
} else {
|
|
1453
|
+
flexLine.layout.mainDim += child.dimensionWithMargin(mainAxis, availableInnerWidth);
|
|
1454
|
+
if (isNodeBaselineLayout) {
|
|
1455
|
+
const ascent = calculateBaseline(child) + child.style.computeFlexStartMargin(FlexDirection.Column, direction, availableInnerWidth);
|
|
1456
|
+
const descent = child.layout.measuredDimension(Dimension.Height) + child.style.computeMarginForAxis(FlexDirection.Column, availableInnerWidth) - ascent;
|
|
1457
|
+
maxAscentForCurrentLine = maxOrDefined(maxAscentForCurrentLine, ascent);
|
|
1458
|
+
maxDescentForCurrentLine = maxOrDefined(maxDescentForCurrentLine, descent);
|
|
1459
|
+
} else flexLine.layout.crossDim = maxOrDefined(flexLine.layout.crossDim, child.dimensionWithMargin(crossAxis, availableInnerWidth));
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
flexLine.layout.mainDim += trailingPaddingAndBorderMain;
|
|
1463
|
+
if (isNodeBaselineLayout) flexLine.layout.crossDim = maxAscentForCurrentLine + maxDescentForCurrentLine;
|
|
1464
|
+
}
|
|
1465
|
+
function calculateLayoutImpl(node, availableWidth, availableHeight, ownerDirection, widthSizingMode, heightSizingMode, ownerWidth, ownerHeight, performLayout, _reason, layoutMarkerData, depth, generationCount) {
|
|
1466
|
+
if (isUndefined(availableWidth) && widthSizingMode !== SizingMode.MaxContent) throw new Error("availableWidth is indefinite so widthSizingMode must be SizingMode::MaxContent");
|
|
1467
|
+
if (isUndefined(availableHeight) && heightSizingMode !== SizingMode.MaxContent) throw new Error("availableHeight is indefinite so heightSizingMode must be SizingMode::MaxContent");
|
|
1468
|
+
if (performLayout) layoutMarkerData.layouts += 1;
|
|
1469
|
+
else layoutMarkerData.measures += 1;
|
|
1470
|
+
const direction = node.resolveDirection(ownerDirection);
|
|
1471
|
+
node.setLayoutDirection(direction);
|
|
1472
|
+
const fixFlexBasisFitContent = node.config.isExperimentalFeatureEnabled(ExperimentalFeature.FixFlexBasisFitContent);
|
|
1473
|
+
if (fixFlexBasisFitContent && performLayout) node.setLayoutHadOverflow(false);
|
|
1474
|
+
const flexRowDirection = resolveDirection(FlexDirection.Row, direction);
|
|
1475
|
+
const flexColumnDirection = resolveDirection(FlexDirection.Column, direction);
|
|
1476
|
+
const startEdge = direction === Direction.LTR ? PhysicalEdge.Left : PhysicalEdge.Right;
|
|
1477
|
+
const endEdge = direction === Direction.LTR ? PhysicalEdge.Right : PhysicalEdge.Left;
|
|
1478
|
+
const marginRowLeading = node.style.computeInlineStartMargin(flexRowDirection, direction, ownerWidth);
|
|
1479
|
+
node.setLayoutMargin(marginRowLeading, startEdge);
|
|
1480
|
+
const marginRowTrailing = node.style.computeInlineEndMargin(flexRowDirection, direction, ownerWidth);
|
|
1481
|
+
node.setLayoutMargin(marginRowTrailing, endEdge);
|
|
1482
|
+
const marginColumnLeading = node.style.computeInlineStartMargin(flexColumnDirection, direction, ownerWidth);
|
|
1483
|
+
node.setLayoutMargin(marginColumnLeading, PhysicalEdge.Top);
|
|
1484
|
+
const marginColumnTrailing = node.style.computeInlineEndMargin(flexColumnDirection, direction, ownerWidth);
|
|
1485
|
+
node.setLayoutMargin(marginColumnTrailing, PhysicalEdge.Bottom);
|
|
1486
|
+
const marginAxisRow = marginRowLeading + marginRowTrailing;
|
|
1487
|
+
const marginAxisColumn = marginColumnLeading + marginColumnTrailing;
|
|
1488
|
+
node.setLayoutBorder(node.style.computeInlineStartBorder(flexRowDirection, direction), startEdge);
|
|
1489
|
+
node.setLayoutBorder(node.style.computeInlineEndBorder(flexRowDirection, direction), endEdge);
|
|
1490
|
+
node.setLayoutBorder(node.style.computeInlineStartBorder(flexColumnDirection, direction), PhysicalEdge.Top);
|
|
1491
|
+
node.setLayoutBorder(node.style.computeInlineEndBorder(flexColumnDirection, direction), PhysicalEdge.Bottom);
|
|
1492
|
+
node.setLayoutPadding(node.style.computeInlineStartPadding(flexRowDirection, direction, ownerWidth), startEdge);
|
|
1493
|
+
node.setLayoutPadding(node.style.computeInlineEndPadding(flexRowDirection, direction, ownerWidth), endEdge);
|
|
1494
|
+
node.setLayoutPadding(node.style.computeInlineStartPadding(flexColumnDirection, direction, ownerWidth), PhysicalEdge.Top);
|
|
1495
|
+
node.setLayoutPadding(node.style.computeInlineEndPadding(flexColumnDirection, direction, ownerWidth), PhysicalEdge.Bottom);
|
|
1496
|
+
if (node.hasMeasureFunc()) {
|
|
1497
|
+
measureNodeWithMeasureFunc(node, direction, availableWidth - marginAxisRow, availableHeight - marginAxisColumn, widthSizingMode, heightSizingMode, ownerWidth, ownerHeight, layoutMarkerData);
|
|
1498
|
+
cleanupContentsNodesRecursively(node, performLayout);
|
|
1499
|
+
return;
|
|
1500
|
+
}
|
|
1501
|
+
const layoutChildren = node.getLayoutChildren();
|
|
1502
|
+
const childCount = layoutChildren.length;
|
|
1503
|
+
if (childCount === 0) {
|
|
1504
|
+
measureNodeWithoutChildren(node, direction, availableWidth - marginAxisRow, availableHeight - marginAxisColumn, widthSizingMode, heightSizingMode, ownerWidth, ownerHeight);
|
|
1505
|
+
cleanupContentsNodesRecursively(node, performLayout);
|
|
1506
|
+
return;
|
|
1507
|
+
}
|
|
1508
|
+
if (!performLayout && measureNodeWithFixedSize(node, direction, availableWidth - marginAxisRow, availableHeight - marginAxisColumn, widthSizingMode, heightSizingMode, ownerWidth, ownerHeight)) {
|
|
1509
|
+
cleanupContentsNodesRecursively(node, false);
|
|
1510
|
+
return;
|
|
1511
|
+
}
|
|
1512
|
+
node.cloneChildrenIfNeeded();
|
|
1513
|
+
if (!fixFlexBasisFitContent || !performLayout) node.setLayoutHadOverflow(false);
|
|
1514
|
+
cleanupContentsNodesRecursively(node, performLayout);
|
|
1515
|
+
const mainAxis = resolveDirection(node.style.flexDirection(), direction);
|
|
1516
|
+
const crossAxis = resolveCrossDirection(mainAxis, direction);
|
|
1517
|
+
const isMainAxisRow = isRow(mainAxis);
|
|
1518
|
+
const isNodeFlexWrap = node.style.flexWrap() !== Wrap.NoWrap;
|
|
1519
|
+
const mainAxisOwnerSize = isMainAxisRow ? ownerWidth : ownerHeight;
|
|
1520
|
+
const crossAxisOwnerSize = isMainAxisRow ? ownerHeight : ownerWidth;
|
|
1521
|
+
const paddingAndBorderAxisMain = paddingAndBorderForAxis(node, mainAxis, direction, ownerWidth);
|
|
1522
|
+
const paddingAndBorderAxisCross = paddingAndBorderForAxis(node, crossAxis, direction, ownerWidth);
|
|
1523
|
+
const leadingPaddingAndBorderCross = node.style.computeFlexStartPaddingAndBorder(crossAxis, direction, ownerWidth);
|
|
1524
|
+
let sizingModeMainDim = isMainAxisRow ? widthSizingMode : heightSizingMode;
|
|
1525
|
+
const sizingModeCrossDim = isMainAxisRow ? heightSizingMode : widthSizingMode;
|
|
1526
|
+
const paddingAndBorderAxisRow = isMainAxisRow ? paddingAndBorderAxisMain : paddingAndBorderAxisCross;
|
|
1527
|
+
const paddingAndBorderAxisColumn = isMainAxisRow ? paddingAndBorderAxisCross : paddingAndBorderAxisMain;
|
|
1528
|
+
const availableInnerWidth = calculateAvailableInnerDimension(node, direction, Dimension.Width, availableWidth - marginAxisRow, paddingAndBorderAxisRow, ownerWidth, ownerWidth);
|
|
1529
|
+
const availableInnerHeight = calculateAvailableInnerDimension(node, direction, Dimension.Height, availableHeight - marginAxisColumn, paddingAndBorderAxisColumn, ownerHeight, ownerWidth);
|
|
1530
|
+
let availableInnerMainDim = isMainAxisRow ? availableInnerWidth : availableInnerHeight;
|
|
1531
|
+
const availableInnerCrossDim = isMainAxisRow ? availableInnerHeight : availableInnerWidth;
|
|
1532
|
+
let totalMainDim = 0;
|
|
1533
|
+
totalMainDim += computeFlexBasisForChildren(node, layoutChildren, availableInnerWidth, availableInnerHeight, availableInnerWidth, availableInnerHeight, widthSizingMode, heightSizingMode, direction, mainAxis, performLayout, layoutMarkerData, depth, generationCount);
|
|
1534
|
+
if (childCount > 1) totalMainDim += node.style.computeGapForAxis(mainAxis, availableInnerMainDim) * (childCount - 1);
|
|
1535
|
+
const mainAxisOverflows = sizingModeMainDim !== SizingMode.MaxContent && totalMainDim > availableInnerMainDim;
|
|
1536
|
+
if (isNodeFlexWrap && mainAxisOverflows && sizingModeMainDim === SizingMode.FitContent) sizingModeMainDim = SizingMode.StretchFit;
|
|
1537
|
+
let startOfLineIndex = 0;
|
|
1538
|
+
let lineCount = 0;
|
|
1539
|
+
let totalLineCrossDim = 0;
|
|
1540
|
+
const crossAxisGap = node.style.computeGapForAxis(crossAxis, availableInnerCrossDim);
|
|
1541
|
+
let maxLineMainDim = 0;
|
|
1542
|
+
const flexLine = node.layout.flexLine ??= {
|
|
1543
|
+
itemsInFlow: [],
|
|
1544
|
+
sizeConsumed: 0,
|
|
1545
|
+
numberOfAutoMargins: 0,
|
|
1546
|
+
endIndex: 0,
|
|
1547
|
+
layout: {
|
|
1548
|
+
totalFlexGrowFactors: 0,
|
|
1549
|
+
totalFlexShrinkScaledFactors: 0,
|
|
1550
|
+
remainingFreeSpace: 0,
|
|
1551
|
+
mainDim: 0,
|
|
1552
|
+
crossDim: 0
|
|
1553
|
+
}
|
|
1554
|
+
};
|
|
1555
|
+
const lineStarts = node.layout.flexLineStarts ??= [];
|
|
1556
|
+
for (; startOfLineIndex < layoutChildren.length; lineCount++) {
|
|
1557
|
+
lineStarts[lineCount] = startOfLineIndex;
|
|
1558
|
+
calculateFlexLine(node, ownerDirection, ownerWidth, mainAxisOwnerSize, availableInnerWidth, availableInnerMainDim, layoutChildren, startOfLineIndex, lineCount, flexLine);
|
|
1559
|
+
startOfLineIndex = flexLine.endIndex;
|
|
1560
|
+
const canSkipFlex = !performLayout && sizingModeCrossDim === SizingMode.StretchFit;
|
|
1561
|
+
let sizeBasedOnContent = false;
|
|
1562
|
+
if (sizingModeMainDim !== SizingMode.StretchFit) {
|
|
1563
|
+
const style = node.style;
|
|
1564
|
+
const minInnerWidth = style.resolvedMinDimension(direction, Dimension.Width, ownerWidth, ownerWidth) - paddingAndBorderAxisRow;
|
|
1565
|
+
const maxInnerWidth = style.resolvedMaxDimension(direction, Dimension.Width, ownerWidth, ownerWidth) - paddingAndBorderAxisRow;
|
|
1566
|
+
const minInnerHeight = style.resolvedMinDimension(direction, Dimension.Height, ownerHeight, ownerWidth) - paddingAndBorderAxisColumn;
|
|
1567
|
+
const maxInnerHeight = style.resolvedMaxDimension(direction, Dimension.Height, ownerHeight, ownerWidth) - paddingAndBorderAxisColumn;
|
|
1568
|
+
const minInnerMainDim = isMainAxisRow ? minInnerWidth : minInnerHeight;
|
|
1569
|
+
const maxInnerMainDim = isMainAxisRow ? maxInnerWidth : maxInnerHeight;
|
|
1570
|
+
if (isDefined(minInnerMainDim) && flexLine.sizeConsumed < minInnerMainDim) availableInnerMainDim = minInnerMainDim;
|
|
1571
|
+
else if (isDefined(maxInnerMainDim) && flexLine.sizeConsumed > maxInnerMainDim) availableInnerMainDim = maxInnerMainDim;
|
|
1572
|
+
else {
|
|
1573
|
+
const useLegacyStretchBehaviour = node.hasErrata(Errata.StretchFlexBasis);
|
|
1574
|
+
if (!useLegacyStretchBehaviour && (isDefined(flexLine.layout.totalFlexGrowFactors) && flexLine.layout.totalFlexGrowFactors === 0 || isDefined(node.resolveFlexGrow()) && node.resolveFlexGrow() === 0)) availableInnerMainDim = flexLine.sizeConsumed;
|
|
1575
|
+
sizeBasedOnContent = !useLegacyStretchBehaviour;
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
if (!sizeBasedOnContent && isDefined(availableInnerMainDim)) flexLine.layout.remainingFreeSpace = availableInnerMainDim - flexLine.sizeConsumed;
|
|
1579
|
+
else if (flexLine.sizeConsumed < 0) flexLine.layout.remainingFreeSpace = -flexLine.sizeConsumed;
|
|
1580
|
+
if (!canSkipFlex) resolveFlexibleLength(node, flexLine, mainAxis, crossAxis, direction, ownerWidth, mainAxisOwnerSize, availableInnerMainDim, availableInnerCrossDim, availableInnerWidth, availableInnerHeight, mainAxisOverflows, sizingModeCrossDim, performLayout, layoutMarkerData, depth, generationCount);
|
|
1581
|
+
node.setLayoutHadOverflow(node.layout.hadOverflow() || flexLine.layout.remainingFreeSpace < 0);
|
|
1582
|
+
justifyMainAxis(node, flexLine, mainAxis, crossAxis, direction, sizingModeMainDim, sizingModeCrossDim, mainAxisOwnerSize, ownerWidth, availableInnerMainDim, availableInnerCrossDim, availableInnerWidth, performLayout);
|
|
1583
|
+
let containerCrossAxis = availableInnerCrossDim;
|
|
1584
|
+
if (sizingModeCrossDim === SizingMode.MaxContent || sizingModeCrossDim === SizingMode.FitContent) containerCrossAxis = boundAxis(node, crossAxis, direction, flexLine.layout.crossDim + paddingAndBorderAxisCross, crossAxisOwnerSize, ownerWidth) - paddingAndBorderAxisCross;
|
|
1585
|
+
if (!isNodeFlexWrap && sizingModeCrossDim === SizingMode.StretchFit) flexLine.layout.crossDim = availableInnerCrossDim;
|
|
1586
|
+
if (!isNodeFlexWrap) flexLine.layout.crossDim = boundAxis(node, crossAxis, direction, flexLine.layout.crossDim + paddingAndBorderAxisCross, crossAxisOwnerSize, ownerWidth) - paddingAndBorderAxisCross;
|
|
1587
|
+
if (performLayout) for (const child of flexLine.itemsInFlow) {
|
|
1588
|
+
let leadingCrossDim = leadingPaddingAndBorderCross;
|
|
1589
|
+
const alignItem = resolveChildAlignment(node, child);
|
|
1590
|
+
if (alignItem === Align.Stretch && !child.style.flexStartMarginIsAuto(crossAxis, direction) && !child.style.flexEndMarginIsAuto(crossAxis, direction)) {
|
|
1591
|
+
if (!child.hasDefiniteLength(dimension(crossAxis), availableInnerCrossDim)) {
|
|
1592
|
+
let childMainSize = child.layout.measuredDimension(dimension(mainAxis));
|
|
1593
|
+
const childStyle = child.style;
|
|
1594
|
+
const childCrossSize = isDefined(childStyle.aspectRatio()) ? child.style.computeMarginForAxis(crossAxis, availableInnerWidth) + (isMainAxisRow ? childMainSize / childStyle.aspectRatio() : childMainSize * childStyle.aspectRatio()) : flexLine.layout.crossDim;
|
|
1595
|
+
childMainSize += child.style.computeMarginForAxis(mainAxis, availableInnerWidth);
|
|
1596
|
+
const childMainModeAndSize = scratchModeA;
|
|
1597
|
+
childMainModeAndSize.mode = SizingMode.StretchFit;
|
|
1598
|
+
childMainModeAndSize.size = childMainSize;
|
|
1599
|
+
constrainMaxSizeForMode(child, direction, mainAxis, availableInnerMainDim, availableInnerWidth, childMainModeAndSize);
|
|
1600
|
+
const childCrossModeAndSize = scratchModeB;
|
|
1601
|
+
childCrossModeAndSize.mode = SizingMode.StretchFit;
|
|
1602
|
+
childCrossModeAndSize.size = childCrossSize;
|
|
1603
|
+
constrainMaxSizeForMode(child, direction, crossAxis, availableInnerCrossDim, availableInnerWidth, childCrossModeAndSize);
|
|
1604
|
+
const childWidth = isMainAxisRow ? childMainModeAndSize.size : childCrossModeAndSize.size;
|
|
1605
|
+
const childHeight = !isMainAxisRow ? childMainModeAndSize.size : childCrossModeAndSize.size;
|
|
1606
|
+
const crossAxisDoesNotGrow = node.style.alignContent() !== Align.Stretch && isNodeFlexWrap;
|
|
1607
|
+
calculateLayoutInternal(child, childWidth, childHeight, direction, isUndefined(childWidth) || !isMainAxisRow && crossAxisDoesNotGrow ? SizingMode.MaxContent : SizingMode.StretchFit, isUndefined(childHeight) || isMainAxisRow && crossAxisDoesNotGrow ? SizingMode.MaxContent : SizingMode.StretchFit, availableInnerWidth, availableInnerHeight, true, LayoutPassReason.Stretch, layoutMarkerData, depth, generationCount);
|
|
1608
|
+
}
|
|
1609
|
+
} else {
|
|
1610
|
+
const remainingCrossDim = containerCrossAxis - child.dimensionWithMargin(crossAxis, availableInnerWidth);
|
|
1611
|
+
if (child.style.flexStartMarginIsAuto(crossAxis, direction) && child.style.flexEndMarginIsAuto(crossAxis, direction)) leadingCrossDim += maxOrDefined(0, remainingCrossDim / 2);
|
|
1612
|
+
else if (child.style.flexEndMarginIsAuto(crossAxis, direction)) {} else if (child.style.flexStartMarginIsAuto(crossAxis, direction)) leadingCrossDim += maxOrDefined(0, remainingCrossDim);
|
|
1613
|
+
else if (alignItem === Align.FlexStart) {} else if (alignItem === Align.Center) leadingCrossDim += remainingCrossDim / 2;
|
|
1614
|
+
else leadingCrossDim += remainingCrossDim;
|
|
1615
|
+
}
|
|
1616
|
+
child.setLayoutPosition(child.layout.position(flexStartEdge(crossAxis)) + totalLineCrossDim + leadingCrossDim, flexStartEdge(crossAxis));
|
|
1617
|
+
}
|
|
1618
|
+
const appliedCrossGap = lineCount !== 0 ? crossAxisGap : 0;
|
|
1619
|
+
totalLineCrossDim += flexLine.layout.crossDim + appliedCrossGap;
|
|
1620
|
+
maxLineMainDim = maxOrDefined(maxLineMainDim, flexLine.layout.mainDim);
|
|
1621
|
+
}
|
|
1622
|
+
if (performLayout && (isNodeFlexWrap || isBaselineLayout(node))) {
|
|
1623
|
+
let leadPerLine = 0;
|
|
1624
|
+
let currentLead = leadingPaddingAndBorderCross;
|
|
1625
|
+
let extraSpacePerLine = 0;
|
|
1626
|
+
const remainingAlignContentDim = boundAxis(node, crossAxis, direction, sizingModeCrossDim === SizingMode.StretchFit ? availableInnerCrossDim + paddingAndBorderAxisCross : node.hasDefiniteLength(dimension(crossAxis), crossAxisOwnerSize) ? node.getResolvedDimension(direction, dimension(crossAxis), crossAxisOwnerSize, ownerWidth) : totalLineCrossDim + paddingAndBorderAxisCross, crossAxisOwnerSize, ownerWidth) - paddingAndBorderAxisCross - totalLineCrossDim;
|
|
1627
|
+
switch (remainingAlignContentDim >= 0 ? node.style.alignContent() : fallbackAlignment(node.style.alignContent())) {
|
|
1628
|
+
case Align.Start:
|
|
1629
|
+
case Align.End: break;
|
|
1630
|
+
case Align.FlexEnd:
|
|
1631
|
+
currentLead += remainingAlignContentDim;
|
|
1632
|
+
break;
|
|
1633
|
+
case Align.Center:
|
|
1634
|
+
currentLead += remainingAlignContentDim / 2;
|
|
1635
|
+
break;
|
|
1636
|
+
case Align.Stretch:
|
|
1637
|
+
extraSpacePerLine = remainingAlignContentDim / lineCount;
|
|
1638
|
+
break;
|
|
1639
|
+
case Align.SpaceAround:
|
|
1640
|
+
currentLead += remainingAlignContentDim / (2 * lineCount);
|
|
1641
|
+
leadPerLine = remainingAlignContentDim / lineCount;
|
|
1642
|
+
break;
|
|
1643
|
+
case Align.SpaceEvenly:
|
|
1644
|
+
currentLead += remainingAlignContentDim / (lineCount + 1);
|
|
1645
|
+
leadPerLine = remainingAlignContentDim / (lineCount + 1);
|
|
1646
|
+
break;
|
|
1647
|
+
case Align.SpaceBetween:
|
|
1648
|
+
if (lineCount > 1) leadPerLine = remainingAlignContentDim / (lineCount - 1);
|
|
1649
|
+
break;
|
|
1650
|
+
case Align.Auto:
|
|
1651
|
+
case Align.FlexStart:
|
|
1652
|
+
case Align.Baseline:
|
|
1653
|
+
}
|
|
1654
|
+
for (let i = 0; i < lineCount; i++) {
|
|
1655
|
+
const lineStart = lineStarts[i];
|
|
1656
|
+
let lineHeight = 0;
|
|
1657
|
+
let maxAscentForCurrentLine = 0;
|
|
1658
|
+
let maxDescentForCurrentLine = 0;
|
|
1659
|
+
let endIndex = lineStart;
|
|
1660
|
+
for (let ii = lineStart; ii < layoutChildren.length; ii++) {
|
|
1661
|
+
const child = layoutChildren[ii];
|
|
1662
|
+
if (child.style.display() === Display.None) {
|
|
1663
|
+
endIndex = ii + 1;
|
|
1664
|
+
continue;
|
|
1665
|
+
}
|
|
1666
|
+
if (child.style.positionType() !== PositionType.Absolute) {
|
|
1667
|
+
if (child.lineIndex !== i) break;
|
|
1668
|
+
if (child.isLayoutDimensionDefined(crossAxis)) lineHeight = maxOrDefined(lineHeight, child.layout.measuredDimension(dimension(crossAxis)) + child.style.computeMarginForAxis(crossAxis, availableInnerWidth));
|
|
1669
|
+
if (resolveChildAlignment(node, child) === Align.Baseline) {
|
|
1670
|
+
const ascent = calculateBaseline(child) + child.style.computeFlexStartMargin(FlexDirection.Column, direction, availableInnerWidth);
|
|
1671
|
+
const descent = child.layout.measuredDimension(Dimension.Height) + child.style.computeMarginForAxis(FlexDirection.Column, availableInnerWidth) - ascent;
|
|
1672
|
+
maxAscentForCurrentLine = maxOrDefined(maxAscentForCurrentLine, ascent);
|
|
1673
|
+
maxDescentForCurrentLine = maxOrDefined(maxDescentForCurrentLine, descent);
|
|
1674
|
+
lineHeight = maxOrDefined(lineHeight, maxAscentForCurrentLine + maxDescentForCurrentLine);
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
endIndex = ii + 1;
|
|
1678
|
+
}
|
|
1679
|
+
currentLead += i !== 0 ? crossAxisGap : 0;
|
|
1680
|
+
lineHeight += extraSpacePerLine;
|
|
1681
|
+
for (let ii = lineStart; ii < endIndex; ii++) {
|
|
1682
|
+
const child = layoutChildren[ii];
|
|
1683
|
+
if (child.style.display() === Display.None) continue;
|
|
1684
|
+
if (child.style.positionType() !== PositionType.Absolute) switch (resolveChildAlignment(node, child)) {
|
|
1685
|
+
case Align.Start:
|
|
1686
|
+
case Align.End: break;
|
|
1687
|
+
case Align.FlexStart:
|
|
1688
|
+
child.setLayoutPosition(currentLead + child.style.computeFlexStartPosition(crossAxis, direction, availableInnerWidth), flexStartEdge(crossAxis));
|
|
1689
|
+
break;
|
|
1690
|
+
case Align.FlexEnd:
|
|
1691
|
+
child.setLayoutPosition(currentLead + lineHeight - child.style.computeFlexEndMargin(crossAxis, direction, availableInnerWidth) - child.layout.measuredDimension(dimension(crossAxis)), flexStartEdge(crossAxis));
|
|
1692
|
+
break;
|
|
1693
|
+
case Align.Center: {
|
|
1694
|
+
const childHeight = child.layout.measuredDimension(dimension(crossAxis));
|
|
1695
|
+
child.setLayoutPosition(currentLead + (lineHeight - childHeight) / 2, flexStartEdge(crossAxis));
|
|
1696
|
+
break;
|
|
1697
|
+
}
|
|
1698
|
+
case Align.Stretch:
|
|
1699
|
+
child.setLayoutPosition(currentLead + child.style.computeFlexStartMargin(crossAxis, direction, availableInnerWidth), flexStartEdge(crossAxis));
|
|
1700
|
+
if (!child.hasDefiniteLength(dimension(crossAxis), availableInnerCrossDim)) {
|
|
1701
|
+
const childWidth = isMainAxisRow ? child.layout.measuredDimension(Dimension.Width) + child.style.computeMarginForAxis(mainAxis, availableInnerWidth) : leadPerLine + lineHeight;
|
|
1702
|
+
const childHeight = !isMainAxisRow ? child.layout.measuredDimension(Dimension.Height) + child.style.computeMarginForAxis(crossAxis, availableInnerWidth) : leadPerLine + lineHeight;
|
|
1703
|
+
if (!(inexactEquals(childWidth, child.layout.measuredDimension(Dimension.Width)) && inexactEquals(childHeight, child.layout.measuredDimension(Dimension.Height)))) calculateLayoutInternal(child, childWidth, childHeight, direction, SizingMode.StretchFit, SizingMode.StretchFit, availableInnerWidth, availableInnerHeight, true, LayoutPassReason.MultilineStretch, layoutMarkerData, depth, generationCount);
|
|
1704
|
+
}
|
|
1705
|
+
break;
|
|
1706
|
+
case Align.Baseline:
|
|
1707
|
+
child.setLayoutPosition(currentLead + maxAscentForCurrentLine - calculateBaseline(child) + child.style.computeFlexStartPosition(FlexDirection.Column, direction, availableInnerCrossDim), PhysicalEdge.Top);
|
|
1708
|
+
break;
|
|
1709
|
+
case Align.Auto:
|
|
1710
|
+
case Align.SpaceBetween:
|
|
1711
|
+
case Align.SpaceAround:
|
|
1712
|
+
case Align.SpaceEvenly:
|
|
1713
|
+
}
|
|
1714
|
+
}
|
|
1715
|
+
currentLead = currentLead + leadPerLine + lineHeight;
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
node.setLayoutMeasuredDimension(boundAxis(node, FlexDirection.Row, direction, availableWidth - marginAxisRow, ownerWidth, ownerWidth), Dimension.Width);
|
|
1719
|
+
node.setLayoutMeasuredDimension(boundAxis(node, FlexDirection.Column, direction, availableHeight - marginAxisColumn, ownerHeight, ownerWidth), Dimension.Height);
|
|
1720
|
+
if (sizingModeMainDim === SizingMode.MaxContent || node.style.overflow() !== Overflow.Scroll && sizingModeMainDim === SizingMode.FitContent) node.setLayoutMeasuredDimension(boundAxis(node, mainAxis, direction, maxLineMainDim, mainAxisOwnerSize, ownerWidth), dimension(mainAxis));
|
|
1721
|
+
else if (sizingModeMainDim === SizingMode.FitContent && node.style.overflow() === Overflow.Scroll) node.setLayoutMeasuredDimension(maxOrDefined(minOrDefined(availableInnerMainDim + paddingAndBorderAxisMain, boundAxisWithinMinAndMax(node, direction, mainAxis, maxLineMainDim, mainAxisOwnerSize, ownerWidth)), paddingAndBorderAxisMain), dimension(mainAxis));
|
|
1722
|
+
if (sizingModeCrossDim === SizingMode.MaxContent || node.style.overflow() !== Overflow.Scroll && sizingModeCrossDim === SizingMode.FitContent) node.setLayoutMeasuredDimension(boundAxis(node, crossAxis, direction, totalLineCrossDim + paddingAndBorderAxisCross, crossAxisOwnerSize, ownerWidth), dimension(crossAxis));
|
|
1723
|
+
else if (sizingModeCrossDim === SizingMode.FitContent && node.style.overflow() === Overflow.Scroll) node.setLayoutMeasuredDimension(maxOrDefined(minOrDefined(availableInnerCrossDim + paddingAndBorderAxisCross, boundAxisWithinMinAndMax(node, direction, crossAxis, totalLineCrossDim + paddingAndBorderAxisCross, crossAxisOwnerSize, ownerWidth)), paddingAndBorderAxisCross), dimension(crossAxis));
|
|
1724
|
+
if (performLayout && node.style.flexWrap() === Wrap.WrapReverse) {
|
|
1725
|
+
for (const child of node.getLayoutChildren()) if (child.style.positionType() !== PositionType.Absolute) child.setLayoutPosition(node.layout.measuredDimension(dimension(crossAxis)) - child.layout.position(flexStartEdge(crossAxis)) - child.layout.measuredDimension(dimension(crossAxis)), flexStartEdge(crossAxis));
|
|
1726
|
+
}
|
|
1727
|
+
if (performLayout) {
|
|
1728
|
+
const needsMainTrailingPos = needsTrailingPosition(mainAxis);
|
|
1729
|
+
const needsCrossTrailingPos = needsTrailingPosition(crossAxis);
|
|
1730
|
+
if (needsMainTrailingPos || needsCrossTrailingPos) for (const child of node.getLayoutChildren()) {
|
|
1731
|
+
if (child.style.display() === Display.None || child.style.positionType() === PositionType.Absolute) continue;
|
|
1732
|
+
if (needsMainTrailingPos) setChildTrailingPosition(node, child, mainAxis);
|
|
1733
|
+
if (needsCrossTrailingPos) setChildTrailingPosition(node, child, crossAxis);
|
|
1734
|
+
}
|
|
1735
|
+
if (node.style.positionType() !== PositionType.Static || node.alwaysFormsContainingBlock || depth === 1) layoutAbsoluteDescendants(node, node, isMainAxisRow ? sizingModeMainDim : sizingModeCrossDim, direction, layoutMarkerData, depth, generationCount, 0, 0, availableInnerWidth, availableInnerHeight);
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
function calculateLayoutInternal(node, availableWidth, availableHeight, ownerDirection, widthSizingMode, heightSizingMode, ownerWidth, ownerHeight, performLayout, reason, layoutMarkerData, depth, generationCount) {
|
|
1739
|
+
if (isUndefined(availableWidth)) widthSizingMode = SizingMode.MaxContent;
|
|
1740
|
+
if (isUndefined(availableHeight)) heightSizingMode = SizingMode.MaxContent;
|
|
1741
|
+
const layout = node.layout;
|
|
1742
|
+
depth++;
|
|
1743
|
+
const needToVisitNode = node.isDirty() && layout.generationCount !== generationCount || layout.configVersion !== node.config.getVersion() || layout.lastOwnerDirection !== ownerDirection;
|
|
1744
|
+
if (needToVisitNode) {
|
|
1745
|
+
layout.nextCachedMeasurementsIndex = 0;
|
|
1746
|
+
layout.cachedLayout.availableWidth = -1;
|
|
1747
|
+
layout.cachedLayout.availableHeight = -1;
|
|
1748
|
+
layout.cachedLayout.widthSizingMode = SizingMode.MaxContent;
|
|
1749
|
+
layout.cachedLayout.heightSizingMode = SizingMode.MaxContent;
|
|
1750
|
+
layout.cachedLayout.computedWidth = -1;
|
|
1751
|
+
layout.cachedLayout.computedHeight = -1;
|
|
1752
|
+
}
|
|
1753
|
+
let cachedResults = null;
|
|
1754
|
+
if (node.hasMeasureFunc()) {
|
|
1755
|
+
const marginAxisRow = node.style.computeMarginForAxis(FlexDirection.Row, ownerWidth);
|
|
1756
|
+
const marginAxisColumn = node.style.computeMarginForAxis(FlexDirection.Column, ownerWidth);
|
|
1757
|
+
if (canUseCachedMeasurement(widthSizingMode, availableWidth, heightSizingMode, availableHeight, layout.cachedLayout.widthSizingMode, layout.cachedLayout.availableWidth, layout.cachedLayout.heightSizingMode, layout.cachedLayout.availableHeight, layout.cachedLayout.computedWidth, layout.cachedLayout.computedHeight, marginAxisRow, marginAxisColumn, node.config)) cachedResults = layout.cachedLayout;
|
|
1758
|
+
else for (let i = 0; i < layout.nextCachedMeasurementsIndex; i++) if (canUseCachedMeasurement(widthSizingMode, availableWidth, heightSizingMode, availableHeight, layout.cachedMeasurements[i].widthSizingMode, layout.cachedMeasurements[i].availableWidth, layout.cachedMeasurements[i].heightSizingMode, layout.cachedMeasurements[i].availableHeight, layout.cachedMeasurements[i].computedWidth, layout.cachedMeasurements[i].computedHeight, marginAxisRow, marginAxisColumn, node.config)) {
|
|
1759
|
+
cachedResults = layout.cachedMeasurements[i];
|
|
1760
|
+
break;
|
|
1761
|
+
}
|
|
1762
|
+
} else if (performLayout) {
|
|
1763
|
+
if (inexactEquals(layout.cachedLayout.availableWidth, availableWidth) && inexactEquals(layout.cachedLayout.availableHeight, availableHeight) && layout.cachedLayout.widthSizingMode === widthSizingMode && layout.cachedLayout.heightSizingMode === heightSizingMode) cachedResults = layout.cachedLayout;
|
|
1764
|
+
} else for (let i = 0; i < layout.nextCachedMeasurementsIndex; i++) if (inexactEquals(layout.cachedMeasurements[i].availableWidth, availableWidth) && inexactEquals(layout.cachedMeasurements[i].availableHeight, availableHeight) && layout.cachedMeasurements[i].widthSizingMode === widthSizingMode && layout.cachedMeasurements[i].heightSizingMode === heightSizingMode) {
|
|
1765
|
+
cachedResults = layout.cachedMeasurements[i];
|
|
1766
|
+
break;
|
|
1767
|
+
}
|
|
1768
|
+
if (!needToVisitNode && cachedResults !== null) {
|
|
1769
|
+
layout.setMeasuredDimension(Dimension.Width, cachedResults.computedWidth);
|
|
1770
|
+
layout.setMeasuredDimension(Dimension.Height, cachedResults.computedHeight);
|
|
1771
|
+
if (performLayout) layoutMarkerData.cachedLayouts += 1;
|
|
1772
|
+
else layoutMarkerData.cachedMeasures += 1;
|
|
1773
|
+
} else {
|
|
1774
|
+
calculateLayoutImpl(node, availableWidth, availableHeight, ownerDirection, widthSizingMode, heightSizingMode, ownerWidth, ownerHeight, performLayout, reason, layoutMarkerData, depth, generationCount);
|
|
1775
|
+
layout.lastOwnerDirection = ownerDirection;
|
|
1776
|
+
layout.configVersion = node.config.getVersion();
|
|
1777
|
+
if (cachedResults === null) {
|
|
1778
|
+
layoutMarkerData.maxMeasureCache = Math.max(layoutMarkerData.maxMeasureCache, layout.nextCachedMeasurementsIndex + 1);
|
|
1779
|
+
if (layout.nextCachedMeasurementsIndex === LayoutResults.MaxCachedMeasurements) layout.nextCachedMeasurementsIndex = 0;
|
|
1780
|
+
let newCacheEntry;
|
|
1781
|
+
if (performLayout) newCacheEntry = layout.cachedLayout;
|
|
1782
|
+
else {
|
|
1783
|
+
newCacheEntry = layout.cachedMeasurements[layout.nextCachedMeasurementsIndex] ??= new CachedMeasurement();
|
|
1784
|
+
layout.nextCachedMeasurementsIndex++;
|
|
1785
|
+
}
|
|
1786
|
+
newCacheEntry.availableWidth = availableWidth;
|
|
1787
|
+
newCacheEntry.availableHeight = availableHeight;
|
|
1788
|
+
newCacheEntry.widthSizingMode = widthSizingMode;
|
|
1789
|
+
newCacheEntry.heightSizingMode = heightSizingMode;
|
|
1790
|
+
newCacheEntry.computedWidth = layout.measuredDimension(Dimension.Width);
|
|
1791
|
+
newCacheEntry.computedHeight = layout.measuredDimension(Dimension.Height);
|
|
1792
|
+
}
|
|
1793
|
+
}
|
|
1794
|
+
if (performLayout) {
|
|
1795
|
+
node.setLayoutDimension(node.layout.measuredDimension(Dimension.Width), Dimension.Width);
|
|
1796
|
+
node.setLayoutDimension(node.layout.measuredDimension(Dimension.Height), Dimension.Height);
|
|
1797
|
+
node.hasNewLayout_ = true;
|
|
1798
|
+
node.setDirty(false);
|
|
1799
|
+
}
|
|
1800
|
+
layout.generationCount = generationCount;
|
|
1801
|
+
return needToVisitNode || cachedResults === null;
|
|
1802
|
+
}
|
|
1803
|
+
function calculateLayout(node, ownerWidth, ownerHeight, ownerDirection) {
|
|
1804
|
+
const markerData = newLayoutData();
|
|
1805
|
+
const currentGenerationCount = ++gCurrentGenerationCount;
|
|
1806
|
+
node.processDimensions();
|
|
1807
|
+
const direction = node.resolveDirection(ownerDirection);
|
|
1808
|
+
let width = NaN;
|
|
1809
|
+
let widthSizingMode = SizingMode.MaxContent;
|
|
1810
|
+
const style = node.style;
|
|
1811
|
+
if (node.hasDefiniteLength(Dimension.Width, ownerWidth)) {
|
|
1812
|
+
width = node.getResolvedDimension(direction, dimension(FlexDirection.Row), ownerWidth, ownerWidth) + node.style.computeMarginForAxis(FlexDirection.Row, ownerWidth);
|
|
1813
|
+
widthSizingMode = SizingMode.StretchFit;
|
|
1814
|
+
} else if (isDefined(style.resolvedMaxDimension(direction, Dimension.Width, ownerWidth, ownerWidth))) {
|
|
1815
|
+
width = style.resolvedMaxDimension(direction, Dimension.Width, ownerWidth, ownerWidth);
|
|
1816
|
+
widthSizingMode = SizingMode.FitContent;
|
|
1817
|
+
} else {
|
|
1818
|
+
width = ownerWidth;
|
|
1819
|
+
widthSizingMode = isUndefined(width) ? SizingMode.MaxContent : SizingMode.StretchFit;
|
|
1820
|
+
}
|
|
1821
|
+
let height = NaN;
|
|
1822
|
+
let heightSizingMode = SizingMode.MaxContent;
|
|
1823
|
+
if (node.hasDefiniteLength(Dimension.Height, ownerHeight)) {
|
|
1824
|
+
height = node.getResolvedDimension(direction, dimension(FlexDirection.Column), ownerHeight, ownerWidth) + node.style.computeMarginForAxis(FlexDirection.Column, ownerWidth);
|
|
1825
|
+
heightSizingMode = SizingMode.StretchFit;
|
|
1826
|
+
} else if (isDefined(style.resolvedMaxDimension(direction, Dimension.Height, ownerHeight, ownerWidth))) {
|
|
1827
|
+
height = style.resolvedMaxDimension(direction, Dimension.Height, ownerHeight, ownerWidth);
|
|
1828
|
+
heightSizingMode = SizingMode.FitContent;
|
|
1829
|
+
} else {
|
|
1830
|
+
height = ownerHeight;
|
|
1831
|
+
heightSizingMode = isUndefined(height) ? SizingMode.MaxContent : SizingMode.StretchFit;
|
|
1832
|
+
}
|
|
1833
|
+
const generationCount = node.config.isExperimentalFeatureEnabled(ExperimentalFeature.FixFlexBasisFitContent) ? currentGenerationCount : gCurrentGenerationCount;
|
|
1834
|
+
if (calculateLayoutInternal(node, width, height, ownerDirection, widthSizingMode, heightSizingMode, ownerWidth, ownerHeight, true, LayoutPassReason.Initial, markerData, 0, generationCount)) {
|
|
1835
|
+
node.setPositionFromStyle(node.layout.direction(), ownerWidth, ownerHeight);
|
|
1836
|
+
roundLayoutResultsToPixelGrid(node, 0, 0);
|
|
1837
|
+
}
|
|
1838
|
+
}
|
|
1839
|
+
//#endregion
|
|
1840
|
+
//#region src/yoga/core/types.ts
|
|
1841
|
+
function isInvalidValue(value) {
|
|
1842
|
+
return isUndefined(value) || !Number.isFinite(value);
|
|
1843
|
+
}
|
|
1844
|
+
/**
|
|
1845
|
+
* A CSS <length-percentage> or keyword. `value` is NaN for keyword units.
|
|
1846
|
+
* Instances are immutable and may be shared.
|
|
1847
|
+
*/
|
|
1848
|
+
var StyleLength = class StyleLength {
|
|
1849
|
+
value;
|
|
1850
|
+
unit;
|
|
1851
|
+
constructor(value, unit) {
|
|
1852
|
+
this.value = value;
|
|
1853
|
+
this.unit = unit;
|
|
1854
|
+
}
|
|
1855
|
+
static points(value) {
|
|
1856
|
+
return isInvalidValue(value) ? StyleLength.undefined() : new StyleLength(value, Unit.Point);
|
|
1857
|
+
}
|
|
1858
|
+
static percent(value) {
|
|
1859
|
+
return isInvalidValue(value) ? StyleLength.undefined() : new StyleLength(value, Unit.Percent);
|
|
1860
|
+
}
|
|
1861
|
+
static ofAuto() {
|
|
1862
|
+
return AUTO;
|
|
1863
|
+
}
|
|
1864
|
+
static undefined() {
|
|
1865
|
+
return UNDEFINED;
|
|
1866
|
+
}
|
|
1867
|
+
isAuto() {
|
|
1868
|
+
return this.unit === Unit.Auto;
|
|
1869
|
+
}
|
|
1870
|
+
isUndefined() {
|
|
1871
|
+
return this.unit === Unit.Undefined;
|
|
1872
|
+
}
|
|
1873
|
+
isDefined() {
|
|
1874
|
+
return !this.isUndefined();
|
|
1875
|
+
}
|
|
1876
|
+
isPoints() {
|
|
1877
|
+
return this.unit === Unit.Point;
|
|
1878
|
+
}
|
|
1879
|
+
isPercent() {
|
|
1880
|
+
return this.unit === Unit.Percent;
|
|
1881
|
+
}
|
|
1882
|
+
resolve(referenceLength) {
|
|
1883
|
+
switch (this.unit) {
|
|
1884
|
+
case Unit.Point: return this.value;
|
|
1885
|
+
case Unit.Percent: return this.value * referenceLength * .01;
|
|
1886
|
+
default: return NaN;
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
equals(other) {
|
|
1890
|
+
return optionalEquals(this.value, other.value) && this.unit === other.unit;
|
|
1891
|
+
}
|
|
1892
|
+
inexactEquals(other) {
|
|
1893
|
+
return this.unit === other.unit && inexactEquals(this.value, other.value);
|
|
1894
|
+
}
|
|
1895
|
+
};
|
|
1896
|
+
const AUTO = new class extends StyleLength {
|
|
1897
|
+
constructor() {
|
|
1898
|
+
super(NaN, Unit.Auto);
|
|
1899
|
+
}
|
|
1900
|
+
}();
|
|
1901
|
+
const UNDEFINED = new class extends StyleLength {
|
|
1902
|
+
constructor() {
|
|
1903
|
+
super(NaN, Unit.Undefined);
|
|
1904
|
+
}
|
|
1905
|
+
}();
|
|
1906
|
+
/**
|
|
1907
|
+
* A CSS value for sizes (width, min-width, flex-basis, ...) which additionally
|
|
1908
|
+
* allows the auto/max-content/fit-content/stretch keywords.
|
|
1909
|
+
*/
|
|
1910
|
+
var StyleSizeLength = class StyleSizeLength {
|
|
1911
|
+
value;
|
|
1912
|
+
unit;
|
|
1913
|
+
constructor(value, unit) {
|
|
1914
|
+
this.value = value;
|
|
1915
|
+
this.unit = unit;
|
|
1916
|
+
}
|
|
1917
|
+
static points(value) {
|
|
1918
|
+
return isInvalidValue(value) ? StyleSizeLength.undefined() : new StyleSizeLength(value, Unit.Point);
|
|
1919
|
+
}
|
|
1920
|
+
static percent(value) {
|
|
1921
|
+
return isInvalidValue(value) ? StyleSizeLength.undefined() : new StyleSizeLength(value, Unit.Percent);
|
|
1922
|
+
}
|
|
1923
|
+
static ofAuto() {
|
|
1924
|
+
return SIZE_AUTO;
|
|
1925
|
+
}
|
|
1926
|
+
static ofMaxContent() {
|
|
1927
|
+
return SIZE_MAX_CONTENT;
|
|
1928
|
+
}
|
|
1929
|
+
static ofFitContent() {
|
|
1930
|
+
return SIZE_FIT_CONTENT;
|
|
1931
|
+
}
|
|
1932
|
+
static ofStretch() {
|
|
1933
|
+
return SIZE_STRETCH;
|
|
1934
|
+
}
|
|
1935
|
+
static undefined() {
|
|
1936
|
+
return SIZE_UNDEFINED;
|
|
1937
|
+
}
|
|
1938
|
+
isAuto() {
|
|
1939
|
+
return this.unit === Unit.Auto;
|
|
1940
|
+
}
|
|
1941
|
+
isMaxContent() {
|
|
1942
|
+
return this.unit === Unit.MaxContent;
|
|
1943
|
+
}
|
|
1944
|
+
isFitContent() {
|
|
1945
|
+
return this.unit === Unit.FitContent;
|
|
1946
|
+
}
|
|
1947
|
+
isStretch() {
|
|
1948
|
+
return this.unit === Unit.Stretch;
|
|
1949
|
+
}
|
|
1950
|
+
isUndefined() {
|
|
1951
|
+
return this.unit === Unit.Undefined;
|
|
1952
|
+
}
|
|
1953
|
+
isDefined() {
|
|
1954
|
+
return !this.isUndefined();
|
|
1955
|
+
}
|
|
1956
|
+
isPoints() {
|
|
1957
|
+
return this.unit === Unit.Point;
|
|
1958
|
+
}
|
|
1959
|
+
isPercent() {
|
|
1960
|
+
return this.unit === Unit.Percent;
|
|
1961
|
+
}
|
|
1962
|
+
resolve(referenceLength) {
|
|
1963
|
+
switch (this.unit) {
|
|
1964
|
+
case Unit.Point: return this.value;
|
|
1965
|
+
case Unit.Percent: return this.value * referenceLength * .01;
|
|
1966
|
+
default: return NaN;
|
|
1967
|
+
}
|
|
1968
|
+
}
|
|
1969
|
+
equals(other) {
|
|
1970
|
+
return optionalEquals(this.value, other.value) && this.unit === other.unit;
|
|
1971
|
+
}
|
|
1972
|
+
inexactEquals(other) {
|
|
1973
|
+
return this.unit === other.unit && inexactEquals(this.value, other.value);
|
|
1974
|
+
}
|
|
1975
|
+
};
|
|
1976
|
+
const SIZE_AUTO = new class extends StyleSizeLength {
|
|
1977
|
+
constructor() {
|
|
1978
|
+
super(NaN, Unit.Auto);
|
|
1979
|
+
}
|
|
1980
|
+
}();
|
|
1981
|
+
const SIZE_MAX_CONTENT = new class extends StyleSizeLength {
|
|
1982
|
+
constructor() {
|
|
1983
|
+
super(NaN, Unit.MaxContent);
|
|
1984
|
+
}
|
|
1985
|
+
}();
|
|
1986
|
+
const SIZE_FIT_CONTENT = new class extends StyleSizeLength {
|
|
1987
|
+
constructor() {
|
|
1988
|
+
super(NaN, Unit.FitContent);
|
|
1989
|
+
}
|
|
1990
|
+
}();
|
|
1991
|
+
const SIZE_STRETCH = new class extends StyleSizeLength {
|
|
1992
|
+
constructor() {
|
|
1993
|
+
super(NaN, Unit.Stretch);
|
|
1994
|
+
}
|
|
1995
|
+
}();
|
|
1996
|
+
const SIZE_UNDEFINED = new class extends StyleSizeLength {
|
|
1997
|
+
constructor() {
|
|
1998
|
+
super(NaN, Unit.Undefined);
|
|
1999
|
+
}
|
|
2000
|
+
}();
|
|
2001
|
+
//#endregion
|
|
2002
|
+
//#region src/yoga/core/style.ts
|
|
2003
|
+
const EDGE_COUNT = 9;
|
|
2004
|
+
const GUTTER_COUNT = 3;
|
|
2005
|
+
function undefinedLengths(count) {
|
|
2006
|
+
return Array.from({ length: count }).fill(StyleLength.undefined());
|
|
2007
|
+
}
|
|
2008
|
+
var Style = class {
|
|
2009
|
+
static DefaultFlexGrow = 0;
|
|
2010
|
+
static DefaultFlexShrink = 0;
|
|
2011
|
+
static WebDefaultFlexShrink = 1;
|
|
2012
|
+
direction_ = Direction.Inherit;
|
|
2013
|
+
flexDirection_ = FlexDirection.Column;
|
|
2014
|
+
justifyContent_ = Justify.FlexStart;
|
|
2015
|
+
justifyItems_ = Justify.Stretch;
|
|
2016
|
+
justifySelf_ = Justify.Auto;
|
|
2017
|
+
alignContent_ = Align.FlexStart;
|
|
2018
|
+
alignItems_ = Align.Stretch;
|
|
2019
|
+
alignSelf_ = Align.Auto;
|
|
2020
|
+
positionType_ = PositionType.Relative;
|
|
2021
|
+
flexWrap_ = Wrap.NoWrap;
|
|
2022
|
+
overflow_ = Overflow.Visible;
|
|
2023
|
+
display_ = Display.Flex;
|
|
2024
|
+
boxSizing_ = BoxSizing.BorderBox;
|
|
2025
|
+
flex_ = NaN;
|
|
2026
|
+
flexGrow_ = NaN;
|
|
2027
|
+
flexShrink_ = NaN;
|
|
2028
|
+
flexBasis_ = StyleSizeLength.ofAuto();
|
|
2029
|
+
margin_ = null;
|
|
2030
|
+
position_ = null;
|
|
2031
|
+
padding_ = null;
|
|
2032
|
+
border_ = null;
|
|
2033
|
+
gap_ = null;
|
|
2034
|
+
marginResolved_ = null;
|
|
2035
|
+
positionResolved_ = null;
|
|
2036
|
+
paddingResolved_ = null;
|
|
2037
|
+
borderResolved_ = null;
|
|
2038
|
+
dimensions_ = [
|
|
2039
|
+
StyleSizeLength.ofAuto(),
|
|
2040
|
+
StyleSizeLength.ofAuto(),
|
|
2041
|
+
StyleSizeLength.undefined(),
|
|
2042
|
+
StyleSizeLength.undefined(),
|
|
2043
|
+
StyleSizeLength.undefined(),
|
|
2044
|
+
StyleSizeLength.undefined()
|
|
2045
|
+
];
|
|
2046
|
+
aspectRatio_ = NaN;
|
|
2047
|
+
direction() {
|
|
2048
|
+
return this.direction_;
|
|
2049
|
+
}
|
|
2050
|
+
setDirection(value) {
|
|
2051
|
+
this.direction_ = value;
|
|
2052
|
+
}
|
|
2053
|
+
flexDirection() {
|
|
2054
|
+
return this.flexDirection_;
|
|
2055
|
+
}
|
|
2056
|
+
setFlexDirection(value) {
|
|
2057
|
+
this.flexDirection_ = value;
|
|
2058
|
+
}
|
|
2059
|
+
justifyContent() {
|
|
2060
|
+
return this.justifyContent_;
|
|
2061
|
+
}
|
|
2062
|
+
setJustifyContent(value) {
|
|
2063
|
+
this.justifyContent_ = value;
|
|
2064
|
+
}
|
|
2065
|
+
justifyItems() {
|
|
2066
|
+
return this.justifyItems_;
|
|
2067
|
+
}
|
|
2068
|
+
setJustifyItems(value) {
|
|
2069
|
+
this.justifyItems_ = value;
|
|
2070
|
+
}
|
|
2071
|
+
justifySelf() {
|
|
2072
|
+
return this.justifySelf_;
|
|
2073
|
+
}
|
|
2074
|
+
setJustifySelf(value) {
|
|
2075
|
+
this.justifySelf_ = value;
|
|
2076
|
+
}
|
|
2077
|
+
alignContent() {
|
|
2078
|
+
return this.alignContent_;
|
|
2079
|
+
}
|
|
2080
|
+
setAlignContent(value) {
|
|
2081
|
+
this.alignContent_ = value;
|
|
2082
|
+
}
|
|
2083
|
+
alignItems() {
|
|
2084
|
+
return this.alignItems_;
|
|
2085
|
+
}
|
|
2086
|
+
setAlignItems(value) {
|
|
2087
|
+
this.alignItems_ = value;
|
|
2088
|
+
}
|
|
2089
|
+
alignSelf() {
|
|
2090
|
+
return this.alignSelf_;
|
|
2091
|
+
}
|
|
2092
|
+
setAlignSelf(value) {
|
|
2093
|
+
this.alignSelf_ = value;
|
|
2094
|
+
}
|
|
2095
|
+
positionType() {
|
|
2096
|
+
return this.positionType_;
|
|
2097
|
+
}
|
|
2098
|
+
setPositionType(value) {
|
|
2099
|
+
this.positionType_ = value;
|
|
2100
|
+
}
|
|
2101
|
+
flexWrap() {
|
|
2102
|
+
return this.flexWrap_;
|
|
2103
|
+
}
|
|
2104
|
+
setFlexWrap(value) {
|
|
2105
|
+
this.flexWrap_ = value;
|
|
2106
|
+
}
|
|
2107
|
+
overflow() {
|
|
2108
|
+
return this.overflow_;
|
|
2109
|
+
}
|
|
2110
|
+
setOverflow(value) {
|
|
2111
|
+
this.overflow_ = value;
|
|
2112
|
+
}
|
|
2113
|
+
display() {
|
|
2114
|
+
return this.display_;
|
|
2115
|
+
}
|
|
2116
|
+
setDisplay(value) {
|
|
2117
|
+
this.display_ = value;
|
|
2118
|
+
}
|
|
2119
|
+
flex() {
|
|
2120
|
+
return this.flex_;
|
|
2121
|
+
}
|
|
2122
|
+
setFlex(value) {
|
|
2123
|
+
this.flex_ = value;
|
|
2124
|
+
}
|
|
2125
|
+
flexGrow() {
|
|
2126
|
+
return this.flexGrow_;
|
|
2127
|
+
}
|
|
2128
|
+
setFlexGrow(value) {
|
|
2129
|
+
this.flexGrow_ = value;
|
|
2130
|
+
}
|
|
2131
|
+
flexShrink() {
|
|
2132
|
+
return this.flexShrink_;
|
|
2133
|
+
}
|
|
2134
|
+
setFlexShrink(value) {
|
|
2135
|
+
this.flexShrink_ = value;
|
|
2136
|
+
}
|
|
2137
|
+
flexBasis() {
|
|
2138
|
+
return this.flexBasis_;
|
|
2139
|
+
}
|
|
2140
|
+
setFlexBasis(value) {
|
|
2141
|
+
this.flexBasis_ = value;
|
|
2142
|
+
}
|
|
2143
|
+
margin(edge) {
|
|
2144
|
+
return this.margin_ !== null ? this.margin_[edge] : StyleLength.undefined();
|
|
2145
|
+
}
|
|
2146
|
+
setMargin(edge, value) {
|
|
2147
|
+
(this.margin_ ??= undefinedLengths(EDGE_COUNT))[edge] = value;
|
|
2148
|
+
this.marginResolved_ = null;
|
|
2149
|
+
}
|
|
2150
|
+
position(edge) {
|
|
2151
|
+
return this.position_ !== null ? this.position_[edge] : StyleLength.undefined();
|
|
2152
|
+
}
|
|
2153
|
+
setPosition(edge, value) {
|
|
2154
|
+
(this.position_ ??= undefinedLengths(EDGE_COUNT))[edge] = value;
|
|
2155
|
+
this.positionResolved_ = null;
|
|
2156
|
+
}
|
|
2157
|
+
padding(edge) {
|
|
2158
|
+
return this.padding_ !== null ? this.padding_[edge] : StyleLength.undefined();
|
|
2159
|
+
}
|
|
2160
|
+
setPadding(edge, value) {
|
|
2161
|
+
(this.padding_ ??= undefinedLengths(EDGE_COUNT))[edge] = value;
|
|
2162
|
+
this.paddingResolved_ = null;
|
|
2163
|
+
}
|
|
2164
|
+
border(edge) {
|
|
2165
|
+
return this.border_ !== null ? this.border_[edge] : StyleLength.undefined();
|
|
2166
|
+
}
|
|
2167
|
+
setBorder(edge, value) {
|
|
2168
|
+
(this.border_ ??= undefinedLengths(EDGE_COUNT))[edge] = value;
|
|
2169
|
+
this.borderResolved_ = null;
|
|
2170
|
+
}
|
|
2171
|
+
gap(gutter) {
|
|
2172
|
+
return this.gap_ !== null ? this.gap_[gutter] : StyleLength.undefined();
|
|
2173
|
+
}
|
|
2174
|
+
setGap(gutter, value) {
|
|
2175
|
+
(this.gap_ ??= undefinedLengths(GUTTER_COUNT))[gutter] = value;
|
|
2176
|
+
}
|
|
2177
|
+
dimension(axis) {
|
|
2178
|
+
return this.dimensions_[axis];
|
|
2179
|
+
}
|
|
2180
|
+
setDimension(axis, value) {
|
|
2181
|
+
this.dimensions_[axis] = value;
|
|
2182
|
+
}
|
|
2183
|
+
minDimension(axis) {
|
|
2184
|
+
return this.dimensions_[2 + axis];
|
|
2185
|
+
}
|
|
2186
|
+
setMinDimension(axis, value) {
|
|
2187
|
+
this.dimensions_[2 + axis] = value;
|
|
2188
|
+
}
|
|
2189
|
+
maxDimension(axis) {
|
|
2190
|
+
return this.dimensions_[4 + axis];
|
|
2191
|
+
}
|
|
2192
|
+
setMaxDimension(axis, value) {
|
|
2193
|
+
this.dimensions_[4 + axis] = value;
|
|
2194
|
+
}
|
|
2195
|
+
resolvedMinDimension(direction, axis, referenceLength, ownerWidth) {
|
|
2196
|
+
const minDimension = this.dimensions_[2 + axis];
|
|
2197
|
+
if (minDimension.isUndefined()) return NaN;
|
|
2198
|
+
const value = minDimension.resolve(referenceLength);
|
|
2199
|
+
if (this.boxSizing_ === BoxSizing.BorderBox || !isDefined(value)) return value;
|
|
2200
|
+
const dimensionPaddingAndBorder = this.computePaddingAndBorderForDimension(direction, axis, ownerWidth);
|
|
2201
|
+
return value + (isDefined(dimensionPaddingAndBorder) ? dimensionPaddingAndBorder : 0);
|
|
2202
|
+
}
|
|
2203
|
+
resolvedMaxDimension(direction, axis, referenceLength, ownerWidth) {
|
|
2204
|
+
const maxDimension = this.dimensions_[4 + axis];
|
|
2205
|
+
if (maxDimension.isUndefined()) return NaN;
|
|
2206
|
+
const value = maxDimension.resolve(referenceLength);
|
|
2207
|
+
if (this.boxSizing_ === BoxSizing.BorderBox || !isDefined(value)) return value;
|
|
2208
|
+
const dimensionPaddingAndBorder = this.computePaddingAndBorderForDimension(direction, axis, ownerWidth);
|
|
2209
|
+
return value + (isDefined(dimensionPaddingAndBorder) ? dimensionPaddingAndBorder : 0);
|
|
2210
|
+
}
|
|
2211
|
+
aspectRatio() {
|
|
2212
|
+
return this.aspectRatio_;
|
|
2213
|
+
}
|
|
2214
|
+
setAspectRatio(value) {
|
|
2215
|
+
this.aspectRatio_ = value === 0 || value === Infinity || value === -Infinity ? NaN : value;
|
|
2216
|
+
}
|
|
2217
|
+
boxSizing() {
|
|
2218
|
+
return this.boxSizing_;
|
|
2219
|
+
}
|
|
2220
|
+
setBoxSizing(value) {
|
|
2221
|
+
this.boxSizing_ = value;
|
|
2222
|
+
}
|
|
2223
|
+
horizontalInsetsDefined() {
|
|
2224
|
+
const position = this.position_;
|
|
2225
|
+
return position !== null && (position[Edge.Left].isDefined() || position[Edge.Right].isDefined() || position[Edge.All].isDefined() || position[Edge.Horizontal].isDefined() || position[Edge.Start].isDefined() || position[Edge.End].isDefined());
|
|
2226
|
+
}
|
|
2227
|
+
verticalInsetsDefined() {
|
|
2228
|
+
const position = this.position_;
|
|
2229
|
+
return position !== null && (position[Edge.Top].isDefined() || position[Edge.Bottom].isDefined() || position[Edge.All].isDefined() || position[Edge.Vertical].isDefined());
|
|
2230
|
+
}
|
|
2231
|
+
hasPositionOrMargin() {
|
|
2232
|
+
return this.position_ !== null || this.margin_ !== null;
|
|
2233
|
+
}
|
|
2234
|
+
hasPaddingOrBorder() {
|
|
2235
|
+
return this.padding_ !== null || this.border_ !== null;
|
|
2236
|
+
}
|
|
2237
|
+
isFlexStartPositionDefined(axis, direction) {
|
|
2238
|
+
if (this.position_ === null) return false;
|
|
2239
|
+
return this.computePosition(flexStartEdge(axis), direction).isDefined();
|
|
2240
|
+
}
|
|
2241
|
+
isFlexStartPositionAuto(axis, direction) {
|
|
2242
|
+
if (this.position_ === null) return false;
|
|
2243
|
+
return this.computePosition(flexStartEdge(axis), direction).isAuto();
|
|
2244
|
+
}
|
|
2245
|
+
isInlineStartPositionDefined(axis, direction) {
|
|
2246
|
+
if (this.position_ === null) return false;
|
|
2247
|
+
return this.computePosition(inlineStartEdge(axis, direction), direction).isDefined();
|
|
2248
|
+
}
|
|
2249
|
+
isInlineStartPositionAuto(axis, direction) {
|
|
2250
|
+
if (this.position_ === null) return false;
|
|
2251
|
+
return this.computePosition(inlineStartEdge(axis, direction), direction).isAuto();
|
|
2252
|
+
}
|
|
2253
|
+
isFlexEndPositionDefined(axis, direction) {
|
|
2254
|
+
if (this.position_ === null) return false;
|
|
2255
|
+
return this.computePosition(flexEndEdge(axis), direction).isDefined();
|
|
2256
|
+
}
|
|
2257
|
+
isFlexEndPositionAuto(axis, direction) {
|
|
2258
|
+
if (this.position_ === null) return false;
|
|
2259
|
+
return this.computePosition(flexEndEdge(axis), direction).isAuto();
|
|
2260
|
+
}
|
|
2261
|
+
isInlineEndPositionDefined(axis, direction) {
|
|
2262
|
+
if (this.position_ === null) return false;
|
|
2263
|
+
return this.computePosition(inlineEndEdge(axis, direction), direction).isDefined();
|
|
2264
|
+
}
|
|
2265
|
+
isInlineEndPositionAuto(axis, direction) {
|
|
2266
|
+
if (this.position_ === null) return false;
|
|
2267
|
+
return this.computePosition(inlineEndEdge(axis, direction), direction).isAuto();
|
|
2268
|
+
}
|
|
2269
|
+
computeFlexStartPosition(axis, direction, axisSize) {
|
|
2270
|
+
if (this.position_ === null) return 0;
|
|
2271
|
+
return edgeValueOrZero(this.resolvedPosition(), direction * 4 + flexStartEdge(axis), axisSize);
|
|
2272
|
+
}
|
|
2273
|
+
computeInlineStartPosition(axis, direction, axisSize) {
|
|
2274
|
+
if (this.position_ === null) return 0;
|
|
2275
|
+
return edgeValueOrZero(this.resolvedPosition(), direction * 4 + inlineStartEdge(axis, direction), axisSize);
|
|
2276
|
+
}
|
|
2277
|
+
computeFlexEndPosition(axis, direction, axisSize) {
|
|
2278
|
+
if (this.position_ === null) return 0;
|
|
2279
|
+
return edgeValueOrZero(this.resolvedPosition(), direction * 4 + flexEndEdge(axis), axisSize);
|
|
2280
|
+
}
|
|
2281
|
+
computeInlineEndPosition(axis, direction, axisSize) {
|
|
2282
|
+
if (this.position_ === null) return 0;
|
|
2283
|
+
return edgeValueOrZero(this.resolvedPosition(), direction * 4 + inlineEndEdge(axis, direction), axisSize);
|
|
2284
|
+
}
|
|
2285
|
+
computeFlexStartMargin(axis, direction, widthSize) {
|
|
2286
|
+
if (this.margin_ === null) return 0;
|
|
2287
|
+
return edgeValueOrZero(this.resolvedMargin(), direction * 4 + flexStartEdge(axis), widthSize);
|
|
2288
|
+
}
|
|
2289
|
+
computeInlineStartMargin(axis, direction, widthSize) {
|
|
2290
|
+
if (this.margin_ === null) return 0;
|
|
2291
|
+
return edgeValueOrZero(this.resolvedMargin(), direction * 4 + inlineStartEdge(axis, direction), widthSize);
|
|
2292
|
+
}
|
|
2293
|
+
computeFlexEndMargin(axis, direction, widthSize) {
|
|
2294
|
+
if (this.margin_ === null) return 0;
|
|
2295
|
+
return edgeValueOrZero(this.resolvedMargin(), direction * 4 + flexEndEdge(axis), widthSize);
|
|
2296
|
+
}
|
|
2297
|
+
computeInlineEndMargin(axis, direction, widthSize) {
|
|
2298
|
+
if (this.margin_ === null) return 0;
|
|
2299
|
+
return edgeValueOrZero(this.resolvedMargin(), direction * 4 + inlineEndEdge(axis, direction), widthSize);
|
|
2300
|
+
}
|
|
2301
|
+
computeFlexStartBorder(axis, direction) {
|
|
2302
|
+
if (this.border_ === null) return 0;
|
|
2303
|
+
return edgeValueFloored(this.resolvedBorder(), direction * 4 + flexStartEdge(axis), 0);
|
|
2304
|
+
}
|
|
2305
|
+
computeInlineStartBorder(axis, direction) {
|
|
2306
|
+
if (this.border_ === null) return 0;
|
|
2307
|
+
return edgeValueFloored(this.resolvedBorder(), direction * 4 + inlineStartEdge(axis, direction), 0);
|
|
2308
|
+
}
|
|
2309
|
+
computeFlexEndBorder(axis, direction) {
|
|
2310
|
+
if (this.border_ === null) return 0;
|
|
2311
|
+
return edgeValueFloored(this.resolvedBorder(), direction * 4 + flexEndEdge(axis), 0);
|
|
2312
|
+
}
|
|
2313
|
+
computeInlineEndBorder(axis, direction) {
|
|
2314
|
+
if (this.border_ === null) return 0;
|
|
2315
|
+
return edgeValueFloored(this.resolvedBorder(), direction * 4 + inlineEndEdge(axis, direction), 0);
|
|
2316
|
+
}
|
|
2317
|
+
computeFlexStartPadding(axis, direction, widthSize) {
|
|
2318
|
+
if (this.padding_ === null) return 0;
|
|
2319
|
+
return edgeValueFloored(this.resolvedPadding(), direction * 4 + flexStartEdge(axis), widthSize);
|
|
2320
|
+
}
|
|
2321
|
+
computeInlineStartPadding(axis, direction, widthSize) {
|
|
2322
|
+
if (this.padding_ === null) return 0;
|
|
2323
|
+
return edgeValueFloored(this.resolvedPadding(), direction * 4 + inlineStartEdge(axis, direction), widthSize);
|
|
2324
|
+
}
|
|
2325
|
+
computeFlexEndPadding(axis, direction, widthSize) {
|
|
2326
|
+
if (this.padding_ === null) return 0;
|
|
2327
|
+
return edgeValueFloored(this.resolvedPadding(), direction * 4 + flexEndEdge(axis), widthSize);
|
|
2328
|
+
}
|
|
2329
|
+
computeInlineEndPadding(axis, direction, widthSize) {
|
|
2330
|
+
if (this.padding_ === null) return 0;
|
|
2331
|
+
return edgeValueFloored(this.resolvedPadding(), direction * 4 + inlineEndEdge(axis, direction), widthSize);
|
|
2332
|
+
}
|
|
2333
|
+
computeInlineStartPaddingAndBorder(axis, direction, widthSize) {
|
|
2334
|
+
return this.computeInlineStartPadding(axis, direction, widthSize) + this.computeInlineStartBorder(axis, direction);
|
|
2335
|
+
}
|
|
2336
|
+
computeFlexStartPaddingAndBorder(axis, direction, widthSize) {
|
|
2337
|
+
return this.computeFlexStartPadding(axis, direction, widthSize) + this.computeFlexStartBorder(axis, direction);
|
|
2338
|
+
}
|
|
2339
|
+
computeInlineEndPaddingAndBorder(axis, direction, widthSize) {
|
|
2340
|
+
return this.computeInlineEndPadding(axis, direction, widthSize) + this.computeInlineEndBorder(axis, direction);
|
|
2341
|
+
}
|
|
2342
|
+
computeFlexEndPaddingAndBorder(axis, direction, widthSize) {
|
|
2343
|
+
return this.computeFlexEndPadding(axis, direction, widthSize) + this.computeFlexEndBorder(axis, direction);
|
|
2344
|
+
}
|
|
2345
|
+
computePaddingAndBorderForDimension(direction, dimension, widthSize) {
|
|
2346
|
+
const flexDirectionForDimension = dimension === Dimension.Width ? FlexDirection.Row : FlexDirection.Column;
|
|
2347
|
+
return this.computeFlexStartPaddingAndBorder(flexDirectionForDimension, direction, widthSize) + this.computeFlexEndPaddingAndBorder(flexDirectionForDimension, direction, widthSize);
|
|
2348
|
+
}
|
|
2349
|
+
computeBorderForAxis(axis) {
|
|
2350
|
+
const resolved = this.resolvedBorder();
|
|
2351
|
+
if (resolved === null) return 0;
|
|
2352
|
+
const startEdge = isRow(axis) ? PhysicalEdge.Left : PhysicalEdge.Top;
|
|
2353
|
+
return edgeValueFloored(resolved, Direction.LTR * 4 + startEdge, 0) + edgeValueFloored(resolved, Direction.LTR * 4 + startEdge + 2, 0);
|
|
2354
|
+
}
|
|
2355
|
+
computeMarginForAxis(axis, widthSize) {
|
|
2356
|
+
const resolved = this.resolvedMargin();
|
|
2357
|
+
if (resolved === null) return 0;
|
|
2358
|
+
const startEdge = isRow(axis) ? PhysicalEdge.Left : PhysicalEdge.Top;
|
|
2359
|
+
return edgeValueOrZero(resolved, Direction.LTR * 4 + startEdge, widthSize) + edgeValueOrZero(resolved, Direction.LTR * 4 + startEdge + 2, widthSize);
|
|
2360
|
+
}
|
|
2361
|
+
computeGapForAxis(axis, ownerSize) {
|
|
2362
|
+
if (this.gap_ === null) return 0;
|
|
2363
|
+
return maxOrDefined((isRow(axis) ? this.computeColumnGap() : this.computeRowGap()).resolve(ownerSize), 0);
|
|
2364
|
+
}
|
|
2365
|
+
computeGapForDimension(dimension, ownerSize) {
|
|
2366
|
+
if (this.gap_ === null) return 0;
|
|
2367
|
+
return maxOrDefined((dimension === Dimension.Width ? this.computeColumnGap() : this.computeRowGap()).resolve(ownerSize), 0);
|
|
2368
|
+
}
|
|
2369
|
+
flexStartMarginIsAuto(axis, direction) {
|
|
2370
|
+
if (this.margin_ === null) return false;
|
|
2371
|
+
return this.computeMargin(flexStartEdge(axis), direction).isAuto();
|
|
2372
|
+
}
|
|
2373
|
+
flexEndMarginIsAuto(axis, direction) {
|
|
2374
|
+
if (this.margin_ === null) return false;
|
|
2375
|
+
return this.computeMargin(flexEndEdge(axis), direction).isAuto();
|
|
2376
|
+
}
|
|
2377
|
+
inlineStartMarginIsAuto(axis, direction) {
|
|
2378
|
+
if (this.margin_ === null) return false;
|
|
2379
|
+
return this.computeMargin(inlineStartEdge(axis, direction), direction).isAuto();
|
|
2380
|
+
}
|
|
2381
|
+
inlineEndMarginIsAuto(axis, direction) {
|
|
2382
|
+
if (this.margin_ === null) return false;
|
|
2383
|
+
return this.computeMargin(inlineEndEdge(axis, direction), direction).isAuto();
|
|
2384
|
+
}
|
|
2385
|
+
equals(other) {
|
|
2386
|
+
const lengthsEqual = (a, b, count) => {
|
|
2387
|
+
if (a === b) return true;
|
|
2388
|
+
for (let i = 0; i < count; i++) {
|
|
2389
|
+
const left = a !== null ? a[i] : StyleLength.undefined();
|
|
2390
|
+
const right = b !== null ? b[i] : StyleLength.undefined();
|
|
2391
|
+
if (!left.equals(right)) return false;
|
|
2392
|
+
}
|
|
2393
|
+
return true;
|
|
2394
|
+
};
|
|
2395
|
+
const numbersEqual = (a, b) => a === b || Number.isNaN(a) && Number.isNaN(b);
|
|
2396
|
+
return this.direction_ === other.direction_ && this.flexDirection_ === other.flexDirection_ && this.justifyContent_ === other.justifyContent_ && this.justifyItems_ === other.justifyItems_ && this.justifySelf_ === other.justifySelf_ && this.alignContent_ === other.alignContent_ && this.alignItems_ === other.alignItems_ && this.alignSelf_ === other.alignSelf_ && this.positionType_ === other.positionType_ && this.flexWrap_ === other.flexWrap_ && this.overflow_ === other.overflow_ && this.display_ === other.display_ && this.boxSizing_ === other.boxSizing_ && numbersEqual(this.flex_, other.flex_) && numbersEqual(this.flexGrow_, other.flexGrow_) && numbersEqual(this.flexShrink_, other.flexShrink_) && this.flexBasis_.equals(other.flexBasis_) && lengthsEqual(this.margin_, other.margin_, EDGE_COUNT) && lengthsEqual(this.position_, other.position_, EDGE_COUNT) && lengthsEqual(this.padding_, other.padding_, EDGE_COUNT) && lengthsEqual(this.border_, other.border_, EDGE_COUNT) && lengthsEqual(this.gap_, other.gap_, GUTTER_COUNT) && this.dimensions_.every((value, i) => value.equals(other.dimensions_[i])) && numbersEqual(this.aspectRatio_, other.aspectRatio_);
|
|
2397
|
+
}
|
|
2398
|
+
copyFrom(other) {
|
|
2399
|
+
this.direction_ = other.direction_;
|
|
2400
|
+
this.flexDirection_ = other.flexDirection_;
|
|
2401
|
+
this.justifyContent_ = other.justifyContent_;
|
|
2402
|
+
this.justifyItems_ = other.justifyItems_;
|
|
2403
|
+
this.justifySelf_ = other.justifySelf_;
|
|
2404
|
+
this.alignContent_ = other.alignContent_;
|
|
2405
|
+
this.alignItems_ = other.alignItems_;
|
|
2406
|
+
this.alignSelf_ = other.alignSelf_;
|
|
2407
|
+
this.positionType_ = other.positionType_;
|
|
2408
|
+
this.flexWrap_ = other.flexWrap_;
|
|
2409
|
+
this.overflow_ = other.overflow_;
|
|
2410
|
+
this.display_ = other.display_;
|
|
2411
|
+
this.boxSizing_ = other.boxSizing_;
|
|
2412
|
+
this.flex_ = other.flex_;
|
|
2413
|
+
this.flexGrow_ = other.flexGrow_;
|
|
2414
|
+
this.flexShrink_ = other.flexShrink_;
|
|
2415
|
+
this.flexBasis_ = other.flexBasis_;
|
|
2416
|
+
this.margin_ = other.margin_ !== null ? other.margin_.slice() : null;
|
|
2417
|
+
this.position_ = other.position_ !== null ? other.position_.slice() : null;
|
|
2418
|
+
this.padding_ = other.padding_ !== null ? other.padding_.slice() : null;
|
|
2419
|
+
this.border_ = other.border_ !== null ? other.border_.slice() : null;
|
|
2420
|
+
this.gap_ = other.gap_ !== null ? other.gap_.slice() : null;
|
|
2421
|
+
this.marginResolved_ = null;
|
|
2422
|
+
this.positionResolved_ = null;
|
|
2423
|
+
this.paddingResolved_ = null;
|
|
2424
|
+
this.borderResolved_ = null;
|
|
2425
|
+
this.dimensions_ = other.dimensions_.slice();
|
|
2426
|
+
this.aspectRatio_ = other.aspectRatio_;
|
|
2427
|
+
}
|
|
2428
|
+
computeColumnGap() {
|
|
2429
|
+
const gap = this.gap_;
|
|
2430
|
+
if (gap === null) return StyleLength.undefined();
|
|
2431
|
+
return gap[Gutter.Column].isDefined() ? gap[Gutter.Column] : gap[Gutter.All];
|
|
2432
|
+
}
|
|
2433
|
+
computeRowGap() {
|
|
2434
|
+
const gap = this.gap_;
|
|
2435
|
+
if (gap === null) return StyleLength.undefined();
|
|
2436
|
+
return gap[Gutter.Row].isDefined() ? gap[Gutter.Row] : gap[Gutter.All];
|
|
2437
|
+
}
|
|
2438
|
+
computeLeftEdge(edges, layoutDirection) {
|
|
2439
|
+
if (layoutDirection === Direction.LTR && edges[Edge.Start].isDefined()) return edges[Edge.Start];
|
|
2440
|
+
else if (layoutDirection === Direction.RTL && edges[Edge.End].isDefined()) return edges[Edge.End];
|
|
2441
|
+
else if (edges[Edge.Left].isDefined()) return edges[Edge.Left];
|
|
2442
|
+
else if (edges[Edge.Horizontal].isDefined()) return edges[Edge.Horizontal];
|
|
2443
|
+
else return edges[Edge.All];
|
|
2444
|
+
}
|
|
2445
|
+
computeTopEdge(edges) {
|
|
2446
|
+
if (edges[Edge.Top].isDefined()) return edges[Edge.Top];
|
|
2447
|
+
else if (edges[Edge.Vertical].isDefined()) return edges[Edge.Vertical];
|
|
2448
|
+
else return edges[Edge.All];
|
|
2449
|
+
}
|
|
2450
|
+
computeRightEdge(edges, layoutDirection) {
|
|
2451
|
+
if (layoutDirection === Direction.LTR && edges[Edge.End].isDefined()) return edges[Edge.End];
|
|
2452
|
+
else if (layoutDirection === Direction.RTL && edges[Edge.Start].isDefined()) return edges[Edge.Start];
|
|
2453
|
+
else if (edges[Edge.Right].isDefined()) return edges[Edge.Right];
|
|
2454
|
+
else if (edges[Edge.Horizontal].isDefined()) return edges[Edge.Horizontal];
|
|
2455
|
+
else return edges[Edge.All];
|
|
2456
|
+
}
|
|
2457
|
+
computeBottomEdge(edges) {
|
|
2458
|
+
if (edges[Edge.Bottom].isDefined()) return edges[Edge.Bottom];
|
|
2459
|
+
else if (edges[Edge.Vertical].isDefined()) return edges[Edge.Vertical];
|
|
2460
|
+
else return edges[Edge.All];
|
|
2461
|
+
}
|
|
2462
|
+
buildResolvedEdges(edges) {
|
|
2463
|
+
const lengths = Array.from({ length: 12 });
|
|
2464
|
+
const units = /* @__PURE__ */ new Uint8Array(12);
|
|
2465
|
+
const values = Array.from({ length: 12 });
|
|
2466
|
+
for (const direction of [
|
|
2467
|
+
Direction.Inherit,
|
|
2468
|
+
Direction.LTR,
|
|
2469
|
+
Direction.RTL
|
|
2470
|
+
]) {
|
|
2471
|
+
lengths[direction * 4 + PhysicalEdge.Left] = this.computeLeftEdge(edges, direction);
|
|
2472
|
+
lengths[direction * 4 + PhysicalEdge.Top] = this.computeTopEdge(edges);
|
|
2473
|
+
lengths[direction * 4 + PhysicalEdge.Right] = this.computeRightEdge(edges, direction);
|
|
2474
|
+
lengths[direction * 4 + PhysicalEdge.Bottom] = this.computeBottomEdge(edges);
|
|
2475
|
+
}
|
|
2476
|
+
for (let i = 0; i < 12; i++) {
|
|
2477
|
+
units[i] = lengths[i].unit;
|
|
2478
|
+
values[i] = lengths[i].value;
|
|
2479
|
+
}
|
|
2480
|
+
return {
|
|
2481
|
+
lengths,
|
|
2482
|
+
units,
|
|
2483
|
+
values
|
|
2484
|
+
};
|
|
2485
|
+
}
|
|
2486
|
+
resolvedPosition() {
|
|
2487
|
+
return this.position_ === null ? null : this.positionResolved_ ??= this.buildResolvedEdges(this.position_);
|
|
2488
|
+
}
|
|
2489
|
+
resolvedMargin() {
|
|
2490
|
+
return this.margin_ === null ? null : this.marginResolved_ ??= this.buildResolvedEdges(this.margin_);
|
|
2491
|
+
}
|
|
2492
|
+
resolvedPadding() {
|
|
2493
|
+
return this.padding_ === null ? null : this.paddingResolved_ ??= this.buildResolvedEdges(this.padding_);
|
|
2494
|
+
}
|
|
2495
|
+
resolvedBorder() {
|
|
2496
|
+
return this.border_ === null ? null : this.borderResolved_ ??= this.buildResolvedEdges(this.border_);
|
|
2497
|
+
}
|
|
2498
|
+
computePosition(edge, direction) {
|
|
2499
|
+
const resolved = this.resolvedPosition();
|
|
2500
|
+
return resolved === null ? StyleLength.undefined() : resolved.lengths[direction * 4 + edge];
|
|
2501
|
+
}
|
|
2502
|
+
computeMargin(edge, direction) {
|
|
2503
|
+
const resolved = this.resolvedMargin();
|
|
2504
|
+
return resolved === null ? StyleLength.undefined() : resolved.lengths[direction * 4 + edge];
|
|
2505
|
+
}
|
|
2506
|
+
computePadding(edge, direction) {
|
|
2507
|
+
const resolved = this.resolvedPadding();
|
|
2508
|
+
return resolved === null ? StyleLength.undefined() : resolved.lengths[direction * 4 + edge];
|
|
2509
|
+
}
|
|
2510
|
+
computeBorder(edge, direction) {
|
|
2511
|
+
const resolved = this.resolvedBorder();
|
|
2512
|
+
return resolved === null ? StyleLength.undefined() : resolved.lengths[direction * 4 + edge];
|
|
2513
|
+
}
|
|
2514
|
+
};
|
|
2515
|
+
function edgeValueOrZero(resolved, index, referenceLength) {
|
|
2516
|
+
if (resolved === null) return 0;
|
|
2517
|
+
const unit = resolved.units[index];
|
|
2518
|
+
if (unit === Unit.Point) return resolved.values[index];
|
|
2519
|
+
if (unit === Unit.Percent) {
|
|
2520
|
+
const value = resolved.values[index] * referenceLength * .01;
|
|
2521
|
+
return Number.isNaN(value) ? 0 : value;
|
|
2522
|
+
}
|
|
2523
|
+
return 0;
|
|
2524
|
+
}
|
|
2525
|
+
function edgeValueFloored(resolved, index, referenceLength) {
|
|
2526
|
+
if (resolved === null) return 0;
|
|
2527
|
+
const unit = resolved.units[index];
|
|
2528
|
+
if (unit === Unit.Point) {
|
|
2529
|
+
const value = resolved.values[index];
|
|
2530
|
+
return value > 0 ? value : 0;
|
|
2531
|
+
}
|
|
2532
|
+
if (unit === Unit.Percent) {
|
|
2533
|
+
const value = resolved.values[index] * referenceLength * .01;
|
|
2534
|
+
return value > 0 ? value : 0;
|
|
2535
|
+
}
|
|
2536
|
+
return 0;
|
|
2537
|
+
}
|
|
2538
|
+
//#endregion
|
|
2539
|
+
//#region src/yoga/core/node.ts
|
|
2540
|
+
var Node$1 = class Node$1 {
|
|
2541
|
+
hasNewLayout_ = true;
|
|
2542
|
+
isReferenceBaseline_ = false;
|
|
2543
|
+
isDirty_ = true;
|
|
2544
|
+
alwaysFormsContainingBlock = false;
|
|
2545
|
+
nodeType = NodeType.Default;
|
|
2546
|
+
measureFunc_ = null;
|
|
2547
|
+
measureResult_ = null;
|
|
2548
|
+
baselineFunc_ = null;
|
|
2549
|
+
dirtiedFunc_ = null;
|
|
2550
|
+
style = new Style();
|
|
2551
|
+
layout = new LayoutResults();
|
|
2552
|
+
lineIndex = 0;
|
|
2553
|
+
contentsChildrenCount_ = 0;
|
|
2554
|
+
owner = null;
|
|
2555
|
+
children = [];
|
|
2556
|
+
config;
|
|
2557
|
+
processedDimensionWidth_ = StyleSizeLength.undefined();
|
|
2558
|
+
processedDimensionHeight_ = StyleSizeLength.undefined();
|
|
2559
|
+
dimensionsDirty_ = true;
|
|
2560
|
+
constructor(config = getDefaultConfig()) {
|
|
2561
|
+
this.config = config;
|
|
2562
|
+
if (config.useWebDefaults()) {
|
|
2563
|
+
this.style.setFlexDirection(FlexDirection.Row);
|
|
2564
|
+
this.style.setAlignContent(Align.Stretch);
|
|
2565
|
+
}
|
|
2566
|
+
}
|
|
2567
|
+
hasMeasureFunc() {
|
|
2568
|
+
return this.measureFunc_ !== null;
|
|
2569
|
+
}
|
|
2570
|
+
measure(availableWidth, widthMode, availableHeight, heightMode) {
|
|
2571
|
+
const size = this.measureFunc_(availableWidth, widthMode, availableHeight, heightMode);
|
|
2572
|
+
const width = size.width === void 0 || size.width === null ? NaN : size.width;
|
|
2573
|
+
const height = size.height === void 0 || size.height === null ? NaN : size.height;
|
|
2574
|
+
const result = this.measureResult_ ??= {
|
|
2575
|
+
width: 0,
|
|
2576
|
+
height: 0
|
|
2577
|
+
};
|
|
2578
|
+
if (isUndefined(height) || height < 0 || isUndefined(width) || width < 0) {
|
|
2579
|
+
result.width = maxOrDefined(0, width);
|
|
2580
|
+
result.height = maxOrDefined(0, height);
|
|
2581
|
+
} else {
|
|
2582
|
+
result.width = width;
|
|
2583
|
+
result.height = height;
|
|
2584
|
+
}
|
|
2585
|
+
return result;
|
|
2586
|
+
}
|
|
2587
|
+
hasBaselineFunc() {
|
|
2588
|
+
return this.baselineFunc_ !== null;
|
|
2589
|
+
}
|
|
2590
|
+
baseline(width, height) {
|
|
2591
|
+
return this.baselineFunc_(width, height);
|
|
2592
|
+
}
|
|
2593
|
+
getDirtiedFunc() {
|
|
2594
|
+
return this.dirtiedFunc_;
|
|
2595
|
+
}
|
|
2596
|
+
dimensionWithMargin(axis, widthSize) {
|
|
2597
|
+
return this.layout.measuredDimension(dimension(axis)) + this.style.computeMarginForAxis(axis, widthSize);
|
|
2598
|
+
}
|
|
2599
|
+
isLayoutDimensionDefined(axis) {
|
|
2600
|
+
const value = this.layout.measuredDimension(dimension(axis));
|
|
2601
|
+
return isDefined(value) && value >= 0;
|
|
2602
|
+
}
|
|
2603
|
+
/**
|
|
2604
|
+
* Whether the node has a "definite length" along the given axis.
|
|
2605
|
+
* https://www.w3.org/TR/css-sizing-3/#definite
|
|
2606
|
+
*/
|
|
2607
|
+
hasDefiniteLength(dim, ownerSize) {
|
|
2608
|
+
const usedValue = this.getProcessedDimension(dim).resolve(ownerSize);
|
|
2609
|
+
return isDefined(usedValue) && usedValue >= 0;
|
|
2610
|
+
}
|
|
2611
|
+
hasErrata(errata) {
|
|
2612
|
+
return this.config.hasErrata(errata);
|
|
2613
|
+
}
|
|
2614
|
+
hasContentsChildren() {
|
|
2615
|
+
return this.contentsChildrenCount_ !== 0;
|
|
2616
|
+
}
|
|
2617
|
+
getChildCount() {
|
|
2618
|
+
return this.children.length;
|
|
2619
|
+
}
|
|
2620
|
+
getChild(index) {
|
|
2621
|
+
return this.children[index];
|
|
2622
|
+
}
|
|
2623
|
+
/**
|
|
2624
|
+
* Children for layout purposes: skips display: contents nodes, splicing
|
|
2625
|
+
* their children in place. Returns the raw children array when nothing
|
|
2626
|
+
* needs splicing — do not mutate the result.
|
|
2627
|
+
*/
|
|
2628
|
+
getLayoutChildren() {
|
|
2629
|
+
if (this.contentsChildrenCount_ === 0) return this.children;
|
|
2630
|
+
const result = [];
|
|
2631
|
+
appendLayoutChildren(this, result);
|
|
2632
|
+
return result;
|
|
2633
|
+
}
|
|
2634
|
+
getLayoutChildCount() {
|
|
2635
|
+
if (this.contentsChildrenCount_ === 0) return this.children.length;
|
|
2636
|
+
return this.getLayoutChildren().length;
|
|
2637
|
+
}
|
|
2638
|
+
isDirty() {
|
|
2639
|
+
return this.isDirty_;
|
|
2640
|
+
}
|
|
2641
|
+
getProcessedDimension(dim) {
|
|
2642
|
+
return dim === Dimension.Width ? this.processedDimensionWidth_ : this.processedDimensionHeight_;
|
|
2643
|
+
}
|
|
2644
|
+
getResolvedDimension(direction, dim, referenceLength, ownerWidth) {
|
|
2645
|
+
const value = this.getProcessedDimension(dim).resolve(referenceLength);
|
|
2646
|
+
if (this.style.boxSizing() === BoxSizing.BorderBox) return value;
|
|
2647
|
+
const dimensionPaddingAndBorder = this.style.computePaddingAndBorderForDimension(direction, dim, ownerWidth);
|
|
2648
|
+
return value + (isDefined(dimensionPaddingAndBorder) ? dimensionPaddingAndBorder : 0);
|
|
2649
|
+
}
|
|
2650
|
+
setMeasureFunc(measureFunc) {
|
|
2651
|
+
if (measureFunc === null) this.nodeType = NodeType.Default;
|
|
2652
|
+
else {
|
|
2653
|
+
if (this.children.length !== 0) throw new Error("Cannot set measure function: Nodes with measure functions cannot have children.");
|
|
2654
|
+
this.nodeType = NodeType.Text;
|
|
2655
|
+
}
|
|
2656
|
+
this.measureFunc_ = measureFunc;
|
|
2657
|
+
this.markLayoutWritten();
|
|
2658
|
+
}
|
|
2659
|
+
setBaselineFunc(baselineFunc) {
|
|
2660
|
+
this.baselineFunc_ = baselineFunc;
|
|
2661
|
+
}
|
|
2662
|
+
setCoreDirtiedFunc(dirtiedFunc) {
|
|
2663
|
+
this.dirtiedFunc_ = dirtiedFunc;
|
|
2664
|
+
}
|
|
2665
|
+
insertChild(child, index) {
|
|
2666
|
+
if (child.style.display() === Display.Contents) this.contentsChildrenCount_++;
|
|
2667
|
+
if (index === this.children.length) this.children.push(child);
|
|
2668
|
+
else this.children.splice(index, 0, child);
|
|
2669
|
+
}
|
|
2670
|
+
setConfig(config) {
|
|
2671
|
+
if (config.useWebDefaults() !== this.config.useWebDefaults()) throw new Error("UseWebDefaults may not be changed after constructing a Node");
|
|
2672
|
+
if (configUpdateInvalidatesLayout(this.config, config)) {
|
|
2673
|
+
this.markDirtyAndPropagate();
|
|
2674
|
+
this.layout.configVersion = 0;
|
|
2675
|
+
} else this.layout.configVersion = config.getVersion();
|
|
2676
|
+
this.config = config;
|
|
2677
|
+
}
|
|
2678
|
+
setDirty(isDirty) {
|
|
2679
|
+
if (isDirty === this.isDirty_) return;
|
|
2680
|
+
this.isDirty_ = isDirty;
|
|
2681
|
+
if (isDirty && this.dirtiedFunc_ !== null) this.dirtiedFunc_();
|
|
2682
|
+
}
|
|
2683
|
+
setChildren(children) {
|
|
2684
|
+
this.children = children.slice();
|
|
2685
|
+
this.contentsChildrenCount_ = 0;
|
|
2686
|
+
for (const child of children) if (child.style.display() === Display.Contents) this.contentsChildrenCount_++;
|
|
2687
|
+
}
|
|
2688
|
+
removeChild(child) {
|
|
2689
|
+
const index = this.children.indexOf(child);
|
|
2690
|
+
if (index >= 0) {
|
|
2691
|
+
if (child.style.display() === Display.Contents) this.contentsChildrenCount_--;
|
|
2692
|
+
this.children.splice(index, 1);
|
|
2693
|
+
return true;
|
|
2694
|
+
}
|
|
2695
|
+
return false;
|
|
2696
|
+
}
|
|
2697
|
+
removeChildAtIndex(index) {
|
|
2698
|
+
if (this.children[index].style.display() === Display.Contents) this.contentsChildrenCount_--;
|
|
2699
|
+
this.children.splice(index, 1);
|
|
2700
|
+
}
|
|
2701
|
+
clearChildren() {
|
|
2702
|
+
this.children = [];
|
|
2703
|
+
}
|
|
2704
|
+
syncContentsChildrenCount() {
|
|
2705
|
+
this.contentsChildrenCount_ = 0;
|
|
2706
|
+
for (const child of this.children) if (child.style.display() === Display.Contents) this.contentsChildrenCount_++;
|
|
2707
|
+
}
|
|
2708
|
+
setLayoutDirection(direction) {
|
|
2709
|
+
this.layout.setDirection(direction);
|
|
2710
|
+
}
|
|
2711
|
+
setLayoutMargin(margin, edge) {
|
|
2712
|
+
this.layout.setMargin(edge, margin);
|
|
2713
|
+
}
|
|
2714
|
+
setLayoutBorder(border, edge) {
|
|
2715
|
+
this.layout.setBorder(edge, border);
|
|
2716
|
+
}
|
|
2717
|
+
setLayoutPadding(padding, edge) {
|
|
2718
|
+
this.layout.setPadding(edge, padding);
|
|
2719
|
+
}
|
|
2720
|
+
setLayoutLastOwnerDirection(direction) {
|
|
2721
|
+
this.layout.lastOwnerDirection = direction;
|
|
2722
|
+
}
|
|
2723
|
+
setLayoutComputedFlexBasis(computedFlexBasis) {
|
|
2724
|
+
this.layout.computedFlexBasis = computedFlexBasis;
|
|
2725
|
+
}
|
|
2726
|
+
markLayoutWritten() {
|
|
2727
|
+
if (this.layout.roundingDirty) return;
|
|
2728
|
+
this.layout.roundingDirty = true;
|
|
2729
|
+
let node = this.owner;
|
|
2730
|
+
while (node !== null && !node.layout.roundingDirty) {
|
|
2731
|
+
node.layout.roundingDirty = true;
|
|
2732
|
+
node = node.owner;
|
|
2733
|
+
}
|
|
2734
|
+
}
|
|
2735
|
+
setLayoutPosition(position, edge) {
|
|
2736
|
+
const value = position;
|
|
2737
|
+
if (!Object.is(this.layout.position(edge), value)) {
|
|
2738
|
+
this.layout.setPosition(edge, value);
|
|
2739
|
+
this.markLayoutWritten();
|
|
2740
|
+
}
|
|
2741
|
+
}
|
|
2742
|
+
setLayoutComputedFlexBasisGeneration(computedFlexBasisGeneration) {
|
|
2743
|
+
this.layout.computedFlexBasisGeneration = computedFlexBasisGeneration;
|
|
2744
|
+
}
|
|
2745
|
+
setLayoutMeasuredDimension(measuredDimension, dim) {
|
|
2746
|
+
this.layout.setMeasuredDimension(dim, measuredDimension);
|
|
2747
|
+
}
|
|
2748
|
+
setLayoutHadOverflow(hadOverflow) {
|
|
2749
|
+
this.layout.setHadOverflow(hadOverflow);
|
|
2750
|
+
}
|
|
2751
|
+
setLayoutDimension(lengthValue, dim) {
|
|
2752
|
+
const value = lengthValue;
|
|
2753
|
+
if (!Object.is(this.layout.dimension(dim), value) || !Object.is(this.layout.rawDimension(dim), value)) {
|
|
2754
|
+
this.layout.setDimension(dim, value);
|
|
2755
|
+
this.layout.setRawDimension(dim, value);
|
|
2756
|
+
this.markLayoutWritten();
|
|
2757
|
+
}
|
|
2758
|
+
}
|
|
2759
|
+
relativePosition(axis, direction, axisSize) {
|
|
2760
|
+
if (this.style.positionType() === PositionType.Static) return 0;
|
|
2761
|
+
if (this.style.isInlineStartPositionDefined(axis, direction) && !this.style.isInlineStartPositionAuto(axis, direction)) return this.style.computeInlineStartPosition(axis, direction, axisSize);
|
|
2762
|
+
return -1 * this.style.computeInlineEndPosition(axis, direction, axisSize);
|
|
2763
|
+
}
|
|
2764
|
+
setPositionFromStyle(direction, ownerWidth, ownerHeight) {
|
|
2765
|
+
if (!this.style.hasPositionOrMargin()) {
|
|
2766
|
+
this.setLayoutPosition(0, PhysicalEdge.Left);
|
|
2767
|
+
this.setLayoutPosition(0, PhysicalEdge.Top);
|
|
2768
|
+
this.setLayoutPosition(0, PhysicalEdge.Right);
|
|
2769
|
+
this.setLayoutPosition(0, PhysicalEdge.Bottom);
|
|
2770
|
+
return;
|
|
2771
|
+
}
|
|
2772
|
+
const directionRespectingRoot = this.owner !== null ? direction : Direction.LTR;
|
|
2773
|
+
const mainAxis = resolveDirection(this.style.flexDirection(), directionRespectingRoot);
|
|
2774
|
+
const crossAxis = resolveCrossDirection(mainAxis, directionRespectingRoot);
|
|
2775
|
+
const relativePositionMain = this.relativePosition(mainAxis, directionRespectingRoot, isRow(mainAxis) ? ownerWidth : ownerHeight);
|
|
2776
|
+
const relativePositionCross = this.relativePosition(crossAxis, directionRespectingRoot, isRow(mainAxis) ? ownerHeight : ownerWidth);
|
|
2777
|
+
const mainAxisLeadingEdge = inlineStartEdge(mainAxis, direction);
|
|
2778
|
+
const mainAxisTrailingEdge = inlineEndEdge(mainAxis, direction);
|
|
2779
|
+
const crossAxisLeadingEdge = inlineStartEdge(crossAxis, direction);
|
|
2780
|
+
const crossAxisTrailingEdge = inlineEndEdge(crossAxis, direction);
|
|
2781
|
+
this.setLayoutPosition(this.style.computeInlineStartMargin(mainAxis, direction, ownerWidth) + relativePositionMain, mainAxisLeadingEdge);
|
|
2782
|
+
this.setLayoutPosition(this.style.computeInlineEndMargin(mainAxis, direction, ownerWidth) + relativePositionMain, mainAxisTrailingEdge);
|
|
2783
|
+
this.setLayoutPosition(this.style.computeInlineStartMargin(crossAxis, direction, ownerWidth) + relativePositionCross, crossAxisLeadingEdge);
|
|
2784
|
+
this.setLayoutPosition(this.style.computeInlineEndMargin(crossAxis, direction, ownerWidth) + relativePositionCross, crossAxisTrailingEdge);
|
|
2785
|
+
}
|
|
2786
|
+
processFlexBasis() {
|
|
2787
|
+
const flexBasis = this.style.flexBasis();
|
|
2788
|
+
if (!flexBasis.isAuto() && !flexBasis.isUndefined()) return flexBasis;
|
|
2789
|
+
if (isDefined(this.style.flex()) && this.style.flex() > 0) return this.config.useWebDefaults() ? StyleSizeLength.ofAuto() : StyleSizeLength.points(0);
|
|
2790
|
+
return StyleSizeLength.ofAuto();
|
|
2791
|
+
}
|
|
2792
|
+
resolveFlexBasis(direction, flexDirection, referenceLength, ownerWidth) {
|
|
2793
|
+
const value = this.processFlexBasis().resolve(referenceLength);
|
|
2794
|
+
if (this.style.boxSizing() === BoxSizing.BorderBox) return value;
|
|
2795
|
+
const dim = dimension(flexDirection);
|
|
2796
|
+
const dimensionPaddingAndBorder = this.style.computePaddingAndBorderForDimension(direction, dim, ownerWidth);
|
|
2797
|
+
return value + (isDefined(dimensionPaddingAndBorder) ? dimensionPaddingAndBorder : 0);
|
|
2798
|
+
}
|
|
2799
|
+
processDimensions() {
|
|
2800
|
+
if (!this.dimensionsDirty_) return;
|
|
2801
|
+
for (let dim = Dimension.Width; dim <= Dimension.Height; dim++) {
|
|
2802
|
+
const maxDimension = this.style.maxDimension(dim);
|
|
2803
|
+
const processed = maxDimension.isDefined() && maxDimension.inexactEquals(this.style.minDimension(dim)) ? maxDimension : this.style.dimension(dim);
|
|
2804
|
+
if (dim === Dimension.Width) this.processedDimensionWidth_ = processed;
|
|
2805
|
+
else this.processedDimensionHeight_ = processed;
|
|
2806
|
+
}
|
|
2807
|
+
this.dimensionsDirty_ = false;
|
|
2808
|
+
}
|
|
2809
|
+
invalidateProcessedDimensions() {
|
|
2810
|
+
this.dimensionsDirty_ = true;
|
|
2811
|
+
}
|
|
2812
|
+
resolveDirection(ownerDirection) {
|
|
2813
|
+
if (this.style.direction() === Direction.Inherit) return ownerDirection !== Direction.Inherit ? ownerDirection : Direction.LTR;
|
|
2814
|
+
else return this.style.direction();
|
|
2815
|
+
}
|
|
2816
|
+
cloneChildrenIfNeeded() {}
|
|
2817
|
+
cloneContentsChildrenIfNeeded() {}
|
|
2818
|
+
markDirtyAndPropagate() {
|
|
2819
|
+
if (!this.isDirty_) {
|
|
2820
|
+
this.setDirty(true);
|
|
2821
|
+
this.setLayoutComputedFlexBasis(NaN);
|
|
2822
|
+
if (this.owner !== null) this.owner.markDirtyAndPropagate();
|
|
2823
|
+
}
|
|
2824
|
+
}
|
|
2825
|
+
resolveFlexGrow() {
|
|
2826
|
+
if (this.owner === null) return 0;
|
|
2827
|
+
if (isDefined(this.style.flexGrow())) return this.style.flexGrow();
|
|
2828
|
+
if (isDefined(this.style.flex()) && this.style.flex() > 0) return this.style.flex();
|
|
2829
|
+
return Style.DefaultFlexGrow;
|
|
2830
|
+
}
|
|
2831
|
+
resolveFlexShrink() {
|
|
2832
|
+
if (this.owner === null) return 0;
|
|
2833
|
+
if (isDefined(this.style.flexShrink())) return this.style.flexShrink();
|
|
2834
|
+
if (!this.config.useWebDefaults() && isDefined(this.style.flex()) && this.style.flex() < 0) return -this.style.flex();
|
|
2835
|
+
return this.config.useWebDefaults() ? Style.WebDefaultFlexShrink : Style.DefaultFlexShrink;
|
|
2836
|
+
}
|
|
2837
|
+
isNodeFlexible() {
|
|
2838
|
+
return this.style.positionType() !== PositionType.Absolute && (this.resolveFlexGrow() !== 0 || this.resolveFlexShrink() !== 0);
|
|
2839
|
+
}
|
|
2840
|
+
reset() {
|
|
2841
|
+
if (this.children.length !== 0) throw new Error("Cannot reset a node which still has children attached");
|
|
2842
|
+
if (this.owner !== null) throw new Error("Cannot reset a node still attached to a owner");
|
|
2843
|
+
const fresh = new Node$1(this.config);
|
|
2844
|
+
this.hasNewLayout_ = fresh.hasNewLayout_;
|
|
2845
|
+
this.isReferenceBaseline_ = fresh.isReferenceBaseline_;
|
|
2846
|
+
this.isDirty_ = true;
|
|
2847
|
+
this.alwaysFormsContainingBlock = fresh.alwaysFormsContainingBlock;
|
|
2848
|
+
this.nodeType = fresh.nodeType;
|
|
2849
|
+
this.measureFunc_ = null;
|
|
2850
|
+
this.measureResult_ = null;
|
|
2851
|
+
this.baselineFunc_ = null;
|
|
2852
|
+
this.dirtiedFunc_ = null;
|
|
2853
|
+
this.style = fresh.style;
|
|
2854
|
+
this.layout = fresh.layout;
|
|
2855
|
+
this.lineIndex = 0;
|
|
2856
|
+
this.contentsChildrenCount_ = 0;
|
|
2857
|
+
this.children = [];
|
|
2858
|
+
this.processedDimensionWidth_ = StyleSizeLength.undefined();
|
|
2859
|
+
this.processedDimensionHeight_ = StyleSizeLength.undefined();
|
|
2860
|
+
this.dimensionsDirty_ = true;
|
|
2861
|
+
}
|
|
2862
|
+
};
|
|
2863
|
+
function appendLayoutChildren(node, out) {
|
|
2864
|
+
for (const child of node.children) if (child.style.display() === Display.Contents) appendLayoutChildren(child, out);
|
|
2865
|
+
else out.push(child);
|
|
2866
|
+
}
|
|
2867
|
+
//#endregion
|
|
2868
|
+
//#region src/yoga/node.ts
|
|
2869
|
+
function styleValue(length) {
|
|
2870
|
+
return {
|
|
2871
|
+
value: length.value,
|
|
2872
|
+
unit: length.unit
|
|
2873
|
+
};
|
|
2874
|
+
}
|
|
2875
|
+
function dispatchSetter(self, fnName, pointFn, args) {
|
|
2876
|
+
const value = args.pop();
|
|
2877
|
+
let unit;
|
|
2878
|
+
let asNumber;
|
|
2879
|
+
if (value === "auto") {
|
|
2880
|
+
unit = Unit.Auto;
|
|
2881
|
+
asNumber = void 0;
|
|
2882
|
+
} else if (value === "max-content") {
|
|
2883
|
+
unit = Unit.MaxContent;
|
|
2884
|
+
asNumber = void 0;
|
|
2885
|
+
} else if (value === "fit-content") {
|
|
2886
|
+
unit = Unit.FitContent;
|
|
2887
|
+
asNumber = void 0;
|
|
2888
|
+
} else if (value === "stretch") {
|
|
2889
|
+
unit = Unit.Stretch;
|
|
2890
|
+
asNumber = void 0;
|
|
2891
|
+
} else if (typeof value === "object" && value !== null) {
|
|
2892
|
+
unit = value.unit;
|
|
2893
|
+
asNumber = value.valueOf();
|
|
2894
|
+
} else {
|
|
2895
|
+
unit = typeof value === "string" && value.endsWith("%") ? Unit.Percent : Unit.Point;
|
|
2896
|
+
asNumber = parseFloat(value);
|
|
2897
|
+
if (value !== void 0 && !Number.isNaN(value) && Number.isNaN(asNumber)) throw new Error(`Invalid value ${JSON.stringify(value) ?? "undefined"} for ${fnName}`);
|
|
2898
|
+
}
|
|
2899
|
+
if (unit === Unit.Point) return pointFn.call(self, ...args, asNumber);
|
|
2900
|
+
const suffix = {
|
|
2901
|
+
[Unit.Percent]: "Percent",
|
|
2902
|
+
[Unit.Auto]: "Auto",
|
|
2903
|
+
[Unit.MaxContent]: "MaxContent",
|
|
2904
|
+
[Unit.FitContent]: "FitContent",
|
|
2905
|
+
[Unit.Stretch]: "Stretch"
|
|
2906
|
+
}[unit];
|
|
2907
|
+
if (suffix === void 0) throw new Error(`Failed to execute "${fnName}": Unsupported unit '${JSON.stringify(value) ?? "undefined"}'`);
|
|
2908
|
+
const method = self[`${fnName}${suffix}`];
|
|
2909
|
+
if (!method) throw new Error(`Failed to execute "${fnName}": Unsupported unit '${JSON.stringify(value) ?? "undefined"}'`);
|
|
2910
|
+
if (asNumber !== void 0) return method.call(self, ...args, asNumber);
|
|
2911
|
+
else return method.call(self, ...args);
|
|
2912
|
+
}
|
|
2913
|
+
//#endregion
|
|
2914
|
+
//#region src/yoga/index.ts
|
|
2915
|
+
const Yoga = {
|
|
2916
|
+
Config,
|
|
2917
|
+
Node: class Node extends Node$1 {
|
|
2918
|
+
constructor(config) {
|
|
2919
|
+
super(config ? config.core : getDefaultConfig());
|
|
2920
|
+
}
|
|
2921
|
+
static create(config) {
|
|
2922
|
+
return new Node(config);
|
|
2923
|
+
}
|
|
2924
|
+
static createDefault() {
|
|
2925
|
+
return new Node();
|
|
2926
|
+
}
|
|
2927
|
+
static createWithConfig(config) {
|
|
2928
|
+
return new Node(config);
|
|
2929
|
+
}
|
|
2930
|
+
/**
|
|
2931
|
+
@deprecated No-op in the TypeScript port: the garbage collector owns this
|
|
2932
|
+
node's lifetime. Kept only for yoga-layout binding compatibility (WASM
|
|
2933
|
+
nodes require explicit destruction).
|
|
2934
|
+
*/
|
|
2935
|
+
free() {}
|
|
2936
|
+
/**
|
|
2937
|
+
@deprecated No-op in the TypeScript port: garbage collection handles
|
|
2938
|
+
object graphs and cycles. Kept only for yoga-layout binding compatibility.
|
|
2939
|
+
*/
|
|
2940
|
+
freeRecursive() {}
|
|
2941
|
+
insertChild(child, index) {
|
|
2942
|
+
if (child.owner !== null) throw new Error("Child already has a owner, it must be removed first.");
|
|
2943
|
+
if (this.hasMeasureFunc()) throw new Error("Cannot add child: Nodes with measure functions cannot have children.");
|
|
2944
|
+
super.insertChild(child, index);
|
|
2945
|
+
child.owner = this;
|
|
2946
|
+
this.markDirtyAndPropagate();
|
|
2947
|
+
}
|
|
2948
|
+
removeChild(child) {
|
|
2949
|
+
let removed = false;
|
|
2950
|
+
if (super.getChildCount() > 0) {
|
|
2951
|
+
if (super.removeChild(child)) {
|
|
2952
|
+
removed = true;
|
|
2953
|
+
child.layout = new LayoutResults();
|
|
2954
|
+
child.owner = null;
|
|
2955
|
+
const dirtiedFunc = child.getDirtiedFunc();
|
|
2956
|
+
child.setCoreDirtiedFunc(null);
|
|
2957
|
+
child.setDirty(true);
|
|
2958
|
+
child.setCoreDirtiedFunc(dirtiedFunc);
|
|
2959
|
+
this.markDirtyAndPropagate();
|
|
2960
|
+
}
|
|
2961
|
+
}
|
|
2962
|
+
return removed;
|
|
2963
|
+
}
|
|
2964
|
+
getChildCount() {
|
|
2965
|
+
return super.getChildCount();
|
|
2966
|
+
}
|
|
2967
|
+
getChild(index) {
|
|
2968
|
+
return super.getChild(index);
|
|
2969
|
+
}
|
|
2970
|
+
getParent() {
|
|
2971
|
+
return this.owner;
|
|
2972
|
+
}
|
|
2973
|
+
setChildren(children) {
|
|
2974
|
+
while (super.getChildCount() !== 0) this.removeChild(this.getChild(super.getChildCount() - 1));
|
|
2975
|
+
children.forEach((child, index) => this.insertChild(child, index));
|
|
2976
|
+
}
|
|
2977
|
+
reset() {
|
|
2978
|
+
super.reset();
|
|
2979
|
+
}
|
|
2980
|
+
copyStyle(other) {
|
|
2981
|
+
if (!this.style.equals(other.style)) {
|
|
2982
|
+
this.style.copyFrom(other.style);
|
|
2983
|
+
this.invalidateProcessedDimensions();
|
|
2984
|
+
this.markDirtyAndPropagate();
|
|
2985
|
+
}
|
|
2986
|
+
}
|
|
2987
|
+
updateStyleLength(get, set, value) {
|
|
2988
|
+
if (!get().equals(value)) {
|
|
2989
|
+
set(value);
|
|
2990
|
+
this.markDirtyAndPropagate();
|
|
2991
|
+
}
|
|
2992
|
+
}
|
|
2993
|
+
updateStyleSize(get, set, value) {
|
|
2994
|
+
if (!get().equals(value)) {
|
|
2995
|
+
set(value);
|
|
2996
|
+
this.markDirtyAndPropagate();
|
|
2997
|
+
}
|
|
2998
|
+
}
|
|
2999
|
+
updateStyleEnum(get, set, value) {
|
|
3000
|
+
if (get() !== value) {
|
|
3001
|
+
set(value);
|
|
3002
|
+
this.markDirtyAndPropagate();
|
|
3003
|
+
}
|
|
3004
|
+
}
|
|
3005
|
+
setDimensionValue(dim, value) {
|
|
3006
|
+
if (!this.style.dimension(dim).equals(value)) {
|
|
3007
|
+
this.style.setDimension(dim, value);
|
|
3008
|
+
this.invalidateProcessedDimensions();
|
|
3009
|
+
this.markDirtyAndPropagate();
|
|
3010
|
+
}
|
|
3011
|
+
}
|
|
3012
|
+
setMinDimensionValue(dim, value) {
|
|
3013
|
+
if (!this.style.minDimension(dim).equals(value)) {
|
|
3014
|
+
this.style.setMinDimension(dim, value);
|
|
3015
|
+
this.invalidateProcessedDimensions();
|
|
3016
|
+
this.markDirtyAndPropagate();
|
|
3017
|
+
}
|
|
3018
|
+
}
|
|
3019
|
+
setMaxDimensionValue(dim, value) {
|
|
3020
|
+
if (!this.style.maxDimension(dim).equals(value)) {
|
|
3021
|
+
this.style.setMaxDimension(dim, value);
|
|
3022
|
+
this.invalidateProcessedDimensions();
|
|
3023
|
+
this.markDirtyAndPropagate();
|
|
3024
|
+
}
|
|
3025
|
+
}
|
|
3026
|
+
setPositionType(positionType) {
|
|
3027
|
+
this.updateStyleEnum(() => this.style.positionType(), (v) => this.style.setPositionType(v), positionType);
|
|
3028
|
+
}
|
|
3029
|
+
setPosition(edge, position) {
|
|
3030
|
+
if (typeof position === "number" || position === void 0) {
|
|
3031
|
+
this.updateStyleLength(() => this.style.position(edge), (v) => this.style.setPosition(edge, v), StyleLength.points(position === void 0 ? NaN : position));
|
|
3032
|
+
return;
|
|
3033
|
+
}
|
|
3034
|
+
dispatchSetter(this, "setPosition", (e, value) => this.updateStyleLength(() => this.style.position(e), (v) => this.style.setPosition(e, v), StyleLength.points(value === void 0 ? NaN : value)), [edge, position]);
|
|
3035
|
+
}
|
|
3036
|
+
setPositionPercent(edge, position) {
|
|
3037
|
+
this.updateStyleLength(() => this.style.position(edge), (v) => this.style.setPosition(edge, v), StyleLength.percent(position === void 0 ? NaN : position));
|
|
3038
|
+
}
|
|
3039
|
+
setPositionAuto(edge) {
|
|
3040
|
+
this.updateStyleLength(() => this.style.position(edge), (v) => this.style.setPosition(edge, v), StyleLength.ofAuto());
|
|
3041
|
+
}
|
|
3042
|
+
setAlignContent(alignContent) {
|
|
3043
|
+
this.updateStyleEnum(() => this.style.alignContent(), (v) => this.style.setAlignContent(v), alignContent);
|
|
3044
|
+
}
|
|
3045
|
+
setAlignItems(alignItems) {
|
|
3046
|
+
this.updateStyleEnum(() => this.style.alignItems(), (v) => this.style.setAlignItems(v), alignItems);
|
|
3047
|
+
}
|
|
3048
|
+
setAlignSelf(alignSelf) {
|
|
3049
|
+
this.updateStyleEnum(() => this.style.alignSelf(), (v) => this.style.setAlignSelf(v), alignSelf);
|
|
3050
|
+
}
|
|
3051
|
+
setFlexDirection(flexDirection) {
|
|
3052
|
+
if (this.style.flexDirection() !== flexDirection) {
|
|
3053
|
+
this.style.setFlexDirection(flexDirection);
|
|
3054
|
+
this.markDirtyAndPropagate();
|
|
3055
|
+
}
|
|
3056
|
+
}
|
|
3057
|
+
setFlexWrap(flexWrap) {
|
|
3058
|
+
this.updateStyleEnum(() => this.style.flexWrap(), (v) => this.style.setFlexWrap(v), flexWrap);
|
|
3059
|
+
}
|
|
3060
|
+
setJustifyContent(justifyContent) {
|
|
3061
|
+
this.updateStyleEnum(() => this.style.justifyContent(), (v) => this.style.setJustifyContent(v), justifyContent);
|
|
3062
|
+
}
|
|
3063
|
+
setDirection(direction) {
|
|
3064
|
+
this.updateStyleEnum(() => this.style.direction(), (v) => this.style.setDirection(v), direction);
|
|
3065
|
+
}
|
|
3066
|
+
setMargin(edge, margin) {
|
|
3067
|
+
if (typeof margin === "number" || margin === void 0) {
|
|
3068
|
+
this.updateStyleLength(() => this.style.margin(edge), (v) => this.style.setMargin(edge, v), StyleLength.points(margin === void 0 ? NaN : margin));
|
|
3069
|
+
return;
|
|
3070
|
+
}
|
|
3071
|
+
dispatchSetter(this, "setMargin", (e, value) => this.updateStyleLength(() => this.style.margin(e), (v) => this.style.setMargin(e, v), StyleLength.points(value === void 0 ? NaN : value)), [edge, margin]);
|
|
3072
|
+
}
|
|
3073
|
+
setMarginPercent(edge, margin) {
|
|
3074
|
+
this.updateStyleLength(() => this.style.margin(edge), (v) => this.style.setMargin(edge, v), StyleLength.percent(margin === void 0 ? NaN : margin));
|
|
3075
|
+
}
|
|
3076
|
+
setMarginAuto(edge) {
|
|
3077
|
+
this.updateStyleLength(() => this.style.margin(edge), (v) => this.style.setMargin(edge, v), StyleLength.ofAuto());
|
|
3078
|
+
}
|
|
3079
|
+
setOverflow(overflow) {
|
|
3080
|
+
this.updateStyleEnum(() => this.style.overflow(), (v) => this.style.setOverflow(v), overflow);
|
|
3081
|
+
}
|
|
3082
|
+
setDisplay(display) {
|
|
3083
|
+
if (this.style.display() !== display) {
|
|
3084
|
+
this.style.setDisplay(display);
|
|
3085
|
+
this.owner?.syncContentsChildrenCount();
|
|
3086
|
+
this.markDirtyAndPropagate();
|
|
3087
|
+
}
|
|
3088
|
+
}
|
|
3089
|
+
setFlex(flex) {
|
|
3090
|
+
const value = flex === void 0 ? NaN : flex;
|
|
3091
|
+
const current = this.style.flex();
|
|
3092
|
+
if (current !== value && !(Number.isNaN(current) && Number.isNaN(value))) {
|
|
3093
|
+
this.style.setFlex(value);
|
|
3094
|
+
this.markDirtyAndPropagate();
|
|
3095
|
+
}
|
|
3096
|
+
}
|
|
3097
|
+
setFlexBasis(flexBasis) {
|
|
3098
|
+
if (typeof flexBasis === "number" || flexBasis === void 0) {
|
|
3099
|
+
this.updateStyleSize(() => this.style.flexBasis(), (v) => this.style.setFlexBasis(v), StyleSizeLength.points(flexBasis === void 0 ? NaN : flexBasis));
|
|
3100
|
+
return;
|
|
3101
|
+
}
|
|
3102
|
+
dispatchSetter(this, "setFlexBasis", (value) => this.updateStyleSize(() => this.style.flexBasis(), (v) => this.style.setFlexBasis(v), StyleSizeLength.points(value === void 0 ? NaN : value)), [flexBasis]);
|
|
3103
|
+
}
|
|
3104
|
+
setFlexBasisPercent(flexBasis) {
|
|
3105
|
+
this.updateStyleSize(() => this.style.flexBasis(), (v) => this.style.setFlexBasis(v), StyleSizeLength.percent(flexBasis === void 0 ? NaN : flexBasis));
|
|
3106
|
+
}
|
|
3107
|
+
setFlexBasisAuto() {
|
|
3108
|
+
this.updateStyleSize(() => this.style.flexBasis(), (v) => this.style.setFlexBasis(v), StyleSizeLength.ofAuto());
|
|
3109
|
+
}
|
|
3110
|
+
setFlexBasisMaxContent() {
|
|
3111
|
+
this.updateStyleSize(() => this.style.flexBasis(), (v) => this.style.setFlexBasis(v), StyleSizeLength.ofMaxContent());
|
|
3112
|
+
}
|
|
3113
|
+
setFlexBasisFitContent() {
|
|
3114
|
+
this.updateStyleSize(() => this.style.flexBasis(), (v) => this.style.setFlexBasis(v), StyleSizeLength.ofFitContent());
|
|
3115
|
+
}
|
|
3116
|
+
setFlexBasisStretch() {
|
|
3117
|
+
this.updateStyleSize(() => this.style.flexBasis(), (v) => this.style.setFlexBasis(v), StyleSizeLength.ofStretch());
|
|
3118
|
+
}
|
|
3119
|
+
setFlexGrow(flexGrow) {
|
|
3120
|
+
const value = flexGrow === void 0 ? NaN : flexGrow;
|
|
3121
|
+
const current = this.style.flexGrow();
|
|
3122
|
+
if (current !== value && !(Number.isNaN(current) && Number.isNaN(value))) {
|
|
3123
|
+
this.style.setFlexGrow(value);
|
|
3124
|
+
this.markDirtyAndPropagate();
|
|
3125
|
+
}
|
|
3126
|
+
}
|
|
3127
|
+
setFlexShrink(flexShrink) {
|
|
3128
|
+
const value = flexShrink === void 0 ? NaN : flexShrink;
|
|
3129
|
+
const current = this.style.flexShrink();
|
|
3130
|
+
if (current !== value && !(Number.isNaN(current) && Number.isNaN(value))) {
|
|
3131
|
+
this.style.setFlexShrink(value);
|
|
3132
|
+
this.markDirtyAndPropagate();
|
|
3133
|
+
}
|
|
3134
|
+
}
|
|
3135
|
+
setWidth(width) {
|
|
3136
|
+
if (typeof width === "number" || width === void 0) {
|
|
3137
|
+
this.setDimensionValue(Dimension.Width, StyleSizeLength.points(width === void 0 ? NaN : width));
|
|
3138
|
+
return;
|
|
3139
|
+
}
|
|
3140
|
+
dispatchSetter(this, "setWidth", (value) => this.setDimensionValue(Dimension.Width, StyleSizeLength.points(value === void 0 ? NaN : value)), [width]);
|
|
3141
|
+
}
|
|
3142
|
+
setWidthPercent(width) {
|
|
3143
|
+
this.setDimensionValue(Dimension.Width, StyleSizeLength.percent(width === void 0 ? NaN : width));
|
|
3144
|
+
}
|
|
3145
|
+
setWidthAuto() {
|
|
3146
|
+
this.setDimensionValue(Dimension.Width, StyleSizeLength.ofAuto());
|
|
3147
|
+
}
|
|
3148
|
+
setWidthMaxContent() {
|
|
3149
|
+
this.setDimensionValue(Dimension.Width, StyleSizeLength.ofMaxContent());
|
|
3150
|
+
}
|
|
3151
|
+
setWidthFitContent() {
|
|
3152
|
+
this.setDimensionValue(Dimension.Width, StyleSizeLength.ofFitContent());
|
|
3153
|
+
}
|
|
3154
|
+
setWidthStretch() {
|
|
3155
|
+
this.setDimensionValue(Dimension.Width, StyleSizeLength.ofStretch());
|
|
3156
|
+
}
|
|
3157
|
+
setHeight(height) {
|
|
3158
|
+
if (typeof height === "number" || height === void 0) {
|
|
3159
|
+
this.setDimensionValue(Dimension.Height, StyleSizeLength.points(height === void 0 ? NaN : height));
|
|
3160
|
+
return;
|
|
3161
|
+
}
|
|
3162
|
+
dispatchSetter(this, "setHeight", (value) => this.setDimensionValue(Dimension.Height, StyleSizeLength.points(value === void 0 ? NaN : value)), [height]);
|
|
3163
|
+
}
|
|
3164
|
+
setHeightPercent(height) {
|
|
3165
|
+
this.setDimensionValue(Dimension.Height, StyleSizeLength.percent(height === void 0 ? NaN : height));
|
|
3166
|
+
}
|
|
3167
|
+
setHeightAuto() {
|
|
3168
|
+
this.setDimensionValue(Dimension.Height, StyleSizeLength.ofAuto());
|
|
3169
|
+
}
|
|
3170
|
+
setHeightMaxContent() {
|
|
3171
|
+
this.setDimensionValue(Dimension.Height, StyleSizeLength.ofMaxContent());
|
|
3172
|
+
}
|
|
3173
|
+
setHeightFitContent() {
|
|
3174
|
+
this.setDimensionValue(Dimension.Height, StyleSizeLength.ofFitContent());
|
|
3175
|
+
}
|
|
3176
|
+
setHeightStretch() {
|
|
3177
|
+
this.setDimensionValue(Dimension.Height, StyleSizeLength.ofStretch());
|
|
3178
|
+
}
|
|
3179
|
+
setMinWidth(minWidth) {
|
|
3180
|
+
if (typeof minWidth === "number" || minWidth === void 0) {
|
|
3181
|
+
this.setMinDimensionValue(Dimension.Width, StyleSizeLength.points(minWidth === void 0 ? NaN : minWidth));
|
|
3182
|
+
return;
|
|
3183
|
+
}
|
|
3184
|
+
dispatchSetter(this, "setMinWidth", (value) => this.setMinDimensionValue(Dimension.Width, StyleSizeLength.points(value === void 0 ? NaN : value)), [minWidth]);
|
|
3185
|
+
}
|
|
3186
|
+
setMinWidthPercent(minWidth) {
|
|
3187
|
+
this.setMinDimensionValue(Dimension.Width, StyleSizeLength.percent(minWidth === void 0 ? NaN : minWidth));
|
|
3188
|
+
}
|
|
3189
|
+
setMinWidthMaxContent() {
|
|
3190
|
+
this.setMinDimensionValue(Dimension.Width, StyleSizeLength.ofMaxContent());
|
|
3191
|
+
}
|
|
3192
|
+
setMinWidthFitContent() {
|
|
3193
|
+
this.setMinDimensionValue(Dimension.Width, StyleSizeLength.ofFitContent());
|
|
3194
|
+
}
|
|
3195
|
+
setMinWidthStretch() {
|
|
3196
|
+
this.setMinDimensionValue(Dimension.Width, StyleSizeLength.ofStretch());
|
|
3197
|
+
}
|
|
3198
|
+
setMinHeight(minHeight) {
|
|
3199
|
+
if (typeof minHeight === "number" || minHeight === void 0) {
|
|
3200
|
+
this.setMinDimensionValue(Dimension.Height, StyleSizeLength.points(minHeight === void 0 ? NaN : minHeight));
|
|
3201
|
+
return;
|
|
3202
|
+
}
|
|
3203
|
+
dispatchSetter(this, "setMinHeight", (value) => this.setMinDimensionValue(Dimension.Height, StyleSizeLength.points(value === void 0 ? NaN : value)), [minHeight]);
|
|
3204
|
+
}
|
|
3205
|
+
setMinHeightPercent(minHeight) {
|
|
3206
|
+
this.setMinDimensionValue(Dimension.Height, StyleSizeLength.percent(minHeight === void 0 ? NaN : minHeight));
|
|
3207
|
+
}
|
|
3208
|
+
setMinHeightMaxContent() {
|
|
3209
|
+
this.setMinDimensionValue(Dimension.Height, StyleSizeLength.ofMaxContent());
|
|
3210
|
+
}
|
|
3211
|
+
setMinHeightFitContent() {
|
|
3212
|
+
this.setMinDimensionValue(Dimension.Height, StyleSizeLength.ofFitContent());
|
|
3213
|
+
}
|
|
3214
|
+
setMinHeightStretch() {
|
|
3215
|
+
this.setMinDimensionValue(Dimension.Height, StyleSizeLength.ofStretch());
|
|
3216
|
+
}
|
|
3217
|
+
setMaxWidth(maxWidth) {
|
|
3218
|
+
if (typeof maxWidth === "number" || maxWidth === void 0) {
|
|
3219
|
+
this.setMaxDimensionValue(Dimension.Width, StyleSizeLength.points(maxWidth === void 0 ? NaN : maxWidth));
|
|
3220
|
+
return;
|
|
3221
|
+
}
|
|
3222
|
+
dispatchSetter(this, "setMaxWidth", (value) => this.setMaxDimensionValue(Dimension.Width, StyleSizeLength.points(value === void 0 ? NaN : value)), [maxWidth]);
|
|
3223
|
+
}
|
|
3224
|
+
setMaxWidthPercent(maxWidth) {
|
|
3225
|
+
this.setMaxDimensionValue(Dimension.Width, StyleSizeLength.percent(maxWidth === void 0 ? NaN : maxWidth));
|
|
3226
|
+
}
|
|
3227
|
+
setMaxWidthMaxContent() {
|
|
3228
|
+
this.setMaxDimensionValue(Dimension.Width, StyleSizeLength.ofMaxContent());
|
|
3229
|
+
}
|
|
3230
|
+
setMaxWidthFitContent() {
|
|
3231
|
+
this.setMaxDimensionValue(Dimension.Width, StyleSizeLength.ofFitContent());
|
|
3232
|
+
}
|
|
3233
|
+
setMaxWidthStretch() {
|
|
3234
|
+
this.setMaxDimensionValue(Dimension.Width, StyleSizeLength.ofStretch());
|
|
3235
|
+
}
|
|
3236
|
+
setMaxHeight(maxHeight) {
|
|
3237
|
+
if (typeof maxHeight === "number" || maxHeight === void 0) {
|
|
3238
|
+
this.setMaxDimensionValue(Dimension.Height, StyleSizeLength.points(maxHeight === void 0 ? NaN : maxHeight));
|
|
3239
|
+
return;
|
|
3240
|
+
}
|
|
3241
|
+
dispatchSetter(this, "setMaxHeight", (value) => this.setMaxDimensionValue(Dimension.Height, StyleSizeLength.points(value === void 0 ? NaN : value)), [maxHeight]);
|
|
3242
|
+
}
|
|
3243
|
+
setMaxHeightPercent(maxHeight) {
|
|
3244
|
+
this.setMaxDimensionValue(Dimension.Height, StyleSizeLength.percent(maxHeight === void 0 ? NaN : maxHeight));
|
|
3245
|
+
}
|
|
3246
|
+
setMaxHeightMaxContent() {
|
|
3247
|
+
this.setMaxDimensionValue(Dimension.Height, StyleSizeLength.ofMaxContent());
|
|
3248
|
+
}
|
|
3249
|
+
setMaxHeightFitContent() {
|
|
3250
|
+
this.setMaxDimensionValue(Dimension.Height, StyleSizeLength.ofFitContent());
|
|
3251
|
+
}
|
|
3252
|
+
setMaxHeightStretch() {
|
|
3253
|
+
this.setMaxDimensionValue(Dimension.Height, StyleSizeLength.ofStretch());
|
|
3254
|
+
}
|
|
3255
|
+
setAspectRatio(aspectRatio) {
|
|
3256
|
+
const value = aspectRatio === void 0 ? NaN : aspectRatio;
|
|
3257
|
+
const current = this.style.aspectRatio();
|
|
3258
|
+
const normalized = value === 0 || value === Infinity || value === -Infinity ? NaN : value;
|
|
3259
|
+
if (current !== normalized && !(Number.isNaN(current) && Number.isNaN(normalized))) {
|
|
3260
|
+
this.style.setAspectRatio(value);
|
|
3261
|
+
this.markDirtyAndPropagate();
|
|
3262
|
+
}
|
|
3263
|
+
}
|
|
3264
|
+
setBorder(edge, borderWidth) {
|
|
3265
|
+
this.updateStyleLength(() => this.style.border(edge), (v) => this.style.setBorder(edge, v), StyleLength.points(borderWidth === void 0 ? NaN : borderWidth));
|
|
3266
|
+
}
|
|
3267
|
+
setPadding(edge, padding) {
|
|
3268
|
+
if (typeof padding === "number" || padding === void 0) {
|
|
3269
|
+
this.updateStyleLength(() => this.style.padding(edge), (v) => this.style.setPadding(edge, v), StyleLength.points(padding === void 0 ? NaN : padding));
|
|
3270
|
+
return;
|
|
3271
|
+
}
|
|
3272
|
+
dispatchSetter(this, "setPadding", (e, value) => this.updateStyleLength(() => this.style.padding(e), (v) => this.style.setPadding(e, v), StyleLength.points(value === void 0 ? NaN : value)), [edge, padding]);
|
|
3273
|
+
}
|
|
3274
|
+
setPaddingPercent(edge, padding) {
|
|
3275
|
+
this.updateStyleLength(() => this.style.padding(edge), (v) => this.style.setPadding(edge, v), StyleLength.percent(padding === void 0 ? NaN : padding));
|
|
3276
|
+
}
|
|
3277
|
+
setGap(gutter, gapLength) {
|
|
3278
|
+
if (typeof gapLength === "number" || gapLength === void 0) {
|
|
3279
|
+
this.updateStyleLength(() => this.style.gap(gutter), (v) => this.style.setGap(gutter, v), StyleLength.points(gapLength === void 0 ? NaN : gapLength));
|
|
3280
|
+
return;
|
|
3281
|
+
}
|
|
3282
|
+
dispatchSetter(this, "setGap", (g, value) => this.updateStyleLength(() => this.style.gap(g), (v) => this.style.setGap(g, v), StyleLength.points(value === void 0 ? NaN : value)), [gutter, gapLength]);
|
|
3283
|
+
}
|
|
3284
|
+
setGapPercent(gutter, gapLength) {
|
|
3285
|
+
this.updateStyleLength(() => this.style.gap(gutter), (v) => this.style.setGap(gutter, v), StyleLength.percent(gapLength === void 0 ? NaN : gapLength));
|
|
3286
|
+
}
|
|
3287
|
+
setBoxSizing(boxSizing) {
|
|
3288
|
+
this.updateStyleEnum(() => this.style.boxSizing(), (v) => this.style.setBoxSizing(v), boxSizing);
|
|
3289
|
+
}
|
|
3290
|
+
setIsReferenceBaseline(isReferenceBaseline) {
|
|
3291
|
+
if (this.isReferenceBaseline_ !== isReferenceBaseline) {
|
|
3292
|
+
this.isReferenceBaseline_ = isReferenceBaseline;
|
|
3293
|
+
this.markDirtyAndPropagate();
|
|
3294
|
+
}
|
|
3295
|
+
}
|
|
3296
|
+
setAlwaysFormsContainingBlock(alwaysFormsContainingBlock) {
|
|
3297
|
+
this.alwaysFormsContainingBlock = alwaysFormsContainingBlock;
|
|
3298
|
+
}
|
|
3299
|
+
getPositionType() {
|
|
3300
|
+
return this.style.positionType();
|
|
3301
|
+
}
|
|
3302
|
+
getPosition(edge) {
|
|
3303
|
+
return styleValue(this.style.position(edge));
|
|
3304
|
+
}
|
|
3305
|
+
getAlignContent() {
|
|
3306
|
+
return this.style.alignContent();
|
|
3307
|
+
}
|
|
3308
|
+
getAlignItems() {
|
|
3309
|
+
return this.style.alignItems();
|
|
3310
|
+
}
|
|
3311
|
+
getAlignSelf() {
|
|
3312
|
+
return this.style.alignSelf();
|
|
3313
|
+
}
|
|
3314
|
+
getFlexDirection() {
|
|
3315
|
+
return this.style.flexDirection();
|
|
3316
|
+
}
|
|
3317
|
+
getFlexWrap() {
|
|
3318
|
+
return this.style.flexWrap();
|
|
3319
|
+
}
|
|
3320
|
+
getJustifyContent() {
|
|
3321
|
+
return this.style.justifyContent();
|
|
3322
|
+
}
|
|
3323
|
+
getDirection() {
|
|
3324
|
+
return this.style.direction();
|
|
3325
|
+
}
|
|
3326
|
+
getMargin(edge) {
|
|
3327
|
+
return styleValue(this.style.margin(edge));
|
|
3328
|
+
}
|
|
3329
|
+
getOverflow() {
|
|
3330
|
+
return this.style.overflow();
|
|
3331
|
+
}
|
|
3332
|
+
getDisplay() {
|
|
3333
|
+
return this.style.display();
|
|
3334
|
+
}
|
|
3335
|
+
getFlexBasis() {
|
|
3336
|
+
return styleValue(this.style.flexBasis());
|
|
3337
|
+
}
|
|
3338
|
+
getFlexGrow() {
|
|
3339
|
+
const flexGrow = this.style.flexGrow();
|
|
3340
|
+
return Number.isNaN(flexGrow) ? 0 : flexGrow;
|
|
3341
|
+
}
|
|
3342
|
+
getFlexShrink() {
|
|
3343
|
+
const flexShrink = this.style.flexShrink();
|
|
3344
|
+
return Number.isNaN(flexShrink) ? this.config.useWebDefaults() ? 1 : 0 : flexShrink;
|
|
3345
|
+
}
|
|
3346
|
+
getWidth() {
|
|
3347
|
+
return styleValue(this.style.dimension(Dimension.Width));
|
|
3348
|
+
}
|
|
3349
|
+
getHeight() {
|
|
3350
|
+
return styleValue(this.style.dimension(Dimension.Height));
|
|
3351
|
+
}
|
|
3352
|
+
getMinWidth() {
|
|
3353
|
+
return styleValue(this.style.minDimension(Dimension.Width));
|
|
3354
|
+
}
|
|
3355
|
+
getMinHeight() {
|
|
3356
|
+
return styleValue(this.style.minDimension(Dimension.Height));
|
|
3357
|
+
}
|
|
3358
|
+
getMaxWidth() {
|
|
3359
|
+
return styleValue(this.style.maxDimension(Dimension.Width));
|
|
3360
|
+
}
|
|
3361
|
+
getMaxHeight() {
|
|
3362
|
+
return styleValue(this.style.maxDimension(Dimension.Height));
|
|
3363
|
+
}
|
|
3364
|
+
getAspectRatio() {
|
|
3365
|
+
return this.style.aspectRatio();
|
|
3366
|
+
}
|
|
3367
|
+
getBorder(edge) {
|
|
3368
|
+
const border = this.style.border(edge);
|
|
3369
|
+
if (border.isUndefined() || border.isAuto()) return NaN;
|
|
3370
|
+
return border.value;
|
|
3371
|
+
}
|
|
3372
|
+
getPadding(edge) {
|
|
3373
|
+
return styleValue(this.style.padding(edge));
|
|
3374
|
+
}
|
|
3375
|
+
getGap(gutter) {
|
|
3376
|
+
return styleValue(this.style.gap(gutter));
|
|
3377
|
+
}
|
|
3378
|
+
getBoxSizing() {
|
|
3379
|
+
return this.style.boxSizing();
|
|
3380
|
+
}
|
|
3381
|
+
isReferenceBaseline() {
|
|
3382
|
+
return this.isReferenceBaseline_;
|
|
3383
|
+
}
|
|
3384
|
+
setMeasureFunc(measureFunc) {
|
|
3385
|
+
if (measureFunc) super.setMeasureFunc(measureFunc);
|
|
3386
|
+
else this.unsetMeasureFunc();
|
|
3387
|
+
}
|
|
3388
|
+
unsetMeasureFunc() {
|
|
3389
|
+
super.setMeasureFunc(null);
|
|
3390
|
+
}
|
|
3391
|
+
setDirtiedFunc(dirtiedFunc) {
|
|
3392
|
+
if (dirtiedFunc) this.setCoreDirtiedFunc(() => dirtiedFunc(this));
|
|
3393
|
+
else this.unsetDirtiedFunc();
|
|
3394
|
+
}
|
|
3395
|
+
unsetDirtiedFunc() {
|
|
3396
|
+
this.setCoreDirtiedFunc(null);
|
|
3397
|
+
}
|
|
3398
|
+
markDirty() {
|
|
3399
|
+
if (!this.hasMeasureFunc()) throw new Error("Only leaf nodes with custom measure functions should manually mark themselves as dirty");
|
|
3400
|
+
this.markDirtyAndPropagate();
|
|
3401
|
+
}
|
|
3402
|
+
isDirty() {
|
|
3403
|
+
return super.isDirty();
|
|
3404
|
+
}
|
|
3405
|
+
markLayoutSeen() {
|
|
3406
|
+
this.hasNewLayout_ = false;
|
|
3407
|
+
}
|
|
3408
|
+
hasNewLayout() {
|
|
3409
|
+
return this.hasNewLayout_;
|
|
3410
|
+
}
|
|
3411
|
+
calculateLayout(width = NaN, height = NaN, direction = Direction.LTR) {
|
|
3412
|
+
calculateLayout(this, typeof width === "number" ? width : NaN, typeof height === "number" ? height : NaN, direction);
|
|
3413
|
+
}
|
|
3414
|
+
getComputedLeft() {
|
|
3415
|
+
return this.layout.position(PhysicalEdge.Left);
|
|
3416
|
+
}
|
|
3417
|
+
getComputedRight() {
|
|
3418
|
+
return this.layout.position(PhysicalEdge.Right);
|
|
3419
|
+
}
|
|
3420
|
+
getComputedTop() {
|
|
3421
|
+
return this.layout.position(PhysicalEdge.Top);
|
|
3422
|
+
}
|
|
3423
|
+
getComputedBottom() {
|
|
3424
|
+
return this.layout.position(PhysicalEdge.Bottom);
|
|
3425
|
+
}
|
|
3426
|
+
getComputedWidth() {
|
|
3427
|
+
return this.layout.dimension(Dimension.Width);
|
|
3428
|
+
}
|
|
3429
|
+
getComputedHeight() {
|
|
3430
|
+
return this.layout.dimension(Dimension.Height);
|
|
3431
|
+
}
|
|
3432
|
+
getComputedHadOverflow() {
|
|
3433
|
+
return this.layout.hadOverflow();
|
|
3434
|
+
}
|
|
3435
|
+
getComputedLayout() {
|
|
3436
|
+
return {
|
|
3437
|
+
left: this.getComputedLeft(),
|
|
3438
|
+
right: this.getComputedRight(),
|
|
3439
|
+
top: this.getComputedTop(),
|
|
3440
|
+
bottom: this.getComputedBottom(),
|
|
3441
|
+
width: this.getComputedWidth(),
|
|
3442
|
+
height: this.getComputedHeight(),
|
|
3443
|
+
hadOverflow: this.getComputedHadOverflow()
|
|
3444
|
+
};
|
|
3445
|
+
}
|
|
3446
|
+
resolvedLayoutProperty(getter, edge) {
|
|
3447
|
+
if (edge > Edge.End) throw new Error("Cannot get layout properties of multi-edge shorthands");
|
|
3448
|
+
if (edge === Edge.Start) return this.layout.direction() === Direction.RTL ? getter(PhysicalEdge.Right) : getter(PhysicalEdge.Left);
|
|
3449
|
+
if (edge === Edge.End) return this.layout.direction() === Direction.RTL ? getter(PhysicalEdge.Left) : getter(PhysicalEdge.Right);
|
|
3450
|
+
return getter(edge);
|
|
3451
|
+
}
|
|
3452
|
+
getComputedMargin(edge) {
|
|
3453
|
+
return this.resolvedLayoutProperty((e) => this.layout.margin(e), edge);
|
|
3454
|
+
}
|
|
3455
|
+
getComputedBorder(edge) {
|
|
3456
|
+
return this.resolvedLayoutProperty((e) => this.layout.border(e), edge);
|
|
3457
|
+
}
|
|
3458
|
+
getComputedPadding(edge) {
|
|
3459
|
+
return this.resolvedLayoutProperty((e) => this.layout.padding(e), edge);
|
|
3460
|
+
}
|
|
3461
|
+
},
|
|
3462
|
+
...constants
|
|
3463
|
+
};
|
|
3464
|
+
//#endregion
|
|
3465
|
+
export { Overflow as _, Direction as a, Wrap as b, Errata as c, GridTrackType as d, Gutter as f, NodeType as g, MeasureMode as h, Dimension as i, ExperimentalFeature as l, LogLevel as m, Align as n, Display as o, Justify as p, BoxSizing as r, Edge as s, Yoga as t, FlexDirection as u, PositionType as v, constants as x, Unit as y };
|