From a8763723576f7071a716aa90d782e79adc97ea91 Mon Sep 17 00:00:00 2001 From: Eric Rozell Date: Thu, 12 Oct 2023 15:02:00 -0700 Subject: [PATCH] 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 --- gentest/gentest-cpp.js | 14 ++++++++++++++ gentest/gentest-java.js | 6 ++++++ gentest/gentest-javascript.js | 8 ++++++++ gentest/gentest.js | 7 +++++++ 4 files changed, 35 insertions(+) diff --git a/gentest/gentest-cpp.js b/gentest/gentest-cpp.js index f04e6db2..b174efd2 100644 --- a/gentest/gentest-cpp.js +++ b/gentest/gentest-cpp.js @@ -219,6 +219,20 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { }, }, + YGNodeStyleSetAspectRatio: { + value: function (nodeName, value) { + this.push( + 'YGNodeStyleSetAspectRatio' + + toFunctionName(value) + + '(' + + nodeName + + ', ' + + toValueCpp(value) + + ');', + ); + }, + }, + YGNodeStyleSetBorder: { value: function (nodeName, edge, value) { this.push( diff --git a/gentest/gentest-java.js b/gentest/gentest-java.js index 3d82b246..b6ec6733 100644 --- a/gentest/gentest-java.js +++ b/gentest/gentest-java.js @@ -239,6 +239,12 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, { }, }, + YGNodeStyleSetAspectRatio: { + value: function (nodeName, value) { + this.push(nodeName + '.setAspectRatio(' + toValueJava(value) + 'f);'); + }, + }, + YGNodeStyleSetBorder: { value: function (nodeName, edge, value) { this.push( diff --git a/gentest/gentest-javascript.js b/gentest/gentest-javascript.js index c847cc7e..c2197f26 100644 --- a/gentest/gentest-javascript.js +++ b/gentest/gentest-javascript.js @@ -222,6 +222,14 @@ JavascriptEmitter.prototype = Object.create(Emitter.prototype, { }, }, + YGNodeStyleSetAspectRatio: { + value: function (nodeName, value) { + this.push( + nodeName + '.setAspectRatio(' + toValueJavascript(value) + ');', + ); + }, + }, + YGNodeStyleSetBorder: { value: function (nodeName, edge, value) { this.push( diff --git a/gentest/gentest.js b/gentest/gentest.js index 5cd500a0..af645b92 100755 --- a/gentest/gentest.js +++ b/gentest/gentest.js @@ -211,6 +211,12 @@ function setupTestTree( if (!isDefaultStyleValue(style, node.style[style])) { switch (style) { + case 'aspect-ratio': + e.YGNodeStyleSetAspectRatio( + nodeName, + pointValue(e, node.style[style]), + ); + break; case 'gap': e.YGNodeStyleSetGap( nodeName, @@ -742,6 +748,7 @@ function getYogaStyle(node) { 'column-gap', 'row-gap', 'display', + 'aspect-ratio', ].reduce((map, key) => { map[key] = node.style[key] || getComputedStyle(node, null).getPropertyValue(key);