Skip to content

Commit 4e3e329

Browse files
fix js tests
1 parent 8d5435f commit 4e3e329

182 files changed

Lines changed: 1657 additions & 1431 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@
1616
{
1717
"mode": "auto"
1818
}
19-
]
19+
],
2020
}

enums.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
"WebFlexBasis",
6969
],
7070
"Gutter": ["Column", "Row", "All"],
71+
"GridTrackType": ["Auto", "Points", "Percent", "Fr", "Minmax"],
7172
# Known incorrect behavior which can be enabled for compatibility
7273
"Errata": [
7374
# Default: Standards conformant mode

gentest/fixtures/grid/grid_minmax_column_indefinite.html

Lines changed: 0 additions & 13 deletions
This file was deleted.

gentest/gentest-javascript.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ JavascriptEmitter.prototype = Object.create(Emitter.prototype, {
9595
this.push('Errata,');
9696
this.push('ExperimentalFeature,');
9797
this.push('FlexDirection,');
98+
this.push('GridTrackType,');
9899
this.push('Gutter,');
99100
this.push('Justify,');
100101
this.push('MeasureMode,');
@@ -531,7 +532,7 @@ JavascriptEmitter.prototype = Object.create(Emitter.prototype, {
531532
const minVal = this.formatGridTrackValueJS(track.min);
532533
const maxVal = this.formatGridTrackValueJS(track.max);
533534
this.push(
534-
`${nodeName}GridTemplateRows.push({type: 'minmax', min: ${minVal}, max: ${maxVal}});`,
535+
`${nodeName}GridTemplateRows.push({type: GridTrackType.Minmax, min: ${minVal}, max: ${maxVal}});`,
535536
);
536537
} else {
537538
const val = this.formatGridTrackValueJS(track);
@@ -559,7 +560,7 @@ JavascriptEmitter.prototype = Object.create(Emitter.prototype, {
559560
const minVal = this.formatGridTrackValueJS(track.min);
560561
const maxVal = this.formatGridTrackValueJS(track.max);
561562
this.push(
562-
`${nodeName}GridTemplateColumns.push({type: 'minmax', min: ${minVal}, max: ${maxVal}});`,
563+
`${nodeName}GridTemplateColumns.push({type: GridTrackType.Minmax, min: ${minVal}, max: ${maxVal}});`,
563564
);
564565
} else {
565566
const val = this.formatGridTrackValueJS(track);
@@ -635,7 +636,7 @@ JavascriptEmitter.prototype = Object.create(Emitter.prototype, {
635636
const minVal = this.formatGridTrackValueJS(track.min);
636637
const maxVal = this.formatGridTrackValueJS(track.max);
637638
this.push(
638-
`${nodeName}GridAutoColumns.push({type: 'minmax', min: ${minVal}, max: ${maxVal}});`,
639+
`${nodeName}GridAutoColumns.push({type: GridTrackType.Minmax, min: ${minVal}, max: ${maxVal}});`,
639640
);
640641
} else {
641642
const val = this.formatGridTrackValueJS(track);
@@ -661,7 +662,7 @@ JavascriptEmitter.prototype = Object.create(Emitter.prototype, {
661662
const minVal = this.formatGridTrackValueJS(track.min);
662663
const maxVal = this.formatGridTrackValueJS(track.max);
663664
this.push(
664-
`${nodeName}GridAutoRows.push({type: 'minmax', min: ${minVal}, max: ${maxVal}});`,
665+
`${nodeName}GridAutoRows.push({type: GridTrackType.Minmax, min: ${minVal}, max: ${maxVal}});`,
665666
);
666667
} else {
667668
const val = this.formatGridTrackValueJS(track);
@@ -677,17 +678,17 @@ JavascriptEmitter.prototype = Object.create(Emitter.prototype, {
677678
value: function (track) {
678679
switch (track.type) {
679680
case 'auto':
680-
return `{type: 'auto'}`;
681+
return `{type: GridTrackType.Auto}`;
681682
case 'points':
682-
return `{type: 'points', value: ${toValueJavascript(
683+
return `{type: GridTrackType.Points, value: ${toValueJavascript(
683684
track.value + 'px',
684685
)}}`;
685686
case 'percent':
686-
return `{type: 'percent', value: ${track.value}}`;
687+
return `{type: GridTrackType.Percent, value: ${track.value}}`;
687688
case 'fr':
688-
return `{type: 'fr', value: ${track.value}}`;
689+
return `{type: GridTrackType.Fr, value: ${track.value}}`;
689690
default:
690-
return `{type: 'auto'}`;
691+
return `{type: GridTrackType.Auto}`;
691692
}
692693
},
693694
},
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
// @generated by enums.py
9+
10+
package com.facebook.yoga;
11+
12+
public enum YogaGridTrackType {
13+
AUTO(0),
14+
POINTS(1),
15+
PERCENT(2),
16+
FR(3),
17+
MINMAX(4);
18+
19+
private final int mIntValue;
20+
21+
YogaGridTrackType(int intValue) {
22+
mIntValue = intValue;
23+
}
24+
25+
public int intValue() {
26+
return mIntValue;
27+
}
28+
29+
public static YogaGridTrackType fromInt(int value) {
30+
switch (value) {
31+
case 0: return AUTO;
32+
case 1: return POINTS;
33+
case 2: return PERCENT;
34+
case 3: return FR;
35+
case 4: return MINMAX;
36+
default: throw new IllegalArgumentException("Unknown enum value: " + value);
37+
}
38+
}
39+
}

java/tests/generated/com/facebook/yoga/grid_minmax_column_indefinite.java

Lines changed: 0 additions & 33 deletions
This file was deleted.

javascript/src/Node.cpp

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -603,26 +603,31 @@ void Node::setAlwaysFormsContainingBlock(bool alwaysFormsContainingBlock) {
603603

604604
// Helper function to convert JS track value to YGGridTrackValueRef
605605
static YGGridTrackValueRef convertTrackValue(emscripten::val track) {
606-
std::string type = track["type"].as<std::string>();
607-
608-
if (type == "auto") {
609-
return YGAuto();
610-
} else if (type == "points") {
611-
float value = track["value"].as<float>();
612-
return YGPoints(value);
613-
} else if (type == "percent") {
614-
float value = track["value"].as<float>();
615-
return YGPercent(value);
616-
} else if (type == "fr") {
617-
float value = track["value"].as<float>();
618-
return YGFr(value);
619-
} else if (type == "minmax") {
620-
YGGridTrackValueRef minVal = convertTrackValue(track["min"]);
621-
YGGridTrackValueRef maxVal = convertTrackValue(track["max"]);
622-
return YGMinMax(minVal, maxVal);
606+
int type = track["type"].as<int>();
607+
608+
switch (type) {
609+
case YGGridTrackTypeAuto:
610+
return YGAuto();
611+
case YGGridTrackTypePoints: {
612+
float value = track["value"].as<float>();
613+
return YGPoints(value);
614+
}
615+
case YGGridTrackTypePercent: {
616+
float value = track["value"].as<float>();
617+
return YGPercent(value);
618+
}
619+
case YGGridTrackTypeFr: {
620+
float value = track["value"].as<float>();
621+
return YGFr(value);
622+
}
623+
case YGGridTrackTypeMinmax: {
624+
YGGridTrackValueRef minVal = convertTrackValue(track["min"]);
625+
YGGridTrackValueRef maxVal = convertTrackValue(track["max"]);
626+
return YGMinMax(minVal, maxVal);
627+
}
628+
default:
629+
return YGAuto();
623630
}
624-
625-
return YGAuto();
626631
}
627632

628633
// Helper function to build grid track list from JS array

javascript/src/generated/YGEnums.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ export enum FlexDirection {
7676
RowReverse = 3,
7777
}
7878

79+
export enum GridTrackType {
80+
Auto = 0,
81+
Points = 1,
82+
Percent = 2,
83+
Fr = 3,
84+
Minmax = 4,
85+
}
86+
7987
export enum Gutter {
8088
Column = 0,
8189
Row = 1,
@@ -186,6 +194,11 @@ const constants = {
186194
FLEX_DIRECTION_COLUMN_REVERSE: FlexDirection.ColumnReverse,
187195
FLEX_DIRECTION_ROW: FlexDirection.Row,
188196
FLEX_DIRECTION_ROW_REVERSE: FlexDirection.RowReverse,
197+
GRID_TRACK_TYPE_AUTO: GridTrackType.Auto,
198+
GRID_TRACK_TYPE_POINTS: GridTrackType.Points,
199+
GRID_TRACK_TYPE_PERCENT: GridTrackType.Percent,
200+
GRID_TRACK_TYPE_FR: GridTrackType.Fr,
201+
GRID_TRACK_TYPE_MINMAX: GridTrackType.Minmax,
189202
GUTTER_COLUMN: Gutter.Column,
190203
GUTTER_ROW: Gutter.Row,
191204
GUTTER_ALL: Gutter.All,

javascript/src/wrapAssembly.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import type {
2020
Errata,
2121
ExperimentalFeature,
2222
FlexDirection,
23+
GridTrackType,
2324
Gutter,
2425
Justify,
2526
MeasureMode,
@@ -47,6 +48,13 @@ type Value = {
4748
value: number;
4849
};
4950

51+
type GridTrackValue = {
52+
type: GridTrackType;
53+
value?: number;
54+
min?: GridTrackValue;
55+
max?: GridTrackValue;
56+
};
57+
5058
export type Config = {
5159
free(): void;
5260
isExperimentalFeatureEnabled(feature: ExperimentalFeature): boolean;
@@ -170,6 +178,8 @@ export type Node = {
170178
setHeightPercent(height: number | undefined): void;
171179
setHeightStretch(): void;
172180
setJustifyContent(justifyContent: Justify): void;
181+
setJustifyItems(justifyItems: Justify): void;
182+
setJustifySelf(justifySelf: Justify): void;
173183
setGap(gutter: Gutter, gapLength: number | `${number}%` | undefined): Value;
174184
setGapPercent(gutter: Gutter, gapLength: number | undefined): Value;
175185
setMargin(
@@ -258,6 +268,18 @@ export type Node = {
258268
unsetDirtiedFunc(): void;
259269
unsetMeasureFunc(): void;
260270
setAlwaysFormsContainingBlock(alwaysFormsContainingBlock: boolean): void;
271+
setGridTemplateColumns(tracks: GridTrackValue[]): void;
272+
setGridTemplateRows(tracks: GridTrackValue[]): void;
273+
setGridAutoColumns(tracks: GridTrackValue[]): void;
274+
setGridAutoRows(tracks: GridTrackValue[]): void;
275+
setGridColumnStart(value: number): void;
276+
setGridColumnStartSpan(span: number): void;
277+
setGridColumnEnd(value: number): void;
278+
setGridColumnEndSpan(span: number): void;
279+
setGridRowStart(value: number): void;
280+
setGridRowStartSpan(span: number): void;
281+
setGridRowEnd(value: number): void;
282+
setGridRowEndSpan(span: number): void;
261283
};
262284

263285
export type Yoga = {

javascript/tests/generated/YGAbsolutePositionTest.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<9deb466dfc94bb340137a9e6b5d5c63d>>
7+
* @generated SignedSource<<ddf440e3512099c9c1dfa25a35e957de>>
88
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGAbsolutePositionTest.html
99
*/
1010

@@ -19,6 +19,7 @@ import {
1919
Errata,
2020
ExperimentalFeature,
2121
FlexDirection,
22+
GridTrackType,
2223
Gutter,
2324
Justify,
2425
MeasureMode,

0 commit comments

Comments
 (0)