Compare commits
18 Commits
v3.1.0
...
release-v3
Author | SHA1 | Date | |
---|---|---|---|
|
af57b2164d | ||
|
1b9b878b9a | ||
|
866f503bde | ||
|
29f016c1ea | ||
|
ed5d2ffc2d | ||
|
8a9758a2cc | ||
|
334eebc484 | ||
|
5b106e5dd5 | ||
|
397d304e14 | ||
|
95cf06543f | ||
|
17450191c3 | ||
|
75e564d0d5 | ||
|
e82479e4ca | ||
|
508b9a57fe | ||
|
749b6b2bf8 | ||
|
fe7dc21eb1 | ||
|
59fb251edc | ||
|
efbebb4a97 |
@@ -9,7 +9,7 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
publish:
|
publish:
|
||||||
name: Publish to CocoaPods trunk
|
name: Publish to CocoaPods trunk
|
||||||
runs-on: ubuntu-latest
|
runs-on: macos-13
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
1
.github/workflows/validate-tests.yml
vendored
1
.github/workflows/validate-tests.yml
vendored
@@ -5,7 +5,6 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- 'release-*'
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
Pod::Spec.new do |spec|
|
Pod::Spec.new do |spec|
|
||||||
spec.name = 'Yoga'
|
spec.name = 'Yoga'
|
||||||
spec.version = '0.0.0'
|
spec.version = '3.0.4'
|
||||||
spec.license = { :type => 'MIT', :file => "LICENSE" }
|
spec.license = { :type => 'MIT', :file => "LICENSE" }
|
||||||
spec.homepage = 'https://yogalayout.dev/'
|
spec.homepage = 'https://yogalayout.dev/'
|
||||||
spec.documentation_url = 'https://yogalayout.dev/docs'
|
spec.documentation_url = 'https://yogalayout.dev/docs'
|
||||||
@@ -24,15 +24,15 @@ Pod::Spec.new do |spec|
|
|||||||
spec.module_name = 'yoga'
|
spec.module_name = 'yoga'
|
||||||
spec.requires_arc = false
|
spec.requires_arc = false
|
||||||
spec.pod_target_xcconfig = {
|
spec.pod_target_xcconfig = {
|
||||||
'DEFINES_MODULE' => 'YES'
|
'DEFINES_MODULE' => 'YES',
|
||||||
|
'HEADER_SEARCH_PATHS' => '"$(PODS_TARGET_SRCROOT)"',
|
||||||
}
|
}
|
||||||
|
|
||||||
spec.compiler_flags = [
|
spec.compiler_flags = [
|
||||||
'-fno-omit-frame-pointer',
|
'-fno-omit-frame-pointer',
|
||||||
'-fexceptions',
|
'-fexceptions',
|
||||||
'-Wall',
|
'-Wall',
|
||||||
'-Werror',
|
'-Werror',
|
||||||
'-Wextra',
|
|
||||||
'-Wconversion',
|
|
||||||
'-std=c++20',
|
'-std=c++20',
|
||||||
'-fPIC'
|
'-fPIC'
|
||||||
]
|
]
|
||||||
|
@@ -33,9 +33,7 @@ add_compile_options(
|
|||||||
-fexceptions
|
-fexceptions
|
||||||
# Enable warnings and warnings as errors
|
# Enable warnings and warnings as errors
|
||||||
-Wall
|
-Wall
|
||||||
-Wextra
|
|
||||||
-Werror
|
-Werror
|
||||||
-Wconversion
|
|
||||||
# Disable RTTI
|
# Disable RTTI
|
||||||
$<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>
|
$<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>
|
||||||
# Use -O2 (prioritize speed)
|
# Use -O2 (prioritize speed)
|
||||||
|
@@ -19,6 +19,60 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="static_position_absolute_child_insets_relative_to_positioned_ancestor_row_reverse">
|
||||||
|
<div style="width: 200px; height: 200px; position: relative; flex-direction: row-reverse">
|
||||||
|
<div style="height: 100px; width: 100px; position: static">
|
||||||
|
<div style="height: 50px; width: 50px; position: absolute; top: 50px; left: 50px;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="column_reverse_static_position_absolute_child_insets_relative_to_positioned_ancestor_row_reverse">
|
||||||
|
<div style="width: 200px; height: 200px; position: relative; flex-direction: row-reverse">
|
||||||
|
<div style="height: 100px; width: 100px; position: static; flex-direction: column-reverse">
|
||||||
|
<div style="height: 50px; width: 50px; position: absolute; top: 50px; left: 50px;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="static_position_absolute_child_insets_relative_to_positioned_ancestor_row">
|
||||||
|
<div style="width: 200px; height: 200px; position: relative; flex-direction: row">
|
||||||
|
<div style="height: 100px; width: 100px; position: static">
|
||||||
|
<div style="height: 50px; width: 50px; position: absolute; top: 50px; right: 50px;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="column_reverse_static_position_absolute_child_insets_relative_to_positioned_ancestor_row">
|
||||||
|
<div style="width: 200px; height: 200px; position: relative; flex-direction: row">
|
||||||
|
<div style="height: 100px; width: 100px; position: static; flex-direction: column-reverse">
|
||||||
|
<div style="height: 50px; width: 50px; position: absolute; top: 50px; right: 50px;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="static_position_absolute_child_insets_relative_to_positioned_ancestor_column_reverse">
|
||||||
|
<div style="width: 200px; height: 200px; position: relative; flex-direction: column-reverse">
|
||||||
|
<div style="height: 100px; width: 100px; position: static">
|
||||||
|
<div style="height: 50px; width: 50px; position: absolute; top: 50px; right: 50px;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="column_reverse_static_position_absolute_child_insets_relative_to_positioned_ancestor_column_reverse">
|
||||||
|
<div style="width: 200px; height: 200px; position: relative; flex-direction: column-reverse">
|
||||||
|
<div style="height: 100px; width: 100px; position: static; flex-direction: column-reverse">
|
||||||
|
<div style="height: 50px; width: 50px; position: absolute; top: 50px; right: 50px;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="static_position_absolute_child_insets_relative_to_positioned_ancestor_deep">
|
<div id="static_position_absolute_child_insets_relative_to_positioned_ancestor_deep">
|
||||||
<div style="width: 200px; height: 200px; position: relative">
|
<div style="width: 200px; height: 200px; position: relative">
|
||||||
<div style="height: 100px; width: 100px; margin-left: 100px; position: static">
|
<div style="height: 100px; width: 100px; margin-left: 100px; position: static">
|
||||||
@@ -634,8 +688,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="static_position_static_root"
|
<div id="static_position_static_root" style="height:200px; width: 100px; position: static; padding: 1px 11px 4px 6px;">
|
||||||
style="height:200px; width: 100px; position: static; padding: 1px 11px 4px 6px;">
|
|
||||||
<div
|
<div
|
||||||
style="height: 50%; width: 50%; position: absolute; border-width: 3px 2px 1px 4px; padding: 7px 5px 4px 3px; margin: 11px 15px 1px 12px">
|
style="height: 50%; width: 50%; position: absolute; border-width: 3px 2px 1px 4px; padding: 7px 5px 4px 3px; margin: 11px 15px 1px 12px">
|
||||||
</div>
|
</div>
|
||||||
|
@@ -11,4 +11,4 @@ android.useAndroidX=true
|
|||||||
|
|
||||||
org.gradle.jvmargs=-Xmx1536M
|
org.gradle.jvmargs=-Xmx1536M
|
||||||
|
|
||||||
VERSION_NAME=0.0.0
|
VERSION_NAME=3.0.4
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*
|
*
|
||||||
* @generated SignedSource<<2f9a2f834e333c2a9ecb0fa936a10f2b>>
|
* @generated SignedSource<<3bbbf27ae54f7b245d6adad352761339>>
|
||||||
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGStaticPositionTest.html
|
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGStaticPositionTest.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -181,6 +181,447 @@ public class YGStaticPositionTest {
|
|||||||
assertEquals(50f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
|
assertEquals(50f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_static_position_absolute_child_insets_relative_to_positioned_ancestor_row_reverse() {
|
||||||
|
YogaConfig config = YogaConfigFactory.create();
|
||||||
|
|
||||||
|
final YogaNode root = createNode(config);
|
||||||
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
||||||
|
|
||||||
|
final YogaNode root_child0 = createNode(config);
|
||||||
|
root_child0.setFlexDirection(YogaFlexDirection.ROW_REVERSE);
|
||||||
|
root_child0.setWidth(200f);
|
||||||
|
root_child0.setHeight(200f);
|
||||||
|
root.addChildAt(root_child0, 0);
|
||||||
|
|
||||||
|
final YogaNode root_child0_child0 = createNode(config);
|
||||||
|
root_child0_child0.setPositionType(YogaPositionType.STATIC);
|
||||||
|
root_child0_child0.setWidth(100f);
|
||||||
|
root_child0_child0.setHeight(100f);
|
||||||
|
root_child0.addChildAt(root_child0_child0, 0);
|
||||||
|
|
||||||
|
final YogaNode root_child0_child0_child0 = createNode(config);
|
||||||
|
root_child0_child0_child0.setPositionType(YogaPositionType.ABSOLUTE);
|
||||||
|
root_child0_child0_child0.setPosition(YogaEdge.LEFT, 50f);
|
||||||
|
root_child0_child0_child0.setPosition(YogaEdge.TOP, 50f);
|
||||||
|
root_child0_child0_child0.setWidth(50f);
|
||||||
|
root_child0_child0_child0.setHeight(50f);
|
||||||
|
root_child0_child0.addChildAt(root_child0_child0_child0, 0);
|
||||||
|
root.setDirection(YogaDirection.LTR);
|
||||||
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(200f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(200f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(100f, root_child0_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(-50f, root_child0_child0_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(50f, root_child0_child0_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(50f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(50f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
root.setDirection(YogaDirection.RTL);
|
||||||
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(200f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(200f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(50f, root_child0_child0_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(50f, root_child0_child0_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(50f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(50f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_column_reverse_static_position_absolute_child_insets_relative_to_positioned_ancestor_row_reverse() {
|
||||||
|
YogaConfig config = YogaConfigFactory.create();
|
||||||
|
|
||||||
|
final YogaNode root = createNode(config);
|
||||||
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
||||||
|
|
||||||
|
final YogaNode root_child0 = createNode(config);
|
||||||
|
root_child0.setFlexDirection(YogaFlexDirection.ROW_REVERSE);
|
||||||
|
root_child0.setWidth(200f);
|
||||||
|
root_child0.setHeight(200f);
|
||||||
|
root.addChildAt(root_child0, 0);
|
||||||
|
|
||||||
|
final YogaNode root_child0_child0 = createNode(config);
|
||||||
|
root_child0_child0.setFlexDirection(YogaFlexDirection.COLUMN_REVERSE);
|
||||||
|
root_child0_child0.setPositionType(YogaPositionType.STATIC);
|
||||||
|
root_child0_child0.setWidth(100f);
|
||||||
|
root_child0_child0.setHeight(100f);
|
||||||
|
root_child0.addChildAt(root_child0_child0, 0);
|
||||||
|
|
||||||
|
final YogaNode root_child0_child0_child0 = createNode(config);
|
||||||
|
root_child0_child0_child0.setPositionType(YogaPositionType.ABSOLUTE);
|
||||||
|
root_child0_child0_child0.setPosition(YogaEdge.LEFT, 50f);
|
||||||
|
root_child0_child0_child0.setPosition(YogaEdge.TOP, 50f);
|
||||||
|
root_child0_child0_child0.setWidth(50f);
|
||||||
|
root_child0_child0_child0.setHeight(50f);
|
||||||
|
root_child0_child0.addChildAt(root_child0_child0_child0, 0);
|
||||||
|
root.setDirection(YogaDirection.LTR);
|
||||||
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(200f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(200f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(100f, root_child0_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(-50f, root_child0_child0_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(50f, root_child0_child0_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(50f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(50f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
root.setDirection(YogaDirection.RTL);
|
||||||
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(200f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(200f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(50f, root_child0_child0_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(50f, root_child0_child0_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(50f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(50f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_static_position_absolute_child_insets_relative_to_positioned_ancestor_row() {
|
||||||
|
YogaConfig config = YogaConfigFactory.create();
|
||||||
|
|
||||||
|
final YogaNode root = createNode(config);
|
||||||
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
||||||
|
|
||||||
|
final YogaNode root_child0 = createNode(config);
|
||||||
|
root_child0.setFlexDirection(YogaFlexDirection.ROW);
|
||||||
|
root_child0.setWidth(200f);
|
||||||
|
root_child0.setHeight(200f);
|
||||||
|
root.addChildAt(root_child0, 0);
|
||||||
|
|
||||||
|
final YogaNode root_child0_child0 = createNode(config);
|
||||||
|
root_child0_child0.setPositionType(YogaPositionType.STATIC);
|
||||||
|
root_child0_child0.setWidth(100f);
|
||||||
|
root_child0_child0.setHeight(100f);
|
||||||
|
root_child0.addChildAt(root_child0_child0, 0);
|
||||||
|
|
||||||
|
final YogaNode root_child0_child0_child0 = createNode(config);
|
||||||
|
root_child0_child0_child0.setPositionType(YogaPositionType.ABSOLUTE);
|
||||||
|
root_child0_child0_child0.setPosition(YogaEdge.TOP, 50f);
|
||||||
|
root_child0_child0_child0.setPosition(YogaEdge.RIGHT, 50f);
|
||||||
|
root_child0_child0_child0.setWidth(50f);
|
||||||
|
root_child0_child0_child0.setHeight(50f);
|
||||||
|
root_child0_child0.addChildAt(root_child0_child0_child0, 0);
|
||||||
|
root.setDirection(YogaDirection.LTR);
|
||||||
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(200f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(200f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(100f, root_child0_child0_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(50f, root_child0_child0_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(50f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(50f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
root.setDirection(YogaDirection.RTL);
|
||||||
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(200f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(200f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(100f, root_child0_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0_child0_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(50f, root_child0_child0_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(50f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(50f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_column_reverse_static_position_absolute_child_insets_relative_to_positioned_ancestor_row() {
|
||||||
|
YogaConfig config = YogaConfigFactory.create();
|
||||||
|
|
||||||
|
final YogaNode root = createNode(config);
|
||||||
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
||||||
|
|
||||||
|
final YogaNode root_child0 = createNode(config);
|
||||||
|
root_child0.setFlexDirection(YogaFlexDirection.ROW);
|
||||||
|
root_child0.setWidth(200f);
|
||||||
|
root_child0.setHeight(200f);
|
||||||
|
root.addChildAt(root_child0, 0);
|
||||||
|
|
||||||
|
final YogaNode root_child0_child0 = createNode(config);
|
||||||
|
root_child0_child0.setFlexDirection(YogaFlexDirection.COLUMN_REVERSE);
|
||||||
|
root_child0_child0.setPositionType(YogaPositionType.STATIC);
|
||||||
|
root_child0_child0.setWidth(100f);
|
||||||
|
root_child0_child0.setHeight(100f);
|
||||||
|
root_child0.addChildAt(root_child0_child0, 0);
|
||||||
|
|
||||||
|
final YogaNode root_child0_child0_child0 = createNode(config);
|
||||||
|
root_child0_child0_child0.setPositionType(YogaPositionType.ABSOLUTE);
|
||||||
|
root_child0_child0_child0.setPosition(YogaEdge.TOP, 50f);
|
||||||
|
root_child0_child0_child0.setPosition(YogaEdge.RIGHT, 50f);
|
||||||
|
root_child0_child0_child0.setWidth(50f);
|
||||||
|
root_child0_child0_child0.setHeight(50f);
|
||||||
|
root_child0_child0.addChildAt(root_child0_child0_child0, 0);
|
||||||
|
root.setDirection(YogaDirection.LTR);
|
||||||
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(200f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(200f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(100f, root_child0_child0_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(50f, root_child0_child0_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(50f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(50f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
root.setDirection(YogaDirection.RTL);
|
||||||
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(200f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(200f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(100f, root_child0_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0_child0_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(50f, root_child0_child0_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(50f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(50f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_static_position_absolute_child_insets_relative_to_positioned_ancestor_column_reverse() {
|
||||||
|
YogaConfig config = YogaConfigFactory.create();
|
||||||
|
|
||||||
|
final YogaNode root = createNode(config);
|
||||||
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
||||||
|
|
||||||
|
final YogaNode root_child0 = createNode(config);
|
||||||
|
root_child0.setFlexDirection(YogaFlexDirection.COLUMN_REVERSE);
|
||||||
|
root_child0.setWidth(200f);
|
||||||
|
root_child0.setHeight(200f);
|
||||||
|
root.addChildAt(root_child0, 0);
|
||||||
|
|
||||||
|
final YogaNode root_child0_child0 = createNode(config);
|
||||||
|
root_child0_child0.setPositionType(YogaPositionType.STATIC);
|
||||||
|
root_child0_child0.setWidth(100f);
|
||||||
|
root_child0_child0.setHeight(100f);
|
||||||
|
root_child0.addChildAt(root_child0_child0, 0);
|
||||||
|
|
||||||
|
final YogaNode root_child0_child0_child0 = createNode(config);
|
||||||
|
root_child0_child0_child0.setPositionType(YogaPositionType.ABSOLUTE);
|
||||||
|
root_child0_child0_child0.setPosition(YogaEdge.TOP, 50f);
|
||||||
|
root_child0_child0_child0.setPosition(YogaEdge.RIGHT, 50f);
|
||||||
|
root_child0_child0_child0.setWidth(50f);
|
||||||
|
root_child0_child0_child0.setHeight(50f);
|
||||||
|
root_child0_child0.addChildAt(root_child0_child0_child0, 0);
|
||||||
|
root.setDirection(YogaDirection.LTR);
|
||||||
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(200f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(200f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(100f, root_child0_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(100f, root_child0_child0_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(-50f, root_child0_child0_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(50f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(50f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
root.setDirection(YogaDirection.RTL);
|
||||||
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(200f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(200f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(100f, root_child0_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(100f, root_child0_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0_child0_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(-50f, root_child0_child0_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(50f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(50f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_column_reverse_static_position_absolute_child_insets_relative_to_positioned_ancestor_column_reverse() {
|
||||||
|
YogaConfig config = YogaConfigFactory.create();
|
||||||
|
|
||||||
|
final YogaNode root = createNode(config);
|
||||||
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
||||||
|
|
||||||
|
final YogaNode root_child0 = createNode(config);
|
||||||
|
root_child0.setFlexDirection(YogaFlexDirection.COLUMN_REVERSE);
|
||||||
|
root_child0.setWidth(200f);
|
||||||
|
root_child0.setHeight(200f);
|
||||||
|
root.addChildAt(root_child0, 0);
|
||||||
|
|
||||||
|
final YogaNode root_child0_child0 = createNode(config);
|
||||||
|
root_child0_child0.setFlexDirection(YogaFlexDirection.COLUMN_REVERSE);
|
||||||
|
root_child0_child0.setPositionType(YogaPositionType.STATIC);
|
||||||
|
root_child0_child0.setWidth(100f);
|
||||||
|
root_child0_child0.setHeight(100f);
|
||||||
|
root_child0.addChildAt(root_child0_child0, 0);
|
||||||
|
|
||||||
|
final YogaNode root_child0_child0_child0 = createNode(config);
|
||||||
|
root_child0_child0_child0.setPositionType(YogaPositionType.ABSOLUTE);
|
||||||
|
root_child0_child0_child0.setPosition(YogaEdge.TOP, 50f);
|
||||||
|
root_child0_child0_child0.setPosition(YogaEdge.RIGHT, 50f);
|
||||||
|
root_child0_child0_child0.setWidth(50f);
|
||||||
|
root_child0_child0_child0.setHeight(50f);
|
||||||
|
root_child0_child0.addChildAt(root_child0_child0_child0, 0);
|
||||||
|
root.setDirection(YogaDirection.LTR);
|
||||||
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(200f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(200f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(100f, root_child0_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(100f, root_child0_child0_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(-50f, root_child0_child0_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(50f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(50f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
root.setDirection(YogaDirection.RTL);
|
||||||
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(200f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(200f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(100f, root_child0_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(100f, root_child0_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0_child0_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(-50f, root_child0_child0_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(50f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(50f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_static_position_absolute_child_insets_relative_to_positioned_ancestor_deep() {
|
public void test_static_position_absolute_child_insets_relative_to_positioned_ancestor_deep() {
|
||||||
YogaConfig config = YogaConfigFactory.create();
|
YogaConfig config = YogaConfigFactory.create();
|
||||||
|
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
This package provides prebuilt WebAssembly bindings for the Yoga layout engine.
|
This package provides prebuilt WebAssembly bindings for the Yoga layout engine.
|
||||||
|
|
||||||
|
See more at https://yogalayout.dev
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
@@ -24,37 +26,15 @@ node.freeRecursive();
|
|||||||
node.free();
|
node.free();
|
||||||
```
|
```
|
||||||
|
|
||||||
## Using TypeScript
|
## Requirements
|
||||||
|
|
||||||
This package provides out-of-the-box TypeScript typings so long as `tsc` is configured to support ESM resolution. It is recommended to set `moduleResolution: 'bundler'` or `moduleResolution: node16` in your `tsconfig.json` according to your environment.
|
`yoga-layout` requires a toolchain that supports ES Modules and top-level await.
|
||||||
|
|
||||||
## ES Modules
|
If top-level-await is not supported, use the `yoga-layout/load` entry point instead. This requires to load yoga manually:
|
||||||
|
|
||||||
`yoga-layout` is only provided as an ES Module, relying on top-level await. This allows providing a synchronous API, while still allowing async WebAssembly compilation in browsers, and will allow eventual usage of ESM/WASM interop.
|
```ts
|
||||||
|
import {loadYoga, Align} from 'yoga-layout/load';
|
||||||
|
|
||||||
## Contributing
|
const node = (await loadYoga).Node.create();
|
||||||
|
node.setAlignContent(Align.Center);
|
||||||
### Requirements
|
|
||||||
|
|
||||||
1. Emscripten SDK
|
|
||||||
1. CMake >= 3.13
|
|
||||||
1. (Optional) ninja, for faster builds
|
|
||||||
|
|
||||||
### Building
|
|
||||||
|
|
||||||
```bash
|
|
||||||
git clone https://github.com/facebook/yoga.git
|
|
||||||
cd yoga/javascript
|
|
||||||
yarn install
|
|
||||||
yarn build
|
|
||||||
```
|
|
||||||
|
|
||||||
### Testing
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Build and test all entrypoints
|
|
||||||
yarn test
|
|
||||||
|
|
||||||
# Build and test a specific entrypoint
|
|
||||||
yarn test:asmjs-sync
|
|
||||||
```
|
```
|
||||||
|
@@ -13,11 +13,11 @@ const {
|
|||||||
logger,
|
logger,
|
||||||
jestTask,
|
jestTask,
|
||||||
option,
|
option,
|
||||||
parallel,
|
|
||||||
series,
|
series,
|
||||||
spawn,
|
spawn,
|
||||||
task,
|
task,
|
||||||
tscTask,
|
tscTask,
|
||||||
|
copyTask,
|
||||||
} = require('just-scripts');
|
} = require('just-scripts');
|
||||||
|
|
||||||
const {existsSync} = require('fs');
|
const {existsSync} = require('fs');
|
||||||
@@ -58,15 +58,32 @@ task('prepack-package-json', async () => {
|
|||||||
const packageJsonContents = await readFile(packageJsonPath);
|
const packageJsonContents = await readFile(packageJsonPath);
|
||||||
const packageJson = JSON.parse(packageJsonContents.toString('utf-8'));
|
const packageJson = JSON.parse(packageJsonContents.toString('utf-8'));
|
||||||
|
|
||||||
recursiveReplace(packageJson, /(.\/src\/.*)\.ts/, '$1.js');
|
packageJson.main = packageJson.main.replace(
|
||||||
|
/^.\/src\/(.*)\.ts/,
|
||||||
|
'./dist/src/$1.js',
|
||||||
|
);
|
||||||
|
packageJson.types = packageJson.main.replace(/(.*)\.js/, '$1.d.ts');
|
||||||
|
|
||||||
|
recursiveReplace(
|
||||||
|
packageJson.exports,
|
||||||
|
/^.\/src\/(.*)\.ts/,
|
||||||
|
'./dist/src/$1.js',
|
||||||
|
);
|
||||||
|
|
||||||
await writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
await writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
||||||
});
|
});
|
||||||
|
|
||||||
task(
|
task(
|
||||||
'prepack',
|
'prepack',
|
||||||
series(
|
series(
|
||||||
parallel('build', tscTask({emitDeclarationOnly: true})),
|
'build',
|
||||||
babelTransformTask({dir: 'src'}),
|
copyTask({paths: ['binaries'], dest: 'dist/binaries'}),
|
||||||
|
tscTask({
|
||||||
|
emitDeclarationOnly: true,
|
||||||
|
rootDir: '.',
|
||||||
|
declarationDir: 'dist',
|
||||||
|
}),
|
||||||
|
babelTransformTask({src: 'src', dst: 'dist/src'}),
|
||||||
'prepack-package-json',
|
'prepack-package-json',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -84,14 +101,14 @@ function recursiveReplace(obj, pattern, replacement) {
|
|||||||
function babelTransformTask(opts) {
|
function babelTransformTask(opts) {
|
||||||
return () => {
|
return () => {
|
||||||
const args = [
|
const args = [
|
||||||
opts.dir,
|
opts.src,
|
||||||
'--source-maps',
|
'--source-maps',
|
||||||
'--out-dir',
|
'--out-dir',
|
||||||
opts.dir,
|
opts.dst,
|
||||||
'--extensions',
|
'--extensions',
|
||||||
'.js,.cjs,.mjs,.ts,.cts,.mts',
|
'.js,.cjs,.mjs,.ts,.cts,.mts',
|
||||||
];
|
];
|
||||||
logger.info(`Transforming "${path.resolve(opts.dir)}"`);
|
logger.info(`Transforming "${path.resolve(opts.src)}"`);
|
||||||
|
|
||||||
return spawn(node, [require.resolve('@babel/cli/bin/babel'), ...args], {
|
return spawn(node, [require.resolve('@babel/cli/bin/babel'), ...args], {
|
||||||
cwd: __dirname,
|
cwd: __dirname,
|
||||||
@@ -151,9 +168,9 @@ function installEmsdkTask() {
|
|||||||
{stdio: 'inherit'},
|
{stdio: 'inherit'},
|
||||||
);
|
);
|
||||||
|
|
||||||
await spawn(emsdkBin, ['install', emsdkVersion], {stdio: 'inherit'});
|
await spawnShell(emsdkBin, ['install', emsdkVersion], {stdio: 'inherit'});
|
||||||
|
|
||||||
await spawn(emsdkBin, ['activate', emsdkVersion], {
|
await spawnShell(emsdkBin, ['activate', emsdkVersion], {
|
||||||
stdio: logger.enableVerbose ? 'inherit' : 'ignore',
|
stdio: logger.enableVerbose ? 'inherit' : 'ignore',
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -199,7 +216,7 @@ function emcmakeGenerateTask() {
|
|||||||
];
|
];
|
||||||
logger.info(['emcmake', ...args].join(' '));
|
logger.info(['emcmake', ...args].join(' '));
|
||||||
|
|
||||||
return spawn(emcmakeBin, args, {
|
return spawnShell(emcmakeBin, args, {
|
||||||
stdio: logger.enableVerbose ? 'inherit' : 'ignore',
|
stdio: logger.enableVerbose ? 'inherit' : 'ignore',
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -217,7 +234,7 @@ function cmakeBuildTask(opts) {
|
|||||||
];
|
];
|
||||||
logger.info(['cmake', ...args].join(' '));
|
logger.info(['cmake', ...args].join(' '));
|
||||||
|
|
||||||
return spawn(cmake, args, {stdio: 'inherit'});
|
return spawnShell(cmake, args, {stdio: 'inherit'});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,8 +246,13 @@ function clangFormatTask(opts) {
|
|||||||
];
|
];
|
||||||
logger.info(['clang-format', ...args].join(' '));
|
logger.info(['clang-format', ...args].join(' '));
|
||||||
|
|
||||||
return spawn(node, [require.resolve('clang-format'), ...args], {
|
return spawnShell(node, [require.resolve('clang-format'), ...args], {
|
||||||
stdio: 'inherit',
|
stdio: 'inherit',
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function spawnShell(cmd, args, opts) {
|
||||||
|
// https://github.com/nodejs/node/issues/52554
|
||||||
|
return spawn(cmd, args, {...opts, shell: true});
|
||||||
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "yoga-layout",
|
"name": "yoga-layout",
|
||||||
"version": "0.0.0",
|
"version": "3.0.4",
|
||||||
"description": "An embeddable and performant flexbox layout engine with bindings for multiple languages",
|
"description": "An embeddable and performant flexbox layout engine with bindings for multiple languages",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"author": "Meta Open Source",
|
"author": "Meta Open Source",
|
||||||
@@ -11,8 +11,14 @@
|
|||||||
},
|
},
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "./src/index.ts",
|
"main": "./src/index.ts",
|
||||||
|
"types": "./src/index.ts",
|
||||||
|
"exports": {
|
||||||
|
".": "./src/index.ts",
|
||||||
|
"./load": "./src/load.ts"
|
||||||
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"binaries/**",
|
"dist/binaries/**",
|
||||||
|
"dist/src/**",
|
||||||
"src/**"
|
"src/**"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@@ -413,6 +413,14 @@ bool Node::isDirty(void) const {
|
|||||||
return YGNodeIsDirty(m_node);
|
return YGNodeIsDirty(m_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Node::markLayoutSeen() {
|
||||||
|
YGNodeSetHasNewLayout(m_node, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Node::hasNewLayout(void) const {
|
||||||
|
return YGNodeGetHasNewLayout(m_node);
|
||||||
|
}
|
||||||
|
|
||||||
void Node::calculateLayout(double width, double height, int direction) {
|
void Node::calculateLayout(double width, double height, int direction) {
|
||||||
YGNodeCalculateLayout(
|
YGNodeCalculateLayout(
|
||||||
m_node, width, height, static_cast<YGDirection>(direction));
|
m_node, width, height, static_cast<YGDirection>(direction));
|
||||||
|
@@ -195,6 +195,8 @@ class Node {
|
|||||||
public: // Dirtiness accessors
|
public: // Dirtiness accessors
|
||||||
void markDirty(void);
|
void markDirty(void);
|
||||||
bool isDirty(void) const;
|
bool isDirty(void) const;
|
||||||
|
void markLayoutSeen();
|
||||||
|
bool hasNewLayout(void) const;
|
||||||
|
|
||||||
public: // Layout mutators
|
public: // Layout mutators
|
||||||
void calculateLayout(double width, double height, int direction);
|
void calculateLayout(double width, double height, int direction);
|
||||||
|
@@ -175,6 +175,9 @@ EMSCRIPTEN_BINDINGS(YOGA_LAYOUT) {
|
|||||||
.function("markDirty", &Node::markDirty)
|
.function("markDirty", &Node::markDirty)
|
||||||
.function("isDirty", &Node::isDirty)
|
.function("isDirty", &Node::isDirty)
|
||||||
|
|
||||||
|
.function("markLayoutSeen", &Node::markLayoutSeen)
|
||||||
|
.function("hasNewLayout", &Node::hasNewLayout)
|
||||||
|
|
||||||
.function("calculateLayout", &Node::calculateLayout)
|
.function("calculateLayout", &Node::calculateLayout)
|
||||||
|
|
||||||
.function("getComputedLeft", &Node::getComputedLeft)
|
.function("getComputedLeft", &Node::getComputedLeft)
|
||||||
|
25
javascript/src/load.ts
Normal file
25
javascript/src/load.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*
|
||||||
|
* @format
|
||||||
|
*/
|
||||||
|
|
||||||
|
// @ts-ignore untyped from Emscripten
|
||||||
|
import loadYogaImpl from '../binaries/yoga-wasm-base64-esm.js';
|
||||||
|
import wrapAssembly from './wrapAssembly.ts';
|
||||||
|
|
||||||
|
export type {
|
||||||
|
Config,
|
||||||
|
DirtiedFunction,
|
||||||
|
MeasureFunction,
|
||||||
|
Node,
|
||||||
|
Yoga,
|
||||||
|
} from './wrapAssembly.ts';
|
||||||
|
|
||||||
|
export async function loadYoga() {
|
||||||
|
return wrapAssembly(await loadYogaImpl());
|
||||||
|
}
|
||||||
|
export * from './generated/YGEnums.ts';
|
@@ -119,6 +119,8 @@ export type Node = {
|
|||||||
isDirty(): boolean;
|
isDirty(): boolean;
|
||||||
isReferenceBaseline(): boolean;
|
isReferenceBaseline(): boolean;
|
||||||
markDirty(): void;
|
markDirty(): void;
|
||||||
|
hasNewLayout(): boolean;
|
||||||
|
markLayoutSeen(): void;
|
||||||
removeChild(child: Node): void;
|
removeChild(child: Node): void;
|
||||||
reset(): void;
|
reset(): void;
|
||||||
setAlignContent(alignContent: Align): void;
|
setAlignContent(alignContent: Align): void;
|
||||||
|
81
javascript/tests/YGHasNewLayout.test.ts
Normal file
81
javascript/tests/YGHasNewLayout.test.ts
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Yoga from 'yoga-layout';
|
||||||
|
|
||||||
|
test('new_layout_can_be_marked_seen', () => {
|
||||||
|
const root = Yoga.Node.create();
|
||||||
|
root.markLayoutSeen();
|
||||||
|
expect(root.hasNewLayout()).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('new_layout_calculating_layout_marks_layout_as_unseen', () => {
|
||||||
|
const root = Yoga.Node.create();
|
||||||
|
root.markLayoutSeen();
|
||||||
|
root.calculateLayout(undefined, undefined);
|
||||||
|
expect(root.hasNewLayout()).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('new_layout_calculated_layout_can_be_marked_seen', () => {
|
||||||
|
const root = Yoga.Node.create();
|
||||||
|
root.calculateLayout(undefined, undefined);
|
||||||
|
root.markLayoutSeen();
|
||||||
|
expect(root.hasNewLayout()).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('new_layout_recalculating_layout_does_mark_as_unseen', () => {
|
||||||
|
const root = Yoga.Node.create();
|
||||||
|
root.calculateLayout(undefined, undefined);
|
||||||
|
root.markLayoutSeen();
|
||||||
|
root.calculateLayout(undefined, undefined);
|
||||||
|
expect(root.hasNewLayout()).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('new_layout_reset_also_resets_layout_seen', () => {
|
||||||
|
const root = Yoga.Node.create();
|
||||||
|
root.markLayoutSeen();
|
||||||
|
root.reset();
|
||||||
|
expect(root.hasNewLayout()).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('new_layout_children_sets_new_layout', () => {
|
||||||
|
const root = Yoga.Node.create();
|
||||||
|
root.setAlignItems(Yoga.ALIGN_FLEX_START);
|
||||||
|
root.setWidth(100);
|
||||||
|
root.setHeight(100);
|
||||||
|
|
||||||
|
const root_child0 = Yoga.Node.create();
|
||||||
|
root_child0.setAlignItems(Yoga.ALIGN_FLEX_START);
|
||||||
|
root_child0.setWidth(50);
|
||||||
|
root_child0.setHeight(20);
|
||||||
|
root.insertChild(root_child0, 0);
|
||||||
|
|
||||||
|
const root_child1 = Yoga.Node.create();
|
||||||
|
root_child1.setAlignItems(Yoga.ALIGN_FLEX_START);
|
||||||
|
root_child1.setWidth(50);
|
||||||
|
root_child1.setHeight(20);
|
||||||
|
root.insertChild(root_child1, 0);
|
||||||
|
|
||||||
|
expect(root.hasNewLayout()).toEqual(true);
|
||||||
|
expect(root_child0.hasNewLayout()).toEqual(true);
|
||||||
|
expect(root_child1.hasNewLayout()).toEqual(true);
|
||||||
|
|
||||||
|
root.markLayoutSeen();
|
||||||
|
root_child0.markLayoutSeen();
|
||||||
|
root_child1.markLayoutSeen();
|
||||||
|
|
||||||
|
expect(root.hasNewLayout()).toEqual(false);
|
||||||
|
expect(root_child0.hasNewLayout()).toEqual(false);
|
||||||
|
expect(root_child1.hasNewLayout()).toEqual(false);
|
||||||
|
|
||||||
|
root_child1.setHeight(30);
|
||||||
|
root.calculateLayout(undefined, undefined);
|
||||||
|
|
||||||
|
expect(root.hasNewLayout()).toEqual(true);
|
||||||
|
expect(root_child0.hasNewLayout()).toEqual(true);
|
||||||
|
expect(root_child1.hasNewLayout()).toEqual(true);
|
||||||
|
});
|
@@ -4,7 +4,7 @@
|
|||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*
|
*
|
||||||
* @generated SignedSource<<6040773dbe8767011fe186f20ead2b56>>
|
* @generated SignedSource<<2f8b96b22567d9b50c880b375cf7de15>>
|
||||||
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGStaticPositionTest.html
|
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGStaticPositionTest.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -196,6 +196,477 @@ test('static_position_absolute_child_insets_relative_to_positioned_ancestor', ()
|
|||||||
config.free();
|
config.free();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
test('static_position_absolute_child_insets_relative_to_positioned_ancestor_row_reverse', () => {
|
||||||
|
const config = Yoga.Config.create();
|
||||||
|
let root;
|
||||||
|
|
||||||
|
try {
|
||||||
|
root = Yoga.Node.create(config);
|
||||||
|
root.setPositionType(PositionType.Absolute);
|
||||||
|
|
||||||
|
const root_child0 = Yoga.Node.create(config);
|
||||||
|
root_child0.setFlexDirection(FlexDirection.RowReverse);
|
||||||
|
root_child0.setWidth(200);
|
||||||
|
root_child0.setHeight(200);
|
||||||
|
root.insertChild(root_child0, 0);
|
||||||
|
|
||||||
|
const root_child0_child0 = Yoga.Node.create(config);
|
||||||
|
root_child0_child0.setPositionType(PositionType.Static);
|
||||||
|
root_child0_child0.setWidth(100);
|
||||||
|
root_child0_child0.setHeight(100);
|
||||||
|
root_child0.insertChild(root_child0_child0, 0);
|
||||||
|
|
||||||
|
const root_child0_child0_child0 = Yoga.Node.create(config);
|
||||||
|
root_child0_child0_child0.setPositionType(PositionType.Absolute);
|
||||||
|
root_child0_child0_child0.setPosition(Edge.Left, 50);
|
||||||
|
root_child0_child0_child0.setPosition(Edge.Top, 50);
|
||||||
|
root_child0_child0_child0.setWidth(50);
|
||||||
|
root_child0_child0_child0.setHeight(50);
|
||||||
|
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
||||||
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
||||||
|
|
||||||
|
expect(root.getComputedLeft()).toBe(0);
|
||||||
|
expect(root.getComputedTop()).toBe(0);
|
||||||
|
expect(root.getComputedWidth()).toBe(200);
|
||||||
|
expect(root.getComputedHeight()).toBe(200);
|
||||||
|
|
||||||
|
expect(root_child0.getComputedLeft()).toBe(0);
|
||||||
|
expect(root_child0.getComputedTop()).toBe(0);
|
||||||
|
expect(root_child0.getComputedWidth()).toBe(200);
|
||||||
|
expect(root_child0.getComputedHeight()).toBe(200);
|
||||||
|
|
||||||
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
||||||
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
||||||
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
||||||
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
||||||
|
|
||||||
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(-50);
|
||||||
|
expect(root_child0_child0_child0.getComputedTop()).toBe(50);
|
||||||
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
||||||
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
||||||
|
|
||||||
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
||||||
|
|
||||||
|
expect(root.getComputedLeft()).toBe(0);
|
||||||
|
expect(root.getComputedTop()).toBe(0);
|
||||||
|
expect(root.getComputedWidth()).toBe(200);
|
||||||
|
expect(root.getComputedHeight()).toBe(200);
|
||||||
|
|
||||||
|
expect(root_child0.getComputedLeft()).toBe(0);
|
||||||
|
expect(root_child0.getComputedTop()).toBe(0);
|
||||||
|
expect(root_child0.getComputedWidth()).toBe(200);
|
||||||
|
expect(root_child0.getComputedHeight()).toBe(200);
|
||||||
|
|
||||||
|
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
||||||
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
||||||
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
||||||
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
||||||
|
|
||||||
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(50);
|
||||||
|
expect(root_child0_child0_child0.getComputedTop()).toBe(50);
|
||||||
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
||||||
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
||||||
|
} finally {
|
||||||
|
if (typeof root !== 'undefined') {
|
||||||
|
root.freeRecursive();
|
||||||
|
}
|
||||||
|
|
||||||
|
config.free();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
test('column_reverse_static_position_absolute_child_insets_relative_to_positioned_ancestor_row_reverse', () => {
|
||||||
|
const config = Yoga.Config.create();
|
||||||
|
let root;
|
||||||
|
|
||||||
|
try {
|
||||||
|
root = Yoga.Node.create(config);
|
||||||
|
root.setPositionType(PositionType.Absolute);
|
||||||
|
|
||||||
|
const root_child0 = Yoga.Node.create(config);
|
||||||
|
root_child0.setFlexDirection(FlexDirection.RowReverse);
|
||||||
|
root_child0.setWidth(200);
|
||||||
|
root_child0.setHeight(200);
|
||||||
|
root.insertChild(root_child0, 0);
|
||||||
|
|
||||||
|
const root_child0_child0 = Yoga.Node.create(config);
|
||||||
|
root_child0_child0.setFlexDirection(FlexDirection.ColumnReverse);
|
||||||
|
root_child0_child0.setPositionType(PositionType.Static);
|
||||||
|
root_child0_child0.setWidth(100);
|
||||||
|
root_child0_child0.setHeight(100);
|
||||||
|
root_child0.insertChild(root_child0_child0, 0);
|
||||||
|
|
||||||
|
const root_child0_child0_child0 = Yoga.Node.create(config);
|
||||||
|
root_child0_child0_child0.setPositionType(PositionType.Absolute);
|
||||||
|
root_child0_child0_child0.setPosition(Edge.Left, 50);
|
||||||
|
root_child0_child0_child0.setPosition(Edge.Top, 50);
|
||||||
|
root_child0_child0_child0.setWidth(50);
|
||||||
|
root_child0_child0_child0.setHeight(50);
|
||||||
|
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
||||||
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
||||||
|
|
||||||
|
expect(root.getComputedLeft()).toBe(0);
|
||||||
|
expect(root.getComputedTop()).toBe(0);
|
||||||
|
expect(root.getComputedWidth()).toBe(200);
|
||||||
|
expect(root.getComputedHeight()).toBe(200);
|
||||||
|
|
||||||
|
expect(root_child0.getComputedLeft()).toBe(0);
|
||||||
|
expect(root_child0.getComputedTop()).toBe(0);
|
||||||
|
expect(root_child0.getComputedWidth()).toBe(200);
|
||||||
|
expect(root_child0.getComputedHeight()).toBe(200);
|
||||||
|
|
||||||
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
||||||
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
||||||
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
||||||
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
||||||
|
|
||||||
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(-50);
|
||||||
|
expect(root_child0_child0_child0.getComputedTop()).toBe(50);
|
||||||
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
||||||
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
||||||
|
|
||||||
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
||||||
|
|
||||||
|
expect(root.getComputedLeft()).toBe(0);
|
||||||
|
expect(root.getComputedTop()).toBe(0);
|
||||||
|
expect(root.getComputedWidth()).toBe(200);
|
||||||
|
expect(root.getComputedHeight()).toBe(200);
|
||||||
|
|
||||||
|
expect(root_child0.getComputedLeft()).toBe(0);
|
||||||
|
expect(root_child0.getComputedTop()).toBe(0);
|
||||||
|
expect(root_child0.getComputedWidth()).toBe(200);
|
||||||
|
expect(root_child0.getComputedHeight()).toBe(200);
|
||||||
|
|
||||||
|
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
||||||
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
||||||
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
||||||
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
||||||
|
|
||||||
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(50);
|
||||||
|
expect(root_child0_child0_child0.getComputedTop()).toBe(50);
|
||||||
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
||||||
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
||||||
|
} finally {
|
||||||
|
if (typeof root !== 'undefined') {
|
||||||
|
root.freeRecursive();
|
||||||
|
}
|
||||||
|
|
||||||
|
config.free();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
test('static_position_absolute_child_insets_relative_to_positioned_ancestor_row', () => {
|
||||||
|
const config = Yoga.Config.create();
|
||||||
|
let root;
|
||||||
|
|
||||||
|
try {
|
||||||
|
root = Yoga.Node.create(config);
|
||||||
|
root.setPositionType(PositionType.Absolute);
|
||||||
|
|
||||||
|
const root_child0 = Yoga.Node.create(config);
|
||||||
|
root_child0.setFlexDirection(FlexDirection.Row);
|
||||||
|
root_child0.setWidth(200);
|
||||||
|
root_child0.setHeight(200);
|
||||||
|
root.insertChild(root_child0, 0);
|
||||||
|
|
||||||
|
const root_child0_child0 = Yoga.Node.create(config);
|
||||||
|
root_child0_child0.setPositionType(PositionType.Static);
|
||||||
|
root_child0_child0.setWidth(100);
|
||||||
|
root_child0_child0.setHeight(100);
|
||||||
|
root_child0.insertChild(root_child0_child0, 0);
|
||||||
|
|
||||||
|
const root_child0_child0_child0 = Yoga.Node.create(config);
|
||||||
|
root_child0_child0_child0.setPositionType(PositionType.Absolute);
|
||||||
|
root_child0_child0_child0.setPosition(Edge.Top, 50);
|
||||||
|
root_child0_child0_child0.setPosition(Edge.Right, 50);
|
||||||
|
root_child0_child0_child0.setWidth(50);
|
||||||
|
root_child0_child0_child0.setHeight(50);
|
||||||
|
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
||||||
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
||||||
|
|
||||||
|
expect(root.getComputedLeft()).toBe(0);
|
||||||
|
expect(root.getComputedTop()).toBe(0);
|
||||||
|
expect(root.getComputedWidth()).toBe(200);
|
||||||
|
expect(root.getComputedHeight()).toBe(200);
|
||||||
|
|
||||||
|
expect(root_child0.getComputedLeft()).toBe(0);
|
||||||
|
expect(root_child0.getComputedTop()).toBe(0);
|
||||||
|
expect(root_child0.getComputedWidth()).toBe(200);
|
||||||
|
expect(root_child0.getComputedHeight()).toBe(200);
|
||||||
|
|
||||||
|
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
||||||
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
||||||
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
||||||
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
||||||
|
|
||||||
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(100);
|
||||||
|
expect(root_child0_child0_child0.getComputedTop()).toBe(50);
|
||||||
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
||||||
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
||||||
|
|
||||||
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
||||||
|
|
||||||
|
expect(root.getComputedLeft()).toBe(0);
|
||||||
|
expect(root.getComputedTop()).toBe(0);
|
||||||
|
expect(root.getComputedWidth()).toBe(200);
|
||||||
|
expect(root.getComputedHeight()).toBe(200);
|
||||||
|
|
||||||
|
expect(root_child0.getComputedLeft()).toBe(0);
|
||||||
|
expect(root_child0.getComputedTop()).toBe(0);
|
||||||
|
expect(root_child0.getComputedWidth()).toBe(200);
|
||||||
|
expect(root_child0.getComputedHeight()).toBe(200);
|
||||||
|
|
||||||
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
||||||
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
||||||
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
||||||
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
||||||
|
|
||||||
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(0);
|
||||||
|
expect(root_child0_child0_child0.getComputedTop()).toBe(50);
|
||||||
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
||||||
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
||||||
|
} finally {
|
||||||
|
if (typeof root !== 'undefined') {
|
||||||
|
root.freeRecursive();
|
||||||
|
}
|
||||||
|
|
||||||
|
config.free();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
test('column_reverse_static_position_absolute_child_insets_relative_to_positioned_ancestor_row', () => {
|
||||||
|
const config = Yoga.Config.create();
|
||||||
|
let root;
|
||||||
|
|
||||||
|
try {
|
||||||
|
root = Yoga.Node.create(config);
|
||||||
|
root.setPositionType(PositionType.Absolute);
|
||||||
|
|
||||||
|
const root_child0 = Yoga.Node.create(config);
|
||||||
|
root_child0.setFlexDirection(FlexDirection.Row);
|
||||||
|
root_child0.setWidth(200);
|
||||||
|
root_child0.setHeight(200);
|
||||||
|
root.insertChild(root_child0, 0);
|
||||||
|
|
||||||
|
const root_child0_child0 = Yoga.Node.create(config);
|
||||||
|
root_child0_child0.setFlexDirection(FlexDirection.ColumnReverse);
|
||||||
|
root_child0_child0.setPositionType(PositionType.Static);
|
||||||
|
root_child0_child0.setWidth(100);
|
||||||
|
root_child0_child0.setHeight(100);
|
||||||
|
root_child0.insertChild(root_child0_child0, 0);
|
||||||
|
|
||||||
|
const root_child0_child0_child0 = Yoga.Node.create(config);
|
||||||
|
root_child0_child0_child0.setPositionType(PositionType.Absolute);
|
||||||
|
root_child0_child0_child0.setPosition(Edge.Top, 50);
|
||||||
|
root_child0_child0_child0.setPosition(Edge.Right, 50);
|
||||||
|
root_child0_child0_child0.setWidth(50);
|
||||||
|
root_child0_child0_child0.setHeight(50);
|
||||||
|
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
||||||
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
||||||
|
|
||||||
|
expect(root.getComputedLeft()).toBe(0);
|
||||||
|
expect(root.getComputedTop()).toBe(0);
|
||||||
|
expect(root.getComputedWidth()).toBe(200);
|
||||||
|
expect(root.getComputedHeight()).toBe(200);
|
||||||
|
|
||||||
|
expect(root_child0.getComputedLeft()).toBe(0);
|
||||||
|
expect(root_child0.getComputedTop()).toBe(0);
|
||||||
|
expect(root_child0.getComputedWidth()).toBe(200);
|
||||||
|
expect(root_child0.getComputedHeight()).toBe(200);
|
||||||
|
|
||||||
|
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
||||||
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
||||||
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
||||||
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
||||||
|
|
||||||
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(100);
|
||||||
|
expect(root_child0_child0_child0.getComputedTop()).toBe(50);
|
||||||
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
||||||
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
||||||
|
|
||||||
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
||||||
|
|
||||||
|
expect(root.getComputedLeft()).toBe(0);
|
||||||
|
expect(root.getComputedTop()).toBe(0);
|
||||||
|
expect(root.getComputedWidth()).toBe(200);
|
||||||
|
expect(root.getComputedHeight()).toBe(200);
|
||||||
|
|
||||||
|
expect(root_child0.getComputedLeft()).toBe(0);
|
||||||
|
expect(root_child0.getComputedTop()).toBe(0);
|
||||||
|
expect(root_child0.getComputedWidth()).toBe(200);
|
||||||
|
expect(root_child0.getComputedHeight()).toBe(200);
|
||||||
|
|
||||||
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
||||||
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
||||||
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
||||||
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
||||||
|
|
||||||
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(0);
|
||||||
|
expect(root_child0_child0_child0.getComputedTop()).toBe(50);
|
||||||
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
||||||
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
||||||
|
} finally {
|
||||||
|
if (typeof root !== 'undefined') {
|
||||||
|
root.freeRecursive();
|
||||||
|
}
|
||||||
|
|
||||||
|
config.free();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
test('static_position_absolute_child_insets_relative_to_positioned_ancestor_column_reverse', () => {
|
||||||
|
const config = Yoga.Config.create();
|
||||||
|
let root;
|
||||||
|
|
||||||
|
try {
|
||||||
|
root = Yoga.Node.create(config);
|
||||||
|
root.setPositionType(PositionType.Absolute);
|
||||||
|
|
||||||
|
const root_child0 = Yoga.Node.create(config);
|
||||||
|
root_child0.setFlexDirection(FlexDirection.ColumnReverse);
|
||||||
|
root_child0.setWidth(200);
|
||||||
|
root_child0.setHeight(200);
|
||||||
|
root.insertChild(root_child0, 0);
|
||||||
|
|
||||||
|
const root_child0_child0 = Yoga.Node.create(config);
|
||||||
|
root_child0_child0.setPositionType(PositionType.Static);
|
||||||
|
root_child0_child0.setWidth(100);
|
||||||
|
root_child0_child0.setHeight(100);
|
||||||
|
root_child0.insertChild(root_child0_child0, 0);
|
||||||
|
|
||||||
|
const root_child0_child0_child0 = Yoga.Node.create(config);
|
||||||
|
root_child0_child0_child0.setPositionType(PositionType.Absolute);
|
||||||
|
root_child0_child0_child0.setPosition(Edge.Top, 50);
|
||||||
|
root_child0_child0_child0.setPosition(Edge.Right, 50);
|
||||||
|
root_child0_child0_child0.setWidth(50);
|
||||||
|
root_child0_child0_child0.setHeight(50);
|
||||||
|
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
||||||
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
||||||
|
|
||||||
|
expect(root.getComputedLeft()).toBe(0);
|
||||||
|
expect(root.getComputedTop()).toBe(0);
|
||||||
|
expect(root.getComputedWidth()).toBe(200);
|
||||||
|
expect(root.getComputedHeight()).toBe(200);
|
||||||
|
|
||||||
|
expect(root_child0.getComputedLeft()).toBe(0);
|
||||||
|
expect(root_child0.getComputedTop()).toBe(0);
|
||||||
|
expect(root_child0.getComputedWidth()).toBe(200);
|
||||||
|
expect(root_child0.getComputedHeight()).toBe(200);
|
||||||
|
|
||||||
|
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
||||||
|
expect(root_child0_child0.getComputedTop()).toBe(100);
|
||||||
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
||||||
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
||||||
|
|
||||||
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(100);
|
||||||
|
expect(root_child0_child0_child0.getComputedTop()).toBe(-50);
|
||||||
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
||||||
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
||||||
|
|
||||||
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
||||||
|
|
||||||
|
expect(root.getComputedLeft()).toBe(0);
|
||||||
|
expect(root.getComputedTop()).toBe(0);
|
||||||
|
expect(root.getComputedWidth()).toBe(200);
|
||||||
|
expect(root.getComputedHeight()).toBe(200);
|
||||||
|
|
||||||
|
expect(root_child0.getComputedLeft()).toBe(0);
|
||||||
|
expect(root_child0.getComputedTop()).toBe(0);
|
||||||
|
expect(root_child0.getComputedWidth()).toBe(200);
|
||||||
|
expect(root_child0.getComputedHeight()).toBe(200);
|
||||||
|
|
||||||
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
||||||
|
expect(root_child0_child0.getComputedTop()).toBe(100);
|
||||||
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
||||||
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
||||||
|
|
||||||
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(0);
|
||||||
|
expect(root_child0_child0_child0.getComputedTop()).toBe(-50);
|
||||||
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
||||||
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
||||||
|
} finally {
|
||||||
|
if (typeof root !== 'undefined') {
|
||||||
|
root.freeRecursive();
|
||||||
|
}
|
||||||
|
|
||||||
|
config.free();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
test('column_reverse_static_position_absolute_child_insets_relative_to_positioned_ancestor_column_reverse', () => {
|
||||||
|
const config = Yoga.Config.create();
|
||||||
|
let root;
|
||||||
|
|
||||||
|
try {
|
||||||
|
root = Yoga.Node.create(config);
|
||||||
|
root.setPositionType(PositionType.Absolute);
|
||||||
|
|
||||||
|
const root_child0 = Yoga.Node.create(config);
|
||||||
|
root_child0.setFlexDirection(FlexDirection.ColumnReverse);
|
||||||
|
root_child0.setWidth(200);
|
||||||
|
root_child0.setHeight(200);
|
||||||
|
root.insertChild(root_child0, 0);
|
||||||
|
|
||||||
|
const root_child0_child0 = Yoga.Node.create(config);
|
||||||
|
root_child0_child0.setFlexDirection(FlexDirection.ColumnReverse);
|
||||||
|
root_child0_child0.setPositionType(PositionType.Static);
|
||||||
|
root_child0_child0.setWidth(100);
|
||||||
|
root_child0_child0.setHeight(100);
|
||||||
|
root_child0.insertChild(root_child0_child0, 0);
|
||||||
|
|
||||||
|
const root_child0_child0_child0 = Yoga.Node.create(config);
|
||||||
|
root_child0_child0_child0.setPositionType(PositionType.Absolute);
|
||||||
|
root_child0_child0_child0.setPosition(Edge.Top, 50);
|
||||||
|
root_child0_child0_child0.setPosition(Edge.Right, 50);
|
||||||
|
root_child0_child0_child0.setWidth(50);
|
||||||
|
root_child0_child0_child0.setHeight(50);
|
||||||
|
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
||||||
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
||||||
|
|
||||||
|
expect(root.getComputedLeft()).toBe(0);
|
||||||
|
expect(root.getComputedTop()).toBe(0);
|
||||||
|
expect(root.getComputedWidth()).toBe(200);
|
||||||
|
expect(root.getComputedHeight()).toBe(200);
|
||||||
|
|
||||||
|
expect(root_child0.getComputedLeft()).toBe(0);
|
||||||
|
expect(root_child0.getComputedTop()).toBe(0);
|
||||||
|
expect(root_child0.getComputedWidth()).toBe(200);
|
||||||
|
expect(root_child0.getComputedHeight()).toBe(200);
|
||||||
|
|
||||||
|
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
||||||
|
expect(root_child0_child0.getComputedTop()).toBe(100);
|
||||||
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
||||||
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
||||||
|
|
||||||
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(100);
|
||||||
|
expect(root_child0_child0_child0.getComputedTop()).toBe(-50);
|
||||||
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
||||||
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
||||||
|
|
||||||
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
||||||
|
|
||||||
|
expect(root.getComputedLeft()).toBe(0);
|
||||||
|
expect(root.getComputedTop()).toBe(0);
|
||||||
|
expect(root.getComputedWidth()).toBe(200);
|
||||||
|
expect(root.getComputedHeight()).toBe(200);
|
||||||
|
|
||||||
|
expect(root_child0.getComputedLeft()).toBe(0);
|
||||||
|
expect(root_child0.getComputedTop()).toBe(0);
|
||||||
|
expect(root_child0.getComputedWidth()).toBe(200);
|
||||||
|
expect(root_child0.getComputedHeight()).toBe(200);
|
||||||
|
|
||||||
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
||||||
|
expect(root_child0_child0.getComputedTop()).toBe(100);
|
||||||
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
||||||
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
||||||
|
|
||||||
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(0);
|
||||||
|
expect(root_child0_child0_child0.getComputedTop()).toBe(-50);
|
||||||
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
||||||
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
||||||
|
} finally {
|
||||||
|
if (typeof root !== 'undefined') {
|
||||||
|
root.freeRecursive();
|
||||||
|
}
|
||||||
|
|
||||||
|
config.free();
|
||||||
|
}
|
||||||
|
});
|
||||||
test('static_position_absolute_child_insets_relative_to_positioned_ancestor_deep', () => {
|
test('static_position_absolute_child_insets_relative_to_positioned_ancestor_deep', () => {
|
||||||
const config = Yoga.Config.create();
|
const config = Yoga.Config.create();
|
||||||
let root;
|
let root;
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*
|
*
|
||||||
* clang-format off
|
* clang-format off
|
||||||
* @generated SignedSource<<226206f3d75249490b25108c85ae51c0>>
|
* @generated SignedSource<<a50664b5921773c99dd44ee9ff4f855f>>
|
||||||
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGStaticPositionTest.html
|
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGStaticPositionTest.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -170,6 +170,453 @@ TEST(YogaTest, static_position_absolute_child_insets_relative_to_positioned_ance
|
|||||||
YGConfigFree(config);
|
YGConfigFree(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(YogaTest, static_position_absolute_child_insets_relative_to_positioned_ancestor_row_reverse) {
|
||||||
|
const YGConfigRef config = YGConfigNew();
|
||||||
|
|
||||||
|
const YGNodeRef root = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRowReverse);
|
||||||
|
YGNodeStyleSetWidth(root_child0, 200);
|
||||||
|
YGNodeStyleSetHeight(root_child0, 200);
|
||||||
|
YGNodeInsertChild(root, root_child0, 0);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeStyleSetPositionType(root_child0_child0, YGPositionTypeStatic);
|
||||||
|
YGNodeStyleSetWidth(root_child0_child0, 100);
|
||||||
|
YGNodeStyleSetHeight(root_child0_child0, 100);
|
||||||
|
YGNodeInsertChild(root_child0, root_child0_child0, 0);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0_child0_child0 = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeStyleSetPositionType(root_child0_child0_child0, YGPositionTypeAbsolute);
|
||||||
|
YGNodeStyleSetPosition(root_child0_child0_child0, YGEdgeLeft, 50);
|
||||||
|
YGNodeStyleSetPosition(root_child0_child0_child0, YGEdgeTop, 50);
|
||||||
|
YGNodeStyleSetWidth(root_child0_child0_child0, 50);
|
||||||
|
YGNodeStyleSetHeight(root_child0_child0_child0, 50);
|
||||||
|
YGNodeInsertChild(root_child0_child0, root_child0_child0_child0, 0);
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(-50, YGNodeLayoutGetLeft(root_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0_child0_child0));
|
||||||
|
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0_child0_child0));
|
||||||
|
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
|
||||||
|
YGConfigFree(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(YogaTest, column_reverse_static_position_absolute_child_insets_relative_to_positioned_ancestor_row_reverse) {
|
||||||
|
const YGConfigRef config = YGConfigNew();
|
||||||
|
|
||||||
|
const YGNodeRef root = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRowReverse);
|
||||||
|
YGNodeStyleSetWidth(root_child0, 200);
|
||||||
|
YGNodeStyleSetHeight(root_child0, 200);
|
||||||
|
YGNodeInsertChild(root, root_child0, 0);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeStyleSetFlexDirection(root_child0_child0, YGFlexDirectionColumnReverse);
|
||||||
|
YGNodeStyleSetPositionType(root_child0_child0, YGPositionTypeStatic);
|
||||||
|
YGNodeStyleSetWidth(root_child0_child0, 100);
|
||||||
|
YGNodeStyleSetHeight(root_child0_child0, 100);
|
||||||
|
YGNodeInsertChild(root_child0, root_child0_child0, 0);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0_child0_child0 = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeStyleSetPositionType(root_child0_child0_child0, YGPositionTypeAbsolute);
|
||||||
|
YGNodeStyleSetPosition(root_child0_child0_child0, YGEdgeLeft, 50);
|
||||||
|
YGNodeStyleSetPosition(root_child0_child0_child0, YGEdgeTop, 50);
|
||||||
|
YGNodeStyleSetWidth(root_child0_child0_child0, 50);
|
||||||
|
YGNodeStyleSetHeight(root_child0_child0_child0, 50);
|
||||||
|
YGNodeInsertChild(root_child0_child0, root_child0_child0_child0, 0);
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(-50, YGNodeLayoutGetLeft(root_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0_child0_child0));
|
||||||
|
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0_child0_child0));
|
||||||
|
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
|
||||||
|
YGConfigFree(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(YogaTest, static_position_absolute_child_insets_relative_to_positioned_ancestor_row) {
|
||||||
|
const YGConfigRef config = YGConfigNew();
|
||||||
|
|
||||||
|
const YGNodeRef root = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow);
|
||||||
|
YGNodeStyleSetWidth(root_child0, 200);
|
||||||
|
YGNodeStyleSetHeight(root_child0, 200);
|
||||||
|
YGNodeInsertChild(root, root_child0, 0);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeStyleSetPositionType(root_child0_child0, YGPositionTypeStatic);
|
||||||
|
YGNodeStyleSetWidth(root_child0_child0, 100);
|
||||||
|
YGNodeStyleSetHeight(root_child0_child0, 100);
|
||||||
|
YGNodeInsertChild(root_child0, root_child0_child0, 0);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0_child0_child0 = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeStyleSetPositionType(root_child0_child0_child0, YGPositionTypeAbsolute);
|
||||||
|
YGNodeStyleSetPosition(root_child0_child0_child0, YGEdgeTop, 50);
|
||||||
|
YGNodeStyleSetPosition(root_child0_child0_child0, YGEdgeRight, 50);
|
||||||
|
YGNodeStyleSetWidth(root_child0_child0_child0, 50);
|
||||||
|
YGNodeStyleSetHeight(root_child0_child0_child0, 50);
|
||||||
|
YGNodeInsertChild(root_child0_child0, root_child0_child0_child0, 0);
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0_child0_child0));
|
||||||
|
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0_child0_child0));
|
||||||
|
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
|
||||||
|
YGConfigFree(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(YogaTest, column_reverse_static_position_absolute_child_insets_relative_to_positioned_ancestor_row) {
|
||||||
|
const YGConfigRef config = YGConfigNew();
|
||||||
|
|
||||||
|
const YGNodeRef root = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow);
|
||||||
|
YGNodeStyleSetWidth(root_child0, 200);
|
||||||
|
YGNodeStyleSetHeight(root_child0, 200);
|
||||||
|
YGNodeInsertChild(root, root_child0, 0);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeStyleSetFlexDirection(root_child0_child0, YGFlexDirectionColumnReverse);
|
||||||
|
YGNodeStyleSetPositionType(root_child0_child0, YGPositionTypeStatic);
|
||||||
|
YGNodeStyleSetWidth(root_child0_child0, 100);
|
||||||
|
YGNodeStyleSetHeight(root_child0_child0, 100);
|
||||||
|
YGNodeInsertChild(root_child0, root_child0_child0, 0);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0_child0_child0 = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeStyleSetPositionType(root_child0_child0_child0, YGPositionTypeAbsolute);
|
||||||
|
YGNodeStyleSetPosition(root_child0_child0_child0, YGEdgeTop, 50);
|
||||||
|
YGNodeStyleSetPosition(root_child0_child0_child0, YGEdgeRight, 50);
|
||||||
|
YGNodeStyleSetWidth(root_child0_child0_child0, 50);
|
||||||
|
YGNodeStyleSetHeight(root_child0_child0_child0, 50);
|
||||||
|
YGNodeInsertChild(root_child0_child0, root_child0_child0_child0, 0);
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0_child0_child0));
|
||||||
|
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0_child0_child0));
|
||||||
|
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
|
||||||
|
YGConfigFree(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(YogaTest, static_position_absolute_child_insets_relative_to_positioned_ancestor_column_reverse) {
|
||||||
|
const YGConfigRef config = YGConfigNew();
|
||||||
|
|
||||||
|
const YGNodeRef root = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionColumnReverse);
|
||||||
|
YGNodeStyleSetWidth(root_child0, 200);
|
||||||
|
YGNodeStyleSetHeight(root_child0, 200);
|
||||||
|
YGNodeInsertChild(root, root_child0, 0);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeStyleSetPositionType(root_child0_child0, YGPositionTypeStatic);
|
||||||
|
YGNodeStyleSetWidth(root_child0_child0, 100);
|
||||||
|
YGNodeStyleSetHeight(root_child0_child0, 100);
|
||||||
|
YGNodeInsertChild(root_child0, root_child0_child0, 0);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0_child0_child0 = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeStyleSetPositionType(root_child0_child0_child0, YGPositionTypeAbsolute);
|
||||||
|
YGNodeStyleSetPosition(root_child0_child0_child0, YGEdgeTop, 50);
|
||||||
|
YGNodeStyleSetPosition(root_child0_child0_child0, YGEdgeRight, 50);
|
||||||
|
YGNodeStyleSetWidth(root_child0_child0_child0, 50);
|
||||||
|
YGNodeStyleSetHeight(root_child0_child0_child0, 50);
|
||||||
|
YGNodeInsertChild(root_child0_child0, root_child0_child0_child0, 0);
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(-50, YGNodeLayoutGetTop(root_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0_child0_child0));
|
||||||
|
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(-50, YGNodeLayoutGetTop(root_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0_child0_child0));
|
||||||
|
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
|
||||||
|
YGConfigFree(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(YogaTest, column_reverse_static_position_absolute_child_insets_relative_to_positioned_ancestor_column_reverse) {
|
||||||
|
const YGConfigRef config = YGConfigNew();
|
||||||
|
|
||||||
|
const YGNodeRef root = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionColumnReverse);
|
||||||
|
YGNodeStyleSetWidth(root_child0, 200);
|
||||||
|
YGNodeStyleSetHeight(root_child0, 200);
|
||||||
|
YGNodeInsertChild(root, root_child0, 0);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeStyleSetFlexDirection(root_child0_child0, YGFlexDirectionColumnReverse);
|
||||||
|
YGNodeStyleSetPositionType(root_child0_child0, YGPositionTypeStatic);
|
||||||
|
YGNodeStyleSetWidth(root_child0_child0, 100);
|
||||||
|
YGNodeStyleSetHeight(root_child0_child0, 100);
|
||||||
|
YGNodeInsertChild(root_child0, root_child0_child0, 0);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0_child0_child0 = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeStyleSetPositionType(root_child0_child0_child0, YGPositionTypeAbsolute);
|
||||||
|
YGNodeStyleSetPosition(root_child0_child0_child0, YGEdgeTop, 50);
|
||||||
|
YGNodeStyleSetPosition(root_child0_child0_child0, YGEdgeRight, 50);
|
||||||
|
YGNodeStyleSetWidth(root_child0_child0_child0, 50);
|
||||||
|
YGNodeStyleSetHeight(root_child0_child0_child0, 50);
|
||||||
|
YGNodeInsertChild(root_child0_child0, root_child0_child0_child0, 0);
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(-50, YGNodeLayoutGetTop(root_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0_child0_child0));
|
||||||
|
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(-50, YGNodeLayoutGetTop(root_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0_child0_child0));
|
||||||
|
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
|
||||||
|
YGConfigFree(config);
|
||||||
|
}
|
||||||
|
|
||||||
TEST(YogaTest, static_position_absolute_child_insets_relative_to_positioned_ancestor_deep) {
|
TEST(YogaTest, static_position_absolute_child_insets_relative_to_positioned_ancestor_deep) {
|
||||||
const YGConfigRef config = YGConfigNew();
|
const YGConfigRef config = YGConfigNew();
|
||||||
|
|
||||||
|
@@ -27,7 +27,7 @@
|
|||||||
"react": "^18.0.0",
|
"react": "^18.0.0",
|
||||||
"react-dom": "^18.0.0",
|
"react-dom": "^18.0.0",
|
||||||
"react-live": "^4.1.5",
|
"react-live": "^4.1.5",
|
||||||
"yoga-layout": "0.0.0"
|
"yoga-layout": "3.0.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@docusaurus/module-type-aliases": "3.0.0",
|
"@docusaurus/module-type-aliases": "3.0.0",
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
# Yoga documentation and playground
|
# Yoga legacy documentation and playground
|
||||||
|
|
||||||
This site uses [gatsby.js](https://www.gatsbyjs.org/) as static site generator. Which transforms all markdown and react code to static HTML and JS files.
|
This site uses [gatsby.js](https://www.gatsbyjs.org/) as static site generator. Which transforms all markdown and react code to static HTML and JS files.
|
||||||
|
|
||||||
|
@@ -480,14 +480,10 @@ void layoutAbsoluteDescendants(
|
|||||||
LayoutData& layoutMarkerData,
|
LayoutData& layoutMarkerData,
|
||||||
uint32_t currentDepth,
|
uint32_t currentDepth,
|
||||||
uint32_t generationCount,
|
uint32_t generationCount,
|
||||||
float currentNodeMainOffsetFromContainingBlock,
|
float currentNodeLeftOffsetFromContainingBlock,
|
||||||
float currentNodeCrossOffsetFromContainingBlock,
|
float currentNodeTopOffsetFromContainingBlock,
|
||||||
float containingNodeAvailableInnerWidth,
|
float containingNodeAvailableInnerWidth,
|
||||||
float containingNodeAvailableInnerHeight) {
|
float containingNodeAvailableInnerHeight) {
|
||||||
const FlexDirection mainAxis = resolveDirection(
|
|
||||||
currentNode->style().flexDirection(), currentNodeDirection);
|
|
||||||
const FlexDirection crossAxis =
|
|
||||||
resolveCrossDirection(mainAxis, currentNodeDirection);
|
|
||||||
for (auto child : currentNode->getChildren()) {
|
for (auto child : currentNode->getChildren()) {
|
||||||
if (child->style().display() == Display::None) {
|
if (child->style().display() == Display::None) {
|
||||||
continue;
|
continue;
|
||||||
@@ -516,45 +512,73 @@ void layoutAbsoluteDescendants(
|
|||||||
currentDepth,
|
currentDepth,
|
||||||
generationCount);
|
generationCount);
|
||||||
|
|
||||||
const bool isMainAxisRow = isRow(mainAxis);
|
/*
|
||||||
const bool mainInsetsDefined = isMainAxisRow
|
* At this point the child has its position set but only on its the
|
||||||
? child->style().horizontalInsetsDefined()
|
* parent's flexStart edge. Additionally, this position should be
|
||||||
: child->style().verticalInsetsDefined();
|
* interpreted relative to the containing block of the child if it had
|
||||||
const bool crossInsetsDefined = isMainAxisRow
|
* insets defined. So we need to adjust the position by subtracting the
|
||||||
? child->style().verticalInsetsDefined()
|
* the parents offset from the containing block. However, getting that
|
||||||
: child->style().horizontalInsetsDefined();
|
* offset is complicated since the two nodes can have different main/cross
|
||||||
|
* axes.
|
||||||
|
*/
|
||||||
|
const FlexDirection parentMainAxis = resolveDirection(
|
||||||
|
currentNode->style().flexDirection(), currentNodeDirection);
|
||||||
|
const FlexDirection parentCrossAxis =
|
||||||
|
resolveCrossDirection(parentMainAxis, currentNodeDirection);
|
||||||
|
|
||||||
const float childMainOffsetFromParent = mainInsetsDefined
|
if (needsTrailingPosition(parentMainAxis)) {
|
||||||
? (child->getLayout().position(flexStartEdge(mainAxis)) -
|
const bool mainInsetsDefined = isRow(parentMainAxis)
|
||||||
currentNodeMainOffsetFromContainingBlock)
|
? child->style().horizontalInsetsDefined()
|
||||||
: child->getLayout().position(flexStartEdge(mainAxis));
|
: child->style().verticalInsetsDefined();
|
||||||
const float childCrossOffsetFromParent = crossInsetsDefined
|
setChildTrailingPosition(
|
||||||
? (child->getLayout().position(flexStartEdge(crossAxis)) -
|
mainInsetsDefined ? containingNode : currentNode,
|
||||||
currentNodeCrossOffsetFromContainingBlock)
|
child,
|
||||||
: child->getLayout().position(flexStartEdge(crossAxis));
|
parentMainAxis);
|
||||||
|
|
||||||
child->setLayoutPosition(
|
|
||||||
childMainOffsetFromParent, flexStartEdge(mainAxis));
|
|
||||||
child->setLayoutPosition(
|
|
||||||
childCrossOffsetFromParent, flexStartEdge(crossAxis));
|
|
||||||
|
|
||||||
if (needsTrailingPosition(mainAxis)) {
|
|
||||||
setChildTrailingPosition(currentNode, child, mainAxis);
|
|
||||||
}
|
}
|
||||||
if (needsTrailingPosition(crossAxis)) {
|
if (needsTrailingPosition(parentCrossAxis)) {
|
||||||
setChildTrailingPosition(currentNode, child, crossAxis);
|
const bool crossInsetsDefined = isRow(parentCrossAxis)
|
||||||
|
? child->style().horizontalInsetsDefined()
|
||||||
|
: child->style().verticalInsetsDefined();
|
||||||
|
setChildTrailingPosition(
|
||||||
|
crossInsetsDefined ? containingNode : currentNode,
|
||||||
|
child,
|
||||||
|
parentCrossAxis);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* At this point we know the left and top physical edges of the child are
|
||||||
|
* set with positions that are relative to the containing block if insets
|
||||||
|
* are defined
|
||||||
|
*/
|
||||||
|
const float childLeftPosition =
|
||||||
|
child->getLayout().position(PhysicalEdge::Left);
|
||||||
|
const float childTopPosition =
|
||||||
|
child->getLayout().position(PhysicalEdge::Top);
|
||||||
|
|
||||||
|
const float childLeftOffsetFromParent =
|
||||||
|
child->style().horizontalInsetsDefined()
|
||||||
|
? (childLeftPosition - currentNodeLeftOffsetFromContainingBlock)
|
||||||
|
: childLeftPosition;
|
||||||
|
const float childTopOffsetFromParent =
|
||||||
|
child->style().verticalInsetsDefined()
|
||||||
|
? (childTopPosition - currentNodeTopOffsetFromContainingBlock)
|
||||||
|
: childTopPosition;
|
||||||
|
|
||||||
|
child->setLayoutPosition(childLeftOffsetFromParent, PhysicalEdge::Left);
|
||||||
|
child->setLayoutPosition(childTopOffsetFromParent, PhysicalEdge::Top);
|
||||||
} else if (
|
} else if (
|
||||||
child->style().positionType() == PositionType::Static &&
|
child->style().positionType() == PositionType::Static &&
|
||||||
!child->alwaysFormsContainingBlock()) {
|
!child->alwaysFormsContainingBlock()) {
|
||||||
const Direction childDirection =
|
const Direction childDirection =
|
||||||
child->resolveDirection(currentNodeDirection);
|
child->resolveDirection(currentNodeDirection);
|
||||||
const float childMainOffsetFromContainingBlock =
|
// By now all descendants of the containing block that are not absolute
|
||||||
currentNodeMainOffsetFromContainingBlock +
|
// will have their positions set for left and top.
|
||||||
child->getLayout().position(flexStartEdge(mainAxis));
|
const float childLeftOffsetFromContainingBlock =
|
||||||
const float childCrossOffsetFromContainingBlock =
|
currentNodeLeftOffsetFromContainingBlock +
|
||||||
currentNodeCrossOffsetFromContainingBlock +
|
child->getLayout().position(PhysicalEdge::Left);
|
||||||
child->getLayout().position(flexStartEdge(crossAxis));
|
const float childTopOffsetFromContainingBlock =
|
||||||
|
currentNodeTopOffsetFromContainingBlock +
|
||||||
|
child->getLayout().position(PhysicalEdge::Top);
|
||||||
|
|
||||||
layoutAbsoluteDescendants(
|
layoutAbsoluteDescendants(
|
||||||
containingNode,
|
containingNode,
|
||||||
@@ -564,8 +588,8 @@ void layoutAbsoluteDescendants(
|
|||||||
layoutMarkerData,
|
layoutMarkerData,
|
||||||
currentDepth + 1,
|
currentDepth + 1,
|
||||||
generationCount,
|
generationCount,
|
||||||
childMainOffsetFromContainingBlock,
|
childLeftOffsetFromContainingBlock,
|
||||||
childCrossOffsetFromContainingBlock,
|
childTopOffsetFromContainingBlock,
|
||||||
containingNodeAvailableInnerWidth,
|
containingNodeAvailableInnerWidth,
|
||||||
containingNodeAvailableInnerHeight);
|
containingNodeAvailableInnerHeight);
|
||||||
}
|
}
|
||||||
|
@@ -2045,26 +2045,7 @@ static void calculateLayoutImpl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (performLayout) {
|
if (performLayout) {
|
||||||
// STEP 10: SIZING AND POSITIONING ABSOLUTE CHILDREN
|
// STEP 10: SETTING TRAILING POSITIONS FOR CHILDREN
|
||||||
// Let the containing block layout its absolute descendants. By definition
|
|
||||||
// the containing block will not be static unless we are at the root.
|
|
||||||
if (node->style().positionType() != PositionType::Static ||
|
|
||||||
node->alwaysFormsContainingBlock() || depth == 1) {
|
|
||||||
layoutAbsoluteDescendants(
|
|
||||||
node,
|
|
||||||
node,
|
|
||||||
isMainAxisRow ? sizingModeMainDim : sizingModeCrossDim,
|
|
||||||
direction,
|
|
||||||
layoutMarkerData,
|
|
||||||
depth,
|
|
||||||
generationCount,
|
|
||||||
0.0f,
|
|
||||||
0.0f,
|
|
||||||
availableInnerWidth,
|
|
||||||
availableInnerHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
// STEP 11: SETTING TRAILING POSITIONS FOR CHILDREN
|
|
||||||
const bool needsMainTrailingPos = needsTrailingPosition(mainAxis);
|
const bool needsMainTrailingPos = needsTrailingPosition(mainAxis);
|
||||||
const bool needsCrossTrailingPos = needsTrailingPosition(crossAxis);
|
const bool needsCrossTrailingPos = needsTrailingPosition(crossAxis);
|
||||||
|
|
||||||
@@ -2087,6 +2068,24 @@ static void calculateLayoutImpl(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// STEP 11: SIZING AND POSITIONING ABSOLUTE CHILDREN
|
||||||
|
// Let the containing block layout its absolute descendants.
|
||||||
|
if (node->style().positionType() != PositionType::Static ||
|
||||||
|
node->alwaysFormsContainingBlock() || depth == 1) {
|
||||||
|
layoutAbsoluteDescendants(
|
||||||
|
node,
|
||||||
|
node,
|
||||||
|
isMainAxisRow ? sizingModeMainDim : sizingModeCrossDim,
|
||||||
|
direction,
|
||||||
|
layoutMarkerData,
|
||||||
|
depth,
|
||||||
|
generationCount,
|
||||||
|
0.0f,
|
||||||
|
0.0f,
|
||||||
|
availableInnerWidth,
|
||||||
|
availableInnerHeight);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user