2017-01-02 02:22:45 -08:00
|
|
|
/**
|
2022-10-04 13:59:32 -07:00
|
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
2017-01-02 02:22:45 -08:00
|
|
|
*
|
2018-02-16 18:24:55 -08:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2017-01-02 02:22:45 -08:00
|
|
|
*/
|
|
|
|
|
2023-07-17 14:27:32 -07:00
|
|
|
/* global Emitter:readable */
|
|
|
|
|
|
|
|
const JavascriptEmitter = function () {
|
2017-01-02 02:22:45 -08:00
|
|
|
Emitter.call(this, 'js', ' ');
|
|
|
|
};
|
|
|
|
|
2017-01-04 04:33:39 -08:00
|
|
|
function toValueJavascript(value) {
|
|
|
|
if (value.match(/^[0-9.e+-]+px$/i)) return parseFloat(value);
|
|
|
|
if (value.match(/^[0-9.e+-]+%/i)) return JSON.stringify(value);
|
2017-02-14 14:26:09 -08:00
|
|
|
if (value == 'Yoga.AUTO') return '"auto"';
|
2024-12-02 17:29:49 -08:00
|
|
|
if (value == 'max-content') return '"max-content"';
|
|
|
|
if (value == 'fit-content') return '"fit-content"';
|
|
|
|
if (value == 'stretch') return '"stretch"';
|
2017-01-04 04:33:39 -08:00
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2017-01-02 02:22:45 -08:00
|
|
|
JavascriptEmitter.prototype = Object.create(Emitter.prototype, {
|
2023-07-17 14:27:32 -07:00
|
|
|
constructor: {value: JavascriptEmitter},
|
|
|
|
|
|
|
|
emitPrologue: {
|
|
|
|
value: function () {
|
2024-06-26 10:00:17 -07:00
|
|
|
this.push(
|
|
|
|
"import { instrinsicSizeMeasureFunc } from '../tools/utils.ts'",
|
|
|
|
);
|
Consolidate JavaScript Flavors (#1433)
Summary:
Fixes https://github.com/facebook/yoga/issues/1417
This dramatically simplifies the matrix of Node vs web, ASM vs WASM, sync vs async compilation, or CommonJS vs ES Modules. We have one variant, using wasm, with ESModule top-level await to do async compilation. Web/node share the same binary, and we base64 encode the WASM into a wrapper JS file for compatibility with Node and bundlers.
This has some downsides, like requiring an environment with top level await, but also has upsides, like a consistent, sync looking API compatible with older Yoga, and mitigating TypeScript issues with package exports and typings resolution.
As part of this work I also removed `ts-node` from the toolchain (at the cost of a couple of config files needing to be vanilla JS).
Pull Request resolved: https://github.com/facebook/yoga/pull/1433
Test Plan:
1. `yarn test`
2. `yarn lint`
3. `yarn tsc`
4. `yarn benchmark`
5. `yarn build` website-next
6. `yarn lint` website-next
7. Locally test website-next
8. Examine package artifact created by GitHub
9. All Automation passes
Reviewed By: yungsters
Differential Revision: D50453324
Pulled By: NickGerleman
fbshipit-source-id: fe1192acc69e57fa69a1ff056dd7b5844d2198d5
2023-10-31 20:41:38 -07:00
|
|
|
this.push("import Yoga from 'yoga-layout';");
|
2023-07-17 14:27:32 -07:00
|
|
|
this.push('import {');
|
|
|
|
this.pushIndent();
|
|
|
|
this.push('Align,');
|
2024-09-25 15:46:55 -07:00
|
|
|
this.push('BoxSizing,');
|
2023-07-17 14:27:32 -07:00
|
|
|
this.push('Direction,');
|
|
|
|
this.push('Display,');
|
|
|
|
this.push('Edge,');
|
|
|
|
this.push('Errata,');
|
|
|
|
this.push('ExperimentalFeature,');
|
|
|
|
this.push('FlexDirection,');
|
|
|
|
this.push('Gutter,');
|
|
|
|
this.push('Justify,');
|
|
|
|
this.push('MeasureMode,');
|
|
|
|
this.push('Overflow,');
|
|
|
|
this.push('PositionType,');
|
|
|
|
this.push('Unit,');
|
|
|
|
this.push('Wrap,');
|
|
|
|
this.popIndent();
|
|
|
|
this.push("} from 'yoga-layout';");
|
|
|
|
this.push('');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
emitTestPrologue: {
|
|
|
|
value: function (name, experiments, ignore) {
|
|
|
|
const testFn = ignore ? `test.skip` : 'test';
|
|
|
|
this.push(`${testFn}('${name}', () => {`);
|
|
|
|
this.pushIndent();
|
|
|
|
this.push('const config = Yoga.Config.create();');
|
|
|
|
this.push('let root;');
|
2017-01-02 02:22:45 -08:00
|
|
|
this.push('');
|
|
|
|
|
2023-07-17 14:27:32 -07:00
|
|
|
if (experiments.length > 0) {
|
|
|
|
for (const experiment of experiments) {
|
|
|
|
this.push(
|
|
|
|
`config.setExperimentalFeatureEnabled(ExperimentalFeature.${experiment}, true);`,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
this.push('');
|
|
|
|
}
|
2017-01-02 02:22:45 -08:00
|
|
|
|
2023-07-17 14:27:32 -07:00
|
|
|
this.push('try {');
|
|
|
|
this.pushIndent();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
emitTestTreePrologue: {
|
|
|
|
value: function (nodeName) {
|
|
|
|
if (nodeName === 'root') {
|
|
|
|
this.push(`root = Yoga.Node.create(config);`);
|
|
|
|
} else {
|
|
|
|
this.push(`const ${nodeName} = Yoga.Node.create(config);`);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
emitTestEpilogue: {
|
|
|
|
value: function (_experiments) {
|
|
|
|
this.popIndent();
|
|
|
|
this.push('} finally {');
|
|
|
|
this.pushIndent();
|
|
|
|
|
|
|
|
this.push("if (typeof root !== 'undefined') {");
|
|
|
|
this.pushIndent();
|
|
|
|
this.push('root.freeRecursive();');
|
|
|
|
this.popIndent();
|
|
|
|
this.push('}');
|
|
|
|
this.push('');
|
|
|
|
this.push('config.free();');
|
2017-01-02 02:22:45 -08:00
|
|
|
|
2023-07-17 14:27:32 -07:00
|
|
|
this.popIndent();
|
|
|
|
this.push('}');
|
2017-01-02 02:22:45 -08:00
|
|
|
|
2023-07-17 14:27:32 -07:00
|
|
|
this.popIndent();
|
|
|
|
this.push('});');
|
|
|
|
},
|
|
|
|
},
|
2022-10-13 08:18:49 -07:00
|
|
|
|
2023-07-17 14:27:32 -07:00
|
|
|
emitEpilogue: {
|
|
|
|
value: function () {
|
|
|
|
this.push('');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
AssertEQ: {
|
|
|
|
value: function (v0, v1) {
|
|
|
|
this.push(`expect(${v1}).toBe(${v0});`);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGAlignAuto: {value: 'Align.Auto'},
|
|
|
|
YGAlignCenter: {value: 'Align.Center'},
|
|
|
|
YGAlignFlexEnd: {value: 'Align.FlexEnd'},
|
|
|
|
YGAlignFlexStart: {value: 'Align.FlexStart'},
|
|
|
|
YGAlignStretch: {value: 'Align.Stretch'},
|
|
|
|
YGAlignSpaceBetween: {value: 'Align.SpaceBetween'},
|
|
|
|
YGAlignSpaceAround: {value: 'Align.SpaceAround'},
|
2023-10-17 20:59:51 -07:00
|
|
|
YGAlignSpaceEvenly: {value: 'Align.SpaceEvenly'},
|
2023-07-17 14:27:32 -07:00
|
|
|
YGAlignBaseline: {value: 'Align.Baseline'},
|
|
|
|
|
|
|
|
YGDirectionInherit: {value: 'Direction.Inherit'},
|
|
|
|
YGDirectionLTR: {value: 'Direction.LTR'},
|
|
|
|
YGDirectionRTL: {value: 'Direction.RTL'},
|
|
|
|
|
|
|
|
YGEdgeBottom: {value: 'Edge.Bottom'},
|
|
|
|
YGEdgeEnd: {value: 'Edge.End'},
|
|
|
|
YGEdgeLeft: {value: 'Edge.Left'},
|
|
|
|
YGEdgeRight: {value: 'Edge.Right'},
|
|
|
|
YGEdgeStart: {value: 'Edge.Start'},
|
|
|
|
YGEdgeTop: {value: 'Edge.Top'},
|
|
|
|
|
|
|
|
YGGutterAll: {value: 'Gutter.All'},
|
|
|
|
YGGutterColumn: {value: 'Gutter.Column'},
|
|
|
|
YGGutterRow: {value: 'Gutter.Row'},
|
|
|
|
|
|
|
|
YGFlexDirectionColumn: {value: 'FlexDirection.Column'},
|
|
|
|
YGFlexDirectionColumnReverse: {value: 'FlexDirection.ColumnReverse'},
|
|
|
|
YGFlexDirectionRow: {value: 'FlexDirection.Row'},
|
|
|
|
YGFlexDirectionRowReverse: {value: 'FlexDirection.RowReverse'},
|
|
|
|
|
|
|
|
YGJustifyCenter: {value: 'Justify.Center'},
|
|
|
|
YGJustifyFlexEnd: {value: 'Justify.FlexEnd'},
|
|
|
|
YGJustifyFlexStart: {value: 'Justify.FlexStart'},
|
|
|
|
YGJustifySpaceAround: {value: 'Justify.SpaceAround'},
|
|
|
|
YGJustifySpaceBetween: {value: 'Justify.SpaceBetween'},
|
|
|
|
YGJustifySpaceEvenly: {value: 'Justify.SpaceEvenly'},
|
|
|
|
|
|
|
|
YGOverflowHidden: {value: 'Overflow.Hidden'},
|
|
|
|
YGOverflowVisible: {value: 'Overflow.Visible'},
|
2023-10-12 15:02:00 -07:00
|
|
|
YGOverflowScroll: {value: 'Overflow.Scroll'},
|
2023-07-17 14:27:32 -07:00
|
|
|
|
|
|
|
YGPositionTypeAbsolute: {value: 'PositionType.Absolute'},
|
|
|
|
YGPositionTypeRelative: {value: 'PositionType.Relative'},
|
2023-10-23 18:20:24 -07:00
|
|
|
YGPositionTypeStatic: {value: 'PositionType.Static'},
|
2023-07-17 14:27:32 -07:00
|
|
|
|
|
|
|
YGAuto: {value: "'auto'"},
|
|
|
|
YGUndefined: {value: 'undefined'},
|
|
|
|
|
|
|
|
YGWrapNoWrap: {value: 'Wrap.NoWrap'},
|
|
|
|
YGWrapWrap: {value: 'Wrap.Wrap'},
|
|
|
|
YGWrapWrapReverse: {value: 'Wrap.WrapReverse'},
|
|
|
|
|
|
|
|
YGDisplayFlex: {value: 'Display.Flex'},
|
|
|
|
YGDisplayNone: {value: 'Display.None'},
|
Add support for `display: contents` style (#1726)
Summary:
X-link: https://github.com/facebook/react-native/pull/47035
This PR adds support for `display: contents` style by effectively skipping nodes with `display: contents` set during layout.
This required changes in the logic related to children traversal - before this PR a node would be always laid out in the context of its direct parent. After this PR that assumption is no longer true - `display: contents` allows nodes to be skipped, i.e.:
```html
<div id="node1">
<div id="node2" style="display: contents;">
<div id="node3" />
</div>
</div>
```
`node3` will be laid out as if it were a child of `node1`.
Because of this, iterating over direct children of a node is no longer correct to achieve the correct layout. This PR introduces `LayoutableChildren::Iterator` which can traverse the subtree of a given node in a way that nodes with `display: contents` are replaced with their concrete children.
A tree like this:
```mermaid
flowchart TD
A((A))
B((B))
C((C))
D((D))
E((E))
F((F))
G((G))
H((H))
I((I))
J((J))
A --> B
A --> C
B --> D
B --> E
C --> F
D --> G
F --> H
G --> I
H --> J
style B fill:https://github.com/facebook/yoga/issues/050
style C fill:https://github.com/facebook/yoga/issues/050
style D fill:https://github.com/facebook/yoga/issues/050
style H fill:https://github.com/facebook/yoga/issues/050
style I fill:https://github.com/facebook/yoga/issues/050
```
would be laid out as if the green nodes (ones with `display: contents`) did not exist. It also changes the logic where children were accessed by index to use the iterator instead as random access would be non-trivial to implement and it's not really necessary - the iteration was always sequential and indices were only used as boundaries.
There's one place where knowledge of layoutable children is required to calculate the gap. An optimization for this is for a node to keep a counter of how many `display: contents` nodes are its children. If there are none, a short path of just returning the size of the children vector can be taken, otherwise it needs to iterate over layoutable children and count them, since the structure may be complex.
One more major change this PR introduces is `cleanupContentsNodesRecursively`. Since nodes with `display: contents` would be entirely skipped during the layout pass, they would keep previous metrics, would be kept as dirty, and, in the case of nested `contents` nodes, would not be cloned, breaking `doesOwn` relation. All of this is handled in the new method which clones `contents` nodes recursively, sets empty layout, and marks them as clean and having a new layout so that it can be used on the React Native side.
Relies on https://github.com/facebook/yoga/pull/1725
Changelog: [Internal]
Pull Request resolved: https://github.com/facebook/yoga/pull/1726
Test Plan: Added tests for `display: contents` based on existing tests for `display: none` and ensured that all the tests were passing.
Reviewed By: joevilches
Differential Revision: D64404340
Pulled By: NickGerleman
fbshipit-source-id: f6f6e9a6fad82873f18c8a0ead58aad897df5d09
2024-10-18 22:05:41 -07:00
|
|
|
YGDisplayContents: {value: 'Display.Contents'},
|
2023-07-17 14:27:32 -07:00
|
|
|
|
2024-09-25 15:46:55 -07:00
|
|
|
YGBoxSizingBorderBox: {value: 'BoxSizing.BorderBox'},
|
|
|
|
YGBoxSizingContentBox: {value: 'BoxSizing.ContentBox'},
|
|
|
|
|
2024-12-02 17:29:49 -08:00
|
|
|
YGMaxContent: {value: 'max-content'},
|
|
|
|
YGFitContent: {value: 'fit-content'},
|
|
|
|
YGStretch: {value: 'stretch'},
|
|
|
|
|
2023-07-17 14:27:32 -07:00
|
|
|
YGNodeCalculateLayout: {
|
|
|
|
value: function (node, dir, _experiments) {
|
|
|
|
this.push(node + '.calculateLayout(undefined, undefined, ' + dir + ');');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeInsertChild: {
|
|
|
|
value: function (parentName, nodeName, index) {
|
|
|
|
this.push(parentName + '.insertChild(' + nodeName + ', ' + index + ');');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeLayoutGetLeft: {
|
|
|
|
value: function (nodeName) {
|
|
|
|
return nodeName + '.getComputedLeft()';
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeLayoutGetTop: {
|
|
|
|
value: function (nodeName) {
|
|
|
|
return nodeName + '.getComputedTop()';
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeLayoutGetWidth: {
|
|
|
|
value: function (nodeName) {
|
|
|
|
return nodeName + '.getComputedWidth()';
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeLayoutGetHeight: {
|
|
|
|
value: function (nodeName) {
|
|
|
|
return nodeName + '.getComputedHeight()';
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetAlignContent: {
|
|
|
|
value: function (nodeName, value) {
|
|
|
|
this.push(
|
|
|
|
nodeName + '.setAlignContent(' + toValueJavascript(value) + ');',
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetAlignItems: {
|
|
|
|
value: function (nodeName, value) {
|
|
|
|
this.push(nodeName + '.setAlignItems(' + toValueJavascript(value) + ');');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetAlignSelf: {
|
|
|
|
value: function (nodeName, value) {
|
|
|
|
this.push(nodeName + '.setAlignSelf(' + toValueJavascript(value) + ');');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2023-10-12 15:02:00 -07:00
|
|
|
YGNodeStyleSetAspectRatio: {
|
|
|
|
value: function (nodeName, value) {
|
|
|
|
this.push(
|
|
|
|
nodeName + '.setAspectRatio(' + toValueJavascript(value) + ');',
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2023-07-17 14:27:32 -07:00
|
|
|
YGNodeStyleSetBorder: {
|
|
|
|
value: function (nodeName, edge, value) {
|
|
|
|
this.push(
|
|
|
|
nodeName +
|
|
|
|
'.setBorder(' +
|
|
|
|
toValueJavascript(edge) +
|
|
|
|
', ' +
|
|
|
|
toValueJavascript(value) +
|
|
|
|
');',
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetDirection: {
|
|
|
|
value: function (nodeName, value) {
|
|
|
|
this.push(nodeName + '.setDirection(' + toValueJavascript(value) + ');');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetDisplay: {
|
|
|
|
value: function (nodeName, value) {
|
|
|
|
this.push(nodeName + '.setDisplay(' + toValueJavascript(value) + ');');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetFlexBasis: {
|
|
|
|
value: function (nodeName, value) {
|
|
|
|
this.push(nodeName + '.setFlexBasis(' + toValueJavascript(value) + ');');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetFlexDirection: {
|
|
|
|
value: function (nodeName, value) {
|
|
|
|
this.push(
|
|
|
|
nodeName + '.setFlexDirection(' + toValueJavascript(value) + ');',
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetFlexGrow: {
|
|
|
|
value: function (nodeName, value) {
|
|
|
|
this.push(nodeName + '.setFlexGrow(' + toValueJavascript(value) + ');');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetFlexShrink: {
|
|
|
|
value: function (nodeName, value) {
|
|
|
|
this.push(nodeName + '.setFlexShrink(' + toValueJavascript(value) + ');');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetFlexWrap: {
|
|
|
|
value: function (nodeName, value) {
|
|
|
|
this.push(nodeName + '.setFlexWrap(' + toValueJavascript(value) + ');');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetHeight: {
|
|
|
|
value: function (nodeName, value) {
|
|
|
|
this.push(nodeName + '.setHeight(' + toValueJavascript(value) + ');');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetJustifyContent: {
|
|
|
|
value: function (nodeName, value) {
|
|
|
|
this.push(
|
|
|
|
nodeName + '.setJustifyContent(' + toValueJavascript(value) + ');',
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetMargin: {
|
|
|
|
value: function (nodeName, edge, value) {
|
|
|
|
this.push(
|
|
|
|
nodeName +
|
|
|
|
'.setMargin(' +
|
|
|
|
toValueJavascript(edge) +
|
|
|
|
', ' +
|
|
|
|
toValueJavascript(value) +
|
|
|
|
');',
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetMaxHeight: {
|
|
|
|
value: function (nodeName, value) {
|
|
|
|
this.push(nodeName + '.setMaxHeight(' + toValueJavascript(value) + ');');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetMaxWidth: {
|
|
|
|
value: function (nodeName, value) {
|
|
|
|
this.push(nodeName + '.setMaxWidth(' + toValueJavascript(value) + ');');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetMinHeight: {
|
|
|
|
value: function (nodeName, value) {
|
|
|
|
this.push(nodeName + '.setMinHeight(' + toValueJavascript(value) + ');');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetMinWidth: {
|
|
|
|
value: function (nodeName, value) {
|
|
|
|
this.push(nodeName + '.setMinWidth(' + toValueJavascript(value) + ');');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetOverflow: {
|
|
|
|
value: function (nodeName, value) {
|
|
|
|
this.push(nodeName + '.setOverflow(' + toValueJavascript(value) + ');');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetPadding: {
|
|
|
|
value: function (nodeName, edge, value) {
|
|
|
|
this.push(
|
|
|
|
nodeName +
|
|
|
|
'.setPadding(' +
|
|
|
|
toValueJavascript(edge) +
|
|
|
|
', ' +
|
|
|
|
toValueJavascript(value) +
|
|
|
|
');',
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetPosition: {
|
|
|
|
value: function (nodeName, edge, value) {
|
2024-08-27 06:00:34 -07:00
|
|
|
const valueStr = toValueJavascript(value);
|
|
|
|
|
|
|
|
if (valueStr == "'auto'") {
|
|
|
|
this.push(
|
|
|
|
nodeName + '.setPositionAuto(' + toValueJavascript(edge) + ');',
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
this.push(
|
|
|
|
nodeName +
|
|
|
|
'.setPosition(' +
|
|
|
|
toValueJavascript(edge) +
|
|
|
|
', ' +
|
|
|
|
valueStr +
|
|
|
|
');',
|
|
|
|
);
|
|
|
|
}
|
2023-07-17 14:27:32 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetPositionType: {
|
|
|
|
value: function (nodeName, value) {
|
|
|
|
this.push(
|
|
|
|
nodeName + '.setPositionType(' + toValueJavascript(value) + ');',
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetWidth: {
|
|
|
|
value: function (nodeName, value) {
|
|
|
|
this.push(nodeName + '.setWidth(' + toValueJavascript(value) + ');');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetGap: {
|
|
|
|
value: function (nodeName, gap, value) {
|
|
|
|
this.push(
|
|
|
|
nodeName +
|
|
|
|
'.setGap(' +
|
|
|
|
toValueJavascript(gap) +
|
|
|
|
', ' +
|
|
|
|
toValueJavascript(value) +
|
|
|
|
');',
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
2024-06-26 10:00:17 -07:00
|
|
|
|
2024-09-25 15:46:55 -07:00
|
|
|
YGNodeStyleSetBoxSizing: {
|
|
|
|
value: function (nodeName, value) {
|
|
|
|
this.push(nodeName + '.setBoxSizing(' + toValueJavascript(value) + ');');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2024-06-26 10:00:17 -07:00
|
|
|
YGNodeSetMeasureFunc: {
|
2024-12-12 11:11:49 -08:00
|
|
|
value: function (nodeName, innerText, flexDirection) {
|
2024-06-26 10:00:17 -07:00
|
|
|
this.push(
|
2024-12-12 11:11:49 -08:00
|
|
|
`${nodeName}.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "${innerText}", flexDirection: ${toValueJavascript(
|
|
|
|
flexDirection,
|
|
|
|
)}}));`,
|
2024-06-26 10:00:17 -07:00
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
2017-01-02 02:22:45 -08:00
|
|
|
});
|