2016-10-23 10:27:30 -07:00
|
|
|
/**
|
2022-10-04 13:59:32 -07:00
|
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
2016-10-23 10:27:30 -07: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.
|
2016-10-23 10:27:30 -07:00
|
|
|
*/
|
|
|
|
|
2023-07-17 14:27:32 -07:00
|
|
|
/* global Emitter:readable */
|
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
function toValueCpp(value) {
|
2023-07-17 14:27:32 -07:00
|
|
|
const n = value.toString().replace('px', '').replace('%', '');
|
2016-11-22 02:46:00 -08:00
|
|
|
return n + (Number(n) == n && n % 1 !== 0 ? 'f' : '');
|
|
|
|
}
|
|
|
|
|
2024-10-09 19:20:15 -07:00
|
|
|
function toFunctionNameCpp(value) {
|
2017-02-14 14:26:09 -08:00
|
|
|
if (value.indexOf('%') >= 0) {
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
return 'Percent';
|
2023-07-17 14:27:32 -07:00
|
|
|
} else if (value.indexOf('Auto') >= 0) {
|
2017-02-14 14:26:09 -08:00
|
|
|
return 'Auto';
|
2024-12-02 17:29:49 -08:00
|
|
|
} else if (value.indexOf('MaxContent') >= 0) {
|
|
|
|
return 'MaxContent';
|
|
|
|
} else if (value.indexOf('FitContent') >= 0) {
|
|
|
|
return 'FitContent';
|
|
|
|
} else if (value.indexOf('Stretch') >= 0) {
|
|
|
|
return 'Stretch';
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
}
|
2024-12-02 17:29:49 -08:00
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
2024-10-09 19:20:15 -07:00
|
|
|
function keywordFunctionCpp(functionPrefix, nodeName, value) {
|
|
|
|
const functionSuffix = toFunctionNameCpp(value);
|
2024-12-02 17:29:49 -08:00
|
|
|
if (
|
|
|
|
functionSuffix == 'Auto' ||
|
|
|
|
functionSuffix == 'MaxContent' ||
|
|
|
|
functionSuffix == 'FitContent' ||
|
|
|
|
functionSuffix == 'Stretch'
|
|
|
|
) {
|
2024-10-09 19:20:15 -07:00
|
|
|
return functionPrefix + functionSuffix + '(' + nodeName + ');';
|
|
|
|
} else {
|
|
|
|
return (
|
|
|
|
functionPrefix +
|
|
|
|
functionSuffix +
|
|
|
|
'(' +
|
|
|
|
nodeName +
|
|
|
|
', ' +
|
|
|
|
toValueCpp(value) +
|
|
|
|
');'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-17 14:27:32 -07:00
|
|
|
const CPPEmitter = function () {
|
2016-10-23 10:27:30 -07:00
|
|
|
Emitter.call(this, 'cpp', ' ');
|
|
|
|
};
|
|
|
|
|
|
|
|
CPPEmitter.prototype = Object.create(Emitter.prototype, {
|
2023-07-17 14:27:32 -07:00
|
|
|
constructor: {value: CPPEmitter},
|
|
|
|
|
|
|
|
emitPrologue: {
|
|
|
|
value: function () {
|
2024-06-26 10:00:17 -07:00
|
|
|
this.push([
|
|
|
|
'#include <gtest/gtest.h>',
|
|
|
|
'#include <yoga/Yoga.h>',
|
|
|
|
'#include "../util/TestUtil.h"',
|
|
|
|
'',
|
|
|
|
]);
|
2023-07-17 14:27:32 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
emitTestPrologue: {
|
|
|
|
value: function (name, experiments, disabled) {
|
|
|
|
this.push('TEST(YogaTest, ' + name + ') {');
|
|
|
|
this.pushIndent();
|
|
|
|
|
|
|
|
if (disabled) {
|
|
|
|
this.push('GTEST_SKIP();');
|
|
|
|
this.push('');
|
|
|
|
}
|
|
|
|
|
2024-07-03 17:30:10 -07:00
|
|
|
this.push('YGConfigRef config = YGConfigNew();');
|
2023-07-17 14:27:32 -07:00
|
|
|
for (const i in experiments) {
|
|
|
|
this.push(
|
|
|
|
'YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeature' +
|
|
|
|
experiments[i] +
|
|
|
|
', true);',
|
|
|
|
);
|
|
|
|
}
|
2023-05-10 22:46:39 -07:00
|
|
|
this.push('');
|
2023-07-17 14:27:32 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
emitTestTreePrologue: {
|
|
|
|
value: function (nodeName) {
|
2024-07-03 17:30:10 -07:00
|
|
|
this.push('YGNodeRef ' + nodeName + ' = YGNodeNewWithConfig(config);');
|
2023-07-17 14:27:32 -07:00
|
|
|
},
|
|
|
|
},
|
2016-10-23 10:27:30 -07:00
|
|
|
|
2023-07-17 14:27:32 -07:00
|
|
|
emitTestEpilogue: {
|
|
|
|
value: function (_experiments) {
|
|
|
|
this.push(['', 'YGNodeFreeRecursive(root);']);
|
2016-10-23 10:27:30 -07:00
|
|
|
|
2023-07-17 14:27:32 -07:00
|
|
|
this.push('');
|
|
|
|
this.push('YGConfigFree(config);');
|
|
|
|
|
|
|
|
this.popIndent();
|
|
|
|
this.push(['}', '']);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
emitEpilogue: {value: function () {}},
|
|
|
|
|
|
|
|
AssertEQ: {
|
|
|
|
value: function (v0, v1) {
|
|
|
|
this.push('ASSERT_FLOAT_EQ(' + toValueCpp(v0) + ', ' + v1 + ');');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGAlignAuto: {value: 'YGAlignAuto'},
|
|
|
|
YGAlignCenter: {value: 'YGAlignCenter'},
|
|
|
|
YGAlignFlexEnd: {value: 'YGAlignFlexEnd'},
|
|
|
|
YGAlignFlexStart: {value: 'YGAlignFlexStart'},
|
|
|
|
YGAlignStretch: {value: 'YGAlignStretch'},
|
|
|
|
YGAlignSpaceBetween: {value: 'YGAlignSpaceBetween'},
|
|
|
|
YGAlignSpaceAround: {value: 'YGAlignSpaceAround'},
|
2023-10-17 20:59:51 -07:00
|
|
|
YGAlignSpaceEvenly: {value: 'YGAlignSpaceEvenly'},
|
2023-07-17 14:27:32 -07:00
|
|
|
YGAlignBaseline: {value: 'YGAlignBaseline'},
|
|
|
|
|
|
|
|
YGDirectionInherit: {value: 'YGDirectionInherit'},
|
|
|
|
YGDirectionLTR: {value: 'YGDirectionLTR'},
|
|
|
|
YGDirectionRTL: {value: 'YGDirectionRTL'},
|
|
|
|
|
|
|
|
YGEdgeBottom: {value: 'YGEdgeBottom'},
|
|
|
|
YGEdgeEnd: {value: 'YGEdgeEnd'},
|
|
|
|
YGEdgeLeft: {value: 'YGEdgeLeft'},
|
|
|
|
YGEdgeRight: {value: 'YGEdgeRight'},
|
|
|
|
YGEdgeStart: {value: 'YGEdgeStart'},
|
|
|
|
YGEdgeTop: {value: 'YGEdgeTop'},
|
|
|
|
|
|
|
|
YGGutterAll: {value: 'YGGutterAll'},
|
|
|
|
YGGutterColumn: {value: 'YGGutterColumn'},
|
|
|
|
YGGutterRow: {value: 'YGGutterRow'},
|
|
|
|
|
|
|
|
YGFlexDirectionColumn: {value: 'YGFlexDirectionColumn'},
|
|
|
|
YGFlexDirectionColumnReverse: {value: 'YGFlexDirectionColumnReverse'},
|
|
|
|
YGFlexDirectionRow: {value: 'YGFlexDirectionRow'},
|
|
|
|
YGFlexDirectionRowReverse: {value: 'YGFlexDirectionRowReverse'},
|
|
|
|
|
|
|
|
YGJustifyCenter: {value: 'YGJustifyCenter'},
|
|
|
|
YGJustifyFlexEnd: {value: 'YGJustifyFlexEnd'},
|
|
|
|
YGJustifyFlexStart: {value: 'YGJustifyFlexStart'},
|
|
|
|
YGJustifySpaceAround: {value: 'YGJustifySpaceAround'},
|
|
|
|
YGJustifySpaceBetween: {value: 'YGJustifySpaceBetween'},
|
|
|
|
YGJustifySpaceEvenly: {value: 'YGJustifySpaceEvenly'},
|
|
|
|
|
|
|
|
YGOverflowHidden: {value: 'YGOverflowHidden'},
|
|
|
|
YGOverflowVisible: {value: 'YGOverflowVisible'},
|
2023-10-12 15:02:00 -07:00
|
|
|
YGOverflowScroll: {value: 'YGOverflowScroll'},
|
2023-07-17 14:27:32 -07:00
|
|
|
|
|
|
|
YGPositionTypeAbsolute: {value: 'YGPositionTypeAbsolute'},
|
|
|
|
YGPositionTypeRelative: {value: 'YGPositionTypeRelative'},
|
2023-10-23 18:20:24 -07:00
|
|
|
YGPositionTypeStatic: {value: 'YGPositionTypeStatic'},
|
2023-07-17 14:27:32 -07:00
|
|
|
|
|
|
|
YGWrapNoWrap: {value: 'YGWrapNoWrap'},
|
|
|
|
YGWrapWrap: {value: 'YGWrapWrap'},
|
|
|
|
YGWrapWrapReverse: {value: 'YGWrapWrapReverse'},
|
|
|
|
|
2024-09-25 15:46:55 -07:00
|
|
|
YGBoxSizingBorderBox: {value: 'YGBoxSizingBorderBox'},
|
|
|
|
YGBoxSizingContentBox: {value: 'YGBoxSizingContentBox'},
|
|
|
|
|
2023-07-17 14:27:32 -07:00
|
|
|
YGUndefined: {value: 'YGUndefined'},
|
|
|
|
|
|
|
|
YGDisplayFlex: {value: 'YGDisplayFlex'},
|
|
|
|
YGDisplayNone: {value: 'YGDisplayNone'},
|
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: 'YGDisplayContents'},
|
2023-07-17 14:27:32 -07:00
|
|
|
YGAuto: {value: 'YGAuto'},
|
|
|
|
|
2024-12-02 17:29:49 -08:00
|
|
|
YGMaxContent: {value: 'MaxContent'},
|
|
|
|
YGFitContent: {value: 'FitContent'},
|
|
|
|
YGStretch: {value: 'Stretch'},
|
|
|
|
|
2023-07-17 14:27:32 -07:00
|
|
|
YGNodeCalculateLayout: {
|
|
|
|
value: function (node, dir, _experiments) {
|
|
|
|
this.push(
|
|
|
|
'YGNodeCalculateLayout(' +
|
|
|
|
node +
|
|
|
|
', YGUndefined, YGUndefined, ' +
|
|
|
|
dir +
|
|
|
|
');',
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeInsertChild: {
|
|
|
|
value: function (parentName, nodeName, index) {
|
|
|
|
this.push(
|
|
|
|
'YGNodeInsertChild(' +
|
|
|
|
parentName +
|
|
|
|
', ' +
|
|
|
|
nodeName +
|
|
|
|
', ' +
|
|
|
|
index +
|
|
|
|
');',
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeLayoutGetLeft: {
|
|
|
|
value: function (nodeName) {
|
|
|
|
return 'YGNodeLayoutGetLeft(' + nodeName + ')';
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeLayoutGetTop: {
|
|
|
|
value: function (nodeName) {
|
|
|
|
return 'YGNodeLayoutGetTop(' + nodeName + ')';
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeLayoutGetWidth: {
|
|
|
|
value: function (nodeName) {
|
|
|
|
return 'YGNodeLayoutGetWidth(' + nodeName + ')';
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeLayoutGetHeight: {
|
|
|
|
value: function (nodeName) {
|
|
|
|
return 'YGNodeLayoutGetHeight(' + nodeName + ')';
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetAlignContent: {
|
|
|
|
value: function (nodeName, value) {
|
|
|
|
this.push(
|
|
|
|
'YGNodeStyleSetAlignContent(' +
|
|
|
|
nodeName +
|
|
|
|
', ' +
|
|
|
|
toValueCpp(value) +
|
|
|
|
');',
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetAlignItems: {
|
|
|
|
value: function (nodeName, value) {
|
|
|
|
this.push(
|
|
|
|
'YGNodeStyleSetAlignItems(' +
|
|
|
|
nodeName +
|
|
|
|
', ' +
|
|
|
|
toValueCpp(value) +
|
|
|
|
');',
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetAlignSelf: {
|
|
|
|
value: function (nodeName, value) {
|
|
|
|
this.push(
|
|
|
|
'YGNodeStyleSetAlignSelf(' + nodeName + ', ' + toValueCpp(value) + ');',
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2023-10-12 15:02:00 -07:00
|
|
|
YGNodeStyleSetAspectRatio: {
|
|
|
|
value: function (nodeName, value) {
|
|
|
|
this.push(
|
|
|
|
'YGNodeStyleSetAspectRatio' +
|
2024-10-09 19:20:15 -07:00
|
|
|
toFunctionNameCpp(value) +
|
2023-10-12 15:02:00 -07:00
|
|
|
'(' +
|
|
|
|
nodeName +
|
|
|
|
', ' +
|
|
|
|
toValueCpp(value) +
|
|
|
|
');',
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2023-07-17 14:27:32 -07:00
|
|
|
YGNodeStyleSetBorder: {
|
|
|
|
value: function (nodeName, edge, value) {
|
|
|
|
this.push(
|
|
|
|
'YGNodeStyleSetBorder(' +
|
|
|
|
nodeName +
|
|
|
|
', ' +
|
|
|
|
edge +
|
|
|
|
', ' +
|
|
|
|
toValueCpp(value) +
|
|
|
|
');',
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetDirection: {
|
|
|
|
value: function (nodeName, value) {
|
|
|
|
this.push(
|
|
|
|
'YGNodeStyleSetDirection(' + nodeName + ', ' + toValueCpp(value) + ');',
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetDisplay: {
|
|
|
|
value: function (nodeName, value) {
|
|
|
|
this.push(
|
|
|
|
'YGNodeStyleSetDisplay(' + nodeName + ', ' + toValueCpp(value) + ');',
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetFlexBasis: {
|
|
|
|
value: function (nodeName, value) {
|
2024-10-09 19:20:15 -07:00
|
|
|
this.push(keywordFunctionCpp('YGNodeStyleSetFlexBasis', nodeName, value));
|
2023-07-17 14:27:32 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetFlexDirection: {
|
|
|
|
value: function (nodeName, value) {
|
|
|
|
this.push(
|
|
|
|
'YGNodeStyleSetFlexDirection(' +
|
|
|
|
nodeName +
|
|
|
|
', ' +
|
|
|
|
toValueCpp(value) +
|
|
|
|
');',
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetFlexGrow: {
|
|
|
|
value: function (nodeName, value) {
|
|
|
|
this.push(
|
|
|
|
'YGNodeStyleSetFlexGrow(' + nodeName + ', ' + toValueCpp(value) + ');',
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetFlexShrink: {
|
|
|
|
value: function (nodeName, value) {
|
|
|
|
this.push(
|
|
|
|
'YGNodeStyleSetFlexShrink(' +
|
|
|
|
nodeName +
|
|
|
|
', ' +
|
|
|
|
toValueCpp(value) +
|
|
|
|
');',
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetFlexWrap: {
|
|
|
|
value: function (nodeName, value) {
|
|
|
|
this.push(
|
|
|
|
'YGNodeStyleSetFlexWrap(' + nodeName + ', ' + toValueCpp(value) + ');',
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetJustifyContent: {
|
|
|
|
value: function (nodeName, value) {
|
|
|
|
this.push(
|
|
|
|
'YGNodeStyleSetJustifyContent(' +
|
|
|
|
nodeName +
|
|
|
|
', ' +
|
|
|
|
toValueCpp(value) +
|
|
|
|
');',
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetMargin: {
|
|
|
|
value: function (nodeName, edge, value) {
|
|
|
|
let valueStr = toValueCpp(value);
|
|
|
|
if (valueStr != 'YGAuto') {
|
|
|
|
valueStr = ', ' + valueStr;
|
|
|
|
} else {
|
|
|
|
valueStr = '';
|
|
|
|
}
|
|
|
|
this.push(
|
|
|
|
'YGNodeStyleSetMargin' +
|
2024-10-09 19:20:15 -07:00
|
|
|
toFunctionNameCpp(value) +
|
2023-07-17 14:27:32 -07:00
|
|
|
'(' +
|
|
|
|
nodeName +
|
|
|
|
', ' +
|
|
|
|
edge +
|
|
|
|
valueStr +
|
|
|
|
');',
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2024-10-09 19:20:15 -07:00
|
|
|
YGNodeStyleSetHeight: {
|
|
|
|
value: function (nodeName, value) {
|
|
|
|
this.push(keywordFunctionCpp('YGNodeStyleSetHeight', nodeName, value));
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetWidth: {
|
|
|
|
value: function (nodeName, value) {
|
|
|
|
this.push(keywordFunctionCpp('YGNodeStyleSetWidth', nodeName, value));
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2023-07-17 14:27:32 -07:00
|
|
|
YGNodeStyleSetMaxHeight: {
|
|
|
|
value: function (nodeName, value) {
|
2024-12-02 17:29:49 -08:00
|
|
|
this.push(keywordFunctionCpp('YGNodeStyleSetMaxHeight', nodeName, value));
|
2023-07-17 14:27:32 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetMaxWidth: {
|
|
|
|
value: function (nodeName, value) {
|
2024-12-02 17:29:49 -08:00
|
|
|
this.push(keywordFunctionCpp('YGNodeStyleSetMaxWidth', nodeName, value));
|
2023-07-17 14:27:32 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetMinHeight: {
|
|
|
|
value: function (nodeName, value) {
|
2024-12-02 17:29:49 -08:00
|
|
|
this.push(keywordFunctionCpp('YGNodeStyleSetMinHeight', nodeName, value));
|
2023-07-17 14:27:32 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetMinWidth: {
|
|
|
|
value: function (nodeName, value) {
|
2024-12-02 17:29:49 -08:00
|
|
|
this.push(keywordFunctionCpp('YGNodeStyleSetMinWidth', nodeName, value));
|
2023-07-17 14:27:32 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetOverflow: {
|
|
|
|
value: function (nodeName, value) {
|
|
|
|
this.push(
|
|
|
|
'YGNodeStyleSetOverflow(' + nodeName + ', ' + toValueCpp(value) + ');',
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetPadding: {
|
|
|
|
value: function (nodeName, edge, value) {
|
|
|
|
this.push(
|
|
|
|
'YGNodeStyleSetPadding' +
|
2024-10-09 19:20:15 -07:00
|
|
|
toFunctionNameCpp(value) +
|
2023-07-17 14:27:32 -07:00
|
|
|
'(' +
|
|
|
|
nodeName +
|
|
|
|
', ' +
|
|
|
|
edge +
|
|
|
|
', ' +
|
|
|
|
toValueCpp(value) +
|
|
|
|
');',
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetPosition: {
|
|
|
|
value: function (nodeName, edge, value) {
|
2024-08-27 06:00:34 -07:00
|
|
|
let valueStr = toValueCpp(value);
|
|
|
|
if (valueStr != 'YGAuto') {
|
|
|
|
valueStr = ', ' + valueStr;
|
|
|
|
} else {
|
|
|
|
valueStr = '';
|
|
|
|
}
|
2023-07-17 14:27:32 -07:00
|
|
|
this.push(
|
|
|
|
'YGNodeStyleSetPosition' +
|
2024-10-09 19:20:15 -07:00
|
|
|
toFunctionNameCpp(value) +
|
2023-07-17 14:27:32 -07:00
|
|
|
'(' +
|
|
|
|
nodeName +
|
|
|
|
', ' +
|
|
|
|
edge +
|
2024-08-27 06:00:34 -07:00
|
|
|
valueStr +
|
2023-07-17 14:27:32 -07:00
|
|
|
');',
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetPositionType: {
|
|
|
|
value: function (nodeName, value) {
|
|
|
|
this.push(
|
|
|
|
'YGNodeStyleSetPositionType(' +
|
|
|
|
nodeName +
|
|
|
|
', ' +
|
|
|
|
toValueCpp(value) +
|
|
|
|
');',
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
YGNodeStyleSetGap: {
|
|
|
|
value: function (nodeName, gap, value) {
|
|
|
|
this.push(
|
|
|
|
'YGNodeStyleSetGap' +
|
2024-10-09 19:20:15 -07:00
|
|
|
toFunctionNameCpp(value) +
|
2023-07-17 14:27:32 -07:00
|
|
|
'(' +
|
|
|
|
nodeName +
|
|
|
|
', ' +
|
|
|
|
gap +
|
|
|
|
', ' +
|
|
|
|
toValueCpp(value) +
|
|
|
|
');',
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
2024-06-26 10:00:17 -07:00
|
|
|
|
2024-09-25 15:46:55 -07:00
|
|
|
YGNodeStyleSetBoxSizing: {
|
|
|
|
value: function (nodeName, value) {
|
|
|
|
this.push(
|
|
|
|
'YGNodeStyleSetBoxSizing(' + nodeName + ', ' + toValueCpp(value) + ');',
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2024-06-26 10:00:17 -07:00
|
|
|
YGNodeSetMeasureFunc: {
|
|
|
|
value: function (nodeName, innerText) {
|
|
|
|
this.push(`YGNodeSetContext(${nodeName}, (void*)"${innerText}");`);
|
|
|
|
this.push(
|
|
|
|
`YGNodeSetMeasureFunc(${nodeName}, &facebook::yoga::test::IntrinsicSizeMeasure);`,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
2016-10-23 10:27:30 -07:00
|
|
|
});
|