Compare commits
19 Commits
NickGerlem
...
NSProgramm
Author | SHA1 | Date | |
---|---|---|---|
|
33b71a71f1 | ||
|
4b5ca50117 | ||
|
30291398f3 | ||
|
27d632c697 | ||
|
117fa494f7 | ||
|
073c136117 | ||
|
1232761571 | ||
|
c935fd5e10 | ||
|
624325302c | ||
|
37a94a86de | ||
|
4abc1a7d5f | ||
|
51e6095005 | ||
|
79cef614ce | ||
|
6455a848a7 | ||
|
1b7d2c8d48 | ||
|
3aa594c1f9 | ||
|
c2ae39167e | ||
|
49ee855f99 | ||
|
b12e0a2a15 |
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' }}
|
||||
shell: bash
|
||||
run: |
|
||||
sudo apt-get install -y libc++-dev libc++abi-dev
|
||||
echo "CC=/usr/bin/clang" >> $GITHUB_ENV
|
||||
echo "CXX=/usr/bin/clang++" >> $GITHUB_ENV
|
||||
echo "CXXFLAGS=-stdlib=libc++" >> $GITHUB_ENV
|
||||
|
@@ -24,7 +24,7 @@ jobs:
|
||||
ORG_GRADLE_PROJECT_SIGNING_PWD: ${{ secrets.ORG_GRADLE_PROJECT_SIGNING_PWD }}
|
||||
|
||||
- name: Upload Build Artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: 'snapshot-artifacts'
|
||||
path: '~/.m2/repository/'
|
||||
|
@@ -23,7 +23,7 @@ jobs:
|
||||
ORG_GRADLE_PROJECT_USE_SNAPSHOT: true
|
||||
|
||||
- name: Upload Build Artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: 'snapshot-artifacts'
|
||||
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 --build build
|
||||
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
|
||||
working-directory: javascript
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: npm-package
|
||||
path: javascript/yoga-layout.tar.gz
|
||||
|
@@ -34,6 +34,8 @@ nexusPublishing {
|
||||
sonatype {
|
||||
username.set(sonatypeUsername)
|
||||
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/"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -19,8 +19,8 @@ add_compile_options(
|
||||
# Enable warnings and warnings as errors
|
||||
/W4
|
||||
/WX
|
||||
# Disable RTTI
|
||||
$<$<COMPILE_LANGUAGE:CXX>:/GR->
|
||||
# Enable RTTI
|
||||
$<$<COMPILE_LANGUAGE:CXX>:/GR>
|
||||
# Use /O2 (Maximize Speed)
|
||||
$<$<CONFIG:RELEASE>:/O2>)
|
||||
|
||||
@@ -34,8 +34,8 @@ add_compile_options(
|
||||
# Enable warnings and warnings as errors
|
||||
-Wall
|
||||
-Werror
|
||||
# Disable RTTI
|
||||
$<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>
|
||||
# Enable RTTI
|
||||
$<$<COMPILE_LANGUAGE:CXX>:-frtti>
|
||||
# Use -O2 (prioritize speed)
|
||||
$<$<CONFIG:RELEASE>:-O2>
|
||||
# Enable separate sections per function/data item
|
||||
|
@@ -240,3 +240,14 @@
|
||||
<div style="position:relative; width:50px; height:50px;">
|
||||
</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>
|
||||
|
@@ -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
|
||||
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
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
26
gradlew
vendored
26
gradlew
vendored
@@ -15,6 +15,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
@@ -55,7 +57,7 @@
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (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.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
@@ -83,7 +85,8 @@ done
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
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.
|
||||
MAX_FD=maximum
|
||||
@@ -130,10 +133,13 @@ location of your Java installation."
|
||||
fi
|
||||
else
|
||||
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
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
@@ -141,7 +147,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# 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 ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
@@ -149,7 +155,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# 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" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
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.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-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 limitations under the License.
|
||||
@rem
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
@@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
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/>
|
||||
|
||||
|
@@ -4,7 +4,7 @@
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* 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
|
||||
*/
|
||||
|
||||
@@ -2293,6 +2293,86 @@ public class YGAlignItemsTest {
|
||||
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) {
|
||||
return mNodeFactory.create(config);
|
||||
}
|
||||
|
@@ -4,7 +4,7 @@
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* 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
|
||||
*/
|
||||
|
||||
@@ -2442,3 +2442,88 @@ test('align_stretch_with_row_reverse', () => {
|
||||
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();
|
||||
}
|
||||
});
|
||||
|
@@ -19,10 +19,11 @@ include(":yoga")
|
||||
|
||||
project(":yoga").projectDir = file("java")
|
||||
|
||||
rootProject.name = "yoga-github"
|
||||
|
||||
// If you specify a file inside gradle/gradle-enterprise.gradle.kts
|
||||
// you can configure your custom Gradle Enterprise instance
|
||||
if (file("./gradle/gradle-enterprise.gradle.kts").exists()) {
|
||||
apply(from = "./gradle/gradle-enterprise.gradle.kts")
|
||||
gradleEnterprise {
|
||||
buildScan {
|
||||
termsOfServiceUrl = "https://gradle.com/terms-of-service"
|
||||
termsOfServiceAgree = "yes"
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "yoga-github"
|
||||
|
184
tests/YGPersistentNodeCloningTest.cpp
Normal file
184
tests/YGPersistentNodeCloningTest.cpp
Normal file
@@ -0,0 +1,184 @@
|
||||
/*
|
||||
* 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());
|
||||
}
|
||||
|
||||
} // namespace facebook::yoga
|
@@ -161,3 +161,23 @@ TEST(YogaTest, per_node_point_scale_factor) {
|
||||
YGConfigFree(config2);
|
||||
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.
|
||||
*
|
||||
* clang-format off
|
||||
* @generated SignedSource<<71295a398c89ea424490884a05e2c77c>>
|
||||
* @generated SignedSource<<1db57b05babb408c08efcec7dbdf16fb>>
|
||||
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGAlignItemsTest.html
|
||||
*/
|
||||
|
||||
@@ -2310,3 +2310,84 @@ TEST(YogaTest, align_stretch_with_row_reverse) {
|
||||
|
||||
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);
|
||||
}
|
||||
|
@@ -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.
|
||||
|
||||
**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.
|
||||
|
||||
**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
|
||||
space around will result in space being distributed to the beginning of
|
||||
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
|
||||
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.
|
||||
|
@@ -90,3 +90,11 @@ float YGNodeLayoutGetPadding(YGNodeConstRef node, YGEdge edge) {
|
||||
return getResolvedLayoutProperty<&LayoutResults::padding>(
|
||||
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 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
|
||||
|
@@ -72,9 +72,9 @@ inline bool operator==(const YGValue& lhs, const YGValue& rhs) {
|
||||
case YGUnitPoint:
|
||||
case YGUnitPercent:
|
||||
return lhs.value == rhs.value;
|
||||
}
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
inline bool operator!=(const YGValue& lhs, const YGValue& rhs) {
|
||||
|
@@ -415,6 +415,12 @@ static void measureNodeWithoutChildren(
|
||||
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(
|
||||
yoga::Node* const node,
|
||||
const Direction direction,
|
||||
@@ -424,12 +430,8 @@ static bool measureNodeWithFixedSize(
|
||||
const SizingMode heightSizingMode,
|
||||
const float ownerWidth,
|
||||
const float ownerHeight) {
|
||||
if ((yoga::isDefined(availableWidth) &&
|
||||
widthSizingMode == SizingMode::FitContent && availableWidth <= 0.0f) ||
|
||||
(yoga::isDefined(availableHeight) &&
|
||||
heightSizingMode == SizingMode::FitContent && availableHeight <= 0.0f) ||
|
||||
(widthSizingMode == SizingMode::StretchFit &&
|
||||
heightSizingMode == SizingMode::StretchFit)) {
|
||||
if (isFixedSize(availableWidth, widthSizingMode) &&
|
||||
isFixedSize(availableHeight, heightSizingMode)) {
|
||||
node->setLayoutMeasuredDimension(
|
||||
boundAxis(
|
||||
node,
|
||||
|
@@ -106,25 +106,25 @@ void roundLayoutResultsToPixelGrid(
|
||||
const bool hasFractionalHeight =
|
||||
!yoga::inexactEquals(round(scaledNodeHeight), scaledNodeHeight);
|
||||
|
||||
node->setLayoutDimension(
|
||||
node->getLayout().setDimension(
|
||||
Dimension::Width,
|
||||
roundValueToPixelGrid(
|
||||
absoluteNodeRight,
|
||||
pointScaleFactor,
|
||||
(textRounding && hasFractionalWidth),
|
||||
(textRounding && !hasFractionalWidth)) -
|
||||
roundValueToPixelGrid(
|
||||
absoluteNodeLeft, pointScaleFactor, false, textRounding),
|
||||
Dimension::Width);
|
||||
absoluteNodeLeft, pointScaleFactor, false, textRounding));
|
||||
|
||||
node->setLayoutDimension(
|
||||
node->getLayout().setDimension(
|
||||
Dimension::Height,
|
||||
roundValueToPixelGrid(
|
||||
absoluteNodeBottom,
|
||||
pointScaleFactor,
|
||||
(textRounding && hasFractionalHeight),
|
||||
(textRounding && !hasFractionalHeight)) -
|
||||
roundValueToPixelGrid(
|
||||
absoluteNodeTop, pointScaleFactor, false, textRounding),
|
||||
Dimension::Height);
|
||||
absoluteNodeTop, pointScaleFactor, false, textRounding));
|
||||
}
|
||||
|
||||
for (yoga::Node* child : node->getChildren()) {
|
||||
|
@@ -19,6 +19,7 @@ namespace facebook::yoga {
|
||||
#if defined(__cpp_exceptions)
|
||||
throw std::logic_error(message);
|
||||
#else
|
||||
static_cast<void>(message); // Unused
|
||||
std::terminate();
|
||||
#endif
|
||||
}
|
||||
|
@@ -36,12 +36,12 @@ enum struct LayoutPassReason : int {
|
||||
};
|
||||
|
||||
struct LayoutData {
|
||||
int layouts;
|
||||
int measures;
|
||||
uint32_t maxMeasureCache;
|
||||
int cachedLayouts;
|
||||
int cachedMeasures;
|
||||
int measureCallbacks;
|
||||
int layouts = 0;
|
||||
int measures = 0;
|
||||
uint32_t maxMeasureCache = 0;
|
||||
int cachedLayouts = 0;
|
||||
int cachedMeasures = 0;
|
||||
int measureCallbacks = 0;
|
||||
std::array<int, static_cast<uint8_t>(LayoutPassReason::COUNT)>
|
||||
measureCallbackReasonsCount;
|
||||
};
|
||||
|
@@ -66,10 +66,18 @@ struct LayoutResults {
|
||||
return measuredDimensions_[yoga::to_underlying(axis)];
|
||||
}
|
||||
|
||||
float rawDimension(Dimension axis) const {
|
||||
return rawDimensions_[yoga::to_underlying(axis)];
|
||||
}
|
||||
|
||||
void setMeasuredDimension(Dimension axis, float dimension) {
|
||||
measuredDimensions_[yoga::to_underlying(axis)] = dimension;
|
||||
}
|
||||
|
||||
void setRawDimension(Dimension axis, float dimension) {
|
||||
rawDimensions_[yoga::to_underlying(axis)] = dimension;
|
||||
}
|
||||
|
||||
float position(PhysicalEdge physicalEdge) const {
|
||||
return position_[yoga::to_underlying(physicalEdge)];
|
||||
}
|
||||
@@ -113,6 +121,7 @@ struct LayoutResults {
|
||||
|
||||
std::array<float, 2> dimensions_ = {{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> margin_ = {};
|
||||
std::array<float, 4> border_ = {};
|
||||
|
@@ -247,6 +247,7 @@ void Node::setLayoutHadOverflow(bool hadOverflow) {
|
||||
|
||||
void Node::setLayoutDimension(float lengthValue, Dimension dimension) {
|
||||
layout_.setDimension(dimension, lengthValue);
|
||||
layout_.setRawDimension(dimension, lengthValue);
|
||||
}
|
||||
|
||||
// If both left and right are defined, then use left. Otherwise return +left or
|
||||
|
Reference in New Issue
Block a user