Compare commits
49 Commits
v3.2.0
...
export-D80
Author | SHA1 | Date | |
---|---|---|---|
|
4e75c24b99 | ||
|
c582f7caa6 | ||
|
bf1cbd29c0 | ||
|
499a825836 | ||
|
8087edaafe | ||
|
c90aecbdfe | ||
|
c54215fd77 | ||
|
cf50bc9adf | ||
|
d1037226c0 | ||
|
714d4b2ebe | ||
|
d4b5220e6c | ||
|
da5ba7f7c6 | ||
|
8bf7a34d02 | ||
|
82671c0132 | ||
|
9f2a9476e5 | ||
|
c7c85621fc | ||
|
73980a3cf8 | ||
|
4b5ca50117 | ||
|
30291398f3 | ||
|
27d632c697 | ||
|
117fa494f7 | ||
|
073c136117 | ||
|
1232761571 | ||
|
c935fd5e10 | ||
|
624325302c | ||
|
37a94a86de | ||
|
4abc1a7d5f | ||
|
51e6095005 | ||
|
79cef614ce | ||
|
6455a848a7 | ||
|
1b7d2c8d48 | ||
|
3aa594c1f9 | ||
|
c2ae39167e | ||
|
49ee855f99 | ||
|
b12e0a2a15 | ||
|
9591210a7a | ||
|
91997d6cd3 | ||
|
909e4bea6e | ||
|
13f4adbbcd | ||
|
ae2d06d0f5 | ||
|
5478812db3 | ||
|
050ac8a413 | ||
|
733ba24064 | ||
|
e177477144 | ||
|
76ffdbc25d | ||
|
f99e657acd | ||
|
a9246bc7db | ||
|
be72b8e8aa | ||
|
b876f596d9 |
23
.github/actions/clang-format/action.yml
vendored
23
.github/actions/clang-format/action.yml
vendored
@@ -1,23 +0,0 @@
|
|||||||
name: Clang Format
|
|
||||||
inputs:
|
|
||||||
directory:
|
|
||||||
description: Directory to Lint
|
|
||||||
required: true
|
|
||||||
version:
|
|
||||||
description: LLVM version to use # Should be kept roughly in sync with arcanist
|
|
||||||
required: false
|
|
||||||
default: 12
|
|
||||||
|
|
||||||
runs:
|
|
||||||
using: "composite"
|
|
||||||
steps:
|
|
||||||
- name: Install
|
|
||||||
shell: bash
|
|
||||||
run: sudo apt-get install -y clang-format-${{ inputs.version }}
|
|
||||||
|
|
||||||
- name: clang-format
|
|
||||||
working-directory: ${{ inputs.directory }}
|
|
||||||
shell: bash
|
|
||||||
env:
|
|
||||||
BASHOPTS: extglob:nullglob
|
|
||||||
run: clang-format-${{ inputs.version }} --dry-run --Werror **/*.{h,hh,hpp,c,cpp,cc,m,mm}
|
|
1
.github/actions/setup-cpp/action.yml
vendored
1
.github/actions/setup-cpp/action.yml
vendored
@@ -16,6 +16,7 @@ runs:
|
|||||||
if: ${{ inputs.toolchain == 'Clang' }}
|
if: ${{ inputs.toolchain == 'Clang' }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
|
sudo apt-get install -y libc++-dev libc++abi-dev
|
||||||
echo "CC=/usr/bin/clang" >> $GITHUB_ENV
|
echo "CC=/usr/bin/clang" >> $GITHUB_ENV
|
||||||
echo "CXX=/usr/bin/clang++" >> $GITHUB_ENV
|
echo "CXX=/usr/bin/clang++" >> $GITHUB_ENV
|
||||||
echo "CXXFLAGS=-stdlib=libc++" >> $GITHUB_ENV
|
echo "CXXFLAGS=-stdlib=libc++" >> $GITHUB_ENV
|
||||||
|
@@ -24,7 +24,7 @@ jobs:
|
|||||||
ORG_GRADLE_PROJECT_SIGNING_PWD: ${{ secrets.ORG_GRADLE_PROJECT_SIGNING_PWD }}
|
ORG_GRADLE_PROJECT_SIGNING_PWD: ${{ secrets.ORG_GRADLE_PROJECT_SIGNING_PWD }}
|
||||||
|
|
||||||
- name: Upload Build Artifacts
|
- name: Upload Build Artifacts
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: 'snapshot-artifacts'
|
name: 'snapshot-artifacts'
|
||||||
path: '~/.m2/repository/'
|
path: '~/.m2/repository/'
|
||||||
|
@@ -23,7 +23,7 @@ jobs:
|
|||||||
ORG_GRADLE_PROJECT_USE_SNAPSHOT: true
|
ORG_GRADLE_PROJECT_USE_SNAPSHOT: true
|
||||||
|
|
||||||
- name: Upload Build Artifacts
|
- name: Upload Build Artifacts
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: 'snapshot-artifacts'
|
name: 'snapshot-artifacts'
|
||||||
path: '~/.m2/repository/'
|
path: '~/.m2/repository/'
|
||||||
|
10
.github/workflows/validate-cpp.yml
vendored
10
.github/workflows/validate-cpp.yml
vendored
@@ -97,13 +97,3 @@ jobs:
|
|||||||
cmake -S . -B build -G Ninja -D CMAKE_BUILD_TYPE=Release
|
cmake -S . -B build -G Ninja -D CMAKE_BUILD_TYPE=Release
|
||||||
cmake --build build
|
cmake --build build
|
||||||
working-directory: capture
|
working-directory: capture
|
||||||
|
|
||||||
clang-format:
|
|
||||||
name: Format
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: clang-format
|
|
||||||
uses: ./.github/actions/clang-format
|
|
||||||
|
2
.github/workflows/validate-js.yml
vendored
2
.github/workflows/validate-js.yml
vendored
@@ -110,7 +110,7 @@ jobs:
|
|||||||
run: yarn pack --filename yoga-layout.tar.gz
|
run: yarn pack --filename yoga-layout.tar.gz
|
||||||
working-directory: javascript
|
working-directory: javascript
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: npm-package
|
name: npm-package
|
||||||
path: javascript/yoga-layout.tar.gz
|
path: javascript/yoga-layout.tar.gz
|
||||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@@ -73,3 +73,6 @@ local.properties
|
|||||||
|
|
||||||
# Docusarus build
|
# Docusarus build
|
||||||
.docusaurus
|
.docusaurus
|
||||||
|
|
||||||
|
# Android Studio
|
||||||
|
.idea
|
||||||
|
@@ -9,6 +9,7 @@ plugins {
|
|||||||
id("com.android.library") version "8.7.1" apply false
|
id("com.android.library") version "8.7.1" apply false
|
||||||
id("com.android.application") version "8.7.1" apply false
|
id("com.android.application") version "8.7.1" apply false
|
||||||
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
|
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
|
||||||
|
id 'org.jetbrains.kotlin.android' version '2.1.20' apply false
|
||||||
}
|
}
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
@@ -34,6 +35,8 @@ nexusPublishing {
|
|||||||
sonatype {
|
sonatype {
|
||||||
username.set(sonatypeUsername)
|
username.set(sonatypeUsername)
|
||||||
password.set(sonatypePassword)
|
password.set(sonatypePassword)
|
||||||
|
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
|
||||||
|
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -225,17 +225,17 @@ static void serializeTreeImpl(
|
|||||||
appendEdges<&YGNodeStyleGetPosition>(
|
appendEdges<&YGNodeStyleGetPosition>(
|
||||||
j, "position", node, defaultNode.get());
|
j, "position", node, defaultNode.get());
|
||||||
|
|
||||||
appendFloatIfNotDefault(
|
appendYGValueIfNotDefault(
|
||||||
j["style"],
|
j["style"],
|
||||||
"gap",
|
"gap",
|
||||||
YGNodeStyleGetGap(node, YGGutterAll),
|
YGNodeStyleGetGap(node, YGGutterAll),
|
||||||
YGNodeStyleGetGap(defaultNode.get(), YGGutterAll));
|
YGNodeStyleGetGap(defaultNode.get(), YGGutterAll));
|
||||||
appendFloatIfNotDefault(
|
appendYGValueIfNotDefault(
|
||||||
j["style"],
|
j["style"],
|
||||||
"column-gap",
|
"column-gap",
|
||||||
YGNodeStyleGetGap(node, YGGutterColumn),
|
YGNodeStyleGetGap(node, YGGutterColumn),
|
||||||
YGNodeStyleGetGap(defaultNode.get(), YGGutterColumn));
|
YGNodeStyleGetGap(defaultNode.get(), YGGutterColumn));
|
||||||
appendFloatIfNotDefault(
|
appendYGValueIfNotDefault(
|
||||||
j["style"],
|
j["style"],
|
||||||
"row-gap",
|
"row-gap",
|
||||||
YGNodeStyleGetGap(node, YGGutterRow),
|
YGNodeStyleGetGap(node, YGGutterRow),
|
||||||
|
@@ -19,8 +19,8 @@ add_compile_options(
|
|||||||
# Enable warnings and warnings as errors
|
# Enable warnings and warnings as errors
|
||||||
/W4
|
/W4
|
||||||
/WX
|
/WX
|
||||||
# Disable RTTI
|
# Enable RTTI
|
||||||
$<$<COMPILE_LANGUAGE:CXX>:/GR->
|
$<$<COMPILE_LANGUAGE:CXX>:/GR>
|
||||||
# Use /O2 (Maximize Speed)
|
# Use /O2 (Maximize Speed)
|
||||||
$<$<CONFIG:RELEASE>:/O2>)
|
$<$<CONFIG:RELEASE>:/O2>)
|
||||||
|
|
||||||
@@ -34,8 +34,8 @@ add_compile_options(
|
|||||||
# Enable warnings and warnings as errors
|
# Enable warnings and warnings as errors
|
||||||
-Wall
|
-Wall
|
||||||
-Werror
|
-Werror
|
||||||
# Disable RTTI
|
# Enable RTTI
|
||||||
$<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>
|
$<$<COMPILE_LANGUAGE:CXX>:-frtti>
|
||||||
# Use -O2 (prioritize speed)
|
# Use -O2 (prioritize speed)
|
||||||
$<$<CONFIG:RELEASE>:-O2>
|
$<$<CONFIG:RELEASE>:-O2>
|
||||||
# Enable separate sections per function/data item
|
# Enable separate sections per function/data item
|
||||||
|
10
enums.py
10
enums.py
@@ -8,7 +8,15 @@ import os
|
|||||||
|
|
||||||
ENUMS = {
|
ENUMS = {
|
||||||
"Direction": ["Inherit", "LTR", "RTL"],
|
"Direction": ["Inherit", "LTR", "RTL"],
|
||||||
"Unit": ["Undefined", "Point", "Percent", "Auto"],
|
"Unit": [
|
||||||
|
"Undefined",
|
||||||
|
"Point",
|
||||||
|
"Percent",
|
||||||
|
"Auto",
|
||||||
|
"MaxContent",
|
||||||
|
"FitContent",
|
||||||
|
"Stretch",
|
||||||
|
],
|
||||||
"FlexDirection": ["Column", "ColumnReverse", "Row", "RowReverse"],
|
"FlexDirection": ["Column", "ColumnReverse", "Row", "RowReverse"],
|
||||||
"Justify": [
|
"Justify": [
|
||||||
"FlexStart",
|
"FlexStart",
|
||||||
|
@@ -240,3 +240,14 @@
|
|||||||
<div style="position:relative; width:50px; height:50px;">
|
<div style="position:relative; width:50px; height:50px;">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="align_items_non_stretch_s526008"
|
||||||
|
style="flex-direction: column; width: 400px; height: 400px;">
|
||||||
|
<div style="flex-direction: row;">
|
||||||
|
<div style="flex-direction: column; align-items: flex-start;">
|
||||||
|
<div>
|
||||||
|
<div style="width: 0; height: 10px;"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@@ -157,6 +157,31 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="contains_inner_text_max_width_max_height_column" style="width:2000px; align-items: flex-start;">
|
||||||
|
<div style="max-width: 50px;">
|
||||||
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at
|
||||||
|
volutpat
|
||||||
|
libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus
|
||||||
|
fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus
|
||||||
|
vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor,
|
||||||
|
vitae
|
||||||
|
finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet
|
||||||
|
consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo
|
||||||
|
tincidunt
|
||||||
|
finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam
|
||||||
|
vulputate eleifasd lectus vel varius.
|
||||||
|
Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis
|
||||||
|
in
|
||||||
|
faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel
|
||||||
|
venenatis
|
||||||
|
turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed
|
||||||
|
nunc
|
||||||
|
malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor
|
||||||
|
lobortis.
|
||||||
|
Sed at consectetur ipsum.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div id="contains_inner_text_max_width" style="width:2000px;height:2000px;align-items: flex-start;">
|
<div id="contains_inner_text_max_width" style="width:2000px;height:2000px;align-items: flex-start;">
|
||||||
<div style="flex-direction:row;max-width:100px">
|
<div style="flex-direction:row;max-width:100px">
|
||||||
@@ -219,3 +244,325 @@
|
|||||||
Sed at consectetur ipsum.
|
Sed at consectetur ipsum.
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="max_content_width" style="flex-direction: row; width:max-content; flex-wrap: wrap;">
|
||||||
|
<div style="width: 50px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 100px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 25px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div data-disabled="true" id="fit_content_width" style="width: 90px;">
|
||||||
|
<div style="flex-direction: row; width: fit-content; flex-wrap: wrap;">
|
||||||
|
<div style="width: 50px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 100px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 25px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="stretch_width" style="width: 500px;">
|
||||||
|
<div style="flex-direction: row; width: -webkit-fill-available; flex-wrap: wrap;">
|
||||||
|
<div style="width: 50px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 100px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 25px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="max_content_height" style="height:max-content; flex-wrap: wrap;">
|
||||||
|
<div style="width: 50px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 50px; height: 100px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 50px; height: 25px;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div data-disabled="true" id="fit_content_height" style="height: 90px; ">
|
||||||
|
<div style="height: fit-content; flex-wrap: wrap;">
|
||||||
|
<div style="width: 50px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 50px; height: 100px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 50px; height: 25px;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div data-disabled="true" id="stretch_height" style="height: 500px;">
|
||||||
|
<div style="height: -webkit-fill-available; flex-wrap: wrap;">
|
||||||
|
<div style="width: 50px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 50px; height: 100px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 50px; height: 25px;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="max_content_flex_basis_column" style="flex-basis: max-content; flex-wrap: wrap;">
|
||||||
|
<div style="width: 50px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 50px; height: 100px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 50px; height: 25px;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div data-disabled="true" id="fit_content_flex_basis_column" style="height: 90px;">
|
||||||
|
<div style="flex-basis: fit-content; flex-wrap: wrap;">
|
||||||
|
<div style="width: 50px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 50px; height: 100px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 50px; height: 25px;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="stretch_flex_basis_column" style="height: 500px;">
|
||||||
|
<div style="flex-basis: -webkit-fill-available; flex-wrap: wrap;">
|
||||||
|
<div style="width: 50px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 50px; height: 100px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 50px; height: 25px;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div data-disabled="true" id="max_content_flex_basis_row" style="flex-direction: row; flex-basis: max-content; flex-wrap: wrap;">
|
||||||
|
<div style="width: 50px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 100px; height: 500px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 25px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div data-disabled="true" id="fit_content_flex_basis_row" style="width: 90px;">
|
||||||
|
<div style="flex-direction: row; flex-basis: fit-content; flex-wrap: wrap;">
|
||||||
|
<div style="width: 50px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 100px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 25px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div data-disabled="true" id="stretch_flex_basis_row" style="width: 500px;">
|
||||||
|
<div style="flex-direction: row; flex-basis: -webkit-fill-available; flex-wrap: wrap;">
|
||||||
|
<div style="width: 50px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 100px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 25px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div data-disabled="true" id="max_content_max_width"
|
||||||
|
style="flex-direction: row; max-width:max-content; width: 200px; flex-wrap: wrap;">
|
||||||
|
<div style="width: 50px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 100px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 25px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div data-disabled="true" id="fit_content_max_width" style="width: 90px;">
|
||||||
|
<div style="flex-direction: row; max-width: fit-content; width: 110px; flex-wrap: wrap;">
|
||||||
|
<div style="width: 50px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 100px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 25px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div data-disabled="true" id="stretch_max_width" style="width: 500px;">
|
||||||
|
<div style="flex-direction: row; max-width: -webkit-fill-available; width: 600px; flex-wrap: wrap;">
|
||||||
|
<div style="width: 50px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 100px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 25px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div data-disabled="true" id="max_content_min_width"
|
||||||
|
style="flex-direction: row; min-width:max-content; width: 100px; flex-wrap: wrap;">
|
||||||
|
<div style="width: 50px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 100px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 25px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div data-disabled="true" id="fit_content_min_width" style="width: 90px;">
|
||||||
|
<div style="flex-direction: row; min-width: fit-content; width: 90px; flex-wrap: wrap;">
|
||||||
|
<div style="width: 50px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 100px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 25px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div data-disabled="true" id="stretch_min_width" style="width: 500px;">
|
||||||
|
<div style="flex-direction: row; min-width: -webkit-fill-available; width: 400px; flex-wrap: wrap;">
|
||||||
|
<div style="width: 50px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 100px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 25px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div data-disabled="true" id="max_content_max_height" style="max-height:max-content; height: 200px; flex-wrap: wrap;">
|
||||||
|
<div style="width: 50px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 50px; height: 100px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 50px; height: 25px;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div data-disabled="true" id="fit_content_max_height" style="height: 90px;">
|
||||||
|
<div style="max-height: fit-content; height: 110px; flex-wrap: wrap;">
|
||||||
|
<div style="width: 50px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 50px; height: 100px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 50px; height: 25px;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div data-disabled="true" id="stretch_max_height" style="height: 500px;">
|
||||||
|
<div style="max-height: -webkit-fill-available; flex-wrap: wrap; height: 600px;">
|
||||||
|
<div style="width: 50px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 50px; height: 100px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 50px; height: 25px;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div data-disabled="true" id="max_content_min_height" style="min-height:max-content; height: 100px; flex-wrap: wrap;">
|
||||||
|
<div style="width: 50px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 50px; height: 100px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 50px; height: 25px;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div data-disabled="true" id="fit_content_min_height" style="height: 90px;">
|
||||||
|
<div style="min-height: fit-content; height: 90px; flex-wrap: wrap;">
|
||||||
|
<div style="width: 50px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 50px; height: 100px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 50px; height: 25px;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div data-disabled="true" id="stretch_min_height" style="height: 500px;">
|
||||||
|
<div style="min-height: -webkit-fill-available; flex-wrap: wrap; height: 400px;">
|
||||||
|
<div style="width: 50px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 50px; height: 100px;">
|
||||||
|
</div>
|
||||||
|
<div style="width: 50px; height: 25px;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div data-disabled="true" id="text_max_content_width" style="width: 200px">
|
||||||
|
<div style="width: max-content;">
|
||||||
|
<div style="flex-direction:row;">
|
||||||
|
Lorem ipsum sdafhasdfkjlasdhlkajsfhasldkfhasdlkahsdflkjasdhflaksdfasdlkjhasdlfjahsdfljkasdhalsdfhas dolor sit amet
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div data-disabled="true" id="text_stretch_width" style="width: 200px">
|
||||||
|
<div style="width: -webkit-fill-available;">
|
||||||
|
<div style="flex-direction:row;">
|
||||||
|
Lorem ipsum dolor sit amet
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div data-disabled="true" id="text_fit_content_width" style="width: 200px">
|
||||||
|
<div style="width: fit-content;">
|
||||||
|
<div style="flex-direction:row;">
|
||||||
|
Lorem ipsum sdafhasdfkjlasdhlkajsfhasldkfhasdlkahsdflkjasdhflaksdfasdlkjhasdlfjahsdfljkasdhalsdfhas dolor sit amet
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div data-disabled="true" id="text_max_content_min_width" style="width: 200px">
|
||||||
|
<div style="min-width: max-content; width: 200px;">
|
||||||
|
<div style="flex-direction:row;">
|
||||||
|
Lorem ipsum sdafhasdfkjlasdhlkajsfhasldkfhasdlkahsdflkjasdhflaksdfasdlkjhasdlfjahsdfljkasdhalsdfhas dolor sit amet
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div data-disabled="true" id="text_stretch_min_width" style="width: 200px">
|
||||||
|
<div style="min-width: -webkit-fill-available; width: 100px;">
|
||||||
|
<div style="flex-direction:row;">
|
||||||
|
Lorem ipsum dolor sit amet
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div data-disabled="true" data-disabled="true" id="text_fit_content_min_width" style="width: 200px">
|
||||||
|
<div style="min-width: fit-content; width: 300px">
|
||||||
|
<div style="flex-direction:row;">
|
||||||
|
Lorem ipsum sdafhasdfkjlasdhlkajsfhasldkfhasdlkahsdflkjasdhflaksdfasdlkjhasdlfjahsdfljkasdhalsdfhas dolor sit amet
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div data-disabled="true" id="text_max_content_max_width" style="width: 200px">
|
||||||
|
<div style="max-width: max-content; width: 2000px;">
|
||||||
|
<div style="flex-direction:row;">
|
||||||
|
Lorem ipsum sdafhasdfkjlasdhlkajsfhasldkfhasdlkahsdflkjasdhflaksdfasdlkjhasdlfjahsdfljkasdhalsdfhas dolor sit amet
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div data-disabled="true" id="text_stretch_max_width" style="width: 200px">
|
||||||
|
<div style="max-width: -webkit-fill-available; width: 300px;">
|
||||||
|
<div style="flex-direction:row;">
|
||||||
|
Lorem ipsum dolor sit amet
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div data-disabled="true" id="text_fit_content_max_width" style="width: 200px">
|
||||||
|
<div style="max-width: fit-content; width: 1000px">
|
||||||
|
<div style="flex-direction:row;">
|
||||||
|
Lorem ipsum sdafhasdfkjlasdhlkajsfhasldkfhasdlkahsdflkjasdhflaksdfasdlkjhasdlfjahsdfljkasdhalsdfhas dolor sit amet
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@@ -17,13 +17,25 @@ function toFunctionNameCpp(value) {
|
|||||||
return 'Percent';
|
return 'Percent';
|
||||||
} else if (value.indexOf('Auto') >= 0) {
|
} else if (value.indexOf('Auto') >= 0) {
|
||||||
return 'Auto';
|
return 'Auto';
|
||||||
|
} else if (value.indexOf('MaxContent') >= 0) {
|
||||||
|
return 'MaxContent';
|
||||||
|
} else if (value.indexOf('FitContent') >= 0) {
|
||||||
|
return 'FitContent';
|
||||||
|
} else if (value.indexOf('Stretch') >= 0) {
|
||||||
|
return 'Stretch';
|
||||||
}
|
}
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
function keywordFunctionCpp(functionPrefix, nodeName, value) {
|
function keywordFunctionCpp(functionPrefix, nodeName, value) {
|
||||||
const functionSuffix = toFunctionNameCpp(value);
|
const functionSuffix = toFunctionNameCpp(value);
|
||||||
if (functionSuffix == 'Auto') {
|
if (
|
||||||
|
functionSuffix == 'Auto' ||
|
||||||
|
functionSuffix == 'MaxContent' ||
|
||||||
|
functionSuffix == 'FitContent' ||
|
||||||
|
functionSuffix == 'Stretch'
|
||||||
|
) {
|
||||||
return functionPrefix + functionSuffix + '(' + nodeName + ');';
|
return functionPrefix + functionSuffix + '(' + nodeName + ');';
|
||||||
} else {
|
} else {
|
||||||
return (
|
return (
|
||||||
@@ -163,6 +175,10 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
|
|||||||
YGDisplayContents: {value: 'YGDisplayContents'},
|
YGDisplayContents: {value: 'YGDisplayContents'},
|
||||||
YGAuto: {value: 'YGAuto'},
|
YGAuto: {value: 'YGAuto'},
|
||||||
|
|
||||||
|
YGMaxContent: {value: 'MaxContent'},
|
||||||
|
YGFitContent: {value: 'FitContent'},
|
||||||
|
YGStretch: {value: 'Stretch'},
|
||||||
|
|
||||||
YGNodeCalculateLayout: {
|
YGNodeCalculateLayout: {
|
||||||
value: function (node, dir, _experiments) {
|
value: function (node, dir, _experiments) {
|
||||||
this.push(
|
this.push(
|
||||||
@@ -382,57 +398,25 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
|
|||||||
|
|
||||||
YGNodeStyleSetMaxHeight: {
|
YGNodeStyleSetMaxHeight: {
|
||||||
value: function (nodeName, value) {
|
value: function (nodeName, value) {
|
||||||
this.push(
|
this.push(keywordFunctionCpp('YGNodeStyleSetMaxHeight', nodeName, value));
|
||||||
'YGNodeStyleSetMaxHeight' +
|
|
||||||
toFunctionNameCpp(value) +
|
|
||||||
'(' +
|
|
||||||
nodeName +
|
|
||||||
', ' +
|
|
||||||
toValueCpp(value) +
|
|
||||||
');',
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
YGNodeStyleSetMaxWidth: {
|
YGNodeStyleSetMaxWidth: {
|
||||||
value: function (nodeName, value) {
|
value: function (nodeName, value) {
|
||||||
this.push(
|
this.push(keywordFunctionCpp('YGNodeStyleSetMaxWidth', nodeName, value));
|
||||||
'YGNodeStyleSetMaxWidth' +
|
|
||||||
toFunctionNameCpp(value) +
|
|
||||||
'(' +
|
|
||||||
nodeName +
|
|
||||||
', ' +
|
|
||||||
toValueCpp(value) +
|
|
||||||
');',
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
YGNodeStyleSetMinHeight: {
|
YGNodeStyleSetMinHeight: {
|
||||||
value: function (nodeName, value) {
|
value: function (nodeName, value) {
|
||||||
this.push(
|
this.push(keywordFunctionCpp('YGNodeStyleSetMinHeight', nodeName, value));
|
||||||
'YGNodeStyleSetMinHeight' +
|
|
||||||
toFunctionNameCpp(value) +
|
|
||||||
'(' +
|
|
||||||
nodeName +
|
|
||||||
', ' +
|
|
||||||
toValueCpp(value) +
|
|
||||||
');',
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
YGNodeStyleSetMinWidth: {
|
YGNodeStyleSetMinWidth: {
|
||||||
value: function (nodeName, value) {
|
value: function (nodeName, value) {
|
||||||
this.push(
|
this.push(keywordFunctionCpp('YGNodeStyleSetMinWidth', nodeName, value));
|
||||||
'YGNodeStyleSetMinWidth' +
|
|
||||||
toFunctionNameCpp(value) +
|
|
||||||
'(' +
|
|
||||||
nodeName +
|
|
||||||
', ' +
|
|
||||||
toValueCpp(value) +
|
|
||||||
');',
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -518,7 +502,7 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
YGNodeSetMeasureFunc: {
|
YGNodeSetMeasureFunc: {
|
||||||
value: function (nodeName, innerText) {
|
value: function (nodeName, innerText, _) {
|
||||||
this.push(`YGNodeSetContext(${nodeName}, (void*)"${innerText}");`);
|
this.push(`YGNodeSetContext(${nodeName}, (void*)"${innerText}");`);
|
||||||
this.push(
|
this.push(
|
||||||
`YGNodeSetMeasureFunc(${nodeName}, &facebook::yoga::test::IntrinsicSizeMeasure);`,
|
`YGNodeSetMeasureFunc(${nodeName}, &facebook::yoga::test::IntrinsicSizeMeasure);`,
|
||||||
|
@@ -17,13 +17,24 @@ function toMethodName(value) {
|
|||||||
return 'Percent';
|
return 'Percent';
|
||||||
} else if (value.indexOf('AUTO') >= 0) {
|
} else if (value.indexOf('AUTO') >= 0) {
|
||||||
return 'Auto';
|
return 'Auto';
|
||||||
|
} else if (value.indexOf('MAX_CONTENT') >= 0) {
|
||||||
|
return 'MaxContent';
|
||||||
|
} else if (value.indexOf('FIT_CONTENT') >= 0) {
|
||||||
|
return 'FitContent';
|
||||||
|
} else if (value.indexOf('STRETCH') >= 0) {
|
||||||
|
return 'Stretch';
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
function keywordMethod(methodPrefix, nodeName, value) {
|
function keywordMethod(methodPrefix, nodeName, value) {
|
||||||
const methodSuffix = toMethodName(value);
|
const methodSuffix = toMethodName(value);
|
||||||
if (methodSuffix == 'Auto') {
|
if (
|
||||||
|
methodSuffix == 'Auto' ||
|
||||||
|
methodSuffix == 'MaxContent' ||
|
||||||
|
methodSuffix == 'FitContent' ||
|
||||||
|
methodSuffix == 'Stretch'
|
||||||
|
) {
|
||||||
return nodeName + '.' + methodPrefix + methodSuffix + '();';
|
return nodeName + '.' + methodPrefix + methodSuffix + '();';
|
||||||
} else {
|
} else {
|
||||||
return (
|
return (
|
||||||
@@ -205,6 +216,10 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
|
|||||||
YGBoxSizingBorderBox: {value: 'YogaBoxSizing.BORDER_BOX'},
|
YGBoxSizingBorderBox: {value: 'YogaBoxSizing.BORDER_BOX'},
|
||||||
YGBoxSizingContentBox: {value: 'YogaBoxSizing.CONTENT_BOX'},
|
YGBoxSizingContentBox: {value: 'YogaBoxSizing.CONTENT_BOX'},
|
||||||
|
|
||||||
|
YGMaxContent: {value: 'MAX_CONTENT'},
|
||||||
|
YGFitContent: {value: 'FIT_CONTENT'},
|
||||||
|
YGStretch: {value: 'STRETCH'},
|
||||||
|
|
||||||
YGNodeCalculateLayout: {
|
YGNodeCalculateLayout: {
|
||||||
value: function (node, dir, _experiments) {
|
value: function (node, dir, _experiments) {
|
||||||
this.push(node + '.setDirection(' + dir + ');');
|
this.push(node + '.setDirection(' + dir + ');');
|
||||||
@@ -360,53 +375,25 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
|
|||||||
|
|
||||||
YGNodeStyleSetMaxHeight: {
|
YGNodeStyleSetMaxHeight: {
|
||||||
value: function (nodeName, value) {
|
value: function (nodeName, value) {
|
||||||
this.push(
|
this.push(keywordMethod('setMaxHeight', nodeName, value));
|
||||||
nodeName +
|
|
||||||
'.setMaxHeight' +
|
|
||||||
toMethodName(value) +
|
|
||||||
'(' +
|
|
||||||
toValueJava(value) +
|
|
||||||
'f);',
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
YGNodeStyleSetMaxWidth: {
|
YGNodeStyleSetMaxWidth: {
|
||||||
value: function (nodeName, value) {
|
value: function (nodeName, value) {
|
||||||
this.push(
|
this.push(keywordMethod('setMaxWidth', nodeName, value));
|
||||||
nodeName +
|
|
||||||
'.setMaxWidth' +
|
|
||||||
toMethodName(value) +
|
|
||||||
'(' +
|
|
||||||
toValueJava(value) +
|
|
||||||
'f);',
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
YGNodeStyleSetMinHeight: {
|
YGNodeStyleSetMinHeight: {
|
||||||
value: function (nodeName, value) {
|
value: function (nodeName, value) {
|
||||||
this.push(
|
this.push(keywordMethod('setMinHeight', nodeName, value));
|
||||||
nodeName +
|
|
||||||
'.setMinHeight' +
|
|
||||||
toMethodName(value) +
|
|
||||||
'(' +
|
|
||||||
toValueJava(value) +
|
|
||||||
'f);',
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
YGNodeStyleSetMinWidth: {
|
YGNodeStyleSetMinWidth: {
|
||||||
value: function (nodeName, value) {
|
value: function (nodeName, value) {
|
||||||
this.push(
|
this.push(keywordMethod('setMinWidth', nodeName, value));
|
||||||
nodeName +
|
|
||||||
'.setMinWidth' +
|
|
||||||
toMethodName(value) +
|
|
||||||
'(' +
|
|
||||||
toValueJava(value) +
|
|
||||||
'f);',
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -480,7 +467,7 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
YGNodeSetMeasureFunc: {
|
YGNodeSetMeasureFunc: {
|
||||||
value: function (nodeName, innerText) {
|
value: function (nodeName, innerText, _) {
|
||||||
this.push(`${nodeName}.setData("${innerText}");`);
|
this.push(`${nodeName}.setData("${innerText}");`);
|
||||||
this.push(
|
this.push(
|
||||||
`${nodeName}.setMeasureFunction(new TestUtils.intrinsicMeasureFunction());`,
|
`${nodeName}.setMeasureFunction(new TestUtils.intrinsicMeasureFunction());`,
|
||||||
|
@@ -15,6 +15,9 @@ function toValueJavascript(value) {
|
|||||||
if (value.match(/^[0-9.e+-]+px$/i)) return parseFloat(value);
|
if (value.match(/^[0-9.e+-]+px$/i)) return parseFloat(value);
|
||||||
if (value.match(/^[0-9.e+-]+%/i)) return JSON.stringify(value);
|
if (value.match(/^[0-9.e+-]+%/i)) return JSON.stringify(value);
|
||||||
if (value == 'Yoga.AUTO') return '"auto"';
|
if (value == 'Yoga.AUTO') return '"auto"';
|
||||||
|
if (value == 'max-content') return '"max-content"';
|
||||||
|
if (value == 'fit-content') return '"fit-content"';
|
||||||
|
if (value == 'stretch') return '"stretch"';
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,6 +179,10 @@ JavascriptEmitter.prototype = Object.create(Emitter.prototype, {
|
|||||||
YGBoxSizingBorderBox: {value: 'BoxSizing.BorderBox'},
|
YGBoxSizingBorderBox: {value: 'BoxSizing.BorderBox'},
|
||||||
YGBoxSizingContentBox: {value: 'BoxSizing.ContentBox'},
|
YGBoxSizingContentBox: {value: 'BoxSizing.ContentBox'},
|
||||||
|
|
||||||
|
YGMaxContent: {value: 'max-content'},
|
||||||
|
YGFitContent: {value: 'fit-content'},
|
||||||
|
YGStretch: {value: 'stretch'},
|
||||||
|
|
||||||
YGNodeCalculateLayout: {
|
YGNodeCalculateLayout: {
|
||||||
value: function (node, dir, _experiments) {
|
value: function (node, dir, _experiments) {
|
||||||
this.push(node + '.calculateLayout(undefined, undefined, ' + dir + ');');
|
this.push(node + '.calculateLayout(undefined, undefined, ' + dir + ');');
|
||||||
@@ -422,9 +429,11 @@ JavascriptEmitter.prototype = Object.create(Emitter.prototype, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
YGNodeSetMeasureFunc: {
|
YGNodeSetMeasureFunc: {
|
||||||
value: function (nodeName, innerText) {
|
value: function (nodeName, innerText, flexDirection) {
|
||||||
this.push(
|
this.push(
|
||||||
`${nodeName}.setMeasureFunc(instrinsicSizeMeasureFunc.bind("${innerText}"));`,
|
`${nodeName}.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "${innerText}", flexDirection: ${toValueJavascript(
|
||||||
|
flexDirection,
|
||||||
|
)}}));`,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@@ -533,7 +533,11 @@ function setupTestTree(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (node.innerText && node.children.length === 0) {
|
if (node.innerText && node.children.length === 0) {
|
||||||
e.YGNodeSetMeasureFunc(nodeName, node.innerText);
|
e.YGNodeSetMeasureFunc(
|
||||||
|
nodeName,
|
||||||
|
node.innerText,
|
||||||
|
flexDirectionValue(e, node.style['flex-direction']),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < node.children.length; i++) {
|
for (let i = 0; i < node.children.length; i++) {
|
||||||
@@ -654,6 +658,13 @@ function pointValue(e, value) {
|
|||||||
return e.YGAuto;
|
return e.YGAuto;
|
||||||
case 'undefined':
|
case 'undefined':
|
||||||
return e.YGUndefined;
|
return e.YGUndefined;
|
||||||
|
case 'max-content':
|
||||||
|
return e.YGMaxContent;
|
||||||
|
case 'fit-content':
|
||||||
|
return e.YGFitContent;
|
||||||
|
case 'stretch':
|
||||||
|
case '-webkit-fill-available':
|
||||||
|
return e.YGStretch;
|
||||||
default:
|
default:
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
@@ -1,17 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// You can use this script to configure the gradleEnterprise{} block in your build.
|
|
||||||
// You need to rename this file to ./gradle/gradle-enterprise.gradle.kts in order for
|
|
||||||
// this to be processed.
|
|
||||||
extensions.getByName("gradleEnterprise").withGroovyBuilder {
|
|
||||||
setProperty("server", "https://your-gradle-enterprise-instance.example.com")
|
|
||||||
getProperty("buildScan").withGroovyBuilder {
|
|
||||||
"publishAlways"()
|
|
||||||
"tag"(if(System.getenv("CI") != null) "CI" else "Local")
|
|
||||||
}
|
|
||||||
}
|
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,7 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
26
gradlew
vendored
26
gradlew
vendored
@@ -15,6 +15,8 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
#
|
||||||
@@ -55,7 +57,7 @@
|
|||||||
# Darwin, MinGW, and NonStop.
|
# Darwin, MinGW, and NonStop.
|
||||||
#
|
#
|
||||||
# (3) This script is generated from the Groovy template
|
# (3) This script is generated from the Groovy template
|
||||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
# within the Gradle project.
|
# within the Gradle project.
|
||||||
#
|
#
|
||||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
@@ -83,7 +85,8 @@ done
|
|||||||
# This is normally unused
|
# This is normally unused
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
APP_BASE_NAME=${0##*/}
|
APP_BASE_NAME=${0##*/}
|
||||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
|
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD=maximum
|
MAX_FD=maximum
|
||||||
@@ -130,10 +133,13 @@ location of your Java installation."
|
|||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
JAVACMD=java
|
JAVACMD=java
|
||||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
if ! command -v java >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
# Increase the maximum file descriptors if we can.
|
||||||
@@ -141,7 +147,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
|||||||
case $MAX_FD in #(
|
case $MAX_FD in #(
|
||||||
max*)
|
max*)
|
||||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
# shellcheck disable=SC3045
|
# shellcheck disable=SC2039,SC3045
|
||||||
MAX_FD=$( ulimit -H -n ) ||
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
warn "Could not query maximum file descriptor limit"
|
warn "Could not query maximum file descriptor limit"
|
||||||
esac
|
esac
|
||||||
@@ -149,7 +155,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
|||||||
'' | soft) :;; #(
|
'' | soft) :;; #(
|
||||||
*)
|
*)
|
||||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
# shellcheck disable=SC3045
|
# shellcheck disable=SC2039,SC3045
|
||||||
ulimit -n "$MAX_FD" ||
|
ulimit -n "$MAX_FD" ||
|
||||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
esac
|
esac
|
||||||
@@ -198,11 +204,11 @@ fi
|
|||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
# Collect all arguments for the java command;
|
# Collect all arguments for the java command:
|
||||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||||
# shell script including quotes and variable substitutions, so put them in
|
# and any embedded shellness will be escaped.
|
||||||
# double quotes to make sure that they get re-expanded; and
|
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||||
# * put everything else in single quotes, so that it's not re-expanded.
|
# treated as '${Hostname}' itself on the command line.
|
||||||
|
|
||||||
set -- \
|
set -- \
|
||||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
|
22
gradlew.bat
vendored
22
gradlew.bat
vendored
@@ -13,6 +13,8 @@
|
|||||||
@rem See the License for the specific language governing permissions and
|
@rem See the License for the specific language governing permissions and
|
||||||
@rem limitations under the License.
|
@rem limitations under the License.
|
||||||
@rem
|
@rem
|
||||||
|
@rem SPDX-License-Identifier: Apache-2.0
|
||||||
|
@rem
|
||||||
|
|
||||||
@if "%DEBUG%"=="" @echo off
|
@if "%DEBUG%"=="" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
|
|||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if %ERRORLEVEL% equ 0 goto execute
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
echo location of your Java installation.
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
@@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
|||||||
|
|
||||||
if exist "%JAVA_EXE%" goto execute
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
echo location of your Java installation.
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
|
@@ -1,4 +1,17 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="com.facebook.yoga"
|
||||||
|
android:versionCode="1"
|
||||||
|
android:versionName="1.0"
|
||||||
|
>
|
||||||
|
|
||||||
<application/>
|
<application/>
|
||||||
|
|
||||||
|
@@ -9,6 +9,7 @@ plugins {
|
|||||||
id("com.android.library")
|
id("com.android.library")
|
||||||
id("maven-publish")
|
id("maven-publish")
|
||||||
id("signing")
|
id("signing")
|
||||||
|
id("org.jetbrains.kotlin.android")
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "com.facebook.yoga"
|
group = "com.facebook.yoga"
|
||||||
@@ -30,6 +31,7 @@ android {
|
|||||||
consumerProguardFiles("proguard-rules.pro")
|
consumerProguardFiles("proguard-rules.pro")
|
||||||
|
|
||||||
ndk { abiFilters.addAll(setOf("x86", "x86_64", "armeabi-v7a", "arm64-v8a")) }
|
ndk { abiFilters.addAll(setOf("x86", "x86_64", "armeabi-v7a", "arm64-v8a")) }
|
||||||
|
externalNativeBuild { cmake { arguments("-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON") } }
|
||||||
}
|
}
|
||||||
|
|
||||||
externalNativeBuild { cmake { path("CMakeLists.txt") } }
|
externalNativeBuild { cmake { path("CMakeLists.txt") } }
|
||||||
@@ -47,6 +49,8 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
kotlinOptions { jvmTarget = "1.8" }
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
multipleVariants {
|
multipleVariants {
|
||||||
withSourcesJar()
|
withSourcesJar()
|
||||||
@@ -59,6 +63,7 @@ android {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation("com.google.code.findbugs:jsr305:3.0.2")
|
implementation("com.google.code.findbugs:jsr305:3.0.2")
|
||||||
implementation("com.facebook.soloader:soloader:0.10.5")
|
implementation("com.facebook.soloader:soloader:0.10.5")
|
||||||
|
implementation("androidx.core:core-ktx:1.16.0")
|
||||||
testImplementation("junit:junit:4.12")
|
testImplementation("junit:junit:4.12")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.facebook.yoga;
|
|
||||||
|
|
||||||
public enum LayoutPassReason {
|
|
||||||
INITIAL(0),
|
|
||||||
ABS_LAYOUT(1),
|
|
||||||
STRETCH(2),
|
|
||||||
MULTILINE_STRETCH(3),
|
|
||||||
FLEX_LAYOUT(4),
|
|
||||||
MEASURE(5),
|
|
||||||
ABS_MEASURE(6),
|
|
||||||
FLEX_MEASURE(7);
|
|
||||||
|
|
||||||
private final int mIntValue;
|
|
||||||
|
|
||||||
LayoutPassReason(int intValue) {
|
|
||||||
mIntValue = intValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int intValue() {
|
|
||||||
return mIntValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static LayoutPassReason fromInt(int value) {
|
|
||||||
switch (value) {
|
|
||||||
case 0: return INITIAL;
|
|
||||||
case 1: return ABS_LAYOUT;
|
|
||||||
case 2: return STRETCH;
|
|
||||||
case 3: return MULTILINE_STRETCH;
|
|
||||||
case 4: return FLEX_LAYOUT;
|
|
||||||
case 5: return MEASURE;
|
|
||||||
case 6: return ABS_MEASURE;
|
|
||||||
case 7: return FLEX_MEASURE;
|
|
||||||
default: throw new IllegalArgumentException("Unknown enum value: " + value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
35
java/com/facebook/yoga/LayoutPassReason.kt
Normal file
35
java/com/facebook/yoga/LayoutPassReason.kt
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.facebook.yoga
|
||||||
|
|
||||||
|
public enum class LayoutPassReason(public val intValue: Int) {
|
||||||
|
INITIAL(0),
|
||||||
|
ABS_LAYOUT(1),
|
||||||
|
STRETCH(2),
|
||||||
|
MULTILINE_STRETCH(3),
|
||||||
|
FLEX_LAYOUT(4),
|
||||||
|
MEASURE(5),
|
||||||
|
ABS_MEASURE(6),
|
||||||
|
FLEX_MEASURE(7);
|
||||||
|
|
||||||
|
public companion object {
|
||||||
|
@JvmStatic
|
||||||
|
public fun fromInt(value: Int): LayoutPassReason =
|
||||||
|
when (value) {
|
||||||
|
0 -> INITIAL
|
||||||
|
1 -> ABS_LAYOUT
|
||||||
|
2 -> STRETCH
|
||||||
|
3 -> MULTILINE_STRETCH
|
||||||
|
4 -> FLEX_LAYOUT
|
||||||
|
5 -> MEASURE
|
||||||
|
6 -> ABS_MEASURE
|
||||||
|
7 -> FLEX_MEASURE
|
||||||
|
else -> throw IllegalArgumentException("Unknown enum value: $value")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -5,12 +5,12 @@
|
|||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.facebook.yoga;
|
package com.facebook.yoga
|
||||||
|
|
||||||
public interface YogaBaselineFunction {
|
public fun interface YogaBaselineFunction {
|
||||||
/**
|
/**
|
||||||
* Return the baseline of the node in points. When no baseline function is set the baseline
|
* Return the baseline of the node in points. When no baseline function is set the baseline
|
||||||
* default to the computed height of the node.
|
* default to the computed height of the node.
|
||||||
*/
|
*/
|
||||||
float baseline(YogaNode node, float width, float height);
|
public fun baseline(node: YogaNode, width: Float, height: Float): Float
|
||||||
}
|
}
|
@@ -5,10 +5,8 @@
|
|||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.facebook.yoga;
|
package com.facebook.yoga
|
||||||
|
|
||||||
public abstract class YogaConfigFactory {
|
public object YogaConfigFactory {
|
||||||
public static YogaConfig create() {
|
@JvmStatic public fun create(): YogaConfig = YogaConfigJNIFinalizer()
|
||||||
return new YogaConfigJNIFinalizer();
|
|
||||||
}
|
|
||||||
}
|
}
|
@@ -1,25 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.facebook.yoga;
|
|
||||||
|
|
||||||
public class YogaConstants {
|
|
||||||
|
|
||||||
public static final float UNDEFINED = Float.NaN;
|
|
||||||
|
|
||||||
public static boolean isUndefined(float value) {
|
|
||||||
return Float.compare(value, UNDEFINED) == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isUndefined(YogaValue value) {
|
|
||||||
return value.unit == YogaUnit.UNDEFINED;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static float getUndefined() {
|
|
||||||
return UNDEFINED;
|
|
||||||
}
|
|
||||||
}
|
|
18
java/com/facebook/yoga/YogaConstants.kt
Normal file
18
java/com/facebook/yoga/YogaConstants.kt
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.facebook.yoga
|
||||||
|
|
||||||
|
public object YogaConstants {
|
||||||
|
@JvmField public val UNDEFINED: Float = Float.NaN
|
||||||
|
|
||||||
|
@JvmStatic public fun isUndefined(value: Float): Boolean = value.compareTo(UNDEFINED) == 0
|
||||||
|
|
||||||
|
@JvmStatic public fun isUndefined(value: YogaValue): Boolean = value.unit == YogaUnit.UNDEFINED
|
||||||
|
|
||||||
|
@JvmStatic public fun getUndefined(): Float = UNDEFINED
|
||||||
|
}
|
@@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.facebook.yoga;
|
|
||||||
|
|
||||||
public enum YogaLayoutType {
|
|
||||||
LAYOUT(0),
|
|
||||||
MEASURE(1),
|
|
||||||
CACHED_LAYOUT(2),
|
|
||||||
CACHED_MEASURE(3);
|
|
||||||
|
|
||||||
private final int mIntValue;
|
|
||||||
|
|
||||||
YogaLayoutType(int intValue) {
|
|
||||||
mIntValue = intValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int intValue() {
|
|
||||||
return mIntValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static YogaLayoutType fromInt(int value) {
|
|
||||||
switch (value) {
|
|
||||||
case 0: return LAYOUT;
|
|
||||||
case 1: return MEASURE;
|
|
||||||
case 2: return CACHED_LAYOUT;
|
|
||||||
case 3: return CACHED_MEASURE;
|
|
||||||
default: throw new IllegalArgumentException("Unknown enum value: " + value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
27
java/com/facebook/yoga/YogaLayoutType.kt
Normal file
27
java/com/facebook/yoga/YogaLayoutType.kt
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.facebook.yoga
|
||||||
|
|
||||||
|
public enum class YogaLayoutType(public val intValue: Int) {
|
||||||
|
LAYOUT(0),
|
||||||
|
MEASURE(1),
|
||||||
|
CACHED_LAYOUT(2),
|
||||||
|
CACHED_MEASURE(3);
|
||||||
|
|
||||||
|
public companion object {
|
||||||
|
@JvmStatic
|
||||||
|
public fun fromInt(value: Int): YogaLayoutType =
|
||||||
|
when (value) {
|
||||||
|
0 -> LAYOUT
|
||||||
|
1 -> MEASURE
|
||||||
|
2 -> CACHED_LAYOUT
|
||||||
|
3 -> CACHED_MEASURE
|
||||||
|
else -> throw IllegalArgumentException("Unknown enum value: $value")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -5,16 +5,15 @@
|
|||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.facebook.yoga;
|
package com.facebook.yoga
|
||||||
|
|
||||||
import com.facebook.yoga.annotations.DoNotStrip;
|
import com.facebook.yoga.annotations.DoNotStrip
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for receiving logs from native layer. Use by setting YogaNode.setLogger(myLogger);
|
* Interface for receiving logs from native layer. Use by setting YogaNode.setLogger(myLogger); See
|
||||||
* See YogaLogLevel for the different log levels.
|
* YogaLogLevel for the different log levels.
|
||||||
*/
|
*/
|
||||||
@DoNotStrip
|
@DoNotStrip
|
||||||
public interface YogaLogger {
|
public fun interface YogaLogger {
|
||||||
@DoNotStrip
|
@DoNotStrip public fun log(level: YogaLogLevel, message: String)
|
||||||
void log(YogaLogLevel level, String message);
|
|
||||||
}
|
}
|
@@ -1,20 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.facebook.yoga;
|
|
||||||
|
|
||||||
public interface YogaMeasureFunction {
|
|
||||||
/**
|
|
||||||
* Return a value created by YogaMeasureOutput.make(width, height);
|
|
||||||
*/
|
|
||||||
long measure(
|
|
||||||
YogaNode node,
|
|
||||||
float width,
|
|
||||||
YogaMeasureMode widthMode,
|
|
||||||
float height,
|
|
||||||
YogaMeasureMode heightMode);
|
|
||||||
}
|
|
19
java/com/facebook/yoga/YogaMeasureFunction.kt
Normal file
19
java/com/facebook/yoga/YogaMeasureFunction.kt
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.facebook.yoga
|
||||||
|
|
||||||
|
public fun interface YogaMeasureFunction {
|
||||||
|
/** Return a value created by YogaMeasureOutput.make(width, height); */
|
||||||
|
public fun measure(
|
||||||
|
node: YogaNode,
|
||||||
|
width: Float,
|
||||||
|
widthMode: YogaMeasureMode,
|
||||||
|
height: Float,
|
||||||
|
heightMode: YogaMeasureMode,
|
||||||
|
): Long
|
||||||
|
}
|
@@ -1,32 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.facebook.yoga;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helpers for building measure output value.
|
|
||||||
*/
|
|
||||||
public class YogaMeasureOutput {
|
|
||||||
|
|
||||||
public static long make(float width, float height) {
|
|
||||||
final int wBits = Float.floatToRawIntBits(width);
|
|
||||||
final int hBits = Float.floatToRawIntBits(height);
|
|
||||||
return ((long) wBits) << 32 | ((long) hBits);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static long make(int width, int height) {
|
|
||||||
return make((float) width, (float) height);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static float getWidth(long measureOutput) {
|
|
||||||
return Float.intBitsToFloat((int) (0xFFFFFFFF & (measureOutput >> 32)));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static float getHeight(long measureOutput) {
|
|
||||||
return Float.intBitsToFloat((int) (0xFFFFFFFF & measureOutput));
|
|
||||||
}
|
|
||||||
}
|
|
29
java/com/facebook/yoga/YogaMeasureOutput.kt
Normal file
29
java/com/facebook/yoga/YogaMeasureOutput.kt
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.facebook.yoga
|
||||||
|
|
||||||
|
/** Helpers for building measure output value. */
|
||||||
|
public object YogaMeasureOutput {
|
||||||
|
@JvmStatic
|
||||||
|
public fun make(width: Float, height: Float): Long {
|
||||||
|
val wBits = java.lang.Float.floatToRawIntBits(width)
|
||||||
|
val hBits = java.lang.Float.floatToRawIntBits(height)
|
||||||
|
return (wBits.toLong()) shl 32 or (hBits.toLong())
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
public fun make(width: Int, height: Int): Long = make(width.toFloat(), height.toFloat())
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
public fun getWidth(measureOutput: Long): Float =
|
||||||
|
java.lang.Float.intBitsToFloat((0xFFFFFFFFL and (measureOutput shr 32)).toInt())
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
public fun getHeight(measureOutput: Long): Float =
|
||||||
|
java.lang.Float.intBitsToFloat((0xFFFFFFFFL and measureOutput).toInt())
|
||||||
|
}
|
@@ -1,120 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.facebook.yoga;
|
|
||||||
|
|
||||||
import com.facebook.yoga.annotations.DoNotStrip;
|
|
||||||
import com.facebook.soloader.SoLoader;
|
|
||||||
|
|
||||||
@DoNotStrip
|
|
||||||
public class YogaNative {
|
|
||||||
static {
|
|
||||||
SoLoader.loadLibrary("yoga");
|
|
||||||
}
|
|
||||||
|
|
||||||
// JNI methods that use Vanilla JNI
|
|
||||||
// YGConfig related
|
|
||||||
static native long jni_YGConfigNewJNI();
|
|
||||||
static native void jni_YGConfigFreeJNI(long nativePointer);
|
|
||||||
static native void jni_YGConfigSetExperimentalFeatureEnabledJNI(long nativePointer, int feature, boolean enabled);
|
|
||||||
static native void jni_YGConfigSetUseWebDefaultsJNI(long nativePointer, boolean useWebDefaults);
|
|
||||||
static native void jni_YGConfigSetPointScaleFactorJNI(long nativePointer, float pixelsInPoint);
|
|
||||||
static native void jni_YGConfigSetErrataJNI(long nativePointer, int errata);
|
|
||||||
static native int jni_YGConfigGetErrataJNI(long nativePointer);
|
|
||||||
static native void jni_YGConfigSetLoggerJNI(long nativePointer, YogaLogger logger);
|
|
||||||
|
|
||||||
// YGNode related
|
|
||||||
static native long jni_YGNodeNewJNI();
|
|
||||||
static native long jni_YGNodeNewWithConfigJNI(long configPointer);
|
|
||||||
static native void jni_YGNodeFinalizeJNI(long nativePointer);
|
|
||||||
static native void jni_YGNodeResetJNI(long nativePointer);
|
|
||||||
static native void jni_YGNodeInsertChildJNI(long nativePointer, long childPointer, int index);
|
|
||||||
static native void jni_YGNodeSwapChildJNI(long nativePointer, long childPointer, int index);
|
|
||||||
static native void jni_YGNodeSetIsReferenceBaselineJNI(long nativePointer, boolean isReferenceBaseline);
|
|
||||||
static native boolean jni_YGNodeIsReferenceBaselineJNI(long nativePointer);
|
|
||||||
static native void jni_YGNodeRemoveAllChildrenJNI(long nativePointer);
|
|
||||||
static native void jni_YGNodeRemoveChildJNI(long nativePointer, long childPointer);
|
|
||||||
static native void jni_YGNodeCalculateLayoutJNI(long nativePointer, float width, float height, long[] nativePointers, YogaNodeJNIBase[] nodes);
|
|
||||||
static native void jni_YGNodeMarkDirtyJNI(long nativePointer);
|
|
||||||
static native boolean jni_YGNodeIsDirtyJNI(long nativePointer);
|
|
||||||
static native void jni_YGNodeCopyStyleJNI(long dstNativePointer, long srcNativePointer);
|
|
||||||
static native int jni_YGNodeStyleGetDirectionJNI(long nativePointer);
|
|
||||||
static native void jni_YGNodeStyleSetDirectionJNI(long nativePointer, int direction);
|
|
||||||
static native int jni_YGNodeStyleGetFlexDirectionJNI(long nativePointer);
|
|
||||||
static native void jni_YGNodeStyleSetFlexDirectionJNI(long nativePointer, int flexDirection);
|
|
||||||
static native int jni_YGNodeStyleGetJustifyContentJNI(long nativePointer);
|
|
||||||
static native void jni_YGNodeStyleSetJustifyContentJNI(long nativePointer, int justifyContent);
|
|
||||||
static native int jni_YGNodeStyleGetAlignItemsJNI(long nativePointer);
|
|
||||||
static native void jni_YGNodeStyleSetAlignItemsJNI(long nativePointer, int alignItems);
|
|
||||||
static native int jni_YGNodeStyleGetAlignSelfJNI(long nativePointer);
|
|
||||||
static native void jni_YGNodeStyleSetAlignSelfJNI(long nativePointer, int alignSelf);
|
|
||||||
static native int jni_YGNodeStyleGetAlignContentJNI(long nativePointer);
|
|
||||||
static native void jni_YGNodeStyleSetAlignContentJNI(long nativePointer, int alignContent);
|
|
||||||
static native int jni_YGNodeStyleGetPositionTypeJNI(long nativePointer);
|
|
||||||
static native void jni_YGNodeStyleSetPositionTypeJNI(long nativePointer, int positionType);
|
|
||||||
static native int jni_YGNodeStyleGetBoxSizingJNI(long nativePointer);
|
|
||||||
static native void jni_YGNodeStyleSetBoxSizingJNI(long nativePointer, int boxSizing);
|
|
||||||
static native int jni_YGNodeStyleGetFlexWrapJNI(long nativePointer);
|
|
||||||
static native void jni_YGNodeStyleSetFlexWrapJNI(long nativePointer, int wrapType);
|
|
||||||
static native int jni_YGNodeStyleGetOverflowJNI(long nativePointer);
|
|
||||||
static native void jni_YGNodeStyleSetOverflowJNI(long nativePointer, int overflow);
|
|
||||||
static native int jni_YGNodeStyleGetDisplayJNI(long nativePointer);
|
|
||||||
static native void jni_YGNodeStyleSetDisplayJNI(long nativePointer, int display);
|
|
||||||
static native float jni_YGNodeStyleGetFlexJNI(long nativePointer);
|
|
||||||
static native void jni_YGNodeStyleSetFlexJNI(long nativePointer, float flex);
|
|
||||||
static native float jni_YGNodeStyleGetFlexGrowJNI(long nativePointer);
|
|
||||||
static native void jni_YGNodeStyleSetFlexGrowJNI(long nativePointer, float flexGrow);
|
|
||||||
static native float jni_YGNodeStyleGetFlexShrinkJNI(long nativePointer);
|
|
||||||
static native void jni_YGNodeStyleSetFlexShrinkJNI(long nativePointer, float flexShrink);
|
|
||||||
static native long jni_YGNodeStyleGetFlexBasisJNI(long nativePointer);
|
|
||||||
static native void jni_YGNodeStyleSetFlexBasisJNI(long nativePointer, float flexBasis);
|
|
||||||
static native void jni_YGNodeStyleSetFlexBasisPercentJNI(long nativePointer, float percent);
|
|
||||||
static native void jni_YGNodeStyleSetFlexBasisAutoJNI(long nativePointer);
|
|
||||||
static native long jni_YGNodeStyleGetMarginJNI(long nativePointer, int edge);
|
|
||||||
static native void jni_YGNodeStyleSetMarginJNI(long nativePointer, int edge, float margin);
|
|
||||||
static native void jni_YGNodeStyleSetMarginPercentJNI(long nativePointer, int edge, float percent);
|
|
||||||
static native void jni_YGNodeStyleSetMarginAutoJNI(long nativePointer, int edge);
|
|
||||||
static native long jni_YGNodeStyleGetPaddingJNI(long nativePointer, int edge);
|
|
||||||
static native void jni_YGNodeStyleSetPaddingJNI(long nativePointer, int edge, float padding);
|
|
||||||
static native void jni_YGNodeStyleSetPaddingPercentJNI(long nativePointer, int edge, float percent);
|
|
||||||
static native float jni_YGNodeStyleGetBorderJNI(long nativePointer, int edge);
|
|
||||||
static native void jni_YGNodeStyleSetBorderJNI(long nativePointer, int edge, float border);
|
|
||||||
static native long jni_YGNodeStyleGetPositionJNI(long nativePointer, int edge);
|
|
||||||
static native void jni_YGNodeStyleSetPositionJNI(long nativePointer, int edge, float position);
|
|
||||||
static native void jni_YGNodeStyleSetPositionPercentJNI(long nativePointer, int edge, float percent);
|
|
||||||
static native void jni_YGNodeStyleSetPositionAutoJNI(long nativePointer, int edge);
|
|
||||||
static native long jni_YGNodeStyleGetWidthJNI(long nativePointer);
|
|
||||||
static native void jni_YGNodeStyleSetWidthJNI(long nativePointer, float width);
|
|
||||||
static native void jni_YGNodeStyleSetWidthPercentJNI(long nativePointer, float percent);
|
|
||||||
static native void jni_YGNodeStyleSetWidthAutoJNI(long nativePointer);
|
|
||||||
static native long jni_YGNodeStyleGetHeightJNI(long nativePointer);
|
|
||||||
static native void jni_YGNodeStyleSetHeightJNI(long nativePointer, float height);
|
|
||||||
static native void jni_YGNodeStyleSetHeightPercentJNI(long nativePointer, float percent);
|
|
||||||
static native void jni_YGNodeStyleSetHeightAutoJNI(long nativePointer);
|
|
||||||
static native long jni_YGNodeStyleGetMinWidthJNI(long nativePointer);
|
|
||||||
static native void jni_YGNodeStyleSetMinWidthJNI(long nativePointer, float minWidth);
|
|
||||||
static native void jni_YGNodeStyleSetMinWidthPercentJNI(long nativePointer, float percent);
|
|
||||||
static native long jni_YGNodeStyleGetMinHeightJNI(long nativePointer);
|
|
||||||
static native void jni_YGNodeStyleSetMinHeightJNI(long nativePointer, float minHeight);
|
|
||||||
static native void jni_YGNodeStyleSetMinHeightPercentJNI(long nativePointer, float percent);
|
|
||||||
static native long jni_YGNodeStyleGetMaxWidthJNI(long nativePointer);
|
|
||||||
static native void jni_YGNodeStyleSetMaxWidthJNI(long nativePointer, float maxWidth);
|
|
||||||
static native void jni_YGNodeStyleSetMaxWidthPercentJNI(long nativePointer, float percent);
|
|
||||||
static native long jni_YGNodeStyleGetMaxHeightJNI(long nativePointer);
|
|
||||||
static native void jni_YGNodeStyleSetMaxHeightJNI(long nativePointer, float maxheight);
|
|
||||||
static native void jni_YGNodeStyleSetMaxHeightPercentJNI(long nativePointer, float percent);
|
|
||||||
static native float jni_YGNodeStyleGetAspectRatioJNI(long nativePointer);
|
|
||||||
static native void jni_YGNodeStyleSetAspectRatioJNI(long nativePointer, float aspectRatio);
|
|
||||||
static native float jni_YGNodeStyleGetGapJNI(long nativePointer, int gutter);
|
|
||||||
static native void jni_YGNodeStyleSetGapJNI(long nativePointer, int gutter, float gapLength);
|
|
||||||
static native void jni_YGNodeStyleSetGapPercentJNI(long nativePointer, int gutter, float gapLength);
|
|
||||||
static native void jni_YGNodeSetHasMeasureFuncJNI(long nativePointer, boolean hasMeasureFunc);
|
|
||||||
static native void jni_YGNodeSetHasBaselineFuncJNI(long nativePointer, boolean hasMeasureFunc);
|
|
||||||
static native void jni_YGNodeSetStyleInputsJNI(long nativePointer, float[] styleInputsArray, int size);
|
|
||||||
static native long jni_YGNodeCloneJNI(long nativePointer);
|
|
||||||
static native void jni_YGNodeSetAlwaysFormsContainingBlockJNI(long nativePointer, boolean alwaysFormContainingBlock);
|
|
||||||
}
|
|
331
java/com/facebook/yoga/YogaNative.kt
Normal file
331
java/com/facebook/yoga/YogaNative.kt
Normal file
@@ -0,0 +1,331 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.facebook.yoga
|
||||||
|
|
||||||
|
import com.facebook.soloader.SoLoader
|
||||||
|
import com.facebook.yoga.annotations.DoNotStrip
|
||||||
|
|
||||||
|
@DoNotStrip
|
||||||
|
public object YogaNative {
|
||||||
|
init {
|
||||||
|
SoLoader.loadLibrary("yoga")
|
||||||
|
}
|
||||||
|
|
||||||
|
// JNI methods that use Vanilla JNI
|
||||||
|
// YGConfig related
|
||||||
|
@JvmStatic public external fun jni_YGConfigNewJNI(): Long
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGConfigFreeJNI(nativePointer: Long)
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
public external fun jni_YGConfigSetExperimentalFeatureEnabledJNI(
|
||||||
|
nativePointer: Long,
|
||||||
|
feature: Int,
|
||||||
|
enabled: Boolean
|
||||||
|
)
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
public external fun jni_YGConfigSetUseWebDefaultsJNI(nativePointer: Long, useWebDefaults: Boolean)
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
public external fun jni_YGConfigSetPointScaleFactorJNI(nativePointer: Long, pixelsInPoint: Float)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGConfigSetErrataJNI(nativePointer: Long, errata: Int)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGConfigGetErrataJNI(nativePointer: Long): Int
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGConfigSetLoggerJNI(nativePointer: Long, logger: YogaLogger)
|
||||||
|
|
||||||
|
// YGNode related
|
||||||
|
@JvmStatic public external fun jni_YGNodeNewJNI(): Long
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeNewWithConfigJNI(configPointer: Long): Long
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeFinalizeJNI(nativePointer: Long)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeResetJNI(nativePointer: Long)
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
public external fun jni_YGNodeInsertChildJNI(nativePointer: Long, childPointer: Long, index: Int)
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
public external fun jni_YGNodeSwapChildJNI(nativePointer: Long, childPointer: Long, index: Int)
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
public external fun jni_YGNodeSetIsReferenceBaselineJNI(
|
||||||
|
nativePointer: Long,
|
||||||
|
isReferenceBaseline: Boolean
|
||||||
|
)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeIsReferenceBaselineJNI(nativePointer: Long): Boolean
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeRemoveAllChildrenJNI(nativePointer: Long)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeRemoveChildJNI(nativePointer: Long, childPointer: Long)
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
public external fun jni_YGNodeCalculateLayoutJNI(
|
||||||
|
nativePointer: Long,
|
||||||
|
width: Float,
|
||||||
|
height: Float,
|
||||||
|
nativePointers: LongArray,
|
||||||
|
nodes: Array<YogaNodeJNIBase>
|
||||||
|
)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeMarkDirtyJNI(nativePointer: Long)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeIsDirtyJNI(nativePointer: Long): Boolean
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
public external fun jni_YGNodeCopyStyleJNI(dstNativePointer: Long, srcNativePointer: Long)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleGetDirectionJNI(nativePointer: Long): Int
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleSetDirectionJNI(nativePointer: Long, direction: Int)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleGetFlexDirectionJNI(nativePointer: Long): Int
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
public external fun jni_YGNodeStyleSetFlexDirectionJNI(nativePointer: Long, flexDirection: Int)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleGetJustifyContentJNI(nativePointer: Long): Int
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
public external fun jni_YGNodeStyleSetJustifyContentJNI(nativePointer: Long, justifyContent: Int)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleGetAlignItemsJNI(nativePointer: Long): Int
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
public external fun jni_YGNodeStyleSetAlignItemsJNI(nativePointer: Long, alignItems: Int)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleGetAlignSelfJNI(nativePointer: Long): Int
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleSetAlignSelfJNI(nativePointer: Long, alignSelf: Int)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleGetAlignContentJNI(nativePointer: Long): Int
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
public external fun jni_YGNodeStyleSetAlignContentJNI(nativePointer: Long, alignContent: Int)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleGetPositionTypeJNI(nativePointer: Long): Int
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
public external fun jni_YGNodeStyleSetPositionTypeJNI(nativePointer: Long, positionType: Int)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleGetBoxSizingJNI(nativePointer: Long): Int
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleSetBoxSizingJNI(nativePointer: Long, boxSizing: Int)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleGetFlexWrapJNI(nativePointer: Long): Int
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleSetFlexWrapJNI(nativePointer: Long, wrapType: Int)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleGetOverflowJNI(nativePointer: Long): Int
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleSetOverflowJNI(nativePointer: Long, overflow: Int)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleGetDisplayJNI(nativePointer: Long): Int
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleSetDisplayJNI(nativePointer: Long, display: Int)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleGetFlexJNI(nativePointer: Long): Float
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleSetFlexJNI(nativePointer: Long, flex: Float)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleGetFlexGrowJNI(nativePointer: Long): Float
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleSetFlexGrowJNI(nativePointer: Long, flexGrow: Float)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleGetFlexShrinkJNI(nativePointer: Long): Float
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
public external fun jni_YGNodeStyleSetFlexShrinkJNI(nativePointer: Long, flexShrink: Float)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleGetFlexBasisJNI(nativePointer: Long): Long
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
public external fun jni_YGNodeStyleSetFlexBasisJNI(nativePointer: Long, flexBasis: Float)
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
public external fun jni_YGNodeStyleSetFlexBasisPercentJNI(nativePointer: Long, percent: Float)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleSetFlexBasisAutoJNI(nativePointer: Long)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleSetFlexBasisMaxContentJNI(nativePointer: Long)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleSetFlexBasisFitContentJNI(nativePointer: Long)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleSetFlexBasisStretchJNI(nativePointer: Long)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleGetMarginJNI(nativePointer: Long, edge: Int): Long
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
public external fun jni_YGNodeStyleSetMarginJNI(nativePointer: Long, edge: Int, margin: Float)
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
public external fun jni_YGNodeStyleSetMarginPercentJNI(
|
||||||
|
nativePointer: Long,
|
||||||
|
edge: Int,
|
||||||
|
percent: Float
|
||||||
|
)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleSetMarginAutoJNI(nativePointer: Long, edge: Int)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleGetPaddingJNI(nativePointer: Long, edge: Int): Long
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
public external fun jni_YGNodeStyleSetPaddingJNI(nativePointer: Long, edge: Int, padding: Float)
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
public external fun jni_YGNodeStyleSetPaddingPercentJNI(
|
||||||
|
nativePointer: Long,
|
||||||
|
edge: Int,
|
||||||
|
percent: Float
|
||||||
|
)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleGetBorderJNI(nativePointer: Long, edge: Int): Float
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
public external fun jni_YGNodeStyleSetBorderJNI(nativePointer: Long, edge: Int, border: Float)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleGetPositionJNI(nativePointer: Long, edge: Int): Long
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
public external fun jni_YGNodeStyleSetPositionJNI(nativePointer: Long, edge: Int, position: Float)
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
public external fun jni_YGNodeStyleSetPositionPercentJNI(
|
||||||
|
nativePointer: Long,
|
||||||
|
edge: Int,
|
||||||
|
percent: Float
|
||||||
|
)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleSetPositionAutoJNI(nativePointer: Long, edge: Int)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleGetWidthJNI(nativePointer: Long): Long
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleSetWidthJNI(nativePointer: Long, width: Float)
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
public external fun jni_YGNodeStyleSetWidthPercentJNI(nativePointer: Long, percent: Float)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleSetWidthAutoJNI(nativePointer: Long)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleSetWidthMaxContentJNI(nativePointer: Long)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleSetWidthFitContentJNI(nativePointer: Long)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleSetWidthStretchJNI(nativePointer: Long)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleGetHeightJNI(nativePointer: Long): Long
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleSetHeightJNI(nativePointer: Long, height: Float)
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
public external fun jni_YGNodeStyleSetHeightPercentJNI(nativePointer: Long, percent: Float)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleSetHeightAutoJNI(nativePointer: Long)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleSetHeightMaxContentJNI(nativePointer: Long)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleSetHeightFitContentJNI(nativePointer: Long)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleSetHeightStretchJNI(nativePointer: Long)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleGetMinWidthJNI(nativePointer: Long): Long
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleSetMinWidthJNI(nativePointer: Long, minWidth: Float)
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
public external fun jni_YGNodeStyleSetMinWidthPercentJNI(nativePointer: Long, percent: Float)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleSetMinWidthMaxContentJNI(nativePointer: Long)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleSetMinWidthFitContentJNI(nativePointer: Long)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleSetMinWidthStretchJNI(nativePointer: Long)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleGetMinHeightJNI(nativePointer: Long): Long
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
public external fun jni_YGNodeStyleSetMinHeightJNI(nativePointer: Long, minHeight: Float)
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
public external fun jni_YGNodeStyleSetMinHeightPercentJNI(nativePointer: Long, percent: Float)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleSetMinHeightMaxContentJNI(nativePointer: Long)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleSetMinHeightFitContentJNI(nativePointer: Long)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleSetMinHeightStretchJNI(nativePointer: Long)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleGetMaxWidthJNI(nativePointer: Long): Long
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleSetMaxWidthJNI(nativePointer: Long, maxWidth: Float)
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
public external fun jni_YGNodeStyleSetMaxWidthPercentJNI(nativePointer: Long, percent: Float)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleSetMaxWidthMaxContentJNI(nativePointer: Long)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleSetMaxWidthFitContentJNI(nativePointer: Long)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleSetMaxWidthStretchJNI(nativePointer: Long)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleGetMaxHeightJNI(nativePointer: Long): Long
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
public external fun jni_YGNodeStyleSetMaxHeightJNI(nativePointer: Long, maxheight: Float)
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
public external fun jni_YGNodeStyleSetMaxHeightPercentJNI(nativePointer: Long, percent: Float)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleSetMaxHeightMaxContentJNI(nativePointer: Long)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleSetMaxHeightFitContentJNI(nativePointer: Long)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleSetMaxHeightStretchJNI(nativePointer: Long)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleGetAspectRatioJNI(nativePointer: Long): Float
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
public external fun jni_YGNodeStyleSetAspectRatioJNI(nativePointer: Long, aspectRatio: Float)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeStyleGetGapJNI(nativePointer: Long, gutter: Int): Long
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
public external fun jni_YGNodeStyleSetGapJNI(nativePointer: Long, gutter: Int, gapLength: Float)
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
public external fun jni_YGNodeStyleSetGapPercentJNI(
|
||||||
|
nativePointer: Long,
|
||||||
|
gutter: Int,
|
||||||
|
gapLength: Float
|
||||||
|
)
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
public external fun jni_YGNodeSetHasMeasureFuncJNI(nativePointer: Long, hasMeasureFunc: Boolean)
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
public external fun jni_YGNodeSetHasBaselineFuncJNI(nativePointer: Long, hasMeasureFunc: Boolean)
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
public external fun jni_YGNodeSetStyleInputsJNI(
|
||||||
|
nativePointer: Long,
|
||||||
|
styleInputsArray: FloatArray,
|
||||||
|
size: Int
|
||||||
|
)
|
||||||
|
|
||||||
|
@JvmStatic public external fun jni_YGNodeCloneJNI(nativePointer: Long): Long
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
public external fun jni_YGNodeSetAlwaysFormsContainingBlockJNI(
|
||||||
|
nativePointer: Long,
|
||||||
|
alwaysFormContainingBlock: Boolean
|
||||||
|
)
|
||||||
|
}
|
@@ -124,6 +124,12 @@ public abstract class YogaNode implements YogaProps {
|
|||||||
|
|
||||||
public abstract void setFlexBasisAuto();
|
public abstract void setFlexBasisAuto();
|
||||||
|
|
||||||
|
public abstract void setFlexBasisMaxContent();
|
||||||
|
|
||||||
|
public abstract void setFlexBasisFitContent();
|
||||||
|
|
||||||
|
public abstract void setFlexBasisStretch();
|
||||||
|
|
||||||
public abstract YogaValue getMargin(YogaEdge edge);
|
public abstract YogaValue getMargin(YogaEdge edge);
|
||||||
|
|
||||||
public abstract void setMargin(YogaEdge edge, float margin);
|
public abstract void setMargin(YogaEdge edge, float margin);
|
||||||
@@ -158,6 +164,12 @@ public abstract class YogaNode implements YogaProps {
|
|||||||
|
|
||||||
public abstract void setWidthAuto();
|
public abstract void setWidthAuto();
|
||||||
|
|
||||||
|
public abstract void setWidthMaxContent();
|
||||||
|
|
||||||
|
public abstract void setWidthFitContent();
|
||||||
|
|
||||||
|
public abstract void setWidthStretch();
|
||||||
|
|
||||||
public abstract YogaValue getHeight();
|
public abstract YogaValue getHeight();
|
||||||
|
|
||||||
public abstract void setHeight(float height);
|
public abstract void setHeight(float height);
|
||||||
@@ -166,35 +178,65 @@ public abstract class YogaNode implements YogaProps {
|
|||||||
|
|
||||||
public abstract void setHeightAuto();
|
public abstract void setHeightAuto();
|
||||||
|
|
||||||
|
public abstract void setHeightMaxContent();
|
||||||
|
|
||||||
|
public abstract void setHeightFitContent();
|
||||||
|
|
||||||
|
public abstract void setHeightStretch();
|
||||||
|
|
||||||
public abstract YogaValue getMinWidth();
|
public abstract YogaValue getMinWidth();
|
||||||
|
|
||||||
public abstract void setMinWidth(float minWidth);
|
public abstract void setMinWidth(float minWidth);
|
||||||
|
|
||||||
public abstract void setMinWidthPercent(float percent);
|
public abstract void setMinWidthPercent(float percent);
|
||||||
|
|
||||||
|
public abstract void setMinWidthMaxContent();
|
||||||
|
|
||||||
|
public abstract void setMinWidthFitContent();
|
||||||
|
|
||||||
|
public abstract void setMinWidthStretch();
|
||||||
|
|
||||||
public abstract YogaValue getMinHeight();
|
public abstract YogaValue getMinHeight();
|
||||||
|
|
||||||
public abstract void setMinHeight(float minHeight);
|
public abstract void setMinHeight(float minHeight);
|
||||||
|
|
||||||
public abstract void setMinHeightPercent(float percent);
|
public abstract void setMinHeightPercent(float percent);
|
||||||
|
|
||||||
|
public abstract void setMinHeightMaxContent();
|
||||||
|
|
||||||
|
public abstract void setMinHeightFitContent();
|
||||||
|
|
||||||
|
public abstract void setMinHeightStretch();
|
||||||
|
|
||||||
public abstract YogaValue getMaxWidth();
|
public abstract YogaValue getMaxWidth();
|
||||||
|
|
||||||
public abstract void setMaxWidth(float maxWidth);
|
public abstract void setMaxWidth(float maxWidth);
|
||||||
|
|
||||||
public abstract void setMaxWidthPercent(float percent);
|
public abstract void setMaxWidthPercent(float percent);
|
||||||
|
|
||||||
|
public abstract void setMaxWidthMaxContent();
|
||||||
|
|
||||||
|
public abstract void setMaxWidthFitContent();
|
||||||
|
|
||||||
|
public abstract void setMaxWidthStretch();
|
||||||
|
|
||||||
public abstract YogaValue getMaxHeight();
|
public abstract YogaValue getMaxHeight();
|
||||||
|
|
||||||
public abstract void setMaxHeight(float maxheight);
|
public abstract void setMaxHeight(float maxheight);
|
||||||
|
|
||||||
public abstract void setMaxHeightPercent(float percent);
|
public abstract void setMaxHeightPercent(float percent);
|
||||||
|
|
||||||
|
public abstract void setMaxHeightMaxContent();
|
||||||
|
|
||||||
|
public abstract void setMaxHeightFitContent();
|
||||||
|
|
||||||
|
public abstract void setMaxHeightStretch();
|
||||||
|
|
||||||
public abstract float getAspectRatio();
|
public abstract float getAspectRatio();
|
||||||
|
|
||||||
public abstract void setAspectRatio(float aspectRatio);
|
public abstract void setAspectRatio(float aspectRatio);
|
||||||
|
|
||||||
public abstract float getGap(YogaGutter gutter);
|
public abstract YogaValue getGap(YogaGutter gutter);
|
||||||
|
|
||||||
public abstract void setGap(YogaGutter gutter, float gapLength);
|
public abstract void setGap(YogaGutter gutter, float gapLength);
|
||||||
|
|
||||||
|
@@ -1,18 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.facebook.yoga;
|
|
||||||
|
|
||||||
public abstract class YogaNodeFactory {
|
|
||||||
public static YogaNode create() {
|
|
||||||
return new YogaNodeJNIFinalizer();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static YogaNode create(YogaConfig config) {
|
|
||||||
return new YogaNodeJNIFinalizer(config);
|
|
||||||
}
|
|
||||||
}
|
|
14
java/com/facebook/yoga/YogaNodeFactory.kt
Normal file
14
java/com/facebook/yoga/YogaNodeFactory.kt
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.facebook.yoga
|
||||||
|
|
||||||
|
public object YogaNodeFactory {
|
||||||
|
@JvmStatic public fun create(): YogaNode = YogaNodeJNIFinalizer()
|
||||||
|
|
||||||
|
@JvmStatic public fun create(config: YogaConfig): YogaNode = YogaNodeJNIFinalizer(config)
|
||||||
|
}
|
@@ -373,6 +373,18 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
|||||||
YogaNative.jni_YGNodeStyleSetFlexBasisAutoJNI(mNativePointer);
|
YogaNative.jni_YGNodeStyleSetFlexBasisAutoJNI(mNativePointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setFlexBasisMaxContent() {
|
||||||
|
YogaNative.jni_YGNodeStyleSetFlexBasisMaxContentJNI(mNativePointer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFlexBasisFitContent() {
|
||||||
|
YogaNative.jni_YGNodeStyleSetFlexBasisFitContentJNI(mNativePointer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFlexBasisStretch() {
|
||||||
|
YogaNative.jni_YGNodeStyleSetFlexBasisStretchJNI(mNativePointer);
|
||||||
|
}
|
||||||
|
|
||||||
public YogaValue getMargin(YogaEdge edge) {
|
public YogaValue getMargin(YogaEdge edge) {
|
||||||
return valueFromLong(YogaNative.jni_YGNodeStyleGetMarginJNI(mNativePointer, edge.intValue()));
|
return valueFromLong(YogaNative.jni_YGNodeStyleGetMarginJNI(mNativePointer, edge.intValue()));
|
||||||
}
|
}
|
||||||
@@ -441,6 +453,18 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
|||||||
YogaNative.jni_YGNodeStyleSetWidthAutoJNI(mNativePointer);
|
YogaNative.jni_YGNodeStyleSetWidthAutoJNI(mNativePointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setWidthMaxContent() {
|
||||||
|
YogaNative.jni_YGNodeStyleSetWidthMaxContentJNI(mNativePointer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWidthFitContent() {
|
||||||
|
YogaNative.jni_YGNodeStyleSetWidthFitContentJNI(mNativePointer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWidthStretch() {
|
||||||
|
YogaNative.jni_YGNodeStyleSetWidthStretchJNI(mNativePointer);
|
||||||
|
}
|
||||||
|
|
||||||
public YogaValue getHeight() {
|
public YogaValue getHeight() {
|
||||||
return valueFromLong(YogaNative.jni_YGNodeStyleGetHeightJNI(mNativePointer));
|
return valueFromLong(YogaNative.jni_YGNodeStyleGetHeightJNI(mNativePointer));
|
||||||
}
|
}
|
||||||
@@ -457,6 +481,18 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
|||||||
YogaNative.jni_YGNodeStyleSetHeightAutoJNI(mNativePointer);
|
YogaNative.jni_YGNodeStyleSetHeightAutoJNI(mNativePointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setHeightMaxContent() {
|
||||||
|
YogaNative.jni_YGNodeStyleSetHeightMaxContentJNI(mNativePointer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHeightFitContent() {
|
||||||
|
YogaNative.jni_YGNodeStyleSetHeightFitContentJNI(mNativePointer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHeightStretch() {
|
||||||
|
YogaNative.jni_YGNodeStyleSetHeightStretchJNI(mNativePointer);
|
||||||
|
}
|
||||||
|
|
||||||
public YogaValue getMinWidth() {
|
public YogaValue getMinWidth() {
|
||||||
return valueFromLong(YogaNative.jni_YGNodeStyleGetMinWidthJNI(mNativePointer));
|
return valueFromLong(YogaNative.jni_YGNodeStyleGetMinWidthJNI(mNativePointer));
|
||||||
}
|
}
|
||||||
@@ -469,6 +505,18 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
|||||||
YogaNative.jni_YGNodeStyleSetMinWidthPercentJNI(mNativePointer, percent);
|
YogaNative.jni_YGNodeStyleSetMinWidthPercentJNI(mNativePointer, percent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMinWidthMaxContent() {
|
||||||
|
YogaNative.jni_YGNodeStyleSetMinWidthMaxContentJNI(mNativePointer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMinWidthFitContent() {
|
||||||
|
YogaNative.jni_YGNodeStyleSetMinWidthFitContentJNI(mNativePointer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMinWidthStretch() {
|
||||||
|
YogaNative.jni_YGNodeStyleSetMinWidthStretchJNI(mNativePointer);
|
||||||
|
}
|
||||||
|
|
||||||
public YogaValue getMinHeight() {
|
public YogaValue getMinHeight() {
|
||||||
return valueFromLong(YogaNative.jni_YGNodeStyleGetMinHeightJNI(mNativePointer));
|
return valueFromLong(YogaNative.jni_YGNodeStyleGetMinHeightJNI(mNativePointer));
|
||||||
}
|
}
|
||||||
@@ -481,6 +529,18 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
|||||||
YogaNative.jni_YGNodeStyleSetMinHeightPercentJNI(mNativePointer, percent);
|
YogaNative.jni_YGNodeStyleSetMinHeightPercentJNI(mNativePointer, percent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMinHeightMaxContent() {
|
||||||
|
YogaNative.jni_YGNodeStyleSetMinHeightMaxContentJNI(mNativePointer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMinHeightFitContent() {
|
||||||
|
YogaNative.jni_YGNodeStyleSetMinHeightFitContentJNI(mNativePointer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMinHeightStretch() {
|
||||||
|
YogaNative.jni_YGNodeStyleSetMinHeightStretchJNI(mNativePointer);
|
||||||
|
}
|
||||||
|
|
||||||
public YogaValue getMaxWidth() {
|
public YogaValue getMaxWidth() {
|
||||||
return valueFromLong(YogaNative.jni_YGNodeStyleGetMaxWidthJNI(mNativePointer));
|
return valueFromLong(YogaNative.jni_YGNodeStyleGetMaxWidthJNI(mNativePointer));
|
||||||
}
|
}
|
||||||
@@ -493,6 +553,18 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
|||||||
YogaNative.jni_YGNodeStyleSetMaxWidthPercentJNI(mNativePointer, percent);
|
YogaNative.jni_YGNodeStyleSetMaxWidthPercentJNI(mNativePointer, percent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMaxWidthMaxContent() {
|
||||||
|
YogaNative.jni_YGNodeStyleSetMaxWidthMaxContentJNI(mNativePointer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxWidthFitContent() {
|
||||||
|
YogaNative.jni_YGNodeStyleSetMaxWidthFitContentJNI(mNativePointer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxWidthStretch() {
|
||||||
|
YogaNative.jni_YGNodeStyleSetMaxWidthStretchJNI(mNativePointer);
|
||||||
|
}
|
||||||
|
|
||||||
public YogaValue getMaxHeight() {
|
public YogaValue getMaxHeight() {
|
||||||
return valueFromLong(YogaNative.jni_YGNodeStyleGetMaxHeightJNI(mNativePointer));
|
return valueFromLong(YogaNative.jni_YGNodeStyleGetMaxHeightJNI(mNativePointer));
|
||||||
}
|
}
|
||||||
@@ -505,6 +577,18 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
|||||||
YogaNative.jni_YGNodeStyleSetMaxHeightPercentJNI(mNativePointer, percent);
|
YogaNative.jni_YGNodeStyleSetMaxHeightPercentJNI(mNativePointer, percent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMaxHeightMaxContent() {
|
||||||
|
YogaNative.jni_YGNodeStyleSetMaxHeightMaxContentJNI(mNativePointer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxHeightFitContent() {
|
||||||
|
YogaNative.jni_YGNodeStyleSetMaxHeightFitContentJNI(mNativePointer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxHeightStretch() {
|
||||||
|
YogaNative.jni_YGNodeStyleSetMaxHeightStretchJNI(mNativePointer);
|
||||||
|
}
|
||||||
|
|
||||||
public float getAspectRatio() {
|
public float getAspectRatio() {
|
||||||
return YogaNative.jni_YGNodeStyleGetAspectRatioJNI(mNativePointer);
|
return YogaNative.jni_YGNodeStyleGetAspectRatioJNI(mNativePointer);
|
||||||
}
|
}
|
||||||
@@ -727,8 +811,8 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getGap(YogaGutter gutter) {
|
public YogaValue getGap(YogaGutter gutter) {
|
||||||
return YogaNative.jni_YGNodeStyleGetGapJNI(mNativePointer, gutter.intValue());
|
return valueFromLong(YogaNative.jni_YGNodeStyleGetGapJNI(mNativePointer, gutter.intValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -15,15 +15,33 @@ public interface YogaProps {
|
|||||||
|
|
||||||
void setWidthPercent(float percent);
|
void setWidthPercent(float percent);
|
||||||
|
|
||||||
|
void setWidthAuto();
|
||||||
|
|
||||||
|
void setWidthMaxContent();
|
||||||
|
|
||||||
|
void setWidthFitContent();
|
||||||
|
|
||||||
|
void setWidthStretch();
|
||||||
|
|
||||||
void setMinWidth(float minWidth);
|
void setMinWidth(float minWidth);
|
||||||
|
|
||||||
void setMinWidthPercent(float percent);
|
void setMinWidthPercent(float percent);
|
||||||
|
|
||||||
|
void setMinWidthMaxContent();
|
||||||
|
|
||||||
|
void setMinWidthFitContent();
|
||||||
|
|
||||||
|
void setMinWidthStretch();
|
||||||
|
|
||||||
void setMaxWidth(float maxWidth);
|
void setMaxWidth(float maxWidth);
|
||||||
|
|
||||||
void setMaxWidthPercent(float percent);
|
void setMaxWidthPercent(float percent);
|
||||||
|
|
||||||
void setWidthAuto();
|
void setMaxWidthMaxContent();
|
||||||
|
|
||||||
|
void setMaxWidthFitContent();
|
||||||
|
|
||||||
|
void setMaxWidthStretch();
|
||||||
|
|
||||||
/* Height properties */
|
/* Height properties */
|
||||||
|
|
||||||
@@ -31,15 +49,33 @@ public interface YogaProps {
|
|||||||
|
|
||||||
void setHeightPercent(float percent);
|
void setHeightPercent(float percent);
|
||||||
|
|
||||||
|
void setHeightAuto();
|
||||||
|
|
||||||
|
void setHeightMaxContent();
|
||||||
|
|
||||||
|
void setHeightFitContent();
|
||||||
|
|
||||||
|
void setHeightStretch();
|
||||||
|
|
||||||
void setMinHeight(float minHeight);
|
void setMinHeight(float minHeight);
|
||||||
|
|
||||||
void setMinHeightPercent(float percent);
|
void setMinHeightPercent(float percent);
|
||||||
|
|
||||||
|
void setMinHeightMaxContent();
|
||||||
|
|
||||||
|
void setMinHeightFitContent();
|
||||||
|
|
||||||
|
void setMinHeightStretch();
|
||||||
|
|
||||||
void setMaxHeight(float maxHeight);
|
void setMaxHeight(float maxHeight);
|
||||||
|
|
||||||
void setMaxHeightPercent(float percent);
|
void setMaxHeightPercent(float percent);
|
||||||
|
|
||||||
void setHeightAuto();
|
void setMaxHeightMaxContent();
|
||||||
|
|
||||||
|
void setMaxHeightFitContent();
|
||||||
|
|
||||||
|
void setMaxHeightStretch();
|
||||||
|
|
||||||
/* Margin properties */
|
/* Margin properties */
|
||||||
|
|
||||||
@@ -81,6 +117,12 @@ public interface YogaProps {
|
|||||||
|
|
||||||
void setFlexBasis(float flexBasis);
|
void setFlexBasis(float flexBasis);
|
||||||
|
|
||||||
|
void setFlexBasisMaxContent();
|
||||||
|
|
||||||
|
void setFlexBasisFitContent();
|
||||||
|
|
||||||
|
void setFlexBasisStretch();
|
||||||
|
|
||||||
void setFlexDirection(YogaFlexDirection direction);
|
void setFlexDirection(YogaFlexDirection direction);
|
||||||
|
|
||||||
void setFlexGrow(float flexGrow);
|
void setFlexGrow(float flexGrow);
|
||||||
|
@@ -1,51 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.facebook.yoga;
|
|
||||||
|
|
||||||
public class YogaStyleInputs {
|
|
||||||
public static final short LAYOUT_DIRECTION = 0;
|
|
||||||
public static final short FLEX_DIRECTION = 1;
|
|
||||||
public static final short FLEX = 2;
|
|
||||||
public static final short FLEX_GROW = 3;
|
|
||||||
public static final short FLEX_SHRINK = 4;
|
|
||||||
public static final short FLEX_BASIS = 5;
|
|
||||||
public static final short FLEX_BASIS_PERCENT = 6;
|
|
||||||
public static final short FLEX_BASIS_AUTO = 7;
|
|
||||||
public static final short FLEX_WRAP = 8;
|
|
||||||
public static final short WIDTH = 9;
|
|
||||||
public static final short WIDTH_PERCENT = 10;
|
|
||||||
public static final short WIDTH_AUTO = 11;
|
|
||||||
public static final short MIN_WIDTH = 12;
|
|
||||||
public static final short MIN_WIDTH_PERCENT = 13;
|
|
||||||
public static final short MAX_WIDTH = 14;
|
|
||||||
public static final short MAX_WIDTH_PERCENT = 15;
|
|
||||||
public static final short HEIGHT = 16;
|
|
||||||
public static final short HEIGHT_PERCENT = 17;
|
|
||||||
public static final short HEIGHT_AUTO = 18;
|
|
||||||
public static final short MIN_HEIGHT = 19;
|
|
||||||
public static final short MIN_HEIGHT_PERCENT = 20;
|
|
||||||
public static final short MAX_HEIGHT = 21;
|
|
||||||
public static final short MAX_HEIGHT_PERCENT = 22;
|
|
||||||
public static final short JUSTIFY_CONTENT = 23;
|
|
||||||
public static final short ALIGN_ITEMS = 24;
|
|
||||||
public static final short ALIGN_SELF = 25;
|
|
||||||
public static final short ALIGN_CONTENT = 26;
|
|
||||||
public static final short POSITION_TYPE = 27;
|
|
||||||
public static final short ASPECT_RATIO = 28;
|
|
||||||
public static final short OVERFLOW = 29;
|
|
||||||
public static final short DISPLAY = 30;
|
|
||||||
public static final short MARGIN = 31;
|
|
||||||
public static final short MARGIN_PERCENT = 32;
|
|
||||||
public static final short MARGIN_AUTO = 33;
|
|
||||||
public static final short PADDING = 34;
|
|
||||||
public static final short PADDING_PERCENT = 35;
|
|
||||||
public static final short BORDER = 36;
|
|
||||||
public static final short POSITION = 37;
|
|
||||||
public static final short POSITION_PERCENT = 38;
|
|
||||||
public static final short IS_REFERENCE_BASELINE = 39;
|
|
||||||
}
|
|
51
java/com/facebook/yoga/YogaStyleInputs.kt
Normal file
51
java/com/facebook/yoga/YogaStyleInputs.kt
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.facebook.yoga
|
||||||
|
|
||||||
|
public object YogaStyleInputs {
|
||||||
|
public const val LAYOUT_DIRECTION: Short = 0
|
||||||
|
public const val FLEX_DIRECTION: Short = 1
|
||||||
|
public const val FLEX: Short = 2
|
||||||
|
public const val FLEX_GROW: Short = 3
|
||||||
|
public const val FLEX_SHRINK: Short = 4
|
||||||
|
public const val FLEX_BASIS: Short = 5
|
||||||
|
public const val FLEX_BASIS_PERCENT: Short = 6
|
||||||
|
public const val FLEX_BASIS_AUTO: Short = 7
|
||||||
|
public const val FLEX_WRAP: Short = 8
|
||||||
|
public const val WIDTH: Short = 9
|
||||||
|
public const val WIDTH_PERCENT: Short = 10
|
||||||
|
public const val WIDTH_AUTO: Short = 11
|
||||||
|
public const val MIN_WIDTH: Short = 12
|
||||||
|
public const val MIN_WIDTH_PERCENT: Short = 13
|
||||||
|
public const val MAX_WIDTH: Short = 14
|
||||||
|
public const val MAX_WIDTH_PERCENT: Short = 15
|
||||||
|
public const val HEIGHT: Short = 16
|
||||||
|
public const val HEIGHT_PERCENT: Short = 17
|
||||||
|
public const val HEIGHT_AUTO: Short = 18
|
||||||
|
public const val MIN_HEIGHT: Short = 19
|
||||||
|
public const val MIN_HEIGHT_PERCENT: Short = 20
|
||||||
|
public const val MAX_HEIGHT: Short = 21
|
||||||
|
public const val MAX_HEIGHT_PERCENT: Short = 22
|
||||||
|
public const val JUSTIFY_CONTENT: Short = 23
|
||||||
|
public const val ALIGN_ITEMS: Short = 24
|
||||||
|
public const val ALIGN_SELF: Short = 25
|
||||||
|
public const val ALIGN_CONTENT: Short = 26
|
||||||
|
public const val POSITION_TYPE: Short = 27
|
||||||
|
public const val ASPECT_RATIO: Short = 28
|
||||||
|
public const val OVERFLOW: Short = 29
|
||||||
|
public const val DISPLAY: Short = 30
|
||||||
|
public const val MARGIN: Short = 31
|
||||||
|
public const val MARGIN_PERCENT: Short = 32
|
||||||
|
public const val MARGIN_AUTO: Short = 33
|
||||||
|
public const val PADDING: Short = 34
|
||||||
|
public const val PADDING_PERCENT: Short = 35
|
||||||
|
public const val BORDER: Short = 36
|
||||||
|
public const val POSITION: Short = 37
|
||||||
|
public const val POSITION_PERCENT: Short = 38
|
||||||
|
public const val IS_REFERENCE_BASELINE: Short = 39
|
||||||
|
}
|
@@ -13,7 +13,10 @@ public enum YogaUnit {
|
|||||||
UNDEFINED(0),
|
UNDEFINED(0),
|
||||||
POINT(1),
|
POINT(1),
|
||||||
PERCENT(2),
|
PERCENT(2),
|
||||||
AUTO(3);
|
AUTO(3),
|
||||||
|
MAX_CONTENT(4),
|
||||||
|
FIT_CONTENT(5),
|
||||||
|
STRETCH(6);
|
||||||
|
|
||||||
private final int mIntValue;
|
private final int mIntValue;
|
||||||
|
|
||||||
@@ -31,6 +34,9 @@ public enum YogaUnit {
|
|||||||
case 1: return POINT;
|
case 1: return POINT;
|
||||||
case 2: return PERCENT;
|
case 2: return PERCENT;
|
||||||
case 3: return AUTO;
|
case 3: return AUTO;
|
||||||
|
case 4: return MAX_CONTENT;
|
||||||
|
case 5: return FIT_CONTENT;
|
||||||
|
case 6: return STRETCH;
|
||||||
default: throw new IllegalArgumentException("Unknown enum value: " + value);
|
default: throw new IllegalArgumentException("Unknown enum value: " + value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,18 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.facebook.yoga.annotations;
|
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
import static java.lang.annotation.RetentionPolicy.CLASS;
|
|
||||||
|
|
||||||
@Target({ ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR })
|
|
||||||
@Retention(CLASS)
|
|
||||||
public @interface DoNotStrip { }
|
|
19
java/com/facebook/yoga/annotations/DoNotStrip.kt
Normal file
19
java/com/facebook/yoga/annotations/DoNotStrip.kt
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.facebook.yoga.annotations
|
||||||
|
|
||||||
|
@Target(
|
||||||
|
AnnotationTarget.CLASS,
|
||||||
|
AnnotationTarget.FIELD,
|
||||||
|
AnnotationTarget.FUNCTION,
|
||||||
|
AnnotationTarget.PROPERTY_GETTER,
|
||||||
|
AnnotationTarget.PROPERTY_SETTER,
|
||||||
|
AnnotationTarget.CONSTRUCTOR,
|
||||||
|
)
|
||||||
|
@Retention(AnnotationRetention.BINARY)
|
||||||
|
public annotation class DoNotStrip
|
@@ -429,6 +429,28 @@ static void jni_YGNodeCopyStyleJNI(
|
|||||||
YGNodeStyleSet##name##Auto(_jlong2YGNodeRef(nativePointer)); \
|
YGNodeStyleSet##name##Auto(_jlong2YGNodeRef(nativePointer)); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define YG_NODE_JNI_STYLE_UNIT_PROP_AUTO_INTRINSIC(name) \
|
||||||
|
YG_NODE_JNI_STYLE_UNIT_PROP_AUTO(name) \
|
||||||
|
YG_NODE_JNI_STYLE_UNIT_INTRINSIC(name)
|
||||||
|
|
||||||
|
#define YG_NODE_JNI_STYLE_UNIT_PROP_INTRINSIC(name) \
|
||||||
|
YG_NODE_JNI_STYLE_UNIT_PROP(name) \
|
||||||
|
YG_NODE_JNI_STYLE_UNIT_INTRINSIC(name)
|
||||||
|
|
||||||
|
#define YG_NODE_JNI_STYLE_UNIT_INTRINSIC(name) \
|
||||||
|
static void jni_YGNodeStyleSet##name##MaxContentJNI( \
|
||||||
|
JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer) { \
|
||||||
|
YGNodeStyleSet##name##MaxContent(_jlong2YGNodeRef(nativePointer)); \
|
||||||
|
} \
|
||||||
|
static void jni_YGNodeStyleSet##name##FitContentJNI( \
|
||||||
|
JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer) { \
|
||||||
|
YGNodeStyleSet##name##FitContent(_jlong2YGNodeRef(nativePointer)); \
|
||||||
|
} \
|
||||||
|
static void jni_YGNodeStyleSet##name##StretchJNI( \
|
||||||
|
JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer) { \
|
||||||
|
YGNodeStyleSet##name##Stretch(_jlong2YGNodeRef(nativePointer)); \
|
||||||
|
}
|
||||||
|
|
||||||
#define YG_NODE_JNI_STYLE_EDGE_UNIT_PROP(name) \
|
#define YG_NODE_JNI_STYLE_EDGE_UNIT_PROP(name) \
|
||||||
static jlong jni_YGNodeStyleGet##name##JNI( \
|
static jlong jni_YGNodeStyleGet##name##JNI( \
|
||||||
JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer, jint edge) { \
|
JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer, jint edge) { \
|
||||||
@@ -483,13 +505,13 @@ YG_NODE_JNI_STYLE_PROP(jfloat, float, Flex);
|
|||||||
YG_NODE_JNI_STYLE_PROP(jfloat, float, FlexGrow);
|
YG_NODE_JNI_STYLE_PROP(jfloat, float, FlexGrow);
|
||||||
YG_NODE_JNI_STYLE_PROP(jfloat, float, FlexShrink);
|
YG_NODE_JNI_STYLE_PROP(jfloat, float, FlexShrink);
|
||||||
|
|
||||||
YG_NODE_JNI_STYLE_UNIT_PROP_AUTO(FlexBasis);
|
YG_NODE_JNI_STYLE_UNIT_PROP_AUTO_INTRINSIC(FlexBasis);
|
||||||
YG_NODE_JNI_STYLE_UNIT_PROP_AUTO(Width);
|
YG_NODE_JNI_STYLE_UNIT_PROP_AUTO_INTRINSIC(Width);
|
||||||
YG_NODE_JNI_STYLE_UNIT_PROP(MinWidth);
|
YG_NODE_JNI_STYLE_UNIT_PROP_INTRINSIC(MinWidth);
|
||||||
YG_NODE_JNI_STYLE_UNIT_PROP(MaxWidth);
|
YG_NODE_JNI_STYLE_UNIT_PROP_INTRINSIC(MaxWidth);
|
||||||
YG_NODE_JNI_STYLE_UNIT_PROP_AUTO(Height);
|
YG_NODE_JNI_STYLE_UNIT_PROP_AUTO_INTRINSIC(Height);
|
||||||
YG_NODE_JNI_STYLE_UNIT_PROP(MinHeight);
|
YG_NODE_JNI_STYLE_UNIT_PROP_INTRINSIC(MinHeight);
|
||||||
YG_NODE_JNI_STYLE_UNIT_PROP(MaxHeight);
|
YG_NODE_JNI_STYLE_UNIT_PROP_INTRINSIC(MaxHeight);
|
||||||
|
|
||||||
YG_NODE_JNI_STYLE_EDGE_UNIT_PROP_AUTO(Position);
|
YG_NODE_JNI_STYLE_EDGE_UNIT_PROP_AUTO(Position);
|
||||||
|
|
||||||
@@ -703,13 +725,13 @@ jni_YGNodeCloneJNI(JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer) {
|
|||||||
return reinterpret_cast<jlong>(clonedYogaNode);
|
return reinterpret_cast<jlong>(clonedYogaNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static jfloat jni_YGNodeStyleGetGapJNI(
|
static jlong jni_YGNodeStyleGetGapJNI(
|
||||||
JNIEnv* /*env*/,
|
JNIEnv* /*env*/,
|
||||||
jobject /*obj*/,
|
jobject /*obj*/,
|
||||||
jlong nativePointer,
|
jlong nativePointer,
|
||||||
jint gutter) {
|
jint gutter) {
|
||||||
return (jfloat)YGNodeStyleGetGap(
|
return YogaValue::asJavaLong(YGNodeStyleGetGap(
|
||||||
_jlong2YGNodeRef(nativePointer), static_cast<YGGutter>(gutter));
|
_jlong2YGNodeRef(nativePointer), static_cast<YGGutter>(gutter)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void jni_YGNodeStyleSetGapJNI(
|
static void jni_YGNodeStyleSetGapJNI(
|
||||||
@@ -870,6 +892,15 @@ static JNINativeMethod methods[] = {
|
|||||||
{"jni_YGNodeStyleSetFlexBasisAutoJNI",
|
{"jni_YGNodeStyleSetFlexBasisAutoJNI",
|
||||||
"(J)V",
|
"(J)V",
|
||||||
(void*)jni_YGNodeStyleSetFlexBasisAutoJNI},
|
(void*)jni_YGNodeStyleSetFlexBasisAutoJNI},
|
||||||
|
{"jni_YGNodeStyleSetFlexBasisMaxContentJNI",
|
||||||
|
"(J)V",
|
||||||
|
(void*)jni_YGNodeStyleSetFlexBasisMaxContentJNI},
|
||||||
|
{"jni_YGNodeStyleSetFlexBasisFitContentJNI",
|
||||||
|
"(J)V",
|
||||||
|
(void*)jni_YGNodeStyleSetFlexBasisFitContentJNI},
|
||||||
|
{"jni_YGNodeStyleSetFlexBasisStretchJNI",
|
||||||
|
"(J)V",
|
||||||
|
(void*)jni_YGNodeStyleSetFlexBasisStretchJNI},
|
||||||
{"jni_YGNodeStyleGetMarginJNI",
|
{"jni_YGNodeStyleGetMarginJNI",
|
||||||
"(JI)J",
|
"(JI)J",
|
||||||
(void*)jni_YGNodeStyleGetMarginJNI},
|
(void*)jni_YGNodeStyleGetMarginJNI},
|
||||||
@@ -917,6 +948,15 @@ static JNINativeMethod methods[] = {
|
|||||||
{"jni_YGNodeStyleSetWidthAutoJNI",
|
{"jni_YGNodeStyleSetWidthAutoJNI",
|
||||||
"(J)V",
|
"(J)V",
|
||||||
(void*)jni_YGNodeStyleSetWidthAutoJNI},
|
(void*)jni_YGNodeStyleSetWidthAutoJNI},
|
||||||
|
{"jni_YGNodeStyleSetWidthMaxContentJNI",
|
||||||
|
"(J)V",
|
||||||
|
(void*)jni_YGNodeStyleSetWidthMaxContentJNI},
|
||||||
|
{"jni_YGNodeStyleSetWidthFitContentJNI",
|
||||||
|
"(J)V",
|
||||||
|
(void*)jni_YGNodeStyleSetWidthFitContentJNI},
|
||||||
|
{"jni_YGNodeStyleSetWidthStretchJNI",
|
||||||
|
"(J)V",
|
||||||
|
(void*)jni_YGNodeStyleSetWidthStretchJNI},
|
||||||
{"jni_YGNodeStyleGetHeightJNI", "(J)J", (void*)jni_YGNodeStyleGetHeightJNI},
|
{"jni_YGNodeStyleGetHeightJNI", "(J)J", (void*)jni_YGNodeStyleGetHeightJNI},
|
||||||
{"jni_YGNodeStyleSetHeightJNI",
|
{"jni_YGNodeStyleSetHeightJNI",
|
||||||
"(JF)V",
|
"(JF)V",
|
||||||
@@ -927,6 +967,15 @@ static JNINativeMethod methods[] = {
|
|||||||
{"jni_YGNodeStyleSetHeightAutoJNI",
|
{"jni_YGNodeStyleSetHeightAutoJNI",
|
||||||
"(J)V",
|
"(J)V",
|
||||||
(void*)jni_YGNodeStyleSetHeightAutoJNI},
|
(void*)jni_YGNodeStyleSetHeightAutoJNI},
|
||||||
|
{"jni_YGNodeStyleSetHeightMaxContentJNI",
|
||||||
|
"(J)V",
|
||||||
|
(void*)jni_YGNodeStyleSetHeightMaxContentJNI},
|
||||||
|
{"jni_YGNodeStyleSetHeightFitContentJNI",
|
||||||
|
"(J)V",
|
||||||
|
(void*)jni_YGNodeStyleSetHeightFitContentJNI},
|
||||||
|
{"jni_YGNodeStyleSetHeightStretchJNI",
|
||||||
|
"(J)V",
|
||||||
|
(void*)jni_YGNodeStyleSetHeightStretchJNI},
|
||||||
{"jni_YGNodeStyleGetMinWidthJNI",
|
{"jni_YGNodeStyleGetMinWidthJNI",
|
||||||
"(J)J",
|
"(J)J",
|
||||||
(void*)jni_YGNodeStyleGetMinWidthJNI},
|
(void*)jni_YGNodeStyleGetMinWidthJNI},
|
||||||
@@ -936,6 +985,15 @@ static JNINativeMethod methods[] = {
|
|||||||
{"jni_YGNodeStyleSetMinWidthPercentJNI",
|
{"jni_YGNodeStyleSetMinWidthPercentJNI",
|
||||||
"(JF)V",
|
"(JF)V",
|
||||||
(void*)jni_YGNodeStyleSetMinWidthPercentJNI},
|
(void*)jni_YGNodeStyleSetMinWidthPercentJNI},
|
||||||
|
{"jni_YGNodeStyleSetMinWidthMaxContentJNI",
|
||||||
|
"(J)V",
|
||||||
|
(void*)jni_YGNodeStyleSetMinWidthMaxContentJNI},
|
||||||
|
{"jni_YGNodeStyleSetMinWidthFitContentJNI",
|
||||||
|
"(J)V",
|
||||||
|
(void*)jni_YGNodeStyleSetMinWidthFitContentJNI},
|
||||||
|
{"jni_YGNodeStyleSetMinWidthStretchJNI",
|
||||||
|
"(J)V",
|
||||||
|
(void*)jni_YGNodeStyleSetMinWidthStretchJNI},
|
||||||
{"jni_YGNodeStyleGetMinHeightJNI",
|
{"jni_YGNodeStyleGetMinHeightJNI",
|
||||||
"(J)J",
|
"(J)J",
|
||||||
(void*)jni_YGNodeStyleGetMinHeightJNI},
|
(void*)jni_YGNodeStyleGetMinHeightJNI},
|
||||||
@@ -945,6 +1003,15 @@ static JNINativeMethod methods[] = {
|
|||||||
{"jni_YGNodeStyleSetMinHeightPercentJNI",
|
{"jni_YGNodeStyleSetMinHeightPercentJNI",
|
||||||
"(JF)V",
|
"(JF)V",
|
||||||
(void*)jni_YGNodeStyleSetMinHeightPercentJNI},
|
(void*)jni_YGNodeStyleSetMinHeightPercentJNI},
|
||||||
|
{"jni_YGNodeStyleSetMinHeightMaxContentJNI",
|
||||||
|
"(J)V",
|
||||||
|
(void*)jni_YGNodeStyleSetMinHeightMaxContentJNI},
|
||||||
|
{"jni_YGNodeStyleSetMinHeightFitContentJNI",
|
||||||
|
"(J)V",
|
||||||
|
(void*)jni_YGNodeStyleSetMinHeightFitContentJNI},
|
||||||
|
{"jni_YGNodeStyleSetMinHeightStretchJNI",
|
||||||
|
"(J)V",
|
||||||
|
(void*)jni_YGNodeStyleSetMinHeightStretchJNI},
|
||||||
{"jni_YGNodeStyleGetMaxWidthJNI",
|
{"jni_YGNodeStyleGetMaxWidthJNI",
|
||||||
"(J)J",
|
"(J)J",
|
||||||
(void*)jni_YGNodeStyleGetMaxWidthJNI},
|
(void*)jni_YGNodeStyleGetMaxWidthJNI},
|
||||||
@@ -954,6 +1021,15 @@ static JNINativeMethod methods[] = {
|
|||||||
{"jni_YGNodeStyleSetMaxWidthPercentJNI",
|
{"jni_YGNodeStyleSetMaxWidthPercentJNI",
|
||||||
"(JF)V",
|
"(JF)V",
|
||||||
(void*)jni_YGNodeStyleSetMaxWidthPercentJNI},
|
(void*)jni_YGNodeStyleSetMaxWidthPercentJNI},
|
||||||
|
{"jni_YGNodeStyleSetMaxWidthMaxContentJNI",
|
||||||
|
"(J)V",
|
||||||
|
(void*)jni_YGNodeStyleSetMaxWidthMaxContentJNI},
|
||||||
|
{"jni_YGNodeStyleSetMaxWidthFitContentJNI",
|
||||||
|
"(J)V",
|
||||||
|
(void*)jni_YGNodeStyleSetMaxWidthFitContentJNI},
|
||||||
|
{"jni_YGNodeStyleSetMaxWidthStretchJNI",
|
||||||
|
"(J)V",
|
||||||
|
(void*)jni_YGNodeStyleSetMaxWidthStretchJNI},
|
||||||
{"jni_YGNodeStyleGetMaxHeightJNI",
|
{"jni_YGNodeStyleGetMaxHeightJNI",
|
||||||
"(J)J",
|
"(J)J",
|
||||||
(void*)jni_YGNodeStyleGetMaxHeightJNI},
|
(void*)jni_YGNodeStyleGetMaxHeightJNI},
|
||||||
@@ -963,6 +1039,15 @@ static JNINativeMethod methods[] = {
|
|||||||
{"jni_YGNodeStyleSetMaxHeightPercentJNI",
|
{"jni_YGNodeStyleSetMaxHeightPercentJNI",
|
||||||
"(JF)V",
|
"(JF)V",
|
||||||
(void*)jni_YGNodeStyleSetMaxHeightPercentJNI},
|
(void*)jni_YGNodeStyleSetMaxHeightPercentJNI},
|
||||||
|
{"jni_YGNodeStyleSetMaxHeightMaxContentJNI",
|
||||||
|
"(J)V",
|
||||||
|
(void*)jni_YGNodeStyleSetMaxHeightMaxContentJNI},
|
||||||
|
{"jni_YGNodeStyleSetMaxHeightFitContentJNI",
|
||||||
|
"(J)V",
|
||||||
|
(void*)jni_YGNodeStyleSetMaxHeightFitContentJNI},
|
||||||
|
{"jni_YGNodeStyleSetMaxHeightStretchJNI",
|
||||||
|
"(J)V",
|
||||||
|
(void*)jni_YGNodeStyleSetMaxHeightStretchJNI},
|
||||||
{"jni_YGNodeStyleGetAspectRatioJNI",
|
{"jni_YGNodeStyleGetAspectRatioJNI",
|
||||||
"(J)F",
|
"(J)F",
|
||||||
(void*)jni_YGNodeStyleGetAspectRatioJNI},
|
(void*)jni_YGNodeStyleGetAspectRatioJNI},
|
||||||
@@ -972,7 +1057,7 @@ static JNINativeMethod methods[] = {
|
|||||||
{"jni_YGNodeSetHasMeasureFuncJNI",
|
{"jni_YGNodeSetHasMeasureFuncJNI",
|
||||||
"(JZ)V",
|
"(JZ)V",
|
||||||
(void*)jni_YGNodeSetHasMeasureFuncJNI},
|
(void*)jni_YGNodeSetHasMeasureFuncJNI},
|
||||||
{"jni_YGNodeStyleGetGapJNI", "(JI)F", (void*)jni_YGNodeStyleGetGapJNI},
|
{"jni_YGNodeStyleGetGapJNI", "(JI)J", (void*)jni_YGNodeStyleGetGapJNI},
|
||||||
{"jni_YGNodeStyleSetGapJNI", "(JIF)V", (void*)jni_YGNodeStyleSetGapJNI},
|
{"jni_YGNodeStyleSetGapJNI", "(JIF)V", (void*)jni_YGNodeStyleSetGapJNI},
|
||||||
{"jni_YGNodeStyleSetGapPercentJNI",
|
{"jni_YGNodeStyleSetGapPercentJNI",
|
||||||
"(JIF)V",
|
"(JIF)V",
|
||||||
|
@@ -11,6 +11,7 @@ import com.facebook.yoga.YogaMeasureMode;
|
|||||||
import com.facebook.yoga.YogaMeasureOutput;
|
import com.facebook.yoga.YogaMeasureOutput;
|
||||||
import com.facebook.yoga.YogaMeasureFunction;
|
import com.facebook.yoga.YogaMeasureFunction;
|
||||||
import com.facebook.yoga.YogaNode;
|
import com.facebook.yoga.YogaNode;
|
||||||
|
import com.facebook.yoga.YogaFlexDirection;
|
||||||
|
|
||||||
public class TestUtils {
|
public class TestUtils {
|
||||||
|
|
||||||
@@ -43,9 +44,13 @@ public class TestUtils {
|
|||||||
} else if (heightMode == YogaMeasureMode.AT_MOST) {
|
} else if (heightMode == YogaMeasureMode.AT_MOST) {
|
||||||
measuredHeight =
|
measuredHeight =
|
||||||
Math.min(
|
Math.min(
|
||||||
caclulateHeight(text, Math.max(measuredWidth, getWidestWordWidth(text))), height);
|
caclulateHeight(text, node.getFlexDirection() == YogaFlexDirection.COLUMN
|
||||||
|
? measuredWidth
|
||||||
|
: Math.max(measuredWidth, getWidestWordWidth(text))), height);
|
||||||
} else {
|
} else {
|
||||||
measuredHeight = caclulateHeight(text, Math.max(measuredWidth, getWidestWordWidth(text)));
|
measuredHeight = caclulateHeight(text, node.getFlexDirection() == YogaFlexDirection.COLUMN
|
||||||
|
? measuredWidth
|
||||||
|
: Math.max(measuredWidth, getWidestWordWidth(text)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return YogaMeasureOutput.make(measuredWidth, measuredHeight);
|
return YogaMeasureOutput.make(measuredWidth, measuredHeight);
|
||||||
|
@@ -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<<e8d11c0e97041bb2f1487f0d87363fdc>>
|
* @generated SignedSource<<84597dd8b2c4f3aac1f21abe68f25308>>
|
||||||
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGAlignItemsTest.html
|
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGAlignItemsTest.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -2293,6 +2293,86 @@ public class YGAlignItemsTest {
|
|||||||
assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
|
assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_align_items_non_stretch_s526008() {
|
||||||
|
YogaConfig config = YogaConfigFactory.create();
|
||||||
|
|
||||||
|
final YogaNode root = createNode(config);
|
||||||
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
||||||
|
root.setWidth(400f);
|
||||||
|
root.setHeight(400f);
|
||||||
|
|
||||||
|
final YogaNode root_child0 = createNode(config);
|
||||||
|
root_child0.setFlexDirection(YogaFlexDirection.ROW);
|
||||||
|
root.addChildAt(root_child0, 0);
|
||||||
|
|
||||||
|
final YogaNode root_child0_child0 = createNode(config);
|
||||||
|
root_child0_child0.setAlignItems(YogaAlign.FLEX_START);
|
||||||
|
root_child0.addChildAt(root_child0_child0, 0);
|
||||||
|
|
||||||
|
final YogaNode root_child0_child0_child0 = createNode(config);
|
||||||
|
root_child0_child0.addChildAt(root_child0_child0_child0, 0);
|
||||||
|
|
||||||
|
final YogaNode root_child0_child0_child0_child0 = createNode(config);
|
||||||
|
root_child0_child0_child0_child0.setHeight(10f);
|
||||||
|
root_child0_child0_child0.addChildAt(root_child0_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(400f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(400f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(400f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0_child0_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(10f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0_child0_child0_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0_child0_child0_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0_child0_child0_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(10f, root_child0_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(400f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(400f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(400f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(400f, root_child0_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0_child0_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(10f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0_child0_child0_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0_child0_child0_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0_child0_child0_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(10f, root_child0_child0_child0_child0.getLayoutHeight(), 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
private YogaNode createNode(YogaConfig config) {
|
private YogaNode createNode(YogaConfig config) {
|
||||||
return mNodeFactory.create(config);
|
return mNodeFactory.create(config);
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -160,6 +160,18 @@ void Node::setFlexBasisAuto() {
|
|||||||
YGNodeStyleSetFlexBasisAuto(m_node);
|
YGNodeStyleSetFlexBasisAuto(m_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Node::setFlexBasisMaxContent() {
|
||||||
|
YGNodeStyleSetFlexBasisMaxContent(m_node);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Node::setFlexBasisFitContent() {
|
||||||
|
YGNodeStyleSetFlexBasisFitContent(m_node);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Node::setFlexBasisStretch() {
|
||||||
|
YGNodeStyleSetFlexBasisStretch(m_node);
|
||||||
|
}
|
||||||
|
|
||||||
void Node::setFlexGrow(double flexGrow) {
|
void Node::setFlexGrow(double flexGrow) {
|
||||||
YGNodeStyleSetFlexGrow(m_node, flexGrow);
|
YGNodeStyleSetFlexGrow(m_node, flexGrow);
|
||||||
}
|
}
|
||||||
@@ -180,6 +192,18 @@ void Node::setWidthAuto() {
|
|||||||
YGNodeStyleSetWidthAuto(m_node);
|
YGNodeStyleSetWidthAuto(m_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Node::setWidthMaxContent() {
|
||||||
|
YGNodeStyleSetWidthMaxContent(m_node);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Node::setWidthFitContent() {
|
||||||
|
YGNodeStyleSetWidthFitContent(m_node);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Node::setWidthStretch() {
|
||||||
|
YGNodeStyleSetWidthStretch(m_node);
|
||||||
|
}
|
||||||
|
|
||||||
void Node::setHeight(double height) {
|
void Node::setHeight(double height) {
|
||||||
YGNodeStyleSetHeight(m_node, height);
|
YGNodeStyleSetHeight(m_node, height);
|
||||||
}
|
}
|
||||||
@@ -192,6 +216,18 @@ void Node::setHeightAuto() {
|
|||||||
YGNodeStyleSetHeightAuto(m_node);
|
YGNodeStyleSetHeightAuto(m_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Node::setHeightMaxContent() {
|
||||||
|
YGNodeStyleSetHeightMaxContent(m_node);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Node::setHeightFitContent() {
|
||||||
|
YGNodeStyleSetHeightFitContent(m_node);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Node::setHeightStretch() {
|
||||||
|
YGNodeStyleSetHeightStretch(m_node);
|
||||||
|
}
|
||||||
|
|
||||||
void Node::setMinWidth(double minWidth) {
|
void Node::setMinWidth(double minWidth) {
|
||||||
YGNodeStyleSetMinWidth(m_node, minWidth);
|
YGNodeStyleSetMinWidth(m_node, minWidth);
|
||||||
}
|
}
|
||||||
@@ -200,6 +236,18 @@ void Node::setMinWidthPercent(double minWidth) {
|
|||||||
YGNodeStyleSetMinWidthPercent(m_node, minWidth);
|
YGNodeStyleSetMinWidthPercent(m_node, minWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Node::setMinWidthMaxContent() {
|
||||||
|
YGNodeStyleSetMinWidthMaxContent(m_node);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Node::setMinWidthFitContent() {
|
||||||
|
YGNodeStyleSetMinWidthFitContent(m_node);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Node::setMinWidthStretch() {
|
||||||
|
YGNodeStyleSetMinWidthStretch(m_node);
|
||||||
|
}
|
||||||
|
|
||||||
void Node::setMinHeight(double minHeight) {
|
void Node::setMinHeight(double minHeight) {
|
||||||
YGNodeStyleSetMinHeight(m_node, minHeight);
|
YGNodeStyleSetMinHeight(m_node, minHeight);
|
||||||
}
|
}
|
||||||
@@ -208,6 +256,18 @@ void Node::setMinHeightPercent(double minHeight) {
|
|||||||
YGNodeStyleSetMinHeightPercent(m_node, minHeight);
|
YGNodeStyleSetMinHeightPercent(m_node, minHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Node::setMinHeightMaxContent() {
|
||||||
|
YGNodeStyleSetMinHeightMaxContent(m_node);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Node::setMinHeightFitContent() {
|
||||||
|
YGNodeStyleSetMinHeightFitContent(m_node);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Node::setMinHeightStretch() {
|
||||||
|
YGNodeStyleSetMinHeightStretch(m_node);
|
||||||
|
}
|
||||||
|
|
||||||
void Node::setMaxWidth(double maxWidth) {
|
void Node::setMaxWidth(double maxWidth) {
|
||||||
YGNodeStyleSetMaxWidth(m_node, maxWidth);
|
YGNodeStyleSetMaxWidth(m_node, maxWidth);
|
||||||
}
|
}
|
||||||
@@ -216,6 +276,18 @@ void Node::setMaxWidthPercent(double maxWidth) {
|
|||||||
YGNodeStyleSetMaxWidthPercent(m_node, maxWidth);
|
YGNodeStyleSetMaxWidthPercent(m_node, maxWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Node::setMaxWidthMaxContent() {
|
||||||
|
YGNodeStyleSetMaxWidthMaxContent(m_node);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Node::setMaxWidthFitContent() {
|
||||||
|
YGNodeStyleSetMaxWidthFitContent(m_node);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Node::setMaxWidthStretch() {
|
||||||
|
YGNodeStyleSetMaxWidthStretch(m_node);
|
||||||
|
}
|
||||||
|
|
||||||
void Node::setMaxHeight(double maxHeight) {
|
void Node::setMaxHeight(double maxHeight) {
|
||||||
YGNodeStyleSetMaxHeight(m_node, maxHeight);
|
YGNodeStyleSetMaxHeight(m_node, maxHeight);
|
||||||
}
|
}
|
||||||
@@ -224,6 +296,18 @@ void Node::setMaxHeightPercent(double maxHeight) {
|
|||||||
YGNodeStyleSetMaxHeightPercent(m_node, maxHeight);
|
YGNodeStyleSetMaxHeightPercent(m_node, maxHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Node::setMaxHeightMaxContent() {
|
||||||
|
YGNodeStyleSetMaxHeightMaxContent(m_node);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Node::setMaxHeightFitContent() {
|
||||||
|
YGNodeStyleSetMaxHeightFitContent(m_node);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Node::setMaxHeightStretch() {
|
||||||
|
YGNodeStyleSetMaxHeightStretch(m_node);
|
||||||
|
}
|
||||||
|
|
||||||
void Node::setAspectRatio(double aspectRatio) {
|
void Node::setAspectRatio(double aspectRatio) {
|
||||||
YGNodeStyleSetAspectRatio(m_node, aspectRatio);
|
YGNodeStyleSetAspectRatio(m_node, aspectRatio);
|
||||||
}
|
}
|
||||||
@@ -355,8 +439,9 @@ Value Node::getPadding(int edge) const {
|
|||||||
YGNodeStyleGetPadding(m_node, static_cast<YGEdge>(edge)));
|
YGNodeStyleGetPadding(m_node, static_cast<YGEdge>(edge)));
|
||||||
}
|
}
|
||||||
|
|
||||||
float Node::getGap(int gutter) {
|
Value Node::getGap(int gutter) const {
|
||||||
return YGNodeStyleGetGap(m_node, static_cast<YGGutter>(gutter));
|
return Value::fromYGValue(
|
||||||
|
YGNodeStyleGetGap(m_node, static_cast<YGGutter>(gutter)));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Node::isReferenceBaseline() {
|
bool Node::isReferenceBaseline() {
|
||||||
|
@@ -97,25 +97,46 @@ class Node {
|
|||||||
void setFlexBasis(double flexBasis);
|
void setFlexBasis(double flexBasis);
|
||||||
void setFlexBasisPercent(double flexBasis);
|
void setFlexBasisPercent(double flexBasis);
|
||||||
void setFlexBasisAuto();
|
void setFlexBasisAuto();
|
||||||
|
void setFlexBasisMaxContent();
|
||||||
|
void setFlexBasisFitContent();
|
||||||
|
void setFlexBasisStretch();
|
||||||
void setFlexGrow(double flexGrow);
|
void setFlexGrow(double flexGrow);
|
||||||
void setFlexShrink(double flexShrink);
|
void setFlexShrink(double flexShrink);
|
||||||
|
|
||||||
void setWidth(double width);
|
void setWidth(double width);
|
||||||
void setWidthPercent(double width);
|
void setWidthPercent(double width);
|
||||||
void setWidthAuto();
|
void setWidthAuto();
|
||||||
|
void setWidthMaxContent();
|
||||||
|
void setWidthFitContent();
|
||||||
|
void setWidthStretch();
|
||||||
void setHeight(double height);
|
void setHeight(double height);
|
||||||
void setHeightPercent(double height);
|
void setHeightPercent(double height);
|
||||||
void setHeightAuto();
|
void setHeightAuto();
|
||||||
|
void setHeightMaxContent();
|
||||||
|
void setHeightFitContent();
|
||||||
|
void setHeightStretch();
|
||||||
|
|
||||||
void setMinWidth(double minWidth);
|
void setMinWidth(double minWidth);
|
||||||
void setMinWidthPercent(double minWidth);
|
void setMinWidthPercent(double minWidth);
|
||||||
|
void setMinWidthMaxContent();
|
||||||
|
void setMinWidthFitContent();
|
||||||
|
void setMinWidthStretch();
|
||||||
void setMinHeight(double minHeight);
|
void setMinHeight(double minHeight);
|
||||||
void setMinHeightPercent(double minHeight);
|
void setMinHeightPercent(double minHeight);
|
||||||
|
void setMinHeightMaxContent();
|
||||||
|
void setMinHeightFitContent();
|
||||||
|
void setMinHeightStretch();
|
||||||
|
|
||||||
void setMaxWidth(double maxWidth);
|
void setMaxWidth(double maxWidth);
|
||||||
void setMaxWidthPercent(double maxWidth);
|
void setMaxWidthPercent(double maxWidth);
|
||||||
|
void setMaxWidthMaxContent();
|
||||||
|
void setMaxWidthFitContent();
|
||||||
|
void setMaxWidthStretch();
|
||||||
void setMaxHeight(double maxHeight);
|
void setMaxHeight(double maxHeight);
|
||||||
void setMaxHeightPercent(double maxHeight);
|
void setMaxHeightPercent(double maxHeight);
|
||||||
|
void setMaxHeightMaxContent();
|
||||||
|
void setMaxHeightFitContent();
|
||||||
|
void setMaxHeightStretch();
|
||||||
|
|
||||||
void setAspectRatio(double aspectRatio);
|
void setAspectRatio(double aspectRatio);
|
||||||
|
|
||||||
@@ -165,7 +186,7 @@ class Node {
|
|||||||
|
|
||||||
Value getPadding(int edge) const;
|
Value getPadding(int edge) const;
|
||||||
|
|
||||||
float getGap(int gutter);
|
Value getGap(int gutter) const;
|
||||||
|
|
||||||
int getBoxSizing(void) const;
|
int getBoxSizing(void) const;
|
||||||
|
|
||||||
|
@@ -90,25 +90,46 @@ EMSCRIPTEN_BINDINGS(YOGA_LAYOUT) {
|
|||||||
.function("setFlexBasis", &Node::setFlexBasis)
|
.function("setFlexBasis", &Node::setFlexBasis)
|
||||||
.function("setFlexBasisPercent", &Node::setFlexBasisPercent)
|
.function("setFlexBasisPercent", &Node::setFlexBasisPercent)
|
||||||
.function("setFlexBasisAuto", &Node::setFlexBasisAuto)
|
.function("setFlexBasisAuto", &Node::setFlexBasisAuto)
|
||||||
|
.function("setFlexBasisMaxContent", &Node::setFlexBasisMaxContent)
|
||||||
|
.function("setFlexBasisFitContent", &Node::setFlexBasisFitContent)
|
||||||
|
.function("setFlexBasisStretch", &Node::setFlexBasisStretch)
|
||||||
.function("setFlexGrow", &Node::setFlexGrow)
|
.function("setFlexGrow", &Node::setFlexGrow)
|
||||||
.function("setFlexShrink", &Node::setFlexShrink)
|
.function("setFlexShrink", &Node::setFlexShrink)
|
||||||
|
|
||||||
.function("setWidth", &Node::setWidth)
|
.function("setWidth", &Node::setWidth)
|
||||||
.function("setWidthPercent", &Node::setWidthPercent)
|
.function("setWidthPercent", &Node::setWidthPercent)
|
||||||
.function("setWidthAuto", &Node::setWidthAuto)
|
.function("setWidthAuto", &Node::setWidthAuto)
|
||||||
|
.function("setWidthMaxContent", &Node::setWidthMaxContent)
|
||||||
|
.function("setWidthFitContent", &Node::setWidthFitContent)
|
||||||
|
.function("setWidthStretch", &Node::setWidthStretch)
|
||||||
.function("setHeight", &Node::setHeight)
|
.function("setHeight", &Node::setHeight)
|
||||||
.function("setHeightPercent", &Node::setHeightPercent)
|
.function("setHeightPercent", &Node::setHeightPercent)
|
||||||
.function("setHeightAuto", &Node::setHeightAuto)
|
.function("setHeightAuto", &Node::setHeightAuto)
|
||||||
|
.function("setHeightMaxContent", &Node::setHeightMaxContent)
|
||||||
|
.function("setHeightFitContent", &Node::setHeightFitContent)
|
||||||
|
.function("setHeightStretch", &Node::setHeightStretch)
|
||||||
|
|
||||||
.function("setMinWidth", &Node::setMinWidth)
|
.function("setMinWidth", &Node::setMinWidth)
|
||||||
.function("setMinWidthPercent", &Node::setMinWidthPercent)
|
.function("setMinWidthPercent", &Node::setMinWidthPercent)
|
||||||
|
.function("setMinWidthMaxContent", &Node::setMinWidthMaxContent)
|
||||||
|
.function("setMinWidthFitContent", &Node::setMinWidthFitContent)
|
||||||
|
.function("setMinWidthStretch", &Node::setMinWidthStretch)
|
||||||
.function("setMinHeight", &Node::setMinHeight)
|
.function("setMinHeight", &Node::setMinHeight)
|
||||||
.function("setMinHeightPercent", &Node::setMinHeightPercent)
|
.function("setMinHeightPercent", &Node::setMinHeightPercent)
|
||||||
|
.function("setMinHeightMaxContent", &Node::setMinHeightMaxContent)
|
||||||
|
.function("setMinHeightFitContent", &Node::setMinHeightFitContent)
|
||||||
|
.function("setMinHeightStretch", &Node::setMinHeightStretch)
|
||||||
|
|
||||||
.function("setMaxWidth", &Node::setMaxWidth)
|
.function("setMaxWidth", &Node::setMaxWidth)
|
||||||
.function("setMaxWidthPercent", &Node::setMaxWidthPercent)
|
.function("setMaxWidthPercent", &Node::setMaxWidthPercent)
|
||||||
|
.function("setMaxWidthMaxContent", &Node::setMaxWidthMaxContent)
|
||||||
|
.function("setMaxWidthFitContent", &Node::setMaxWidthFitContent)
|
||||||
|
.function("setMaxWidthStretch", &Node::setMaxWidthStretch)
|
||||||
.function("setMaxHeight", &Node::setMaxHeight)
|
.function("setMaxHeight", &Node::setMaxHeight)
|
||||||
.function("setMaxHeightPercent", &Node::setMaxHeightPercent)
|
.function("setMaxHeightPercent", &Node::setMaxHeightPercent)
|
||||||
|
.function("setMaxHeightMaxContent", &Node::setMaxHeightMaxContent)
|
||||||
|
.function("setMaxHeightFitContent", &Node::setMaxHeightFitContent)
|
||||||
|
.function("setMaxHeightStretch", &Node::setMaxHeightStretch)
|
||||||
|
|
||||||
.function("setBoxSizing", &Node::setBoxSizing)
|
.function("setBoxSizing", &Node::setBoxSizing)
|
||||||
|
|
||||||
|
@@ -125,6 +125,9 @@ export enum Unit {
|
|||||||
Point = 1,
|
Point = 1,
|
||||||
Percent = 2,
|
Percent = 2,
|
||||||
Auto = 3,
|
Auto = 3,
|
||||||
|
MaxContent = 4,
|
||||||
|
FitContent = 5,
|
||||||
|
Stretch = 6,
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum Wrap {
|
export enum Wrap {
|
||||||
@@ -203,6 +206,9 @@ const constants = {
|
|||||||
UNIT_POINT: Unit.Point,
|
UNIT_POINT: Unit.Point,
|
||||||
UNIT_PERCENT: Unit.Percent,
|
UNIT_PERCENT: Unit.Percent,
|
||||||
UNIT_AUTO: Unit.Auto,
|
UNIT_AUTO: Unit.Auto,
|
||||||
|
UNIT_MAX_CONTENT: Unit.MaxContent,
|
||||||
|
UNIT_FIT_CONTENT: Unit.FitContent,
|
||||||
|
UNIT_STRETCH: Unit.Stretch,
|
||||||
WRAP_NO_WRAP: Wrap.NoWrap,
|
WRAP_NO_WRAP: Wrap.NoWrap,
|
||||||
WRAP_WRAP: Wrap.Wrap,
|
WRAP_WRAP: Wrap.Wrap,
|
||||||
WRAP_WRAP_REVERSE: Wrap.WrapReverse,
|
WRAP_WRAP_REVERSE: Wrap.WrapReverse,
|
||||||
|
@@ -134,17 +134,41 @@ export type Node = {
|
|||||||
setDirection(direction: Direction): void;
|
setDirection(direction: Direction): void;
|
||||||
setDisplay(display: Display): void;
|
setDisplay(display: Display): void;
|
||||||
setFlex(flex: number | undefined): void;
|
setFlex(flex: number | undefined): void;
|
||||||
setFlexBasis(flexBasis: number | 'auto' | `${number}%` | undefined): void;
|
setFlexBasis(
|
||||||
|
flexBasis:
|
||||||
|
| number
|
||||||
|
| 'auto'
|
||||||
|
| 'fit-content'
|
||||||
|
| 'max-content'
|
||||||
|
| 'stretch'
|
||||||
|
| `${number}%`
|
||||||
|
| undefined,
|
||||||
|
): void;
|
||||||
setFlexBasisPercent(flexBasis: number | undefined): void;
|
setFlexBasisPercent(flexBasis: number | undefined): void;
|
||||||
setFlexBasisAuto(): void;
|
setFlexBasisAuto(): void;
|
||||||
|
setFlexBasisFitContent(): void;
|
||||||
|
setFlexBasisMaxContent(): void;
|
||||||
|
setFlexBasisStretch(): void;
|
||||||
setFlexDirection(flexDirection: FlexDirection): void;
|
setFlexDirection(flexDirection: FlexDirection): void;
|
||||||
setFlexGrow(flexGrow: number | undefined): void;
|
setFlexGrow(flexGrow: number | undefined): void;
|
||||||
setFlexShrink(flexShrink: number | undefined): void;
|
setFlexShrink(flexShrink: number | undefined): void;
|
||||||
setFlexWrap(flexWrap: Wrap): void;
|
setFlexWrap(flexWrap: Wrap): void;
|
||||||
setHeight(height: number | 'auto' | `${number}%` | undefined): void;
|
setHeight(
|
||||||
|
height:
|
||||||
|
| number
|
||||||
|
| 'auto'
|
||||||
|
| 'fit-content'
|
||||||
|
| 'max-content'
|
||||||
|
| 'stretch'
|
||||||
|
| `${number}%`
|
||||||
|
| undefined,
|
||||||
|
): void;
|
||||||
setIsReferenceBaseline(isReferenceBaseline: boolean): void;
|
setIsReferenceBaseline(isReferenceBaseline: boolean): void;
|
||||||
setHeightAuto(): void;
|
setHeightAuto(): void;
|
||||||
|
setHeightFitContent(): void;
|
||||||
|
setHeightMaxContent(): void;
|
||||||
setHeightPercent(height: number | undefined): void;
|
setHeightPercent(height: number | undefined): void;
|
||||||
|
setHeightStretch(): void;
|
||||||
setJustifyContent(justifyContent: Justify): void;
|
setJustifyContent(justifyContent: Justify): void;
|
||||||
setGap(gutter: Gutter, gapLength: number | `${number}%` | undefined): Value;
|
setGap(gutter: Gutter, gapLength: number | `${number}%` | undefined): Value;
|
||||||
setGapPercent(gutter: Gutter, gapLength: number | undefined): Value;
|
setGapPercent(gutter: Gutter, gapLength: number | undefined): Value;
|
||||||
@@ -154,16 +178,60 @@ export type Node = {
|
|||||||
): void;
|
): void;
|
||||||
setMarginAuto(edge: Edge): void;
|
setMarginAuto(edge: Edge): void;
|
||||||
setMarginPercent(edge: Edge, margin: number | undefined): void;
|
setMarginPercent(edge: Edge, margin: number | undefined): void;
|
||||||
setMaxHeight(maxHeight: number | `${number}%` | undefined): void;
|
setMaxHeight(
|
||||||
|
maxHeight:
|
||||||
|
| number
|
||||||
|
| 'fit-content'
|
||||||
|
| 'max-content'
|
||||||
|
| 'stretch'
|
||||||
|
| `${number}%`
|
||||||
|
| undefined,
|
||||||
|
): void;
|
||||||
|
setMaxHeightFitContent(): void;
|
||||||
|
setMaxHeightMaxContent(): void;
|
||||||
setMaxHeightPercent(maxHeight: number | undefined): void;
|
setMaxHeightPercent(maxHeight: number | undefined): void;
|
||||||
setMaxWidth(maxWidth: number | `${number}%` | undefined): void;
|
setMaxHeightStretch(): void;
|
||||||
|
setMaxWidth(
|
||||||
|
maxWidth:
|
||||||
|
| number
|
||||||
|
| 'fit-content'
|
||||||
|
| 'max-content'
|
||||||
|
| 'stretch'
|
||||||
|
| `${number}%`
|
||||||
|
| undefined,
|
||||||
|
): void;
|
||||||
|
setMaxWidthFitContent(): void;
|
||||||
|
setMaxWidthMaxContent(): void;
|
||||||
setMaxWidthPercent(maxWidth: number | undefined): void;
|
setMaxWidthPercent(maxWidth: number | undefined): void;
|
||||||
|
setMaxWidthStretch(): void;
|
||||||
setDirtiedFunc(dirtiedFunc: DirtiedFunction | null): void;
|
setDirtiedFunc(dirtiedFunc: DirtiedFunction | null): void;
|
||||||
setMeasureFunc(measureFunc: MeasureFunction | null): void;
|
setMeasureFunc(measureFunc: MeasureFunction | null): void;
|
||||||
setMinHeight(minHeight: number | `${number}%` | undefined): void;
|
setMinHeight(
|
||||||
|
minHeight:
|
||||||
|
| number
|
||||||
|
| 'fit-content'
|
||||||
|
| 'max-content'
|
||||||
|
| 'stretch'
|
||||||
|
| `${number}%`
|
||||||
|
| undefined,
|
||||||
|
): void;
|
||||||
|
setMinHeightFitContent(): void;
|
||||||
|
setMinHeightMaxContent(): void;
|
||||||
setMinHeightPercent(minHeight: number | undefined): void;
|
setMinHeightPercent(minHeight: number | undefined): void;
|
||||||
setMinWidth(minWidth: number | `${number}%` | undefined): void;
|
setMinHeightStretch(): void;
|
||||||
|
setMinWidth(
|
||||||
|
minWidth:
|
||||||
|
| number
|
||||||
|
| 'fit-content'
|
||||||
|
| 'max-content'
|
||||||
|
| 'stretch'
|
||||||
|
| `${number}%`
|
||||||
|
| undefined,
|
||||||
|
): void;
|
||||||
|
setMinWidthFitContent(): void;
|
||||||
|
setMinWidthMaxContent(): void;
|
||||||
setMinWidthPercent(minWidth: number | undefined): void;
|
setMinWidthPercent(minWidth: number | undefined): void;
|
||||||
|
setMinWidthStretch(): void;
|
||||||
setOverflow(overflow: Overflow): void;
|
setOverflow(overflow: Overflow): void;
|
||||||
setPadding(edge: Edge, padding: number | `${number}%` | undefined): void;
|
setPadding(edge: Edge, padding: number | `${number}%` | undefined): void;
|
||||||
setPaddingPercent(edge: Edge, padding: number | undefined): void;
|
setPaddingPercent(edge: Edge, padding: number | undefined): void;
|
||||||
@@ -172,9 +240,21 @@ export type Node = {
|
|||||||
setPositionType(positionType: PositionType): void;
|
setPositionType(positionType: PositionType): void;
|
||||||
setPositionAuto(edge: Edge): void;
|
setPositionAuto(edge: Edge): void;
|
||||||
setBoxSizing(boxSizing: BoxSizing): void;
|
setBoxSizing(boxSizing: BoxSizing): void;
|
||||||
setWidth(width: number | 'auto' | `${number}%` | undefined): void;
|
setWidth(
|
||||||
|
width:
|
||||||
|
| number
|
||||||
|
| 'auto'
|
||||||
|
| 'fit-content'
|
||||||
|
| 'max-content'
|
||||||
|
| 'stretch'
|
||||||
|
| `${number}%`
|
||||||
|
| undefined,
|
||||||
|
): void;
|
||||||
setWidthAuto(): void;
|
setWidthAuto(): void;
|
||||||
|
setWidthFitContent(): void;
|
||||||
|
setWidthMaxContent(): void;
|
||||||
setWidthPercent(width: number | undefined): void;
|
setWidthPercent(width: number | undefined): void;
|
||||||
|
setWidthStretch(): void;
|
||||||
unsetDirtiedFunc(): void;
|
unsetDirtiedFunc(): void;
|
||||||
unsetMeasureFunc(): void;
|
unsetMeasureFunc(): void;
|
||||||
setAlwaysFormsContainingBlock(alwaysFormsContainingBlock: boolean): void;
|
setAlwaysFormsContainingBlock(alwaysFormsContainingBlock: boolean): void;
|
||||||
@@ -220,6 +300,9 @@ export default function wrapAssembly(lib: any): Yoga {
|
|||||||
[Unit.Point]: lib.Node.prototype[fnName],
|
[Unit.Point]: lib.Node.prototype[fnName],
|
||||||
[Unit.Percent]: lib.Node.prototype[`${fnName}Percent`],
|
[Unit.Percent]: lib.Node.prototype[`${fnName}Percent`],
|
||||||
[Unit.Auto]: lib.Node.prototype[`${fnName}Auto`],
|
[Unit.Auto]: lib.Node.prototype[`${fnName}Auto`],
|
||||||
|
[Unit.MaxContent]: lib.Node.prototype[`${fnName}MaxContent`],
|
||||||
|
[Unit.FitContent]: lib.Node.prototype[`${fnName}FitContent`],
|
||||||
|
[Unit.Stretch]: lib.Node.prototype[`${fnName}Stretch`],
|
||||||
};
|
};
|
||||||
|
|
||||||
patch(lib.Node.prototype, fnName, function (original, ...args) {
|
patch(lib.Node.prototype, fnName, function (original, ...args) {
|
||||||
@@ -232,6 +315,15 @@ export default function wrapAssembly(lib: any): Yoga {
|
|||||||
if (value === 'auto') {
|
if (value === 'auto') {
|
||||||
unit = Unit.Auto;
|
unit = Unit.Auto;
|
||||||
asNumber = undefined;
|
asNumber = undefined;
|
||||||
|
} else if (value == 'max-content') {
|
||||||
|
unit = Unit.MaxContent;
|
||||||
|
asNumber = undefined;
|
||||||
|
} else if (value == 'fit-content') {
|
||||||
|
unit = Unit.FitContent;
|
||||||
|
asNumber = undefined;
|
||||||
|
} else if (value == 'stretch') {
|
||||||
|
unit = Unit.Stretch;
|
||||||
|
asNumber = undefined;
|
||||||
} else if (typeof value === 'object') {
|
} else if (typeof value === 'object') {
|
||||||
unit = value.unit;
|
unit = value.unit;
|
||||||
asNumber = value.valueOf();
|
asNumber = value.valueOf();
|
||||||
|
@@ -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<<075a0b67003e5c4a1f51bd99da71c700>>
|
* @generated SignedSource<<fd80af208d8635435f86ffa8f3810b39>>
|
||||||
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGAlignItemsTest.html
|
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGAlignItemsTest.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -2442,3 +2442,88 @@ test('align_stretch_with_row_reverse', () => {
|
|||||||
config.free();
|
config.free();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
test('align_items_non_stretch_s526008', () => {
|
||||||
|
const config = Yoga.Config.create();
|
||||||
|
let root;
|
||||||
|
|
||||||
|
try {
|
||||||
|
root = Yoga.Node.create(config);
|
||||||
|
root.setPositionType(PositionType.Absolute);
|
||||||
|
root.setWidth(400);
|
||||||
|
root.setHeight(400);
|
||||||
|
|
||||||
|
const root_child0 = Yoga.Node.create(config);
|
||||||
|
root_child0.setFlexDirection(FlexDirection.Row);
|
||||||
|
root.insertChild(root_child0, 0);
|
||||||
|
|
||||||
|
const root_child0_child0 = Yoga.Node.create(config);
|
||||||
|
root_child0_child0.setAlignItems(Align.FlexStart);
|
||||||
|
root_child0.insertChild(root_child0_child0, 0);
|
||||||
|
|
||||||
|
const root_child0_child0_child0 = Yoga.Node.create(config);
|
||||||
|
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
||||||
|
|
||||||
|
const root_child0_child0_child0_child0 = Yoga.Node.create(config);
|
||||||
|
root_child0_child0_child0_child0.setHeight(10);
|
||||||
|
root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0);
|
||||||
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
||||||
|
|
||||||
|
expect(root.getComputedLeft()).toBe(0);
|
||||||
|
expect(root.getComputedTop()).toBe(0);
|
||||||
|
expect(root.getComputedWidth()).toBe(400);
|
||||||
|
expect(root.getComputedHeight()).toBe(400);
|
||||||
|
|
||||||
|
expect(root_child0.getComputedLeft()).toBe(0);
|
||||||
|
expect(root_child0.getComputedTop()).toBe(0);
|
||||||
|
expect(root_child0.getComputedWidth()).toBe(400);
|
||||||
|
expect(root_child0.getComputedHeight()).toBe(10);
|
||||||
|
|
||||||
|
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
||||||
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
||||||
|
expect(root_child0_child0.getComputedWidth()).toBe(0);
|
||||||
|
expect(root_child0_child0.getComputedHeight()).toBe(10);
|
||||||
|
|
||||||
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(0);
|
||||||
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
||||||
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(0);
|
||||||
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(10);
|
||||||
|
|
||||||
|
expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(0);
|
||||||
|
expect(root_child0_child0_child0_child0.getComputedTop()).toBe(0);
|
||||||
|
expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(0);
|
||||||
|
expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(10);
|
||||||
|
|
||||||
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
||||||
|
|
||||||
|
expect(root.getComputedLeft()).toBe(0);
|
||||||
|
expect(root.getComputedTop()).toBe(0);
|
||||||
|
expect(root.getComputedWidth()).toBe(400);
|
||||||
|
expect(root.getComputedHeight()).toBe(400);
|
||||||
|
|
||||||
|
expect(root_child0.getComputedLeft()).toBe(0);
|
||||||
|
expect(root_child0.getComputedTop()).toBe(0);
|
||||||
|
expect(root_child0.getComputedWidth()).toBe(400);
|
||||||
|
expect(root_child0.getComputedHeight()).toBe(10);
|
||||||
|
|
||||||
|
expect(root_child0_child0.getComputedLeft()).toBe(400);
|
||||||
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
||||||
|
expect(root_child0_child0.getComputedWidth()).toBe(0);
|
||||||
|
expect(root_child0_child0.getComputedHeight()).toBe(10);
|
||||||
|
|
||||||
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(0);
|
||||||
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
||||||
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(0);
|
||||||
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(10);
|
||||||
|
|
||||||
|
expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(0);
|
||||||
|
expect(root_child0_child0_child0_child0.getComputedTop()).toBe(0);
|
||||||
|
expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(0);
|
||||||
|
expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(10);
|
||||||
|
} finally {
|
||||||
|
if (typeof root !== 'undefined') {
|
||||||
|
root.freeRecursive();
|
||||||
|
}
|
||||||
|
|
||||||
|
config.free();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -5,17 +5,23 @@
|
|||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {MeasureMode} from 'yoga-layout';
|
import {FlexDirection, MeasureMode} from 'yoga-layout';
|
||||||
|
|
||||||
|
type MeasureContext = {
|
||||||
|
text: string;
|
||||||
|
flexDirection: FlexDirection;
|
||||||
|
};
|
||||||
|
|
||||||
export function instrinsicSizeMeasureFunc(
|
export function instrinsicSizeMeasureFunc(
|
||||||
this: string,
|
this: MeasureContext,
|
||||||
width: number,
|
width: number,
|
||||||
widthMode: MeasureMode,
|
widthMode: MeasureMode,
|
||||||
height: number,
|
height: number,
|
||||||
heightMode: MeasureMode,
|
heightMode: MeasureMode,
|
||||||
): {width: number; height: number} {
|
): {width: number; height: number} {
|
||||||
const textLength = this.length;
|
const textLength = this.text.length;
|
||||||
const words = this.split(' ');
|
const words = this.text.split(' ');
|
||||||
|
const flexDirection = this.flexDirection;
|
||||||
const widthPerChar = 10;
|
const widthPerChar = 10;
|
||||||
const heightPerChar = 10;
|
const heightPerChar = 10;
|
||||||
|
|
||||||
@@ -53,7 +59,10 @@ export function instrinsicSizeMeasureFunc(
|
|||||||
return heightPerChar;
|
return heightPerChar;
|
||||||
}
|
}
|
||||||
|
|
||||||
const maxLineWidth = Math.max(longestWordWidth(), measuredWidth);
|
const maxLineWidth =
|
||||||
|
flexDirection == FlexDirection.Column
|
||||||
|
? measuredWidth
|
||||||
|
: Math.max(longestWordWidth(), measuredWidth);
|
||||||
|
|
||||||
//if fixed width < width of widest word, take width of widest word
|
//if fixed width < width of widest word, take width of widest word
|
||||||
|
|
||||||
|
@@ -19,10 +19,11 @@ include(":yoga")
|
|||||||
|
|
||||||
project(":yoga").projectDir = file("java")
|
project(":yoga").projectDir = file("java")
|
||||||
|
|
||||||
rootProject.name = "yoga-github"
|
gradleEnterprise {
|
||||||
|
buildScan {
|
||||||
// If you specify a file inside gradle/gradle-enterprise.gradle.kts
|
termsOfServiceUrl = "https://gradle.com/terms-of-service"
|
||||||
// you can configure your custom Gradle Enterprise instance
|
termsOfServiceAgree = "yes"
|
||||||
if (file("./gradle/gradle-enterprise.gradle.kts").exists()) {
|
}
|
||||||
apply(from = "./gradle/gradle-enterprise.gradle.kts")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rootProject.name = "yoga-github"
|
||||||
|
7
tests/.clang-tidy
Normal file
7
tests/.clang-tidy
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
InheritParentConfig: true
|
||||||
|
Checks: '
|
||||||
|
-facebook-hte-CArray,
|
||||||
|
-modernize-avoid-c-arrays,
|
||||||
|
'
|
||||||
|
...
|
@@ -128,4 +128,19 @@ TEST(StyleValuePool, store_undefined_after_large_int) {
|
|||||||
EXPECT_EQ(pool.getLength(handle), StyleLength::undefined());
|
EXPECT_EQ(pool.getLength(handle), StyleLength::undefined());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(StyleValuePool, store_keywords) {
|
||||||
|
StyleValuePool pool;
|
||||||
|
StyleValueHandle handleMaxContent;
|
||||||
|
StyleValueHandle handleFitContent;
|
||||||
|
StyleValueHandle handleStretch;
|
||||||
|
|
||||||
|
pool.store(handleMaxContent, StyleSizeLength::ofMaxContent());
|
||||||
|
pool.store(handleFitContent, StyleSizeLength::ofFitContent());
|
||||||
|
pool.store(handleStretch, StyleSizeLength::ofStretch());
|
||||||
|
|
||||||
|
EXPECT_EQ(pool.getSize(handleMaxContent), StyleSizeLength::ofMaxContent());
|
||||||
|
EXPECT_EQ(pool.getSize(handleFitContent), StyleSizeLength::ofFitContent());
|
||||||
|
EXPECT_EQ(pool.getSize(handleStretch), StyleSizeLength::ofStretch());
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace facebook::yoga
|
} // namespace facebook::yoga
|
||||||
|
214
tests/YGPersistentNodeCloningTest.cpp
Normal file
214
tests/YGPersistentNodeCloningTest.cpp
Normal file
@@ -0,0 +1,214 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include <yoga/Yoga.h>
|
||||||
|
#include <yoga/config/Config.h>
|
||||||
|
#include <yoga/node/Node.h>
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
#include <memory>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace facebook::yoga {
|
||||||
|
|
||||||
|
struct YGPersistentNodeCloningTest : public ::testing::Test {
|
||||||
|
struct NodeWrapper {
|
||||||
|
explicit NodeWrapper(
|
||||||
|
YGConfigRef config,
|
||||||
|
std::vector<std::shared_ptr<NodeWrapper>> children = {})
|
||||||
|
: node{YGNodeNewWithConfig(config)}, children{std::move(children)} {
|
||||||
|
YGNodeSetContext(node, this);
|
||||||
|
|
||||||
|
auto privateNode = resolveRef(node);
|
||||||
|
for (const auto& child : this->children) {
|
||||||
|
auto privateChild = resolveRef(child->node);
|
||||||
|
// Claim first ownership of not yet owned nodes, to avoid immediately
|
||||||
|
// cloning them
|
||||||
|
if (YGNodeGetOwner(child->node) == nullptr) {
|
||||||
|
privateChild->setOwner(privateNode);
|
||||||
|
}
|
||||||
|
privateNode->insertChild(privateChild, privateNode->getChildCount());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clone, with current children, for mutation
|
||||||
|
NodeWrapper(const NodeWrapper& other)
|
||||||
|
: node{YGNodeClone(other.node)}, children{other.children} {
|
||||||
|
YGNodeSetContext(node, this);
|
||||||
|
|
||||||
|
auto privateNode = resolveRef(node);
|
||||||
|
privateNode->setOwner(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clone, with new children
|
||||||
|
NodeWrapper(
|
||||||
|
const NodeWrapper& other,
|
||||||
|
std::vector<std::shared_ptr<NodeWrapper>> children)
|
||||||
|
: node{YGNodeClone(other.node)}, children{std::move(children)} {
|
||||||
|
YGNodeSetContext(node, this);
|
||||||
|
|
||||||
|
auto privateNode = resolveRef(node);
|
||||||
|
privateNode->setOwner(nullptr);
|
||||||
|
privateNode->setChildren({});
|
||||||
|
privateNode->setDirty(true);
|
||||||
|
|
||||||
|
for (const auto& child : this->children) {
|
||||||
|
auto privateChild = resolveRef(child->node);
|
||||||
|
// Claim first ownership of not yet owned nodes, to avoid immediately
|
||||||
|
// cloning them
|
||||||
|
if (YGNodeGetOwner(child->node) == nullptr) {
|
||||||
|
privateChild->setOwner(privateNode);
|
||||||
|
}
|
||||||
|
privateNode->insertChild(privateChild, privateNode->getChildCount());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NodeWrapper(NodeWrapper&&) = delete;
|
||||||
|
|
||||||
|
~NodeWrapper() {
|
||||||
|
YGNodeFree(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
NodeWrapper& operator=(const NodeWrapper& other) = delete;
|
||||||
|
NodeWrapper& operator=(NodeWrapper&& other) = delete;
|
||||||
|
|
||||||
|
YGNodeRef node;
|
||||||
|
std::vector<std::shared_ptr<NodeWrapper>> children;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ConfigWrapper {
|
||||||
|
ConfigWrapper() {
|
||||||
|
YGConfigSetCloneNodeFunc(
|
||||||
|
config,
|
||||||
|
[](YGNodeConstRef oldNode, YGNodeConstRef owner, size_t childIndex) {
|
||||||
|
onClone(oldNode, owner, childIndex);
|
||||||
|
auto wrapper = static_cast<NodeWrapper*>(YGNodeGetContext(owner));
|
||||||
|
auto old = static_cast<NodeWrapper*>(YGNodeGetContext(oldNode));
|
||||||
|
|
||||||
|
wrapper->children[childIndex] = std::make_shared<NodeWrapper>(*old);
|
||||||
|
return wrapper->children[childIndex]->node;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
ConfigWrapper(const ConfigWrapper&) = delete;
|
||||||
|
ConfigWrapper(ConfigWrapper&&) = delete;
|
||||||
|
|
||||||
|
~ConfigWrapper() {
|
||||||
|
YGConfigFree(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
ConfigWrapper& operator=(const ConfigWrapper&) = delete;
|
||||||
|
ConfigWrapper& operator=(ConfigWrapper&&) = delete;
|
||||||
|
|
||||||
|
YGConfigRef config{YGConfigNew()};
|
||||||
|
};
|
||||||
|
|
||||||
|
ConfigWrapper configWrapper;
|
||||||
|
YGConfigRef config{configWrapper.config};
|
||||||
|
|
||||||
|
void SetUp() override {
|
||||||
|
onClone = [](...) {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||||
|
static inline std::function<void(YGNodeConstRef, YGNodeConstRef, size_t)>
|
||||||
|
onClone;
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(
|
||||||
|
YGPersistentNodeCloningTest,
|
||||||
|
changing_sibling_height_does_not_clone_neighbors) {
|
||||||
|
// <ScrollView>
|
||||||
|
// <View id="Sibling" style={{ height: 1 }} />
|
||||||
|
// <View id="A" style={{ height: 1 }}>
|
||||||
|
// <View id="B">
|
||||||
|
// <View id="C">
|
||||||
|
// <View id="D"/>
|
||||||
|
// </View>
|
||||||
|
// </View>
|
||||||
|
// </View>
|
||||||
|
// </ScrollView>
|
||||||
|
|
||||||
|
auto sibling = std::make_shared<NodeWrapper>(config);
|
||||||
|
YGNodeStyleSetHeight(sibling->node, 1);
|
||||||
|
|
||||||
|
auto d = std::make_shared<NodeWrapper>(config);
|
||||||
|
auto c = std::make_shared<NodeWrapper>(config, std::vector{d});
|
||||||
|
auto b = std::make_shared<NodeWrapper>(config, std::vector{c});
|
||||||
|
auto a = std::make_shared<NodeWrapper>(config, std::vector{b});
|
||||||
|
YGNodeStyleSetHeight(a->node, 1);
|
||||||
|
|
||||||
|
auto scrollContentView =
|
||||||
|
std::make_shared<NodeWrapper>(config, std::vector{sibling, a});
|
||||||
|
YGNodeStyleSetPositionType(scrollContentView->node, YGPositionTypeAbsolute);
|
||||||
|
|
||||||
|
auto scrollView =
|
||||||
|
std::make_shared<NodeWrapper>(config, std::vector{scrollContentView});
|
||||||
|
YGNodeStyleSetWidth(scrollView->node, 100);
|
||||||
|
YGNodeStyleSetHeight(scrollView->node, 100);
|
||||||
|
|
||||||
|
// We don't expect any cloning during the first layout
|
||||||
|
onClone = [](...) { FAIL(); };
|
||||||
|
|
||||||
|
YGNodeCalculateLayout(
|
||||||
|
scrollView->node, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
|
|
||||||
|
auto siblingPrime = std::make_shared<NodeWrapper>(config);
|
||||||
|
YGNodeStyleSetHeight(siblingPrime->node, 2);
|
||||||
|
|
||||||
|
auto scrollContentViewPrime = std::make_shared<NodeWrapper>(
|
||||||
|
*scrollContentView, std::vector{siblingPrime, a});
|
||||||
|
auto scrollViewPrime = std::make_shared<NodeWrapper>(
|
||||||
|
*scrollView, std::vector{scrollContentViewPrime});
|
||||||
|
|
||||||
|
std::vector<NodeWrapper*> nodesCloned;
|
||||||
|
// We should only need to clone "A"
|
||||||
|
onClone = [&](YGNodeConstRef oldNode,
|
||||||
|
YGNodeConstRef /*owner*/,
|
||||||
|
size_t /*childIndex*/) {
|
||||||
|
nodesCloned.push_back(static_cast<NodeWrapper*>(YGNodeGetContext(oldNode)));
|
||||||
|
};
|
||||||
|
|
||||||
|
YGNodeCalculateLayout(
|
||||||
|
scrollViewPrime->node, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
|
|
||||||
|
EXPECT_EQ(nodesCloned.size(), 1);
|
||||||
|
EXPECT_EQ(nodesCloned[0], a.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(YGPersistentNodeCloningTest, clone_leaf_display_contents_node) {
|
||||||
|
// <View id="A">
|
||||||
|
// <View id="B" style={{ display: 'contents' }} />
|
||||||
|
// </View>
|
||||||
|
|
||||||
|
auto b = std::make_shared<NodeWrapper>(config);
|
||||||
|
auto a = std::make_shared<NodeWrapper>(config, std::vector{b});
|
||||||
|
YGNodeStyleSetDisplay(b->node, YGDisplayContents);
|
||||||
|
|
||||||
|
// We don't expect any cloning during the first layout
|
||||||
|
onClone = [](...) { FAIL(); };
|
||||||
|
|
||||||
|
YGNodeCalculateLayout(a->node, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
|
|
||||||
|
auto aPrime = std::make_shared<NodeWrapper>(config, std::vector{b});
|
||||||
|
|
||||||
|
std::vector<NodeWrapper*> nodesCloned;
|
||||||
|
// We should clone "C"
|
||||||
|
onClone = [&](YGNodeConstRef oldNode,
|
||||||
|
YGNodeConstRef /*owner*/,
|
||||||
|
size_t /*childIndex*/) {
|
||||||
|
nodesCloned.push_back(static_cast<NodeWrapper*>(YGNodeGetContext(oldNode)));
|
||||||
|
};
|
||||||
|
|
||||||
|
YGNodeCalculateLayout(aPrime->node, 100, 100, YGDirectionLTR);
|
||||||
|
|
||||||
|
EXPECT_EQ(nodesCloned.size(), 1);
|
||||||
|
EXPECT_EQ(nodesCloned[0], b.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace facebook::yoga
|
@@ -8,6 +8,8 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <yoga/Yoga.h>
|
#include <yoga/Yoga.h>
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
TEST(YogaTest, rounding_value) {
|
TEST(YogaTest, rounding_value) {
|
||||||
// Test that whole numbers are rounded to whole despite ceil/floor flags
|
// Test that whole numbers are rounded to whole despite ceil/floor flags
|
||||||
ASSERT_FLOAT_EQ(6.0, YGRoundValueToPixelGrid(6.000001, 2.0, false, false));
|
ASSERT_FLOAT_EQ(6.0, YGRoundValueToPixelGrid(6.000001, 2.0, false, false));
|
||||||
@@ -39,6 +41,44 @@ TEST(YogaTest, rounding_value) {
|
|||||||
ASSERT_FLOAT_EQ(-6.0, YGRoundValueToPixelGrid(-5.99, 2.0, false, false));
|
ASSERT_FLOAT_EQ(-6.0, YGRoundValueToPixelGrid(-5.99, 2.0, false, false));
|
||||||
ASSERT_FLOAT_EQ(-5.5, YGRoundValueToPixelGrid(-5.99, 2.0, true, false));
|
ASSERT_FLOAT_EQ(-5.5, YGRoundValueToPixelGrid(-5.99, 2.0, true, false));
|
||||||
ASSERT_FLOAT_EQ(-6.0, YGRoundValueToPixelGrid(-5.99, 2.0, false, true));
|
ASSERT_FLOAT_EQ(-6.0, YGRoundValueToPixelGrid(-5.99, 2.0, false, true));
|
||||||
|
|
||||||
|
// Rounding up/down halfway values is as expected for both positive and
|
||||||
|
// negative numbers
|
||||||
|
ASSERT_FLOAT_EQ(-3, YGRoundValueToPixelGrid(-3.5, 1.0, false, false));
|
||||||
|
ASSERT_FLOAT_EQ(-3, YGRoundValueToPixelGrid(-3.4, 1.0, false, false));
|
||||||
|
ASSERT_FLOAT_EQ(-4, YGRoundValueToPixelGrid(-3.6, 1.0, false, false));
|
||||||
|
ASSERT_FLOAT_EQ(-3, YGRoundValueToPixelGrid(-3.499999, 1.0, false, false));
|
||||||
|
ASSERT_FLOAT_EQ(-3, YGRoundValueToPixelGrid(-3.500001, 1.0, false, false));
|
||||||
|
ASSERT_FLOAT_EQ(-4, YGRoundValueToPixelGrid(-3.5001, 1.0, false, false));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(-3, YGRoundValueToPixelGrid(-3.5, 1.0, true, false));
|
||||||
|
ASSERT_FLOAT_EQ(-3, YGRoundValueToPixelGrid(-3.4, 1.0, true, false));
|
||||||
|
ASSERT_FLOAT_EQ(-3, YGRoundValueToPixelGrid(-3.6, 1.0, true, false));
|
||||||
|
ASSERT_FLOAT_EQ(-3, YGRoundValueToPixelGrid(-3.499999, 1.0, true, false));
|
||||||
|
ASSERT_FLOAT_EQ(-3, YGRoundValueToPixelGrid(-3.500001, 1.0, true, false));
|
||||||
|
ASSERT_FLOAT_EQ(-3, YGRoundValueToPixelGrid(-3.5001, 1.0, true, false));
|
||||||
|
ASSERT_FLOAT_EQ(-3, YGRoundValueToPixelGrid(-3.00001, 1.0, true, false));
|
||||||
|
ASSERT_FLOAT_EQ(-3, YGRoundValueToPixelGrid(-3, 1.0, true, false));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(-4, YGRoundValueToPixelGrid(-3.5, 1.0, false, true));
|
||||||
|
ASSERT_FLOAT_EQ(-4, YGRoundValueToPixelGrid(-3.4, 1.0, false, true));
|
||||||
|
ASSERT_FLOAT_EQ(-4, YGRoundValueToPixelGrid(-3.6, 1.0, false, true));
|
||||||
|
ASSERT_FLOAT_EQ(-4, YGRoundValueToPixelGrid(-3.499999, 1.0, false, true));
|
||||||
|
ASSERT_FLOAT_EQ(-4, YGRoundValueToPixelGrid(-3.500001, 1.0, false, true));
|
||||||
|
ASSERT_FLOAT_EQ(-4, YGRoundValueToPixelGrid(-3.5001, 1.0, false, true));
|
||||||
|
ASSERT_FLOAT_EQ(-3, YGRoundValueToPixelGrid(-3.00001, 1.0, false, true));
|
||||||
|
ASSERT_FLOAT_EQ(-3, YGRoundValueToPixelGrid(-3, 1.0, false, true));
|
||||||
|
|
||||||
|
// NAN is treated as expected:
|
||||||
|
ASSERT_TRUE(std::isnan(YGRoundValueToPixelGrid(
|
||||||
|
std::numeric_limits<double>::quiet_NaN(), 1.5, false, false)));
|
||||||
|
ASSERT_TRUE(std::isnan(YGRoundValueToPixelGrid(
|
||||||
|
1.5, std::numeric_limits<double>::quiet_NaN(), false, false)));
|
||||||
|
ASSERT_TRUE(std::isnan(YGRoundValueToPixelGrid(
|
||||||
|
std::numeric_limits<double>::quiet_NaN(),
|
||||||
|
std::numeric_limits<double>::quiet_NaN(),
|
||||||
|
false,
|
||||||
|
false)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static YGSize measureText(
|
static YGSize measureText(
|
||||||
@@ -121,3 +161,23 @@ TEST(YogaTest, per_node_point_scale_factor) {
|
|||||||
YGConfigFree(config2);
|
YGConfigFree(config2);
|
||||||
YGConfigFree(config3);
|
YGConfigFree(config3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(YogaTest, raw_layout_dimensions) {
|
||||||
|
YGConfigRef config = YGConfigNew();
|
||||||
|
YGConfigSetPointScaleFactor(config, 0.5f);
|
||||||
|
|
||||||
|
YGNodeRef root = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeStyleSetWidth(root, 11.5f);
|
||||||
|
YGNodeStyleSetHeight(root, 9.5f);
|
||||||
|
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
|
|
||||||
|
ASSERT_EQ(YGNodeLayoutGetWidth(root), 12.0f);
|
||||||
|
ASSERT_EQ(YGNodeLayoutGetHeight(root), 10.0f);
|
||||||
|
ASSERT_EQ(YGNodeLayoutGetRawWidth(root), 11.5f);
|
||||||
|
ASSERT_EQ(YGNodeLayoutGetRawHeight(root), 9.5f);
|
||||||
|
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
|
||||||
|
YGConfigFree(config);
|
||||||
|
}
|
||||||
|
@@ -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<<71295a398c89ea424490884a05e2c77c>>
|
* @generated SignedSource<<1db57b05babb408c08efcec7dbdf16fb>>
|
||||||
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGAlignItemsTest.html
|
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGAlignItemsTest.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -2310,3 +2310,84 @@ TEST(YogaTest, align_stretch_with_row_reverse) {
|
|||||||
|
|
||||||
YGConfigFree(config);
|
YGConfigFree(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(YogaTest, align_items_non_stretch_s526008) {
|
||||||
|
YGConfigRef config = YGConfigNew();
|
||||||
|
|
||||||
|
YGNodeRef root = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
|
||||||
|
YGNodeStyleSetWidth(root, 400);
|
||||||
|
YGNodeStyleSetHeight(root, 400);
|
||||||
|
|
||||||
|
YGNodeRef root_child0 = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow);
|
||||||
|
YGNodeInsertChild(root, root_child0, 0);
|
||||||
|
|
||||||
|
YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeStyleSetAlignItems(root_child0_child0, YGAlignFlexStart);
|
||||||
|
YGNodeInsertChild(root_child0, root_child0_child0, 0);
|
||||||
|
|
||||||
|
YGNodeRef root_child0_child0_child0 = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeInsertChild(root_child0_child0, root_child0_child0_child0, 0);
|
||||||
|
|
||||||
|
YGNodeRef root_child0_child0_child0_child0 = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeStyleSetHeight(root_child0_child0_child0_child0, 10);
|
||||||
|
YGNodeInsertChild(root_child0_child0_child0, root_child0_child0_child0_child0, 0);
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0_child0_child0));
|
||||||
|
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(400, YGNodeLayoutGetLeft(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0_child0_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0_child0_child0));
|
||||||
|
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
|
||||||
|
YGConfigFree(config);
|
||||||
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -90,14 +90,20 @@ YGSize IntrinsicSizeMeasure(
|
|||||||
measuredHeight = std::min(
|
measuredHeight = std::min(
|
||||||
calculateHeight(
|
calculateHeight(
|
||||||
innerText,
|
innerText,
|
||||||
std::max(longestWordWidth(innerText, widthPerChar), measuredWidth),
|
YGNodeStyleGetFlexDirection(node) == YGFlexDirectionColumn
|
||||||
|
? measuredWidth
|
||||||
|
: std::max(
|
||||||
|
longestWordWidth(innerText, widthPerChar), measuredWidth),
|
||||||
widthPerChar,
|
widthPerChar,
|
||||||
heightPerChar),
|
heightPerChar),
|
||||||
height);
|
height);
|
||||||
} else {
|
} else {
|
||||||
measuredHeight = calculateHeight(
|
measuredHeight = calculateHeight(
|
||||||
innerText,
|
innerText,
|
||||||
std::max(longestWordWidth(innerText, widthPerChar), measuredWidth),
|
YGNodeStyleGetFlexDirection(node) == YGFlexDirectionColumn
|
||||||
|
? measuredWidth
|
||||||
|
: std::max(
|
||||||
|
longestWordWidth(innerText, widthPerChar), measuredWidth),
|
||||||
widthPerChar,
|
widthPerChar,
|
||||||
heightPerChar);
|
heightPerChar);
|
||||||
}
|
}
|
||||||
|
83
website/blog/2024-12-02-announcing-yoga-3.2.md
Normal file
83
website/blog/2024-12-02-announcing-yoga-3.2.md
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
---
|
||||||
|
slug: announcing-yoga-3.2
|
||||||
|
title: Announcing Yoga 3.2
|
||||||
|
authors:
|
||||||
|
- NickGerleman
|
||||||
|
---
|
||||||
|
|
||||||
|
import Playground from '@site/src/components/Playground';
|
||||||
|
|
||||||
|
Yoga 3.2 is a new minor version of Yoga, used by React Native 0.77.
|
||||||
|
|
||||||
|
## Highlights
|
||||||
|
|
||||||
|
1. Support for `box-sizing`
|
||||||
|
2. Support for `display: contents`
|
||||||
|
3. Bug fixes and improvements
|
||||||
|
|
||||||
|
## `box-sizing`
|
||||||
|
|
||||||
|
Yoga [now supports](https://github.com/facebook/yoga/commit/671ae61a39d02091d1e73fe773d6a09f2f93cda4) [`box-sizing`](https://developer.mozilla.org/en-US/docs/Web/CSS/box-sizing) on styles, allowing sizing values to influence the content box instead of the border box.
|
||||||
|
|
||||||
|
:::warning
|
||||||
|
|
||||||
|
To preserve compatibility, Yoga nodes default to `box-sizing: border-box`, even if `UseWebDefaults` is set. We recommend manually setting node defaults instead of using the `UseWebDefaults` API.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
<Playground code={`<Layout config={{useWebDefaults: true}}>
|
||||||
|
<Node
|
||||||
|
style={{
|
||||||
|
width: 100,
|
||||||
|
height: 100,
|
||||||
|
padding: 50,
|
||||||
|
boxSizing: "border-box",
|
||||||
|
}}>
|
||||||
|
</Node>
|
||||||
|
</Layout>`} />
|
||||||
|
|
||||||
|
<Playground code={`<Layout config={{useWebDefaults: true}}>
|
||||||
|
<Node
|
||||||
|
style={{
|
||||||
|
width: 100,
|
||||||
|
height: 100,
|
||||||
|
padding: 50,
|
||||||
|
boxSizing: "content-box",
|
||||||
|
}}>
|
||||||
|
</Node>
|
||||||
|
</Layout>`} />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## `display: contents`
|
||||||
|
|
||||||
|
Yoga nodes [may now be set to `display: contents`](https://github.com/facebook/yoga/commit/68bb2343d2b470962065789d09016bba8e785340) to remove them from the layout flow, while preserving and hoisting the node's children. This may be used by the higher level UI framework to allow more easily composing wrapper components (such as those which may need to handle events, without influencing child layout). Thanks [@j-piasecki](https://github.com/j-piasecki) for the contribution!
|
||||||
|
|
||||||
|
<Playground code={`<Layout config={{useWebDefaults: false}}>
|
||||||
|
<Node
|
||||||
|
style={{
|
||||||
|
width: 100,
|
||||||
|
height: 100,
|
||||||
|
gap: 10,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Node style={{display: "contents"}}>
|
||||||
|
<Node style={{flexGrow: 1}} />
|
||||||
|
<Node style={{flexGrow: 1}} />
|
||||||
|
<Node style={{flexGrow: 1}} />
|
||||||
|
</Node>
|
||||||
|
</Node>
|
||||||
|
</Layout>`} />
|
||||||
|
|
||||||
|
|
||||||
|
## Removal of legacy absolute positioning
|
||||||
|
|
||||||
|
Yoga 3.0 introduced a new algorithm used for absolute positioning. This algorithm is more correct than the one previously used, but led to observed compatibility issues with existing code, so we left the option to disable it via the `AbsolutePositioningIncorrect` erratum (enabled by default in frameworks like React Native). Yoga 3.2 removes the legacy absolute positioning path, but ports over the main compatibility quirk under a new erratum `AbsolutePositionWithoutInsetsExcludesPadding` (where the previous incorrect behavior would omit padding when a position was not specified on the absolute node). Errata users should see more correct absolute positioning behavior, while preserving compatibility with existing code.
|
||||||
|
|
||||||
|
## Fixed non-global YogaConfig in Java bindings
|
||||||
|
|
||||||
|
Yoga would previously allow garbage collection of a `YogaConfig` if it was not retained outside of the Yoga tree. This could result in confusing errors caused by use-after free. Yoga nodes [now correctly retain the configs they are using](https://github.com/facebook/yoga/commit/22b018c957e930de950338ad87f4ef8d59e8a169). Thanks [@michaeltroger](https://github.com/michaeltroger) for this fix!
|
||||||
|
|
||||||
|
## Fixed behavior when combining `align-items` with `align-content`
|
||||||
|
|
||||||
|
A regression [was fixed](https://github.com/facebook/yoga/commit/77c99870127e9c2d46a07264fa372025334d8fd0) in how Yoga handles some combinations of `align-content` and `align-items`. Thanks [@phuccvx12](https://github.com/phuccvx12) for this fix!
|
@@ -17,15 +17,15 @@ has effect when items are wrapped to multiple lines using [flex wrap](/docs/styl
|
|||||||
|
|
||||||
**Center**: Align wrapped lines in the center of the container's cross axis.
|
**Center**: Align wrapped lines in the center of the container's cross axis.
|
||||||
|
|
||||||
**Space between**: Evenly space wrapped lines across the container's main axis, distributing
|
**Space between**: Evenly space wrapped lines across the container's cross axis, distributing
|
||||||
remaining space between the lines.
|
remaining space between the lines.
|
||||||
|
|
||||||
**Space around**: Evenly space wrapped lines across the container's main axis, distributing
|
**Space around**: Evenly space wrapped lines across the container's cross axis, distributing
|
||||||
remaining space around the lines. Compared to space between using
|
remaining space around the lines. Compared to space between using
|
||||||
space around will result in space being distributed to the beginning of
|
space around will result in space being distributed to the beginning of
|
||||||
the first lines and end of the last line.
|
the first lines and end of the last line.
|
||||||
|
|
||||||
**Space evenly**: Evenly space wrapped lines across the container's main axis, distributing
|
**Space evenly**: Evenly space wrapped lines across the container's cross axis, distributing
|
||||||
remaining space around the lines. Compared to space around, space evenly will not
|
remaining space around the lines. Compared to space around, space evenly will not
|
||||||
double the gaps between children. The size of gaps between children and between
|
double the gaps between children. The size of gaps between children and between
|
||||||
the parent's edges and the first/last child will all be equal.
|
the parent's edges and the first/last child will all be equal.
|
||||||
|
@@ -63,7 +63,7 @@ export type FlexStyle = {
|
|||||||
bottom?: number | `${number}%`;
|
bottom?: number | `${number}%`;
|
||||||
boxSizing?: 'border-box' | 'content-box';
|
boxSizing?: 'border-box' | 'content-box';
|
||||||
direction?: 'ltr' | 'rtl';
|
direction?: 'ltr' | 'rtl';
|
||||||
display?: 'none' | 'flex';
|
display?: 'none' | 'flex' | 'contents';
|
||||||
end?: number | `${number}%`;
|
end?: number | `${number}%`;
|
||||||
flex?: number;
|
flex?: number;
|
||||||
flexBasis?: number | 'auto' | `${number}%`;
|
flexBasis?: number | 'auto' | `${number}%`;
|
||||||
@@ -360,12 +360,14 @@ function direction(str?: 'ltr' | 'rtl'): Direction {
|
|||||||
throw new Error(`"${str}" is not a valid value for direction`);
|
throw new Error(`"${str}" is not a valid value for direction`);
|
||||||
}
|
}
|
||||||
|
|
||||||
function display(str?: 'none' | 'flex'): Display {
|
function display(str?: 'none' | 'flex' | 'contents'): Display {
|
||||||
switch (str) {
|
switch (str) {
|
||||||
case 'none':
|
case 'none':
|
||||||
return Display.None;
|
return Display.None;
|
||||||
case 'flex':
|
case 'flex':
|
||||||
return Display.Flex;
|
return Display.Flex;
|
||||||
|
case 'contents':
|
||||||
|
return Display.Contents;
|
||||||
}
|
}
|
||||||
throw new Error(`"${str}" is not a valid value for display`);
|
throw new Error(`"${str}" is not a valid value for display`);
|
||||||
}
|
}
|
||||||
|
@@ -16,6 +16,7 @@ export type LayoutMetrics = {
|
|||||||
width: number;
|
width: number;
|
||||||
height: number;
|
height: number;
|
||||||
overflow?: 'visible' | 'hidden' | 'scroll';
|
overflow?: 'visible' | 'hidden' | 'scroll';
|
||||||
|
display?: 'flex' | 'none' | 'contents';
|
||||||
children?: LayoutMetrics[];
|
children?: LayoutMetrics[];
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -49,7 +50,11 @@ export default function LayoutBox({metrics, depth, className}: Props) {
|
|||||||
position: depth === 0 ? 'relative' : 'absolute',
|
position: depth === 0 ? 'relative' : 'absolute',
|
||||||
}}>
|
}}>
|
||||||
{children?.map((child, i) => (
|
{children?.map((child, i) => (
|
||||||
<LayoutBox key={i} metrics={child} depth={depth + 1} />
|
<LayoutBox
|
||||||
|
key={i}
|
||||||
|
metrics={child}
|
||||||
|
depth={style.display === 'contents' ? depth : depth + 1}
|
||||||
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@@ -8,7 +8,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {useMemo} from 'react';
|
import {useMemo} from 'react';
|
||||||
import Yoga, {Direction, Overflow, Node as YogaNode} from 'yoga-layout';
|
import Yoga, {
|
||||||
|
Direction,
|
||||||
|
Display,
|
||||||
|
Overflow,
|
||||||
|
Node as YogaNode,
|
||||||
|
} from 'yoga-layout';
|
||||||
import {FlexStyle, applyStyle} from './FlexStyle';
|
import {FlexStyle, applyStyle} from './FlexStyle';
|
||||||
import LayoutBox from './LayoutBox';
|
import LayoutBox from './LayoutBox';
|
||||||
|
|
||||||
@@ -109,6 +114,16 @@ function metricsFromYogaNode(node: YogaNode): LayoutMetrics {
|
|||||||
return 'visible';
|
return 'visible';
|
||||||
}
|
}
|
||||||
})(),
|
})(),
|
||||||
|
display: (() => {
|
||||||
|
switch (node.getDisplay()) {
|
||||||
|
case Display.Flex:
|
||||||
|
return 'flex';
|
||||||
|
case Display.None:
|
||||||
|
return 'none';
|
||||||
|
case Display.Contents:
|
||||||
|
return 'contents';
|
||||||
|
}
|
||||||
|
})(),
|
||||||
children,
|
children,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -245,6 +245,12 @@ const char* YGUnitToString(const YGUnit value) {
|
|||||||
return "percent";
|
return "percent";
|
||||||
case YGUnitAuto:
|
case YGUnitAuto:
|
||||||
return "auto";
|
return "auto";
|
||||||
|
case YGUnitMaxContent:
|
||||||
|
return "max-content";
|
||||||
|
case YGUnitFitContent:
|
||||||
|
return "fit-content";
|
||||||
|
case YGUnitStretch:
|
||||||
|
return "stretch";
|
||||||
}
|
}
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
|
@@ -131,7 +131,10 @@ YG_ENUM_DECL(
|
|||||||
YGUnitUndefined,
|
YGUnitUndefined,
|
||||||
YGUnitPoint,
|
YGUnitPoint,
|
||||||
YGUnitPercent,
|
YGUnitPercent,
|
||||||
YGUnitAuto)
|
YGUnitAuto,
|
||||||
|
YGUnitMaxContent,
|
||||||
|
YGUnitFitContent,
|
||||||
|
YGUnitStretch)
|
||||||
|
|
||||||
YG_ENUM_DECL(
|
YG_ENUM_DECL(
|
||||||
YGWrap,
|
YGWrap,
|
||||||
|
@@ -90,3 +90,11 @@ float YGNodeLayoutGetPadding(YGNodeConstRef node, YGEdge edge) {
|
|||||||
return getResolvedLayoutProperty<&LayoutResults::padding>(
|
return getResolvedLayoutProperty<&LayoutResults::padding>(
|
||||||
node, scopedEnum(edge));
|
node, scopedEnum(edge));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float YGNodeLayoutGetRawHeight(YGNodeConstRef node) {
|
||||||
|
return resolveRef(node)->getLayout().rawDimension(Dimension::Height);
|
||||||
|
}
|
||||||
|
|
||||||
|
float YGNodeLayoutGetRawWidth(YGNodeConstRef node) {
|
||||||
|
return resolveRef(node)->getLayout().rawDimension(Dimension::Width);
|
||||||
|
}
|
||||||
|
@@ -32,4 +32,14 @@ YG_EXPORT float YGNodeLayoutGetMargin(YGNodeConstRef node, YGEdge edge);
|
|||||||
YG_EXPORT float YGNodeLayoutGetBorder(YGNodeConstRef node, YGEdge edge);
|
YG_EXPORT float YGNodeLayoutGetBorder(YGNodeConstRef node, YGEdge edge);
|
||||||
YG_EXPORT float YGNodeLayoutGetPadding(YGNodeConstRef node, YGEdge edge);
|
YG_EXPORT float YGNodeLayoutGetPadding(YGNodeConstRef node, YGEdge edge);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the measured height of the node, before layout rounding
|
||||||
|
*/
|
||||||
|
YG_EXPORT float YGNodeLayoutGetRawHeight(YGNodeConstRef node);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the measured width of the node, before layout rounding
|
||||||
|
*/
|
||||||
|
YG_EXPORT float YGNodeLayoutGetRawWidth(YGNodeConstRef node);
|
||||||
|
|
||||||
YG_EXTERN_C_END
|
YG_EXTERN_C_END
|
||||||
|
@@ -177,19 +177,34 @@ float YGNodeStyleGetFlexShrink(const YGNodeConstRef nodeRef) {
|
|||||||
|
|
||||||
void YGNodeStyleSetFlexBasis(const YGNodeRef node, const float flexBasis) {
|
void YGNodeStyleSetFlexBasis(const YGNodeRef node, const float flexBasis) {
|
||||||
updateStyle<&Style::flexBasis, &Style::setFlexBasis>(
|
updateStyle<&Style::flexBasis, &Style::setFlexBasis>(
|
||||||
node, StyleLength::points(flexBasis));
|
node, StyleSizeLength::points(flexBasis));
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetFlexBasisPercent(
|
void YGNodeStyleSetFlexBasisPercent(
|
||||||
const YGNodeRef node,
|
const YGNodeRef node,
|
||||||
const float flexBasisPercent) {
|
const float flexBasisPercent) {
|
||||||
updateStyle<&Style::flexBasis, &Style::setFlexBasis>(
|
updateStyle<&Style::flexBasis, &Style::setFlexBasis>(
|
||||||
node, StyleLength::percent(flexBasisPercent));
|
node, StyleSizeLength::percent(flexBasisPercent));
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetFlexBasisAuto(const YGNodeRef node) {
|
void YGNodeStyleSetFlexBasisAuto(const YGNodeRef node) {
|
||||||
updateStyle<&Style::flexBasis, &Style::setFlexBasis>(
|
updateStyle<&Style::flexBasis, &Style::setFlexBasis>(
|
||||||
node, StyleLength::ofAuto());
|
node, StyleSizeLength::ofAuto());
|
||||||
|
}
|
||||||
|
|
||||||
|
void YGNodeStyleSetFlexBasisMaxContent(const YGNodeRef node) {
|
||||||
|
updateStyle<&Style::flexBasis, &Style::setFlexBasis>(
|
||||||
|
node, StyleSizeLength::ofMaxContent());
|
||||||
|
}
|
||||||
|
|
||||||
|
void YGNodeStyleSetFlexBasisFitContent(const YGNodeRef node) {
|
||||||
|
updateStyle<&Style::flexBasis, &Style::setFlexBasis>(
|
||||||
|
node, StyleSizeLength::ofFitContent());
|
||||||
|
}
|
||||||
|
|
||||||
|
void YGNodeStyleSetFlexBasisStretch(const YGNodeRef node) {
|
||||||
|
updateStyle<&Style::flexBasis, &Style::setFlexBasis>(
|
||||||
|
node, StyleSizeLength::ofStretch());
|
||||||
}
|
}
|
||||||
|
|
||||||
YGValue YGNodeStyleGetFlexBasis(const YGNodeConstRef node) {
|
YGValue YGNodeStyleGetFlexBasis(const YGNodeConstRef node) {
|
||||||
@@ -278,13 +293,8 @@ void YGNodeStyleSetGapPercent(YGNodeRef node, YGGutter gutter, float percent) {
|
|||||||
node, scopedEnum(gutter), StyleLength::percent(percent));
|
node, scopedEnum(gutter), StyleLength::percent(percent));
|
||||||
}
|
}
|
||||||
|
|
||||||
float YGNodeStyleGetGap(const YGNodeConstRef node, const YGGutter gutter) {
|
YGValue YGNodeStyleGetGap(const YGNodeConstRef node, const YGGutter gutter) {
|
||||||
auto gapLength = resolveRef(node)->style().gap(scopedEnum(gutter));
|
return (YGValue)resolveRef(node)->style().gap(scopedEnum(gutter));
|
||||||
if (gapLength.isUndefined() || gapLength.isAuto()) {
|
|
||||||
return YGUndefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
return static_cast<YGValue>(gapLength).value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetAspectRatio(const YGNodeRef node, const float aspectRatio) {
|
void YGNodeStyleSetAspectRatio(const YGNodeRef node, const float aspectRatio) {
|
||||||
@@ -308,17 +318,32 @@ YGBoxSizing YGNodeStyleGetBoxSizing(const YGNodeConstRef node) {
|
|||||||
|
|
||||||
void YGNodeStyleSetWidth(YGNodeRef node, float points) {
|
void YGNodeStyleSetWidth(YGNodeRef node, float points) {
|
||||||
updateStyle<&Style::dimension, &Style::setDimension>(
|
updateStyle<&Style::dimension, &Style::setDimension>(
|
||||||
node, Dimension::Width, StyleLength::points(points));
|
node, Dimension::Width, StyleSizeLength::points(points));
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetWidthPercent(YGNodeRef node, float percent) {
|
void YGNodeStyleSetWidthPercent(YGNodeRef node, float percent) {
|
||||||
updateStyle<&Style::dimension, &Style::setDimension>(
|
updateStyle<&Style::dimension, &Style::setDimension>(
|
||||||
node, Dimension::Width, StyleLength::percent(percent));
|
node, Dimension::Width, StyleSizeLength::percent(percent));
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetWidthAuto(YGNodeRef node) {
|
void YGNodeStyleSetWidthAuto(YGNodeRef node) {
|
||||||
updateStyle<&Style::dimension, &Style::setDimension>(
|
updateStyle<&Style::dimension, &Style::setDimension>(
|
||||||
node, Dimension::Width, StyleLength::ofAuto());
|
node, Dimension::Width, StyleSizeLength::ofAuto());
|
||||||
|
}
|
||||||
|
|
||||||
|
void YGNodeStyleSetWidthMaxContent(YGNodeRef node) {
|
||||||
|
updateStyle<&Style::dimension, &Style::setDimension>(
|
||||||
|
node, Dimension::Width, StyleSizeLength::ofMaxContent());
|
||||||
|
}
|
||||||
|
|
||||||
|
void YGNodeStyleSetWidthFitContent(YGNodeRef node) {
|
||||||
|
updateStyle<&Style::dimension, &Style::setDimension>(
|
||||||
|
node, Dimension::Width, StyleSizeLength::ofFitContent());
|
||||||
|
}
|
||||||
|
|
||||||
|
void YGNodeStyleSetWidthStretch(YGNodeRef node) {
|
||||||
|
updateStyle<&Style::dimension, &Style::setDimension>(
|
||||||
|
node, Dimension::Width, StyleSizeLength::ofStretch());
|
||||||
}
|
}
|
||||||
|
|
||||||
YGValue YGNodeStyleGetWidth(YGNodeConstRef node) {
|
YGValue YGNodeStyleGetWidth(YGNodeConstRef node) {
|
||||||
@@ -327,17 +352,32 @@ YGValue YGNodeStyleGetWidth(YGNodeConstRef node) {
|
|||||||
|
|
||||||
void YGNodeStyleSetHeight(YGNodeRef node, float points) {
|
void YGNodeStyleSetHeight(YGNodeRef node, float points) {
|
||||||
updateStyle<&Style::dimension, &Style::setDimension>(
|
updateStyle<&Style::dimension, &Style::setDimension>(
|
||||||
node, Dimension::Height, StyleLength::points(points));
|
node, Dimension::Height, StyleSizeLength::points(points));
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetHeightPercent(YGNodeRef node, float percent) {
|
void YGNodeStyleSetHeightPercent(YGNodeRef node, float percent) {
|
||||||
updateStyle<&Style::dimension, &Style::setDimension>(
|
updateStyle<&Style::dimension, &Style::setDimension>(
|
||||||
node, Dimension::Height, StyleLength::percent(percent));
|
node, Dimension::Height, StyleSizeLength::percent(percent));
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetHeightAuto(YGNodeRef node) {
|
void YGNodeStyleSetHeightAuto(YGNodeRef node) {
|
||||||
updateStyle<&Style::dimension, &Style::setDimension>(
|
updateStyle<&Style::dimension, &Style::setDimension>(
|
||||||
node, Dimension::Height, StyleLength::ofAuto());
|
node, Dimension::Height, StyleSizeLength::ofAuto());
|
||||||
|
}
|
||||||
|
|
||||||
|
void YGNodeStyleSetHeightMaxContent(YGNodeRef node) {
|
||||||
|
updateStyle<&Style::dimension, &Style::setDimension>(
|
||||||
|
node, Dimension::Height, StyleSizeLength::ofMaxContent());
|
||||||
|
}
|
||||||
|
|
||||||
|
void YGNodeStyleSetHeightFitContent(YGNodeRef node) {
|
||||||
|
updateStyle<&Style::dimension, &Style::setDimension>(
|
||||||
|
node, Dimension::Height, StyleSizeLength::ofFitContent());
|
||||||
|
}
|
||||||
|
|
||||||
|
void YGNodeStyleSetHeightStretch(YGNodeRef node) {
|
||||||
|
updateStyle<&Style::dimension, &Style::setDimension>(
|
||||||
|
node, Dimension::Height, StyleSizeLength::ofStretch());
|
||||||
}
|
}
|
||||||
|
|
||||||
YGValue YGNodeStyleGetHeight(YGNodeConstRef node) {
|
YGValue YGNodeStyleGetHeight(YGNodeConstRef node) {
|
||||||
@@ -346,12 +386,27 @@ YGValue YGNodeStyleGetHeight(YGNodeConstRef node) {
|
|||||||
|
|
||||||
void YGNodeStyleSetMinWidth(const YGNodeRef node, const float minWidth) {
|
void YGNodeStyleSetMinWidth(const YGNodeRef node, const float minWidth) {
|
||||||
updateStyle<&Style::minDimension, &Style::setMinDimension>(
|
updateStyle<&Style::minDimension, &Style::setMinDimension>(
|
||||||
node, Dimension::Width, StyleLength::points(minWidth));
|
node, Dimension::Width, StyleSizeLength::points(minWidth));
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetMinWidthPercent(const YGNodeRef node, const float minWidth) {
|
void YGNodeStyleSetMinWidthPercent(const YGNodeRef node, const float minWidth) {
|
||||||
updateStyle<&Style::minDimension, &Style::setMinDimension>(
|
updateStyle<&Style::minDimension, &Style::setMinDimension>(
|
||||||
node, Dimension::Width, StyleLength::percent(minWidth));
|
node, Dimension::Width, StyleSizeLength::percent(minWidth));
|
||||||
|
}
|
||||||
|
|
||||||
|
void YGNodeStyleSetMinWidthMaxContent(const YGNodeRef node) {
|
||||||
|
updateStyle<&Style::minDimension, &Style::setMinDimension>(
|
||||||
|
node, Dimension::Width, StyleSizeLength::ofMaxContent());
|
||||||
|
}
|
||||||
|
|
||||||
|
void YGNodeStyleSetMinWidthFitContent(const YGNodeRef node) {
|
||||||
|
updateStyle<&Style::minDimension, &Style::setMinDimension>(
|
||||||
|
node, Dimension::Width, StyleSizeLength::ofFitContent());
|
||||||
|
}
|
||||||
|
|
||||||
|
void YGNodeStyleSetMinWidthStretch(const YGNodeRef node) {
|
||||||
|
updateStyle<&Style::minDimension, &Style::setMinDimension>(
|
||||||
|
node, Dimension::Width, StyleSizeLength::ofStretch());
|
||||||
}
|
}
|
||||||
|
|
||||||
YGValue YGNodeStyleGetMinWidth(const YGNodeConstRef node) {
|
YGValue YGNodeStyleGetMinWidth(const YGNodeConstRef node) {
|
||||||
@@ -360,14 +415,29 @@ YGValue YGNodeStyleGetMinWidth(const YGNodeConstRef node) {
|
|||||||
|
|
||||||
void YGNodeStyleSetMinHeight(const YGNodeRef node, const float minHeight) {
|
void YGNodeStyleSetMinHeight(const YGNodeRef node, const float minHeight) {
|
||||||
updateStyle<&Style::minDimension, &Style::setMinDimension>(
|
updateStyle<&Style::minDimension, &Style::setMinDimension>(
|
||||||
node, Dimension::Height, StyleLength::points(minHeight));
|
node, Dimension::Height, StyleSizeLength::points(minHeight));
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetMinHeightPercent(
|
void YGNodeStyleSetMinHeightPercent(
|
||||||
const YGNodeRef node,
|
const YGNodeRef node,
|
||||||
const float minHeight) {
|
const float minHeight) {
|
||||||
updateStyle<&Style::minDimension, &Style::setMinDimension>(
|
updateStyle<&Style::minDimension, &Style::setMinDimension>(
|
||||||
node, Dimension::Height, StyleLength::percent(minHeight));
|
node, Dimension::Height, StyleSizeLength::percent(minHeight));
|
||||||
|
}
|
||||||
|
|
||||||
|
void YGNodeStyleSetMinHeightMaxContent(const YGNodeRef node) {
|
||||||
|
updateStyle<&Style::minDimension, &Style::setMinDimension>(
|
||||||
|
node, Dimension::Height, StyleSizeLength::ofMaxContent());
|
||||||
|
}
|
||||||
|
|
||||||
|
void YGNodeStyleSetMinHeightFitContent(const YGNodeRef node) {
|
||||||
|
updateStyle<&Style::minDimension, &Style::setMinDimension>(
|
||||||
|
node, Dimension::Height, StyleSizeLength::ofFitContent());
|
||||||
|
}
|
||||||
|
|
||||||
|
void YGNodeStyleSetMinHeightStretch(const YGNodeRef node) {
|
||||||
|
updateStyle<&Style::minDimension, &Style::setMinDimension>(
|
||||||
|
node, Dimension::Height, StyleSizeLength::ofStretch());
|
||||||
}
|
}
|
||||||
|
|
||||||
YGValue YGNodeStyleGetMinHeight(const YGNodeConstRef node) {
|
YGValue YGNodeStyleGetMinHeight(const YGNodeConstRef node) {
|
||||||
@@ -376,12 +446,27 @@ YGValue YGNodeStyleGetMinHeight(const YGNodeConstRef node) {
|
|||||||
|
|
||||||
void YGNodeStyleSetMaxWidth(const YGNodeRef node, const float maxWidth) {
|
void YGNodeStyleSetMaxWidth(const YGNodeRef node, const float maxWidth) {
|
||||||
updateStyle<&Style::maxDimension, &Style::setMaxDimension>(
|
updateStyle<&Style::maxDimension, &Style::setMaxDimension>(
|
||||||
node, Dimension::Width, StyleLength::points(maxWidth));
|
node, Dimension::Width, StyleSizeLength::points(maxWidth));
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetMaxWidthPercent(const YGNodeRef node, const float maxWidth) {
|
void YGNodeStyleSetMaxWidthPercent(const YGNodeRef node, const float maxWidth) {
|
||||||
updateStyle<&Style::maxDimension, &Style::setMaxDimension>(
|
updateStyle<&Style::maxDimension, &Style::setMaxDimension>(
|
||||||
node, Dimension::Width, StyleLength::percent(maxWidth));
|
node, Dimension::Width, StyleSizeLength::percent(maxWidth));
|
||||||
|
}
|
||||||
|
|
||||||
|
void YGNodeStyleSetMaxWidthMaxContent(const YGNodeRef node) {
|
||||||
|
updateStyle<&Style::maxDimension, &Style::setMaxDimension>(
|
||||||
|
node, Dimension::Width, StyleSizeLength::ofMaxContent());
|
||||||
|
}
|
||||||
|
|
||||||
|
void YGNodeStyleSetMaxWidthFitContent(const YGNodeRef node) {
|
||||||
|
updateStyle<&Style::maxDimension, &Style::setMaxDimension>(
|
||||||
|
node, Dimension::Width, StyleSizeLength::ofFitContent());
|
||||||
|
}
|
||||||
|
|
||||||
|
void YGNodeStyleSetMaxWidthStretch(const YGNodeRef node) {
|
||||||
|
updateStyle<&Style::maxDimension, &Style::setMaxDimension>(
|
||||||
|
node, Dimension::Width, StyleSizeLength::ofStretch());
|
||||||
}
|
}
|
||||||
|
|
||||||
YGValue YGNodeStyleGetMaxWidth(const YGNodeConstRef node) {
|
YGValue YGNodeStyleGetMaxWidth(const YGNodeConstRef node) {
|
||||||
@@ -390,14 +475,29 @@ YGValue YGNodeStyleGetMaxWidth(const YGNodeConstRef node) {
|
|||||||
|
|
||||||
void YGNodeStyleSetMaxHeight(const YGNodeRef node, const float maxHeight) {
|
void YGNodeStyleSetMaxHeight(const YGNodeRef node, const float maxHeight) {
|
||||||
updateStyle<&Style::maxDimension, &Style::setMaxDimension>(
|
updateStyle<&Style::maxDimension, &Style::setMaxDimension>(
|
||||||
node, Dimension::Height, StyleLength::points(maxHeight));
|
node, Dimension::Height, StyleSizeLength::points(maxHeight));
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetMaxHeightPercent(
|
void YGNodeStyleSetMaxHeightPercent(
|
||||||
const YGNodeRef node,
|
const YGNodeRef node,
|
||||||
const float maxHeight) {
|
const float maxHeight) {
|
||||||
updateStyle<&Style::maxDimension, &Style::setMaxDimension>(
|
updateStyle<&Style::maxDimension, &Style::setMaxDimension>(
|
||||||
node, Dimension::Height, StyleLength::percent(maxHeight));
|
node, Dimension::Height, StyleSizeLength::percent(maxHeight));
|
||||||
|
}
|
||||||
|
|
||||||
|
void YGNodeStyleSetMaxHeightMaxContent(const YGNodeRef node) {
|
||||||
|
updateStyle<&Style::maxDimension, &Style::setMaxDimension>(
|
||||||
|
node, Dimension::Height, StyleSizeLength::ofMaxContent());
|
||||||
|
}
|
||||||
|
|
||||||
|
void YGNodeStyleSetMaxHeightFitContent(const YGNodeRef node) {
|
||||||
|
updateStyle<&Style::maxDimension, &Style::setMaxDimension>(
|
||||||
|
node, Dimension::Height, StyleSizeLength::ofFitContent());
|
||||||
|
}
|
||||||
|
|
||||||
|
void YGNodeStyleSetMaxHeightStretch(const YGNodeRef node) {
|
||||||
|
updateStyle<&Style::maxDimension, &Style::setMaxDimension>(
|
||||||
|
node, Dimension::Height, StyleSizeLength::ofStretch());
|
||||||
}
|
}
|
||||||
|
|
||||||
YGValue YGNodeStyleGetMaxHeight(const YGNodeConstRef node) {
|
YGValue YGNodeStyleGetMaxHeight(const YGNodeConstRef node) {
|
||||||
|
@@ -64,6 +64,9 @@ YG_EXPORT float YGNodeStyleGetFlexShrink(YGNodeConstRef node);
|
|||||||
YG_EXPORT void YGNodeStyleSetFlexBasis(YGNodeRef node, float flexBasis);
|
YG_EXPORT void YGNodeStyleSetFlexBasis(YGNodeRef node, float flexBasis);
|
||||||
YG_EXPORT void YGNodeStyleSetFlexBasisPercent(YGNodeRef node, float flexBasis);
|
YG_EXPORT void YGNodeStyleSetFlexBasisPercent(YGNodeRef node, float flexBasis);
|
||||||
YG_EXPORT void YGNodeStyleSetFlexBasisAuto(YGNodeRef node);
|
YG_EXPORT void YGNodeStyleSetFlexBasisAuto(YGNodeRef node);
|
||||||
|
YG_EXPORT void YGNodeStyleSetFlexBasisMaxContent(YGNodeRef node);
|
||||||
|
YG_EXPORT void YGNodeStyleSetFlexBasisFitContent(YGNodeRef node);
|
||||||
|
YG_EXPORT void YGNodeStyleSetFlexBasisStretch(YGNodeRef node);
|
||||||
YG_EXPORT YGValue YGNodeStyleGetFlexBasis(YGNodeConstRef node);
|
YG_EXPORT YGValue YGNodeStyleGetFlexBasis(YGNodeConstRef node);
|
||||||
|
|
||||||
YG_EXPORT void
|
YG_EXPORT void
|
||||||
@@ -93,7 +96,7 @@ YG_EXPORT void
|
|||||||
YGNodeStyleSetGap(YGNodeRef node, YGGutter gutter, float gapLength);
|
YGNodeStyleSetGap(YGNodeRef node, YGGutter gutter, float gapLength);
|
||||||
YG_EXPORT void
|
YG_EXPORT void
|
||||||
YGNodeStyleSetGapPercent(YGNodeRef node, YGGutter gutter, float gapLength);
|
YGNodeStyleSetGapPercent(YGNodeRef node, YGGutter gutter, float gapLength);
|
||||||
YG_EXPORT float YGNodeStyleGetGap(YGNodeConstRef node, YGGutter gutter);
|
YG_EXPORT YGValue YGNodeStyleGetGap(YGNodeConstRef node, YGGutter gutter);
|
||||||
|
|
||||||
YG_EXPORT void YGNodeStyleSetBoxSizing(YGNodeRef node, YGBoxSizing boxSizing);
|
YG_EXPORT void YGNodeStyleSetBoxSizing(YGNodeRef node, YGBoxSizing boxSizing);
|
||||||
YG_EXPORT YGBoxSizing YGNodeStyleGetBoxSizing(YGNodeConstRef node);
|
YG_EXPORT YGBoxSizing YGNodeStyleGetBoxSizing(YGNodeConstRef node);
|
||||||
@@ -101,27 +104,45 @@ YG_EXPORT YGBoxSizing YGNodeStyleGetBoxSizing(YGNodeConstRef node);
|
|||||||
YG_EXPORT void YGNodeStyleSetWidth(YGNodeRef node, float width);
|
YG_EXPORT void YGNodeStyleSetWidth(YGNodeRef node, float width);
|
||||||
YG_EXPORT void YGNodeStyleSetWidthPercent(YGNodeRef node, float width);
|
YG_EXPORT void YGNodeStyleSetWidthPercent(YGNodeRef node, float width);
|
||||||
YG_EXPORT void YGNodeStyleSetWidthAuto(YGNodeRef node);
|
YG_EXPORT void YGNodeStyleSetWidthAuto(YGNodeRef node);
|
||||||
|
YG_EXPORT void YGNodeStyleSetWidthMaxContent(YGNodeRef node);
|
||||||
|
YG_EXPORT void YGNodeStyleSetWidthFitContent(YGNodeRef node);
|
||||||
|
YG_EXPORT void YGNodeStyleSetWidthStretch(YGNodeRef node);
|
||||||
YG_EXPORT YGValue YGNodeStyleGetWidth(YGNodeConstRef node);
|
YG_EXPORT YGValue YGNodeStyleGetWidth(YGNodeConstRef node);
|
||||||
|
|
||||||
YG_EXPORT void YGNodeStyleSetHeight(YGNodeRef node, float height);
|
YG_EXPORT void YGNodeStyleSetHeight(YGNodeRef node, float height);
|
||||||
YG_EXPORT void YGNodeStyleSetHeightPercent(YGNodeRef node, float height);
|
YG_EXPORT void YGNodeStyleSetHeightPercent(YGNodeRef node, float height);
|
||||||
YG_EXPORT void YGNodeStyleSetHeightAuto(YGNodeRef node);
|
YG_EXPORT void YGNodeStyleSetHeightAuto(YGNodeRef node);
|
||||||
|
YG_EXPORT void YGNodeStyleSetHeightMaxContent(YGNodeRef node);
|
||||||
|
YG_EXPORT void YGNodeStyleSetHeightFitContent(YGNodeRef node);
|
||||||
|
YG_EXPORT void YGNodeStyleSetHeightStretch(YGNodeRef node);
|
||||||
YG_EXPORT YGValue YGNodeStyleGetHeight(YGNodeConstRef node);
|
YG_EXPORT YGValue YGNodeStyleGetHeight(YGNodeConstRef node);
|
||||||
|
|
||||||
YG_EXPORT void YGNodeStyleSetMinWidth(YGNodeRef node, float minWidth);
|
YG_EXPORT void YGNodeStyleSetMinWidth(YGNodeRef node, float minWidth);
|
||||||
YG_EXPORT void YGNodeStyleSetMinWidthPercent(YGNodeRef node, float minWidth);
|
YG_EXPORT void YGNodeStyleSetMinWidthPercent(YGNodeRef node, float minWidth);
|
||||||
|
YG_EXPORT void YGNodeStyleSetMinWidthMaxContent(YGNodeRef node);
|
||||||
|
YG_EXPORT void YGNodeStyleSetMinWidthFitContent(YGNodeRef node);
|
||||||
|
YG_EXPORT void YGNodeStyleSetMinWidthStretch(YGNodeRef node);
|
||||||
YG_EXPORT YGValue YGNodeStyleGetMinWidth(YGNodeConstRef node);
|
YG_EXPORT YGValue YGNodeStyleGetMinWidth(YGNodeConstRef node);
|
||||||
|
|
||||||
YG_EXPORT void YGNodeStyleSetMinHeight(YGNodeRef node, float minHeight);
|
YG_EXPORT void YGNodeStyleSetMinHeight(YGNodeRef node, float minHeight);
|
||||||
YG_EXPORT void YGNodeStyleSetMinHeightPercent(YGNodeRef node, float minHeight);
|
YG_EXPORT void YGNodeStyleSetMinHeightPercent(YGNodeRef node, float minHeight);
|
||||||
|
YG_EXPORT void YGNodeStyleSetMinHeightMaxContent(YGNodeRef node);
|
||||||
|
YG_EXPORT void YGNodeStyleSetMinHeightFitContent(YGNodeRef node);
|
||||||
|
YG_EXPORT void YGNodeStyleSetMinHeightStretch(YGNodeRef node);
|
||||||
YG_EXPORT YGValue YGNodeStyleGetMinHeight(YGNodeConstRef node);
|
YG_EXPORT YGValue YGNodeStyleGetMinHeight(YGNodeConstRef node);
|
||||||
|
|
||||||
YG_EXPORT void YGNodeStyleSetMaxWidth(YGNodeRef node, float maxWidth);
|
YG_EXPORT void YGNodeStyleSetMaxWidth(YGNodeRef node, float maxWidth);
|
||||||
YG_EXPORT void YGNodeStyleSetMaxWidthPercent(YGNodeRef node, float maxWidth);
|
YG_EXPORT void YGNodeStyleSetMaxWidthPercent(YGNodeRef node, float maxWidth);
|
||||||
|
YG_EXPORT void YGNodeStyleSetMaxWidthMaxContent(YGNodeRef node);
|
||||||
|
YG_EXPORT void YGNodeStyleSetMaxWidthFitContent(YGNodeRef node);
|
||||||
|
YG_EXPORT void YGNodeStyleSetMaxWidthStretch(YGNodeRef node);
|
||||||
YG_EXPORT YGValue YGNodeStyleGetMaxWidth(YGNodeConstRef node);
|
YG_EXPORT YGValue YGNodeStyleGetMaxWidth(YGNodeConstRef node);
|
||||||
|
|
||||||
YG_EXPORT void YGNodeStyleSetMaxHeight(YGNodeRef node, float maxHeight);
|
YG_EXPORT void YGNodeStyleSetMaxHeight(YGNodeRef node, float maxHeight);
|
||||||
YG_EXPORT void YGNodeStyleSetMaxHeightPercent(YGNodeRef node, float maxHeight);
|
YG_EXPORT void YGNodeStyleSetMaxHeightPercent(YGNodeRef node, float maxHeight);
|
||||||
|
YG_EXPORT void YGNodeStyleSetMaxHeightMaxContent(YGNodeRef node);
|
||||||
|
YG_EXPORT void YGNodeStyleSetMaxHeightFitContent(YGNodeRef node);
|
||||||
|
YG_EXPORT void YGNodeStyleSetMaxHeightStretch(YGNodeRef node);
|
||||||
YG_EXPORT YGValue YGNodeStyleGetMaxHeight(YGNodeConstRef node);
|
YG_EXPORT YGValue YGNodeStyleGetMaxHeight(YGNodeConstRef node);
|
||||||
|
|
||||||
YG_EXPORT void YGNodeStyleSetAspectRatio(YGNodeRef node, float aspectRatio);
|
YG_EXPORT void YGNodeStyleSetAspectRatio(YGNodeRef node, float aspectRatio);
|
||||||
|
@@ -65,13 +65,16 @@ inline bool operator==(const YGValue& lhs, const YGValue& rhs) {
|
|||||||
switch (lhs.unit) {
|
switch (lhs.unit) {
|
||||||
case YGUnitUndefined:
|
case YGUnitUndefined:
|
||||||
case YGUnitAuto:
|
case YGUnitAuto:
|
||||||
|
case YGUnitFitContent:
|
||||||
|
case YGUnitMaxContent:
|
||||||
|
case YGUnitStretch:
|
||||||
return true;
|
return true;
|
||||||
case YGUnitPoint:
|
case YGUnitPoint:
|
||||||
case YGUnitPercent:
|
case YGUnitPercent:
|
||||||
return lhs.value == rhs.value;
|
return lhs.value == rhs.value;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool operator!=(const YGValue& lhs, const YGValue& rhs) {
|
inline bool operator!=(const YGValue& lhs, const YGValue& rhs) {
|
||||||
|
16
yoga/Yoga.h
16
yoga/Yoga.h
@@ -11,11 +11,11 @@
|
|||||||
* `#include <yoga/Yoga.h>` includes all of Yoga's public headers.
|
* `#include <yoga/Yoga.h>` includes all of Yoga's public headers.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <yoga/YGConfig.h>
|
#include <yoga/YGConfig.h> // IWYU pragma: export
|
||||||
#include <yoga/YGEnums.h>
|
#include <yoga/YGEnums.h> // IWYU pragma: export
|
||||||
#include <yoga/YGMacros.h>
|
#include <yoga/YGMacros.h> // IWYU pragma: export
|
||||||
#include <yoga/YGNode.h>
|
#include <yoga/YGNode.h> // IWYU pragma: export
|
||||||
#include <yoga/YGNodeLayout.h>
|
#include <yoga/YGNodeLayout.h> // IWYU pragma: export
|
||||||
#include <yoga/YGNodeStyle.h>
|
#include <yoga/YGNodeStyle.h> // IWYU pragma: export
|
||||||
#include <yoga/YGPixelGrid.h>
|
#include <yoga/YGPixelGrid.h> // IWYU pragma: export
|
||||||
#include <yoga/YGValue.h>
|
#include <yoga/YGValue.h> // IWYU pragma: export
|
||||||
|
@@ -415,6 +415,12 @@ static void measureNodeWithoutChildren(
|
|||||||
Dimension::Height);
|
Dimension::Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool isFixedSize(float dim, SizingMode sizingMode) {
|
||||||
|
return sizingMode == SizingMode::StretchFit ||
|
||||||
|
(yoga::isDefined(dim) && sizingMode == SizingMode::FitContent &&
|
||||||
|
dim <= 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
static bool measureNodeWithFixedSize(
|
static bool measureNodeWithFixedSize(
|
||||||
yoga::Node* const node,
|
yoga::Node* const node,
|
||||||
const Direction direction,
|
const Direction direction,
|
||||||
@@ -424,12 +430,8 @@ static bool measureNodeWithFixedSize(
|
|||||||
const SizingMode heightSizingMode,
|
const SizingMode heightSizingMode,
|
||||||
const float ownerWidth,
|
const float ownerWidth,
|
||||||
const float ownerHeight) {
|
const float ownerHeight) {
|
||||||
if ((yoga::isDefined(availableWidth) &&
|
if (isFixedSize(availableWidth, widthSizingMode) &&
|
||||||
widthSizingMode == SizingMode::FitContent && availableWidth <= 0.0f) ||
|
isFixedSize(availableHeight, heightSizingMode)) {
|
||||||
(yoga::isDefined(availableHeight) &&
|
|
||||||
heightSizingMode == SizingMode::FitContent && availableHeight <= 0.0f) ||
|
|
||||||
(widthSizingMode == SizingMode::StretchFit &&
|
|
||||||
heightSizingMode == SizingMode::StretchFit)) {
|
|
||||||
node->setLayoutMeasuredDimension(
|
node->setLayoutMeasuredDimension(
|
||||||
boundAxis(
|
boundAxis(
|
||||||
node,
|
node,
|
||||||
@@ -476,16 +478,19 @@ static void zeroOutLayoutRecursively(yoga::Node* const node) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void cleanupContentsNodesRecursively(yoga::Node* const node) {
|
static void cleanupContentsNodesRecursively(yoga::Node* const node) {
|
||||||
for (auto child : node->getChildren()) {
|
if (node->hasContentsChildren()) [[unlikely]] {
|
||||||
if (child->style().display() == Display::Contents) {
|
node->cloneContentsChildrenIfNeeded();
|
||||||
child->getLayout() = {};
|
for (auto child : node->getChildren()) {
|
||||||
child->setLayoutDimension(0, Dimension::Width);
|
if (child->style().display() == Display::Contents) {
|
||||||
child->setLayoutDimension(0, Dimension::Height);
|
child->getLayout() = {};
|
||||||
child->setHasNewLayout(true);
|
child->setLayoutDimension(0, Dimension::Width);
|
||||||
child->setDirty(false);
|
child->setLayoutDimension(0, Dimension::Height);
|
||||||
child->cloneChildrenIfNeeded();
|
child->setHasNewLayout(true);
|
||||||
|
child->setDirty(false);
|
||||||
|
child->cloneChildrenIfNeeded();
|
||||||
|
|
||||||
cleanupContentsNodesRecursively(child);
|
cleanupContentsNodesRecursively(child);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -741,7 +746,7 @@ static float distributeFreeSpaceSecondPass(
|
|||||||
marginCross;
|
marginCross;
|
||||||
const bool isLoosePercentageMeasurement =
|
const bool isLoosePercentageMeasurement =
|
||||||
currentLineChild->getProcessedDimension(dimension(crossAxis))
|
currentLineChild->getProcessedDimension(dimension(crossAxis))
|
||||||
.unit() == Unit::Percent &&
|
.isPercent() &&
|
||||||
sizingModeCrossDim != SizingMode::StretchFit;
|
sizingModeCrossDim != SizingMode::StretchFit;
|
||||||
childCrossSizingMode =
|
childCrossSizingMode =
|
||||||
yoga::isUndefined(childCrossSize) || isLoosePercentageMeasurement
|
yoga::isUndefined(childCrossSize) || isLoosePercentageMeasurement
|
||||||
@@ -1213,10 +1218,10 @@ static void calculateLayoutImpl(
|
|||||||
const float ownerWidth,
|
const float ownerWidth,
|
||||||
const float ownerHeight,
|
const float ownerHeight,
|
||||||
const bool performLayout,
|
const bool performLayout,
|
||||||
|
const LayoutPassReason reason,
|
||||||
LayoutData& layoutMarkerData,
|
LayoutData& layoutMarkerData,
|
||||||
const uint32_t depth,
|
const uint32_t depth,
|
||||||
const uint32_t generationCount,
|
const uint32_t generationCount) {
|
||||||
const LayoutPassReason reason) {
|
|
||||||
yoga::assertFatalWithNode(
|
yoga::assertFatalWithNode(
|
||||||
node,
|
node,
|
||||||
yoga::isUndefined(availableWidth)
|
yoga::isUndefined(availableWidth)
|
||||||
@@ -1780,7 +1785,7 @@ static void calculateLayoutImpl(
|
|||||||
crossAxis,
|
crossAxis,
|
||||||
direction,
|
direction,
|
||||||
unclampedCrossDim,
|
unclampedCrossDim,
|
||||||
ownerHeight,
|
crossAxisOwnerSize,
|
||||||
ownerWidth) -
|
ownerWidth) -
|
||||||
paddingAndBorderAxisCross;
|
paddingAndBorderAxisCross;
|
||||||
|
|
||||||
@@ -2268,10 +2273,10 @@ bool calculateLayoutInternal(
|
|||||||
ownerWidth,
|
ownerWidth,
|
||||||
ownerHeight,
|
ownerHeight,
|
||||||
performLayout,
|
performLayout,
|
||||||
|
reason,
|
||||||
layoutMarkerData,
|
layoutMarkerData,
|
||||||
depth,
|
depth,
|
||||||
generationCount,
|
generationCount);
|
||||||
reason);
|
|
||||||
|
|
||||||
layout->lastOwnerDirection = ownerDirection;
|
layout->lastOwnerDirection = ownerDirection;
|
||||||
layout->configVersion = node->getConfig()->getVersion();
|
layout->configVersion = node->getConfig()->getVersion();
|
||||||
|
@@ -17,7 +17,7 @@ FlexLine calculateFlexLine(
|
|||||||
yoga::Node* const node,
|
yoga::Node* const node,
|
||||||
const Direction ownerDirection,
|
const Direction ownerDirection,
|
||||||
const float ownerWidth,
|
const float ownerWidth,
|
||||||
const float mainAxisownerSize,
|
const float mainAxisOwnerSize,
|
||||||
const float availableInnerWidth,
|
const float availableInnerWidth,
|
||||||
const float availableInnerMainDim,
|
const float availableInnerMainDim,
|
||||||
Node::LayoutableChildren::Iterator& iterator,
|
Node::LayoutableChildren::Iterator& iterator,
|
||||||
@@ -70,7 +70,7 @@ FlexLine calculateFlexLine(
|
|||||||
direction,
|
direction,
|
||||||
mainAxis,
|
mainAxis,
|
||||||
child->getLayout().computedFlexBasis,
|
child->getLayout().computedFlexBasis,
|
||||||
mainAxisownerSize,
|
mainAxisOwnerSize,
|
||||||
ownerWidth)
|
ownerWidth)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
@@ -66,7 +66,7 @@ FlexLine calculateFlexLine(
|
|||||||
yoga::Node* node,
|
yoga::Node* node,
|
||||||
Direction ownerDirection,
|
Direction ownerDirection,
|
||||||
float ownerWidth,
|
float ownerWidth,
|
||||||
float mainAxisownerSize,
|
float mainAxisOwnerSize,
|
||||||
float availableInnerWidth,
|
float availableInnerWidth,
|
||||||
float availableInnerMainDim,
|
float availableInnerMainDim,
|
||||||
Node::LayoutableChildren::Iterator& iterator,
|
Node::LayoutableChildren::Iterator& iterator,
|
||||||
|
@@ -66,7 +66,8 @@ void roundLayoutResultsToPixelGrid(
|
|||||||
yoga::Node* const node,
|
yoga::Node* const node,
|
||||||
const double absoluteLeft,
|
const double absoluteLeft,
|
||||||
const double absoluteTop) {
|
const double absoluteTop) {
|
||||||
const auto pointScaleFactor = node->getConfig()->getPointScaleFactor();
|
const auto pointScaleFactor =
|
||||||
|
static_cast<double>(node->getConfig()->getPointScaleFactor());
|
||||||
|
|
||||||
const double nodeLeft = node->getLayout().position(PhysicalEdge::Left);
|
const double nodeLeft = node->getLayout().position(PhysicalEdge::Left);
|
||||||
const double nodeTop = node->getLayout().position(PhysicalEdge::Top);
|
const double nodeTop = node->getLayout().position(PhysicalEdge::Top);
|
||||||
@@ -80,7 +81,7 @@ void roundLayoutResultsToPixelGrid(
|
|||||||
const double absoluteNodeRight = absoluteNodeLeft + nodeWidth;
|
const double absoluteNodeRight = absoluteNodeLeft + nodeWidth;
|
||||||
const double absoluteNodeBottom = absoluteNodeTop + nodeHeight;
|
const double absoluteNodeBottom = absoluteNodeTop + nodeHeight;
|
||||||
|
|
||||||
if (pointScaleFactor != 0.0f) {
|
if (pointScaleFactor != 0.0) {
|
||||||
// If a node has a custom measure function we never want to round down its
|
// If a node has a custom measure function we never want to round down its
|
||||||
// size as this could lead to unwanted text truncation.
|
// size as this could lead to unwanted text truncation.
|
||||||
const bool textRounding = node->getNodeType() == NodeType::Text;
|
const bool textRounding = node->getNodeType() == NodeType::Text;
|
||||||
@@ -96,32 +97,34 @@ void roundLayoutResultsToPixelGrid(
|
|||||||
// We multiply dimension by scale factor and if the result is close to the
|
// We multiply dimension by scale factor and if the result is close to the
|
||||||
// whole number, we don't have any fraction To verify if the result is close
|
// whole number, we don't have any fraction To verify if the result is close
|
||||||
// to whole number we want to check both floor and ceil numbers
|
// to whole number we want to check both floor and ceil numbers
|
||||||
const bool hasFractionalWidth =
|
|
||||||
!yoga::inexactEquals(fmod(nodeWidth * pointScaleFactor, 1.0), 0) &&
|
|
||||||
!yoga::inexactEquals(fmod(nodeWidth * pointScaleFactor, 1.0), 1.0);
|
|
||||||
const bool hasFractionalHeight =
|
|
||||||
!yoga::inexactEquals(fmod(nodeHeight * pointScaleFactor, 1.0), 0) &&
|
|
||||||
!yoga::inexactEquals(fmod(nodeHeight * pointScaleFactor, 1.0), 1.0);
|
|
||||||
|
|
||||||
node->setLayoutDimension(
|
const double scaledNodeWith = nodeWidth * pointScaleFactor;
|
||||||
|
const bool hasFractionalWidth =
|
||||||
|
!yoga::inexactEquals(round(scaledNodeWith), scaledNodeWith);
|
||||||
|
|
||||||
|
const double scaledNodeHeight = nodeHeight * pointScaleFactor;
|
||||||
|
const bool hasFractionalHeight =
|
||||||
|
!yoga::inexactEquals(round(scaledNodeHeight), scaledNodeHeight);
|
||||||
|
|
||||||
|
node->getLayout().setDimension(
|
||||||
|
Dimension::Width,
|
||||||
roundValueToPixelGrid(
|
roundValueToPixelGrid(
|
||||||
absoluteNodeRight,
|
absoluteNodeRight,
|
||||||
pointScaleFactor,
|
pointScaleFactor,
|
||||||
(textRounding && hasFractionalWidth),
|
(textRounding && hasFractionalWidth),
|
||||||
(textRounding && !hasFractionalWidth)) -
|
(textRounding && !hasFractionalWidth)) -
|
||||||
roundValueToPixelGrid(
|
roundValueToPixelGrid(
|
||||||
absoluteNodeLeft, pointScaleFactor, false, textRounding),
|
absoluteNodeLeft, pointScaleFactor, false, textRounding));
|
||||||
Dimension::Width);
|
|
||||||
|
|
||||||
node->setLayoutDimension(
|
node->getLayout().setDimension(
|
||||||
|
Dimension::Height,
|
||||||
roundValueToPixelGrid(
|
roundValueToPixelGrid(
|
||||||
absoluteNodeBottom,
|
absoluteNodeBottom,
|
||||||
pointScaleFactor,
|
pointScaleFactor,
|
||||||
(textRounding && hasFractionalHeight),
|
(textRounding && hasFractionalHeight),
|
||||||
(textRounding && !hasFractionalHeight)) -
|
(textRounding && !hasFractionalHeight)) -
|
||||||
roundValueToPixelGrid(
|
roundValueToPixelGrid(
|
||||||
absoluteNodeTop, pointScaleFactor, false, textRounding),
|
absoluteNodeTop, pointScaleFactor, false, textRounding));
|
||||||
Dimension::Height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (yoga::Node* child : node->getChildren()) {
|
for (yoga::Node* child : node->getChildren()) {
|
||||||
|
@@ -19,6 +19,7 @@ namespace facebook::yoga {
|
|||||||
#if defined(__cpp_exceptions)
|
#if defined(__cpp_exceptions)
|
||||||
throw std::logic_error(message);
|
throw std::logic_error(message);
|
||||||
#else
|
#else
|
||||||
|
static_cast<void>(message); // Unused
|
||||||
std::terminate();
|
std::terminate();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@@ -20,11 +20,14 @@ enum class Unit : uint8_t {
|
|||||||
Point = YGUnitPoint,
|
Point = YGUnitPoint,
|
||||||
Percent = YGUnitPercent,
|
Percent = YGUnitPercent,
|
||||||
Auto = YGUnitAuto,
|
Auto = YGUnitAuto,
|
||||||
|
MaxContent = YGUnitMaxContent,
|
||||||
|
FitContent = YGUnitFitContent,
|
||||||
|
Stretch = YGUnitStretch,
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
constexpr int32_t ordinalCount<Unit>() {
|
constexpr int32_t ordinalCount<Unit>() {
|
||||||
return 4;
|
return 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr Unit scopedEnum(YGUnit unscoped) {
|
constexpr Unit scopedEnum(YGUnit unscoped) {
|
||||||
|
@@ -36,12 +36,12 @@ enum struct LayoutPassReason : int {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct LayoutData {
|
struct LayoutData {
|
||||||
int layouts;
|
int layouts = 0;
|
||||||
int measures;
|
int measures = 0;
|
||||||
uint32_t maxMeasureCache;
|
uint32_t maxMeasureCache = 0;
|
||||||
int cachedLayouts;
|
int cachedLayouts = 0;
|
||||||
int cachedMeasures;
|
int cachedMeasures = 0;
|
||||||
int measureCallbacks;
|
int measureCallbacks = 0;
|
||||||
std::array<int, static_cast<uint8_t>(LayoutPassReason::COUNT)>
|
std::array<int, static_cast<uint8_t>(LayoutPassReason::COUNT)>
|
||||||
measureCallbackReasonsCount;
|
measureCallbackReasonsCount;
|
||||||
};
|
};
|
||||||
|
@@ -66,10 +66,18 @@ struct LayoutResults {
|
|||||||
return measuredDimensions_[yoga::to_underlying(axis)];
|
return measuredDimensions_[yoga::to_underlying(axis)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float rawDimension(Dimension axis) const {
|
||||||
|
return rawDimensions_[yoga::to_underlying(axis)];
|
||||||
|
}
|
||||||
|
|
||||||
void setMeasuredDimension(Dimension axis, float dimension) {
|
void setMeasuredDimension(Dimension axis, float dimension) {
|
||||||
measuredDimensions_[yoga::to_underlying(axis)] = dimension;
|
measuredDimensions_[yoga::to_underlying(axis)] = dimension;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setRawDimension(Dimension axis, float dimension) {
|
||||||
|
rawDimensions_[yoga::to_underlying(axis)] = dimension;
|
||||||
|
}
|
||||||
|
|
||||||
float position(PhysicalEdge physicalEdge) const {
|
float position(PhysicalEdge physicalEdge) const {
|
||||||
return position_[yoga::to_underlying(physicalEdge)];
|
return position_[yoga::to_underlying(physicalEdge)];
|
||||||
}
|
}
|
||||||
@@ -113,6 +121,7 @@ struct LayoutResults {
|
|||||||
|
|
||||||
std::array<float, 2> dimensions_ = {{YGUndefined, YGUndefined}};
|
std::array<float, 2> dimensions_ = {{YGUndefined, YGUndefined}};
|
||||||
std::array<float, 2> measuredDimensions_ = {{YGUndefined, YGUndefined}};
|
std::array<float, 2> measuredDimensions_ = {{YGUndefined, YGUndefined}};
|
||||||
|
std::array<float, 2> rawDimensions_ = {{YGUndefined, YGUndefined}};
|
||||||
std::array<float, 4> position_ = {};
|
std::array<float, 4> position_ = {};
|
||||||
std::array<float, 4> margin_ = {};
|
std::array<float, 4> margin_ = {};
|
||||||
std::array<float, 4> border_ = {};
|
std::array<float, 4> border_ = {};
|
||||||
|
@@ -181,6 +181,17 @@ void Node::setDirty(bool isDirty) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Node::setChildren(const std::vector<Node*>& children) {
|
||||||
|
children_ = children;
|
||||||
|
|
||||||
|
contentsChildrenCount_ = 0;
|
||||||
|
for (const auto& child : children) {
|
||||||
|
if (child->style().display() == Display::Contents) {
|
||||||
|
contentsChildrenCount_++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool Node::removeChild(Node* child) {
|
bool Node::removeChild(Node* child) {
|
||||||
auto p = std::find(children_.begin(), children_.end(), child);
|
auto p = std::find(children_.begin(), children_.end(), child);
|
||||||
if (p != children_.end()) {
|
if (p != children_.end()) {
|
||||||
@@ -245,8 +256,9 @@ void Node::setLayoutHadOverflow(bool hadOverflow) {
|
|||||||
layout_.setHadOverflow(hadOverflow);
|
layout_.setHadOverflow(hadOverflow);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Node::setLayoutDimension(float LengthValue, Dimension dimension) {
|
void Node::setLayoutDimension(float lengthValue, Dimension dimension) {
|
||||||
layout_.setDimension(dimension, LengthValue);
|
layout_.setDimension(dimension, lengthValue);
|
||||||
|
layout_.setRawDimension(dimension, lengthValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If both left and right are defined, then use left. Otherwise return +left or
|
// If both left and right are defined, then use left. Otherwise return +left or
|
||||||
@@ -314,16 +326,16 @@ void Node::setPosition(
|
|||||||
crossAxisTrailingEdge);
|
crossAxisTrailingEdge);
|
||||||
}
|
}
|
||||||
|
|
||||||
Style::Length Node::processFlexBasis() const {
|
Style::SizeLength Node::processFlexBasis() const {
|
||||||
Style::Length flexBasis = style_.flexBasis();
|
Style::SizeLength flexBasis = style_.flexBasis();
|
||||||
if (flexBasis.unit() != Unit::Auto && flexBasis.unit() != Unit::Undefined) {
|
if (!flexBasis.isAuto() && !flexBasis.isUndefined()) {
|
||||||
return flexBasis;
|
return flexBasis;
|
||||||
}
|
}
|
||||||
if (style_.flex().isDefined() && style_.flex().unwrap() > 0.0f) {
|
if (style_.flex().isDefined() && style_.flex().unwrap() > 0.0f) {
|
||||||
return config_->useWebDefaults() ? StyleLength::ofAuto()
|
return config_->useWebDefaults() ? StyleSizeLength::ofAuto()
|
||||||
: StyleLength::points(0);
|
: StyleSizeLength::points(0);
|
||||||
}
|
}
|
||||||
return StyleLength::ofAuto();
|
return StyleSizeLength::ofAuto();
|
||||||
}
|
}
|
||||||
|
|
||||||
FloatOptional Node::resolveFlexBasis(
|
FloatOptional Node::resolveFlexBasis(
|
||||||
@@ -379,6 +391,23 @@ void Node::cloneChildrenIfNeeded() {
|
|||||||
if (child->getOwner() != this) {
|
if (child->getOwner() != this) {
|
||||||
child = resolveRef(config_->cloneNode(child, this, i));
|
child = resolveRef(config_->cloneNode(child, this, i));
|
||||||
child->setOwner(this);
|
child->setOwner(this);
|
||||||
|
|
||||||
|
if (child->hasContentsChildren()) [[unlikely]] {
|
||||||
|
child->cloneContentsChildrenIfNeeded();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
i += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Node::cloneContentsChildrenIfNeeded() {
|
||||||
|
size_t i = 0;
|
||||||
|
for (Node*& child : children_) {
|
||||||
|
if (child->style().display() == Display::Contents &&
|
||||||
|
child->getOwner() != this) {
|
||||||
|
child = resolveRef(config_->cloneNode(child, this, i));
|
||||||
|
child->setOwner(this);
|
||||||
|
child->cloneChildrenIfNeeded();
|
||||||
}
|
}
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
|
@@ -96,6 +96,10 @@ class YG_EXPORT Node : public ::YGNode {
|
|||||||
return config_->hasErrata(errata);
|
return config_->hasErrata(errata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool hasContentsChildren() const {
|
||||||
|
return contentsChildrenCount_ != 0;
|
||||||
|
}
|
||||||
|
|
||||||
YGDirtiedFunc getDirtiedFunc() const {
|
YGDirtiedFunc getDirtiedFunc() const {
|
||||||
return dirtiedFunc_;
|
return dirtiedFunc_;
|
||||||
}
|
}
|
||||||
@@ -172,7 +176,7 @@ class YG_EXPORT Node : public ::YGNode {
|
|||||||
return isDirty_;
|
return isDirty_;
|
||||||
}
|
}
|
||||||
|
|
||||||
Style::Length getProcessedDimension(Dimension dimension) const {
|
Style::SizeLength getProcessedDimension(Dimension dimension) const {
|
||||||
return processedDimensions_[static_cast<size_t>(dimension)];
|
return processedDimensions_[static_cast<size_t>(dimension)];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,22 +248,19 @@ class YG_EXPORT Node : public ::YGNode {
|
|||||||
owner_ = owner;
|
owner_ = owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setChildren(const std::vector<Node*>& children) {
|
|
||||||
children_ = children;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: rvalue override for setChildren
|
// TODO: rvalue override for setChildren
|
||||||
|
|
||||||
void setConfig(Config* config);
|
void setConfig(Config* config);
|
||||||
|
|
||||||
void setDirty(bool isDirty);
|
void setDirty(bool isDirty);
|
||||||
|
void setChildren(const std::vector<Node*>& children);
|
||||||
void setLayoutLastOwnerDirection(Direction direction);
|
void setLayoutLastOwnerDirection(Direction direction);
|
||||||
void setLayoutComputedFlexBasis(FloatOptional computedFlexBasis);
|
void setLayoutComputedFlexBasis(FloatOptional computedFlexBasis);
|
||||||
void setLayoutComputedFlexBasisGeneration(
|
void setLayoutComputedFlexBasisGeneration(
|
||||||
uint32_t computedFlexBasisGeneration);
|
uint32_t computedFlexBasisGeneration);
|
||||||
void setLayoutMeasuredDimension(float measuredDimension, Dimension dimension);
|
void setLayoutMeasuredDimension(float measuredDimension, Dimension dimension);
|
||||||
void setLayoutHadOverflow(bool hadOverflow);
|
void setLayoutHadOverflow(bool hadOverflow);
|
||||||
void setLayoutDimension(float LengthValue, Dimension dimension);
|
void setLayoutDimension(float lengthValue, Dimension dimension);
|
||||||
void setLayoutDirection(Direction direction);
|
void setLayoutDirection(Direction direction);
|
||||||
void setLayoutMargin(float margin, PhysicalEdge edge);
|
void setLayoutMargin(float margin, PhysicalEdge edge);
|
||||||
void setLayoutBorder(float border, PhysicalEdge edge);
|
void setLayoutBorder(float border, PhysicalEdge edge);
|
||||||
@@ -268,7 +269,7 @@ class YG_EXPORT Node : public ::YGNode {
|
|||||||
void setPosition(Direction direction, float ownerWidth, float ownerHeight);
|
void setPosition(Direction direction, float ownerWidth, float ownerHeight);
|
||||||
|
|
||||||
// Other methods
|
// Other methods
|
||||||
Style::Length processFlexBasis() const;
|
Style::SizeLength processFlexBasis() const;
|
||||||
FloatOptional resolveFlexBasis(
|
FloatOptional resolveFlexBasis(
|
||||||
Direction direction,
|
Direction direction,
|
||||||
FlexDirection flexDirection,
|
FlexDirection flexDirection,
|
||||||
@@ -286,6 +287,7 @@ class YG_EXPORT Node : public ::YGNode {
|
|||||||
void removeChild(size_t index);
|
void removeChild(size_t index);
|
||||||
|
|
||||||
void cloneChildrenIfNeeded();
|
void cloneChildrenIfNeeded();
|
||||||
|
void cloneContentsChildrenIfNeeded();
|
||||||
void markDirtyAndPropagate();
|
void markDirtyAndPropagate();
|
||||||
float resolveFlexGrow() const;
|
float resolveFlexGrow() const;
|
||||||
float resolveFlexShrink() const;
|
float resolveFlexShrink() const;
|
||||||
@@ -322,8 +324,8 @@ class YG_EXPORT Node : public ::YGNode {
|
|||||||
Node* owner_ = nullptr;
|
Node* owner_ = nullptr;
|
||||||
std::vector<Node*> children_;
|
std::vector<Node*> children_;
|
||||||
const Config* config_;
|
const Config* config_;
|
||||||
std::array<Style::Length, 2> processedDimensions_{
|
std::array<Style::SizeLength, 2> processedDimensions_{
|
||||||
{StyleLength::undefined(), StyleLength::undefined()}};
|
{StyleSizeLength::undefined(), StyleSizeLength::undefined()}};
|
||||||
};
|
};
|
||||||
|
|
||||||
inline Node* resolveRef(const YGNodeRef ref) {
|
inline Node* resolveRef(const YGNodeRef ref) {
|
||||||
|
@@ -30,6 +30,7 @@
|
|||||||
#include <yoga/enums/Wrap.h>
|
#include <yoga/enums/Wrap.h>
|
||||||
#include <yoga/numeric/FloatOptional.h>
|
#include <yoga/numeric/FloatOptional.h>
|
||||||
#include <yoga/style/StyleLength.h>
|
#include <yoga/style/StyleLength.h>
|
||||||
|
#include <yoga/style/StyleSizeLength.h>
|
||||||
#include <yoga/style/StyleValuePool.h>
|
#include <yoga/style/StyleValuePool.h>
|
||||||
|
|
||||||
namespace facebook::yoga {
|
namespace facebook::yoga {
|
||||||
@@ -37,6 +38,7 @@ namespace facebook::yoga {
|
|||||||
class YG_EXPORT Style {
|
class YG_EXPORT Style {
|
||||||
public:
|
public:
|
||||||
using Length = StyleLength;
|
using Length = StyleLength;
|
||||||
|
using SizeLength = StyleSizeLength;
|
||||||
|
|
||||||
static constexpr float DefaultFlexGrow = 0.0f;
|
static constexpr float DefaultFlexGrow = 0.0f;
|
||||||
static constexpr float DefaultFlexShrink = 0.0f;
|
static constexpr float DefaultFlexShrink = 0.0f;
|
||||||
@@ -133,10 +135,10 @@ class YG_EXPORT Style {
|
|||||||
pool_.store(flexShrink_, value);
|
pool_.store(flexShrink_, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
Style::Length flexBasis() const {
|
Style::SizeLength flexBasis() const {
|
||||||
return pool_.getLength(flexBasis_);
|
return pool_.getSize(flexBasis_);
|
||||||
}
|
}
|
||||||
void setFlexBasis(Style::Length value) {
|
void setFlexBasis(Style::SizeLength value) {
|
||||||
pool_.store(flexBasis_, value);
|
pool_.store(flexBasis_, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,17 +177,17 @@ class YG_EXPORT Style {
|
|||||||
pool_.store(gap_[yoga::to_underlying(gutter)], value);
|
pool_.store(gap_[yoga::to_underlying(gutter)], value);
|
||||||
}
|
}
|
||||||
|
|
||||||
Style::Length dimension(Dimension axis) const {
|
Style::SizeLength dimension(Dimension axis) const {
|
||||||
return pool_.getLength(dimensions_[yoga::to_underlying(axis)]);
|
return pool_.getSize(dimensions_[yoga::to_underlying(axis)]);
|
||||||
}
|
}
|
||||||
void setDimension(Dimension axis, Style::Length value) {
|
void setDimension(Dimension axis, Style::SizeLength value) {
|
||||||
pool_.store(dimensions_[yoga::to_underlying(axis)], value);
|
pool_.store(dimensions_[yoga::to_underlying(axis)], value);
|
||||||
}
|
}
|
||||||
|
|
||||||
Style::Length minDimension(Dimension axis) const {
|
Style::SizeLength minDimension(Dimension axis) const {
|
||||||
return pool_.getLength(minDimensions_[yoga::to_underlying(axis)]);
|
return pool_.getSize(minDimensions_[yoga::to_underlying(axis)]);
|
||||||
}
|
}
|
||||||
void setMinDimension(Dimension axis, Style::Length value) {
|
void setMinDimension(Dimension axis, Style::SizeLength value) {
|
||||||
pool_.store(minDimensions_[yoga::to_underlying(axis)], value);
|
pool_.store(minDimensions_[yoga::to_underlying(axis)], value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,10 +209,10 @@ class YG_EXPORT Style {
|
|||||||
: FloatOptional{0.0});
|
: FloatOptional{0.0});
|
||||||
}
|
}
|
||||||
|
|
||||||
Style::Length maxDimension(Dimension axis) const {
|
Style::SizeLength maxDimension(Dimension axis) const {
|
||||||
return pool_.getLength(maxDimensions_[yoga::to_underlying(axis)]);
|
return pool_.getSize(maxDimensions_[yoga::to_underlying(axis)]);
|
||||||
}
|
}
|
||||||
void setMaxDimension(Dimension axis, Style::Length value) {
|
void setMaxDimension(Dimension axis, Style::SizeLength value) {
|
||||||
pool_.store(maxDimensions_[yoga::to_underlying(axis)], value);
|
pool_.store(maxDimensions_[yoga::to_underlying(axis)], value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -19,13 +19,11 @@ namespace facebook::yoga {
|
|||||||
* 3. A CSS <length-percentage> value:
|
* 3. A CSS <length-percentage> value:
|
||||||
* a. <length> value (e.g. 10px)
|
* a. <length> value (e.g. 10px)
|
||||||
* b. <percentage> value of a reference <length>
|
* b. <percentage> value of a reference <length>
|
||||||
* 4. (soon) A math function which returns a <length-percentage> value
|
|
||||||
*
|
*
|
||||||
* References:
|
* References:
|
||||||
* 1. https://www.w3.org/TR/css-values-4/#lengths
|
* 1. https://www.w3.org/TR/css-values-4/#lengths
|
||||||
* 2. https://www.w3.org/TR/css-values-4/#percentage-value
|
* 2. https://www.w3.org/TR/css-values-4/#percentage-value
|
||||||
* 3. https://www.w3.org/TR/css-values-4/#mixed-percentages
|
* 3. https://www.w3.org/TR/css-values-4/#mixed-percentages
|
||||||
* 4. https://www.w3.org/TR/css-values-4/#math
|
|
||||||
*/
|
*/
|
||||||
class StyleLength {
|
class StyleLength {
|
||||||
public:
|
public:
|
||||||
@@ -59,6 +57,14 @@ class StyleLength {
|
|||||||
return unit_ == Unit::Undefined;
|
return unit_ == Unit::Undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr bool isPoints() const {
|
||||||
|
return unit_ == Unit::Point;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr bool isPercent() const {
|
||||||
|
return unit_ == Unit::Percent;
|
||||||
|
}
|
||||||
|
|
||||||
constexpr bool isDefined() const {
|
constexpr bool isDefined() const {
|
||||||
return !isUndefined();
|
return !isUndefined();
|
||||||
}
|
}
|
||||||
@@ -67,10 +73,6 @@ class StyleLength {
|
|||||||
return value_;
|
return value_;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr Unit unit() const {
|
|
||||||
return unit_;
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr FloatOptional resolve(float referenceLength) {
|
constexpr FloatOptional resolve(float referenceLength) {
|
||||||
switch (unit_) {
|
switch (unit_) {
|
||||||
case Unit::Point:
|
case Unit::Point:
|
||||||
@@ -90,6 +92,11 @@ class StyleLength {
|
|||||||
return value_ == rhs.value_ && unit_ == rhs.unit_;
|
return value_ == rhs.value_ && unit_ == rhs.unit_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr bool inexactEquals(const StyleLength& other) const {
|
||||||
|
return unit_ == other.unit_ &&
|
||||||
|
facebook::yoga::inexactEquals(value_, other.value_);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// We intentionally do not allow direct construction using value and unit, to
|
// We intentionally do not allow direct construction using value and unit, to
|
||||||
// avoid invalid, or redundant combinations.
|
// avoid invalid, or redundant combinations.
|
||||||
@@ -101,7 +108,7 @@ class StyleLength {
|
|||||||
};
|
};
|
||||||
|
|
||||||
inline bool inexactEquals(const StyleLength& a, const StyleLength& b) {
|
inline bool inexactEquals(const StyleLength& a, const StyleLength& b) {
|
||||||
return a.unit() == b.unit() && inexactEquals(a.value(), b.value());
|
return a.inexactEquals(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace facebook::yoga
|
} // namespace facebook::yoga
|
||||||
|
139
yoga/style/StyleSizeLength.h
Normal file
139
yoga/style/StyleSizeLength.h
Normal file
@@ -0,0 +1,139 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <yoga/enums/Unit.h>
|
||||||
|
#include <yoga/numeric/FloatOptional.h>
|
||||||
|
|
||||||
|
namespace facebook::yoga {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents a CSS Value for sizes (e.g. width, height, min-width,
|
||||||
|
* etc.). It may be one of:
|
||||||
|
* 1. Undefined
|
||||||
|
* 2. A keyword (e.g. auto, max-content, stretch, etc.)
|
||||||
|
* 3. A CSS <length-percentage> value:
|
||||||
|
* a. <length> value (e.g. 10px)
|
||||||
|
* b. <percentage> value of a reference <length>
|
||||||
|
*
|
||||||
|
* References:
|
||||||
|
* 1. https://www.w3.org/TR/css-values-4/#lengths
|
||||||
|
* 2. https://www.w3.org/TR/css-values-4/#percentage-value
|
||||||
|
* 3. https://www.w3.org/TR/css-values-4/#mixed-percentages
|
||||||
|
*/
|
||||||
|
class StyleSizeLength {
|
||||||
|
public:
|
||||||
|
constexpr StyleSizeLength() = default;
|
||||||
|
|
||||||
|
constexpr static StyleSizeLength points(float value) {
|
||||||
|
return yoga::isUndefined(value) || yoga::isinf(value)
|
||||||
|
? undefined()
|
||||||
|
: StyleSizeLength{FloatOptional{value}, Unit::Point};
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr static StyleSizeLength percent(float value) {
|
||||||
|
return yoga::isUndefined(value) || yoga::isinf(value)
|
||||||
|
? undefined()
|
||||||
|
: StyleSizeLength{FloatOptional{value}, Unit::Percent};
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr static StyleSizeLength ofAuto() {
|
||||||
|
return StyleSizeLength{{}, Unit::Auto};
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr static StyleSizeLength ofMaxContent() {
|
||||||
|
return StyleSizeLength{{}, Unit::MaxContent};
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr static StyleSizeLength ofFitContent() {
|
||||||
|
return StyleSizeLength{{}, Unit::FitContent};
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr static StyleSizeLength ofStretch() {
|
||||||
|
return StyleSizeLength{{}, Unit::Stretch};
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr static StyleSizeLength undefined() {
|
||||||
|
return StyleSizeLength{{}, Unit::Undefined};
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr bool isAuto() const {
|
||||||
|
return unit_ == Unit::Auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr bool isMaxContent() const {
|
||||||
|
return unit_ == Unit::MaxContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr bool isFitContent() const {
|
||||||
|
return unit_ == Unit::FitContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr bool isStretch() const {
|
||||||
|
return unit_ == Unit::Stretch;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr bool isUndefined() const {
|
||||||
|
return unit_ == Unit::Undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr bool isDefined() const {
|
||||||
|
return !isUndefined();
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr bool isPoints() const {
|
||||||
|
return unit_ == Unit::Point;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr bool isPercent() const {
|
||||||
|
return unit_ == Unit::Percent;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr FloatOptional value() const {
|
||||||
|
return value_;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr FloatOptional resolve(float referenceLength) {
|
||||||
|
switch (unit_) {
|
||||||
|
case Unit::Point:
|
||||||
|
return value_;
|
||||||
|
case Unit::Percent:
|
||||||
|
return FloatOptional{value_.unwrap() * referenceLength * 0.01f};
|
||||||
|
default:
|
||||||
|
return FloatOptional{};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
explicit constexpr operator YGValue() const {
|
||||||
|
return YGValue{value_.unwrap(), unscopedEnum(unit_)};
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr bool operator==(const StyleSizeLength& rhs) const {
|
||||||
|
return value_ == rhs.value_ && unit_ == rhs.unit_;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr bool inexactEquals(const StyleSizeLength& other) const {
|
||||||
|
return unit_ == other.unit_ &&
|
||||||
|
facebook::yoga::inexactEquals(value_, other.value_);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
// We intentionally do not allow direct construction using value and unit, to
|
||||||
|
// avoid invalid, or redundant combinations.
|
||||||
|
constexpr StyleSizeLength(FloatOptional value, Unit unit)
|
||||||
|
: value_(value), unit_(unit) {}
|
||||||
|
|
||||||
|
FloatOptional value_{};
|
||||||
|
Unit unit_{Unit::Undefined};
|
||||||
|
};
|
||||||
|
|
||||||
|
inline bool inexactEquals(const StyleSizeLength& a, const StyleSizeLength& b) {
|
||||||
|
return a.inexactEquals(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace facebook::yoga
|
@@ -62,8 +62,16 @@ class StyleValueHandle {
|
|||||||
Percent,
|
Percent,
|
||||||
Number,
|
Number,
|
||||||
Auto,
|
Auto,
|
||||||
|
Keyword
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Intentionally leaving out auto as a fast path
|
||||||
|
enum class Keyword : uint8_t { MaxContent, FitContent, Stretch };
|
||||||
|
|
||||||
|
constexpr bool isKeyword(Keyword keyword) const {
|
||||||
|
return type() == Type::Keyword && value() == static_cast<uint16_t>(keyword);
|
||||||
|
}
|
||||||
|
|
||||||
constexpr Type type() const {
|
constexpr Type type() const {
|
||||||
return static_cast<Type>(repr_ & kHandleTypeMask);
|
return static_cast<Type>(repr_ & kHandleTypeMask);
|
||||||
}
|
}
|
||||||
|
@@ -13,6 +13,7 @@
|
|||||||
#include <yoga/numeric/FloatOptional.h>
|
#include <yoga/numeric/FloatOptional.h>
|
||||||
#include <yoga/style/SmallValueBuffer.h>
|
#include <yoga/style/SmallValueBuffer.h>
|
||||||
#include <yoga/style/StyleLength.h>
|
#include <yoga/style/StyleLength.h>
|
||||||
|
#include <yoga/style/StyleSizeLength.h>
|
||||||
#include <yoga/style/StyleValueHandle.h>
|
#include <yoga/style/StyleValueHandle.h>
|
||||||
|
|
||||||
namespace facebook::yoga {
|
namespace facebook::yoga {
|
||||||
@@ -32,13 +33,30 @@ class StyleValuePool {
|
|||||||
} else if (length.isAuto()) {
|
} else if (length.isAuto()) {
|
||||||
handle.setType(StyleValueHandle::Type::Auto);
|
handle.setType(StyleValueHandle::Type::Auto);
|
||||||
} else {
|
} else {
|
||||||
auto type = length.unit() == Unit::Point
|
auto type = length.isPoints() ? StyleValueHandle::Type::Point
|
||||||
? StyleValueHandle::Type::Point
|
: StyleValueHandle::Type::Percent;
|
||||||
: StyleValueHandle::Type::Percent;
|
|
||||||
storeValue(handle, length.value().unwrap(), type);
|
storeValue(handle, length.value().unwrap(), type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void store(StyleValueHandle& handle, StyleSizeLength sizeValue) {
|
||||||
|
if (sizeValue.isUndefined()) {
|
||||||
|
handle.setType(StyleValueHandle::Type::Undefined);
|
||||||
|
} else if (sizeValue.isAuto()) {
|
||||||
|
handle.setType(StyleValueHandle::Type::Auto);
|
||||||
|
} else if (sizeValue.isMaxContent()) {
|
||||||
|
storeKeyword(handle, StyleValueHandle::Keyword::MaxContent);
|
||||||
|
} else if (sizeValue.isStretch()) {
|
||||||
|
storeKeyword(handle, StyleValueHandle::Keyword::Stretch);
|
||||||
|
} else if (sizeValue.isFitContent()) {
|
||||||
|
storeKeyword(handle, StyleValueHandle::Keyword::FitContent);
|
||||||
|
} else {
|
||||||
|
auto type = sizeValue.isPoints() ? StyleValueHandle::Type::Point
|
||||||
|
: StyleValueHandle::Type::Percent;
|
||||||
|
storeValue(handle, sizeValue.value().unwrap(), type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void store(StyleValueHandle& handle, FloatOptional number) {
|
void store(StyleValueHandle& handle, FloatOptional number) {
|
||||||
if (number.isUndefined()) {
|
if (number.isUndefined()) {
|
||||||
handle.setType(StyleValueHandle::Type::Undefined);
|
handle.setType(StyleValueHandle::Type::Undefined);
|
||||||
@@ -66,6 +84,31 @@ class StyleValuePool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StyleSizeLength getSize(StyleValueHandle handle) const {
|
||||||
|
if (handle.isUndefined()) {
|
||||||
|
return StyleSizeLength::undefined();
|
||||||
|
} else if (handle.isAuto()) {
|
||||||
|
return StyleSizeLength::ofAuto();
|
||||||
|
} else if (handle.isKeyword(StyleValueHandle::Keyword::MaxContent)) {
|
||||||
|
return StyleSizeLength::ofMaxContent();
|
||||||
|
} else if (handle.isKeyword(StyleValueHandle::Keyword::FitContent)) {
|
||||||
|
return StyleSizeLength::ofFitContent();
|
||||||
|
} else if (handle.isKeyword(StyleValueHandle::Keyword::Stretch)) {
|
||||||
|
return StyleSizeLength::ofStretch();
|
||||||
|
} else {
|
||||||
|
assert(
|
||||||
|
handle.type() == StyleValueHandle::Type::Point ||
|
||||||
|
handle.type() == StyleValueHandle::Type::Percent);
|
||||||
|
float value = (handle.isValueIndexed())
|
||||||
|
? std::bit_cast<float>(buffer_.get32(handle.value()))
|
||||||
|
: unpackInlineInteger(handle.value());
|
||||||
|
|
||||||
|
return handle.type() == StyleValueHandle::Type::Point
|
||||||
|
? StyleSizeLength::points(value)
|
||||||
|
: StyleSizeLength::percent(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FloatOptional getNumber(StyleValueHandle handle) const {
|
FloatOptional getNumber(StyleValueHandle handle) const {
|
||||||
if (handle.isUndefined()) {
|
if (handle.isUndefined()) {
|
||||||
return FloatOptional{};
|
return FloatOptional{};
|
||||||
@@ -98,6 +141,20 @@ class StyleValuePool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void storeKeyword(
|
||||||
|
StyleValueHandle& handle,
|
||||||
|
StyleValueHandle::Keyword keyword) {
|
||||||
|
handle.setType(StyleValueHandle::Type::Keyword);
|
||||||
|
|
||||||
|
if (handle.isValueIndexed()) {
|
||||||
|
auto newIndex =
|
||||||
|
buffer_.replace(handle.value(), static_cast<uint32_t>(keyword));
|
||||||
|
handle.setValue(newIndex);
|
||||||
|
} else {
|
||||||
|
handle.setValue(static_cast<uint16_t>(keyword));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static constexpr bool isIntegerPackable(float f) {
|
static constexpr bool isIntegerPackable(float f) {
|
||||||
constexpr uint16_t kMaxInlineAbsValue = (1 << 11) - 1;
|
constexpr uint16_t kMaxInlineAbsValue = (1 << 11) - 1;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user