Add option to use aspect-ratio in test fixtures

Summary: Wires up codegen for aspect-ratio styles in JS, Java and CPP gentest fixtures.

Reviewed By: NickGerleman

Differential Revision: D50225805

fbshipit-source-id: 660a3999eab24611b7c2d2e073b1d55180a5d4f0
This commit is contained in:
Eric Rozell
2023-10-12 15:02:00 -07:00
committed by Facebook GitHub Bot
parent fad4d50b8e
commit a876372357
4 changed files with 35 additions and 0 deletions

View File

@@ -219,6 +219,20 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
}, },
}, },
YGNodeStyleSetAspectRatio: {
value: function (nodeName, value) {
this.push(
'YGNodeStyleSetAspectRatio' +
toFunctionName(value) +
'(' +
nodeName +
', ' +
toValueCpp(value) +
');',
);
},
},
YGNodeStyleSetBorder: { YGNodeStyleSetBorder: {
value: function (nodeName, edge, value) { value: function (nodeName, edge, value) {
this.push( this.push(

View File

@@ -239,6 +239,12 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
}, },
}, },
YGNodeStyleSetAspectRatio: {
value: function (nodeName, value) {
this.push(nodeName + '.setAspectRatio(' + toValueJava(value) + 'f);');
},
},
YGNodeStyleSetBorder: { YGNodeStyleSetBorder: {
value: function (nodeName, edge, value) { value: function (nodeName, edge, value) {
this.push( this.push(

View File

@@ -222,6 +222,14 @@ JavascriptEmitter.prototype = Object.create(Emitter.prototype, {
}, },
}, },
YGNodeStyleSetAspectRatio: {
value: function (nodeName, value) {
this.push(
nodeName + '.setAspectRatio(' + toValueJavascript(value) + ');',
);
},
},
YGNodeStyleSetBorder: { YGNodeStyleSetBorder: {
value: function (nodeName, edge, value) { value: function (nodeName, edge, value) {
this.push( this.push(

View File

@@ -211,6 +211,12 @@ function setupTestTree(
if (!isDefaultStyleValue(style, node.style[style])) { if (!isDefaultStyleValue(style, node.style[style])) {
switch (style) { switch (style) {
case 'aspect-ratio':
e.YGNodeStyleSetAspectRatio(
nodeName,
pointValue(e, node.style[style]),
);
break;
case 'gap': case 'gap':
e.YGNodeStyleSetGap( e.YGNodeStyleSetGap(
nodeName, nodeName,
@@ -742,6 +748,7 @@ function getYogaStyle(node) {
'column-gap', 'column-gap',
'row-gap', 'row-gap',
'display', 'display',
'aspect-ratio',
].reduce((map, key) => { ].reduce((map, key) => {
map[key] = map[key] =
node.style[key] || getComputedStyle(node, null).getPropertyValue(key); node.style[key] || getComputedStyle(node, null).getPropertyValue(key);