Revive JavaScript Bindings (#1177)
Summary: Yoga's JavaScript bindings do not work past Node 10, or on recent versions of Ubuntu even using it. This is due to a reliance on `nbind`, a library which is no longer maintained. `nbind` itself abstracts over `embind` running Emscripten to generate an asm.js build, along with building Node native modules. In the meantime, [yoga-layout-prebuilt](https://www.npmjs.com/package/yoga-layout-prebuilt) has been used by the community instead of the official package. https://github.com/facebook/yoga/pull/1177 was contributed as a conversion of bindings created using `nbind` to instead use `embind` directly. I continued building on this to add more: 1. WebAssembly support (required to be async in browsers) 2. CMake + Ninja Build for the 4 flavors 3. TypeScript typings (partially generated) 4. yarn scripts to build (working on macOS, Ubuntu, Windows) 5. A README with some usage and contribution instructions 6. Updated tests to work with Jest, and updated general infra 7. ESLint and clang-format scripts 8. More GitHub actions (and now testing Windows) 9. Probably more I kinda got carried away here lol The plan is to eventually publish this to NPM, but there is a little bit of work after this before that happens. Pull Request resolved: https://github.com/facebook/yoga/pull/1177 Test Plan: The bindings pass Jest tests (both manual and generated). GitHub actions added for the different yarn scripts. Did some manual checks on using the library as TS. Reviewed By: christophpurrer Differential Revision: D42207782 Pulled By: NickGerleman fbshipit-source-id: 1dc5ce440f1c2b9705a005bbdcc86f952785d94e
This commit is contained in:
committed by
Facebook GitHub Bot
parent
8035456330
commit
1813748eaa
25
.github/actions/black/action.yml
vendored
Normal file
25
.github/actions/black/action.yml
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
name: Black Formatter
|
||||
inputs:
|
||||
directory:
|
||||
description: Directory to Lint
|
||||
required: true
|
||||
version:
|
||||
description: pypi version of "black" to use
|
||||
required: false
|
||||
default: 22.3.0
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Ensure supported Python selected
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '>=3.6.2'
|
||||
|
||||
- name: pip install
|
||||
shell: bash
|
||||
run: pip install black==${{ inputs.version }}
|
||||
|
||||
- name: black
|
||||
shell: bash
|
||||
run: black --check ${{ inputs.directory }}
|
7
.github/actions/clang-format/action.yml
vendored
7
.github/actions/clang-format/action.yml
vendored
@@ -18,7 +18,6 @@ runs:
|
||||
- name: clang-format
|
||||
working-directory: ${{ inputs.directory }}
|
||||
shell: bash
|
||||
run: |
|
||||
shopt -s globstar
|
||||
shopt -s nullglob
|
||||
clang-format-${{ inputs.version }} --dry-run --Werror **/*.cpp **/*.h **/*.m **/*.mm
|
||||
env:
|
||||
BASHOPTS: extglob:nullglob
|
||||
run: clang-format-${{ inputs.version }} --dry-run --Werror **/*.{h,hh,hpp,c,cpp,cc,m,mm}
|
||||
|
23
.github/actions/install-emsdk/action.yml
vendored
Normal file
23
.github/actions/install-emsdk/action.yml
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
name: Install emsdk (including emcc)
|
||||
inputs:
|
||||
version:
|
||||
description: EMCC Version to install
|
||||
required: false
|
||||
default: 3.1.28
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Clone emsdk repo
|
||||
working-directory: ${{ runner.temp }}
|
||||
shell: bash
|
||||
run: git clone https://github.com/emscripten-core/emsdk.git
|
||||
|
||||
- name: emdsk install
|
||||
working-directory: ${{ runner.temp }}/emsdk
|
||||
shell: bash
|
||||
run: |
|
||||
./emsdk install ${{ inputs.version }}
|
||||
./emsdk activate ${{ inputs.version }}
|
||||
echo $RUNNER_TEMP/emsdk >> $GITHUB_PATH
|
||||
echo $RUNNER_TEMP/emsdk/upstream/emscripten >> $GITHUB_PATH
|
11
.github/actions/setup-android/action.yml
vendored
11
.github/actions/setup-android/action.yml
vendored
@@ -3,11 +3,8 @@ name: Setup Android envirionment
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Install JDK 1.8
|
||||
uses: actions/setup-java@v1
|
||||
- name: Select Java Version
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
java-version: 1.8
|
||||
|
||||
- name: Install NDK 21
|
||||
shell: bash
|
||||
run: echo "y" | /usr/local/lib/android/sdk/tools/bin/sdkmanager --install "ndk;21.3.6528147" --sdk_root=${ANDROID_SDK_ROOT}
|
||||
distribution: temurin
|
||||
java-version: 8
|
||||
|
27
.github/actions/setup-js/action.yml
vendored
Normal file
27
.github/actions/setup-js/action.yml
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
name: Setup JavaScript envirionment
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Install Node
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 18.x
|
||||
|
||||
- name: Install emsdk
|
||||
uses: ./.github/actions/install-emsdk
|
||||
|
||||
- name: Install ninja (Linux)
|
||||
if: ${{ runner.os == 'Linux' }}
|
||||
shell: bash
|
||||
run: sudo apt-get install -y ninja-build
|
||||
|
||||
- name: Install ninja (Windows)
|
||||
if: ${{ runner.os == 'Windows' }}
|
||||
shell: powershell
|
||||
run: choco install ninja
|
||||
|
||||
- name: yarn install
|
||||
shell: bash
|
||||
run: yarn install --frozen-lockfile
|
||||
working-directory: javascript
|
6
.github/actions/setup-website/action.yml
vendored
6
.github/actions/setup-website/action.yml
vendored
@@ -3,11 +3,15 @@ name: Setup Website envirionment
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Install NodeJS 12
|
||||
# TODO: Update to latest when website is moved to the workspace version of
|
||||
# yoga-layout
|
||||
- name: Install Node
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 12.x
|
||||
|
||||
# TODO: the website should be in a yarn workspace with the library, but the
|
||||
# current version of gatsby is incompatible with hoisting.
|
||||
- name: yarn install
|
||||
shell: bash
|
||||
run: yarn install --frozen-lockfile
|
||||
|
5
.github/workflows/validate-android.yml
vendored
5
.github/workflows/validate-android.yml
vendored
@@ -9,11 +9,12 @@ on:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build (${{ matrix.mode }})
|
||||
runs-on: ubuntu-latest
|
||||
name: Build [${{ matrix.os }}][${{ matrix.mode }}]
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
mode: [Debug, Release]
|
||||
os: [ubuntu-latest, windows-latest]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
8
.github/workflows/validate-apple.yml
vendored
8
.github/workflows/validate-apple.yml
vendored
@@ -10,7 +10,6 @@ on:
|
||||
jobs:
|
||||
lint-pods:
|
||||
name: Lint
|
||||
if: ${{ false }} # Apple Build is Broken
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
@@ -21,10 +20,10 @@ jobs:
|
||||
|
||||
- name: pod spec lint
|
||||
run: pod spec lint --verbose
|
||||
continue-on-error: true # Apple Build is Broken
|
||||
|
||||
build-sample:
|
||||
name: Build (${{ matrix.mode }})
|
||||
if: ${{ false }} # Apple Build is Broken
|
||||
name: Build [${{ matrix.mode }}]
|
||||
runs-on: macos-latest
|
||||
strategy:
|
||||
matrix:
|
||||
@@ -37,8 +36,9 @@ jobs:
|
||||
uses: ./.github/actions/setup-apple
|
||||
|
||||
- name: pod install
|
||||
working-directory: ./YogaKit/YogaKitSample
|
||||
run: pod install
|
||||
working-directory: ./YogaKit/YogaKitSample
|
||||
continue-on-error: true # Apple Build is Broken
|
||||
|
||||
# TODO: xcodebuild
|
||||
|
||||
|
74
.github/workflows/validate-js.yml
vendored
Normal file
74
.github/workflows/validate-js.yml
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
name: JavaScript
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
FORCE_COLOR: 3
|
||||
|
||||
jobs:
|
||||
benchmark:
|
||||
name: Benchmark [${{ matrix.os }}]
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup
|
||||
uses: ./.github/actions/setup-js
|
||||
|
||||
- name: yarn benchmark
|
||||
run: yarn benchmark
|
||||
working-directory: javascript
|
||||
|
||||
build:
|
||||
name: Build [${{ matrix.os }}]
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup
|
||||
uses: ./.github/actions/setup-js
|
||||
|
||||
- name: yarn build
|
||||
run: yarn build
|
||||
working-directory: javascript
|
||||
|
||||
test:
|
||||
name: Test [${{ matrix.os }}]
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup
|
||||
uses: ./.github/actions/setup-js
|
||||
|
||||
- name: yarn test
|
||||
run: yarn test
|
||||
working-directory: javascript
|
||||
|
||||
lint:
|
||||
name: Lint
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: yarn install
|
||||
run: yarn install --frozen-lockfile
|
||||
working-directory: javascript
|
||||
|
||||
- name: yarn lint
|
||||
run: yarn lint
|
||||
working-directory: javascript
|
21
.github/workflows/validate-python.yml
vendored
Normal file
21
.github/workflows/validate-python.yml
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
name: Python
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
format:
|
||||
name: Format
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: black --check
|
||||
uses: ./.github/actions/black
|
||||
with:
|
||||
directory: ${{ github.workspace }}
|
55
enums.py
55
enums.py
@@ -222,38 +222,56 @@ for name, values in sorted(ENUMS.items()):
|
||||
f.write("}\n")
|
||||
|
||||
# write out javascript file
|
||||
with open(root + "/javascript/sources/YGEnums.js", "w") as f:
|
||||
with open(root + "/javascript/src_js/generated/YGEnums.js", "w") as f:
|
||||
f.write(get_license("js"))
|
||||
f.write("// @flow\n")
|
||||
f.write("// @format\n")
|
||||
f.write("const CONSTANTS = {\n")
|
||||
f.write("module.exports = {\n")
|
||||
items = sorted(ENUMS.items())
|
||||
for name, values in items:
|
||||
f.write(" %s_COUNT: %s,\n" % (to_java_upper(name), len(values)))
|
||||
base = 0
|
||||
for value in values:
|
||||
if isinstance(value, tuple):
|
||||
f.write(
|
||||
" %s_%s: %d,\n"
|
||||
% (to_java_upper(name), to_java_upper(value[0]), value[1])
|
||||
)
|
||||
base = value[1] + 1
|
||||
else:
|
||||
f.write(
|
||||
" %s_%s: %d,\n" % (to_java_upper(name), to_java_upper(value), base)
|
||||
)
|
||||
base += 1
|
||||
value_arg = value[0] if isinstance(value, tuple) else value
|
||||
ordinal_arg = value[1] if isinstance(value, tuple) else base
|
||||
|
||||
f.write(
|
||||
" %s_%s: %d,\n"
|
||||
% (to_java_upper(name), to_java_upper(value_arg), ordinal_arg)
|
||||
)
|
||||
base = ordinal_arg + 1
|
||||
|
||||
if name != items[-1][0]:
|
||||
f.write("\n")
|
||||
f.write("};\n")
|
||||
|
||||
with open(root + "/javascript/src_js/generated/YGEnums.d.ts", "w") as f:
|
||||
f.write(get_license("js"))
|
||||
|
||||
for name, values in sorted(ENUMS.items()):
|
||||
f.write("export type Yoga${} =\n".format(name))
|
||||
base = 0
|
||||
for value in values:
|
||||
value_arg = value[0] if isinstance(value, tuple) else value
|
||||
ordinal_arg = value[1] if isinstance(value, tuple) else base
|
||||
|
||||
f.write(
|
||||
(
|
||||
"type {name}_{value} = {ordinal} & ['{name}']\n"
|
||||
+ "export const {name}_{value}: {name}_{value};\n\n"
|
||||
).format(
|
||||
name=to_java_upper(name),
|
||||
value=to_java_upper(value_arg),
|
||||
ordinal=ordinal_arg,
|
||||
)
|
||||
)
|
||||
|
||||
base = ordinal_arg + 1
|
||||
|
||||
f.write("\n")
|
||||
|
||||
for name, values in sorted(ENUMS.items()):
|
||||
f.write("export type {} =\n".format(name))
|
||||
for value in values:
|
||||
unpackedValue = value[0] if isinstance(value, tuple) else value
|
||||
f.write(
|
||||
" | typeof CONSTANTS.{}_{}".format(
|
||||
" | typeof {}_{}".format(
|
||||
to_java_upper(name), to_java_upper(unpackedValue)
|
||||
)
|
||||
)
|
||||
@@ -263,4 +281,3 @@ with open(root + "/javascript/sources/YGEnums.js", "w") as f:
|
||||
f.write("\n")
|
||||
|
||||
f.write("\n")
|
||||
f.write("module.exports = CONSTANTS;\n")
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
var JavascriptEmitter = function() {
|
||||
const JavascriptEmitter = function() {
|
||||
Emitter.call(this, 'js', ' ');
|
||||
};
|
||||
|
||||
@@ -17,9 +17,8 @@ function toValueJavascript(value) {
|
||||
}
|
||||
|
||||
function toJavascriptUpper(symbol) {
|
||||
var out = '';
|
||||
for (var i = 0; i < symbol.length; i++) {
|
||||
var c = symbol[i];
|
||||
let out = '';
|
||||
for (const c of symbol) {
|
||||
if (c == c.toUpperCase() && i != 0 && symbol[i - 1] != symbol[i - 1].toUpperCase()) {
|
||||
out += '_';
|
||||
}
|
||||
@@ -31,21 +30,17 @@ function toJavascriptUpper(symbol) {
|
||||
JavascriptEmitter.prototype = Object.create(Emitter.prototype, {
|
||||
constructor:{value:JavascriptEmitter},
|
||||
|
||||
emitPrologue:{value:function() {
|
||||
this.push([
|
||||
'var Yoga = Yoga || require("../../sources/entry-" + process.env.TEST_ENTRY);',
|
||||
''
|
||||
]);
|
||||
}},
|
||||
emitPrologue:{value:function() {}},
|
||||
|
||||
emitTestPrologue:{value:function(name, experiments) {
|
||||
this.push('it(' + JSON.stringify(name) + ', function () {');
|
||||
this.push('test(' + JSON.stringify(name) + ', () => {');
|
||||
this.pushIndent();
|
||||
this.push('var config = Yoga.Config.create();');
|
||||
this.push('const config = Yoga.Config.create();');
|
||||
this.push('let root;');
|
||||
this.push('');
|
||||
|
||||
if (experiments.length > 0) {
|
||||
for (var i in experiments) {
|
||||
for (const i in experiments) {
|
||||
this.push('config.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_' + toJavascriptUpper(experiments[i]) + ', true);');
|
||||
}
|
||||
this.push('');
|
||||
@@ -56,7 +51,11 @@ JavascriptEmitter.prototype = Object.create(Emitter.prototype, {
|
||||
}},
|
||||
|
||||
emitTestTreePrologue:{value:function(nodeName) {
|
||||
this.push('var ' + nodeName + ' = Yoga.Node.create(config);');
|
||||
if (nodeName === 'root') {
|
||||
this.push(`root = Yoga.Node.create(config);`);
|
||||
} else {
|
||||
this.push(`const ${nodeName} = Yoga.Node.create(config);`);
|
||||
}
|
||||
}},
|
||||
|
||||
emitTestEpilogue:{value:function(experiments) {
|
||||
@@ -84,7 +83,7 @@ JavascriptEmitter.prototype = Object.create(Emitter.prototype, {
|
||||
}},
|
||||
|
||||
AssertEQ:{value:function(v0, v1) {
|
||||
this.push('console.assert(' + v0 + ' === ' + v1 + ', "' + v0 + ' === ' + v1 + ' (" + ' + v1 + ' + ")");');
|
||||
this.push(`expect(${v1}).toBe(${v0});`);
|
||||
}},
|
||||
|
||||
YGAlignAuto:{value:'Yoga.ALIGN_AUTO'},
|
||||
|
@@ -56,7 +56,7 @@ Dir['fixtures/*.html'].each do |file|
|
||||
|
||||
print logs[4]
|
||||
|
||||
f = File.open("../javascript/tests/Facebook.Yoga/#{name}.js", 'w')
|
||||
f = File.open("../javascript/tests/generated/#{name}.test.js", 'w')
|
||||
f.write eval(logs[3].message.sub(/^[^"]*/, '')).sub('YogaTest', name)
|
||||
f.close
|
||||
end
|
||||
|
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"presets": ["stage-3", "es2015"],
|
||||
"plugins": [
|
||||
"transform-flow-strip-types",
|
||||
[
|
||||
"replace-require",
|
||||
{
|
||||
"fs": "{}",
|
||||
"path": "{}"
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
14
javascript/.babelrc.js
Normal file
14
javascript/.babelrc.js
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.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
"presets": [
|
||||
["@babel/preset-env", {"targets": "defaults"}]
|
||||
],
|
||||
};
|
45
javascript/.eslintrc.js
Normal file
45
javascript/.eslintrc.js
Normal file
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
ignorePatterns: ["dist/**", "**/*.d.ts"],
|
||||
parser: "@babel/eslint-parser",
|
||||
extends: [
|
||||
"eslint:recommended",
|
||||
"plugin:jest/recommended",
|
||||
"plugin:prettier/recommended",
|
||||
],
|
||||
rules: {
|
||||
"no-var": "error",
|
||||
"prefer-arrow-callback": "error",
|
||||
"prefer-const": "error",
|
||||
"prefer-object-spread": "error",
|
||||
"prefer-spread": "error",
|
||||
"require-await": "error",
|
||||
},
|
||||
env: {
|
||||
commonjs: true,
|
||||
es6: true,
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
files: ["jest.*", "just.config.js", "tests/**"],
|
||||
env: {
|
||||
node: true,
|
||||
},
|
||||
globals: {
|
||||
getMeasureCounter: "writable",
|
||||
getMeasureCounterMax: "writable",
|
||||
getMeasureCounterMin: "writable",
|
||||
Yoga: "writable",
|
||||
YGBENCHMARK: "writable",
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
11
javascript/.gitignore
vendored
11
javascript/.gitignore
vendored
@@ -1,10 +1,3 @@
|
||||
node_modules
|
||||
|
||||
*.gypi
|
||||
!/final-flags.gypi
|
||||
|
||||
/build
|
||||
/dist
|
||||
/build/*
|
||||
/sources/yoga
|
||||
|
||||
npm-debug.log*
|
||||
/node_modules
|
||||
|
@@ -1,15 +0,0 @@
|
||||
syntax:glob
|
||||
|
||||
node_modules
|
||||
|
||||
*.gypi
|
||||
!/final-flags.gypi
|
||||
|
||||
/dist
|
||||
/build/*
|
||||
!/build/Release
|
||||
/build/Release/*
|
||||
!/build/Release/nbind.js
|
||||
/sources/yoga
|
||||
|
||||
npm-debug.log*
|
1
javascript/.prettierignore
Normal file
1
javascript/.prettierignore
Normal file
@@ -0,0 +1 @@
|
||||
tests/generated/
|
72
javascript/CMakeLists.txt
Normal file
72
javascript/CMakeLists.txt
Normal file
@@ -0,0 +1,72 @@
|
||||
# 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.
|
||||
|
||||
cmake_minimum_required(VERSION 3.13)
|
||||
set(CMAKE_VERBOSE_MAKEFILE on)
|
||||
project(yoga)
|
||||
|
||||
file(GLOB SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../yoga/*.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../yoga/**/*.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src_native/*.cc)
|
||||
|
||||
include_directories(..)
|
||||
|
||||
set(CXX_STANDARD, 11)
|
||||
|
||||
add_compile_definitions(
|
||||
EMSCRIPTEN_HAS_UNBOUND_TYPE_NAMES=0)
|
||||
|
||||
set(COMPILE_OPTIONS
|
||||
-flto
|
||||
-fno-exceptions
|
||||
-fno-rtti
|
||||
-g0
|
||||
-Os
|
||||
"SHELL:-s STRICT=1")
|
||||
|
||||
add_compile_options(${COMPILE_OPTIONS})
|
||||
|
||||
add_link_options(
|
||||
${COMPILE_OPTIONS}
|
||||
--closure 1
|
||||
--memory-init-file 0
|
||||
--no-entry
|
||||
"SHELL:-s ALLOW_MEMORY_GROWTH=1"
|
||||
"SHELL:-s ASSERTIONS=0"
|
||||
"SHELL:-s DYNAMIC_EXECUTION=0"
|
||||
"SHELL:-s ENVIRONMENT='web,node'"
|
||||
"SHELL:-s EXPORT_NAME='loadYoga'"
|
||||
"SHELL:-s FETCH_SUPPORT_INDEXEDDB=0"
|
||||
"SHELL:-s FILESYSTEM=0"
|
||||
"SHELL:-s MALLOC='emmalloc'"
|
||||
"SHELL:-s MODULARIZE=1"
|
||||
"SHELL:-s TEXTDECODER=0")
|
||||
|
||||
link_libraries(embind)
|
||||
|
||||
add_library(yogaObjLib OBJECT ${SOURCES})
|
||||
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/dist/build)
|
||||
|
||||
add_executable(asmjs-sync $<TARGET_OBJECTS:yogaObjLib>)
|
||||
target_link_options(asmjs-sync PUBLIC
|
||||
"SHELL:-s WASM=0"
|
||||
"SHELL:-s WASM_ASYNC_COMPILATION=0")
|
||||
|
||||
add_executable(asmjs-async $<TARGET_OBJECTS:yogaObjLib>)
|
||||
target_link_options(asmjs-async PUBLIC
|
||||
"SHELL:-s WASM=0"
|
||||
"SHELL:-s WASM_ASYNC_COMPILATION=1")
|
||||
|
||||
add_executable(wasm-sync $<TARGET_OBJECTS:yogaObjLib>)
|
||||
target_link_options(wasm-sync PUBLIC
|
||||
"SHELL:-s WASM=1"
|
||||
"SHELL:-s WASM_ASYNC_COMPILATION=0")
|
||||
|
||||
add_executable(wasm-async $<TARGET_OBJECTS:yogaObjLib>)
|
||||
target_link_options(wasm-async PUBLIC
|
||||
"SHELL:-s WASM=1"
|
||||
"SHELL:-s WASM_ASYNC_COMPILATION=1")
|
76
javascript/README.md
Normal file
76
javascript/README.md
Normal file
@@ -0,0 +1,76 @@
|
||||
# yoga-layout
|
||||
|
||||
This package provides prebuilt JavaScript bindings for the Yoga layout engine. Both WebAssembly and asm.js variants are packaged, with the optimal loaded based on platform.
|
||||
|
||||
## Usage
|
||||
|
||||
The default entrypoint provides an asynchronous loader function to return a Yoga instance.
|
||||
|
||||
```ts
|
||||
import { loadYoga, ALIGN_CENTER } from "yoga-layout";
|
||||
|
||||
const Yoga = await loadYoga();
|
||||
|
||||
const node = Yoga.Node.create();
|
||||
node.setAlignContent(ALIGN_CENTER);
|
||||
```
|
||||
|
||||
An alternative synchronous API is provided for compatibility, but requires using asm.js in browsers instead of WebAssembly, leading to worse performance and larger assets.
|
||||
|
||||
```ts
|
||||
import Yoga, { ALIGN_CENTER } from "yoga-layout/sync";
|
||||
|
||||
const node = Yoga.Node.create();
|
||||
node.setAlignContent(ALIGN_CENTER);
|
||||
```
|
||||
|
||||
Objects created by `Yoga.<>.create()` are not automatically garbage collected and should be freed once they are no longer in use.
|
||||
|
||||
```ts
|
||||
// Free a config
|
||||
config.free();
|
||||
|
||||
// Free a tree of Nodes
|
||||
node.freeRecursive();
|
||||
|
||||
// Free a single Node
|
||||
node.free();
|
||||
```
|
||||
|
||||
## Selecting WebAssembly or asm.js
|
||||
|
||||
For better performance and smaller packages, WebAssembly is preferred to asm.js where available. `yoga-layout` tries to provide the right default using [export maps](https://webpack.js.org/guides/package-exports/#conditional-syntax) so that platforms which can take advantage of WebAssembly use it by default.
|
||||
|
||||
A specific entrypoint may be specified on platforms which do not understand export conditions.
|
||||
|
||||
```ts
|
||||
import { loadYoga } from "yoga-layout/dist/entrypoint/wasm-async";
|
||||
```
|
||||
|
||||
|
||||
## Contributing
|
||||
|
||||
### Requirements
|
||||
|
||||
1. Emscripten SDK
|
||||
1. CMake >= 3.13
|
||||
1. (Optional) ninja, for faster builds
|
||||
|
||||
### Building
|
||||
|
||||
```bash
|
||||
git clone https://github.com/facebook/yoga.git
|
||||
cd yoga/javascript
|
||||
yarn install
|
||||
yarn build
|
||||
```
|
||||
|
||||
### Testing
|
||||
|
||||
```bash
|
||||
# Build and test all entrypoints
|
||||
yarn test
|
||||
|
||||
# Build and test a specific entrypoint
|
||||
yarn test:asmjs-sync
|
||||
```
|
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"dependencies": [
|
||||
"nbind"
|
||||
],
|
||||
"includes": []
|
||||
}
|
@@ -1,28 +0,0 @@
|
||||
{
|
||||
"targets": [{
|
||||
"includes": [
|
||||
"auto.gypi",
|
||||
"final-flags.gypi"
|
||||
],
|
||||
|
||||
"sources": [
|
||||
"<!@(ls -1 sources/yoga/*.cpp)",
|
||||
"<!@(ls -1 sources/yoga/*/*.cpp)",
|
||||
"sources/Config.cc",
|
||||
"sources/Node.cc",
|
||||
"sources/nbind.cc"
|
||||
],
|
||||
|
||||
"cflags": [
|
||||
"-DNBIND"
|
||||
],
|
||||
|
||||
"include_dirs": [
|
||||
"sources"
|
||||
]
|
||||
}],
|
||||
|
||||
"includes": [
|
||||
"auto-top.gypi"
|
||||
]
|
||||
}
|
@@ -1,32 +0,0 @@
|
||||
{
|
||||
"conditions": [
|
||||
|
||||
[ "1==1", {
|
||||
|
||||
"cflags_cc": [
|
||||
"-std=c++14",
|
||||
"-DNBIND_DUPLICATE_POINTERS"
|
||||
],
|
||||
|
||||
"xcode_settings": {
|
||||
"OTHER_CPLUSPLUSFLAGS": [ "<@(_cflags_cc)" ]
|
||||
}
|
||||
|
||||
} ],
|
||||
|
||||
[ "asmjs==1", {
|
||||
|
||||
"ldflags": [
|
||||
"--memory-init-file", "0",
|
||||
"-s", "PRECISE_F32=1",
|
||||
"-s", "TOTAL_MEMORY=134217728"
|
||||
],
|
||||
|
||||
"xcode_settings": {
|
||||
"OTHER_LDFLAGS": [ "<@(_ldflags)" ]
|
||||
}
|
||||
|
||||
} ]
|
||||
|
||||
]
|
||||
}
|
14
javascript/jest.config.js
Normal file
14
javascript/jest.config.js
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.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
setupFiles: ["./jest.setup.js", "./tests/tools.js"],
|
||||
testRegex: "/tests/.*\\.test\\.js$",
|
||||
watchman: false,
|
||||
};
|
24
javascript/jest.setup.js
Normal file
24
javascript/jest.setup.js
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
module.exports = async () => {
|
||||
if (process.env["SYNC"] == true && process.env["WASM"] == true) {
|
||||
global.Yoga = require("./dist/entrypoint/wasm-sync");
|
||||
} else if (process.env["SYNC"] == true) {
|
||||
global.Yoga = require("./dist/entrypoint/asmjs-sync");
|
||||
} else if (process.env["WASM"] == true) {
|
||||
global.Yoga = await require("./dist/entrypoint/wasm-async").loadYoga();
|
||||
} else {
|
||||
global.Yoga = await require("./dist/entrypoint/asmjs-async").loadYoga();
|
||||
}
|
||||
};
|
||||
|
||||
Object.defineProperty(global, "YGBENCHMARK", {
|
||||
get: () => global.test,
|
||||
});
|
143
javascript/just.config.js
Normal file
143
javascript/just.config.js
Normal file
@@ -0,0 +1,143 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
const {
|
||||
argv,
|
||||
copyTask,
|
||||
eslintTask,
|
||||
logger,
|
||||
jestTask,
|
||||
option,
|
||||
parallel,
|
||||
series,
|
||||
spawn,
|
||||
task,
|
||||
} = require("just-scripts");
|
||||
|
||||
const glob = require("glob");
|
||||
const which = require("which");
|
||||
|
||||
const node = process.execPath;
|
||||
|
||||
option("fix");
|
||||
|
||||
task(
|
||||
"prepare-for-build",
|
||||
parallel(
|
||||
babelTransformTask({ paths: ["src_js"], dest: "dist" }),
|
||||
copyTask({ paths: ["src_js/**/*.d.ts"], dest: "dist" }),
|
||||
emcmakeGenerateTask()
|
||||
)
|
||||
);
|
||||
|
||||
function defineFlavor(flavor, env) {
|
||||
task(`cmake-build:${flavor}`, cmakeBuildTask([flavor]));
|
||||
task(`jest:${flavor}`, jestTask({ env }));
|
||||
task(
|
||||
`test:${flavor}`,
|
||||
series("prepare-for-build", `cmake-build:${flavor}`, `jest:${flavor}`)
|
||||
);
|
||||
}
|
||||
|
||||
defineFlavor("asmjs-async", { WASM: 0, SYNC: 0 });
|
||||
defineFlavor("asmjs-sync", { WASM: 0, SYNC: 1 });
|
||||
defineFlavor("wasm-async", { WASM: 1, SYNC: 0 });
|
||||
defineFlavor("wasm-sync", { WASM: 1, SYNC: 1 });
|
||||
|
||||
task("cmake-build:all", cmakeBuildTask());
|
||||
task("cmake-build:async", cmakeBuildTask(["asmjs-async", "wasm-async"]));
|
||||
task("cmake-build:sync", cmakeBuildTask(["asmjs-sync", "wasm-sync"]));
|
||||
|
||||
task("build", series("prepare-for-build", "cmake-build:all"));
|
||||
|
||||
task(
|
||||
"test",
|
||||
series(
|
||||
"prepare-for-build",
|
||||
series("cmake-build:asmjs-async", "jest:asmjs-async"),
|
||||
series("cmake-build:asmjs-sync", "jest:asmjs-sync"),
|
||||
series("cmake-build:wasm-async", "jest:wasm-async"),
|
||||
series("cmake-build:wasm-sync", "jest:wasm-sync")
|
||||
)
|
||||
);
|
||||
|
||||
task(
|
||||
"benchmark",
|
||||
series("prepare-for-build", "cmake-build:sync", runBenchTask())
|
||||
);
|
||||
|
||||
task(
|
||||
"lint",
|
||||
series(eslintTask({ fix: argv().fix }), clangFormatTask({ fix: argv().fix }))
|
||||
);
|
||||
|
||||
function babelTransformTask(opts) {
|
||||
return () => {
|
||||
const args = [...opts.paths, "--source-maps", "--out-dir", opts.dest];
|
||||
logger.info(`Transforming [${opts.paths.join(",")}] to '${opts.dest}'`);
|
||||
|
||||
return spawn(node, [require.resolve("@babel/cli/bin/babel"), ...args]);
|
||||
};
|
||||
}
|
||||
|
||||
function runBenchTask() {
|
||||
return () => {
|
||||
const files = glob.sync("./tests/Benchmarks/**/*.js");
|
||||
const args = ["./tests/run-bench.js", ...files];
|
||||
logger.info(args.join(" "));
|
||||
|
||||
return spawn(node, args, { stdio: "inherit" });
|
||||
};
|
||||
}
|
||||
|
||||
function emcmakeGenerateTask() {
|
||||
return () => {
|
||||
const emcmake = which.sync("emcmake");
|
||||
const ninja = which.sync("ninja", { nothrow: true });
|
||||
const args = [
|
||||
"cmake",
|
||||
"-S",
|
||||
".",
|
||||
"-B",
|
||||
"build",
|
||||
...(ninja ? ["-G", "Ninja"] : []),
|
||||
];
|
||||
logger.info(["encmake", ...args].join(" "));
|
||||
|
||||
return spawn(emcmake, args);
|
||||
};
|
||||
}
|
||||
|
||||
function cmakeBuildTask(targets) {
|
||||
return () => {
|
||||
const cmake = which.sync("cmake");
|
||||
const args = [
|
||||
"--build",
|
||||
"build",
|
||||
...(targets ? ["--target", ...targets] : []),
|
||||
];
|
||||
logger.info(["cmake", ...args].join(" "));
|
||||
|
||||
return spawn(cmake, args, { stdio: "inherit" });
|
||||
};
|
||||
}
|
||||
|
||||
function clangFormatTask(opts) {
|
||||
return () => {
|
||||
const args = [
|
||||
...(opts.fix ? ["-i"] : ["--dry-run", "--Werror"]),
|
||||
...glob.sync("**/*.{h,hh,hpp,c,cpp,cc,m,mm}"),
|
||||
];
|
||||
logger.info(["clang-format", ...args].join(" "));
|
||||
|
||||
return spawn(node, [require.resolve("clang-format"), ...args], {
|
||||
stdio: "inherit",
|
||||
});
|
||||
};
|
||||
}
|
@@ -1,49 +1,55 @@
|
||||
{
|
||||
"name": "yoga-layout",
|
||||
"version": "1.9.3",
|
||||
"description": "Yoga is a cross-platform layout engine enabling maximum collaboration within your team by implementing an API many designers are familiar with, and opening it up to developers across different platforms.",
|
||||
"version": "2.0.0-beta.1",
|
||||
"description": "JavaScript bindings for the Yoga layout engine",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git@github.com:facebook/yoga.git"
|
||||
},
|
||||
"main": "./dist/entry-node",
|
||||
"browser": "./dist/entry-browser",
|
||||
"config": {
|
||||
"platform": "all"
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"browser": "./dist/entrypoint/wasm-async.js",
|
||||
"node": "./dist/entrypoint/wasm-async.js",
|
||||
"default": "./dist/entrypoint/asmjs-async.js"
|
||||
},
|
||||
"./sync": {
|
||||
"browser": "./dist/entrypoint/asmjs-sync.js",
|
||||
"node": "./dist/entrypoint/wasm-sync.js",
|
||||
"default": "./dist/entrypoint/asmjs-sync.js"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist/**",
|
||||
"src_js/**"
|
||||
],
|
||||
"scripts": {
|
||||
"which": "which",
|
||||
"autogypi": "autogypi",
|
||||
"node-gyp": "node-gyp",
|
||||
"emcc-path": "emcc-path",
|
||||
"is-monolithic": "test \"$(basename \"$(pwd)\")\" = javascript",
|
||||
"copy-sources": "! npm -s run is-monolithic || (rsync -r --checksum --delete ../yoga/ sources/yoga/)",
|
||||
"build:node": "npm run copy-sources && autogypi && node-gyp configure build",
|
||||
"build:browser": "npm run copy-sources && autogypi && node-gyp configure build --asmjs=1",
|
||||
"build:all": "npm run build:node && npm run build:browser",
|
||||
"build": "cross-env \"npm --if-present run build:$npm_package_config_platform\"",
|
||||
"test:node": "TEST_ENTRY=node time mocha --compilers js:babel-core/register --expose-gc -r tests/tools.js tests/Facebook.Yoga/**/*.js",
|
||||
"test:browser": "TEST_ENTRY=browser time mocha --compilers js:babel-core/register --expose-gc -r tests/tools.js tests/Facebook.Yoga/**/*.js",
|
||||
"test": "npm run test:node && npm run test:browser",
|
||||
"benchmark": "npm run prepublish && node tests/run-bench $(find tests/Benchmarks -name '*.js')",
|
||||
"install": "npm run build:node",
|
||||
"prepublish": "npm run copy-sources && babel sources --out-dir dist && flow-copy-source sources dist"
|
||||
},
|
||||
"dependencies": {
|
||||
"autogypi": "^0.2.2",
|
||||
"nbind": "^0.3.14",
|
||||
"node-gyp": "^3.6.2"
|
||||
"benchmark": "just benchmark",
|
||||
"build": "just build",
|
||||
"lint": "just lint",
|
||||
"lint:fix": "just lint --fix",
|
||||
"test": "just test",
|
||||
"test:asmjs-async": "just test:asmjs-async",
|
||||
"test:asmjs-sync": "just test:asmjs-sync",
|
||||
"test:wasm-async": "just test:wasm-async",
|
||||
"test:wasm-sync": "just test:wasm-sync"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-cli": "^6.24.1",
|
||||
"babel-core": "^6.25.0",
|
||||
"babel-plugin-replace-require": "^0.0.4",
|
||||
"babel-plugin-transform-flow-strip-types": "^6.22.0",
|
||||
"babel-preset-es2015": "^6.24.1",
|
||||
"babel-preset-stage-3": "^6.24.1",
|
||||
"cross-env": "^4.0.0",
|
||||
"flow-copy-source": "^2.0.7",
|
||||
"mocha": "^3.2.0"
|
||||
"@babel/cli": "^7.20.7",
|
||||
"@babel/core": "^7.20.7",
|
||||
"@babel/eslint-parser": "^7.19.1",
|
||||
"@babel/preset-env": "^7.20.2",
|
||||
"clang-format": "^1.8.0",
|
||||
"eslint": "^8.30.0",
|
||||
"eslint-config-prettier": "^8.5.0",
|
||||
"eslint-plugin-jest": "^27.1.7",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"glob": "^8.0.3",
|
||||
"jest": "^29.3.1",
|
||||
"just-scripts": "^2.1.0",
|
||||
"prettier": "^2.4.1",
|
||||
"which": "^3.0.0"
|
||||
}
|
||||
}
|
||||
|
@@ -1,211 +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.
|
||||
*/
|
||||
|
||||
// @generated by enums.py
|
||||
|
||||
// @flow
|
||||
// @format
|
||||
const CONSTANTS = {
|
||||
ALIGN_COUNT: 8,
|
||||
ALIGN_AUTO: 0,
|
||||
ALIGN_FLEX_START: 1,
|
||||
ALIGN_CENTER: 2,
|
||||
ALIGN_FLEX_END: 3,
|
||||
ALIGN_STRETCH: 4,
|
||||
ALIGN_BASELINE: 5,
|
||||
ALIGN_SPACE_BETWEEN: 6,
|
||||
ALIGN_SPACE_AROUND: 7,
|
||||
|
||||
DIMENSION_COUNT: 2,
|
||||
DIMENSION_WIDTH: 0,
|
||||
DIMENSION_HEIGHT: 1,
|
||||
|
||||
DIRECTION_COUNT: 3,
|
||||
DIRECTION_INHERIT: 0,
|
||||
DIRECTION_LTR: 1,
|
||||
DIRECTION_RTL: 2,
|
||||
|
||||
DISPLAY_COUNT: 2,
|
||||
DISPLAY_FLEX: 0,
|
||||
DISPLAY_NONE: 1,
|
||||
|
||||
EDGE_COUNT: 9,
|
||||
EDGE_LEFT: 0,
|
||||
EDGE_TOP: 1,
|
||||
EDGE_RIGHT: 2,
|
||||
EDGE_BOTTOM: 3,
|
||||
EDGE_START: 4,
|
||||
EDGE_END: 5,
|
||||
EDGE_HORIZONTAL: 6,
|
||||
EDGE_VERTICAL: 7,
|
||||
EDGE_ALL: 8,
|
||||
|
||||
EXPERIMENTAL_FEATURE_COUNT: 1,
|
||||
EXPERIMENTAL_FEATURE_WEB_FLEX_BASIS: 0,
|
||||
|
||||
FLEX_DIRECTION_COUNT: 4,
|
||||
FLEX_DIRECTION_COLUMN: 0,
|
||||
FLEX_DIRECTION_COLUMN_REVERSE: 1,
|
||||
FLEX_DIRECTION_ROW: 2,
|
||||
FLEX_DIRECTION_ROW_REVERSE: 3,
|
||||
|
||||
GUTTER_COUNT: 3,
|
||||
GUTTER_COLUMN: 0,
|
||||
GUTTER_ROW: 1,
|
||||
GUTTER_ALL: 2,
|
||||
|
||||
JUSTIFY_COUNT: 6,
|
||||
JUSTIFY_FLEX_START: 0,
|
||||
JUSTIFY_CENTER: 1,
|
||||
JUSTIFY_FLEX_END: 2,
|
||||
JUSTIFY_SPACE_BETWEEN: 3,
|
||||
JUSTIFY_SPACE_AROUND: 4,
|
||||
JUSTIFY_SPACE_EVENLY: 5,
|
||||
|
||||
LOG_LEVEL_COUNT: 6,
|
||||
LOG_LEVEL_ERROR: 0,
|
||||
LOG_LEVEL_WARN: 1,
|
||||
LOG_LEVEL_INFO: 2,
|
||||
LOG_LEVEL_DEBUG: 3,
|
||||
LOG_LEVEL_VERBOSE: 4,
|
||||
LOG_LEVEL_FATAL: 5,
|
||||
|
||||
MEASURE_MODE_COUNT: 3,
|
||||
MEASURE_MODE_UNDEFINED: 0,
|
||||
MEASURE_MODE_EXACTLY: 1,
|
||||
MEASURE_MODE_AT_MOST: 2,
|
||||
|
||||
NODE_TYPE_COUNT: 2,
|
||||
NODE_TYPE_DEFAULT: 0,
|
||||
NODE_TYPE_TEXT: 1,
|
||||
|
||||
OVERFLOW_COUNT: 3,
|
||||
OVERFLOW_VISIBLE: 0,
|
||||
OVERFLOW_HIDDEN: 1,
|
||||
OVERFLOW_SCROLL: 2,
|
||||
|
||||
POSITION_TYPE_COUNT: 3,
|
||||
POSITION_TYPE_STATIC: 0,
|
||||
POSITION_TYPE_RELATIVE: 1,
|
||||
POSITION_TYPE_ABSOLUTE: 2,
|
||||
|
||||
PRINT_OPTIONS_COUNT: 3,
|
||||
PRINT_OPTIONS_LAYOUT: 1,
|
||||
PRINT_OPTIONS_STYLE: 2,
|
||||
PRINT_OPTIONS_CHILDREN: 4,
|
||||
|
||||
UNIT_COUNT: 4,
|
||||
UNIT_UNDEFINED: 0,
|
||||
UNIT_POINT: 1,
|
||||
UNIT_PERCENT: 2,
|
||||
UNIT_AUTO: 3,
|
||||
|
||||
WRAP_COUNT: 3,
|
||||
WRAP_NO_WRAP: 0,
|
||||
WRAP_WRAP: 1,
|
||||
WRAP_WRAP_REVERSE: 2,
|
||||
};
|
||||
export type Yoga$Align =
|
||||
| typeof CONSTANTS.ALIGN_AUTO
|
||||
| typeof CONSTANTS.ALIGN_FLEX_START
|
||||
| typeof CONSTANTS.ALIGN_CENTER
|
||||
| typeof CONSTANTS.ALIGN_FLEX_END
|
||||
| typeof CONSTANTS.ALIGN_STRETCH
|
||||
| typeof CONSTANTS.ALIGN_BASELINE
|
||||
| typeof CONSTANTS.ALIGN_SPACE_BETWEEN
|
||||
| typeof CONSTANTS.ALIGN_SPACE_AROUND;
|
||||
|
||||
export type Yoga$Dimension =
|
||||
| typeof CONSTANTS.DIMENSION_WIDTH
|
||||
| typeof CONSTANTS.DIMENSION_HEIGHT;
|
||||
|
||||
export type Yoga$Direction =
|
||||
| typeof CONSTANTS.DIRECTION_INHERIT
|
||||
| typeof CONSTANTS.DIRECTION_LTR
|
||||
| typeof CONSTANTS.DIRECTION_RTL;
|
||||
|
||||
export type Yoga$Display =
|
||||
| typeof CONSTANTS.DISPLAY_FLEX
|
||||
| typeof CONSTANTS.DISPLAY_NONE;
|
||||
|
||||
export type Yoga$Edge =
|
||||
| typeof CONSTANTS.EDGE_LEFT
|
||||
| typeof CONSTANTS.EDGE_TOP
|
||||
| typeof CONSTANTS.EDGE_RIGHT
|
||||
| typeof CONSTANTS.EDGE_BOTTOM
|
||||
| typeof CONSTANTS.EDGE_START
|
||||
| typeof CONSTANTS.EDGE_END
|
||||
| typeof CONSTANTS.EDGE_HORIZONTAL
|
||||
| typeof CONSTANTS.EDGE_VERTICAL
|
||||
| typeof CONSTANTS.EDGE_ALL;
|
||||
|
||||
export type Yoga$ExperimentalFeature =
|
||||
| typeof CONSTANTS.EXPERIMENTAL_FEATURE_WEB_FLEX_BASIS;
|
||||
|
||||
export type Yoga$FlexDirection =
|
||||
| typeof CONSTANTS.FLEX_DIRECTION_COLUMN
|
||||
| typeof CONSTANTS.FLEX_DIRECTION_COLUMN_REVERSE
|
||||
| typeof CONSTANTS.FLEX_DIRECTION_ROW
|
||||
| typeof CONSTANTS.FLEX_DIRECTION_ROW_REVERSE;
|
||||
|
||||
export type Yoga$Gutter =
|
||||
| typeof CONSTANTS.GUTTER_COLUMN
|
||||
| typeof CONSTANTS.GUTTER_ROW
|
||||
| typeof CONSTANTS.GUTTER_ALL;
|
||||
|
||||
export type Yoga$Justify =
|
||||
| typeof CONSTANTS.JUSTIFY_FLEX_START
|
||||
| typeof CONSTANTS.JUSTIFY_CENTER
|
||||
| typeof CONSTANTS.JUSTIFY_FLEX_END
|
||||
| typeof CONSTANTS.JUSTIFY_SPACE_BETWEEN
|
||||
| typeof CONSTANTS.JUSTIFY_SPACE_AROUND
|
||||
| typeof CONSTANTS.JUSTIFY_SPACE_EVENLY;
|
||||
|
||||
export type Yoga$LogLevel =
|
||||
| typeof CONSTANTS.LOG_LEVEL_ERROR
|
||||
| typeof CONSTANTS.LOG_LEVEL_WARN
|
||||
| typeof CONSTANTS.LOG_LEVEL_INFO
|
||||
| typeof CONSTANTS.LOG_LEVEL_DEBUG
|
||||
| typeof CONSTANTS.LOG_LEVEL_VERBOSE
|
||||
| typeof CONSTANTS.LOG_LEVEL_FATAL;
|
||||
|
||||
export type Yoga$MeasureMode =
|
||||
| typeof CONSTANTS.MEASURE_MODE_UNDEFINED
|
||||
| typeof CONSTANTS.MEASURE_MODE_EXACTLY
|
||||
| typeof CONSTANTS.MEASURE_MODE_AT_MOST;
|
||||
|
||||
export type Yoga$NodeType =
|
||||
| typeof CONSTANTS.NODE_TYPE_DEFAULT
|
||||
| typeof CONSTANTS.NODE_TYPE_TEXT;
|
||||
|
||||
export type Yoga$Overflow =
|
||||
| typeof CONSTANTS.OVERFLOW_VISIBLE
|
||||
| typeof CONSTANTS.OVERFLOW_HIDDEN
|
||||
| typeof CONSTANTS.OVERFLOW_SCROLL;
|
||||
|
||||
export type Yoga$PositionType =
|
||||
| typeof CONSTANTS.POSITION_TYPE_STATIC
|
||||
| typeof CONSTANTS.POSITION_TYPE_RELATIVE
|
||||
| typeof CONSTANTS.POSITION_TYPE_ABSOLUTE;
|
||||
|
||||
export type Yoga$PrintOptions =
|
||||
| typeof CONSTANTS.PRINT_OPTIONS_LAYOUT
|
||||
| typeof CONSTANTS.PRINT_OPTIONS_STYLE
|
||||
| typeof CONSTANTS.PRINT_OPTIONS_CHILDREN;
|
||||
|
||||
export type Yoga$Unit =
|
||||
| typeof CONSTANTS.UNIT_UNDEFINED
|
||||
| typeof CONSTANTS.UNIT_POINT
|
||||
| typeof CONSTANTS.UNIT_PERCENT
|
||||
| typeof CONSTANTS.UNIT_AUTO;
|
||||
|
||||
export type Yoga$Wrap =
|
||||
| typeof CONSTANTS.WRAP_NO_WRAP
|
||||
| typeof CONSTANTS.WRAP_WRAP
|
||||
| typeof CONSTANTS.WRAP_WRAP_REVERSE;
|
||||
|
||||
module.exports = CONSTANTS;
|
@@ -1,55 +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.
|
||||
*
|
||||
* @flow
|
||||
* @format
|
||||
*/
|
||||
|
||||
const Yoga = require('./entry-common');
|
||||
const nbind = require('../build/Release/nbind.js');
|
||||
|
||||
let ran = false;
|
||||
let ret = null;
|
||||
|
||||
nbind({}, function(err, result) {
|
||||
if (ran) {
|
||||
return;
|
||||
}
|
||||
|
||||
ran = true;
|
||||
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
ret = result;
|
||||
});
|
||||
|
||||
if (!ran) {
|
||||
throw new Error(
|
||||
"Failed to load the yoga module - it needed to be loaded synchronously, but didn't",
|
||||
);
|
||||
}
|
||||
|
||||
// $FlowFixMe ret will not be null here
|
||||
module.exports = Yoga(ret.bind, ret.lib);
|
||||
|
||||
export type {
|
||||
Yoga$Justify,
|
||||
Yoga$Align,
|
||||
Yoga$FlexDirection,
|
||||
Yoga$Direction,
|
||||
Yoga$Wrap,
|
||||
Yoga$Gutter,
|
||||
Yoga$Edge,
|
||||
Yoga$Display,
|
||||
Yoga$Unit,
|
||||
Yoga$Overflow,
|
||||
Yoga$PositionType,
|
||||
Yoga$ExperimentalFeature,
|
||||
} from './YGEnums.js';
|
||||
|
||||
export type {Yoga$Node, Yoga$Config} from './entry-common';
|
@@ -1,360 +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.
|
||||
*
|
||||
* @flow
|
||||
* @format
|
||||
*/
|
||||
|
||||
|
||||
const CONSTANTS = require('./YGEnums');
|
||||
import type {
|
||||
Yoga$Edge,
|
||||
Yoga$Wrap,
|
||||
Yoga$Align,
|
||||
Yoga$FlexDirection,
|
||||
Yoga$Gap,
|
||||
Yoga$Direction,
|
||||
Yoga$PositionType,
|
||||
Yoga$Overflow,
|
||||
Yoga$Justify,
|
||||
Yoga$Display,
|
||||
Yoga$ExperimentalFeature,
|
||||
} from './YGEnums';
|
||||
|
||||
class Layout {
|
||||
left: number;
|
||||
right: number;
|
||||
top: number;
|
||||
bottom: number;
|
||||
width: number;
|
||||
height: number;
|
||||
|
||||
constructor(left, right, top, bottom, width, height) {
|
||||
this.left = left;
|
||||
this.right = right;
|
||||
this.top = top;
|
||||
this.bottom = bottom;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
fromJS(expose) {
|
||||
expose(
|
||||
this.left,
|
||||
this.right,
|
||||
this.top,
|
||||
this.bottom,
|
||||
this.width,
|
||||
this.height,
|
||||
);
|
||||
}
|
||||
|
||||
toString() {
|
||||
return `<Layout#${this.left}:${this.right};${this.top}:${this.bottom};${
|
||||
this.width
|
||||
}:${this.height}>`;
|
||||
}
|
||||
}
|
||||
|
||||
class Size {
|
||||
static fromJS({width, height}) {
|
||||
return new Size(width, height);
|
||||
}
|
||||
|
||||
width: number;
|
||||
height: number;
|
||||
|
||||
constructor(width, height) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
fromJS(expose) {
|
||||
expose(this.width, this.height);
|
||||
}
|
||||
|
||||
toString() {
|
||||
return `<Size#${this.width}x${this.height}>`;
|
||||
}
|
||||
}
|
||||
|
||||
class Value {
|
||||
unit: number;
|
||||
value: number;
|
||||
|
||||
constructor(unit, value) {
|
||||
this.unit = unit;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
fromJS(expose) {
|
||||
expose(this.unit, this.value);
|
||||
}
|
||||
|
||||
toString() {
|
||||
switch (this.unit) {
|
||||
case CONSTANTS.UNIT_POINT:
|
||||
return String(this.value);
|
||||
case CONSTANTS.UNIT_PERCENT:
|
||||
return `${this.value}%`;
|
||||
case CONSTANTS.UNIT_AUTO:
|
||||
return 'auto';
|
||||
default: {
|
||||
return `${this.value}?`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
valueOf() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
|
||||
export type Yoga$Config = {
|
||||
isExperimentalFeatureEnabled(feature: Yoga$ExperimentalFeature): boolean,
|
||||
setExperimentalFeatureEnabled(
|
||||
feature: Yoga$ExperimentalFeature,
|
||||
enabled: boolean,
|
||||
): void,
|
||||
setPointScaleFactor(factor: number): void,
|
||||
};
|
||||
|
||||
export type Yoga$Node = {
|
||||
calculateLayout(
|
||||
width?: number,
|
||||
height?: number,
|
||||
direction?: Yoga$Direction,
|
||||
): void,
|
||||
copyStyle(node: Yoga$Node): void,
|
||||
free(): void,
|
||||
freeRecursive(): void,
|
||||
getAlignContent(): Yoga$Align,
|
||||
getAlignItems(): Yoga$Align,
|
||||
getAlignSelf(): Yoga$Align,
|
||||
getAspectRatio(): number,
|
||||
getBorder(edge: Yoga$Edge): number,
|
||||
getChild(index: number): Yoga$Node,
|
||||
getChildCount(): number,
|
||||
getComputedBorder(edge: Yoga$Edge): number,
|
||||
getComputedBottom(): number,
|
||||
getComputedHeight(): number,
|
||||
getComputedLayout(): Layout,
|
||||
getComputedLeft(): number,
|
||||
getComputedMargin(edge: Yoga$Edge): number,
|
||||
getComputedPadding(edge: Yoga$Edge): number,
|
||||
getComputedRight(): number,
|
||||
getComputedTop(): number,
|
||||
getComputedWidth(): number,
|
||||
getDisplay(): Yoga$Display,
|
||||
getFlexBasis(): number,
|
||||
getFlexDirection(): Yoga$FlexDirection,
|
||||
getFlexGrow(): number,
|
||||
getFlexShrink(): number,
|
||||
getFlexWrap(): Yoga$Wrap,
|
||||
getHeight(): Value,
|
||||
getJustifyContent(): Yoga$Justify,
|
||||
getGap(gutter: Yoga$Gutter): Value,
|
||||
getMargin(edge: Yoga$Edge): Value,
|
||||
getMaxHeight(): Value,
|
||||
getMaxWidth(): Value,
|
||||
getMinHeight(): Value,
|
||||
getMinWidth(): Value,
|
||||
getOverflow(): Yoga$Overflow,
|
||||
getPadding(edge: Yoga$Edge): Value,
|
||||
getParent(): ?Yoga$Node,
|
||||
getPosition(edge: Yoga$Edge): Value,
|
||||
getPositionType(): Yoga$PositionType,
|
||||
getWidth(): Value,
|
||||
insertChild(child: Yoga$Node, index: number): void,
|
||||
isDirty(): boolean,
|
||||
markDirty(): void,
|
||||
removeChild(child: Yoga$Node): void,
|
||||
reset(): void,
|
||||
setAlignContent(alignContent: Yoga$Align): void,
|
||||
setAlignItems(alignItems: Yoga$Align): void,
|
||||
setAlignSelf(alignSelf: Yoga$Align): void,
|
||||
setAspectRatio(aspectRatio: number): void,
|
||||
setBorder(edge: Yoga$Edge, borderWidth: number): void,
|
||||
setDisplay(display: Yoga$Display): void,
|
||||
setFlex(flex: number): void,
|
||||
setFlexBasis(flexBasis: number | string): void,
|
||||
setFlexBasisPercent(flexBasis: number): void,
|
||||
setFlexBasisAuto(): void,
|
||||
setFlexDirection(flexDirection: Yoga$FlexDirection): void,
|
||||
setFlexGrow(flexGrow: number): void,
|
||||
setFlexShrink(flexShrink: number): void,
|
||||
setFlexWrap(flexWrap: Yoga$Wrap): void,
|
||||
setHeight(height: number | string): void,
|
||||
setHeightAuto(): void,
|
||||
setHeightPercent(height: number): void,
|
||||
setJustifyContent(justifyContent: Yoga$Justify): void,
|
||||
setGap(gutter: Yoga$Gutter, gapLength: number): Value,
|
||||
setMargin(edge: Yoga$Edge, margin: number): void,
|
||||
setMarginAuto(edge: Yoga$Edge): void,
|
||||
setMarginPercent(edge: Yoga$Edge, margin: number): void,
|
||||
setMaxHeight(maxHeight: number | string): void,
|
||||
setMaxHeightPercent(maxHeight: number): void,
|
||||
setMaxWidth(maxWidth: number | string): void,
|
||||
setMaxWidthPercent(maxWidth: number): void,
|
||||
setMeasureFunc(measureFunc: ?Function): void,
|
||||
setMinHeight(minHeight: number | string): void,
|
||||
setMinHeightPercent(minHeight: number): void,
|
||||
setMinWidth(minWidth: number | string): void,
|
||||
setMinWidthPercent(minWidth: number): void,
|
||||
setOverflow(overflow: Yoga$Overflow): void,
|
||||
setPadding(edge: Yoga$Edge, padding: number | string): void,
|
||||
setPaddingPercent(edge: Yoga$Edge, padding: number): void,
|
||||
setPosition(edge: Yoga$Edge, position: number | string): void,
|
||||
setPositionPercent(edge: Yoga$Edge, position: number): void,
|
||||
setPositionType(positionType: Yoga$PositionType): void,
|
||||
setWidth(width: number | string): void,
|
||||
setWidthAuto(): void,
|
||||
setWidthPercent(width: number): void,
|
||||
unsetMeasureFun(): void,
|
||||
};
|
||||
|
||||
type Yoga = {
|
||||
Config: {
|
||||
create(): Yoga$Config,
|
||||
destroy(config: Yoga$Config): any,
|
||||
},
|
||||
Node: {
|
||||
create(): Yoga$Node,
|
||||
createDefault(): Yoga$Node,
|
||||
createWithConfig(config: Yoga$Config): Yoga$Node,
|
||||
destroy(node: Yoga$Node): any,
|
||||
},
|
||||
Layout: Layout,
|
||||
Size: Size,
|
||||
Value: Value,
|
||||
getInstanceCount(): number,
|
||||
...typeof CONSTANTS,
|
||||
};
|
||||
|
||||
module.exports = (bind: any, lib: any): Yoga => {
|
||||
function patch(prototype, name, fn) {
|
||||
let original = prototype[name];
|
||||
|
||||
prototype[name] = function(...args) {
|
||||
return fn.call(this, original, ...args);
|
||||
};
|
||||
}
|
||||
|
||||
for (let fnName of [
|
||||
'setPosition',
|
||||
'setMargin',
|
||||
'setFlexBasis',
|
||||
'setWidth',
|
||||
'setHeight',
|
||||
'setMinWidth',
|
||||
'setMinHeight',
|
||||
'setMaxWidth',
|
||||
'setMaxHeight',
|
||||
'setPadding',
|
||||
]) {
|
||||
let methods = {
|
||||
[CONSTANTS.UNIT_POINT]: lib.Node.prototype[fnName],
|
||||
[CONSTANTS.UNIT_PERCENT]: lib.Node.prototype[`${fnName}Percent`],
|
||||
[CONSTANTS.UNIT_AUTO]: lib.Node.prototype[`${fnName}Auto`],
|
||||
};
|
||||
|
||||
patch(lib.Node.prototype, fnName, function(original, ...args) {
|
||||
// We patch all these functions to add support for the following calls:
|
||||
// .setWidth(100) / .setWidth("100%") / .setWidth(.getWidth()) / .setWidth("auto")
|
||||
|
||||
let value = args.pop();
|
||||
let unit, asNumber;
|
||||
|
||||
if (value === 'auto') {
|
||||
unit = CONSTANTS.UNIT_AUTO;
|
||||
asNumber = undefined;
|
||||
} else if (value instanceof Value) {
|
||||
unit = value.unit;
|
||||
asNumber = value.valueOf();
|
||||
} else {
|
||||
unit =
|
||||
typeof value === 'string' && value.endsWith('%')
|
||||
? CONSTANTS.UNIT_PERCENT
|
||||
: CONSTANTS.UNIT_POINT;
|
||||
asNumber = parseFloat(value);
|
||||
if (!Number.isNaN(value) && Number.isNaN(asNumber)) {
|
||||
throw new Error(`Invalid value ${value} for ${fnName}`);
|
||||
}
|
||||
}
|
||||
|
||||
if (!methods[unit])
|
||||
throw new Error(
|
||||
`Failed to execute "${fnName}": Unsupported unit '${value}'`,
|
||||
);
|
||||
|
||||
if (asNumber !== undefined) {
|
||||
return methods[unit].call(this, ...args, asNumber);
|
||||
} else {
|
||||
return methods[unit].call(this, ...args);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
patch(lib.Config.prototype, 'free', function() {
|
||||
// Since we handle the memory allocation ourselves (via lib.Config.create),
|
||||
// we also need to handle the deallocation
|
||||
lib.Config.destroy(this);
|
||||
});
|
||||
|
||||
patch(lib.Node, 'create', function(_, config) {
|
||||
// We decide the constructor we want to call depending on the parameters
|
||||
return config
|
||||
? lib.Node.createWithConfig(config)
|
||||
: lib.Node.createDefault();
|
||||
});
|
||||
|
||||
patch(lib.Node.prototype, 'free', function() {
|
||||
// Since we handle the memory allocation ourselves (via lib.Node.create),
|
||||
// we also need to handle the deallocation
|
||||
lib.Node.destroy(this);
|
||||
});
|
||||
|
||||
patch(lib.Node.prototype, 'freeRecursive', function() {
|
||||
for (let t = 0, T = this.getChildCount(); t < T; ++t) {
|
||||
this.getChild(0).freeRecursive();
|
||||
}
|
||||
this.free();
|
||||
});
|
||||
|
||||
patch(lib.Node.prototype, 'setMeasureFunc', function(original, measureFunc) {
|
||||
// This patch is just a convenience patch, since it helps write more
|
||||
// idiomatic source code (such as .setMeasureFunc(null))
|
||||
// We also automatically convert the return value of the measureFunc
|
||||
// to a Size object, so that we can return anything that has .width and
|
||||
// .height properties
|
||||
if (measureFunc) {
|
||||
return original.call(this, (...args) =>
|
||||
Size.fromJS(measureFunc(...args)),
|
||||
);
|
||||
} else {
|
||||
return this.unsetMeasureFunc();
|
||||
}
|
||||
});
|
||||
|
||||
patch(lib.Node.prototype, 'calculateLayout', function(
|
||||
original,
|
||||
width = NaN,
|
||||
height = NaN,
|
||||
direction = CONSTANTS.DIRECTION_LTR,
|
||||
) {
|
||||
// Just a small patch to add support for the function default parameters
|
||||
return original.call(this, width, height, direction);
|
||||
});
|
||||
|
||||
return {
|
||||
Config: lib.Config,
|
||||
Node: lib.Node,
|
||||
Layout: bind('Layout', Layout),
|
||||
Size: bind('Size', Size),
|
||||
Value: bind('Value', Value),
|
||||
...CONSTANTS,
|
||||
};
|
||||
};
|
@@ -1,30 +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.
|
||||
*
|
||||
* @flow
|
||||
* @format
|
||||
*/
|
||||
|
||||
const Yoga = require('./entry-common');
|
||||
const nbind = require('nbind');
|
||||
const {bind, lib} = nbind.init(__dirname + '/../');
|
||||
module.exports = Yoga(bind, lib);
|
||||
export type {
|
||||
Yoga$Justify,
|
||||
Yoga$Align,
|
||||
Yoga$FlexDirection,
|
||||
Yoga$Direction,
|
||||
Yoga$Wrap,
|
||||
Yoga$Gutter,
|
||||
Yoga$Edge,
|
||||
Yoga$Display,
|
||||
Yoga$Unit,
|
||||
Yoga$Overflow,
|
||||
Yoga$PositionType,
|
||||
Yoga$ExperimentalFeature,
|
||||
} from './YGEnums.js';
|
||||
|
||||
export type {Yoga$Node, Yoga$Config} from './entry-common';
|
@@ -1,175 +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.
|
||||
*/
|
||||
|
||||
#include <yoga/Yoga.h>
|
||||
|
||||
#include "./Node.hh"
|
||||
#include "./Layout.hh"
|
||||
#include "./Size.hh"
|
||||
#include "./Value.hh"
|
||||
#include "./Config.hh"
|
||||
|
||||
#include <nbind/nbind.h>
|
||||
|
||||
NBIND_CLASS(Size) {
|
||||
construct<>();
|
||||
construct<double, double>();
|
||||
}
|
||||
|
||||
NBIND_CLASS(Layout) {
|
||||
construct<>();
|
||||
}
|
||||
|
||||
NBIND_CLASS(Value) {
|
||||
construct<>();
|
||||
construct<int, double>();
|
||||
}
|
||||
|
||||
NBIND_CLASS(Config) {
|
||||
method(create);
|
||||
|
||||
method(destroy);
|
||||
|
||||
method(setExperimentalFeatureEnabled);
|
||||
method(setPointScaleFactor);
|
||||
|
||||
method(isExperimentalFeatureEnabled);
|
||||
}
|
||||
|
||||
NBIND_CLASS(Node) {
|
||||
method(createDefault);
|
||||
method(createWithConfig);
|
||||
method(destroy);
|
||||
|
||||
method(reset);
|
||||
|
||||
method(copyStyle);
|
||||
|
||||
method(setPositionType);
|
||||
method(setPosition);
|
||||
method(setPositionPercent);
|
||||
|
||||
method(setAlignContent);
|
||||
method(setAlignItems);
|
||||
method(setAlignSelf);
|
||||
method(setFlexDirection);
|
||||
method(setFlexWrap);
|
||||
method(setJustifyContent);
|
||||
|
||||
method(setMargin);
|
||||
method(setMarginPercent);
|
||||
method(setMarginAuto);
|
||||
|
||||
method(setOverflow);
|
||||
method(setDisplay);
|
||||
|
||||
method(setFlex);
|
||||
method(setFlexBasis);
|
||||
method(setFlexBasisPercent);
|
||||
method(setFlexBasisAuto);
|
||||
method(setFlexGrow);
|
||||
method(setFlexShrink);
|
||||
|
||||
method(setWidth);
|
||||
method(setWidthPercent);
|
||||
method(setWidthAuto);
|
||||
method(setHeight);
|
||||
method(setHeightPercent);
|
||||
method(setHeightAuto);
|
||||
|
||||
method(setMinWidth);
|
||||
method(setMinWidthPercent);
|
||||
method(setMinHeight);
|
||||
method(setMinHeightPercent);
|
||||
|
||||
method(setMaxWidth);
|
||||
method(setMaxWidthPercent);
|
||||
method(setMaxHeight);
|
||||
method(setMaxHeightPercent);
|
||||
|
||||
method(setAspectRatio);
|
||||
|
||||
method(setBorder);
|
||||
|
||||
method(setPadding);
|
||||
method(setPaddingPercent);
|
||||
|
||||
method(setGap);
|
||||
|
||||
method(getPositionType);
|
||||
method(getPosition);
|
||||
|
||||
method(getAlignContent);
|
||||
method(getAlignItems);
|
||||
method(getAlignSelf);
|
||||
method(getFlexDirection);
|
||||
method(getFlexWrap);
|
||||
method(getJustifyContent);
|
||||
|
||||
method(getMargin);
|
||||
|
||||
method(getFlexBasis);
|
||||
method(getFlexGrow);
|
||||
method(getFlexShrink);
|
||||
|
||||
method(getWidth);
|
||||
method(getHeight);
|
||||
|
||||
method(getMinWidth);
|
||||
method(getMinHeight);
|
||||
|
||||
method(getMaxWidth);
|
||||
method(getMaxHeight);
|
||||
|
||||
method(getAspectRatio);
|
||||
|
||||
method(getBorder);
|
||||
|
||||
method(getOverflow);
|
||||
method(getDisplay);
|
||||
|
||||
method(getPadding);
|
||||
|
||||
method(getGap);
|
||||
|
||||
method(insertChild);
|
||||
method(removeChild);
|
||||
|
||||
method(getChildCount);
|
||||
|
||||
method(getParent);
|
||||
method(getChild);
|
||||
|
||||
method(isReferenceBaseline);
|
||||
method(setIsReferenceBaseline);
|
||||
|
||||
method(setMeasureFunc);
|
||||
method(unsetMeasureFunc);
|
||||
|
||||
method(setDirtiedFunc);
|
||||
method(unsetDirtiedFunc);
|
||||
|
||||
method(markDirty);
|
||||
method(isDirty);
|
||||
|
||||
method(calculateLayout);
|
||||
|
||||
method(getComputedLeft);
|
||||
method(getComputedRight);
|
||||
|
||||
method(getComputedTop);
|
||||
method(getComputedBottom);
|
||||
|
||||
method(getComputedWidth);
|
||||
method(getComputedHeight);
|
||||
|
||||
method(getComputedLayout);
|
||||
|
||||
method(getComputedMargin);
|
||||
method(getComputedBorder);
|
||||
method(getComputedPadding);
|
||||
}
|
15
javascript/src_js/entrypoint/_entryAsync.js
Normal file
15
javascript/src_js/entrypoint/_entryAsync.js
Normal file
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
const wrapAsm = require("../wrapAsm");
|
||||
|
||||
module.exports = (loadAsm) => ({
|
||||
loadYoga: () => loadAsm().then(wrapAsm),
|
||||
...require("../generated/YGEnums"),
|
||||
});
|
11
javascript/src_js/entrypoint/_entrySync.js
Normal file
11
javascript/src_js/entrypoint/_entrySync.js
Normal file
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
const wrapAsm = require("../wrapAsm");
|
||||
module.exports = (asm) => wrapAsm(asm());
|
11
javascript/src_js/entrypoint/asmjs-async.js
Normal file
11
javascript/src_js/entrypoint/asmjs-async.js
Normal file
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
const asm = require("../build/asmjs-async");
|
||||
module.exports = require("./_entryAsync")(asm);
|
11
javascript/src_js/entrypoint/asmjs-sync.js
Normal file
11
javascript/src_js/entrypoint/asmjs-sync.js
Normal file
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
const asm = require("../build/asmjs-sync");
|
||||
module.exports = require("./_entrySync")(asm);
|
11
javascript/src_js/entrypoint/wasm-async.js
Normal file
11
javascript/src_js/entrypoint/wasm-async.js
Normal file
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
const asm = require("../build/wasm-async");
|
||||
module.exports = require("./_entryAsync")(asm);
|
11
javascript/src_js/entrypoint/wasm-sync.js
Normal file
11
javascript/src_js/entrypoint/wasm-sync.js
Normal file
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
const asm = require("../build/wasm-sync");
|
||||
module.exports = require("./_entrySync")(asm);
|
320
javascript/src_js/generated/YGEnums.d.ts
vendored
Normal file
320
javascript/src_js/generated/YGEnums.d.ts
vendored
Normal file
@@ -0,0 +1,320 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// @generated by enums.py
|
||||
|
||||
type ALIGN_AUTO = 0 & ['ALIGN']
|
||||
export const ALIGN_AUTO: ALIGN_AUTO;
|
||||
|
||||
type ALIGN_FLEX_START = 1 & ['ALIGN']
|
||||
export const ALIGN_FLEX_START: ALIGN_FLEX_START;
|
||||
|
||||
type ALIGN_CENTER = 2 & ['ALIGN']
|
||||
export const ALIGN_CENTER: ALIGN_CENTER;
|
||||
|
||||
type ALIGN_FLEX_END = 3 & ['ALIGN']
|
||||
export const ALIGN_FLEX_END: ALIGN_FLEX_END;
|
||||
|
||||
type ALIGN_STRETCH = 4 & ['ALIGN']
|
||||
export const ALIGN_STRETCH: ALIGN_STRETCH;
|
||||
|
||||
type ALIGN_BASELINE = 5 & ['ALIGN']
|
||||
export const ALIGN_BASELINE: ALIGN_BASELINE;
|
||||
|
||||
type ALIGN_SPACE_BETWEEN = 6 & ['ALIGN']
|
||||
export const ALIGN_SPACE_BETWEEN: ALIGN_SPACE_BETWEEN;
|
||||
|
||||
type ALIGN_SPACE_AROUND = 7 & ['ALIGN']
|
||||
export const ALIGN_SPACE_AROUND: ALIGN_SPACE_AROUND;
|
||||
|
||||
|
||||
type DIMENSION_WIDTH = 0 & ['DIMENSION']
|
||||
export const DIMENSION_WIDTH: DIMENSION_WIDTH;
|
||||
|
||||
type DIMENSION_HEIGHT = 1 & ['DIMENSION']
|
||||
export const DIMENSION_HEIGHT: DIMENSION_HEIGHT;
|
||||
|
||||
|
||||
type DIRECTION_INHERIT = 0 & ['DIRECTION']
|
||||
export const DIRECTION_INHERIT: DIRECTION_INHERIT;
|
||||
|
||||
type DIRECTION_LTR = 1 & ['DIRECTION']
|
||||
export const DIRECTION_LTR: DIRECTION_LTR;
|
||||
|
||||
type DIRECTION_RTL = 2 & ['DIRECTION']
|
||||
export const DIRECTION_RTL: DIRECTION_RTL;
|
||||
|
||||
|
||||
type DISPLAY_FLEX = 0 & ['DISPLAY']
|
||||
export const DISPLAY_FLEX: DISPLAY_FLEX;
|
||||
|
||||
type DISPLAY_NONE = 1 & ['DISPLAY']
|
||||
export const DISPLAY_NONE: DISPLAY_NONE;
|
||||
|
||||
|
||||
type EDGE_LEFT = 0 & ['EDGE']
|
||||
export const EDGE_LEFT: EDGE_LEFT;
|
||||
|
||||
type EDGE_TOP = 1 & ['EDGE']
|
||||
export const EDGE_TOP: EDGE_TOP;
|
||||
|
||||
type EDGE_RIGHT = 2 & ['EDGE']
|
||||
export const EDGE_RIGHT: EDGE_RIGHT;
|
||||
|
||||
type EDGE_BOTTOM = 3 & ['EDGE']
|
||||
export const EDGE_BOTTOM: EDGE_BOTTOM;
|
||||
|
||||
type EDGE_START = 4 & ['EDGE']
|
||||
export const EDGE_START: EDGE_START;
|
||||
|
||||
type EDGE_END = 5 & ['EDGE']
|
||||
export const EDGE_END: EDGE_END;
|
||||
|
||||
type EDGE_HORIZONTAL = 6 & ['EDGE']
|
||||
export const EDGE_HORIZONTAL: EDGE_HORIZONTAL;
|
||||
|
||||
type EDGE_VERTICAL = 7 & ['EDGE']
|
||||
export const EDGE_VERTICAL: EDGE_VERTICAL;
|
||||
|
||||
type EDGE_ALL = 8 & ['EDGE']
|
||||
export const EDGE_ALL: EDGE_ALL;
|
||||
|
||||
|
||||
type EXPERIMENTAL_FEATURE_WEB_FLEX_BASIS = 0 & ['EXPERIMENTAL_FEATURE']
|
||||
export const EXPERIMENTAL_FEATURE_WEB_FLEX_BASIS: EXPERIMENTAL_FEATURE_WEB_FLEX_BASIS;
|
||||
|
||||
|
||||
type FLEX_DIRECTION_COLUMN = 0 & ['FLEX_DIRECTION']
|
||||
export const FLEX_DIRECTION_COLUMN: FLEX_DIRECTION_COLUMN;
|
||||
|
||||
type FLEX_DIRECTION_COLUMN_REVERSE = 1 & ['FLEX_DIRECTION']
|
||||
export const FLEX_DIRECTION_COLUMN_REVERSE: FLEX_DIRECTION_COLUMN_REVERSE;
|
||||
|
||||
type FLEX_DIRECTION_ROW = 2 & ['FLEX_DIRECTION']
|
||||
export const FLEX_DIRECTION_ROW: FLEX_DIRECTION_ROW;
|
||||
|
||||
type FLEX_DIRECTION_ROW_REVERSE = 3 & ['FLEX_DIRECTION']
|
||||
export const FLEX_DIRECTION_ROW_REVERSE: FLEX_DIRECTION_ROW_REVERSE;
|
||||
|
||||
|
||||
type GUTTER_COLUMN = 0 & ['GUTTER']
|
||||
export const GUTTER_COLUMN: GUTTER_COLUMN;
|
||||
|
||||
type GUTTER_ROW = 1 & ['GUTTER']
|
||||
export const GUTTER_ROW: GUTTER_ROW;
|
||||
|
||||
type GUTTER_ALL = 2 & ['GUTTER']
|
||||
export const GUTTER_ALL: GUTTER_ALL;
|
||||
|
||||
|
||||
type JUSTIFY_FLEX_START = 0 & ['JUSTIFY']
|
||||
export const JUSTIFY_FLEX_START: JUSTIFY_FLEX_START;
|
||||
|
||||
type JUSTIFY_CENTER = 1 & ['JUSTIFY']
|
||||
export const JUSTIFY_CENTER: JUSTIFY_CENTER;
|
||||
|
||||
type JUSTIFY_FLEX_END = 2 & ['JUSTIFY']
|
||||
export const JUSTIFY_FLEX_END: JUSTIFY_FLEX_END;
|
||||
|
||||
type JUSTIFY_SPACE_BETWEEN = 3 & ['JUSTIFY']
|
||||
export const JUSTIFY_SPACE_BETWEEN: JUSTIFY_SPACE_BETWEEN;
|
||||
|
||||
type JUSTIFY_SPACE_AROUND = 4 & ['JUSTIFY']
|
||||
export const JUSTIFY_SPACE_AROUND: JUSTIFY_SPACE_AROUND;
|
||||
|
||||
type JUSTIFY_SPACE_EVENLY = 5 & ['JUSTIFY']
|
||||
export const JUSTIFY_SPACE_EVENLY: JUSTIFY_SPACE_EVENLY;
|
||||
|
||||
|
||||
type LOG_LEVEL_ERROR = 0 & ['LOG_LEVEL']
|
||||
export const LOG_LEVEL_ERROR: LOG_LEVEL_ERROR;
|
||||
|
||||
type LOG_LEVEL_WARN = 1 & ['LOG_LEVEL']
|
||||
export const LOG_LEVEL_WARN: LOG_LEVEL_WARN;
|
||||
|
||||
type LOG_LEVEL_INFO = 2 & ['LOG_LEVEL']
|
||||
export const LOG_LEVEL_INFO: LOG_LEVEL_INFO;
|
||||
|
||||
type LOG_LEVEL_DEBUG = 3 & ['LOG_LEVEL']
|
||||
export const LOG_LEVEL_DEBUG: LOG_LEVEL_DEBUG;
|
||||
|
||||
type LOG_LEVEL_VERBOSE = 4 & ['LOG_LEVEL']
|
||||
export const LOG_LEVEL_VERBOSE: LOG_LEVEL_VERBOSE;
|
||||
|
||||
type LOG_LEVEL_FATAL = 5 & ['LOG_LEVEL']
|
||||
export const LOG_LEVEL_FATAL: LOG_LEVEL_FATAL;
|
||||
|
||||
|
||||
type MEASURE_MODE_UNDEFINED = 0 & ['MEASURE_MODE']
|
||||
export const MEASURE_MODE_UNDEFINED: MEASURE_MODE_UNDEFINED;
|
||||
|
||||
type MEASURE_MODE_EXACTLY = 1 & ['MEASURE_MODE']
|
||||
export const MEASURE_MODE_EXACTLY: MEASURE_MODE_EXACTLY;
|
||||
|
||||
type MEASURE_MODE_AT_MOST = 2 & ['MEASURE_MODE']
|
||||
export const MEASURE_MODE_AT_MOST: MEASURE_MODE_AT_MOST;
|
||||
|
||||
|
||||
type NODE_TYPE_DEFAULT = 0 & ['NODE_TYPE']
|
||||
export const NODE_TYPE_DEFAULT: NODE_TYPE_DEFAULT;
|
||||
|
||||
type NODE_TYPE_TEXT = 1 & ['NODE_TYPE']
|
||||
export const NODE_TYPE_TEXT: NODE_TYPE_TEXT;
|
||||
|
||||
|
||||
type OVERFLOW_VISIBLE = 0 & ['OVERFLOW']
|
||||
export const OVERFLOW_VISIBLE: OVERFLOW_VISIBLE;
|
||||
|
||||
type OVERFLOW_HIDDEN = 1 & ['OVERFLOW']
|
||||
export const OVERFLOW_HIDDEN: OVERFLOW_HIDDEN;
|
||||
|
||||
type OVERFLOW_SCROLL = 2 & ['OVERFLOW']
|
||||
export const OVERFLOW_SCROLL: OVERFLOW_SCROLL;
|
||||
|
||||
|
||||
type POSITION_TYPE_STATIC = 0 & ['POSITION_TYPE']
|
||||
export const POSITION_TYPE_STATIC: POSITION_TYPE_STATIC;
|
||||
|
||||
type POSITION_TYPE_RELATIVE = 1 & ['POSITION_TYPE']
|
||||
export const POSITION_TYPE_RELATIVE: POSITION_TYPE_RELATIVE;
|
||||
|
||||
type POSITION_TYPE_ABSOLUTE = 2 & ['POSITION_TYPE']
|
||||
export const POSITION_TYPE_ABSOLUTE: POSITION_TYPE_ABSOLUTE;
|
||||
|
||||
|
||||
type PRINT_OPTIONS_LAYOUT = 1 & ['PRINT_OPTIONS']
|
||||
export const PRINT_OPTIONS_LAYOUT: PRINT_OPTIONS_LAYOUT;
|
||||
|
||||
type PRINT_OPTIONS_STYLE = 2 & ['PRINT_OPTIONS']
|
||||
export const PRINT_OPTIONS_STYLE: PRINT_OPTIONS_STYLE;
|
||||
|
||||
type PRINT_OPTIONS_CHILDREN = 4 & ['PRINT_OPTIONS']
|
||||
export const PRINT_OPTIONS_CHILDREN: PRINT_OPTIONS_CHILDREN;
|
||||
|
||||
|
||||
type UNIT_UNDEFINED = 0 & ['UNIT']
|
||||
export const UNIT_UNDEFINED: UNIT_UNDEFINED;
|
||||
|
||||
type UNIT_POINT = 1 & ['UNIT']
|
||||
export const UNIT_POINT: UNIT_POINT;
|
||||
|
||||
type UNIT_PERCENT = 2 & ['UNIT']
|
||||
export const UNIT_PERCENT: UNIT_PERCENT;
|
||||
|
||||
type UNIT_AUTO = 3 & ['UNIT']
|
||||
export const UNIT_AUTO: UNIT_AUTO;
|
||||
|
||||
|
||||
type WRAP_NO_WRAP = 0 & ['WRAP']
|
||||
export const WRAP_NO_WRAP: WRAP_NO_WRAP;
|
||||
|
||||
type WRAP_WRAP = 1 & ['WRAP']
|
||||
export const WRAP_WRAP: WRAP_WRAP;
|
||||
|
||||
type WRAP_WRAP_REVERSE = 2 & ['WRAP']
|
||||
export const WRAP_WRAP_REVERSE: WRAP_WRAP_REVERSE;
|
||||
|
||||
|
||||
export type Align =
|
||||
| typeof ALIGN_AUTO
|
||||
| typeof ALIGN_FLEX_START
|
||||
| typeof ALIGN_CENTER
|
||||
| typeof ALIGN_FLEX_END
|
||||
| typeof ALIGN_STRETCH
|
||||
| typeof ALIGN_BASELINE
|
||||
| typeof ALIGN_SPACE_BETWEEN
|
||||
| typeof ALIGN_SPACE_AROUND;
|
||||
|
||||
export type Dimension =
|
||||
| typeof DIMENSION_WIDTH
|
||||
| typeof DIMENSION_HEIGHT;
|
||||
|
||||
export type Direction =
|
||||
| typeof DIRECTION_INHERIT
|
||||
| typeof DIRECTION_LTR
|
||||
| typeof DIRECTION_RTL;
|
||||
|
||||
export type Display =
|
||||
| typeof DISPLAY_FLEX
|
||||
| typeof DISPLAY_NONE;
|
||||
|
||||
export type Edge =
|
||||
| typeof EDGE_LEFT
|
||||
| typeof EDGE_TOP
|
||||
| typeof EDGE_RIGHT
|
||||
| typeof EDGE_BOTTOM
|
||||
| typeof EDGE_START
|
||||
| typeof EDGE_END
|
||||
| typeof EDGE_HORIZONTAL
|
||||
| typeof EDGE_VERTICAL
|
||||
| typeof EDGE_ALL;
|
||||
|
||||
export type ExperimentalFeature =
|
||||
| typeof EXPERIMENTAL_FEATURE_WEB_FLEX_BASIS;
|
||||
|
||||
export type FlexDirection =
|
||||
| typeof FLEX_DIRECTION_COLUMN
|
||||
| typeof FLEX_DIRECTION_COLUMN_REVERSE
|
||||
| typeof FLEX_DIRECTION_ROW
|
||||
| typeof FLEX_DIRECTION_ROW_REVERSE;
|
||||
|
||||
export type Gutter =
|
||||
| typeof GUTTER_COLUMN
|
||||
| typeof GUTTER_ROW
|
||||
| typeof GUTTER_ALL;
|
||||
|
||||
export type Justify =
|
||||
| typeof JUSTIFY_FLEX_START
|
||||
| typeof JUSTIFY_CENTER
|
||||
| typeof JUSTIFY_FLEX_END
|
||||
| typeof JUSTIFY_SPACE_BETWEEN
|
||||
| typeof JUSTIFY_SPACE_AROUND
|
||||
| typeof JUSTIFY_SPACE_EVENLY;
|
||||
|
||||
export type LogLevel =
|
||||
| typeof LOG_LEVEL_ERROR
|
||||
| typeof LOG_LEVEL_WARN
|
||||
| typeof LOG_LEVEL_INFO
|
||||
| typeof LOG_LEVEL_DEBUG
|
||||
| typeof LOG_LEVEL_VERBOSE
|
||||
| typeof LOG_LEVEL_FATAL;
|
||||
|
||||
export type MeasureMode =
|
||||
| typeof MEASURE_MODE_UNDEFINED
|
||||
| typeof MEASURE_MODE_EXACTLY
|
||||
| typeof MEASURE_MODE_AT_MOST;
|
||||
|
||||
export type NodeType =
|
||||
| typeof NODE_TYPE_DEFAULT
|
||||
| typeof NODE_TYPE_TEXT;
|
||||
|
||||
export type Overflow =
|
||||
| typeof OVERFLOW_VISIBLE
|
||||
| typeof OVERFLOW_HIDDEN
|
||||
| typeof OVERFLOW_SCROLL;
|
||||
|
||||
export type PositionType =
|
||||
| typeof POSITION_TYPE_STATIC
|
||||
| typeof POSITION_TYPE_RELATIVE
|
||||
| typeof POSITION_TYPE_ABSOLUTE;
|
||||
|
||||
export type PrintOptions =
|
||||
| typeof PRINT_OPTIONS_LAYOUT
|
||||
| typeof PRINT_OPTIONS_STYLE
|
||||
| typeof PRINT_OPTIONS_CHILDREN;
|
||||
|
||||
export type Unit =
|
||||
| typeof UNIT_UNDEFINED
|
||||
| typeof UNIT_POINT
|
||||
| typeof UNIT_PERCENT
|
||||
| typeof UNIT_AUTO;
|
||||
|
||||
export type Wrap =
|
||||
| typeof WRAP_NO_WRAP
|
||||
| typeof WRAP_WRAP
|
||||
| typeof WRAP_WRAP_REVERSE;
|
||||
|
92
javascript/src_js/generated/YGEnums.js
Normal file
92
javascript/src_js/generated/YGEnums.js
Normal file
@@ -0,0 +1,92 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// @generated by enums.py
|
||||
|
||||
module.exports = {
|
||||
ALIGN_AUTO: 0,
|
||||
ALIGN_FLEX_START: 1,
|
||||
ALIGN_CENTER: 2,
|
||||
ALIGN_FLEX_END: 3,
|
||||
ALIGN_STRETCH: 4,
|
||||
ALIGN_BASELINE: 5,
|
||||
ALIGN_SPACE_BETWEEN: 6,
|
||||
ALIGN_SPACE_AROUND: 7,
|
||||
|
||||
DIMENSION_WIDTH: 0,
|
||||
DIMENSION_HEIGHT: 1,
|
||||
|
||||
DIRECTION_INHERIT: 0,
|
||||
DIRECTION_LTR: 1,
|
||||
DIRECTION_RTL: 2,
|
||||
|
||||
DISPLAY_FLEX: 0,
|
||||
DISPLAY_NONE: 1,
|
||||
|
||||
EDGE_LEFT: 0,
|
||||
EDGE_TOP: 1,
|
||||
EDGE_RIGHT: 2,
|
||||
EDGE_BOTTOM: 3,
|
||||
EDGE_START: 4,
|
||||
EDGE_END: 5,
|
||||
EDGE_HORIZONTAL: 6,
|
||||
EDGE_VERTICAL: 7,
|
||||
EDGE_ALL: 8,
|
||||
|
||||
EXPERIMENTAL_FEATURE_WEB_FLEX_BASIS: 0,
|
||||
|
||||
FLEX_DIRECTION_COLUMN: 0,
|
||||
FLEX_DIRECTION_COLUMN_REVERSE: 1,
|
||||
FLEX_DIRECTION_ROW: 2,
|
||||
FLEX_DIRECTION_ROW_REVERSE: 3,
|
||||
|
||||
GUTTER_COLUMN: 0,
|
||||
GUTTER_ROW: 1,
|
||||
GUTTER_ALL: 2,
|
||||
|
||||
JUSTIFY_FLEX_START: 0,
|
||||
JUSTIFY_CENTER: 1,
|
||||
JUSTIFY_FLEX_END: 2,
|
||||
JUSTIFY_SPACE_BETWEEN: 3,
|
||||
JUSTIFY_SPACE_AROUND: 4,
|
||||
JUSTIFY_SPACE_EVENLY: 5,
|
||||
|
||||
LOG_LEVEL_ERROR: 0,
|
||||
LOG_LEVEL_WARN: 1,
|
||||
LOG_LEVEL_INFO: 2,
|
||||
LOG_LEVEL_DEBUG: 3,
|
||||
LOG_LEVEL_VERBOSE: 4,
|
||||
LOG_LEVEL_FATAL: 5,
|
||||
|
||||
MEASURE_MODE_UNDEFINED: 0,
|
||||
MEASURE_MODE_EXACTLY: 1,
|
||||
MEASURE_MODE_AT_MOST: 2,
|
||||
|
||||
NODE_TYPE_DEFAULT: 0,
|
||||
NODE_TYPE_TEXT: 1,
|
||||
|
||||
OVERFLOW_VISIBLE: 0,
|
||||
OVERFLOW_HIDDEN: 1,
|
||||
OVERFLOW_SCROLL: 2,
|
||||
|
||||
POSITION_TYPE_STATIC: 0,
|
||||
POSITION_TYPE_RELATIVE: 1,
|
||||
POSITION_TYPE_ABSOLUTE: 2,
|
||||
|
||||
PRINT_OPTIONS_LAYOUT: 1,
|
||||
PRINT_OPTIONS_STYLE: 2,
|
||||
PRINT_OPTIONS_CHILDREN: 4,
|
||||
|
||||
UNIT_UNDEFINED: 0,
|
||||
UNIT_POINT: 1,
|
||||
UNIT_PERCENT: 2,
|
||||
UNIT_AUTO: 3,
|
||||
|
||||
WRAP_NO_WRAP: 0,
|
||||
WRAP_WRAP: 1,
|
||||
WRAP_WRAP_REVERSE: 2,
|
||||
};
|
15
javascript/src_js/index.d.ts
vendored
Normal file
15
javascript/src_js/index.d.ts
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
import type {Yoga} from './wrapAsm';
|
||||
|
||||
export * from './generated/YGEnums';
|
||||
export * from './wrapAsm';
|
||||
|
||||
export function loadYoga(): Promise<Yoga>;
|
11
javascript/src_js/index.js
Normal file
11
javascript/src_js/index.js
Normal file
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
// Fallback for when the export map is not followed
|
||||
module.exports = require("./entrypoint/asmjs-async");
|
16
javascript/src_js/sync.d.ts
vendored
Normal file
16
javascript/src_js/sync.d.ts
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
import type {Yoga} from './wrapAsm';
|
||||
|
||||
export * from './generated/YGEnums';
|
||||
export * from './wrapAsm';
|
||||
|
||||
declare const yoga: Yoga;
|
||||
export default yoga;
|
11
javascript/src_js/sync.js
Normal file
11
javascript/src_js/sync.js
Normal file
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
// Fallback for when the export map is not followed
|
||||
module.exports = require("./entrypoint/asmjs-sync");
|
174
javascript/src_js/wrapAsm.d.ts
vendored
Normal file
174
javascript/src_js/wrapAsm.d.ts
vendored
Normal file
@@ -0,0 +1,174 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
import type {
|
||||
Edge,
|
||||
Wrap,
|
||||
Align,
|
||||
FlexDirection,
|
||||
Gutter,
|
||||
Direction,
|
||||
PositionType,
|
||||
Overflow,
|
||||
Justify,
|
||||
Display,
|
||||
ExperimentalFeature,
|
||||
} from './generated/YGEnums';
|
||||
|
||||
import type * as YGEnums from './generated/YGEnums';
|
||||
|
||||
type Layout = {
|
||||
left: number;
|
||||
right: number;
|
||||
top: number;
|
||||
bottom: number;
|
||||
width: number;
|
||||
height: number;
|
||||
}
|
||||
|
||||
type Size = {
|
||||
width: number;
|
||||
height: number;
|
||||
}
|
||||
|
||||
type Value = {
|
||||
unit: number;
|
||||
value: number;
|
||||
}
|
||||
|
||||
export type Config = {
|
||||
free(): void;
|
||||
isExperimentalFeatureEnabled(feature: ExperimentalFeature): boolean,
|
||||
setExperimentalFeatureEnabled(
|
||||
feature: ExperimentalFeature,
|
||||
enabled: boolean,
|
||||
): void,
|
||||
setPointScaleFactor(factor: number): void,
|
||||
useLegacyStretchBehaviour(): boolean,
|
||||
setUseLegacyStretchBehaviour(useLegacyStretchBehaviour: boolean): void,
|
||||
useWebDefaults(): boolean,
|
||||
setUseWebDefaults(useWebDefaults): void,
|
||||
};
|
||||
|
||||
export type MeasureFunction = (
|
||||
width: number,
|
||||
widthMode: number,
|
||||
height: number,
|
||||
heightMode: number
|
||||
) => Size;
|
||||
|
||||
export type Node = {
|
||||
calculateLayout(
|
||||
width?: number,
|
||||
height?: number,
|
||||
direction?: Direction,
|
||||
): void,
|
||||
copyStyle(node: Node): void,
|
||||
free(): void,
|
||||
freeRecursive(): void,
|
||||
getAlignContent(): Align,
|
||||
getAlignItems(): Align,
|
||||
getAlignSelf(): Align,
|
||||
getAspectRatio(): number,
|
||||
getBorder(edge: Edge): number,
|
||||
getChild(index: number): Node,
|
||||
getChildCount(): number,
|
||||
getComputedBorder(edge: Edge): number,
|
||||
getComputedBottom(): number,
|
||||
getComputedHeight(): number,
|
||||
getComputedLayout(): Layout,
|
||||
getComputedLeft(): number,
|
||||
getComputedMargin(edge: Edge): number,
|
||||
getComputedPadding(edge: Edge): number,
|
||||
getComputedRight(): number,
|
||||
getComputedTop(): number,
|
||||
getComputedWidth(): number,
|
||||
getDisplay(): Display,
|
||||
getFlexBasis(): number,
|
||||
getFlexDirection(): FlexDirection,
|
||||
getFlexGrow(): number,
|
||||
getFlexShrink(): number,
|
||||
getFlexWrap(): Wrap,
|
||||
getHeight(): Value,
|
||||
getJustifyContent(): Justify,
|
||||
getGap(gutter: Gutter): Value,
|
||||
getMargin(edge: Edge): Value,
|
||||
getMaxHeight(): Value,
|
||||
getMaxWidth(): Value,
|
||||
getMinHeight(): Value,
|
||||
getMinWidth(): Value,
|
||||
getOverflow(): Overflow,
|
||||
getPadding(edge: Edge): Value,
|
||||
getParent(): Node | null,
|
||||
getPosition(edge: Edge): Value,
|
||||
getPositionType(): PositionType,
|
||||
getWidth(): Value,
|
||||
insertChild(child: Node, index: number): void,
|
||||
isDirty(): boolean,
|
||||
markDirty(): void,
|
||||
removeChild(child: Node): void,
|
||||
reset(): void,
|
||||
setAlignContent(alignContent: Align): void,
|
||||
setAlignItems(alignItems: Align): void,
|
||||
setAlignSelf(alignSelf: Align): void,
|
||||
setAspectRatio(aspectRatio: number): void,
|
||||
setBorder(edge: Edge, borderWidth: number): void,
|
||||
setDisplay(display: Display): void,
|
||||
setFlex(flex: number): void,
|
||||
setFlexBasis(flexBasis: number | string): void,
|
||||
setFlexBasisPercent(flexBasis: number): void,
|
||||
setFlexBasisAuto(): void,
|
||||
setFlexDirection(flexDirection: FlexDirection): void,
|
||||
setFlexGrow(flexGrow: number): void,
|
||||
setFlexShrink(flexShrink: number): void,
|
||||
setFlexWrap(flexWrap: Wrap): void,
|
||||
setHeight(height: number | string): void,
|
||||
setHeightAuto(): void,
|
||||
setHeightPercent(height: number): void,
|
||||
setJustifyContent(justifyContent: Justify): void,
|
||||
setGap(gutter: Gutter, gapLength: number): Value,
|
||||
setMargin(edge: Edge, margin: number): void,
|
||||
setMarginAuto(edge: Edge): void,
|
||||
setMarginPercent(edge: Edge, margin: number): void,
|
||||
setMaxHeight(maxHeight: number | string): void,
|
||||
setMaxHeightPercent(maxHeight: number): void,
|
||||
setMaxWidth(maxWidth: number | string): void,
|
||||
setMaxWidthPercent(maxWidth: number): void,
|
||||
setMeasureFunc(measureFunc: MeasureFunction | null): void,
|
||||
setMinHeight(minHeight: number | string): void,
|
||||
setMinHeightPercent(minHeight: number): void,
|
||||
setMinWidth(minWidth: number | string): void,
|
||||
setMinWidthPercent(minWidth: number): void,
|
||||
setOverflow(overflow: Overflow): void,
|
||||
setPadding(edge: Edge, padding: number | string): void,
|
||||
setPaddingPercent(edge: Edge, padding: number): void,
|
||||
setPosition(edge: Edge, position: number | string): void,
|
||||
setPositionPercent(edge: Edge, position: number): void,
|
||||
setPositionType(positionType: PositionType): void,
|
||||
setWidth(width: number | string): void,
|
||||
setWidthAuto(): void,
|
||||
setWidthPercent(width: number): void,
|
||||
unsetMeasureFun(): void,
|
||||
};
|
||||
|
||||
export type Yoga = {
|
||||
Config: {
|
||||
create(): Config,
|
||||
destroy(config: Config): any,
|
||||
},
|
||||
Node: {
|
||||
create(): Node,
|
||||
createDefault(): Node,
|
||||
createWithConfig(config: Config): Node,
|
||||
destroy(node: Node): any,
|
||||
},
|
||||
} & typeof YGEnums;
|
||||
|
||||
declare const wrapAsm: () => Yoga;
|
||||
export default wrapAsm;
|
147
javascript/src_js/wrapAsm.js
Normal file
147
javascript/src_js/wrapAsm.js
Normal file
@@ -0,0 +1,147 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
const CONSTANTS = require("./generated/YGEnums");
|
||||
|
||||
module.exports = (lib) => {
|
||||
function patch(prototype, name, fn) {
|
||||
const original = prototype[name];
|
||||
|
||||
prototype[name] = function (...args) {
|
||||
return fn.call(this, original, ...args);
|
||||
};
|
||||
}
|
||||
|
||||
for (const fnName of [
|
||||
"setPosition",
|
||||
"setMargin",
|
||||
"setFlexBasis",
|
||||
"setWidth",
|
||||
"setHeight",
|
||||
"setMinWidth",
|
||||
"setMinHeight",
|
||||
"setMaxWidth",
|
||||
"setMaxHeight",
|
||||
"setPadding",
|
||||
]) {
|
||||
const methods = {
|
||||
[CONSTANTS.UNIT_POINT]: lib.Node.prototype[fnName],
|
||||
[CONSTANTS.UNIT_PERCENT]: lib.Node.prototype[`${fnName}Percent`],
|
||||
[CONSTANTS.UNIT_AUTO]: lib.Node.prototype[`${fnName}Auto`],
|
||||
};
|
||||
|
||||
patch(lib.Node.prototype, fnName, function (original, ...args) {
|
||||
// We patch all these functions to add support for the following calls:
|
||||
// .setWidth(100) / .setWidth("100%") / .setWidth(.getWidth()) / .setWidth("auto")
|
||||
|
||||
const value = args.pop();
|
||||
let unit, asNumber;
|
||||
|
||||
if (value === "auto") {
|
||||
unit = CONSTANTS.UNIT_AUTO;
|
||||
asNumber = undefined;
|
||||
} else if (typeof value === "object") {
|
||||
unit = value.unit;
|
||||
asNumber = value.valueOf();
|
||||
} else {
|
||||
unit =
|
||||
typeof value === "string" && value.endsWith("%")
|
||||
? CONSTANTS.UNIT_PERCENT
|
||||
: CONSTANTS.UNIT_POINT;
|
||||
asNumber = parseFloat(value);
|
||||
if (!Number.isNaN(value) && Number.isNaN(asNumber)) {
|
||||
throw new Error(`Invalid value ${value} for ${fnName}`);
|
||||
}
|
||||
}
|
||||
|
||||
if (!methods[unit])
|
||||
throw new Error(
|
||||
`Failed to execute "${fnName}": Unsupported unit '${value}'`
|
||||
);
|
||||
|
||||
if (asNumber !== undefined) {
|
||||
return methods[unit].call(this, ...args, asNumber);
|
||||
} else {
|
||||
return methods[unit].call(this, ...args);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function wrapMeasureFunction(measureFunction) {
|
||||
return lib.MeasureCallback.implement({ measure: measureFunction });
|
||||
}
|
||||
|
||||
patch(lib.Node.prototype, "setMeasureFunc", function (original, measureFunc) {
|
||||
original.call(this, wrapMeasureFunction(measureFunc));
|
||||
});
|
||||
|
||||
function wrapDirtiedFunc(dirtiedFunction) {
|
||||
return lib.DirtiedCallback.implement({ dirtied: dirtiedFunction });
|
||||
}
|
||||
|
||||
patch(lib.Node.prototype, "setDirtiedFunc", function (original, dirtiedFunc) {
|
||||
original.call(this, wrapDirtiedFunc(dirtiedFunc));
|
||||
});
|
||||
|
||||
patch(lib.Config.prototype, "free", function () {
|
||||
// Since we handle the memory allocation ourselves (via lib.Config.create),
|
||||
// we also need to handle the deallocation
|
||||
lib.Config.destroy(this);
|
||||
});
|
||||
|
||||
patch(lib.Node, "create", (_, config) => {
|
||||
// We decide the constructor we want to call depending on the parameters
|
||||
return config
|
||||
? lib.Node.createWithConfig(config)
|
||||
: lib.Node.createDefault();
|
||||
});
|
||||
|
||||
patch(lib.Node.prototype, "free", function () {
|
||||
// Since we handle the memory allocation ourselves (via lib.Node.create),
|
||||
// we also need to handle the deallocation
|
||||
lib.Node.destroy(this);
|
||||
});
|
||||
|
||||
patch(lib.Node.prototype, "freeRecursive", function () {
|
||||
for (let t = 0, T = this.getChildCount(); t < T; ++t) {
|
||||
this.getChild(0).freeRecursive();
|
||||
}
|
||||
this.free();
|
||||
});
|
||||
|
||||
patch(lib.Node.prototype, "setMeasureFunc", function (original, measureFunc) {
|
||||
// This patch is just a convenience patch, since it helps write more
|
||||
// idiomatic source code (such as .setMeasureFunc(null))
|
||||
if (measureFunc) {
|
||||
return original.call(this, (...args) => measureFunc(...args));
|
||||
} else {
|
||||
return this.unsetMeasureFunc();
|
||||
}
|
||||
});
|
||||
|
||||
patch(
|
||||
lib.Node.prototype,
|
||||
"calculateLayout",
|
||||
function (
|
||||
original,
|
||||
width = NaN,
|
||||
height = NaN,
|
||||
direction = CONSTANTS.DIRECTION_LTR
|
||||
) {
|
||||
// Just a small patch to add support for the function default parameters
|
||||
return original.call(this, width, height, direction);
|
||||
}
|
||||
);
|
||||
|
||||
return {
|
||||
Config: lib.Config,
|
||||
Node: lib.Node,
|
||||
...CONSTANTS,
|
||||
};
|
||||
};
|
@@ -32,7 +32,23 @@ void Config::setPointScaleFactor(float pixelsInPoint) {
|
||||
YGConfigSetPointScaleFactor(m_config, pixelsInPoint);
|
||||
}
|
||||
|
||||
void Config::setUseLegacyStretchBehaviour(bool useLegacyStretchBehaviour) {
|
||||
YGConfigSetUseLegacyStretchBehaviour(m_config, useLegacyStretchBehaviour);
|
||||
}
|
||||
|
||||
void Config::setUseWebDefaults(bool useWebDefaults) {
|
||||
YGConfigSetUseWebDefaults(m_config, useWebDefaults);
|
||||
}
|
||||
|
||||
bool Config::isExperimentalFeatureEnabled(int feature) const {
|
||||
return YGConfigIsExperimentalFeatureEnabled(
|
||||
m_config, static_cast<YGExperimentalFeature>(feature));
|
||||
}
|
||||
|
||||
bool Config::useLegacyStretchBehaviour() {
|
||||
return YGConfigGetUseLegacyStretchBehaviour(m_config);
|
||||
}
|
||||
|
||||
bool Config::useWebDefaults() {
|
||||
return YGConfigGetUseWebDefaults(m_config);
|
||||
}
|
@@ -7,8 +7,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <nbind/api.h>
|
||||
#include <nbind/BindDefiner.h>
|
||||
#include <yoga/Yoga.h>
|
||||
|
||||
class Config {
|
||||
@@ -34,9 +32,13 @@ public: // Prevent accidental copy
|
||||
public: // Setters
|
||||
void setExperimentalFeatureEnabled(int feature, bool enabled);
|
||||
void setPointScaleFactor(float pixelsInPoint);
|
||||
void setUseLegacyStretchBehaviour(bool useLegacyStretchBehaviour);
|
||||
void setUseWebDefaults(bool useWebDefaults);
|
||||
|
||||
public: // Getters
|
||||
bool isExperimentalFeatureEnabled(int feature) const;
|
||||
bool useLegacyStretchBehaviour();
|
||||
bool useWebDefaults();
|
||||
|
||||
private:
|
||||
YGConfigRef m_config;
|
@@ -7,9 +7,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <nbind/api.h>
|
||||
#include <nbind/BindDefiner.h>
|
||||
|
||||
struct Layout {
|
||||
double left;
|
||||
double right;
|
||||
@@ -19,8 +16,4 @@ struct Layout {
|
||||
|
||||
double width;
|
||||
double height;
|
||||
|
||||
void toJS(nbind::cbOutput expose) const {
|
||||
expose(left, right, top, bottom, width, height);
|
||||
}
|
||||
};
|
@@ -331,9 +331,8 @@ Value Node::getPadding(int edge) const {
|
||||
YGNodeStyleGetPadding(m_node, static_cast<YGEdge>(edge)));
|
||||
}
|
||||
|
||||
Value Node::getGap(int gutter, ) {
|
||||
return Value::fromYGValue(
|
||||
YGNodeStyleGetGap(m_node, static_cast<YGGutter>(gutter)));
|
||||
float Node::getGap(int gutter) {
|
||||
return YGNodeStyleGetGap(m_node, static_cast<YGGutter>(gutter));
|
||||
}
|
||||
|
||||
bool Node::isReferenceBaseline() {
|
||||
@@ -370,8 +369,8 @@ Node* Node::getChild(unsigned index) {
|
||||
return Node::fromYGNode(nodePtr);
|
||||
}
|
||||
|
||||
void Node::setMeasureFunc(nbind::cbFunction& measureFunc) {
|
||||
m_measureFunc.reset(new nbind::cbFunction(measureFunc));
|
||||
void Node::setMeasureFunc(MeasureCallback* measureFunc) {
|
||||
m_measureFunc.reset(measureFunc);
|
||||
|
||||
YGNodeSetMeasureFunc(m_node, &globalMeasureFunc);
|
||||
}
|
||||
@@ -387,11 +386,11 @@ Size Node::callMeasureFunc(
|
||||
int widthMode,
|
||||
double height,
|
||||
int heightMode) const {
|
||||
return m_measureFunc->call<Size>(width, widthMode, height, heightMode);
|
||||
return m_measureFunc->measure(width, widthMode, height, heightMode);
|
||||
}
|
||||
|
||||
void Node::setDirtiedFunc(nbind::cbFunction& dirtiedFunc) {
|
||||
m_dirtiedFunc.reset(new nbind::cbFunction(dirtiedFunc));
|
||||
void Node::setDirtiedFunc(DirtiedCallback* dirtiedFunc) {
|
||||
m_dirtiedFunc.reset(dirtiedFunc);
|
||||
|
||||
YGNodeSetDirtiedFunc(m_node, &globalDirtiedFunc);
|
||||
}
|
||||
@@ -403,7 +402,7 @@ void Node::unsetDirtiedFunc(void) {
|
||||
}
|
||||
|
||||
void Node::callDirtiedFunc(void) const {
|
||||
m_dirtiedFunc->call<void>();
|
||||
m_dirtiedFunc->dirtied();
|
||||
}
|
||||
|
||||
void Node::markDirty(void) {
|
@@ -9,8 +9,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <nbind/api.h>
|
||||
#include <nbind/BindDefiner.h>
|
||||
#include <emscripten/bind.h>
|
||||
#include <yoga/Yoga.h>
|
||||
|
||||
#include "./Layout.hh"
|
||||
@@ -18,6 +17,36 @@
|
||||
#include "./Value.hh"
|
||||
#include "./Config.hh"
|
||||
|
||||
class MeasureCallback {
|
||||
public:
|
||||
virtual ~MeasureCallback() {}
|
||||
virtual Size measure(
|
||||
float width,
|
||||
int widthMode,
|
||||
float height,
|
||||
int heightMode) = 0;
|
||||
};
|
||||
|
||||
class MeasureCallbackWrapper : public emscripten::wrapper<MeasureCallback> {
|
||||
public:
|
||||
EMSCRIPTEN_WRAPPER(MeasureCallbackWrapper);
|
||||
Size measure(float width, int widthMode, float height, int heightMode) {
|
||||
return call<Size>("measure", width, widthMode, height, heightMode);
|
||||
}
|
||||
};
|
||||
|
||||
class DirtiedCallback {
|
||||
public:
|
||||
virtual ~DirtiedCallback() {}
|
||||
virtual void dirtied() = 0;
|
||||
};
|
||||
|
||||
class DirtiedCallbackWrapper : public emscripten::wrapper<DirtiedCallback> {
|
||||
public:
|
||||
EMSCRIPTEN_WRAPPER(DirtiedCallbackWrapper);
|
||||
void dirtied() { return call<void>("dirtied"); }
|
||||
};
|
||||
|
||||
class Node {
|
||||
|
||||
public:
|
||||
@@ -132,7 +161,7 @@ public: // Style getters
|
||||
|
||||
Value getPadding(int edge) const;
|
||||
|
||||
Value getGap(int gutter);
|
||||
float getGap(int gutter);
|
||||
|
||||
public: // Tree hierarchy mutators
|
||||
void insertChild(Node* child, unsigned index);
|
||||
@@ -148,7 +177,7 @@ public: // Tree hierarchy inspectors
|
||||
Node* getChild(unsigned index);
|
||||
|
||||
public: // Measure func mutators
|
||||
void setMeasureFunc(nbind::cbFunction& measureFunc);
|
||||
void setMeasureFunc(MeasureCallback* measureFunc);
|
||||
void unsetMeasureFunc(void);
|
||||
|
||||
public: // Measure func inspectors
|
||||
@@ -159,7 +188,7 @@ public: // Measure func inspectors
|
||||
int heightMode) const;
|
||||
|
||||
public: // Dirtied func mutators
|
||||
void setDirtiedFunc(nbind::cbFunction& dirtiedFunc);
|
||||
void setDirtiedFunc(DirtiedCallback* dirtiedFunc);
|
||||
void unsetDirtiedFunc(void);
|
||||
|
||||
public: // Dirtied func inspectors
|
||||
@@ -194,6 +223,6 @@ public:
|
||||
|
||||
YGNodeRef m_node;
|
||||
|
||||
std::unique_ptr<nbind::cbFunction> m_measureFunc;
|
||||
std::unique_ptr<nbind::cbFunction> m_dirtiedFunc;
|
||||
std::unique_ptr<MeasureCallback> m_measureFunc;
|
||||
std::unique_ptr<DirtiedCallback> m_dirtiedFunc;
|
||||
};
|
@@ -7,9 +7,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <nbind/api.h>
|
||||
#include <nbind/BindDefiner.h>
|
||||
|
||||
struct Size {
|
||||
double width;
|
||||
double height;
|
||||
@@ -17,6 +14,4 @@ struct Size {
|
||||
Size(void) : width(0.0), height(0.0) {}
|
||||
|
||||
Size(double width, double height) : width(width), height(height) {}
|
||||
|
||||
void toJS(nbind::cbOutput expose) const { expose(width, height); }
|
||||
};
|
@@ -20,6 +20,4 @@ struct Value {
|
||||
Value(void) : unit(YGUnitUndefined), value(0.0) {}
|
||||
|
||||
Value(int unit, double value) : unit(unit), value(value) {}
|
||||
|
||||
void toJS(nbind::cbOutput expose) const { expose(unit, value); }
|
||||
};
|
191
javascript/src_native/embind.cc
Normal file
191
javascript/src_native/embind.cc
Normal file
@@ -0,0 +1,191 @@
|
||||
/*
|
||||
* 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 "./Node.hh"
|
||||
#include "./Layout.hh"
|
||||
#include "./Size.hh"
|
||||
#include "./Value.hh"
|
||||
#include "./Config.hh"
|
||||
|
||||
#include <yoga/Yoga.h>
|
||||
#include <emscripten/bind.h>
|
||||
|
||||
using namespace emscripten;
|
||||
|
||||
EMSCRIPTEN_BINDINGS(YOGA_LAYOUT) {
|
||||
class_<MeasureCallback>("MeasureCallback")
|
||||
.function("measure", &MeasureCallback::measure, pure_virtual())
|
||||
.allow_subclass<MeasureCallbackWrapper>("MeasureCallbackWrapper");
|
||||
class_<DirtiedCallback>("DirtiedCallback")
|
||||
.function("dirtied", &DirtiedCallback::dirtied, pure_virtual())
|
||||
.allow_subclass<DirtiedCallbackWrapper>("DirtiedCallbackWrapper");
|
||||
|
||||
class_<Config>("Config")
|
||||
.constructor<>(&Config::create, allow_raw_pointers())
|
||||
.class_function<>("create", &Config::create, allow_raw_pointers())
|
||||
.class_function<>("destroy", &Config::destroy, allow_raw_pointers())
|
||||
.function(
|
||||
"setExperimentalFeatureEnabled",
|
||||
&Config::setExperimentalFeatureEnabled)
|
||||
.function("setPointScaleFactor", &Config::setPointScaleFactor)
|
||||
.function(
|
||||
"setUseLegacyStretchBehaviour", &Config::setUseLegacyStretchBehaviour)
|
||||
.function("setUseWebDefaults", &Config::setUseWebDefaults)
|
||||
.function(
|
||||
"isExperimentalFeatureEnabled", &Config::isExperimentalFeatureEnabled)
|
||||
.function("useLegacyStretchBehaviour", &Config::useLegacyStretchBehaviour)
|
||||
.function("useWebDefaults", &Config::useWebDefaults);
|
||||
|
||||
value_object<Layout>("Layout")
|
||||
.field("left", &Layout::left)
|
||||
.field("right", &Layout::right)
|
||||
.field("top", &Layout::top)
|
||||
.field("bottom", &Layout::bottom)
|
||||
.field("width", &Layout::width)
|
||||
.field("height", &Layout::height);
|
||||
|
||||
value_object<Size>("Size")
|
||||
.field("width", &Size::width)
|
||||
.field("height", &Size::height);
|
||||
|
||||
value_object<Value>("Value")
|
||||
.field("value", &Value::value)
|
||||
.field("unit", &Value::unit);
|
||||
|
||||
class_<Node>("Node")
|
||||
.constructor<>(&Node::createDefault, allow_raw_pointers())
|
||||
|
||||
.class_function<>(
|
||||
"createDefault", &Node::createDefault, allow_raw_pointers())
|
||||
.class_function<>(
|
||||
"createWithConfig", &Node::createWithConfig, allow_raw_pointers())
|
||||
.class_function<>("destroy", &Node::destroy, allow_raw_pointers())
|
||||
.function("reset", &Node::reset)
|
||||
|
||||
.function("copyStyle", &Node::copyStyle)
|
||||
|
||||
.function("setPositionType", &Node::setPositionType)
|
||||
.function("setPosition", &Node::setPosition)
|
||||
.function("setPositionPercent", &Node::setPositionPercent)
|
||||
|
||||
.function("setAlignContent", &Node::setAlignContent)
|
||||
.function("setAlignItems", &Node::setAlignItems)
|
||||
.function("setAlignSelf", &Node::setAlignSelf)
|
||||
.function("setFlexDirection", &Node::setFlexDirection)
|
||||
.function("setFlexWrap", &Node::setFlexWrap)
|
||||
.function("setJustifyContent", &Node::setJustifyContent)
|
||||
|
||||
.function("setMargin", &Node::setMargin)
|
||||
.function("setMarginPercent", &Node::setMarginPercent)
|
||||
.function("setMarginAuto", &Node::setMarginAuto)
|
||||
|
||||
.function("setOverflow", &Node::setOverflow)
|
||||
.function("setDisplay", &Node::setDisplay)
|
||||
|
||||
.function("setFlex", &Node::setFlex)
|
||||
.function("setFlexBasis", &Node::setFlexBasis)
|
||||
.function("setFlexBasisPercent", &Node::setFlexBasisPercent)
|
||||
.function("setFlexGrow", &Node::setFlexGrow)
|
||||
.function("setFlexShrink", &Node::setFlexShrink)
|
||||
|
||||
.function("setWidth", &Node::setWidth)
|
||||
.function("setWidthPercent", &Node::setWidthPercent)
|
||||
.function("setWidthAuto", &Node::setWidthAuto)
|
||||
.function("setHeight", &Node::setHeight)
|
||||
.function("setHeightPercent", &Node::setHeightPercent)
|
||||
.function("setHeightAuto", &Node::setHeightAuto)
|
||||
|
||||
.function("setMinWidth", &Node::setMinWidth)
|
||||
.function("setMinWidthPercent", &Node::setMinWidthPercent)
|
||||
.function("setMinHeight", &Node::setMinHeight)
|
||||
.function("setMinHeightPercent", &Node::setMinHeightPercent)
|
||||
|
||||
.function("setMaxWidth", &Node::setMaxWidth)
|
||||
.function("setMaxWidthPercent", &Node::setMaxWidthPercent)
|
||||
.function("setMaxHeight", &Node::setMaxHeight)
|
||||
.function("setMaxHeightPercent", &Node::setMaxHeightPercent)
|
||||
|
||||
.function("setAspectRatio", &Node::setAspectRatio)
|
||||
|
||||
.function("setBorder", &Node::setBorder)
|
||||
|
||||
.function("setPadding", &Node::setPadding)
|
||||
.function("setPaddingPercent", &Node::setPaddingPercent)
|
||||
.function("setGap", &Node::setGap)
|
||||
|
||||
.function("getPositionType", &Node::getPositionType)
|
||||
.function("getPosition", &Node::getPosition)
|
||||
|
||||
.function("getAlignContent", &Node::getAlignContent)
|
||||
.function("getAlignItems", &Node::getAlignItems)
|
||||
.function("getAlignSelf", &Node::getAlignSelf)
|
||||
.function("getFlexDirection", &Node::getFlexDirection)
|
||||
.function("getFlexWrap", &Node::getFlexWrap)
|
||||
.function("getJustifyContent", &Node::getJustifyContent)
|
||||
|
||||
.function("getMargin", &Node::getMargin)
|
||||
|
||||
.function("getFlexBasis", &Node::getFlexBasis)
|
||||
.function("getFlexGrow", &Node::getFlexGrow)
|
||||
.function("getFlexShrink", &Node::getFlexShrink)
|
||||
|
||||
.function("getWidth", &Node::getWidth)
|
||||
.function("getHeight", &Node::getHeight)
|
||||
|
||||
.function("getMinWidth", &Node::getMinWidth)
|
||||
.function("getMinHeight", &Node::getMinHeight)
|
||||
|
||||
.function("getMaxWidth", &Node::getMaxWidth)
|
||||
.function("getMaxHeight", &Node::getMaxHeight)
|
||||
|
||||
.function("getAspectRatio", &Node::getAspectRatio)
|
||||
|
||||
.function("getBorder", &Node::getBorder)
|
||||
|
||||
.function("getOverflow", &Node::getOverflow)
|
||||
.function("getDisplay", &Node::getDisplay)
|
||||
|
||||
.function("getPadding", &Node::getPadding)
|
||||
.function("getGap", &Node::getGap)
|
||||
|
||||
.function("insertChild", &Node::insertChild, allow_raw_pointers())
|
||||
.function("removeChild", &Node::removeChild, allow_raw_pointers())
|
||||
|
||||
.function("getChildCount", &Node::getChildCount)
|
||||
|
||||
.function("getParent", &Node::getParent, allow_raw_pointers())
|
||||
.function("getChild", &Node::getChild, allow_raw_pointers())
|
||||
|
||||
.function("isReferenceBaseline", &Node::isReferenceBaseline)
|
||||
.function("setIsReferenceBaseline", &Node::setIsReferenceBaseline)
|
||||
|
||||
.function("setMeasureFunc", &Node::setMeasureFunc, allow_raw_pointers())
|
||||
.function("unsetMeasureFunc", &Node::unsetMeasureFunc)
|
||||
|
||||
.function("setDirtiedFunc", &Node::setDirtiedFunc, allow_raw_pointers())
|
||||
.function("unsetDirtiedFunc", &Node::unsetDirtiedFunc)
|
||||
|
||||
.function("markDirty", &Node::markDirty)
|
||||
.function("isDirty", &Node::isDirty)
|
||||
|
||||
.function("calculateLayout", &Node::calculateLayout)
|
||||
|
||||
.function("getComputedLeft", &Node::getComputedLeft)
|
||||
.function("getComputedRight", &Node::getComputedRight)
|
||||
|
||||
.function("getComputedTop", &Node::getComputedTop)
|
||||
.function("getComputedBottom", &Node::getComputedBottom)
|
||||
|
||||
.function("getComputedWidth", &Node::getComputedWidth)
|
||||
.function("getComputedHeight", &Node::getComputedHeight)
|
||||
|
||||
.function("getComputedLayout", &Node::getComputedLayout)
|
||||
|
||||
.function("getComputedMargin", &Node::getComputedMargin)
|
||||
.function("getComputedBorder", &Node::getComputedBorder)
|
||||
.function("getComputedPadding", &Node::getComputedPadding);
|
||||
}
|
@@ -5,18 +5,16 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
var Yoga = Yoga || require("../../dist/entry-" + process.env.TEST_ENTRY);
|
||||
const ITERATIONS = 2000;
|
||||
|
||||
var ITERATIONS = 2000;
|
||||
|
||||
YGBENCHMARK("Stack with flex", function() {
|
||||
var root = Yoga.Node.create();
|
||||
YGBENCHMARK("Stack with flex", () => {
|
||||
const root = Yoga.Node.create();
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
var measureCounter = getMeasureCounter(Yoga);
|
||||
const measureCounter = getMeasureCounter(Yoga);
|
||||
|
||||
for (var i = 0; i < ITERATIONS; i++) {
|
||||
for (let i = 0; i < ITERATIONS; i++) {
|
||||
const child = Yoga.Node.create();
|
||||
child.setMeasureFunc(measureCounter.inc);
|
||||
child.setFlex(1);
|
||||
@@ -27,13 +25,13 @@ YGBENCHMARK("Stack with flex", function() {
|
||||
root.freeRecursive();
|
||||
});
|
||||
|
||||
YGBENCHMARK("Align stretch in undefined axis", function() {
|
||||
var root = Yoga.Node.create();
|
||||
YGBENCHMARK("Align stretch in undefined axis", () => {
|
||||
const root = Yoga.Node.create();
|
||||
|
||||
var measureCounter = getMeasureCounter(Yoga);
|
||||
const measureCounter = getMeasureCounter(Yoga);
|
||||
|
||||
for (var i = 0; i < ITERATIONS; i++) {
|
||||
var child = Yoga.Node.create();
|
||||
for (let i = 0; i < ITERATIONS; i++) {
|
||||
const child = Yoga.Node.create();
|
||||
child.setMeasureFunc(measureCounter.inc);
|
||||
child.setHeight(20);
|
||||
root.insertChild(child, 0);
|
||||
@@ -43,20 +41,20 @@ YGBENCHMARK("Align stretch in undefined axis", function() {
|
||||
root.freeRecursive();
|
||||
});
|
||||
|
||||
YGBENCHMARK("Nested flex", function() {
|
||||
var root = Yoga.Node.create();
|
||||
YGBENCHMARK("Nested flex", () => {
|
||||
const root = Yoga.Node.create();
|
||||
|
||||
var measureCounter = getMeasureCounter(Yoga);
|
||||
const measureCounter = getMeasureCounter(Yoga);
|
||||
|
||||
var iterations = Math.pow(ITERATIONS, 1 / 2);
|
||||
const iterations = Math.pow(ITERATIONS, 1 / 2);
|
||||
|
||||
for (var i = 0; i < iterations; i++) {
|
||||
var child = Yoga.Node.create();
|
||||
for (let i = 0; i < iterations; i++) {
|
||||
const child = Yoga.Node.create();
|
||||
child.setFlex(1);
|
||||
root.insertChild(child, 0);
|
||||
|
||||
for (var ii = 0; ii < iterations; ii++) {
|
||||
var grandChild = Yoga.Node.create();
|
||||
for (let ii = 0; ii < iterations; ii++) {
|
||||
const grandChild = Yoga.Node.create();
|
||||
grandChild.setMeasureFunc(measureCounter.inc);
|
||||
grandChild.setFlex(1);
|
||||
child.insertChild(grandChild, 0);
|
||||
@@ -67,35 +65,35 @@ YGBENCHMARK("Nested flex", function() {
|
||||
root.freeRecursive();
|
||||
});
|
||||
|
||||
YGBENCHMARK("Huge nested layout", function() {
|
||||
var root = Yoga.Node.create();
|
||||
YGBENCHMARK("Huge nested layout", () => {
|
||||
const root = Yoga.Node.create();
|
||||
|
||||
var iterations = Math.pow(ITERATIONS, 1 / 4);
|
||||
const iterations = Math.pow(ITERATIONS, 1 / 4);
|
||||
|
||||
for (var i = 0; i < iterations; i++) {
|
||||
var child = Yoga.Node.create();
|
||||
for (let i = 0; i < iterations; i++) {
|
||||
const child = Yoga.Node.create();
|
||||
child.setFlexGrow(1);
|
||||
child.setWidth(10);
|
||||
child.setHeight(10);
|
||||
root.insertChild(child, 0);
|
||||
|
||||
for (var ii = 0; ii < iterations; ii++) {
|
||||
var grandChild = Yoga.Node.create();
|
||||
for (let ii = 0; ii < iterations; ii++) {
|
||||
const grandChild = Yoga.Node.create();
|
||||
grandChild.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
grandChild.setFlexGrow(1);
|
||||
grandChild.setWidth(10);
|
||||
grandChild.setHeight(10);
|
||||
child.insertChild(grandChild, 0);
|
||||
|
||||
for (var iii = 0; iii < iterations; iii++) {
|
||||
var grandGrandChild = Yoga.Node.create();
|
||||
for (let iii = 0; iii < iterations; iii++) {
|
||||
const grandGrandChild = Yoga.Node.create();
|
||||
grandGrandChild.setFlexGrow(1);
|
||||
grandGrandChild.setWidth(10);
|
||||
grandGrandChild.setHeight(10);
|
||||
grandChild.insertChild(grandGrandChild, 0);
|
||||
|
||||
for (var iiii = 0; iiii < iterations; iiii++) {
|
||||
var grandGrandGrandChild = Yoga.Node.create();
|
||||
for (let iiii = 0; iiii < iterations; iiii++) {
|
||||
const grandGrandGrandChild = Yoga.Node.create();
|
||||
grandGrandGrandChild.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
grandGrandGrandChild.setFlexGrow(1);
|
||||
grandGrandGrandChild.setWidth(10);
|
File diff suppressed because it is too large
Load Diff
@@ -1,156 +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.
|
||||
*/
|
||||
|
||||
var Yoga = Yoga || require("../../sources/entry-" + process.env.TEST_ENTRY);
|
||||
|
||||
it("align_baseline_parent_using_child_in_column_as_reference", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root.setWidth(1000);
|
||||
root.setHeight(1000);
|
||||
root.setAlignItems(Yoga.ALIGN_BASELINE);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN);
|
||||
root_child0.setWidth(500);
|
||||
root_child0.setHeight(600);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
var root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN);
|
||||
root_child1.setWidth(500);
|
||||
root_child1.setHeight(800);
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
var root_child1_child0 = Yoga.Node.create(config);
|
||||
root_child1_child0.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN);
|
||||
root_child1_child0.setWidth(500);
|
||||
root_child1_child0.setHeight(300);
|
||||
root_child1.insertChild(root_child1_child0, 0);
|
||||
|
||||
var root_child1_child1 = Yoga.Node.create(config);
|
||||
root_child1_child1.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN);
|
||||
root_child1_child1.setWidth(500);
|
||||
root_child1_child1.setHeight(400);
|
||||
root_child1_child1.setIsReferenceBaseline(true);
|
||||
root_child1.insertChild(root_child1_child1, 1);
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(),
|
||||
"0 === root_child0.getComputedLeft() (" +
|
||||
root_child0.getComputedLeft() + ")");
|
||||
console.assert(100 === root_child0.getComputedTop(),
|
||||
"100 === root_child0.getComputedTop() (" +
|
||||
root_child0.getComputedTop() + ")");
|
||||
|
||||
console.assert(500 === root_child1.getComputedLeft(),
|
||||
"500 === root_child1.getComputedLeft() (" +
|
||||
root_child1.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1.getComputedTop(),
|
||||
"0 === root_child1.getComputedTop() (" +
|
||||
root_child1.getComputedTop() + ")");
|
||||
|
||||
console.assert(0 === root_child1_child0.getComputedLeft(),
|
||||
"0 === root_child1_child0.getComputedLeft() (" +
|
||||
root_child1_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1_child0.getComputedTop(),
|
||||
"0 === root_child1_child0.getComputedTop() (" +
|
||||
root_child1_child0.getComputedTop() + ")");
|
||||
|
||||
console.assert(0 === root_child1_child1.getComputedLeft(),
|
||||
"0 === root_child1_child1.getComputedLeft() (" +
|
||||
root_child1_child1.getComputedLeft() + ")");
|
||||
console.assert(300 === root_child1_child1.getComputedTop(),
|
||||
"300 === root_child1_child1.getComputedTop() (" +
|
||||
root_child1_child1.getComputedTop() + ")");
|
||||
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
|
||||
it("align_baseline_parent_using_child_in_row_as_reference", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root.setWidth(1000);
|
||||
root.setHeight(1000);
|
||||
root.setAlignItems(Yoga.ALIGN_BASELINE);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN);
|
||||
root_child0.setWidth(500);
|
||||
root_child0.setHeight(600);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
var root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root_child1.setWidth(500);
|
||||
root_child1.setHeight(800);
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
var root_child1_child0 = Yoga.Node.create(config);
|
||||
root_child1_child0.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN);
|
||||
root_child1_child0.setWidth(500);
|
||||
root_child1_child0.setHeight(500);
|
||||
root_child1.insertChild(root_child1_child0, 0);
|
||||
|
||||
var root_child1_child1 = Yoga.Node.create(config);
|
||||
root_child1_child1.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN);
|
||||
root_child1_child1.setWidth(500);
|
||||
root_child1_child1.setHeight(400);
|
||||
root_child1_child1.setIsReferenceBaseline(true);
|
||||
root_child1.insertChild(root_child1_child1, 1);
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(),
|
||||
"0 === root_child0.getComputedLeft() (" +
|
||||
root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(),
|
||||
"0 === root_child0.getComputedTop() (" +
|
||||
root_child0.getComputedTop() + ")");
|
||||
|
||||
console.assert(500 === root_child1.getComputedLeft(),
|
||||
"500 === root_child1.getComputedLeft() (" +
|
||||
root_child1.getComputedLeft() + ")");
|
||||
console.assert(200 === root_child1.getComputedTop(),
|
||||
"200 === root_child1.getComputedTop() (" +
|
||||
root_child1.getComputedTop() + ")");
|
||||
|
||||
console.assert(0 === root_child1_child0.getComputedLeft(),
|
||||
"0 === root_child1_child0.getComputedLeft() (" +
|
||||
root_child1_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1_child0.getComputedTop(),
|
||||
"0 === root_child1_child0.getComputedTop() (" +
|
||||
root_child1_child0.getComputedTop() + ")");
|
||||
|
||||
console.assert(500 === root_child1_child1.getComputedLeft(),
|
||||
"500 === root_child1_child1.getComputedLeft() (" +
|
||||
root_child1_child1.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1_child1.getComputedTop(),
|
||||
"0 === root_child1_child1.getComputedTop() (" +
|
||||
root_child1_child1.getComputedTop() + ")");
|
||||
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,264 +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.
|
||||
*/
|
||||
|
||||
// @generated by gentest/gentest.rb from gentest/fixtures/YGAlignSelfTest.html
|
||||
|
||||
var Yoga = Yoga || require("../../sources/entry-" + process.env.TEST_ENTRY);
|
||||
|
||||
it("align_self_center", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setAlignSelf(Yoga.ALIGN_CENTER);
|
||||
root_child0.setWidth(10);
|
||||
root_child0.setHeight(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(45 === root_child0.getComputedLeft(), "45 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(10 === root_child0.getComputedWidth(), "10 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child0.getComputedHeight(), "10 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(45 === root_child0.getComputedLeft(), "45 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(10 === root_child0.getComputedWidth(), "10 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child0.getComputedHeight(), "10 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("align_self_flex_end", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setAlignSelf(Yoga.ALIGN_FLEX_END);
|
||||
root_child0.setWidth(10);
|
||||
root_child0.setHeight(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(90 === root_child0.getComputedLeft(), "90 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(10 === root_child0.getComputedWidth(), "10 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child0.getComputedHeight(), "10 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(10 === root_child0.getComputedWidth(), "10 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child0.getComputedHeight(), "10 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("align_self_flex_start", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setAlignSelf(Yoga.ALIGN_FLEX_START);
|
||||
root_child0.setWidth(10);
|
||||
root_child0.setHeight(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(10 === root_child0.getComputedWidth(), "10 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child0.getComputedHeight(), "10 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(90 === root_child0.getComputedLeft(), "90 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(10 === root_child0.getComputedWidth(), "10 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child0.getComputedHeight(), "10 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("align_self_flex_end_override_flex_start", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setAlignItems(Yoga.ALIGN_FLEX_START);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setAlignSelf(Yoga.ALIGN_FLEX_END);
|
||||
root_child0.setWidth(10);
|
||||
root_child0.setHeight(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(90 === root_child0.getComputedLeft(), "90 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(10 === root_child0.getComputedWidth(), "10 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child0.getComputedHeight(), "10 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(10 === root_child0.getComputedWidth(), "10 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child0.getComputedHeight(), "10 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("align_self_baseline", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setAlignSelf(Yoga.ALIGN_BASELINE);
|
||||
root_child0.setWidth(50);
|
||||
root_child0.setHeight(50);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
var root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setAlignSelf(Yoga.ALIGN_BASELINE);
|
||||
root_child1.setWidth(50);
|
||||
root_child1.setHeight(20);
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
var root_child1_child0 = Yoga.Node.create(config);
|
||||
root_child1_child0.setWidth(50);
|
||||
root_child1_child0.setHeight(10);
|
||||
root_child1.insertChild(root_child1_child0, 0);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(50 === root_child0.getComputedWidth(), "50 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(50 === root_child0.getComputedHeight(), "50 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(50 === root_child1.getComputedLeft(), "50 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(40 === root_child1.getComputedTop(), "40 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(50 === root_child1.getComputedWidth(), "50 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(20 === root_child1.getComputedHeight(), "20 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1_child0.getComputedLeft(), "0 === root_child1_child0.getComputedLeft() (" + root_child1_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1_child0.getComputedTop(), "0 === root_child1_child0.getComputedTop() (" + root_child1_child0.getComputedTop() + ")");
|
||||
console.assert(50 === root_child1_child0.getComputedWidth(), "50 === root_child1_child0.getComputedWidth() (" + root_child1_child0.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child1_child0.getComputedHeight(), "10 === root_child1_child0.getComputedHeight() (" + root_child1_child0.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(50 === root_child0.getComputedLeft(), "50 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(50 === root_child0.getComputedWidth(), "50 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(50 === root_child0.getComputedHeight(), "50 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(40 === root_child1.getComputedTop(), "40 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(50 === root_child1.getComputedWidth(), "50 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(20 === root_child1.getComputedHeight(), "20 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1_child0.getComputedLeft(), "0 === root_child1_child0.getComputedLeft() (" + root_child1_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1_child0.getComputedTop(), "0 === root_child1_child0.getComputedTop() (" + root_child1_child0.getComputedTop() + ")");
|
||||
console.assert(50 === root_child1_child0.getComputedWidth(), "50 === root_child1_child0.getComputedWidth() (" + root_child1_child0.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child1_child0.getComputedHeight(), "10 === root_child1_child0.getComputedHeight() (" + root_child1_child0.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
@@ -1,294 +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.
|
||||
*/
|
||||
|
||||
// @generated by gentest/gentest.rb from gentest/fixtures/YGAndroidNewsFeed.html
|
||||
|
||||
var Yoga = Yoga || require("../../sources/entry-" + process.env.TEST_ENTRY);
|
||||
|
||||
it("android_news_feed", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setAlignContent(Yoga.ALIGN_STRETCH);
|
||||
root.setWidth(1080);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
var root_child0_child0 = Yoga.Node.create(config);
|
||||
root_child0_child0.setAlignContent(Yoga.ALIGN_STRETCH);
|
||||
root_child0.insertChild(root_child0_child0, 0);
|
||||
|
||||
var root_child0_child0_child0 = Yoga.Node.create(config);
|
||||
root_child0_child0_child0.setAlignContent(Yoga.ALIGN_STRETCH);
|
||||
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
||||
|
||||
var root_child0_child0_child0_child0 = Yoga.Node.create(config);
|
||||
root_child0_child0_child0_child0.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root_child0_child0_child0_child0.setAlignContent(Yoga.ALIGN_STRETCH);
|
||||
root_child0_child0_child0_child0.setAlignItems(Yoga.ALIGN_FLEX_START);
|
||||
root_child0_child0_child0_child0.setMargin(Yoga.EDGE_START, 36);
|
||||
root_child0_child0_child0_child0.setMargin(Yoga.EDGE_TOP, 24);
|
||||
root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0);
|
||||
|
||||
var root_child0_child0_child0_child0_child0 = Yoga.Node.create(config);
|
||||
root_child0_child0_child0_child0_child0.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root_child0_child0_child0_child0_child0.setAlignContent(Yoga.ALIGN_STRETCH);
|
||||
root_child0_child0_child0_child0.insertChild(root_child0_child0_child0_child0_child0, 0);
|
||||
|
||||
var root_child0_child0_child0_child0_child0_child0 = Yoga.Node.create(config);
|
||||
root_child0_child0_child0_child0_child0_child0.setAlignContent(Yoga.ALIGN_STRETCH);
|
||||
root_child0_child0_child0_child0_child0_child0.setWidth(120);
|
||||
root_child0_child0_child0_child0_child0_child0.setHeight(120);
|
||||
root_child0_child0_child0_child0_child0.insertChild(root_child0_child0_child0_child0_child0_child0, 0);
|
||||
|
||||
var root_child0_child0_child0_child0_child1 = Yoga.Node.create(config);
|
||||
root_child0_child0_child0_child0_child1.setAlignContent(Yoga.ALIGN_STRETCH);
|
||||
root_child0_child0_child0_child0_child1.setFlexShrink(1);
|
||||
root_child0_child0_child0_child0_child1.setMargin(Yoga.EDGE_RIGHT, 36);
|
||||
root_child0_child0_child0_child0_child1.setPadding(Yoga.EDGE_LEFT, 36);
|
||||
root_child0_child0_child0_child0_child1.setPadding(Yoga.EDGE_TOP, 21);
|
||||
root_child0_child0_child0_child0_child1.setPadding(Yoga.EDGE_RIGHT, 36);
|
||||
root_child0_child0_child0_child0_child1.setPadding(Yoga.EDGE_BOTTOM, 18);
|
||||
root_child0_child0_child0_child0.insertChild(root_child0_child0_child0_child0_child1, 1);
|
||||
|
||||
var root_child0_child0_child0_child0_child1_child0 = Yoga.Node.create(config);
|
||||
root_child0_child0_child0_child0_child1_child0.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root_child0_child0_child0_child0_child1_child0.setAlignContent(Yoga.ALIGN_STRETCH);
|
||||
root_child0_child0_child0_child0_child1_child0.setFlexShrink(1);
|
||||
root_child0_child0_child0_child0_child1.insertChild(root_child0_child0_child0_child0_child1_child0, 0);
|
||||
|
||||
var root_child0_child0_child0_child0_child1_child1 = Yoga.Node.create(config);
|
||||
root_child0_child0_child0_child0_child1_child1.setAlignContent(Yoga.ALIGN_STRETCH);
|
||||
root_child0_child0_child0_child0_child1_child1.setFlexShrink(1);
|
||||
root_child0_child0_child0_child0_child1.insertChild(root_child0_child0_child0_child0_child1_child1, 1);
|
||||
|
||||
var root_child0_child0_child1 = Yoga.Node.create(config);
|
||||
root_child0_child0_child1.setAlignContent(Yoga.ALIGN_STRETCH);
|
||||
root_child0_child0.insertChild(root_child0_child0_child1, 1);
|
||||
|
||||
var root_child0_child0_child1_child0 = Yoga.Node.create(config);
|
||||
root_child0_child0_child1_child0.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root_child0_child0_child1_child0.setAlignContent(Yoga.ALIGN_STRETCH);
|
||||
root_child0_child0_child1_child0.setAlignItems(Yoga.ALIGN_FLEX_START);
|
||||
root_child0_child0_child1_child0.setMargin(Yoga.EDGE_START, 174);
|
||||
root_child0_child0_child1_child0.setMargin(Yoga.EDGE_TOP, 24);
|
||||
root_child0_child0_child1.insertChild(root_child0_child0_child1_child0, 0);
|
||||
|
||||
var root_child0_child0_child1_child0_child0 = Yoga.Node.create(config);
|
||||
root_child0_child0_child1_child0_child0.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root_child0_child0_child1_child0_child0.setAlignContent(Yoga.ALIGN_STRETCH);
|
||||
root_child0_child0_child1_child0.insertChild(root_child0_child0_child1_child0_child0, 0);
|
||||
|
||||
var root_child0_child0_child1_child0_child0_child0 = Yoga.Node.create(config);
|
||||
root_child0_child0_child1_child0_child0_child0.setAlignContent(Yoga.ALIGN_STRETCH);
|
||||
root_child0_child0_child1_child0_child0_child0.setWidth(72);
|
||||
root_child0_child0_child1_child0_child0_child0.setHeight(72);
|
||||
root_child0_child0_child1_child0_child0.insertChild(root_child0_child0_child1_child0_child0_child0, 0);
|
||||
|
||||
var root_child0_child0_child1_child0_child1 = Yoga.Node.create(config);
|
||||
root_child0_child0_child1_child0_child1.setAlignContent(Yoga.ALIGN_STRETCH);
|
||||
root_child0_child0_child1_child0_child1.setFlexShrink(1);
|
||||
root_child0_child0_child1_child0_child1.setMargin(Yoga.EDGE_RIGHT, 36);
|
||||
root_child0_child0_child1_child0_child1.setPadding(Yoga.EDGE_LEFT, 36);
|
||||
root_child0_child0_child1_child0_child1.setPadding(Yoga.EDGE_TOP, 21);
|
||||
root_child0_child0_child1_child0_child1.setPadding(Yoga.EDGE_RIGHT, 36);
|
||||
root_child0_child0_child1_child0_child1.setPadding(Yoga.EDGE_BOTTOM, 18);
|
||||
root_child0_child0_child1_child0.insertChild(root_child0_child0_child1_child0_child1, 1);
|
||||
|
||||
var root_child0_child0_child1_child0_child1_child0 = Yoga.Node.create(config);
|
||||
root_child0_child0_child1_child0_child1_child0.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root_child0_child0_child1_child0_child1_child0.setAlignContent(Yoga.ALIGN_STRETCH);
|
||||
root_child0_child0_child1_child0_child1_child0.setFlexShrink(1);
|
||||
root_child0_child0_child1_child0_child1.insertChild(root_child0_child0_child1_child0_child1_child0, 0);
|
||||
|
||||
var root_child0_child0_child1_child0_child1_child1 = Yoga.Node.create(config);
|
||||
root_child0_child0_child1_child0_child1_child1.setAlignContent(Yoga.ALIGN_STRETCH);
|
||||
root_child0_child0_child1_child0_child1_child1.setFlexShrink(1);
|
||||
root_child0_child0_child1_child0_child1.insertChild(root_child0_child0_child1_child0_child1_child1, 1);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(1080 === root.getComputedWidth(), "1080 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(240 === root.getComputedHeight(), "240 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(1080 === root_child0.getComputedWidth(), "1080 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(240 === root_child0.getComputedHeight(), "240 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0_child0.getComputedLeft(), "0 === root_child0_child0.getComputedLeft() (" + root_child0_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0_child0.getComputedTop(), "0 === root_child0_child0.getComputedTop() (" + root_child0_child0.getComputedTop() + ")");
|
||||
console.assert(1080 === root_child0_child0.getComputedWidth(), "1080 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
|
||||
console.assert(240 === root_child0_child0.getComputedHeight(), "240 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0_child0_child0.getComputedLeft(), "0 === root_child0_child0_child0.getComputedLeft() (" + root_child0_child0_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0_child0_child0.getComputedTop(), "0 === root_child0_child0_child0.getComputedTop() (" + root_child0_child0_child0.getComputedTop() + ")");
|
||||
console.assert(1080 === root_child0_child0_child0.getComputedWidth(), "1080 === root_child0_child0_child0.getComputedWidth() (" + root_child0_child0_child0.getComputedWidth() + ")");
|
||||
console.assert(144 === root_child0_child0_child0.getComputedHeight(), "144 === root_child0_child0_child0.getComputedHeight() (" + root_child0_child0_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(36 === root_child0_child0_child0_child0.getComputedLeft(), "36 === root_child0_child0_child0_child0.getComputedLeft() (" + root_child0_child0_child0_child0.getComputedLeft() + ")");
|
||||
console.assert(24 === root_child0_child0_child0_child0.getComputedTop(), "24 === root_child0_child0_child0_child0.getComputedTop() (" + root_child0_child0_child0_child0.getComputedTop() + ")");
|
||||
console.assert(1044 === root_child0_child0_child0_child0.getComputedWidth(), "1044 === root_child0_child0_child0_child0.getComputedWidth() (" + root_child0_child0_child0_child0.getComputedWidth() + ")");
|
||||
console.assert(120 === root_child0_child0_child0_child0.getComputedHeight(), "120 === root_child0_child0_child0_child0.getComputedHeight() (" + root_child0_child0_child0_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0_child0_child0_child0_child0.getComputedLeft(), "0 === root_child0_child0_child0_child0_child0.getComputedLeft() (" + root_child0_child0_child0_child0_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0_child0_child0_child0_child0.getComputedTop(), "0 === root_child0_child0_child0_child0_child0.getComputedTop() (" + root_child0_child0_child0_child0_child0.getComputedTop() + ")");
|
||||
console.assert(120 === root_child0_child0_child0_child0_child0.getComputedWidth(), "120 === root_child0_child0_child0_child0_child0.getComputedWidth() (" + root_child0_child0_child0_child0_child0.getComputedWidth() + ")");
|
||||
console.assert(120 === root_child0_child0_child0_child0_child0.getComputedHeight(), "120 === root_child0_child0_child0_child0_child0.getComputedHeight() (" + root_child0_child0_child0_child0_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0_child0_child0_child0_child0_child0.getComputedLeft(), "0 === root_child0_child0_child0_child0_child0_child0.getComputedLeft() (" + root_child0_child0_child0_child0_child0_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0_child0_child0_child0_child0_child0.getComputedTop(), "0 === root_child0_child0_child0_child0_child0_child0.getComputedTop() (" + root_child0_child0_child0_child0_child0_child0.getComputedTop() + ")");
|
||||
console.assert(120 === root_child0_child0_child0_child0_child0_child0.getComputedWidth(), "120 === root_child0_child0_child0_child0_child0_child0.getComputedWidth() (" + root_child0_child0_child0_child0_child0_child0.getComputedWidth() + ")");
|
||||
console.assert(120 === root_child0_child0_child0_child0_child0_child0.getComputedHeight(), "120 === root_child0_child0_child0_child0_child0_child0.getComputedHeight() (" + root_child0_child0_child0_child0_child0_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(120 === root_child0_child0_child0_child0_child1.getComputedLeft(), "120 === root_child0_child0_child0_child0_child1.getComputedLeft() (" + root_child0_child0_child0_child0_child1.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0_child0_child0_child0_child1.getComputedTop(), "0 === root_child0_child0_child0_child0_child1.getComputedTop() (" + root_child0_child0_child0_child0_child1.getComputedTop() + ")");
|
||||
console.assert(72 === root_child0_child0_child0_child0_child1.getComputedWidth(), "72 === root_child0_child0_child0_child0_child1.getComputedWidth() (" + root_child0_child0_child0_child0_child1.getComputedWidth() + ")");
|
||||
console.assert(39 === root_child0_child0_child0_child0_child1.getComputedHeight(), "39 === root_child0_child0_child0_child0_child1.getComputedHeight() (" + root_child0_child0_child0_child0_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(36 === root_child0_child0_child0_child0_child1_child0.getComputedLeft(), "36 === root_child0_child0_child0_child0_child1_child0.getComputedLeft() (" + root_child0_child0_child0_child0_child1_child0.getComputedLeft() + ")");
|
||||
console.assert(21 === root_child0_child0_child0_child0_child1_child0.getComputedTop(), "21 === root_child0_child0_child0_child0_child1_child0.getComputedTop() (" + root_child0_child0_child0_child0_child1_child0.getComputedTop() + ")");
|
||||
console.assert(0 === root_child0_child0_child0_child0_child1_child0.getComputedWidth(), "0 === root_child0_child0_child0_child0_child1_child0.getComputedWidth() (" + root_child0_child0_child0_child0_child1_child0.getComputedWidth() + ")");
|
||||
console.assert(0 === root_child0_child0_child0_child0_child1_child0.getComputedHeight(), "0 === root_child0_child0_child0_child0_child1_child0.getComputedHeight() (" + root_child0_child0_child0_child0_child1_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(36 === root_child0_child0_child0_child0_child1_child1.getComputedLeft(), "36 === root_child0_child0_child0_child0_child1_child1.getComputedLeft() (" + root_child0_child0_child0_child0_child1_child1.getComputedLeft() + ")");
|
||||
console.assert(21 === root_child0_child0_child0_child0_child1_child1.getComputedTop(), "21 === root_child0_child0_child0_child0_child1_child1.getComputedTop() (" + root_child0_child0_child0_child0_child1_child1.getComputedTop() + ")");
|
||||
console.assert(0 === root_child0_child0_child0_child0_child1_child1.getComputedWidth(), "0 === root_child0_child0_child0_child0_child1_child1.getComputedWidth() (" + root_child0_child0_child0_child0_child1_child1.getComputedWidth() + ")");
|
||||
console.assert(0 === root_child0_child0_child0_child0_child1_child1.getComputedHeight(), "0 === root_child0_child0_child0_child0_child1_child1.getComputedHeight() (" + root_child0_child0_child0_child0_child1_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0_child0_child1.getComputedLeft(), "0 === root_child0_child0_child1.getComputedLeft() (" + root_child0_child0_child1.getComputedLeft() + ")");
|
||||
console.assert(144 === root_child0_child0_child1.getComputedTop(), "144 === root_child0_child0_child1.getComputedTop() (" + root_child0_child0_child1.getComputedTop() + ")");
|
||||
console.assert(1080 === root_child0_child0_child1.getComputedWidth(), "1080 === root_child0_child0_child1.getComputedWidth() (" + root_child0_child0_child1.getComputedWidth() + ")");
|
||||
console.assert(96 === root_child0_child0_child1.getComputedHeight(), "96 === root_child0_child0_child1.getComputedHeight() (" + root_child0_child0_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(174 === root_child0_child0_child1_child0.getComputedLeft(), "174 === root_child0_child0_child1_child0.getComputedLeft() (" + root_child0_child0_child1_child0.getComputedLeft() + ")");
|
||||
console.assert(24 === root_child0_child0_child1_child0.getComputedTop(), "24 === root_child0_child0_child1_child0.getComputedTop() (" + root_child0_child0_child1_child0.getComputedTop() + ")");
|
||||
console.assert(906 === root_child0_child0_child1_child0.getComputedWidth(), "906 === root_child0_child0_child1_child0.getComputedWidth() (" + root_child0_child0_child1_child0.getComputedWidth() + ")");
|
||||
console.assert(72 === root_child0_child0_child1_child0.getComputedHeight(), "72 === root_child0_child0_child1_child0.getComputedHeight() (" + root_child0_child0_child1_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0_child0_child1_child0_child0.getComputedLeft(), "0 === root_child0_child0_child1_child0_child0.getComputedLeft() (" + root_child0_child0_child1_child0_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0_child0_child1_child0_child0.getComputedTop(), "0 === root_child0_child0_child1_child0_child0.getComputedTop() (" + root_child0_child0_child1_child0_child0.getComputedTop() + ")");
|
||||
console.assert(72 === root_child0_child0_child1_child0_child0.getComputedWidth(), "72 === root_child0_child0_child1_child0_child0.getComputedWidth() (" + root_child0_child0_child1_child0_child0.getComputedWidth() + ")");
|
||||
console.assert(72 === root_child0_child0_child1_child0_child0.getComputedHeight(), "72 === root_child0_child0_child1_child0_child0.getComputedHeight() (" + root_child0_child0_child1_child0_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0_child0_child1_child0_child0_child0.getComputedLeft(), "0 === root_child0_child0_child1_child0_child0_child0.getComputedLeft() (" + root_child0_child0_child1_child0_child0_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0_child0_child1_child0_child0_child0.getComputedTop(), "0 === root_child0_child0_child1_child0_child0_child0.getComputedTop() (" + root_child0_child0_child1_child0_child0_child0.getComputedTop() + ")");
|
||||
console.assert(72 === root_child0_child0_child1_child0_child0_child0.getComputedWidth(), "72 === root_child0_child0_child1_child0_child0_child0.getComputedWidth() (" + root_child0_child0_child1_child0_child0_child0.getComputedWidth() + ")");
|
||||
console.assert(72 === root_child0_child0_child1_child0_child0_child0.getComputedHeight(), "72 === root_child0_child0_child1_child0_child0_child0.getComputedHeight() (" + root_child0_child0_child1_child0_child0_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(72 === root_child0_child0_child1_child0_child1.getComputedLeft(), "72 === root_child0_child0_child1_child0_child1.getComputedLeft() (" + root_child0_child0_child1_child0_child1.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0_child0_child1_child0_child1.getComputedTop(), "0 === root_child0_child0_child1_child0_child1.getComputedTop() (" + root_child0_child0_child1_child0_child1.getComputedTop() + ")");
|
||||
console.assert(72 === root_child0_child0_child1_child0_child1.getComputedWidth(), "72 === root_child0_child0_child1_child0_child1.getComputedWidth() (" + root_child0_child0_child1_child0_child1.getComputedWidth() + ")");
|
||||
console.assert(39 === root_child0_child0_child1_child0_child1.getComputedHeight(), "39 === root_child0_child0_child1_child0_child1.getComputedHeight() (" + root_child0_child0_child1_child0_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(36 === root_child0_child0_child1_child0_child1_child0.getComputedLeft(), "36 === root_child0_child0_child1_child0_child1_child0.getComputedLeft() (" + root_child0_child0_child1_child0_child1_child0.getComputedLeft() + ")");
|
||||
console.assert(21 === root_child0_child0_child1_child0_child1_child0.getComputedTop(), "21 === root_child0_child0_child1_child0_child1_child0.getComputedTop() (" + root_child0_child0_child1_child0_child1_child0.getComputedTop() + ")");
|
||||
console.assert(0 === root_child0_child0_child1_child0_child1_child0.getComputedWidth(), "0 === root_child0_child0_child1_child0_child1_child0.getComputedWidth() (" + root_child0_child0_child1_child0_child1_child0.getComputedWidth() + ")");
|
||||
console.assert(0 === root_child0_child0_child1_child0_child1_child0.getComputedHeight(), "0 === root_child0_child0_child1_child0_child1_child0.getComputedHeight() (" + root_child0_child0_child1_child0_child1_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(36 === root_child0_child0_child1_child0_child1_child1.getComputedLeft(), "36 === root_child0_child0_child1_child0_child1_child1.getComputedLeft() (" + root_child0_child0_child1_child0_child1_child1.getComputedLeft() + ")");
|
||||
console.assert(21 === root_child0_child0_child1_child0_child1_child1.getComputedTop(), "21 === root_child0_child0_child1_child0_child1_child1.getComputedTop() (" + root_child0_child0_child1_child0_child1_child1.getComputedTop() + ")");
|
||||
console.assert(0 === root_child0_child0_child1_child0_child1_child1.getComputedWidth(), "0 === root_child0_child0_child1_child0_child1_child1.getComputedWidth() (" + root_child0_child0_child1_child0_child1_child1.getComputedWidth() + ")");
|
||||
console.assert(0 === root_child0_child0_child1_child0_child1_child1.getComputedHeight(), "0 === root_child0_child0_child1_child0_child1_child1.getComputedHeight() (" + root_child0_child0_child1_child0_child1_child1.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(1080 === root.getComputedWidth(), "1080 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(240 === root.getComputedHeight(), "240 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(1080 === root_child0.getComputedWidth(), "1080 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(240 === root_child0.getComputedHeight(), "240 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0_child0.getComputedLeft(), "0 === root_child0_child0.getComputedLeft() (" + root_child0_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0_child0.getComputedTop(), "0 === root_child0_child0.getComputedTop() (" + root_child0_child0.getComputedTop() + ")");
|
||||
console.assert(1080 === root_child0_child0.getComputedWidth(), "1080 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
|
||||
console.assert(240 === root_child0_child0.getComputedHeight(), "240 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0_child0_child0.getComputedLeft(), "0 === root_child0_child0_child0.getComputedLeft() (" + root_child0_child0_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0_child0_child0.getComputedTop(), "0 === root_child0_child0_child0.getComputedTop() (" + root_child0_child0_child0.getComputedTop() + ")");
|
||||
console.assert(1080 === root_child0_child0_child0.getComputedWidth(), "1080 === root_child0_child0_child0.getComputedWidth() (" + root_child0_child0_child0.getComputedWidth() + ")");
|
||||
console.assert(144 === root_child0_child0_child0.getComputedHeight(), "144 === root_child0_child0_child0.getComputedHeight() (" + root_child0_child0_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0_child0_child0_child0.getComputedLeft(), "0 === root_child0_child0_child0_child0.getComputedLeft() (" + root_child0_child0_child0_child0.getComputedLeft() + ")");
|
||||
console.assert(24 === root_child0_child0_child0_child0.getComputedTop(), "24 === root_child0_child0_child0_child0.getComputedTop() (" + root_child0_child0_child0_child0.getComputedTop() + ")");
|
||||
console.assert(1044 === root_child0_child0_child0_child0.getComputedWidth(), "1044 === root_child0_child0_child0_child0.getComputedWidth() (" + root_child0_child0_child0_child0.getComputedWidth() + ")");
|
||||
console.assert(120 === root_child0_child0_child0_child0.getComputedHeight(), "120 === root_child0_child0_child0_child0.getComputedHeight() (" + root_child0_child0_child0_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(924 === root_child0_child0_child0_child0_child0.getComputedLeft(), "924 === root_child0_child0_child0_child0_child0.getComputedLeft() (" + root_child0_child0_child0_child0_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0_child0_child0_child0_child0.getComputedTop(), "0 === root_child0_child0_child0_child0_child0.getComputedTop() (" + root_child0_child0_child0_child0_child0.getComputedTop() + ")");
|
||||
console.assert(120 === root_child0_child0_child0_child0_child0.getComputedWidth(), "120 === root_child0_child0_child0_child0_child0.getComputedWidth() (" + root_child0_child0_child0_child0_child0.getComputedWidth() + ")");
|
||||
console.assert(120 === root_child0_child0_child0_child0_child0.getComputedHeight(), "120 === root_child0_child0_child0_child0_child0.getComputedHeight() (" + root_child0_child0_child0_child0_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0_child0_child0_child0_child0_child0.getComputedLeft(), "0 === root_child0_child0_child0_child0_child0_child0.getComputedLeft() (" + root_child0_child0_child0_child0_child0_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0_child0_child0_child0_child0_child0.getComputedTop(), "0 === root_child0_child0_child0_child0_child0_child0.getComputedTop() (" + root_child0_child0_child0_child0_child0_child0.getComputedTop() + ")");
|
||||
console.assert(120 === root_child0_child0_child0_child0_child0_child0.getComputedWidth(), "120 === root_child0_child0_child0_child0_child0_child0.getComputedWidth() (" + root_child0_child0_child0_child0_child0_child0.getComputedWidth() + ")");
|
||||
console.assert(120 === root_child0_child0_child0_child0_child0_child0.getComputedHeight(), "120 === root_child0_child0_child0_child0_child0_child0.getComputedHeight() (" + root_child0_child0_child0_child0_child0_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(816 === root_child0_child0_child0_child0_child1.getComputedLeft(), "816 === root_child0_child0_child0_child0_child1.getComputedLeft() (" + root_child0_child0_child0_child0_child1.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0_child0_child0_child0_child1.getComputedTop(), "0 === root_child0_child0_child0_child0_child1.getComputedTop() (" + root_child0_child0_child0_child0_child1.getComputedTop() + ")");
|
||||
console.assert(72 === root_child0_child0_child0_child0_child1.getComputedWidth(), "72 === root_child0_child0_child0_child0_child1.getComputedWidth() (" + root_child0_child0_child0_child0_child1.getComputedWidth() + ")");
|
||||
console.assert(39 === root_child0_child0_child0_child0_child1.getComputedHeight(), "39 === root_child0_child0_child0_child0_child1.getComputedHeight() (" + root_child0_child0_child0_child0_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(36 === root_child0_child0_child0_child0_child1_child0.getComputedLeft(), "36 === root_child0_child0_child0_child0_child1_child0.getComputedLeft() (" + root_child0_child0_child0_child0_child1_child0.getComputedLeft() + ")");
|
||||
console.assert(21 === root_child0_child0_child0_child0_child1_child0.getComputedTop(), "21 === root_child0_child0_child0_child0_child1_child0.getComputedTop() (" + root_child0_child0_child0_child0_child1_child0.getComputedTop() + ")");
|
||||
console.assert(0 === root_child0_child0_child0_child0_child1_child0.getComputedWidth(), "0 === root_child0_child0_child0_child0_child1_child0.getComputedWidth() (" + root_child0_child0_child0_child0_child1_child0.getComputedWidth() + ")");
|
||||
console.assert(0 === root_child0_child0_child0_child0_child1_child0.getComputedHeight(), "0 === root_child0_child0_child0_child0_child1_child0.getComputedHeight() (" + root_child0_child0_child0_child0_child1_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(36 === root_child0_child0_child0_child0_child1_child1.getComputedLeft(), "36 === root_child0_child0_child0_child0_child1_child1.getComputedLeft() (" + root_child0_child0_child0_child0_child1_child1.getComputedLeft() + ")");
|
||||
console.assert(21 === root_child0_child0_child0_child0_child1_child1.getComputedTop(), "21 === root_child0_child0_child0_child0_child1_child1.getComputedTop() (" + root_child0_child0_child0_child0_child1_child1.getComputedTop() + ")");
|
||||
console.assert(0 === root_child0_child0_child0_child0_child1_child1.getComputedWidth(), "0 === root_child0_child0_child0_child0_child1_child1.getComputedWidth() (" + root_child0_child0_child0_child0_child1_child1.getComputedWidth() + ")");
|
||||
console.assert(0 === root_child0_child0_child0_child0_child1_child1.getComputedHeight(), "0 === root_child0_child0_child0_child0_child1_child1.getComputedHeight() (" + root_child0_child0_child0_child0_child1_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0_child0_child1.getComputedLeft(), "0 === root_child0_child0_child1.getComputedLeft() (" + root_child0_child0_child1.getComputedLeft() + ")");
|
||||
console.assert(144 === root_child0_child0_child1.getComputedTop(), "144 === root_child0_child0_child1.getComputedTop() (" + root_child0_child0_child1.getComputedTop() + ")");
|
||||
console.assert(1080 === root_child0_child0_child1.getComputedWidth(), "1080 === root_child0_child0_child1.getComputedWidth() (" + root_child0_child0_child1.getComputedWidth() + ")");
|
||||
console.assert(96 === root_child0_child0_child1.getComputedHeight(), "96 === root_child0_child0_child1.getComputedHeight() (" + root_child0_child0_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0_child0_child1_child0.getComputedLeft(), "0 === root_child0_child0_child1_child0.getComputedLeft() (" + root_child0_child0_child1_child0.getComputedLeft() + ")");
|
||||
console.assert(24 === root_child0_child0_child1_child0.getComputedTop(), "24 === root_child0_child0_child1_child0.getComputedTop() (" + root_child0_child0_child1_child0.getComputedTop() + ")");
|
||||
console.assert(906 === root_child0_child0_child1_child0.getComputedWidth(), "906 === root_child0_child0_child1_child0.getComputedWidth() (" + root_child0_child0_child1_child0.getComputedWidth() + ")");
|
||||
console.assert(72 === root_child0_child0_child1_child0.getComputedHeight(), "72 === root_child0_child0_child1_child0.getComputedHeight() (" + root_child0_child0_child1_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(834 === root_child0_child0_child1_child0_child0.getComputedLeft(), "834 === root_child0_child0_child1_child0_child0.getComputedLeft() (" + root_child0_child0_child1_child0_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0_child0_child1_child0_child0.getComputedTop(), "0 === root_child0_child0_child1_child0_child0.getComputedTop() (" + root_child0_child0_child1_child0_child0.getComputedTop() + ")");
|
||||
console.assert(72 === root_child0_child0_child1_child0_child0.getComputedWidth(), "72 === root_child0_child0_child1_child0_child0.getComputedWidth() (" + root_child0_child0_child1_child0_child0.getComputedWidth() + ")");
|
||||
console.assert(72 === root_child0_child0_child1_child0_child0.getComputedHeight(), "72 === root_child0_child0_child1_child0_child0.getComputedHeight() (" + root_child0_child0_child1_child0_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0_child0_child1_child0_child0_child0.getComputedLeft(), "0 === root_child0_child0_child1_child0_child0_child0.getComputedLeft() (" + root_child0_child0_child1_child0_child0_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0_child0_child1_child0_child0_child0.getComputedTop(), "0 === root_child0_child0_child1_child0_child0_child0.getComputedTop() (" + root_child0_child0_child1_child0_child0_child0.getComputedTop() + ")");
|
||||
console.assert(72 === root_child0_child0_child1_child0_child0_child0.getComputedWidth(), "72 === root_child0_child0_child1_child0_child0_child0.getComputedWidth() (" + root_child0_child0_child1_child0_child0_child0.getComputedWidth() + ")");
|
||||
console.assert(72 === root_child0_child0_child1_child0_child0_child0.getComputedHeight(), "72 === root_child0_child0_child1_child0_child0_child0.getComputedHeight() (" + root_child0_child0_child1_child0_child0_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(726 === root_child0_child0_child1_child0_child1.getComputedLeft(), "726 === root_child0_child0_child1_child0_child1.getComputedLeft() (" + root_child0_child0_child1_child0_child1.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0_child0_child1_child0_child1.getComputedTop(), "0 === root_child0_child0_child1_child0_child1.getComputedTop() (" + root_child0_child0_child1_child0_child1.getComputedTop() + ")");
|
||||
console.assert(72 === root_child0_child0_child1_child0_child1.getComputedWidth(), "72 === root_child0_child0_child1_child0_child1.getComputedWidth() (" + root_child0_child0_child1_child0_child1.getComputedWidth() + ")");
|
||||
console.assert(39 === root_child0_child0_child1_child0_child1.getComputedHeight(), "39 === root_child0_child0_child1_child0_child1.getComputedHeight() (" + root_child0_child0_child1_child0_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(36 === root_child0_child0_child1_child0_child1_child0.getComputedLeft(), "36 === root_child0_child0_child1_child0_child1_child0.getComputedLeft() (" + root_child0_child0_child1_child0_child1_child0.getComputedLeft() + ")");
|
||||
console.assert(21 === root_child0_child0_child1_child0_child1_child0.getComputedTop(), "21 === root_child0_child0_child1_child0_child1_child0.getComputedTop() (" + root_child0_child0_child1_child0_child1_child0.getComputedTop() + ")");
|
||||
console.assert(0 === root_child0_child0_child1_child0_child1_child0.getComputedWidth(), "0 === root_child0_child0_child1_child0_child1_child0.getComputedWidth() (" + root_child0_child0_child1_child0_child1_child0.getComputedWidth() + ")");
|
||||
console.assert(0 === root_child0_child0_child1_child0_child1_child0.getComputedHeight(), "0 === root_child0_child0_child1_child0_child1_child0.getComputedHeight() (" + root_child0_child0_child1_child0_child1_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(36 === root_child0_child0_child1_child0_child1_child1.getComputedLeft(), "36 === root_child0_child0_child1_child0_child1_child1.getComputedLeft() (" + root_child0_child0_child1_child0_child1_child1.getComputedLeft() + ")");
|
||||
console.assert(21 === root_child0_child0_child1_child0_child1_child1.getComputedTop(), "21 === root_child0_child0_child1_child0_child1_child1.getComputedTop() (" + root_child0_child0_child1_child0_child1_child1.getComputedTop() + ")");
|
||||
console.assert(0 === root_child0_child0_child1_child0_child1_child1.getComputedWidth(), "0 === root_child0_child0_child1_child0_child1_child1.getComputedWidth() (" + root_child0_child0_child1_child0_child1_child1.getComputedWidth() + ")");
|
||||
console.assert(0 === root_child0_child0_child1_child0_child1_child1.getComputedHeight(), "0 === root_child0_child0_child1_child0_child1_child1.getComputedHeight() (" + root_child0_child0_child1_child0_child1_child1.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
@@ -1,227 +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.
|
||||
*/
|
||||
|
||||
// @generated by gentest/gentest.rb from gentest/fixtures/YGBorderTest.html
|
||||
|
||||
var Yoga = Yoga || require("../../sources/entry-" + process.env.TEST_ENTRY);
|
||||
|
||||
it("border_no_size", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setBorder(Yoga.EDGE_LEFT, 10);
|
||||
root.setBorder(Yoga.EDGE_TOP, 10);
|
||||
root.setBorder(Yoga.EDGE_RIGHT, 10);
|
||||
root.setBorder(Yoga.EDGE_BOTTOM, 10);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(20 === root.getComputedWidth(), "20 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(20 === root.getComputedHeight(), "20 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(20 === root.getComputedWidth(), "20 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(20 === root.getComputedHeight(), "20 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("border_container_match_child", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setBorder(Yoga.EDGE_LEFT, 10);
|
||||
root.setBorder(Yoga.EDGE_TOP, 10);
|
||||
root.setBorder(Yoga.EDGE_RIGHT, 10);
|
||||
root.setBorder(Yoga.EDGE_BOTTOM, 10);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setWidth(10);
|
||||
root_child0.setHeight(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(30 === root.getComputedWidth(), "30 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(30 === root.getComputedHeight(), "30 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(10 === root_child0.getComputedLeft(), "10 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(10 === root_child0.getComputedTop(), "10 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(10 === root_child0.getComputedWidth(), "10 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child0.getComputedHeight(), "10 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(30 === root.getComputedWidth(), "30 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(30 === root.getComputedHeight(), "30 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(10 === root_child0.getComputedLeft(), "10 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(10 === root_child0.getComputedTop(), "10 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(10 === root_child0.getComputedWidth(), "10 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child0.getComputedHeight(), "10 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("border_flex_child", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setBorder(Yoga.EDGE_LEFT, 10);
|
||||
root.setBorder(Yoga.EDGE_TOP, 10);
|
||||
root.setBorder(Yoga.EDGE_RIGHT, 10);
|
||||
root.setBorder(Yoga.EDGE_BOTTOM, 10);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setFlexGrow(1);
|
||||
root_child0.setWidth(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(10 === root_child0.getComputedLeft(), "10 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(10 === root_child0.getComputedTop(), "10 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(10 === root_child0.getComputedWidth(), "10 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(80 === root_child0.getComputedHeight(), "80 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(80 === root_child0.getComputedLeft(), "80 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(10 === root_child0.getComputedTop(), "10 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(10 === root_child0.getComputedWidth(), "10 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(80 === root_child0.getComputedHeight(), "80 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("border_stretch_child", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setBorder(Yoga.EDGE_LEFT, 10);
|
||||
root.setBorder(Yoga.EDGE_TOP, 10);
|
||||
root.setBorder(Yoga.EDGE_RIGHT, 10);
|
||||
root.setBorder(Yoga.EDGE_BOTTOM, 10);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setHeight(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(10 === root_child0.getComputedLeft(), "10 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(10 === root_child0.getComputedTop(), "10 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(80 === root_child0.getComputedWidth(), "80 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child0.getComputedHeight(), "10 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(10 === root_child0.getComputedLeft(), "10 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(10 === root_child0.getComputedTop(), "10 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(80 === root_child0.getComputedWidth(), "80 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child0.getComputedHeight(), "10 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("border_center_child", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setJustifyContent(Yoga.JUSTIFY_CENTER);
|
||||
root.setAlignItems(Yoga.ALIGN_CENTER);
|
||||
root.setBorder(Yoga.EDGE_START, 10);
|
||||
root.setBorder(Yoga.EDGE_END, 20);
|
||||
root.setBorder(Yoga.EDGE_BOTTOM, 20);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setWidth(10);
|
||||
root_child0.setHeight(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(40 === root_child0.getComputedLeft(), "40 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(35 === root_child0.getComputedTop(), "35 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(10 === root_child0.getComputedWidth(), "10 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child0.getComputedHeight(), "10 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(50 === root_child0.getComputedLeft(), "50 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(35 === root_child0.getComputedTop(), "35 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(10 === root_child0.getComputedWidth(), "10 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child0.getComputedHeight(), "10 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
@@ -1,31 +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.
|
||||
*/
|
||||
|
||||
var Yoga = Yoga || require("../../sources/entry-" + process.env.TEST_ENTRY);
|
||||
|
||||
it("border_start", function () {
|
||||
var root = Yoga.Node.create();
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
root.setBorder(Yoga.EDGE_START, 10);
|
||||
|
||||
root.calculateLayout(100, 100, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(10 === root.getComputedBorder(Yoga.EDGE_LEFT), "10 === root.getComputedBorder(Yoga.EDGE_LEFT)");
|
||||
console.assert(0 === root.getComputedBorder(Yoga.EDGE_RIGHT), "0 === root.getComputedBorder(Yoga.EDGE_RIGHT)");
|
||||
|
||||
root.calculateLayout(100, 100, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedBorder(Yoga.EDGE_LEFT), "0 === root.getComputedBorder(Yoga.EDGE_LEFT)");
|
||||
console.assert(10 === root.getComputedBorder(Yoga.EDGE_RIGHT), "10 === root.getComputedBorder(Yoga.EDGE_RIGHT)");
|
||||
|
||||
if (typeof root !== "undefined")
|
||||
root.freeRecursive();
|
||||
|
||||
(typeof gc !== "undefined") && gc();
|
||||
// TODO Add event support in js and check instace allocation and de allocation using that
|
||||
});
|
@@ -1,31 +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.
|
||||
*/
|
||||
|
||||
var Yoga = Yoga || require("../../sources/entry-" + process.env.TEST_ENTRY);
|
||||
|
||||
it("margin_start", function () {
|
||||
var root = Yoga.Node.create();
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
root.setMargin(Yoga.EDGE_START, `10%`);
|
||||
|
||||
root.calculateLayout(100, 100, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(10 === root.getComputedMargin(Yoga.EDGE_LEFT), "10 === root.getComputedMargin(Yoga.EDGE_LEFT)");
|
||||
console.assert(0 === root.getComputedMargin(Yoga.EDGE_RIGHT), "0 === root.getComputedMargin(Yoga.EDGE_RIGHT)");
|
||||
|
||||
root.calculateLayout(100, 100, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedMargin(Yoga.EDGE_LEFT), "0 === root.getComputedMargin(Yoga.EDGE_LEFT)");
|
||||
console.assert(10 === root.getComputedMargin(Yoga.EDGE_RIGHT), "10 === root.getComputedMargin(Yoga.EDGE_RIGHT)");
|
||||
|
||||
if (typeof root !== "undefined")
|
||||
root.freeRecursive();
|
||||
|
||||
(typeof gc !== "undefined") && gc();
|
||||
// TODO Add event support in js and check instace allocation and de allocation using that
|
||||
});
|
@@ -1,31 +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.
|
||||
*/
|
||||
|
||||
var Yoga = Yoga || require("../../sources/entry-" + process.env.TEST_ENTRY);
|
||||
|
||||
it("padding_start", function () {
|
||||
var root = Yoga.Node.create();
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
root.setPadding(Yoga.EDGE_START, `10%`);
|
||||
|
||||
root.calculateLayout(100, 100, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(10 === root.getComputedPadding(Yoga.EDGE_LEFT), "10 === root.getComputedPadding(Yoga.EDGE_LEFT)");
|
||||
console.assert(0 === root.getComputedPadding(Yoga.EDGE_RIGHT), "0 === root.getComputedPadding(Yoga.EDGE_RIGHT)");
|
||||
|
||||
root.calculateLayout(100, 100, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedPadding(Yoga.EDGE_LEFT), "0 === root.getComputedPadding(Yoga.EDGE_LEFT)");
|
||||
console.assert(10 === root.getComputedPadding(Yoga.EDGE_RIGHT), "10 === root.getComputedPadding(Yoga.EDGE_RIGHT)");
|
||||
|
||||
if (typeof root !== "undefined")
|
||||
root.freeRecursive();
|
||||
|
||||
(typeof gc !== "undefined") && gc();
|
||||
// TODO Add event support in js and check instace allocation and de allocation using that
|
||||
});
|
@@ -1,106 +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.
|
||||
*/
|
||||
|
||||
// @generated by gentest/gentest.rb from gentest/fixtures/YGDimensionTest.html
|
||||
|
||||
var Yoga = Yoga || require("../../sources/entry-" + process.env.TEST_ENTRY);
|
||||
|
||||
it("wrap_child", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setWidth(100);
|
||||
root_child0.setHeight(100);
|
||||
root.insertChild(root_child0, 0);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("wrap_grandchild", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
var root_child0_child0 = Yoga.Node.create(config);
|
||||
root_child0_child0.setWidth(100);
|
||||
root_child0_child0.setHeight(100);
|
||||
root_child0.insertChild(root_child0_child0, 0);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0_child0.getComputedLeft(), "0 === root_child0_child0.getComputedLeft() (" + root_child0_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0_child0.getComputedTop(), "0 === root_child0_child0.getComputedTop() (" + root_child0_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0_child0.getComputedWidth(), "100 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child0_child0.getComputedHeight(), "100 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0_child0.getComputedLeft(), "0 === root_child0_child0.getComputedLeft() (" + root_child0_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0_child0.getComputedTop(), "0 === root_child0_child0.getComputedTop() (" + root_child0_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0_child0.getComputedWidth(), "100 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child0_child0.getComputedHeight(), "100 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
@@ -1,390 +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.
|
||||
*/
|
||||
|
||||
// @generated by gentest/gentest.rb from gentest/fixtures/YGDisplayTest.html
|
||||
|
||||
var Yoga = Yoga || require("../../sources/entry-" + process.env.TEST_ENTRY);
|
||||
|
||||
it("display_none", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setFlexGrow(1);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
var root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setFlexGrow(1);
|
||||
root_child1.setDisplay(Yoga.DISPLAY_NONE);
|
||||
root.insertChild(root_child1, 1);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(0 === root_child1.getComputedWidth(), "0 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(0 === root_child1.getComputedHeight(), "0 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(0 === root_child1.getComputedWidth(), "0 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(0 === root_child1.getComputedHeight(), "0 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("display_none_fixed_size", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setFlexGrow(1);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
var root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setWidth(20);
|
||||
root_child1.setHeight(20);
|
||||
root_child1.setDisplay(Yoga.DISPLAY_NONE);
|
||||
root.insertChild(root_child1, 1);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(0 === root_child1.getComputedWidth(), "0 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(0 === root_child1.getComputedHeight(), "0 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(0 === root_child1.getComputedWidth(), "0 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(0 === root_child1.getComputedHeight(), "0 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("display_none_with_margin", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setMargin(Yoga.EDGE_LEFT, 10);
|
||||
root_child0.setMargin(Yoga.EDGE_TOP, 10);
|
||||
root_child0.setMargin(Yoga.EDGE_RIGHT, 10);
|
||||
root_child0.setMargin(Yoga.EDGE_BOTTOM, 10);
|
||||
root_child0.setWidth(20);
|
||||
root_child0.setHeight(20);
|
||||
root_child0.setDisplay(Yoga.DISPLAY_NONE);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
var root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setFlexGrow(1);
|
||||
root.insertChild(root_child1, 1);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(0 === root_child0.getComputedWidth(), "0 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(0 === root_child0.getComputedHeight(), "0 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(100 === root_child1.getComputedWidth(), "100 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child1.getComputedHeight(), "100 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(0 === root_child0.getComputedWidth(), "0 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(0 === root_child0.getComputedHeight(), "0 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(100 === root_child1.getComputedWidth(), "100 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child1.getComputedHeight(), "100 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("display_none_with_child", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setFlexGrow(1);
|
||||
root_child0.setFlexShrink(1);
|
||||
root_child0.setFlexBasis("0%");
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
var root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setFlexGrow(1);
|
||||
root_child1.setFlexShrink(1);
|
||||
root_child1.setFlexBasis("0%");
|
||||
root_child1.setDisplay(Yoga.DISPLAY_NONE);
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
var root_child1_child0 = Yoga.Node.create(config);
|
||||
root_child1_child0.setFlexGrow(1);
|
||||
root_child1_child0.setFlexShrink(1);
|
||||
root_child1_child0.setFlexBasis("0%");
|
||||
root_child1_child0.setWidth(20);
|
||||
root_child1.insertChild(root_child1_child0, 0);
|
||||
|
||||
var root_child2 = Yoga.Node.create(config);
|
||||
root_child2.setFlexGrow(1);
|
||||
root_child2.setFlexShrink(1);
|
||||
root_child2.setFlexBasis("0%");
|
||||
root.insertChild(root_child2, 2);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(50 === root_child0.getComputedWidth(), "50 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(0 === root_child1.getComputedWidth(), "0 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(0 === root_child1.getComputedHeight(), "0 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1_child0.getComputedLeft(), "0 === root_child1_child0.getComputedLeft() (" + root_child1_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1_child0.getComputedTop(), "0 === root_child1_child0.getComputedTop() (" + root_child1_child0.getComputedTop() + ")");
|
||||
console.assert(0 === root_child1_child0.getComputedWidth(), "0 === root_child1_child0.getComputedWidth() (" + root_child1_child0.getComputedWidth() + ")");
|
||||
console.assert(0 === root_child1_child0.getComputedHeight(), "0 === root_child1_child0.getComputedHeight() (" + root_child1_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(50 === root_child2.getComputedLeft(), "50 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child2.getComputedTop(), "0 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
|
||||
console.assert(50 === root_child2.getComputedWidth(), "50 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child2.getComputedHeight(), "100 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(50 === root_child0.getComputedLeft(), "50 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(50 === root_child0.getComputedWidth(), "50 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(0 === root_child1.getComputedWidth(), "0 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(0 === root_child1.getComputedHeight(), "0 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1_child0.getComputedLeft(), "0 === root_child1_child0.getComputedLeft() (" + root_child1_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1_child0.getComputedTop(), "0 === root_child1_child0.getComputedTop() (" + root_child1_child0.getComputedTop() + ")");
|
||||
console.assert(0 === root_child1_child0.getComputedWidth(), "0 === root_child1_child0.getComputedWidth() (" + root_child1_child0.getComputedWidth() + ")");
|
||||
console.assert(0 === root_child1_child0.getComputedHeight(), "0 === root_child1_child0.getComputedHeight() (" + root_child1_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child2.getComputedLeft(), "0 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child2.getComputedTop(), "0 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
|
||||
console.assert(50 === root_child2.getComputedWidth(), "50 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child2.getComputedHeight(), "100 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("display_none_with_position", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setFlexGrow(1);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
var root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setFlexGrow(1);
|
||||
root_child1.setPosition(Yoga.EDGE_TOP, 10);
|
||||
root_child1.setDisplay(Yoga.DISPLAY_NONE);
|
||||
root.insertChild(root_child1, 1);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(0 === root_child1.getComputedWidth(), "0 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(0 === root_child1.getComputedHeight(), "0 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(0 === root_child1.getComputedWidth(), "0 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(0 === root_child1.getComputedHeight(), "0 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("display_none_with_position_absolute", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setPositionType(Yoga.POSITION_TYPE_ABSOLUTE);
|
||||
root_child0.setWidth(100);
|
||||
root_child0.setHeight(100);
|
||||
root_child0.setDisplay(Yoga.DISPLAY_NONE);
|
||||
root.insertChild(root_child0, 0);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(0 === root_child0.getComputedWidth(), "0 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(0 === root_child0.getComputedHeight(), "0 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(0 === root_child0.getComputedWidth(), "0 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(0 === root_child0.getComputedHeight(), "0 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
@@ -1,433 +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.
|
||||
*/
|
||||
|
||||
// @generated by gentest/gentest.rb from gentest/fixtures/YGFlexDirectionTest.html
|
||||
|
||||
var Yoga = Yoga || require("../../sources/entry-" + process.env.TEST_ENTRY);
|
||||
|
||||
it("flex_direction_column_no_height", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setWidth(100);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setHeight(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
var root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setHeight(10);
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
var root_child2 = Yoga.Node.create(config);
|
||||
root_child2.setHeight(10);
|
||||
root.insertChild(root_child2, 2);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(30 === root.getComputedHeight(), "30 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child0.getComputedHeight(), "10 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(10 === root_child1.getComputedTop(), "10 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(100 === root_child1.getComputedWidth(), "100 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child1.getComputedHeight(), "10 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child2.getComputedLeft(), "0 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
|
||||
console.assert(20 === root_child2.getComputedTop(), "20 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
|
||||
console.assert(100 === root_child2.getComputedWidth(), "100 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child2.getComputedHeight(), "10 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(30 === root.getComputedHeight(), "30 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child0.getComputedHeight(), "10 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(10 === root_child1.getComputedTop(), "10 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(100 === root_child1.getComputedWidth(), "100 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child1.getComputedHeight(), "10 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child2.getComputedLeft(), "0 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
|
||||
console.assert(20 === root_child2.getComputedTop(), "20 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
|
||||
console.assert(100 === root_child2.getComputedWidth(), "100 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child2.getComputedHeight(), "10 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("flex_direction_row_no_width", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root.setHeight(100);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setWidth(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
var root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setWidth(10);
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
var root_child2 = Yoga.Node.create(config);
|
||||
root_child2.setWidth(10);
|
||||
root.insertChild(root_child2, 2);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(30 === root.getComputedWidth(), "30 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(10 === root_child0.getComputedWidth(), "10 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(10 === root_child1.getComputedLeft(), "10 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(10 === root_child1.getComputedWidth(), "10 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child1.getComputedHeight(), "100 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(20 === root_child2.getComputedLeft(), "20 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child2.getComputedTop(), "0 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
|
||||
console.assert(10 === root_child2.getComputedWidth(), "10 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child2.getComputedHeight(), "100 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(30 === root.getComputedWidth(), "30 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(20 === root_child0.getComputedLeft(), "20 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(10 === root_child0.getComputedWidth(), "10 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(10 === root_child1.getComputedLeft(), "10 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(10 === root_child1.getComputedWidth(), "10 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child1.getComputedHeight(), "100 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child2.getComputedLeft(), "0 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child2.getComputedTop(), "0 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
|
||||
console.assert(10 === root_child2.getComputedWidth(), "10 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child2.getComputedHeight(), "100 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("flex_direction_column", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setHeight(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
var root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setHeight(10);
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
var root_child2 = Yoga.Node.create(config);
|
||||
root_child2.setHeight(10);
|
||||
root.insertChild(root_child2, 2);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child0.getComputedHeight(), "10 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(10 === root_child1.getComputedTop(), "10 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(100 === root_child1.getComputedWidth(), "100 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child1.getComputedHeight(), "10 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child2.getComputedLeft(), "0 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
|
||||
console.assert(20 === root_child2.getComputedTop(), "20 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
|
||||
console.assert(100 === root_child2.getComputedWidth(), "100 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child2.getComputedHeight(), "10 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child0.getComputedHeight(), "10 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(10 === root_child1.getComputedTop(), "10 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(100 === root_child1.getComputedWidth(), "100 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child1.getComputedHeight(), "10 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child2.getComputedLeft(), "0 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
|
||||
console.assert(20 === root_child2.getComputedTop(), "20 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
|
||||
console.assert(100 === root_child2.getComputedWidth(), "100 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child2.getComputedHeight(), "10 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("flex_direction_row", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setWidth(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
var root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setWidth(10);
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
var root_child2 = Yoga.Node.create(config);
|
||||
root_child2.setWidth(10);
|
||||
root.insertChild(root_child2, 2);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(10 === root_child0.getComputedWidth(), "10 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(10 === root_child1.getComputedLeft(), "10 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(10 === root_child1.getComputedWidth(), "10 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child1.getComputedHeight(), "100 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(20 === root_child2.getComputedLeft(), "20 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child2.getComputedTop(), "0 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
|
||||
console.assert(10 === root_child2.getComputedWidth(), "10 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child2.getComputedHeight(), "100 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(90 === root_child0.getComputedLeft(), "90 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(10 === root_child0.getComputedWidth(), "10 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(80 === root_child1.getComputedLeft(), "80 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(10 === root_child1.getComputedWidth(), "10 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child1.getComputedHeight(), "100 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(70 === root_child2.getComputedLeft(), "70 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child2.getComputedTop(), "0 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
|
||||
console.assert(10 === root_child2.getComputedWidth(), "10 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child2.getComputedHeight(), "100 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("flex_direction_column_reverse", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN_REVERSE);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setHeight(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
var root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setHeight(10);
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
var root_child2 = Yoga.Node.create(config);
|
||||
root_child2.setHeight(10);
|
||||
root.insertChild(root_child2, 2);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(90 === root_child0.getComputedTop(), "90 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child0.getComputedHeight(), "10 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(80 === root_child1.getComputedTop(), "80 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(100 === root_child1.getComputedWidth(), "100 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child1.getComputedHeight(), "10 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child2.getComputedLeft(), "0 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
|
||||
console.assert(70 === root_child2.getComputedTop(), "70 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
|
||||
console.assert(100 === root_child2.getComputedWidth(), "100 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child2.getComputedHeight(), "10 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(90 === root_child0.getComputedTop(), "90 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child0.getComputedHeight(), "10 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(80 === root_child1.getComputedTop(), "80 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(100 === root_child1.getComputedWidth(), "100 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child1.getComputedHeight(), "10 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child2.getComputedLeft(), "0 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
|
||||
console.assert(70 === root_child2.getComputedTop(), "70 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
|
||||
console.assert(100 === root_child2.getComputedWidth(), "100 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child2.getComputedHeight(), "10 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("flex_direction_row_reverse", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW_REVERSE);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setWidth(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
var root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setWidth(10);
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
var root_child2 = Yoga.Node.create(config);
|
||||
root_child2.setWidth(10);
|
||||
root.insertChild(root_child2, 2);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(90 === root_child0.getComputedLeft(), "90 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(10 === root_child0.getComputedWidth(), "10 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(80 === root_child1.getComputedLeft(), "80 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(10 === root_child1.getComputedWidth(), "10 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child1.getComputedHeight(), "100 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(70 === root_child2.getComputedLeft(), "70 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child2.getComputedTop(), "0 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
|
||||
console.assert(10 === root_child2.getComputedWidth(), "10 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child2.getComputedHeight(), "100 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(10 === root_child0.getComputedWidth(), "10 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(10 === root_child1.getComputedLeft(), "10 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(10 === root_child1.getComputedWidth(), "10 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child1.getComputedHeight(), "100 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(20 === root_child2.getComputedLeft(), "20 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child2.getComputedTop(), "0 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
|
||||
console.assert(10 === root_child2.getComputedWidth(), "10 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child2.getComputedHeight(), "100 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
@@ -1,638 +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.
|
||||
*/
|
||||
|
||||
// @generated by gentest/gentest.rb from gentest/fixtures/YGFlexTest.html
|
||||
|
||||
var Yoga = Yoga || require("../../sources/entry-" + process.env.TEST_ENTRY);
|
||||
|
||||
it("flex_basis_flex_grow_column", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setFlexGrow(1);
|
||||
root_child0.setFlexBasis(50);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
var root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setFlexGrow(1);
|
||||
root.insertChild(root_child1, 1);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(75 === root_child0.getComputedHeight(), "75 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(75 === root_child1.getComputedTop(), "75 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(100 === root_child1.getComputedWidth(), "100 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(25 === root_child1.getComputedHeight(), "25 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(75 === root_child0.getComputedHeight(), "75 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(75 === root_child1.getComputedTop(), "75 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(100 === root_child1.getComputedWidth(), "100 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(25 === root_child1.getComputedHeight(), "25 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("flex_shrink_flex_grow_row", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root.setWidth(500);
|
||||
root.setHeight(500);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setFlexShrink(1);
|
||||
root_child0.setWidth(500);
|
||||
root_child0.setHeight(100);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
var root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setFlexShrink(1);
|
||||
root_child1.setWidth(500);
|
||||
root_child1.setHeight(100);
|
||||
root.insertChild(root_child1, 1);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(500 === root.getComputedWidth(), "500 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(500 === root.getComputedHeight(), "500 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(250 === root_child0.getComputedWidth(), "250 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(250 === root_child1.getComputedLeft(), "250 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(250 === root_child1.getComputedWidth(), "250 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child1.getComputedHeight(), "100 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(500 === root.getComputedWidth(), "500 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(500 === root.getComputedHeight(), "500 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(250 === root_child0.getComputedLeft(), "250 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(250 === root_child0.getComputedWidth(), "250 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(250 === root_child1.getComputedWidth(), "250 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child1.getComputedHeight(), "100 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("flex_shrink_flex_grow_child_flex_shrink_other_child", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root.setWidth(500);
|
||||
root.setHeight(500);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setFlexShrink(1);
|
||||
root_child0.setWidth(500);
|
||||
root_child0.setHeight(100);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
var root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setFlexGrow(1);
|
||||
root_child1.setFlexShrink(1);
|
||||
root_child1.setWidth(500);
|
||||
root_child1.setHeight(100);
|
||||
root.insertChild(root_child1, 1);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(500 === root.getComputedWidth(), "500 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(500 === root.getComputedHeight(), "500 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(250 === root_child0.getComputedWidth(), "250 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(250 === root_child1.getComputedLeft(), "250 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(250 === root_child1.getComputedWidth(), "250 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child1.getComputedHeight(), "100 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(500 === root.getComputedWidth(), "500 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(500 === root.getComputedHeight(), "500 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(250 === root_child0.getComputedLeft(), "250 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(250 === root_child0.getComputedWidth(), "250 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(250 === root_child1.getComputedWidth(), "250 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child1.getComputedHeight(), "100 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("flex_basis_flex_grow_row", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setFlexGrow(1);
|
||||
root_child0.setFlexBasis(50);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
var root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setFlexGrow(1);
|
||||
root.insertChild(root_child1, 1);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(75 === root_child0.getComputedWidth(), "75 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(75 === root_child1.getComputedLeft(), "75 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(25 === root_child1.getComputedWidth(), "25 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child1.getComputedHeight(), "100 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(25 === root_child0.getComputedLeft(), "25 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(75 === root_child0.getComputedWidth(), "75 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(25 === root_child1.getComputedWidth(), "25 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child1.getComputedHeight(), "100 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("flex_basis_flex_shrink_column", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setFlexShrink(1);
|
||||
root_child0.setFlexBasis(100);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
var root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setFlexBasis(50);
|
||||
root.insertChild(root_child1, 1);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(50 === root_child0.getComputedHeight(), "50 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(50 === root_child1.getComputedTop(), "50 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(100 === root_child1.getComputedWidth(), "100 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(50 === root_child1.getComputedHeight(), "50 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(50 === root_child0.getComputedHeight(), "50 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(50 === root_child1.getComputedTop(), "50 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(100 === root_child1.getComputedWidth(), "100 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(50 === root_child1.getComputedHeight(), "50 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("flex_basis_flex_shrink_row", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setFlexShrink(1);
|
||||
root_child0.setFlexBasis(100);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
var root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setFlexBasis(50);
|
||||
root.insertChild(root_child1, 1);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(50 === root_child0.getComputedWidth(), "50 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(50 === root_child1.getComputedLeft(), "50 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(50 === root_child1.getComputedWidth(), "50 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child1.getComputedHeight(), "100 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(50 === root_child0.getComputedLeft(), "50 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(50 === root_child0.getComputedWidth(), "50 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(50 === root_child1.getComputedWidth(), "50 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child1.getComputedHeight(), "100 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("flex_shrink_to_zero", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setHeight(75);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setWidth(50);
|
||||
root_child0.setHeight(50);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
var root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setFlexShrink(1);
|
||||
root_child1.setWidth(50);
|
||||
root_child1.setHeight(50);
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
var root_child2 = Yoga.Node.create(config);
|
||||
root_child2.setWidth(50);
|
||||
root_child2.setHeight(50);
|
||||
root.insertChild(root_child2, 2);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(50 === root.getComputedWidth(), "50 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(75 === root.getComputedHeight(), "75 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(50 === root_child0.getComputedWidth(), "50 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(50 === root_child0.getComputedHeight(), "50 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(50 === root_child1.getComputedTop(), "50 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(50 === root_child1.getComputedWidth(), "50 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(0 === root_child1.getComputedHeight(), "0 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child2.getComputedLeft(), "0 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
|
||||
console.assert(50 === root_child2.getComputedTop(), "50 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
|
||||
console.assert(50 === root_child2.getComputedWidth(), "50 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
|
||||
console.assert(50 === root_child2.getComputedHeight(), "50 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(50 === root.getComputedWidth(), "50 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(75 === root.getComputedHeight(), "75 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(50 === root_child0.getComputedWidth(), "50 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(50 === root_child0.getComputedHeight(), "50 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(50 === root_child1.getComputedTop(), "50 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(50 === root_child1.getComputedWidth(), "50 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(0 === root_child1.getComputedHeight(), "0 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child2.getComputedLeft(), "0 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
|
||||
console.assert(50 === root_child2.getComputedTop(), "50 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
|
||||
console.assert(50 === root_child2.getComputedWidth(), "50 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
|
||||
console.assert(50 === root_child2.getComputedHeight(), "50 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("flex_basis_overrides_main_size", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setFlexGrow(1);
|
||||
root_child0.setFlexBasis(50);
|
||||
root_child0.setHeight(20);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
var root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setFlexGrow(1);
|
||||
root_child1.setHeight(10);
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
var root_child2 = Yoga.Node.create(config);
|
||||
root_child2.setFlexGrow(1);
|
||||
root_child2.setHeight(10);
|
||||
root.insertChild(root_child2, 2);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(60 === root_child0.getComputedHeight(), "60 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(60 === root_child1.getComputedTop(), "60 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(100 === root_child1.getComputedWidth(), "100 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(20 === root_child1.getComputedHeight(), "20 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child2.getComputedLeft(), "0 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
|
||||
console.assert(80 === root_child2.getComputedTop(), "80 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
|
||||
console.assert(100 === root_child2.getComputedWidth(), "100 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
|
||||
console.assert(20 === root_child2.getComputedHeight(), "20 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(60 === root_child0.getComputedHeight(), "60 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(60 === root_child1.getComputedTop(), "60 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(100 === root_child1.getComputedWidth(), "100 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(20 === root_child1.getComputedHeight(), "20 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child2.getComputedLeft(), "0 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
|
||||
console.assert(80 === root_child2.getComputedTop(), "80 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
|
||||
console.assert(100 === root_child2.getComputedWidth(), "100 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
|
||||
console.assert(20 === root_child2.getComputedHeight(), "20 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("flex_grow_shrink_at_most", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
var root_child0_child0 = Yoga.Node.create(config);
|
||||
root_child0_child0.setFlexGrow(1);
|
||||
root_child0_child0.setFlexShrink(1);
|
||||
root_child0.insertChild(root_child0_child0, 0);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(0 === root_child0.getComputedHeight(), "0 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0_child0.getComputedLeft(), "0 === root_child0_child0.getComputedLeft() (" + root_child0_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0_child0.getComputedTop(), "0 === root_child0_child0.getComputedTop() (" + root_child0_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0_child0.getComputedWidth(), "100 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
|
||||
console.assert(0 === root_child0_child0.getComputedHeight(), "0 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(0 === root_child0.getComputedHeight(), "0 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0_child0.getComputedLeft(), "0 === root_child0_child0.getComputedLeft() (" + root_child0_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0_child0.getComputedTop(), "0 === root_child0_child0.getComputedTop() (" + root_child0_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0_child0.getComputedWidth(), "100 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
|
||||
console.assert(0 === root_child0_child0.getComputedHeight(), "0 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("flex_grow_less_than_factor_one", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setWidth(200);
|
||||
root.setHeight(500);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setFlexGrow(0.2);
|
||||
root_child0.setFlexBasis(40);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
var root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setFlexGrow(0.2);
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
var root_child2 = Yoga.Node.create(config);
|
||||
root_child2.setFlexGrow(0.4);
|
||||
root.insertChild(root_child2, 2);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(200 === root.getComputedWidth(), "200 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(500 === root.getComputedHeight(), "500 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(200 === root_child0.getComputedWidth(), "200 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(132 === root_child0.getComputedHeight(), "132 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(132 === root_child1.getComputedTop(), "132 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(200 === root_child1.getComputedWidth(), "200 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(92 === root_child1.getComputedHeight(), "92 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child2.getComputedLeft(), "0 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
|
||||
console.assert(224 === root_child2.getComputedTop(), "224 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
|
||||
console.assert(200 === root_child2.getComputedWidth(), "200 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
|
||||
console.assert(184 === root_child2.getComputedHeight(), "184 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(200 === root.getComputedWidth(), "200 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(500 === root.getComputedHeight(), "500 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(200 === root_child0.getComputedWidth(), "200 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(132 === root_child0.getComputedHeight(), "132 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(132 === root_child1.getComputedTop(), "132 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(200 === root_child1.getComputedWidth(), "200 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(92 === root_child1.getComputedHeight(), "92 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child2.getComputedLeft(), "0 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
|
||||
console.assert(224 === root_child2.getComputedTop(), "224 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
|
||||
console.assert(200 === root_child2.getComputedWidth(), "200 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
|
||||
console.assert(184 === root_child2.getComputedHeight(), "184 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,31 +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.
|
||||
*/
|
||||
|
||||
var Yoga = Yoga || require("../../sources/entry-" + process.env.TEST_ENTRY);
|
||||
|
||||
it("dont_measure_single_grow_shrink_child", function () {
|
||||
var root = Yoga.Node.create();
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
var measureCounter = getMeasureCounter(Yoga, null, 100, 100);
|
||||
|
||||
var root_child0 = Yoga.Node.create();
|
||||
root_child0.setMeasureFunc(measureCounter.inc);
|
||||
root_child0.setFlexGrow(1);
|
||||
root_child0.setFlexShrink(1);
|
||||
root.insertChild(root_child0, 0);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === measureCounter.get(), "0 === measureCounter.get() (" + measureCounter.get() + ")");
|
||||
|
||||
if (typeof root !== "undefined")
|
||||
root.freeRecursive();
|
||||
|
||||
(typeof gc !== "undefined") && gc();
|
||||
// TODO Add event support in js and check instace allocation and de allocation using that
|
||||
});
|
File diff suppressed because it is too large
Load Diff
@@ -1,276 +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.
|
||||
*/
|
||||
|
||||
// @generated by gentest/gentest.rb from gentest/fixtures/YGPaddingTest.html
|
||||
|
||||
var Yoga = Yoga || require("../../sources/entry-" + process.env.TEST_ENTRY);
|
||||
|
||||
it("padding_no_size", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setPadding(Yoga.EDGE_LEFT, 10);
|
||||
root.setPadding(Yoga.EDGE_TOP, 10);
|
||||
root.setPadding(Yoga.EDGE_RIGHT, 10);
|
||||
root.setPadding(Yoga.EDGE_BOTTOM, 10);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(20 === root.getComputedWidth(), "20 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(20 === root.getComputedHeight(), "20 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(20 === root.getComputedWidth(), "20 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(20 === root.getComputedHeight(), "20 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("padding_container_match_child", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setPadding(Yoga.EDGE_LEFT, 10);
|
||||
root.setPadding(Yoga.EDGE_TOP, 10);
|
||||
root.setPadding(Yoga.EDGE_RIGHT, 10);
|
||||
root.setPadding(Yoga.EDGE_BOTTOM, 10);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setWidth(10);
|
||||
root_child0.setHeight(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(30 === root.getComputedWidth(), "30 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(30 === root.getComputedHeight(), "30 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(10 === root_child0.getComputedLeft(), "10 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(10 === root_child0.getComputedTop(), "10 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(10 === root_child0.getComputedWidth(), "10 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child0.getComputedHeight(), "10 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(30 === root.getComputedWidth(), "30 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(30 === root.getComputedHeight(), "30 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(10 === root_child0.getComputedLeft(), "10 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(10 === root_child0.getComputedTop(), "10 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(10 === root_child0.getComputedWidth(), "10 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child0.getComputedHeight(), "10 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("padding_flex_child", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setPadding(Yoga.EDGE_LEFT, 10);
|
||||
root.setPadding(Yoga.EDGE_TOP, 10);
|
||||
root.setPadding(Yoga.EDGE_RIGHT, 10);
|
||||
root.setPadding(Yoga.EDGE_BOTTOM, 10);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setFlexGrow(1);
|
||||
root_child0.setWidth(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(10 === root_child0.getComputedLeft(), "10 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(10 === root_child0.getComputedTop(), "10 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(10 === root_child0.getComputedWidth(), "10 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(80 === root_child0.getComputedHeight(), "80 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(80 === root_child0.getComputedLeft(), "80 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(10 === root_child0.getComputedTop(), "10 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(10 === root_child0.getComputedWidth(), "10 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(80 === root_child0.getComputedHeight(), "80 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("padding_stretch_child", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setPadding(Yoga.EDGE_LEFT, 10);
|
||||
root.setPadding(Yoga.EDGE_TOP, 10);
|
||||
root.setPadding(Yoga.EDGE_RIGHT, 10);
|
||||
root.setPadding(Yoga.EDGE_BOTTOM, 10);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setHeight(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(10 === root_child0.getComputedLeft(), "10 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(10 === root_child0.getComputedTop(), "10 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(80 === root_child0.getComputedWidth(), "80 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child0.getComputedHeight(), "10 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(10 === root_child0.getComputedLeft(), "10 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(10 === root_child0.getComputedTop(), "10 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(80 === root_child0.getComputedWidth(), "80 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child0.getComputedHeight(), "10 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("padding_center_child", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setJustifyContent(Yoga.JUSTIFY_CENTER);
|
||||
root.setAlignItems(Yoga.ALIGN_CENTER);
|
||||
root.setPadding(Yoga.EDGE_START, 10);
|
||||
root.setPadding(Yoga.EDGE_END, 20);
|
||||
root.setPadding(Yoga.EDGE_BOTTOM, 20);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setWidth(10);
|
||||
root_child0.setHeight(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(40 === root_child0.getComputedLeft(), "40 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(35 === root_child0.getComputedTop(), "35 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(10 === root_child0.getComputedWidth(), "10 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child0.getComputedHeight(), "10 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(50 === root_child0.getComputedLeft(), "50 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(35 === root_child0.getComputedTop(), "35 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(10 === root_child0.getComputedWidth(), "10 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child0.getComputedHeight(), "10 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("child_with_padding_align_end", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setJustifyContent(Yoga.JUSTIFY_FLEX_END);
|
||||
root.setAlignItems(Yoga.ALIGN_FLEX_END);
|
||||
root.setWidth(200);
|
||||
root.setHeight(200);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setPadding(Yoga.EDGE_LEFT, 20);
|
||||
root_child0.setPadding(Yoga.EDGE_TOP, 20);
|
||||
root_child0.setPadding(Yoga.EDGE_RIGHT, 20);
|
||||
root_child0.setPadding(Yoga.EDGE_BOTTOM, 20);
|
||||
root_child0.setWidth(100);
|
||||
root_child0.setHeight(100);
|
||||
root.insertChild(root_child0, 0);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(200 === root.getComputedWidth(), "200 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(200 === root.getComputedHeight(), "200 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(100 === root_child0.getComputedLeft(), "100 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(100 === root_child0.getComputedTop(), "100 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(200 === root.getComputedWidth(), "200 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(200 === root.getComputedHeight(), "200 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(100 === root_child0.getComputedTop(), "100 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,182 +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.
|
||||
*/
|
||||
|
||||
// @generated by gentest/gentest.rb from gentest/fixtures/YGSizeOverflowTest.html
|
||||
|
||||
var Yoga = Yoga || require("../../sources/entry-" + process.env.TEST_ENTRY);
|
||||
|
||||
it("nested_overflowing_child", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
var root_child0_child0 = Yoga.Node.create(config);
|
||||
root_child0_child0.setWidth(200);
|
||||
root_child0_child0.setHeight(200);
|
||||
root_child0.insertChild(root_child0_child0, 0);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(200 === root_child0.getComputedHeight(), "200 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0_child0.getComputedLeft(), "0 === root_child0_child0.getComputedLeft() (" + root_child0_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0_child0.getComputedTop(), "0 === root_child0_child0.getComputedTop() (" + root_child0_child0.getComputedTop() + ")");
|
||||
console.assert(200 === root_child0_child0.getComputedWidth(), "200 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
|
||||
console.assert(200 === root_child0_child0.getComputedHeight(), "200 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(200 === root_child0.getComputedHeight(), "200 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(-100 === root_child0_child0.getComputedLeft(), "-100 === root_child0_child0.getComputedLeft() (" + root_child0_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0_child0.getComputedTop(), "0 === root_child0_child0.getComputedTop() (" + root_child0_child0.getComputedTop() + ")");
|
||||
console.assert(200 === root_child0_child0.getComputedWidth(), "200 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
|
||||
console.assert(200 === root_child0_child0.getComputedHeight(), "200 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("nested_overflowing_child_in_constraint_parent", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setWidth(100);
|
||||
root_child0.setHeight(100);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
var root_child0_child0 = Yoga.Node.create(config);
|
||||
root_child0_child0.setWidth(200);
|
||||
root_child0_child0.setHeight(200);
|
||||
root_child0.insertChild(root_child0_child0, 0);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0_child0.getComputedLeft(), "0 === root_child0_child0.getComputedLeft() (" + root_child0_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0_child0.getComputedTop(), "0 === root_child0_child0.getComputedTop() (" + root_child0_child0.getComputedTop() + ")");
|
||||
console.assert(200 === root_child0_child0.getComputedWidth(), "200 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
|
||||
console.assert(200 === root_child0_child0.getComputedHeight(), "200 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(-100 === root_child0_child0.getComputedLeft(), "-100 === root_child0_child0.getComputedLeft() (" + root_child0_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0_child0.getComputedTop(), "0 === root_child0_child0.getComputedTop() (" + root_child0_child0.getComputedTop() + ")");
|
||||
console.assert(200 === root_child0_child0.getComputedWidth(), "200 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
|
||||
console.assert(200 === root_child0_child0.getComputedHeight(), "200 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("parent_wrap_child_size_overflowing_parent", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setWidth(100);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
var root_child0_child0 = Yoga.Node.create(config);
|
||||
root_child0_child0.setWidth(100);
|
||||
root_child0_child0.setHeight(200);
|
||||
root_child0.insertChild(root_child0_child0, 0);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(200 === root_child0.getComputedHeight(), "200 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0_child0.getComputedLeft(), "0 === root_child0_child0.getComputedLeft() (" + root_child0_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0_child0.getComputedTop(), "0 === root_child0_child0.getComputedTop() (" + root_child0_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0_child0.getComputedWidth(), "100 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
|
||||
console.assert(200 === root_child0_child0.getComputedHeight(), "200 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(200 === root_child0.getComputedHeight(), "200 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0_child0.getComputedLeft(), "0 === root_child0_child0.getComputedLeft() (" + root_child0_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0_child0.getComputedTop(), "0 === root_child0_child0.getComputedTop() (" + root_child0_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0_child0.getComputedWidth(), "100 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
|
||||
console.assert(200 === root_child0_child0.getComputedHeight(), "200 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
122
javascript/tests/YGAlignBaselineTest.test.js
Normal file
122
javascript/tests/YGAlignBaselineTest.test.js
Normal file
@@ -0,0 +1,122 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
test("align_baseline_parent_using_child_in_column_as_reference", () => {
|
||||
const config = Yoga.Config.create();
|
||||
let root;
|
||||
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root.setWidth(1000);
|
||||
root.setHeight(1000);
|
||||
root.setAlignItems(Yoga.ALIGN_BASELINE);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN);
|
||||
root_child0.setWidth(500);
|
||||
root_child0.setHeight(600);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
const root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN);
|
||||
root_child1.setWidth(500);
|
||||
root_child1.setHeight(800);
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
const root_child1_child0 = Yoga.Node.create(config);
|
||||
root_child1_child0.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN);
|
||||
root_child1_child0.setWidth(500);
|
||||
root_child1_child0.setHeight(300);
|
||||
root_child1.insertChild(root_child1_child0, 0);
|
||||
|
||||
const root_child1_child1 = Yoga.Node.create(config);
|
||||
root_child1_child1.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN);
|
||||
root_child1_child1.setWidth(500);
|
||||
root_child1_child1.setHeight(400);
|
||||
root_child1_child1.setIsReferenceBaseline(true);
|
||||
root_child1.insertChild(root_child1_child1, 1);
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(100);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(500);
|
||||
expect(root_child1.getComputedTop()).toBe(0);
|
||||
|
||||
expect(root_child1_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child1_child0.getComputedTop()).toBe(0);
|
||||
|
||||
expect(root_child1_child1.getComputedLeft()).toBe(0);
|
||||
expect(root_child1_child1.getComputedTop()).toBe(300);
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
|
||||
test("align_baseline_parent_using_child_in_row_as_reference", () => {
|
||||
const config = Yoga.Config.create();
|
||||
let root;
|
||||
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root.setWidth(1000);
|
||||
root.setHeight(1000);
|
||||
root.setAlignItems(Yoga.ALIGN_BASELINE);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN);
|
||||
root_child0.setWidth(500);
|
||||
root_child0.setHeight(600);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
const root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root_child1.setWidth(500);
|
||||
root_child1.setHeight(800);
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
const root_child1_child0 = Yoga.Node.create(config);
|
||||
root_child1_child0.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN);
|
||||
root_child1_child0.setWidth(500);
|
||||
root_child1_child0.setHeight(500);
|
||||
root_child1.insertChild(root_child1_child0, 0);
|
||||
|
||||
const root_child1_child1 = Yoga.Node.create(config);
|
||||
root_child1_child1.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN);
|
||||
root_child1_child1.setWidth(500);
|
||||
root_child1_child1.setHeight(400);
|
||||
root_child1_child1.setIsReferenceBaseline(true);
|
||||
root_child1.insertChild(root_child1_child1, 1);
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(500);
|
||||
expect(root_child1.getComputedTop()).toBe(200);
|
||||
|
||||
expect(root_child1_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child1_child0.getComputedTop()).toBe(0);
|
||||
|
||||
expect(root_child1_child1.getComputedLeft()).toBe(500);
|
||||
expect(root_child1_child1.getComputedTop()).toBe(0);
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
25
javascript/tests/YGComputedBorderTest.test.js
Normal file
25
javascript/tests/YGComputedBorderTest.test.js
Normal file
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
test("border_start", () => {
|
||||
const root = Yoga.Node.create();
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
root.setBorder(Yoga.EDGE_START, 10);
|
||||
|
||||
root.calculateLayout(100, 100, Yoga.DIRECTION_LTR);
|
||||
|
||||
expect(root.getComputedBorder(Yoga.EDGE_LEFT)).toBe(10);
|
||||
expect(root.getComputedBorder(Yoga.EDGE_RIGHT)).toBe(0);
|
||||
|
||||
root.calculateLayout(100, 100, Yoga.DIRECTION_RTL);
|
||||
|
||||
expect(root.getComputedBorder(Yoga.EDGE_LEFT)).toBe(0);
|
||||
expect(root.getComputedBorder(Yoga.EDGE_RIGHT)).toBe(10);
|
||||
|
||||
root.freeRecursive();
|
||||
});
|
25
javascript/tests/YGComputedMarginTest.test.js
Normal file
25
javascript/tests/YGComputedMarginTest.test.js
Normal file
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
test("margin_start", () => {
|
||||
const root = Yoga.Node.create();
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
root.setMargin(Yoga.EDGE_START, `10%`);
|
||||
|
||||
root.calculateLayout(100, 100, Yoga.DIRECTION_LTR);
|
||||
|
||||
expect(root.getComputedMargin(Yoga.EDGE_LEFT)).toBe(10);
|
||||
expect(root.getComputedMargin(Yoga.EDGE_RIGHT)).toBe(0);
|
||||
|
||||
root.calculateLayout(100, 100, Yoga.DIRECTION_RTL);
|
||||
|
||||
expect(root.getComputedMargin(Yoga.EDGE_LEFT)).toBe(0);
|
||||
expect(root.getComputedMargin(Yoga.EDGE_RIGHT)).toBe(10);
|
||||
|
||||
root.freeRecursive();
|
||||
});
|
25
javascript/tests/YGComputedPaddingTest.test.js
Normal file
25
javascript/tests/YGComputedPaddingTest.test.js
Normal file
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
test("padding_start", () => {
|
||||
const root = Yoga.Node.create();
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
root.setPadding(Yoga.EDGE_START, `10%`);
|
||||
|
||||
root.calculateLayout(100, 100, Yoga.DIRECTION_LTR);
|
||||
|
||||
expect(root.getComputedPadding(Yoga.EDGE_LEFT)).toBe(10);
|
||||
expect(root.getComputedPadding(Yoga.EDGE_RIGHT)).toBe(0);
|
||||
|
||||
root.calculateLayout(100, 100, Yoga.DIRECTION_RTL);
|
||||
|
||||
expect(root.getComputedPadding(Yoga.EDGE_LEFT)).toBe(0);
|
||||
expect(root.getComputedPadding(Yoga.EDGE_RIGHT)).toBe(10);
|
||||
|
||||
root.freeRecursive();
|
||||
});
|
@@ -5,10 +5,8 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
var Yoga = Yoga || require("../../sources/entry-" + process.env.TEST_ENTRY);
|
||||
|
||||
it("dirtied", function() {
|
||||
var root = Yoga.Node.create();
|
||||
test("dirtied", () => {
|
||||
const root = Yoga.Node.create();
|
||||
root.setAlignItems(Yoga.ALIGN_FLEX_START);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
@@ -16,41 +14,39 @@ it("dirtied", function() {
|
||||
root.calculateLayout(undefined, undefined, Yoga.DIRECTION_LTR);
|
||||
|
||||
let dirtied = 0;
|
||||
root.setDirtiedFunc(function() { dirtied++; });
|
||||
root.setDirtiedFunc(() => {
|
||||
dirtied++;
|
||||
});
|
||||
// only nodes with a measure function can be marked dirty
|
||||
root.setMeasureFunc(function() {});
|
||||
root.setMeasureFunc(() => {});
|
||||
|
||||
console.assert(0 === dirtied, "0 === dirtied");
|
||||
expect(dirtied).toBe(0);
|
||||
|
||||
// dirtied func MUST be called in case of explicit dirtying.
|
||||
root.markDirty();
|
||||
console.assert(1 === dirtied, "1 === dirtied");
|
||||
expect(dirtied).toBe(1);
|
||||
|
||||
// dirtied func MUST be called ONCE.
|
||||
root.markDirty();
|
||||
console.assert(1 === dirtied, "1 === dirtied");
|
||||
expect(dirtied).toBe(1);
|
||||
|
||||
if (typeof root !== "undefined")
|
||||
root.freeRecursive();
|
||||
|
||||
typeof gc !== "undefined" && gc();
|
||||
// TODO Add event support in js and check instace allocation and de allocation using that
|
||||
root.freeRecursive();
|
||||
});
|
||||
|
||||
it("dirtied_propagation", function() {
|
||||
var root = Yoga.Node.create();
|
||||
test("dirtied_propagation", () => {
|
||||
const root = Yoga.Node.create();
|
||||
root.setAlignItems(Yoga.ALIGN_FLEX_START);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
var root_child0 = Yoga.Node.create();
|
||||
const root_child0 = Yoga.Node.create();
|
||||
root_child0.setAlignItems(Yoga.ALIGN_FLEX_START);
|
||||
root_child0.setWidth(50);
|
||||
root_child0.setHeight(20);
|
||||
root_child0.setMeasureFunc(function() {});
|
||||
root_child0.setMeasureFunc(() => {});
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
var root_child1 = Yoga.Node.create();
|
||||
const root_child1 = Yoga.Node.create();
|
||||
root_child1.setAlignItems(Yoga.ALIGN_FLEX_START);
|
||||
root_child1.setWidth(50);
|
||||
root_child1.setHeight(20);
|
||||
@@ -59,91 +55,85 @@ it("dirtied_propagation", function() {
|
||||
root.calculateLayout(undefined, undefined, Yoga.DIRECTION_LTR);
|
||||
|
||||
let dirtied = 0;
|
||||
root.setDirtiedFunc(function() { dirtied++; });
|
||||
|
||||
console.assert(0 === dirtied, "0 === dirtied");
|
||||
|
||||
// dirtied func MUST be called for the first time.
|
||||
root_child0.markDirty();
|
||||
console.assert(1 === dirtied, "1 === dirtied");
|
||||
|
||||
// dirtied func must NOT be called for the second time.
|
||||
root_child0.markDirty();
|
||||
console.assert(1 === dirtied, "1 === dirtied");
|
||||
|
||||
if (typeof root !== "undefined")
|
||||
root.freeRecursive();
|
||||
|
||||
typeof gc !== "undefined" && gc();
|
||||
// TODO Add event support in js and check instace allocation and de allocation using that
|
||||
});
|
||||
|
||||
it("dirtied_hierarchy", function() {
|
||||
var root = Yoga.Node.create();
|
||||
root.setAlignItems(Yoga.ALIGN_FLEX_START);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
var root_child0 = Yoga.Node.create();
|
||||
root_child0.setAlignItems(Yoga.ALIGN_FLEX_START);
|
||||
root_child0.setWidth(50);
|
||||
root_child0.setHeight(20);
|
||||
root_child0.setMeasureFunc(function() {});
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
var root_child1 = Yoga.Node.create();
|
||||
root_child1.setAlignItems(Yoga.ALIGN_FLEX_START);
|
||||
root_child1.setWidth(50);
|
||||
root_child1.setHeight(20);
|
||||
root_child1.setMeasureFunc(function() {});
|
||||
root.insertChild(root_child1, 0);
|
||||
|
||||
root.calculateLayout(undefined, undefined, Yoga.DIRECTION_LTR);
|
||||
|
||||
let dirtied = 0;
|
||||
root_child0.setDirtiedFunc(function() {
|
||||
root.setDirtiedFunc(() => {
|
||||
dirtied++;
|
||||
});
|
||||
|
||||
console.assert(0 === dirtied, "0 === dirtied");
|
||||
expect(dirtied).toBe(0);
|
||||
|
||||
// dirtied func MUST be called for the first time.
|
||||
root_child0.markDirty();
|
||||
expect(dirtied).toBe(1);
|
||||
|
||||
// dirtied func must NOT be called for the second time.
|
||||
root_child0.markDirty();
|
||||
expect(dirtied).toBe(1);
|
||||
|
||||
root.freeRecursive();
|
||||
});
|
||||
|
||||
test("dirtied_hierarchy", () => {
|
||||
const root = Yoga.Node.create();
|
||||
root.setAlignItems(Yoga.ALIGN_FLEX_START);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
const root_child0 = Yoga.Node.create();
|
||||
root_child0.setAlignItems(Yoga.ALIGN_FLEX_START);
|
||||
root_child0.setWidth(50);
|
||||
root_child0.setHeight(20);
|
||||
root_child0.setMeasureFunc(() => {});
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
const root_child1 = Yoga.Node.create();
|
||||
root_child1.setAlignItems(Yoga.ALIGN_FLEX_START);
|
||||
root_child1.setWidth(50);
|
||||
root_child1.setHeight(20);
|
||||
root_child1.setMeasureFunc(() => {});
|
||||
root.insertChild(root_child1, 0);
|
||||
|
||||
root.calculateLayout(undefined, undefined, Yoga.DIRECTION_LTR);
|
||||
|
||||
let dirtied = 0;
|
||||
root_child0.setDirtiedFunc(() => {
|
||||
dirtied++;
|
||||
});
|
||||
|
||||
expect(dirtied).toBe(0);
|
||||
|
||||
// dirtied func must NOT be called for descendants.
|
||||
// NOTE: nodes without a measure function cannot be marked dirty manually,
|
||||
// but nodes with a measure function can not have children.
|
||||
// Update the width to dirty the node instead.
|
||||
root.setWidth(110);
|
||||
console.assert(0 === dirtied, "0 === dirtied");
|
||||
expect(dirtied).toBe(0);
|
||||
|
||||
// dirtied func MUST be called in case of explicit dirtying.
|
||||
root_child0.markDirty();
|
||||
console.assert(1 === dirtied, "1 === dirtied");
|
||||
expect(dirtied).toBe(1);
|
||||
|
||||
if (typeof root !== "undefined")
|
||||
root.freeRecursive();
|
||||
|
||||
typeof gc !== "undefined" && gc();
|
||||
// TODO Add event support in js and check instace allocation and de allocation using that
|
||||
root.freeRecursive();
|
||||
});
|
||||
|
||||
it("dirtied_reset", function() {
|
||||
var root = Yoga.Node.create();
|
||||
test("dirtied_reset", () => {
|
||||
const root = Yoga.Node.create();
|
||||
root.setAlignItems(Yoga.ALIGN_FLEX_START);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
root.setMeasureFunc(function() {});
|
||||
root.setMeasureFunc(() => {});
|
||||
|
||||
root.calculateLayout(undefined, undefined, Yoga.DIRECTION_LTR);
|
||||
|
||||
let dirtied = 0;
|
||||
root.setDirtiedFunc(function() {
|
||||
root.setDirtiedFunc(() => {
|
||||
dirtied++;
|
||||
});
|
||||
|
||||
console.assert(0 === dirtied, "0 === dirtied");
|
||||
expect(dirtied).toBe(0);
|
||||
|
||||
// dirtied func MUST be called in case of explicit dirtying.
|
||||
root.markDirty();
|
||||
console.assert(1 === dirtied, "1 === dirtied");
|
||||
expect(dirtied).toBe(1);
|
||||
|
||||
// recalculate so the root is no longer dirty
|
||||
root.calculateLayout(undefined, undefined, Yoga.DIRECTION_LTR);
|
||||
@@ -152,17 +142,13 @@ it("dirtied_reset", function() {
|
||||
root.setAlignItems(Yoga.ALIGN_FLEX_START);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
root.setMeasureFunc(function() {});
|
||||
root.setMeasureFunc(() => {});
|
||||
|
||||
root.markDirty();
|
||||
|
||||
// dirtied func must NOT be called after reset.
|
||||
root.markDirty();
|
||||
console.assert(1 === dirtied, "1 === dirtied");
|
||||
expect(dirtied).toBe(1);
|
||||
|
||||
if (typeof root !== "undefined")
|
||||
root.freeRecursive();
|
||||
|
||||
typeof gc !== "undefined" && gc();
|
||||
// TODO Add event support in js and check instace allocation and de allocation using that
|
||||
root.freeRecursive();
|
||||
});
|
@@ -5,29 +5,23 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
var Yoga = Yoga || require("../../sources/entry-" + process.env.TEST_ENTRY);
|
||||
|
||||
it("measure_once_single_flexible_child", function () {
|
||||
var root = Yoga.Node.create();
|
||||
test("measure_once_single_flexible_child", () => {
|
||||
const root = Yoga.Node.create();
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root.setAlignItems(Yoga.ALIGN_FLEX_START);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
var measureCounter = getMeasureCounterMax(Yoga);
|
||||
const measureCounter = getMeasureCounterMax(Yoga);
|
||||
|
||||
var root_child0 = Yoga.Node.create();
|
||||
const root_child0 = Yoga.Node.create();
|
||||
root_child0.setMeasureFunc(measureCounter.inc);
|
||||
root_child0.setFlexGrow(1);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(1 === measureCounter.get(), "1 === measureCounter.get()");
|
||||
expect(measureCounter.get()).toBe(1);
|
||||
|
||||
if (typeof root !== "undefined")
|
||||
root.freeRecursive();
|
||||
|
||||
(typeof gc !== "undefined") && gc();
|
||||
// TODO Add event support in js and check instace allocation and de allocation using that
|
||||
root.freeRecursive();
|
||||
});
|
25
javascript/tests/YGMeasureTest.test.js
Normal file
25
javascript/tests/YGMeasureTest.test.js
Normal file
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
test("dont_measure_single_grow_shrink_child", () => {
|
||||
const root = Yoga.Node.create();
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
const measureCounter = getMeasureCounter(Yoga, null, 100, 100);
|
||||
|
||||
const root_child0 = Yoga.Node.create();
|
||||
root_child0.setMeasureFunc(measureCounter.inc);
|
||||
root_child0.setFlexGrow(1);
|
||||
root_child0.setFlexShrink(1);
|
||||
root.insertChild(root_child0, 0);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
expect(measureCounter.get()).toBe(0);
|
||||
|
||||
root.freeRecursive();
|
||||
});
|
1113
javascript/tests/generated/YGAbsolutePositionTest.test.js
Normal file
1113
javascript/tests/generated/YGAbsolutePositionTest.test.js
Normal file
File diff suppressed because it is too large
Load Diff
1952
javascript/tests/generated/YGAlignContentTest.test.js
Normal file
1952
javascript/tests/generated/YGAlignContentTest.test.js
Normal file
File diff suppressed because it is too large
Load Diff
2268
javascript/tests/generated/YGAlignItemsTest.test.js
Normal file
2268
javascript/tests/generated/YGAlignItemsTest.test.js
Normal file
File diff suppressed because it is too large
Load Diff
267
javascript/tests/generated/YGAlignSelfTest.test.js
Normal file
267
javascript/tests/generated/YGAlignSelfTest.test.js
Normal file
@@ -0,0 +1,267 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// @generated by gentest/gentest.rb from gentest/fixtures/YGAlignSelfTest.html
|
||||
|
||||
test("align_self_center", () => {
|
||||
const config = Yoga.Config.create();
|
||||
let root;
|
||||
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setAlignSelf(Yoga.ALIGN_CENTER);
|
||||
root_child0.setWidth(10);
|
||||
root_child0.setHeight(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(45);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(10);
|
||||
expect(root_child0.getComputedHeight()).toBe(10);
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(45);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(10);
|
||||
expect(root_child0.getComputedHeight()).toBe(10);
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
test("align_self_flex_end", () => {
|
||||
const config = Yoga.Config.create();
|
||||
let root;
|
||||
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setAlignSelf(Yoga.ALIGN_FLEX_END);
|
||||
root_child0.setWidth(10);
|
||||
root_child0.setHeight(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(90);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(10);
|
||||
expect(root_child0.getComputedHeight()).toBe(10);
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(10);
|
||||
expect(root_child0.getComputedHeight()).toBe(10);
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
test("align_self_flex_start", () => {
|
||||
const config = Yoga.Config.create();
|
||||
let root;
|
||||
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setAlignSelf(Yoga.ALIGN_FLEX_START);
|
||||
root_child0.setWidth(10);
|
||||
root_child0.setHeight(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(10);
|
||||
expect(root_child0.getComputedHeight()).toBe(10);
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(90);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(10);
|
||||
expect(root_child0.getComputedHeight()).toBe(10);
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
test("align_self_flex_end_override_flex_start", () => {
|
||||
const config = Yoga.Config.create();
|
||||
let root;
|
||||
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setAlignItems(Yoga.ALIGN_FLEX_START);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setAlignSelf(Yoga.ALIGN_FLEX_END);
|
||||
root_child0.setWidth(10);
|
||||
root_child0.setHeight(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(90);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(10);
|
||||
expect(root_child0.getComputedHeight()).toBe(10);
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(10);
|
||||
expect(root_child0.getComputedHeight()).toBe(10);
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
test("align_self_baseline", () => {
|
||||
const config = Yoga.Config.create();
|
||||
let root;
|
||||
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setAlignSelf(Yoga.ALIGN_BASELINE);
|
||||
root_child0.setWidth(50);
|
||||
root_child0.setHeight(50);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
const root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setAlignSelf(Yoga.ALIGN_BASELINE);
|
||||
root_child1.setWidth(50);
|
||||
root_child1.setHeight(20);
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
const root_child1_child0 = Yoga.Node.create(config);
|
||||
root_child1_child0.setWidth(50);
|
||||
root_child1_child0.setHeight(10);
|
||||
root_child1.insertChild(root_child1_child0, 0);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(50);
|
||||
expect(root_child0.getComputedHeight()).toBe(50);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(50);
|
||||
expect(root_child1.getComputedTop()).toBe(40);
|
||||
expect(root_child1.getComputedWidth()).toBe(50);
|
||||
expect(root_child1.getComputedHeight()).toBe(20);
|
||||
|
||||
expect(root_child1_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child1_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child1_child0.getComputedWidth()).toBe(50);
|
||||
expect(root_child1_child0.getComputedHeight()).toBe(10);
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(50);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(50);
|
||||
expect(root_child0.getComputedHeight()).toBe(50);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(0);
|
||||
expect(root_child1.getComputedTop()).toBe(40);
|
||||
expect(root_child1.getComputedWidth()).toBe(50);
|
||||
expect(root_child1.getComputedHeight()).toBe(20);
|
||||
|
||||
expect(root_child1_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child1_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child1_child0.getComputedWidth()).toBe(50);
|
||||
expect(root_child1_child0.getComputedHeight()).toBe(10);
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
293
javascript/tests/generated/YGAndroidNewsFeed.test.js
Normal file
293
javascript/tests/generated/YGAndroidNewsFeed.test.js
Normal file
@@ -0,0 +1,293 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// @generated by gentest/gentest.rb from gentest/fixtures/YGAndroidNewsFeed.html
|
||||
|
||||
test("android_news_feed", () => {
|
||||
const config = Yoga.Config.create();
|
||||
let root;
|
||||
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setAlignContent(Yoga.ALIGN_STRETCH);
|
||||
root.setWidth(1080);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
const root_child0_child0 = Yoga.Node.create(config);
|
||||
root_child0_child0.setAlignContent(Yoga.ALIGN_STRETCH);
|
||||
root_child0.insertChild(root_child0_child0, 0);
|
||||
|
||||
const root_child0_child0_child0 = Yoga.Node.create(config);
|
||||
root_child0_child0_child0.setAlignContent(Yoga.ALIGN_STRETCH);
|
||||
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
||||
|
||||
const root_child0_child0_child0_child0 = Yoga.Node.create(config);
|
||||
root_child0_child0_child0_child0.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root_child0_child0_child0_child0.setAlignContent(Yoga.ALIGN_STRETCH);
|
||||
root_child0_child0_child0_child0.setAlignItems(Yoga.ALIGN_FLEX_START);
|
||||
root_child0_child0_child0_child0.setMargin(Yoga.EDGE_START, 36);
|
||||
root_child0_child0_child0_child0.setMargin(Yoga.EDGE_TOP, 24);
|
||||
root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0);
|
||||
|
||||
const root_child0_child0_child0_child0_child0 = Yoga.Node.create(config);
|
||||
root_child0_child0_child0_child0_child0.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root_child0_child0_child0_child0_child0.setAlignContent(Yoga.ALIGN_STRETCH);
|
||||
root_child0_child0_child0_child0.insertChild(root_child0_child0_child0_child0_child0, 0);
|
||||
|
||||
const root_child0_child0_child0_child0_child0_child0 = Yoga.Node.create(config);
|
||||
root_child0_child0_child0_child0_child0_child0.setAlignContent(Yoga.ALIGN_STRETCH);
|
||||
root_child0_child0_child0_child0_child0_child0.setWidth(120);
|
||||
root_child0_child0_child0_child0_child0_child0.setHeight(120);
|
||||
root_child0_child0_child0_child0_child0.insertChild(root_child0_child0_child0_child0_child0_child0, 0);
|
||||
|
||||
const root_child0_child0_child0_child0_child1 = Yoga.Node.create(config);
|
||||
root_child0_child0_child0_child0_child1.setAlignContent(Yoga.ALIGN_STRETCH);
|
||||
root_child0_child0_child0_child0_child1.setFlexShrink(1);
|
||||
root_child0_child0_child0_child0_child1.setMargin(Yoga.EDGE_RIGHT, 36);
|
||||
root_child0_child0_child0_child0_child1.setPadding(Yoga.EDGE_LEFT, 36);
|
||||
root_child0_child0_child0_child0_child1.setPadding(Yoga.EDGE_TOP, 21);
|
||||
root_child0_child0_child0_child0_child1.setPadding(Yoga.EDGE_RIGHT, 36);
|
||||
root_child0_child0_child0_child0_child1.setPadding(Yoga.EDGE_BOTTOM, 18);
|
||||
root_child0_child0_child0_child0.insertChild(root_child0_child0_child0_child0_child1, 1);
|
||||
|
||||
const root_child0_child0_child0_child0_child1_child0 = Yoga.Node.create(config);
|
||||
root_child0_child0_child0_child0_child1_child0.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root_child0_child0_child0_child0_child1_child0.setAlignContent(Yoga.ALIGN_STRETCH);
|
||||
root_child0_child0_child0_child0_child1_child0.setFlexShrink(1);
|
||||
root_child0_child0_child0_child0_child1.insertChild(root_child0_child0_child0_child0_child1_child0, 0);
|
||||
|
||||
const root_child0_child0_child0_child0_child1_child1 = Yoga.Node.create(config);
|
||||
root_child0_child0_child0_child0_child1_child1.setAlignContent(Yoga.ALIGN_STRETCH);
|
||||
root_child0_child0_child0_child0_child1_child1.setFlexShrink(1);
|
||||
root_child0_child0_child0_child0_child1.insertChild(root_child0_child0_child0_child0_child1_child1, 1);
|
||||
|
||||
const root_child0_child0_child1 = Yoga.Node.create(config);
|
||||
root_child0_child0_child1.setAlignContent(Yoga.ALIGN_STRETCH);
|
||||
root_child0_child0.insertChild(root_child0_child0_child1, 1);
|
||||
|
||||
const root_child0_child0_child1_child0 = Yoga.Node.create(config);
|
||||
root_child0_child0_child1_child0.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root_child0_child0_child1_child0.setAlignContent(Yoga.ALIGN_STRETCH);
|
||||
root_child0_child0_child1_child0.setAlignItems(Yoga.ALIGN_FLEX_START);
|
||||
root_child0_child0_child1_child0.setMargin(Yoga.EDGE_START, 174);
|
||||
root_child0_child0_child1_child0.setMargin(Yoga.EDGE_TOP, 24);
|
||||
root_child0_child0_child1.insertChild(root_child0_child0_child1_child0, 0);
|
||||
|
||||
const root_child0_child0_child1_child0_child0 = Yoga.Node.create(config);
|
||||
root_child0_child0_child1_child0_child0.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root_child0_child0_child1_child0_child0.setAlignContent(Yoga.ALIGN_STRETCH);
|
||||
root_child0_child0_child1_child0.insertChild(root_child0_child0_child1_child0_child0, 0);
|
||||
|
||||
const root_child0_child0_child1_child0_child0_child0 = Yoga.Node.create(config);
|
||||
root_child0_child0_child1_child0_child0_child0.setAlignContent(Yoga.ALIGN_STRETCH);
|
||||
root_child0_child0_child1_child0_child0_child0.setWidth(72);
|
||||
root_child0_child0_child1_child0_child0_child0.setHeight(72);
|
||||
root_child0_child0_child1_child0_child0.insertChild(root_child0_child0_child1_child0_child0_child0, 0);
|
||||
|
||||
const root_child0_child0_child1_child0_child1 = Yoga.Node.create(config);
|
||||
root_child0_child0_child1_child0_child1.setAlignContent(Yoga.ALIGN_STRETCH);
|
||||
root_child0_child0_child1_child0_child1.setFlexShrink(1);
|
||||
root_child0_child0_child1_child0_child1.setMargin(Yoga.EDGE_RIGHT, 36);
|
||||
root_child0_child0_child1_child0_child1.setPadding(Yoga.EDGE_LEFT, 36);
|
||||
root_child0_child0_child1_child0_child1.setPadding(Yoga.EDGE_TOP, 21);
|
||||
root_child0_child0_child1_child0_child1.setPadding(Yoga.EDGE_RIGHT, 36);
|
||||
root_child0_child0_child1_child0_child1.setPadding(Yoga.EDGE_BOTTOM, 18);
|
||||
root_child0_child0_child1_child0.insertChild(root_child0_child0_child1_child0_child1, 1);
|
||||
|
||||
const root_child0_child0_child1_child0_child1_child0 = Yoga.Node.create(config);
|
||||
root_child0_child0_child1_child0_child1_child0.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root_child0_child0_child1_child0_child1_child0.setAlignContent(Yoga.ALIGN_STRETCH);
|
||||
root_child0_child0_child1_child0_child1_child0.setFlexShrink(1);
|
||||
root_child0_child0_child1_child0_child1.insertChild(root_child0_child0_child1_child0_child1_child0, 0);
|
||||
|
||||
const root_child0_child0_child1_child0_child1_child1 = Yoga.Node.create(config);
|
||||
root_child0_child0_child1_child0_child1_child1.setAlignContent(Yoga.ALIGN_STRETCH);
|
||||
root_child0_child0_child1_child0_child1_child1.setFlexShrink(1);
|
||||
root_child0_child0_child1_child0_child1.insertChild(root_child0_child0_child1_child0_child1_child1, 1);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(1080);
|
||||
expect(root.getComputedHeight()).toBe(240);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(1080);
|
||||
expect(root_child0.getComputedHeight()).toBe(240);
|
||||
|
||||
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0_child0.getComputedWidth()).toBe(1080);
|
||||
expect(root_child0_child0.getComputedHeight()).toBe(240);
|
||||
|
||||
expect(root_child0_child0_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0_child0_child0.getComputedWidth()).toBe(1080);
|
||||
expect(root_child0_child0_child0.getComputedHeight()).toBe(144);
|
||||
|
||||
expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(36);
|
||||
expect(root_child0_child0_child0_child0.getComputedTop()).toBe(24);
|
||||
expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(1044);
|
||||
expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(120);
|
||||
|
||||
expect(root_child0_child0_child0_child0_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0_child0_child0_child0_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0_child0_child0_child0_child0.getComputedWidth()).toBe(120);
|
||||
expect(root_child0_child0_child0_child0_child0.getComputedHeight()).toBe(120);
|
||||
|
||||
expect(root_child0_child0_child0_child0_child0_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0_child0_child0_child0_child0_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0_child0_child0_child0_child0_child0.getComputedWidth()).toBe(120);
|
||||
expect(root_child0_child0_child0_child0_child0_child0.getComputedHeight()).toBe(120);
|
||||
|
||||
expect(root_child0_child0_child0_child0_child1.getComputedLeft()).toBe(120);
|
||||
expect(root_child0_child0_child0_child0_child1.getComputedTop()).toBe(0);
|
||||
expect(root_child0_child0_child0_child0_child1.getComputedWidth()).toBe(72);
|
||||
expect(root_child0_child0_child0_child0_child1.getComputedHeight()).toBe(39);
|
||||
|
||||
expect(root_child0_child0_child0_child0_child1_child0.getComputedLeft()).toBe(36);
|
||||
expect(root_child0_child0_child0_child0_child1_child0.getComputedTop()).toBe(21);
|
||||
expect(root_child0_child0_child0_child0_child1_child0.getComputedWidth()).toBe(0);
|
||||
expect(root_child0_child0_child0_child0_child1_child0.getComputedHeight()).toBe(0);
|
||||
|
||||
expect(root_child0_child0_child0_child0_child1_child1.getComputedLeft()).toBe(36);
|
||||
expect(root_child0_child0_child0_child0_child1_child1.getComputedTop()).toBe(21);
|
||||
expect(root_child0_child0_child0_child0_child1_child1.getComputedWidth()).toBe(0);
|
||||
expect(root_child0_child0_child0_child0_child1_child1.getComputedHeight()).toBe(0);
|
||||
|
||||
expect(root_child0_child0_child1.getComputedLeft()).toBe(0);
|
||||
expect(root_child0_child0_child1.getComputedTop()).toBe(144);
|
||||
expect(root_child0_child0_child1.getComputedWidth()).toBe(1080);
|
||||
expect(root_child0_child0_child1.getComputedHeight()).toBe(96);
|
||||
|
||||
expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(174);
|
||||
expect(root_child0_child0_child1_child0.getComputedTop()).toBe(24);
|
||||
expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(906);
|
||||
expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(72);
|
||||
|
||||
expect(root_child0_child0_child1_child0_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0_child0_child1_child0_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0_child0_child1_child0_child0.getComputedWidth()).toBe(72);
|
||||
expect(root_child0_child0_child1_child0_child0.getComputedHeight()).toBe(72);
|
||||
|
||||
expect(root_child0_child0_child1_child0_child0_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0_child0_child1_child0_child0_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0_child0_child1_child0_child0_child0.getComputedWidth()).toBe(72);
|
||||
expect(root_child0_child0_child1_child0_child0_child0.getComputedHeight()).toBe(72);
|
||||
|
||||
expect(root_child0_child0_child1_child0_child1.getComputedLeft()).toBe(72);
|
||||
expect(root_child0_child0_child1_child0_child1.getComputedTop()).toBe(0);
|
||||
expect(root_child0_child0_child1_child0_child1.getComputedWidth()).toBe(72);
|
||||
expect(root_child0_child0_child1_child0_child1.getComputedHeight()).toBe(39);
|
||||
|
||||
expect(root_child0_child0_child1_child0_child1_child0.getComputedLeft()).toBe(36);
|
||||
expect(root_child0_child0_child1_child0_child1_child0.getComputedTop()).toBe(21);
|
||||
expect(root_child0_child0_child1_child0_child1_child0.getComputedWidth()).toBe(0);
|
||||
expect(root_child0_child0_child1_child0_child1_child0.getComputedHeight()).toBe(0);
|
||||
|
||||
expect(root_child0_child0_child1_child0_child1_child1.getComputedLeft()).toBe(36);
|
||||
expect(root_child0_child0_child1_child0_child1_child1.getComputedTop()).toBe(21);
|
||||
expect(root_child0_child0_child1_child0_child1_child1.getComputedWidth()).toBe(0);
|
||||
expect(root_child0_child0_child1_child0_child1_child1.getComputedHeight()).toBe(0);
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(1080);
|
||||
expect(root.getComputedHeight()).toBe(240);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(1080);
|
||||
expect(root_child0.getComputedHeight()).toBe(240);
|
||||
|
||||
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0_child0.getComputedWidth()).toBe(1080);
|
||||
expect(root_child0_child0.getComputedHeight()).toBe(240);
|
||||
|
||||
expect(root_child0_child0_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0_child0_child0.getComputedWidth()).toBe(1080);
|
||||
expect(root_child0_child0_child0.getComputedHeight()).toBe(144);
|
||||
|
||||
expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0_child0_child0_child0.getComputedTop()).toBe(24);
|
||||
expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(1044);
|
||||
expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(120);
|
||||
|
||||
expect(root_child0_child0_child0_child0_child0.getComputedLeft()).toBe(924);
|
||||
expect(root_child0_child0_child0_child0_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0_child0_child0_child0_child0.getComputedWidth()).toBe(120);
|
||||
expect(root_child0_child0_child0_child0_child0.getComputedHeight()).toBe(120);
|
||||
|
||||
expect(root_child0_child0_child0_child0_child0_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0_child0_child0_child0_child0_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0_child0_child0_child0_child0_child0.getComputedWidth()).toBe(120);
|
||||
expect(root_child0_child0_child0_child0_child0_child0.getComputedHeight()).toBe(120);
|
||||
|
||||
expect(root_child0_child0_child0_child0_child1.getComputedLeft()).toBe(816);
|
||||
expect(root_child0_child0_child0_child0_child1.getComputedTop()).toBe(0);
|
||||
expect(root_child0_child0_child0_child0_child1.getComputedWidth()).toBe(72);
|
||||
expect(root_child0_child0_child0_child0_child1.getComputedHeight()).toBe(39);
|
||||
|
||||
expect(root_child0_child0_child0_child0_child1_child0.getComputedLeft()).toBe(36);
|
||||
expect(root_child0_child0_child0_child0_child1_child0.getComputedTop()).toBe(21);
|
||||
expect(root_child0_child0_child0_child0_child1_child0.getComputedWidth()).toBe(0);
|
||||
expect(root_child0_child0_child0_child0_child1_child0.getComputedHeight()).toBe(0);
|
||||
|
||||
expect(root_child0_child0_child0_child0_child1_child1.getComputedLeft()).toBe(36);
|
||||
expect(root_child0_child0_child0_child0_child1_child1.getComputedTop()).toBe(21);
|
||||
expect(root_child0_child0_child0_child0_child1_child1.getComputedWidth()).toBe(0);
|
||||
expect(root_child0_child0_child0_child0_child1_child1.getComputedHeight()).toBe(0);
|
||||
|
||||
expect(root_child0_child0_child1.getComputedLeft()).toBe(0);
|
||||
expect(root_child0_child0_child1.getComputedTop()).toBe(144);
|
||||
expect(root_child0_child0_child1.getComputedWidth()).toBe(1080);
|
||||
expect(root_child0_child0_child1.getComputedHeight()).toBe(96);
|
||||
|
||||
expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0_child0_child1_child0.getComputedTop()).toBe(24);
|
||||
expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(906);
|
||||
expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(72);
|
||||
|
||||
expect(root_child0_child0_child1_child0_child0.getComputedLeft()).toBe(834);
|
||||
expect(root_child0_child0_child1_child0_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0_child0_child1_child0_child0.getComputedWidth()).toBe(72);
|
||||
expect(root_child0_child0_child1_child0_child0.getComputedHeight()).toBe(72);
|
||||
|
||||
expect(root_child0_child0_child1_child0_child0_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0_child0_child1_child0_child0_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0_child0_child1_child0_child0_child0.getComputedWidth()).toBe(72);
|
||||
expect(root_child0_child0_child1_child0_child0_child0.getComputedHeight()).toBe(72);
|
||||
|
||||
expect(root_child0_child0_child1_child0_child1.getComputedLeft()).toBe(726);
|
||||
expect(root_child0_child0_child1_child0_child1.getComputedTop()).toBe(0);
|
||||
expect(root_child0_child0_child1_child0_child1.getComputedWidth()).toBe(72);
|
||||
expect(root_child0_child0_child1_child0_child1.getComputedHeight()).toBe(39);
|
||||
|
||||
expect(root_child0_child0_child1_child0_child1_child0.getComputedLeft()).toBe(36);
|
||||
expect(root_child0_child0_child1_child0_child1_child0.getComputedTop()).toBe(21);
|
||||
expect(root_child0_child0_child1_child0_child1_child0.getComputedWidth()).toBe(0);
|
||||
expect(root_child0_child0_child1_child0_child1_child0.getComputedHeight()).toBe(0);
|
||||
|
||||
expect(root_child0_child0_child1_child0_child1_child1.getComputedLeft()).toBe(36);
|
||||
expect(root_child0_child0_child1_child0_child1_child1.getComputedTop()).toBe(21);
|
||||
expect(root_child0_child0_child1_child0_child1_child1.getComputedWidth()).toBe(0);
|
||||
expect(root_child0_child0_child1_child0_child1_child1.getComputedHeight()).toBe(0);
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
230
javascript/tests/generated/YGBorderTest.test.js
Normal file
230
javascript/tests/generated/YGBorderTest.test.js
Normal file
@@ -0,0 +1,230 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// @generated by gentest/gentest.rb from gentest/fixtures/YGBorderTest.html
|
||||
|
||||
test("border_no_size", () => {
|
||||
const config = Yoga.Config.create();
|
||||
let root;
|
||||
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setBorder(Yoga.EDGE_LEFT, 10);
|
||||
root.setBorder(Yoga.EDGE_TOP, 10);
|
||||
root.setBorder(Yoga.EDGE_RIGHT, 10);
|
||||
root.setBorder(Yoga.EDGE_BOTTOM, 10);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(20);
|
||||
expect(root.getComputedHeight()).toBe(20);
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(20);
|
||||
expect(root.getComputedHeight()).toBe(20);
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
test("border_container_match_child", () => {
|
||||
const config = Yoga.Config.create();
|
||||
let root;
|
||||
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setBorder(Yoga.EDGE_LEFT, 10);
|
||||
root.setBorder(Yoga.EDGE_TOP, 10);
|
||||
root.setBorder(Yoga.EDGE_RIGHT, 10);
|
||||
root.setBorder(Yoga.EDGE_BOTTOM, 10);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setWidth(10);
|
||||
root_child0.setHeight(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(30);
|
||||
expect(root.getComputedHeight()).toBe(30);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(10);
|
||||
expect(root_child0.getComputedTop()).toBe(10);
|
||||
expect(root_child0.getComputedWidth()).toBe(10);
|
||||
expect(root_child0.getComputedHeight()).toBe(10);
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(30);
|
||||
expect(root.getComputedHeight()).toBe(30);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(10);
|
||||
expect(root_child0.getComputedTop()).toBe(10);
|
||||
expect(root_child0.getComputedWidth()).toBe(10);
|
||||
expect(root_child0.getComputedHeight()).toBe(10);
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
test("border_flex_child", () => {
|
||||
const config = Yoga.Config.create();
|
||||
let root;
|
||||
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setBorder(Yoga.EDGE_LEFT, 10);
|
||||
root.setBorder(Yoga.EDGE_TOP, 10);
|
||||
root.setBorder(Yoga.EDGE_RIGHT, 10);
|
||||
root.setBorder(Yoga.EDGE_BOTTOM, 10);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setFlexGrow(1);
|
||||
root_child0.setWidth(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(10);
|
||||
expect(root_child0.getComputedTop()).toBe(10);
|
||||
expect(root_child0.getComputedWidth()).toBe(10);
|
||||
expect(root_child0.getComputedHeight()).toBe(80);
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(80);
|
||||
expect(root_child0.getComputedTop()).toBe(10);
|
||||
expect(root_child0.getComputedWidth()).toBe(10);
|
||||
expect(root_child0.getComputedHeight()).toBe(80);
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
test("border_stretch_child", () => {
|
||||
const config = Yoga.Config.create();
|
||||
let root;
|
||||
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setBorder(Yoga.EDGE_LEFT, 10);
|
||||
root.setBorder(Yoga.EDGE_TOP, 10);
|
||||
root.setBorder(Yoga.EDGE_RIGHT, 10);
|
||||
root.setBorder(Yoga.EDGE_BOTTOM, 10);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setHeight(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(10);
|
||||
expect(root_child0.getComputedTop()).toBe(10);
|
||||
expect(root_child0.getComputedWidth()).toBe(80);
|
||||
expect(root_child0.getComputedHeight()).toBe(10);
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(10);
|
||||
expect(root_child0.getComputedTop()).toBe(10);
|
||||
expect(root_child0.getComputedWidth()).toBe(80);
|
||||
expect(root_child0.getComputedHeight()).toBe(10);
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
test("border_center_child", () => {
|
||||
const config = Yoga.Config.create();
|
||||
let root;
|
||||
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setJustifyContent(Yoga.JUSTIFY_CENTER);
|
||||
root.setAlignItems(Yoga.ALIGN_CENTER);
|
||||
root.setBorder(Yoga.EDGE_START, 10);
|
||||
root.setBorder(Yoga.EDGE_END, 20);
|
||||
root.setBorder(Yoga.EDGE_BOTTOM, 20);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setWidth(10);
|
||||
root_child0.setHeight(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(40);
|
||||
expect(root_child0.getComputedTop()).toBe(35);
|
||||
expect(root_child0.getComputedWidth()).toBe(10);
|
||||
expect(root_child0.getComputedHeight()).toBe(10);
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(50);
|
||||
expect(root_child0.getComputedTop()).toBe(35);
|
||||
expect(root_child0.getComputedWidth()).toBe(10);
|
||||
expect(root_child0.getComputedHeight()).toBe(10);
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
106
javascript/tests/generated/YGDimensionTest.test.js
Normal file
106
javascript/tests/generated/YGDimensionTest.test.js
Normal file
@@ -0,0 +1,106 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// @generated by gentest/gentest.rb from gentest/fixtures/YGDimensionTest.html
|
||||
|
||||
test("wrap_child", () => {
|
||||
const config = Yoga.Config.create();
|
||||
let root;
|
||||
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setWidth(100);
|
||||
root_child0.setHeight(100);
|
||||
root.insertChild(root_child0, 0);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(100);
|
||||
expect(root_child0.getComputedHeight()).toBe(100);
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(100);
|
||||
expect(root_child0.getComputedHeight()).toBe(100);
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
test("wrap_grandchild", () => {
|
||||
const config = Yoga.Config.create();
|
||||
let root;
|
||||
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
const root_child0_child0 = Yoga.Node.create(config);
|
||||
root_child0_child0.setWidth(100);
|
||||
root_child0_child0.setHeight(100);
|
||||
root_child0.insertChild(root_child0_child0, 0);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(100);
|
||||
expect(root_child0.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
||||
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(100);
|
||||
expect(root_child0.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
||||
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
394
javascript/tests/generated/YGDisplayTest.test.js
Normal file
394
javascript/tests/generated/YGDisplayTest.test.js
Normal file
@@ -0,0 +1,394 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// @generated by gentest/gentest.rb from gentest/fixtures/YGDisplayTest.html
|
||||
|
||||
test("display_none", () => {
|
||||
const config = Yoga.Config.create();
|
||||
let root;
|
||||
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setFlexGrow(1);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
const root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setFlexGrow(1);
|
||||
root_child1.setDisplay(Yoga.DISPLAY_NONE);
|
||||
root.insertChild(root_child1, 1);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(100);
|
||||
expect(root_child0.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(0);
|
||||
expect(root_child1.getComputedTop()).toBe(0);
|
||||
expect(root_child1.getComputedWidth()).toBe(0);
|
||||
expect(root_child1.getComputedHeight()).toBe(0);
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(100);
|
||||
expect(root_child0.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(0);
|
||||
expect(root_child1.getComputedTop()).toBe(0);
|
||||
expect(root_child1.getComputedWidth()).toBe(0);
|
||||
expect(root_child1.getComputedHeight()).toBe(0);
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
test("display_none_fixed_size", () => {
|
||||
const config = Yoga.Config.create();
|
||||
let root;
|
||||
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setFlexGrow(1);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
const root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setWidth(20);
|
||||
root_child1.setHeight(20);
|
||||
root_child1.setDisplay(Yoga.DISPLAY_NONE);
|
||||
root.insertChild(root_child1, 1);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(100);
|
||||
expect(root_child0.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(0);
|
||||
expect(root_child1.getComputedTop()).toBe(0);
|
||||
expect(root_child1.getComputedWidth()).toBe(0);
|
||||
expect(root_child1.getComputedHeight()).toBe(0);
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(100);
|
||||
expect(root_child0.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(0);
|
||||
expect(root_child1.getComputedTop()).toBe(0);
|
||||
expect(root_child1.getComputedWidth()).toBe(0);
|
||||
expect(root_child1.getComputedHeight()).toBe(0);
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
test("display_none_with_margin", () => {
|
||||
const config = Yoga.Config.create();
|
||||
let root;
|
||||
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setMargin(Yoga.EDGE_LEFT, 10);
|
||||
root_child0.setMargin(Yoga.EDGE_TOP, 10);
|
||||
root_child0.setMargin(Yoga.EDGE_RIGHT, 10);
|
||||
root_child0.setMargin(Yoga.EDGE_BOTTOM, 10);
|
||||
root_child0.setWidth(20);
|
||||
root_child0.setHeight(20);
|
||||
root_child0.setDisplay(Yoga.DISPLAY_NONE);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
const root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setFlexGrow(1);
|
||||
root.insertChild(root_child1, 1);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(0);
|
||||
expect(root_child0.getComputedHeight()).toBe(0);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(0);
|
||||
expect(root_child1.getComputedTop()).toBe(0);
|
||||
expect(root_child1.getComputedWidth()).toBe(100);
|
||||
expect(root_child1.getComputedHeight()).toBe(100);
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(0);
|
||||
expect(root_child0.getComputedHeight()).toBe(0);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(0);
|
||||
expect(root_child1.getComputedTop()).toBe(0);
|
||||
expect(root_child1.getComputedWidth()).toBe(100);
|
||||
expect(root_child1.getComputedHeight()).toBe(100);
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
test("display_none_with_child", () => {
|
||||
const config = Yoga.Config.create();
|
||||
let root;
|
||||
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setFlexGrow(1);
|
||||
root_child0.setFlexShrink(1);
|
||||
root_child0.setFlexBasis("0%");
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
const root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setFlexGrow(1);
|
||||
root_child1.setFlexShrink(1);
|
||||
root_child1.setFlexBasis("0%");
|
||||
root_child1.setDisplay(Yoga.DISPLAY_NONE);
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
const root_child1_child0 = Yoga.Node.create(config);
|
||||
root_child1_child0.setFlexGrow(1);
|
||||
root_child1_child0.setFlexShrink(1);
|
||||
root_child1_child0.setFlexBasis("0%");
|
||||
root_child1_child0.setWidth(20);
|
||||
root_child1.insertChild(root_child1_child0, 0);
|
||||
|
||||
const root_child2 = Yoga.Node.create(config);
|
||||
root_child2.setFlexGrow(1);
|
||||
root_child2.setFlexShrink(1);
|
||||
root_child2.setFlexBasis("0%");
|
||||
root.insertChild(root_child2, 2);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(50);
|
||||
expect(root_child0.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(0);
|
||||
expect(root_child1.getComputedTop()).toBe(0);
|
||||
expect(root_child1.getComputedWidth()).toBe(0);
|
||||
expect(root_child1.getComputedHeight()).toBe(0);
|
||||
|
||||
expect(root_child1_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child1_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child1_child0.getComputedWidth()).toBe(0);
|
||||
expect(root_child1_child0.getComputedHeight()).toBe(0);
|
||||
|
||||
expect(root_child2.getComputedLeft()).toBe(50);
|
||||
expect(root_child2.getComputedTop()).toBe(0);
|
||||
expect(root_child2.getComputedWidth()).toBe(50);
|
||||
expect(root_child2.getComputedHeight()).toBe(100);
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(50);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(50);
|
||||
expect(root_child0.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(0);
|
||||
expect(root_child1.getComputedTop()).toBe(0);
|
||||
expect(root_child1.getComputedWidth()).toBe(0);
|
||||
expect(root_child1.getComputedHeight()).toBe(0);
|
||||
|
||||
expect(root_child1_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child1_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child1_child0.getComputedWidth()).toBe(0);
|
||||
expect(root_child1_child0.getComputedHeight()).toBe(0);
|
||||
|
||||
expect(root_child2.getComputedLeft()).toBe(0);
|
||||
expect(root_child2.getComputedTop()).toBe(0);
|
||||
expect(root_child2.getComputedWidth()).toBe(50);
|
||||
expect(root_child2.getComputedHeight()).toBe(100);
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
test("display_none_with_position", () => {
|
||||
const config = Yoga.Config.create();
|
||||
let root;
|
||||
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setFlexGrow(1);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
const root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setFlexGrow(1);
|
||||
root_child1.setPosition(Yoga.EDGE_TOP, 10);
|
||||
root_child1.setDisplay(Yoga.DISPLAY_NONE);
|
||||
root.insertChild(root_child1, 1);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(100);
|
||||
expect(root_child0.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(0);
|
||||
expect(root_child1.getComputedTop()).toBe(0);
|
||||
expect(root_child1.getComputedWidth()).toBe(0);
|
||||
expect(root_child1.getComputedHeight()).toBe(0);
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(100);
|
||||
expect(root_child0.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(0);
|
||||
expect(root_child1.getComputedTop()).toBe(0);
|
||||
expect(root_child1.getComputedWidth()).toBe(0);
|
||||
expect(root_child1.getComputedHeight()).toBe(0);
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
test("display_none_with_position_absolute", () => {
|
||||
const config = Yoga.Config.create();
|
||||
let root;
|
||||
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setPositionType(Yoga.POSITION_TYPE_ABSOLUTE);
|
||||
root_child0.setWidth(100);
|
||||
root_child0.setHeight(100);
|
||||
root_child0.setDisplay(Yoga.DISPLAY_NONE);
|
||||
root.insertChild(root_child0, 0);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(0);
|
||||
expect(root_child0.getComputedHeight()).toBe(0);
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(0);
|
||||
expect(root_child0.getComputedHeight()).toBe(0);
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
437
javascript/tests/generated/YGFlexDirectionTest.test.js
Normal file
437
javascript/tests/generated/YGFlexDirectionTest.test.js
Normal file
@@ -0,0 +1,437 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// @generated by gentest/gentest.rb from gentest/fixtures/YGFlexDirectionTest.html
|
||||
|
||||
test("flex_direction_column_no_height", () => {
|
||||
const config = Yoga.Config.create();
|
||||
let root;
|
||||
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setWidth(100);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setHeight(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
const root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setHeight(10);
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
const root_child2 = Yoga.Node.create(config);
|
||||
root_child2.setHeight(10);
|
||||
root.insertChild(root_child2, 2);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(30);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(100);
|
||||
expect(root_child0.getComputedHeight()).toBe(10);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(0);
|
||||
expect(root_child1.getComputedTop()).toBe(10);
|
||||
expect(root_child1.getComputedWidth()).toBe(100);
|
||||
expect(root_child1.getComputedHeight()).toBe(10);
|
||||
|
||||
expect(root_child2.getComputedLeft()).toBe(0);
|
||||
expect(root_child2.getComputedTop()).toBe(20);
|
||||
expect(root_child2.getComputedWidth()).toBe(100);
|
||||
expect(root_child2.getComputedHeight()).toBe(10);
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(30);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(100);
|
||||
expect(root_child0.getComputedHeight()).toBe(10);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(0);
|
||||
expect(root_child1.getComputedTop()).toBe(10);
|
||||
expect(root_child1.getComputedWidth()).toBe(100);
|
||||
expect(root_child1.getComputedHeight()).toBe(10);
|
||||
|
||||
expect(root_child2.getComputedLeft()).toBe(0);
|
||||
expect(root_child2.getComputedTop()).toBe(20);
|
||||
expect(root_child2.getComputedWidth()).toBe(100);
|
||||
expect(root_child2.getComputedHeight()).toBe(10);
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
test("flex_direction_row_no_width", () => {
|
||||
const config = Yoga.Config.create();
|
||||
let root;
|
||||
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root.setHeight(100);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setWidth(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
const root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setWidth(10);
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
const root_child2 = Yoga.Node.create(config);
|
||||
root_child2.setWidth(10);
|
||||
root.insertChild(root_child2, 2);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(30);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(10);
|
||||
expect(root_child0.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(10);
|
||||
expect(root_child1.getComputedTop()).toBe(0);
|
||||
expect(root_child1.getComputedWidth()).toBe(10);
|
||||
expect(root_child1.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child2.getComputedLeft()).toBe(20);
|
||||
expect(root_child2.getComputedTop()).toBe(0);
|
||||
expect(root_child2.getComputedWidth()).toBe(10);
|
||||
expect(root_child2.getComputedHeight()).toBe(100);
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(30);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(20);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(10);
|
||||
expect(root_child0.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(10);
|
||||
expect(root_child1.getComputedTop()).toBe(0);
|
||||
expect(root_child1.getComputedWidth()).toBe(10);
|
||||
expect(root_child1.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child2.getComputedLeft()).toBe(0);
|
||||
expect(root_child2.getComputedTop()).toBe(0);
|
||||
expect(root_child2.getComputedWidth()).toBe(10);
|
||||
expect(root_child2.getComputedHeight()).toBe(100);
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
test("flex_direction_column", () => {
|
||||
const config = Yoga.Config.create();
|
||||
let root;
|
||||
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setHeight(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
const root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setHeight(10);
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
const root_child2 = Yoga.Node.create(config);
|
||||
root_child2.setHeight(10);
|
||||
root.insertChild(root_child2, 2);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(100);
|
||||
expect(root_child0.getComputedHeight()).toBe(10);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(0);
|
||||
expect(root_child1.getComputedTop()).toBe(10);
|
||||
expect(root_child1.getComputedWidth()).toBe(100);
|
||||
expect(root_child1.getComputedHeight()).toBe(10);
|
||||
|
||||
expect(root_child2.getComputedLeft()).toBe(0);
|
||||
expect(root_child2.getComputedTop()).toBe(20);
|
||||
expect(root_child2.getComputedWidth()).toBe(100);
|
||||
expect(root_child2.getComputedHeight()).toBe(10);
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(100);
|
||||
expect(root_child0.getComputedHeight()).toBe(10);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(0);
|
||||
expect(root_child1.getComputedTop()).toBe(10);
|
||||
expect(root_child1.getComputedWidth()).toBe(100);
|
||||
expect(root_child1.getComputedHeight()).toBe(10);
|
||||
|
||||
expect(root_child2.getComputedLeft()).toBe(0);
|
||||
expect(root_child2.getComputedTop()).toBe(20);
|
||||
expect(root_child2.getComputedWidth()).toBe(100);
|
||||
expect(root_child2.getComputedHeight()).toBe(10);
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
test("flex_direction_row", () => {
|
||||
const config = Yoga.Config.create();
|
||||
let root;
|
||||
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setWidth(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
const root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setWidth(10);
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
const root_child2 = Yoga.Node.create(config);
|
||||
root_child2.setWidth(10);
|
||||
root.insertChild(root_child2, 2);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(10);
|
||||
expect(root_child0.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(10);
|
||||
expect(root_child1.getComputedTop()).toBe(0);
|
||||
expect(root_child1.getComputedWidth()).toBe(10);
|
||||
expect(root_child1.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child2.getComputedLeft()).toBe(20);
|
||||
expect(root_child2.getComputedTop()).toBe(0);
|
||||
expect(root_child2.getComputedWidth()).toBe(10);
|
||||
expect(root_child2.getComputedHeight()).toBe(100);
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(90);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(10);
|
||||
expect(root_child0.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(80);
|
||||
expect(root_child1.getComputedTop()).toBe(0);
|
||||
expect(root_child1.getComputedWidth()).toBe(10);
|
||||
expect(root_child1.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child2.getComputedLeft()).toBe(70);
|
||||
expect(root_child2.getComputedTop()).toBe(0);
|
||||
expect(root_child2.getComputedWidth()).toBe(10);
|
||||
expect(root_child2.getComputedHeight()).toBe(100);
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
test("flex_direction_column_reverse", () => {
|
||||
const config = Yoga.Config.create();
|
||||
let root;
|
||||
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN_REVERSE);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setHeight(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
const root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setHeight(10);
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
const root_child2 = Yoga.Node.create(config);
|
||||
root_child2.setHeight(10);
|
||||
root.insertChild(root_child2, 2);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(90);
|
||||
expect(root_child0.getComputedWidth()).toBe(100);
|
||||
expect(root_child0.getComputedHeight()).toBe(10);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(0);
|
||||
expect(root_child1.getComputedTop()).toBe(80);
|
||||
expect(root_child1.getComputedWidth()).toBe(100);
|
||||
expect(root_child1.getComputedHeight()).toBe(10);
|
||||
|
||||
expect(root_child2.getComputedLeft()).toBe(0);
|
||||
expect(root_child2.getComputedTop()).toBe(70);
|
||||
expect(root_child2.getComputedWidth()).toBe(100);
|
||||
expect(root_child2.getComputedHeight()).toBe(10);
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(90);
|
||||
expect(root_child0.getComputedWidth()).toBe(100);
|
||||
expect(root_child0.getComputedHeight()).toBe(10);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(0);
|
||||
expect(root_child1.getComputedTop()).toBe(80);
|
||||
expect(root_child1.getComputedWidth()).toBe(100);
|
||||
expect(root_child1.getComputedHeight()).toBe(10);
|
||||
|
||||
expect(root_child2.getComputedLeft()).toBe(0);
|
||||
expect(root_child2.getComputedTop()).toBe(70);
|
||||
expect(root_child2.getComputedWidth()).toBe(100);
|
||||
expect(root_child2.getComputedHeight()).toBe(10);
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
test("flex_direction_row_reverse", () => {
|
||||
const config = Yoga.Config.create();
|
||||
let root;
|
||||
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW_REVERSE);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setWidth(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
const root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setWidth(10);
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
const root_child2 = Yoga.Node.create(config);
|
||||
root_child2.setWidth(10);
|
||||
root.insertChild(root_child2, 2);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(90);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(10);
|
||||
expect(root_child0.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(80);
|
||||
expect(root_child1.getComputedTop()).toBe(0);
|
||||
expect(root_child1.getComputedWidth()).toBe(10);
|
||||
expect(root_child1.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child2.getComputedLeft()).toBe(70);
|
||||
expect(root_child2.getComputedTop()).toBe(0);
|
||||
expect(root_child2.getComputedWidth()).toBe(10);
|
||||
expect(root_child2.getComputedHeight()).toBe(100);
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(10);
|
||||
expect(root_child0.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(10);
|
||||
expect(root_child1.getComputedTop()).toBe(0);
|
||||
expect(root_child1.getComputedWidth()).toBe(10);
|
||||
expect(root_child1.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child2.getComputedLeft()).toBe(20);
|
||||
expect(root_child2.getComputedTop()).toBe(0);
|
||||
expect(root_child2.getComputedWidth()).toBe(10);
|
||||
expect(root_child2.getComputedHeight()).toBe(100);
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
646
javascript/tests/generated/YGFlexTest.test.js
Normal file
646
javascript/tests/generated/YGFlexTest.test.js
Normal file
@@ -0,0 +1,646 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// @generated by gentest/gentest.rb from gentest/fixtures/YGFlexTest.html
|
||||
|
||||
test("flex_basis_flex_grow_column", () => {
|
||||
const config = Yoga.Config.create();
|
||||
let root;
|
||||
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setFlexGrow(1);
|
||||
root_child0.setFlexBasis(50);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
const root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setFlexGrow(1);
|
||||
root.insertChild(root_child1, 1);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(100);
|
||||
expect(root_child0.getComputedHeight()).toBe(75);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(0);
|
||||
expect(root_child1.getComputedTop()).toBe(75);
|
||||
expect(root_child1.getComputedWidth()).toBe(100);
|
||||
expect(root_child1.getComputedHeight()).toBe(25);
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(100);
|
||||
expect(root_child0.getComputedHeight()).toBe(75);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(0);
|
||||
expect(root_child1.getComputedTop()).toBe(75);
|
||||
expect(root_child1.getComputedWidth()).toBe(100);
|
||||
expect(root_child1.getComputedHeight()).toBe(25);
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
test("flex_shrink_flex_grow_row", () => {
|
||||
const config = Yoga.Config.create();
|
||||
let root;
|
||||
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root.setWidth(500);
|
||||
root.setHeight(500);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setFlexShrink(1);
|
||||
root_child0.setWidth(500);
|
||||
root_child0.setHeight(100);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
const root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setFlexShrink(1);
|
||||
root_child1.setWidth(500);
|
||||
root_child1.setHeight(100);
|
||||
root.insertChild(root_child1, 1);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(500);
|
||||
expect(root.getComputedHeight()).toBe(500);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(250);
|
||||
expect(root_child0.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(250);
|
||||
expect(root_child1.getComputedTop()).toBe(0);
|
||||
expect(root_child1.getComputedWidth()).toBe(250);
|
||||
expect(root_child1.getComputedHeight()).toBe(100);
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(500);
|
||||
expect(root.getComputedHeight()).toBe(500);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(250);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(250);
|
||||
expect(root_child0.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(0);
|
||||
expect(root_child1.getComputedTop()).toBe(0);
|
||||
expect(root_child1.getComputedWidth()).toBe(250);
|
||||
expect(root_child1.getComputedHeight()).toBe(100);
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
test("flex_shrink_flex_grow_child_flex_shrink_other_child", () => {
|
||||
const config = Yoga.Config.create();
|
||||
let root;
|
||||
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root.setWidth(500);
|
||||
root.setHeight(500);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setFlexShrink(1);
|
||||
root_child0.setWidth(500);
|
||||
root_child0.setHeight(100);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
const root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setFlexGrow(1);
|
||||
root_child1.setFlexShrink(1);
|
||||
root_child1.setWidth(500);
|
||||
root_child1.setHeight(100);
|
||||
root.insertChild(root_child1, 1);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(500);
|
||||
expect(root.getComputedHeight()).toBe(500);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(250);
|
||||
expect(root_child0.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(250);
|
||||
expect(root_child1.getComputedTop()).toBe(0);
|
||||
expect(root_child1.getComputedWidth()).toBe(250);
|
||||
expect(root_child1.getComputedHeight()).toBe(100);
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(500);
|
||||
expect(root.getComputedHeight()).toBe(500);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(250);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(250);
|
||||
expect(root_child0.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(0);
|
||||
expect(root_child1.getComputedTop()).toBe(0);
|
||||
expect(root_child1.getComputedWidth()).toBe(250);
|
||||
expect(root_child1.getComputedHeight()).toBe(100);
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
test("flex_basis_flex_grow_row", () => {
|
||||
const config = Yoga.Config.create();
|
||||
let root;
|
||||
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setFlexGrow(1);
|
||||
root_child0.setFlexBasis(50);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
const root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setFlexGrow(1);
|
||||
root.insertChild(root_child1, 1);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(75);
|
||||
expect(root_child0.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(75);
|
||||
expect(root_child1.getComputedTop()).toBe(0);
|
||||
expect(root_child1.getComputedWidth()).toBe(25);
|
||||
expect(root_child1.getComputedHeight()).toBe(100);
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(25);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(75);
|
||||
expect(root_child0.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(0);
|
||||
expect(root_child1.getComputedTop()).toBe(0);
|
||||
expect(root_child1.getComputedWidth()).toBe(25);
|
||||
expect(root_child1.getComputedHeight()).toBe(100);
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
test("flex_basis_flex_shrink_column", () => {
|
||||
const config = Yoga.Config.create();
|
||||
let root;
|
||||
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setFlexShrink(1);
|
||||
root_child0.setFlexBasis(100);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
const root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setFlexBasis(50);
|
||||
root.insertChild(root_child1, 1);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(100);
|
||||
expect(root_child0.getComputedHeight()).toBe(50);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(0);
|
||||
expect(root_child1.getComputedTop()).toBe(50);
|
||||
expect(root_child1.getComputedWidth()).toBe(100);
|
||||
expect(root_child1.getComputedHeight()).toBe(50);
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(100);
|
||||
expect(root_child0.getComputedHeight()).toBe(50);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(0);
|
||||
expect(root_child1.getComputedTop()).toBe(50);
|
||||
expect(root_child1.getComputedWidth()).toBe(100);
|
||||
expect(root_child1.getComputedHeight()).toBe(50);
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
test("flex_basis_flex_shrink_row", () => {
|
||||
const config = Yoga.Config.create();
|
||||
let root;
|
||||
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setFlexShrink(1);
|
||||
root_child0.setFlexBasis(100);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
const root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setFlexBasis(50);
|
||||
root.insertChild(root_child1, 1);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(50);
|
||||
expect(root_child0.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(50);
|
||||
expect(root_child1.getComputedTop()).toBe(0);
|
||||
expect(root_child1.getComputedWidth()).toBe(50);
|
||||
expect(root_child1.getComputedHeight()).toBe(100);
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(50);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(50);
|
||||
expect(root_child0.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(0);
|
||||
expect(root_child1.getComputedTop()).toBe(0);
|
||||
expect(root_child1.getComputedWidth()).toBe(50);
|
||||
expect(root_child1.getComputedHeight()).toBe(100);
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
test("flex_shrink_to_zero", () => {
|
||||
const config = Yoga.Config.create();
|
||||
let root;
|
||||
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setHeight(75);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setWidth(50);
|
||||
root_child0.setHeight(50);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
const root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setFlexShrink(1);
|
||||
root_child1.setWidth(50);
|
||||
root_child1.setHeight(50);
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
const root_child2 = Yoga.Node.create(config);
|
||||
root_child2.setWidth(50);
|
||||
root_child2.setHeight(50);
|
||||
root.insertChild(root_child2, 2);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(50);
|
||||
expect(root.getComputedHeight()).toBe(75);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(50);
|
||||
expect(root_child0.getComputedHeight()).toBe(50);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(0);
|
||||
expect(root_child1.getComputedTop()).toBe(50);
|
||||
expect(root_child1.getComputedWidth()).toBe(50);
|
||||
expect(root_child1.getComputedHeight()).toBe(0);
|
||||
|
||||
expect(root_child2.getComputedLeft()).toBe(0);
|
||||
expect(root_child2.getComputedTop()).toBe(50);
|
||||
expect(root_child2.getComputedWidth()).toBe(50);
|
||||
expect(root_child2.getComputedHeight()).toBe(50);
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(50);
|
||||
expect(root.getComputedHeight()).toBe(75);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(50);
|
||||
expect(root_child0.getComputedHeight()).toBe(50);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(0);
|
||||
expect(root_child1.getComputedTop()).toBe(50);
|
||||
expect(root_child1.getComputedWidth()).toBe(50);
|
||||
expect(root_child1.getComputedHeight()).toBe(0);
|
||||
|
||||
expect(root_child2.getComputedLeft()).toBe(0);
|
||||
expect(root_child2.getComputedTop()).toBe(50);
|
||||
expect(root_child2.getComputedWidth()).toBe(50);
|
||||
expect(root_child2.getComputedHeight()).toBe(50);
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
test("flex_basis_overrides_main_size", () => {
|
||||
const config = Yoga.Config.create();
|
||||
let root;
|
||||
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setFlexGrow(1);
|
||||
root_child0.setFlexBasis(50);
|
||||
root_child0.setHeight(20);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
const root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setFlexGrow(1);
|
||||
root_child1.setHeight(10);
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
const root_child2 = Yoga.Node.create(config);
|
||||
root_child2.setFlexGrow(1);
|
||||
root_child2.setHeight(10);
|
||||
root.insertChild(root_child2, 2);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(100);
|
||||
expect(root_child0.getComputedHeight()).toBe(60);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(0);
|
||||
expect(root_child1.getComputedTop()).toBe(60);
|
||||
expect(root_child1.getComputedWidth()).toBe(100);
|
||||
expect(root_child1.getComputedHeight()).toBe(20);
|
||||
|
||||
expect(root_child2.getComputedLeft()).toBe(0);
|
||||
expect(root_child2.getComputedTop()).toBe(80);
|
||||
expect(root_child2.getComputedWidth()).toBe(100);
|
||||
expect(root_child2.getComputedHeight()).toBe(20);
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(100);
|
||||
expect(root_child0.getComputedHeight()).toBe(60);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(0);
|
||||
expect(root_child1.getComputedTop()).toBe(60);
|
||||
expect(root_child1.getComputedWidth()).toBe(100);
|
||||
expect(root_child1.getComputedHeight()).toBe(20);
|
||||
|
||||
expect(root_child2.getComputedLeft()).toBe(0);
|
||||
expect(root_child2.getComputedTop()).toBe(80);
|
||||
expect(root_child2.getComputedWidth()).toBe(100);
|
||||
expect(root_child2.getComputedHeight()).toBe(20);
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
test("flex_grow_shrink_at_most", () => {
|
||||
const config = Yoga.Config.create();
|
||||
let root;
|
||||
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
const root_child0_child0 = Yoga.Node.create(config);
|
||||
root_child0_child0.setFlexGrow(1);
|
||||
root_child0_child0.setFlexShrink(1);
|
||||
root_child0.insertChild(root_child0_child0, 0);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(100);
|
||||
expect(root_child0.getComputedHeight()).toBe(0);
|
||||
|
||||
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
||||
expect(root_child0_child0.getComputedHeight()).toBe(0);
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(100);
|
||||
expect(root.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(100);
|
||||
expect(root_child0.getComputedHeight()).toBe(0);
|
||||
|
||||
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
||||
expect(root_child0_child0.getComputedHeight()).toBe(0);
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
test("flex_grow_less_than_factor_one", () => {
|
||||
const config = Yoga.Config.create();
|
||||
let root;
|
||||
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setWidth(200);
|
||||
root.setHeight(500);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setFlexGrow(0.2);
|
||||
root_child0.setFlexBasis(40);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
const root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setFlexGrow(0.2);
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
const root_child2 = Yoga.Node.create(config);
|
||||
root_child2.setFlexGrow(0.4);
|
||||
root.insertChild(root_child2, 2);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(200);
|
||||
expect(root.getComputedHeight()).toBe(500);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(200);
|
||||
expect(root_child0.getComputedHeight()).toBe(132);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(0);
|
||||
expect(root_child1.getComputedTop()).toBe(132);
|
||||
expect(root_child1.getComputedWidth()).toBe(200);
|
||||
expect(root_child1.getComputedHeight()).toBe(92);
|
||||
|
||||
expect(root_child2.getComputedLeft()).toBe(0);
|
||||
expect(root_child2.getComputedTop()).toBe(224);
|
||||
expect(root_child2.getComputedWidth()).toBe(200);
|
||||
expect(root_child2.getComputedHeight()).toBe(184);
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(200);
|
||||
expect(root.getComputedHeight()).toBe(500);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(200);
|
||||
expect(root_child0.getComputedHeight()).toBe(132);
|
||||
|
||||
expect(root_child1.getComputedLeft()).toBe(0);
|
||||
expect(root_child1.getComputedTop()).toBe(132);
|
||||
expect(root_child1.getComputedWidth()).toBe(200);
|
||||
expect(root_child1.getComputedHeight()).toBe(92);
|
||||
|
||||
expect(root_child2.getComputedLeft()).toBe(0);
|
||||
expect(root_child2.getComputedTop()).toBe(224);
|
||||
expect(root_child2.getComputedWidth()).toBe(200);
|
||||
expect(root_child2.getComputedHeight()).toBe(184);
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
1813
javascript/tests/generated/YGFlexWrapTest.test.js
Normal file
1813
javascript/tests/generated/YGFlexWrapTest.test.js
Normal file
File diff suppressed because it is too large
Load Diff
2202
javascript/tests/generated/YGGapTest.test.js
Normal file
2202
javascript/tests/generated/YGGapTest.test.js
Normal file
File diff suppressed because it is too large
Load Diff
1223
javascript/tests/generated/YGJustifyContentTest.test.js
Normal file
1223
javascript/tests/generated/YGJustifyContentTest.test.js
Normal file
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user