Compare commits
54 Commits
1.8.0
...
woehrl01/b
Author | SHA1 | Date | |
---|---|---|---|
|
2a3d9ba20e | ||
|
e1c19cecad | ||
|
8e4f3a3084 | ||
|
9b8323ff38 | ||
|
5b7adda620 | ||
|
ba2a3b8c91 | ||
|
eb15939c23 | ||
|
b9fa60fd74 | ||
|
d397aa04d7 | ||
|
adb1b11055 | ||
|
2e234473ca | ||
|
6b08db68bb | ||
|
9550126f76 | ||
|
bad262b961 | ||
|
3c6c10075a | ||
|
6a77a6939e | ||
|
b725a4a140 | ||
|
2b714a5b5d | ||
|
572546088f | ||
|
5b109578d3 | ||
|
77b720f9a5 | ||
|
de954eb9cc | ||
|
3e322e60e4 | ||
|
a3642541d0 | ||
|
bb139d3f91 | ||
|
08743a42e2 | ||
|
cb6e76973d | ||
|
4b760fa9bc | ||
|
5730be093e | ||
|
d85e2ee9c3 | ||
|
fe433b012f | ||
|
5e3ffb39a2 | ||
|
f0edefdbb7 | ||
|
17901ea5c2 | ||
|
187fc54596 | ||
|
c951ad7c7b | ||
|
9785975f77 | ||
|
79281049f2 | ||
|
7d2b84aab6 | ||
|
cda328fa7e | ||
|
5d7b75a47a | ||
|
ae86824636 | ||
|
0dde40ce0b | ||
|
369c9ad12a | ||
|
cfb9eeca20 | ||
|
3dfb68887d | ||
|
d567885070 | ||
|
877c275a13 | ||
|
8aadae8ce4 | ||
|
2232d7603a | ||
|
b3f8851bc2 | ||
|
47ad3f63cf | ||
|
c75adb0671 | ||
|
178b8f5f64 |
60
.travis.yml
60
.travis.yml
@@ -1,23 +1,58 @@
|
|||||||
# Copyright (c) 2014-present, Facebook, Inc.
|
language: java
|
||||||
# All rights reserved.
|
|
||||||
#
|
|
||||||
# This source code is licensed under the BSD-style license found in the
|
|
||||||
# LICENSE file in the root directory of this source tree. An additional grant
|
|
||||||
# of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
|
|
||||||
language: node_js
|
env:
|
||||||
node_js:
|
- TARGET: website
|
||||||
- "8"
|
- TARGET: android
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- cd website
|
- cd website
|
||||||
- yarn --ignore-scripts
|
- yarn --ignore-scripts
|
||||||
- cd ..
|
- cd ..
|
||||||
|
|
||||||
|
cache:
|
||||||
|
directories:
|
||||||
|
- $HOME/buck
|
||||||
|
- $HOME/.gradle
|
||||||
|
|
||||||
|
before_install:
|
||||||
|
- |
|
||||||
|
if [[ -n "$encrypted_d27e803291ff_iv" ]]; then
|
||||||
|
openssl aes-256-cbc -K $encrypted_d27e803291ff_key -iv $encrypted_d27e803291ff_iv -in scripts/setup-keys.enc -d >> gradle.properties;
|
||||||
|
fi
|
||||||
|
# Android
|
||||||
|
- |
|
||||||
|
if [[ $TARGET = "android" ]]; then
|
||||||
|
pushd $HOME
|
||||||
|
git clone --depth 1 https://github.com/facebook/buck.git
|
||||||
|
cd buck
|
||||||
|
ant
|
||||||
|
popd
|
||||||
|
export PATH=$PATH:$HOME/buck/bin/
|
||||||
|
buck --version
|
||||||
|
export TERMINAL=dumb
|
||||||
|
source scripts/android-setup.sh && installAndroidSDK
|
||||||
|
export ANDROID_SDK=$ANDROID_HOME
|
||||||
|
export ANDROID_NDK_REPOSITORY=$HOME/android-ndk
|
||||||
|
export ANDROID_NDK_HOME=$ANDROID_NDK_REPOSITORY/android-ndk-r15c
|
||||||
|
fi
|
||||||
|
# Website
|
||||||
|
- |
|
||||||
|
if [[ $TARGET = "website" ]]; then
|
||||||
|
nvm install 8
|
||||||
|
nvm use 8
|
||||||
|
fi
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- cd website
|
- |
|
||||||
- yarn build
|
if [[ $TARGET = "android" ]]; then
|
||||||
- cd ..
|
./gradlew testDebugUnit && scripts/publish-snapshot.sh
|
||||||
|
fi
|
||||||
|
- |
|
||||||
|
if [[ $TARGET = "website" ]]; then
|
||||||
|
pushd website
|
||||||
|
yarn build
|
||||||
|
popd
|
||||||
|
fi
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
provider: pages
|
provider: pages
|
||||||
@@ -30,3 +65,4 @@ deploy:
|
|||||||
keep-history: true
|
keep-history: true
|
||||||
on:
|
on:
|
||||||
branch: master
|
branch: master
|
||||||
|
condition: $TARGET = website
|
||||||
|
20
BUCK
20
BUCK
@@ -3,7 +3,7 @@
|
|||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
load("//:yoga_defs.bzl", "LIBRARY_COMPILER_FLAGS", "BASE_COMPILER_FLAGS", "GTEST_TARGET", "yoga_dep", "cxx_library", "cxx_test")
|
load("//:yoga_defs.bzl", "LIBRARY_COMPILER_FLAGS", "BASE_COMPILER_FLAGS", "GTEST_TARGET", "yoga_dep", "yoga_cxx_library", "yoga_cxx_test")
|
||||||
|
|
||||||
GMOCK_OVERRIDE_FLAGS = [
|
GMOCK_OVERRIDE_FLAGS = [
|
||||||
# gmock does not mark mocked methods as override, ignore the warnings in tests
|
# gmock does not mark mocked methods as override, ignore the warnings in tests
|
||||||
@@ -18,7 +18,7 @@ TEST_COMPILER_FLAGS = BASE_COMPILER_FLAGS + GMOCK_OVERRIDE_FLAGS + [
|
|||||||
"-std=c++1y",
|
"-std=c++1y",
|
||||||
]
|
]
|
||||||
|
|
||||||
cxx_library(
|
yoga_cxx_library(
|
||||||
name = "yoga",
|
name = "yoga",
|
||||||
srcs = glob(["yoga/*.cpp"]),
|
srcs = glob(["yoga/*.cpp"]),
|
||||||
header_namespace = "",
|
header_namespace = "",
|
||||||
@@ -32,21 +32,7 @@ cxx_library(
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
cxx_library(
|
yoga_cxx_test(
|
||||||
name = "yogafastmath",
|
|
||||||
srcs = glob(["yoga/*.cpp"]),
|
|
||||||
header_namespace = "",
|
|
||||||
exported_headers = subdir_glob([("", "yoga/*.h")]),
|
|
||||||
compiler_flags = COMPILER_FLAGS + ["-ffast-math"],
|
|
||||||
soname = "libyogafastmathcore.$(ext)",
|
|
||||||
tests = [":YogaTests"],
|
|
||||||
visibility = ["PUBLIC"],
|
|
||||||
deps = [
|
|
||||||
yoga_dep("lib/fb:ndklog"),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
cxx_test(
|
|
||||||
name = "YogaTests",
|
name = "YogaTests",
|
||||||
srcs = glob(["tests/*.cpp"]),
|
srcs = glob(["tests/*.cpp"]),
|
||||||
compiler_flags = TEST_COMPILER_FLAGS,
|
compiler_flags = TEST_COMPILER_FLAGS,
|
||||||
|
12
Yoga.podspec
12
Yoga.podspec
@@ -1,9 +1,9 @@
|
|||||||
Pod::Spec.new do |spec|
|
Pod::Spec.new do |spec|
|
||||||
spec.name = 'Yoga'
|
spec.name = 'Yoga'
|
||||||
spec.version = '1.7.0'
|
spec.version = '1.8.0'
|
||||||
spec.license = { :type => 'MIT', :file => "LICENSE" }
|
spec.license = { :type => 'MIT', :file => "LICENSE" }
|
||||||
spec.homepage = 'https://facebook.github.io/yoga/'
|
spec.homepage = 'https://yogalayout.com/'
|
||||||
spec.documentation_url = 'https://facebook.github.io/yoga/docs/api/c/'
|
spec.documentation_url = 'https://yogalayout.com/docs'
|
||||||
|
|
||||||
spec.summary = 'Yoga is a cross-platform layout engine which implements Flexbox.'
|
spec.summary = 'Yoga is a cross-platform layout engine which implements Flexbox.'
|
||||||
spec.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.'
|
spec.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.'
|
||||||
@@ -11,9 +11,9 @@ Pod::Spec.new do |spec|
|
|||||||
spec.authors = 'Facebook'
|
spec.authors = 'Facebook'
|
||||||
spec.source = {
|
spec.source = {
|
||||||
:git => 'https://github.com/facebook/yoga.git',
|
:git => 'https://github.com/facebook/yoga.git',
|
||||||
:tag => '1.7.0',
|
:tag => '1.8.0',
|
||||||
}
|
}
|
||||||
|
spec.osx.deployment_target = '10.13'
|
||||||
spec.module_name = 'yoga'
|
spec.module_name = 'yoga'
|
||||||
spec.requires_arc = false
|
spec.requires_arc = false
|
||||||
spec.compiler_flags = [
|
spec.compiler_flags = [
|
||||||
@@ -25,4 +25,6 @@ Pod::Spec.new do |spec|
|
|||||||
'-fPIC'
|
'-fPIC'
|
||||||
]
|
]
|
||||||
spec.source_files = 'yoga/**/*.{c,h,cpp}'
|
spec.source_files = 'yoga/**/*.{c,h,cpp}'
|
||||||
|
spec.public_header_files = 'yoga/{Yoga,YGEnums,YGMacros}.h'
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
load("//:yoga_defs.bzl", "yoga_dep", "apple_library", "apple_test")
|
load("//:yoga_defs.bzl", "yoga_dep", "yoga_apple_library", "yoga_apple_test")
|
||||||
|
|
||||||
COMPILER_FLAGS = [
|
COMPILER_FLAGS = [
|
||||||
"-fobjc-arc",
|
"-fobjc-arc",
|
||||||
@@ -25,7 +25,7 @@ COMPILER_FLAGS = [
|
|||||||
"-Wunused-value",
|
"-Wunused-value",
|
||||||
]
|
]
|
||||||
|
|
||||||
apple_library(
|
yoga_apple_library(
|
||||||
name = "YogaKit",
|
name = "YogaKit",
|
||||||
srcs = glob(["Source/**/*.m"]),
|
srcs = glob(["Source/**/*.m"]),
|
||||||
header_namespace = "",
|
header_namespace = "",
|
||||||
@@ -49,7 +49,7 @@ apple_library(
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
apple_test(
|
yoga_apple_test(
|
||||||
name = "YogaKitTests",
|
name = "YogaKitTests",
|
||||||
srcs = glob(["Tests/**/*.m"]),
|
srcs = glob(["Tests/**/*.m"]),
|
||||||
compiler_flags = COMPILER_FLAGS,
|
compiler_flags = COMPILER_FLAGS,
|
||||||
|
@@ -3,9 +3,9 @@
|
|||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
load("//:yoga_defs.bzl", "ANDROID_JAVA_TARGET", "ANDROID_RES_TARGET", "INFER_ANNOTATIONS_TARGET", "JAVA_TARGET", "PROGRUARD_ANNOTATIONS_TARGET", "android_aar", "android_resource")
|
load("//:yoga_defs.bzl", "ANDROID_JAVA_TARGET", "ANDROID_RES_TARGET", "INFER_ANNOTATIONS_TARGET", "JAVA_TARGET", "PROGRUARD_ANNOTATIONS_TARGET", "yoga_android_aar", "yoga_android_resource")
|
||||||
|
|
||||||
android_aar(
|
yoga_android_aar(
|
||||||
name = "android",
|
name = "android",
|
||||||
manifest_skeleton = "src/main/AndroidManifest.xml",
|
manifest_skeleton = "src/main/AndroidManifest.xml",
|
||||||
visibility = [
|
visibility = [
|
||||||
@@ -20,7 +20,7 @@ android_aar(
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
android_resource(
|
yoga_android_resource(
|
||||||
name = "res",
|
name = "res",
|
||||||
package = "com.facebook.yoga.android",
|
package = "com.facebook.yoga.android",
|
||||||
res = "src/main/res",
|
res = "src/main/res",
|
||||||
|
@@ -4,9 +4,9 @@
|
|||||||
# This source code is licensed under the license found in the
|
# This source code is licensed under the license found in the
|
||||||
# LICENSE-examples file in the root directory of this source tree.
|
# LICENSE-examples file in the root directory of this source tree.
|
||||||
|
|
||||||
load("//:yoga_defs.bzl", "ANDROID_SAMPLE_JAVA_TARGET", "ANDROID_SAMPLE_RES_TARGET", "ANDROID_RES_TARGET", "android_binary", "android_resource")
|
load("//:yoga_defs.bzl", "ANDROID_SAMPLE_JAVA_TARGET", "ANDROID_SAMPLE_RES_TARGET", "ANDROID_RES_TARGET", "yoga_android_binary", "yoga_android_resource")
|
||||||
|
|
||||||
android_binary(
|
yoga_android_binary(
|
||||||
name = "sample",
|
name = "sample",
|
||||||
keystore = ":debug_keystore",
|
keystore = ":debug_keystore",
|
||||||
manifest = "AndroidManifest.xml",
|
manifest = "AndroidManifest.xml",
|
||||||
@@ -16,7 +16,7 @@ android_binary(
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
android_resource(
|
yoga_android_resource(
|
||||||
name = "res",
|
name = "res",
|
||||||
package = "com.facebook.samples.yoga",
|
package = "com.facebook.samples.yoga",
|
||||||
res = "res",
|
res = "res",
|
||||||
|
@@ -1,13 +1,11 @@
|
|||||||
# Copyright (c) 2014-present, Facebook, Inc.
|
# Copyright (c) 2014-present, Facebook, Inc.
|
||||||
# All rights reserved.
|
|
||||||
#
|
#
|
||||||
# This source code is licensed under the BSD-style license found in the
|
# This source code is licensed under the license found in the
|
||||||
# LICENSE file in the root directory of this source tree. An additional grant
|
# LICENSE-examples file in the root directory of this source tree.
|
||||||
# of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
|
|
||||||
load("//:yoga_defs.bzl", "ANDROID_JAVA_TARGET", "ANDROID_SAMPLE_RES_TARGET", "ANDROID_SUPPORT_TARGET", "APPCOMPAT_TARGET", "SOLOADER_TARGET", "android_library")
|
load("//:yoga_defs.bzl", "ANDROID_JAVA_TARGET", "ANDROID_SAMPLE_RES_TARGET", "ANDROID_SUPPORT_TARGET", "APPCOMPAT_TARGET", "SOLOADER_TARGET", "yoga_android_library")
|
||||||
|
|
||||||
android_library(
|
yoga_android_library(
|
||||||
name = "yoga",
|
name = "yoga",
|
||||||
srcs = glob(["**/*.java"]),
|
srcs = glob(["**/*.java"]),
|
||||||
visibility = [
|
visibility = [
|
||||||
|
@@ -3,9 +3,9 @@
|
|||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
load("//:yoga_defs.bzl", "ANDROID_RES_TARGET", "INFER_ANNOTATIONS_TARGET", "JAVA_TARGET", "JSR_305_TARGET", "SOLOADER_TARGET", "android_library")
|
load("//:yoga_defs.bzl", "ANDROID_RES_TARGET", "INFER_ANNOTATIONS_TARGET", "JAVA_TARGET", "JSR_305_TARGET", "SOLOADER_TARGET", "yoga_android_library")
|
||||||
|
|
||||||
android_library(
|
yoga_android_library(
|
||||||
name = "android",
|
name = "android",
|
||||||
srcs = glob(["**/*.java"]),
|
srcs = glob(["**/*.java"]),
|
||||||
visibility = [
|
visibility = [
|
||||||
|
@@ -7,9 +7,6 @@
|
|||||||
|
|
||||||
package com.facebook.yoga.android;
|
package com.facebook.yoga.android;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
@@ -21,9 +18,6 @@ import android.util.SparseArray;
|
|||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import com.facebook.yoga.android.R;
|
|
||||||
import com.facebook.yoga.YogaAlign;
|
import com.facebook.yoga.YogaAlign;
|
||||||
import com.facebook.yoga.YogaConstants;
|
import com.facebook.yoga.YogaConstants;
|
||||||
import com.facebook.yoga.YogaDirection;
|
import com.facebook.yoga.YogaDirection;
|
||||||
@@ -35,10 +29,11 @@ import com.facebook.yoga.YogaMeasureFunction;
|
|||||||
import com.facebook.yoga.YogaMeasureMode;
|
import com.facebook.yoga.YogaMeasureMode;
|
||||||
import com.facebook.yoga.YogaMeasureOutput;
|
import com.facebook.yoga.YogaMeasureOutput;
|
||||||
import com.facebook.yoga.YogaNode;
|
import com.facebook.yoga.YogaNode;
|
||||||
import com.facebook.yoga.YogaNode;
|
|
||||||
import com.facebook.yoga.YogaOverflow;
|
import com.facebook.yoga.YogaOverflow;
|
||||||
import com.facebook.yoga.YogaPositionType;
|
import com.facebook.yoga.YogaPositionType;
|
||||||
import com.facebook.yoga.YogaWrap;
|
import com.facebook.yoga.YogaWrap;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@code ViewGroup} based on the Yoga layout engine.
|
* A {@code ViewGroup} based on the Yoga layout engine.
|
||||||
@@ -51,14 +46,14 @@ import com.facebook.yoga.YogaWrap;
|
|||||||
* <YogaLayout
|
* <YogaLayout
|
||||||
* xmlns:android="http://schemas.android.com/apk/res/android"
|
* xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
* xmlns:yoga="http://schemas.android.com/apk/com.facebook.yoga.android"
|
* xmlns:yoga="http://schemas.android.com/apk/com.facebook.yoga.android"
|
||||||
* android:layout_width="match_parent"
|
* android:layout_width="match_owner"
|
||||||
* android:layout_height="match_parent"
|
* android:layout_height="match_owner"
|
||||||
* yoga:flex_direction="row"
|
* yoga:flex_direction="row"
|
||||||
* yoga:padding_all="10dp"
|
* yoga:padding_all="10dp"
|
||||||
* >
|
* >
|
||||||
* <TextView
|
* <TextView
|
||||||
* android:layout_width="match_parent"
|
* android:layout_width="match_owner"
|
||||||
* android:layout_height="match_parent"
|
* android:layout_height="match_owner"
|
||||||
* android:text="Hello, World!"
|
* android:text="Hello, World!"
|
||||||
* yoga:flex="1"
|
* yoga:flex="1"
|
||||||
* />
|
* />
|
||||||
@@ -267,11 +262,11 @@ public class YogaLayout extends ViewGroup {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final YogaNode parent = node.getParent();
|
final YogaNode owner = node.getOwner();
|
||||||
|
|
||||||
for (int i = 0; i < parent.getChildCount(); i++) {
|
for (int i = 0; i < owner.getChildCount(); i++) {
|
||||||
if (parent.getChildAt(i).equals(node)) {
|
if (owner.getChildAt(i).equals(node)) {
|
||||||
parent.removeChildAt(i);
|
owner.removeChildAt(i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -291,6 +286,8 @@ public class YogaLayout extends ViewGroup {
|
|||||||
if (view.getVisibility() == GONE) {
|
if (view.getVisibility() == GONE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
int left = Math.round(xOffset + node.getLayoutX());
|
||||||
|
int top = Math.round(yOffset + node.getLayoutY());
|
||||||
view.measure(
|
view.measure(
|
||||||
View.MeasureSpec.makeMeasureSpec(
|
View.MeasureSpec.makeMeasureSpec(
|
||||||
Math.round(node.getLayoutWidth()),
|
Math.round(node.getLayoutWidth()),
|
||||||
@@ -298,11 +295,7 @@ public class YogaLayout extends ViewGroup {
|
|||||||
View.MeasureSpec.makeMeasureSpec(
|
View.MeasureSpec.makeMeasureSpec(
|
||||||
Math.round(node.getLayoutHeight()),
|
Math.round(node.getLayoutHeight()),
|
||||||
View.MeasureSpec.EXACTLY));
|
View.MeasureSpec.EXACTLY));
|
||||||
view.layout(
|
view.layout(left, top, left + view.getMeasuredWidth(), top + view.getMeasuredHeight());
|
||||||
Math.round(xOffset + node.getLayoutX()),
|
|
||||||
Math.round(yOffset + node.getLayoutY()),
|
|
||||||
Math.round(xOffset + node.getLayoutX() + node.getLayoutWidth()),
|
|
||||||
Math.round(yOffset + node.getLayoutY() + node.getLayoutHeight()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final int childrenCount = node.getChildCount();
|
final int childrenCount = node.getChildCount();
|
||||||
@@ -322,7 +315,7 @@ public class YogaLayout extends ViewGroup {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
||||||
// Either we are a root of a tree, or this function is called by our parent's onLayout, in which
|
// Either we are a root of a tree, or this function is called by our owner's onLayout, in which
|
||||||
// case our r-l and b-t are the size of our node.
|
// case our r-l and b-t are the size of our node.
|
||||||
if (!(getParent() instanceof YogaLayout)) {
|
if (!(getParent() instanceof YogaLayout)) {
|
||||||
createLayout(
|
createLayout(
|
||||||
@@ -706,7 +699,7 @@ public class YogaLayout extends ViewGroup {
|
|||||||
/**
|
/**
|
||||||
* Constructs a set of layout params, given width and height specs. In this case, we can set
|
* Constructs a set of layout params, given width and height specs. In this case, we can set
|
||||||
* the {@code yoga:width} and {@code yoga:height} if we are given them explicitly. If other
|
* the {@code yoga:width} and {@code yoga:height} if we are given them explicitly. If other
|
||||||
* options (such as {@code match_parent} or {@code wrap_content} are given, then the parent
|
* options (such as {@code match_owner} or {@code wrap_content} are given, then the owner
|
||||||
* LayoutParams will store them, and we deal with them during layout. (see
|
* LayoutParams will store them, and we deal with them during layout. (see
|
||||||
* {@link YogaLayout#createLayout})
|
* {@link YogaLayout#createLayout})
|
||||||
*
|
*
|
||||||
@@ -780,9 +773,9 @@ public class YogaLayout extends ViewGroup {
|
|||||||
* {@code View}'s measure function.
|
* {@code View}'s measure function.
|
||||||
*
|
*
|
||||||
* @param node The yoga node to measure
|
* @param node The yoga node to measure
|
||||||
* @param width The suggested width from the parent
|
* @param width The suggested width from the owner
|
||||||
* @param widthMode The type of suggestion for the width
|
* @param widthMode The type of suggestion for the width
|
||||||
* @param height The suggested height from the parent
|
* @param height The suggested height from the owner
|
||||||
* @param heightMode The type of suggestion for the height
|
* @param heightMode The type of suggestion for the height
|
||||||
* @return A measurement output ({@code YogaMeasureOutput}) for the node
|
* @return A measurement output ({@code YogaMeasureOutput}) for the node
|
||||||
*/
|
*/
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
load("//:yoga_defs.bzl", "yoga_dep")
|
load("//:yoga_defs.bzl", "yoga_dep", "ANDROID", "APPLE")
|
||||||
|
|
||||||
cxx_binary(
|
cxx_binary(
|
||||||
name = "benchmark",
|
name = "benchmark",
|
||||||
@@ -18,6 +18,7 @@ cxx_binary(
|
|||||||
"-O3",
|
"-O3",
|
||||||
"-std=c11",
|
"-std=c11",
|
||||||
],
|
],
|
||||||
|
platforms = (ANDROID, APPLE),
|
||||||
visibility = ["PUBLIC"],
|
visibility = ["PUBLIC"],
|
||||||
deps = [
|
deps = [
|
||||||
yoga_dep(":yoga"),
|
yoga_dep(":yoga"),
|
||||||
|
12
csharp/BUCK
12
csharp/BUCK
@@ -3,7 +3,7 @@
|
|||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
load("//:yoga_defs.bzl", "BASE_COMPILER_FLAGS", "yoga_dep", "cxx_library", "is_apple_platform")
|
load("//:yoga_defs.bzl", "BASE_COMPILER_FLAGS", "yoga_dep", "yoga_cxx_library", "is_apple_platform")
|
||||||
|
|
||||||
COMPILER_FLAGS = BASE_COMPILER_FLAGS + ["-std=c++11"]
|
COMPILER_FLAGS = BASE_COMPILER_FLAGS + ["-std=c++11"]
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ csharp_library(
|
|||||||
framework_ver = "net45",
|
framework_ver = "net45",
|
||||||
)
|
)
|
||||||
|
|
||||||
cxx_library(
|
yoga_cxx_library(
|
||||||
name = "yoganet",
|
name = "yoganet",
|
||||||
srcs = glob(["Yoga/YGInterop.cpp"]),
|
srcs = glob(["Yoga/YGInterop.cpp"]),
|
||||||
compiler_flags = COMPILER_FLAGS,
|
compiler_flags = COMPILER_FLAGS,
|
||||||
@@ -42,9 +42,9 @@ if is_apple_platform():
|
|||||||
genrule(
|
genrule(
|
||||||
name = name,
|
name = name,
|
||||||
srcs = [
|
srcs = [
|
||||||
yoga_dep(':yoga#%s,static' % arch),
|
yoga_dep(':yogaApple#%s,static' % arch),
|
||||||
yoga_dep('YogaKit:YogaKit#%s,static' % arch),
|
yoga_dep('YogaKit:YogaKitApple#%s,static' % arch),
|
||||||
yoga_dep('csharp:yoganet#%s,static' % arch),
|
yoga_dep('csharp:yoganetApple#%s,static' % arch),
|
||||||
],
|
],
|
||||||
out = 'libyoga-%s.a' % arch,
|
out = 'libyoga-%s.a' % arch,
|
||||||
cmd = 'libtool -static -o $OUT $SRCS',
|
cmd = 'libtool -static -o $OUT $SRCS',
|
||||||
@@ -59,7 +59,7 @@ if is_apple_platform():
|
|||||||
visibility = ['PUBLIC'],
|
visibility = ['PUBLIC'],
|
||||||
)
|
)
|
||||||
|
|
||||||
yoganet_macosx_target = 'csharp:yoganet#macosx-%s,dynamic'
|
yoganet_macosx_target = 'csharp:yoganetAppleMac#macosx-%s,dynamic'
|
||||||
genrule(
|
genrule(
|
||||||
name = 'yoganet-macosx',
|
name = 'yoganet-macosx',
|
||||||
srcs = [
|
srcs = [
|
||||||
|
@@ -227,19 +227,31 @@
|
|||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\..\yoga\Yoga.h" />
|
<ClInclude Include="..\..\yoga\Utils.h" />
|
||||||
|
<ClInclude Include="..\..\yoga\YGConfig.h" />
|
||||||
<ClInclude Include="..\..\yoga\YGEnums.h" />
|
<ClInclude Include="..\..\yoga\YGEnums.h" />
|
||||||
|
<ClInclude Include="..\..\yoga\YGFloatOptional.h" />
|
||||||
|
<ClInclude Include="..\..\yoga\YGLayout.h" />
|
||||||
<ClInclude Include="..\..\yoga\YGMacros.h" />
|
<ClInclude Include="..\..\yoga\YGMacros.h" />
|
||||||
<ClInclude Include="..\..\yoga\YGNodeList.h" />
|
<ClInclude Include="..\..\yoga\YGNode.h" />
|
||||||
|
<ClInclude Include="..\..\yoga\YGNodePrint.h" />
|
||||||
|
<ClInclude Include="..\..\yoga\YGStyle.h" />
|
||||||
|
<ClInclude Include="..\..\yoga\Yoga-internal.h" />
|
||||||
|
<ClInclude Include="..\..\yoga\Yoga.h" />
|
||||||
<ClInclude Include="resource.h" />
|
<ClInclude Include="resource.h" />
|
||||||
<ClInclude Include="YGInterop.h" />
|
|
||||||
<ClInclude Include="stdafx.h" />
|
<ClInclude Include="stdafx.h" />
|
||||||
<ClInclude Include="targetver.h" />
|
<ClInclude Include="targetver.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\..\yoga\Yoga.c" />
|
<ClCompile Include="..\..\yoga\Utils.cpp" />
|
||||||
<ClCompile Include="..\..\yoga\YGEnums.c" />
|
<ClCompile Include="..\..\yoga\YGConfig.cpp" />
|
||||||
<ClCompile Include="..\..\yoga\YGNodeList.c" />
|
<ClCompile Include="..\..\yoga\YGEnums.cpp" />
|
||||||
|
<ClCompile Include="..\..\yoga\YGFloatOptional.cpp" />
|
||||||
|
<ClCompile Include="..\..\yoga\YGLayout.cpp" />
|
||||||
|
<ClCompile Include="..\..\yoga\YGNode.cpp" />
|
||||||
|
<ClCompile Include="..\..\yoga\YGNodePrint.cpp" />
|
||||||
|
<ClCompile Include="..\..\yoga\YGStyle.cpp" />
|
||||||
|
<ClCompile Include="..\..\yoga\Yoga.cpp" />
|
||||||
<ClCompile Include="YGInterop.cpp" />
|
<ClCompile Include="YGInterop.cpp" />
|
||||||
<ClCompile Include="dllmain.cpp">
|
<ClCompile Include="dllmain.cpp">
|
||||||
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>
|
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>
|
||||||
|
@@ -21,19 +21,40 @@
|
|||||||
<ClInclude Include="targetver.h">
|
<ClInclude Include="targetver.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\yoga\Yoga.h">
|
<ClInclude Include="resource.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\yoga\Utils.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\yoga\YGEnums.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\yoga\YGFloatOptional.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\yoga\YGLayout.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\yoga\YGMacros.h">
|
<ClInclude Include="..\..\yoga\YGMacros.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\yoga\YGNodeList.h">
|
<ClInclude Include="..\..\yoga\YGNode.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="YGInterop.h">
|
<ClInclude Include="..\..\yoga\YGNodePrint.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="resource.h">
|
<ClInclude Include="..\..\yoga\YGStyle.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\yoga\Yoga.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\yoga\Yoga-internal.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\yoga\YGConfig.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@@ -44,15 +65,36 @@
|
|||||||
<ClCompile Include="dllmain.cpp">
|
<ClCompile Include="dllmain.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\yoga\Yoga.c">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\yoga\YGNodeList.c">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="YGInterop.cpp">
|
<ClCompile Include="YGInterop.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\yoga\Utils.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\yoga\YGEnums.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\yoga\YGFloatOptional.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\yoga\YGLayout.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\yoga\YGNode.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\yoga\YGNodePrint.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\yoga\YGStyle.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\yoga\Yoga.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\yoga\YGConfig.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ResourceCompile Include="Yoga.rc">
|
<ResourceCompile Include="Yoga.rc">
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
org.gradle.jvmargs=-Xmx1536M
|
org.gradle.jvmargs=-Xmx1536M
|
||||||
|
|
||||||
VERSION_NAME=1.7.1-SNAPSHOT
|
VERSION_NAME=1.8.1-SNAPSHOT
|
||||||
POM_URL=https://github.com/facebook/yoga
|
POM_URL=https://github.com/facebook/yoga
|
||||||
POM_SCM_URL=https://github.com/facebook/yoga.git
|
POM_SCM_URL=https://github.com/facebook/yoga.git
|
||||||
POM_SCM_CONNECTION=scm:git:https://github.com/facebook/yoga.git
|
POM_SCM_CONNECTION=scm:git:https://github.com/facebook/yoga.git
|
||||||
|
34
java/BUCK
34
java/BUCK
@@ -3,9 +3,9 @@
|
|||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
load("//:yoga_defs.bzl", "FBJNI_TARGET", "JNI_TARGET", "INFER_ANNOTATIONS_TARGET", "JSR_305_TARGET", "PROGRUARD_ANNOTATIONS_TARGET", "SOLOADER_TARGET", "JUNIT_TARGET", "FBJNI_JAVA_TARGET", "CXX_LIBRARY_WHITELIST", "ANDROID", "yoga_dep", "cxx_library", "java_library", "java_test", "java_binary")
|
load("//:yoga_defs.bzl", "FBJNI_TARGET", "JNI_TARGET", "INFER_ANNOTATIONS_TARGET", "JSR_305_TARGET", "PROGRUARD_ANNOTATIONS_TARGET", "SOLOADER_TARGET", "JUNIT_TARGET", "FBJNI_JAVA_TARGET", "CXX_LIBRARY_WHITELIST", "ANDROID", "yoga_dep", "yoga_cxx_library", "yoga_java_library", "yoga_java_test", "yoga_java_binary")
|
||||||
|
|
||||||
cxx_library(
|
yoga_cxx_library(
|
||||||
name = "jni",
|
name = "jni",
|
||||||
srcs = glob(["jni/*.cpp"]),
|
srcs = glob(["jni/*.cpp"]),
|
||||||
header_namespace = "",
|
header_namespace = "",
|
||||||
@@ -28,30 +28,7 @@ cxx_library(
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
cxx_library(
|
yoga_java_library(
|
||||||
name = "jniFastMath",
|
|
||||||
srcs = glob(["jni/*.cpp"]),
|
|
||||||
header_namespace = "",
|
|
||||||
compiler_flags = [
|
|
||||||
"-fno-omit-frame-pointer",
|
|
||||||
"-fexceptions",
|
|
||||||
"-fPIC",
|
|
||||||
"-Wall",
|
|
||||||
"-Werror",
|
|
||||||
"-O3",
|
|
||||||
"-std=c++11",
|
|
||||||
],
|
|
||||||
platforms = ANDROID,
|
|
||||||
soname = "libyogafastmath.$(ext)",
|
|
||||||
visibility = ["PUBLIC"],
|
|
||||||
deps = [
|
|
||||||
FBJNI_TARGET,
|
|
||||||
JNI_TARGET,
|
|
||||||
yoga_dep(":yogafastmath"),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
java_library(
|
|
||||||
name = "java",
|
name = "java",
|
||||||
srcs = glob(["com/facebook/yoga/*.java"]),
|
srcs = glob(["com/facebook/yoga/*.java"]),
|
||||||
required_for_source_only_abi = True,
|
required_for_source_only_abi = True,
|
||||||
@@ -63,7 +40,6 @@ java_library(
|
|||||||
visibility = ["PUBLIC"],
|
visibility = ["PUBLIC"],
|
||||||
deps = [
|
deps = [
|
||||||
":jni",
|
":jni",
|
||||||
":jniFastMath",
|
|
||||||
INFER_ANNOTATIONS_TARGET,
|
INFER_ANNOTATIONS_TARGET,
|
||||||
JSR_305_TARGET,
|
JSR_305_TARGET,
|
||||||
PROGRUARD_ANNOTATIONS_TARGET,
|
PROGRUARD_ANNOTATIONS_TARGET,
|
||||||
@@ -71,7 +47,7 @@ java_library(
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
java_test(
|
yoga_java_test(
|
||||||
name = "tests",
|
name = "tests",
|
||||||
srcs = glob(["tests/**/*.java"]),
|
srcs = glob(["tests/**/*.java"]),
|
||||||
cxx_library_whitelist = CXX_LIBRARY_WHITELIST,
|
cxx_library_whitelist = CXX_LIBRARY_WHITELIST,
|
||||||
@@ -83,7 +59,7 @@ java_test(
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
java_binary(
|
yoga_java_binary(
|
||||||
name = "yoga",
|
name = "yoga",
|
||||||
deps = [
|
deps = [
|
||||||
":java",
|
":java",
|
||||||
|
@@ -16,16 +16,12 @@ public class YogaConfig {
|
|||||||
public static int SPACING_TYPE = 1;
|
public static int SPACING_TYPE = 1;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
if (YogaConstants.shouldUseFastMath) {
|
|
||||||
SoLoader.loadLibrary("yogafastmath");
|
|
||||||
} else {
|
|
||||||
SoLoader.loadLibrary("yoga");
|
SoLoader.loadLibrary("yoga");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
long mNativePointer;
|
long mNativePointer;
|
||||||
private YogaLogger mLogger;
|
private YogaLogger mLogger;
|
||||||
private YogaNodeClonedFunction mNodeClonedFunction;
|
private YogaNodeCloneFunction mYogaNodeCloneFunction;
|
||||||
|
|
||||||
private native long jni_YGConfigNew();
|
private native long jni_YGConfigNew();
|
||||||
public YogaConfig() {
|
public YogaConfig() {
|
||||||
@@ -74,6 +70,19 @@ public class YogaConfig {
|
|||||||
jni_YGConfigSetUseLegacyStretchBehaviour(mNativePointer, useLegacyStretchBehaviour);
|
jni_YGConfigSetUseLegacyStretchBehaviour(mNativePointer, useLegacyStretchBehaviour);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private native void jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(
|
||||||
|
long nativePointer, boolean shouldDiffLayoutWithoutLegacyStretchBehaviour);
|
||||||
|
/**
|
||||||
|
* If this flag is set then yoga would diff the layout without legacy flag and would set a bool in
|
||||||
|
* YogaNode(mDoesLegacyStretchFlagAffectsLayout) with true if the layouts were different and false
|
||||||
|
* if not
|
||||||
|
*/
|
||||||
|
public void setShouldDiffLayoutWithoutLegacyStretchBehaviour(
|
||||||
|
boolean shouldDiffLayoutWithoutLegacyStretchBehaviour) {
|
||||||
|
jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(
|
||||||
|
mNativePointer, shouldDiffLayoutWithoutLegacyStretchBehaviour);
|
||||||
|
}
|
||||||
|
|
||||||
private native void jni_YGConfigSetLogger(long nativePointer, Object logger);
|
private native void jni_YGConfigSetLogger(long nativePointer, Object logger);
|
||||||
public void setLogger(YogaLogger logger) {
|
public void setLogger(YogaLogger logger) {
|
||||||
mLogger = logger;
|
mLogger = logger;
|
||||||
@@ -84,16 +93,15 @@ public class YogaConfig {
|
|||||||
return mLogger;
|
return mLogger;
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGConfigSetHasNodeClonedFunc(long nativePointer, boolean hasClonedFunc);
|
private native void jni_YGConfigSetHasCloneNodeFunc(long nativePointer, boolean hasClonedFunc);
|
||||||
|
|
||||||
public void setOnNodeCloned(YogaNodeClonedFunction nodeClonedFunction) {
|
public void setOnCloneNode(YogaNodeCloneFunction cloneYogaNodeFunction) {
|
||||||
mNodeClonedFunction = nodeClonedFunction;
|
mYogaNodeCloneFunction = cloneYogaNodeFunction;
|
||||||
jni_YGConfigSetHasNodeClonedFunc(mNativePointer, nodeClonedFunction != null);
|
jni_YGConfigSetHasCloneNodeFunc(mNativePointer, cloneYogaNodeFunction != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DoNotStrip
|
@DoNotStrip
|
||||||
public final void onNodeCloned(
|
private final YogaNode cloneNode(YogaNode oldNode, YogaNode parent, int childIndex) {
|
||||||
YogaNode oldNode, YogaNode newNode, YogaNode parent, int childIndex) {
|
return mYogaNodeCloneFunction.cloneNode(oldNode, parent, childIndex);
|
||||||
mNodeClonedFunction.onNodeCloned(oldNode, newNode, parent, childIndex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -18,8 +18,6 @@ public class YogaConstants {
|
|||||||
*/
|
*/
|
||||||
public static final float UNDEFINED = (float) (10E20);
|
public static final float UNDEFINED = (float) (10E20);
|
||||||
|
|
||||||
public static boolean shouldUseFastMath = false;
|
|
||||||
|
|
||||||
public static boolean isUndefined(float value) {
|
public static boolean isUndefined(float value) {
|
||||||
// Value of a float in the case of it being not defined is 10.1E20. Earlier it used to be NAN,
|
// Value of a float in the case of it being not defined is 10.1E20. Earlier it used to be NAN,
|
||||||
// the benefit of which
|
// the benefit of which
|
||||||
|
@@ -17,20 +17,16 @@ import javax.annotation.Nullable;
|
|||||||
public class YogaNode implements Cloneable {
|
public class YogaNode implements Cloneable {
|
||||||
|
|
||||||
static {
|
static {
|
||||||
if (YogaConstants.shouldUseFastMath) {
|
|
||||||
SoLoader.loadLibrary("yogafastmath");
|
|
||||||
} else {
|
|
||||||
SoLoader.loadLibrary("yoga");
|
SoLoader.loadLibrary("yoga");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get native instance count. Useful for testing only.
|
* Get native instance count. Useful for testing only.
|
||||||
*/
|
*/
|
||||||
static native int jni_YGNodeGetInstanceCount();
|
static native int jni_YGNodeGetInstanceCount();
|
||||||
|
|
||||||
private YogaNode mParent;
|
private YogaNode mOwner;
|
||||||
private List<YogaNode> mChildren;
|
@Nullable private List<YogaNode> mChildren;
|
||||||
private YogaMeasureFunction mMeasureFunction;
|
private YogaMeasureFunction mMeasureFunction;
|
||||||
private YogaBaselineFunction mBaselineFunction;
|
private YogaBaselineFunction mBaselineFunction;
|
||||||
private long mNativePointer;
|
private long mNativePointer;
|
||||||
@@ -82,6 +78,7 @@ public class YogaNode implements Cloneable {
|
|||||||
private int mLayoutDirection = 0;
|
private int mLayoutDirection = 0;
|
||||||
@DoNotStrip
|
@DoNotStrip
|
||||||
private boolean mHasNewLayout = true;
|
private boolean mHasNewLayout = true;
|
||||||
|
@DoNotStrip private boolean mDoesLegacyStretchFlagAffectsLayout = false;
|
||||||
|
|
||||||
private native long jni_YGNodeNew();
|
private native long jni_YGNodeNew();
|
||||||
public YogaNode() {
|
public YogaNode() {
|
||||||
@@ -136,6 +133,7 @@ public class YogaNode implements Cloneable {
|
|||||||
mMeasureFunction = null;
|
mMeasureFunction = null;
|
||||||
mBaselineFunction = null;
|
mBaselineFunction = null;
|
||||||
mData = null;
|
mData = null;
|
||||||
|
mDoesLegacyStretchFlagAffectsLayout = false;
|
||||||
|
|
||||||
jni_YGNodeReset(mNativePointer);
|
jni_YGNodeReset(mNativePointer);
|
||||||
}
|
}
|
||||||
@@ -145,12 +143,15 @@ public class YogaNode implements Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public YogaNode getChildAt(int i) {
|
public YogaNode getChildAt(int i) {
|
||||||
|
if (mChildren == null) {
|
||||||
|
throw new IllegalStateException("YogaNode does not have children");
|
||||||
|
}
|
||||||
return mChildren.get(i);
|
return mChildren.get(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeInsertChild(long nativePointer, long childPointer, int index);
|
private native void jni_YGNodeInsertChild(long nativePointer, long childPointer, int index);
|
||||||
public void addChildAt(YogaNode child, int i) {
|
public void addChildAt(YogaNode child, int i) {
|
||||||
if (child.mParent != null) {
|
if (child.mOwner != null) {
|
||||||
throw new IllegalStateException("Child already has a parent, it must be removed first.");
|
throw new IllegalStateException("Child already has a parent, it must be removed first.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,35 +159,91 @@ public class YogaNode implements Cloneable {
|
|||||||
mChildren = new ArrayList<>(4);
|
mChildren = new ArrayList<>(4);
|
||||||
}
|
}
|
||||||
mChildren.add(i, child);
|
mChildren.add(i, child);
|
||||||
child.mParent = this;
|
child.mOwner = this;
|
||||||
jni_YGNodeInsertChild(mNativePointer, child.mNativePointer, i);
|
jni_YGNodeInsertChild(mNativePointer, child.mNativePointer, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private native void jni_YGNodeInsertSharedChild(long nativePointer, long childPointer, int index);
|
||||||
|
|
||||||
|
public void addSharedChildAt(YogaNode child, int i) {
|
||||||
|
if (mChildren == null) {
|
||||||
|
mChildren = new ArrayList<>(4);
|
||||||
|
}
|
||||||
|
mChildren.add(i, child);
|
||||||
|
child.mOwner = null;
|
||||||
|
jni_YGNodeInsertSharedChild(mNativePointer, child.mNativePointer, i);
|
||||||
|
}
|
||||||
|
|
||||||
private native long jni_YGNodeClone(long nativePointer, Object newNode);
|
private native long jni_YGNodeClone(long nativePointer, Object newNode);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public YogaNode clone() throws CloneNotSupportedException {
|
public YogaNode clone() {
|
||||||
|
try {
|
||||||
YogaNode clonedYogaNode = (YogaNode) super.clone();
|
YogaNode clonedYogaNode = (YogaNode) super.clone();
|
||||||
long clonedNativePointer = jni_YGNodeClone(mNativePointer, clonedYogaNode);
|
long clonedNativePointer = jni_YGNodeClone(mNativePointer, clonedYogaNode);
|
||||||
clonedYogaNode.mNativePointer = clonedNativePointer;
|
clonedYogaNode.mNativePointer = clonedNativePointer;
|
||||||
|
clonedYogaNode.mOwner = null;
|
||||||
clonedYogaNode.mChildren =
|
clonedYogaNode.mChildren =
|
||||||
mChildren != null ? (List<YogaNode>) ((ArrayList) mChildren).clone() : null;
|
mChildren != null ? (List<YogaNode>) ((ArrayList) mChildren).clone() : null;
|
||||||
return clonedYogaNode;
|
return clonedYogaNode;
|
||||||
|
} catch (CloneNotSupportedException ex) {
|
||||||
|
// This class implements Cloneable, this should not happen
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public YogaNode cloneWithNewChildren() {
|
||||||
|
try {
|
||||||
|
YogaNode clonedYogaNode = (YogaNode) super.clone();
|
||||||
|
long clonedNativePointer = jni_YGNodeClone(mNativePointer, clonedYogaNode);
|
||||||
|
clonedYogaNode.mOwner = null;
|
||||||
|
clonedYogaNode.mNativePointer = clonedNativePointer;
|
||||||
|
clonedYogaNode.clearChildren();
|
||||||
|
return clonedYogaNode;
|
||||||
|
} catch (CloneNotSupportedException ex) {
|
||||||
|
// This class implements Cloneable, this should not happen
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private native void jni_YGNodeClearChildren(long nativePointer);
|
||||||
|
|
||||||
|
private void clearChildren() {
|
||||||
|
mChildren = null;
|
||||||
|
jni_YGNodeClearChildren(mNativePointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeRemoveChild(long nativePointer, long childPointer);
|
private native void jni_YGNodeRemoveChild(long nativePointer, long childPointer);
|
||||||
public YogaNode removeChildAt(int i) {
|
public YogaNode removeChildAt(int i) {
|
||||||
|
if (mChildren == null) {
|
||||||
|
throw new IllegalStateException(
|
||||||
|
"Trying to remove a child of a YogaNode that does not have children");
|
||||||
|
}
|
||||||
final YogaNode child = mChildren.remove(i);
|
final YogaNode child = mChildren.remove(i);
|
||||||
child.mParent = null;
|
child.mOwner = null;
|
||||||
jni_YGNodeRemoveChild(mNativePointer, child.mNativePointer);
|
jni_YGNodeRemoveChild(mNativePointer, child.mNativePointer);
|
||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns the {@link YogaNode} that owns this {@link YogaNode}.
|
||||||
|
* The owner is used to identify the YogaTree that a {@link YogaNode} belongs
|
||||||
|
* to.
|
||||||
|
* This method will return the parent of the {@link YogaNode} when the
|
||||||
|
* {@link YogaNode} only belongs to one YogaTree or null when the
|
||||||
|
* {@link YogaNode} is shared between two or more YogaTrees.
|
||||||
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public
|
public
|
||||||
|
YogaNode getOwner() {
|
||||||
|
return mOwner;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @deprecated Use #getOwner() instead. This will be removed in the next version. */
|
||||||
|
@Deprecated
|
||||||
|
@Nullable
|
||||||
YogaNode getParent() {
|
YogaNode getParent() {
|
||||||
return mParent;
|
return getOwner();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int indexOf(YogaNode child) {
|
public int indexOf(YogaNode child) {
|
||||||
@@ -573,6 +630,10 @@ public class YogaNode implements Cloneable {
|
|||||||
return mHeight;
|
return mHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getDoesLegacyStretchFlagAffectsLayout() {
|
||||||
|
return mDoesLegacyStretchFlagAffectsLayout;
|
||||||
|
}
|
||||||
|
|
||||||
public float getLayoutMargin(YogaEdge edge) {
|
public float getLayoutMargin(YogaEdge edge) {
|
||||||
switch (edge) {
|
switch (edge) {
|
||||||
case LEFT:
|
case LEFT:
|
||||||
@@ -691,4 +752,22 @@ public class YogaNode implements Cloneable {
|
|||||||
public void print() {
|
public void print() {
|
||||||
jni_YGNodePrint(mNativePointer);
|
jni_YGNodePrint(mNativePointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method replaces the child at childIndex position with the newNode received by parameter.
|
||||||
|
* This is different than calling removeChildAt and addChildAt because this method ONLY replaces
|
||||||
|
* the child in the mChildren datastructure. @DoNotStrip: called from JNI
|
||||||
|
*
|
||||||
|
* @return the nativePointer of the newNode {@linl YogaNode}
|
||||||
|
*/
|
||||||
|
@DoNotStrip
|
||||||
|
private final long replaceChild(YogaNode newNode, int childIndex) {
|
||||||
|
if (mChildren == null) {
|
||||||
|
throw new IllegalStateException("Cannot replace child. YogaNode does not have children");
|
||||||
|
}
|
||||||
|
mChildren.remove(childIndex);
|
||||||
|
mChildren.add(childIndex, newNode);
|
||||||
|
newNode.mOwner = this;
|
||||||
|
return newNode.mNativePointer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,8 +10,8 @@ package com.facebook.yoga;
|
|||||||
import com.facebook.proguard.annotations.DoNotStrip;
|
import com.facebook.proguard.annotations.DoNotStrip;
|
||||||
|
|
||||||
@DoNotStrip
|
@DoNotStrip
|
||||||
public interface YogaNodeClonedFunction {
|
public interface YogaNodeCloneFunction {
|
||||||
|
|
||||||
@DoNotStrip
|
@DoNotStrip
|
||||||
void onNodeCloned(YogaNode oldNode, YogaNode newNode, YogaNode parent, int childIndex);
|
YogaNode cloneNode(YogaNode oldNode, YogaNode parent, int childIndex);
|
||||||
}
|
}
|
@@ -42,7 +42,7 @@ static void YGTransferLayoutDirection(YGNodeRef node, alias_ref<jobject> javaNod
|
|||||||
javaNode->setFieldValue(layoutDirectionField, static_cast<jint>(YGNodeLayoutGetDirection(node)));
|
javaNode->setFieldValue(layoutDirectionField, static_cast<jint>(YGNodeLayoutGetDirection(node)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void YGTransferLayoutOutputsRecursive(YGNodeRef root) {
|
static void YGTransferLayoutOutputsRecursiveImpl(YGNodeRef root, bool transferAndResetNewLayoutFlag) {
|
||||||
if (root->getHasNewLayout()) {
|
if (root->getHasNewLayout()) {
|
||||||
if (auto obj = YGNodeJobject(root)->lockLocal()) {
|
if (auto obj = YGNodeJobject(root)->lockLocal()) {
|
||||||
static auto widthField = obj->getClass()->getField<jfloat>("mWidth");
|
static auto widthField = obj->getClass()->getField<jfloat>("mWidth");
|
||||||
@@ -67,6 +67,9 @@ static void YGTransferLayoutOutputsRecursive(YGNodeRef root) {
|
|||||||
|
|
||||||
static auto edgeSetFlagField = obj->getClass()->getField<jint>("mEdgeSetFlag");
|
static auto edgeSetFlagField = obj->getClass()->getField<jint>("mEdgeSetFlag");
|
||||||
static auto hasNewLayoutField = obj->getClass()->getField<jboolean>("mHasNewLayout");
|
static auto hasNewLayoutField = obj->getClass()->getField<jboolean>("mHasNewLayout");
|
||||||
|
static auto doesLegacyStretchBehaviour =
|
||||||
|
obj->getClass()->getField<jboolean>(
|
||||||
|
"mDoesLegacyStretchFlagAffectsLayout");
|
||||||
|
|
||||||
/* Those flags needs be in sync with YogaNode.java */
|
/* Those flags needs be in sync with YogaNode.java */
|
||||||
const int MARGIN = 1;
|
const int MARGIN = 1;
|
||||||
@@ -79,12 +82,19 @@ static void YGTransferLayoutOutputsRecursive(YGNodeRef root) {
|
|||||||
obj->setFieldValue(heightField, YGNodeLayoutGetHeight(root));
|
obj->setFieldValue(heightField, YGNodeLayoutGetHeight(root));
|
||||||
obj->setFieldValue(leftField, YGNodeLayoutGetLeft(root));
|
obj->setFieldValue(leftField, YGNodeLayoutGetLeft(root));
|
||||||
obj->setFieldValue(topField, YGNodeLayoutGetTop(root));
|
obj->setFieldValue(topField, YGNodeLayoutGetTop(root));
|
||||||
|
obj->setFieldValue<jboolean>(
|
||||||
|
doesLegacyStretchBehaviour,
|
||||||
|
YGNodeLayoutGetDidLegacyStretchFlagAffectLayout(root));
|
||||||
|
|
||||||
if ((hasEdgeSetFlag & MARGIN) == MARGIN) {
|
if ((hasEdgeSetFlag & MARGIN) == MARGIN) {
|
||||||
obj->setFieldValue(marginLeftField, YGNodeLayoutGetMargin(root, YGEdgeLeft));
|
obj->setFieldValue(
|
||||||
obj->setFieldValue(marginTopField, YGNodeLayoutGetMargin(root, YGEdgeTop));
|
marginLeftField, YGNodeLayoutGetMargin(root, YGEdgeLeft));
|
||||||
obj->setFieldValue(marginRightField, YGNodeLayoutGetMargin(root, YGEdgeRight));
|
obj->setFieldValue(
|
||||||
obj->setFieldValue(marginBottomField, YGNodeLayoutGetMargin(root, YGEdgeBottom));
|
marginTopField, YGNodeLayoutGetMargin(root, YGEdgeTop));
|
||||||
|
obj->setFieldValue(
|
||||||
|
marginRightField, YGNodeLayoutGetMargin(root, YGEdgeRight));
|
||||||
|
obj->setFieldValue(
|
||||||
|
marginBottomField, YGNodeLayoutGetMargin(root, YGEdgeBottom));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((hasEdgeSetFlag & PADDING) == PADDING) {
|
if ((hasEdgeSetFlag & PADDING) == PADDING) {
|
||||||
@@ -101,12 +111,14 @@ static void YGTransferLayoutOutputsRecursive(YGNodeRef root) {
|
|||||||
obj->setFieldValue(borderBottomField, YGNodeLayoutGetBorder(root, YGEdgeBottom));
|
obj->setFieldValue(borderBottomField, YGNodeLayoutGetBorder(root, YGEdgeBottom));
|
||||||
}
|
}
|
||||||
|
|
||||||
obj->setFieldValue<jboolean>(hasNewLayoutField, true);
|
|
||||||
YGTransferLayoutDirection(root, obj);
|
YGTransferLayoutDirection(root, obj);
|
||||||
|
if(transferAndResetNewLayoutFlag){
|
||||||
|
obj->setFieldValue<jboolean>(hasNewLayoutField, true);
|
||||||
root->setHasNewLayout(false);
|
root->setHasNewLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
for (uint32_t i = 0; i < YGNodeGetChildCount(root); i++) {
|
for (uint32_t i = 0; i < YGNodeGetChildCount(root); i++) {
|
||||||
YGTransferLayoutOutputsRecursive(YGNodeGetChild(root, i));
|
YGTransferLayoutOutputsRecursiveImpl(YGNodeGetChild(root, i), transferAndResetNewLayoutFlag);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
YGLog(root, YGLogLevelError, "Java YGNode was GCed during layout calculation\n");
|
YGLog(root, YGLogLevelError, "Java YGNode was GCed during layout calculation\n");
|
||||||
@@ -114,6 +126,14 @@ static void YGTransferLayoutOutputsRecursive(YGNodeRef root) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void YGTransferLayoutOutputsRecursive(YGNodeRef root) {
|
||||||
|
YGTransferLayoutOutputsRecursiveImpl(root, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void YGTransferLayoutOutputsRecursiveForBaseline(YGNodeRef root) {
|
||||||
|
YGTransferLayoutOutputsRecursiveImpl(root, false);
|
||||||
|
}
|
||||||
|
|
||||||
static void YGPrint(YGNodeRef node) {
|
static void YGPrint(YGNodeRef node) {
|
||||||
if (auto obj = YGNodeJobject(node)->lockLocal()) {
|
if (auto obj = YGNodeJobject(node)->lockLocal()) {
|
||||||
cout << obj->toString() << endl;
|
cout << obj->toString() << endl;
|
||||||
@@ -126,37 +146,56 @@ static float YGJNIBaselineFunc(YGNodeRef node, float width, float height) {
|
|||||||
if (auto obj = YGNodeJobject(node)->lockLocal()) {
|
if (auto obj = YGNodeJobject(node)->lockLocal()) {
|
||||||
static auto baselineFunc = findClassStatic("com/facebook/yoga/YogaNode")
|
static auto baselineFunc = findClassStatic("com/facebook/yoga/YogaNode")
|
||||||
->getMethod<jfloat(jfloat, jfloat)>("baseline");
|
->getMethod<jfloat(jfloat, jfloat)>("baseline");
|
||||||
|
YGTransferLayoutOutputsRecursiveForBaseline(node);
|
||||||
return baselineFunc(obj, width, height);
|
return baselineFunc(obj, width, height);
|
||||||
} else {
|
} else {
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void YGJNIOnNodeClonedFunc(
|
static inline YGNodeRef _jlong2YGNodeRef(jlong addr) {
|
||||||
|
return reinterpret_cast<YGNodeRef>(static_cast<intptr_t>(addr));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline YGConfigRef _jlong2YGConfigRef(jlong addr) {
|
||||||
|
return reinterpret_cast<YGConfigRef>(static_cast<intptr_t>(addr));
|
||||||
|
}
|
||||||
|
|
||||||
|
static YGNodeRef YGJNIOnNodeClonedFunc(
|
||||||
YGNodeRef oldNode,
|
YGNodeRef oldNode,
|
||||||
YGNodeRef newNode,
|
YGNodeRef owner,
|
||||||
YGNodeRef parent,
|
|
||||||
int childIndex) {
|
int childIndex) {
|
||||||
auto config = oldNode->getConfig();
|
auto config = oldNode->getConfig();
|
||||||
if (!config) {
|
if (!config) {
|
||||||
return;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static auto onNodeClonedFunc = findClassStatic("com/facebook/yoga/YogaConfig")
|
static auto onNodeClonedFunc = findClassStatic("com/facebook/yoga/YogaConfig")
|
||||||
->getMethod<void(
|
->getMethod<alias_ref<JYogaNode>(
|
||||||
local_ref<JYogaNode>,
|
local_ref<JYogaNode>,
|
||||||
local_ref<JYogaNode>,
|
local_ref<JYogaNode>,
|
||||||
local_ref<JYogaNode>,
|
jint)>("cloneNode");
|
||||||
jint)>("onNodeCloned");
|
|
||||||
|
|
||||||
auto context = reinterpret_cast<YGConfigContext*>(YGConfigGetContext(config));
|
auto context = reinterpret_cast<YGConfigContext*>(YGConfigGetContext(config));
|
||||||
auto javaConfig = context->config;
|
auto javaConfig = context->config;
|
||||||
|
|
||||||
onNodeClonedFunc(
|
auto newNode = onNodeClonedFunc(
|
||||||
javaConfig->get(),
|
javaConfig->get(),
|
||||||
YGNodeJobject(oldNode)->lockLocal(),
|
YGNodeJobject(oldNode)->lockLocal(),
|
||||||
YGNodeJobject(newNode)->lockLocal(),
|
YGNodeJobject(owner)->lockLocal(),
|
||||||
YGNodeJobject(parent)->lockLocal(),
|
|
||||||
childIndex);
|
childIndex);
|
||||||
|
|
||||||
|
static auto replaceChild = findClassStatic("com/facebook/yoga/YogaNode")
|
||||||
|
->getMethod<jlong(
|
||||||
|
local_ref<JYogaNode>,
|
||||||
|
jint)>("replaceChild");
|
||||||
|
|
||||||
|
jlong newNodeNativePointer = replaceChild(
|
||||||
|
YGNodeJobject(owner)->lockLocal(),
|
||||||
|
newNode,
|
||||||
|
childIndex);
|
||||||
|
|
||||||
|
return _jlong2YGNodeRef(newNodeNativePointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static YGSize YGJNIMeasureFunc(
|
static YGSize YGJNIMeasureFunc(
|
||||||
@@ -224,14 +263,6 @@ static int YGJNILogFunc(const YGConfigRef config,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline YGNodeRef _jlong2YGNodeRef(jlong addr) {
|
|
||||||
return reinterpret_cast<YGNodeRef>(static_cast<intptr_t>(addr));
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline YGConfigRef _jlong2YGConfigRef(jlong addr) {
|
|
||||||
return reinterpret_cast<YGConfigRef>(static_cast<intptr_t>(addr));
|
|
||||||
}
|
|
||||||
|
|
||||||
jlong jni_YGNodeNew(alias_ref<jobject> thiz) {
|
jlong jni_YGNodeNew(alias_ref<jobject> thiz) {
|
||||||
const YGNodeRef node = YGNodeNew();
|
const YGNodeRef node = YGNodeNew();
|
||||||
node->setContext(new weak_ref<jobject>(make_weak(thiz)));
|
node->setContext(new weak_ref<jobject>(make_weak(thiz)));
|
||||||
@@ -264,6 +295,11 @@ void jni_YGNodeFree(alias_ref<jobject> thiz, jlong nativePointer) {
|
|||||||
YGNodeFree(node);
|
YGNodeFree(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void jni_YGNodeClearChildren(alias_ref<jobject> thiz, jlong nativePointer) {
|
||||||
|
const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
|
||||||
|
node->clearChildren();
|
||||||
|
}
|
||||||
|
|
||||||
void jni_YGNodeReset(alias_ref<jobject> thiz, jlong nativePointer) {
|
void jni_YGNodeReset(alias_ref<jobject> thiz, jlong nativePointer) {
|
||||||
const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
|
const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
|
||||||
void* context = node->getContext();
|
void* context = node->getContext();
|
||||||
@@ -283,6 +319,15 @@ void jni_YGNodeInsertChild(alias_ref<jobject>, jlong nativePointer, jlong childP
|
|||||||
YGNodeInsertChild(_jlong2YGNodeRef(nativePointer), _jlong2YGNodeRef(childPointer), index);
|
YGNodeInsertChild(_jlong2YGNodeRef(nativePointer), _jlong2YGNodeRef(childPointer), index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void jni_YGNodeInsertSharedChild(
|
||||||
|
alias_ref<jobject>,
|
||||||
|
jlong nativePointer,
|
||||||
|
jlong childPointer,
|
||||||
|
jint index) {
|
||||||
|
YGNodeInsertSharedChild(
|
||||||
|
_jlong2YGNodeRef(nativePointer), _jlong2YGNodeRef(childPointer), index);
|
||||||
|
}
|
||||||
|
|
||||||
void jni_YGNodeRemoveChild(alias_ref<jobject>, jlong nativePointer, jlong childPointer) {
|
void jni_YGNodeRemoveChild(alias_ref<jobject>, jlong nativePointer, jlong childPointer) {
|
||||||
YGNodeRemoveChild(_jlong2YGNodeRef(nativePointer), _jlong2YGNodeRef(childPointer));
|
YGNodeRemoveChild(_jlong2YGNodeRef(nativePointer), _jlong2YGNodeRef(childPointer));
|
||||||
}
|
}
|
||||||
@@ -467,6 +512,14 @@ void jni_YGConfigSetExperimentalFeatureEnabled(alias_ref<jobject>,
|
|||||||
enabled);
|
enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(
|
||||||
|
alias_ref<jobject>,
|
||||||
|
jlong nativePointer,
|
||||||
|
jboolean enabled) {
|
||||||
|
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
||||||
|
YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(config, enabled);
|
||||||
|
}
|
||||||
|
|
||||||
void jni_YGConfigSetUseWebDefaults(alias_ref<jobject>,
|
void jni_YGConfigSetUseWebDefaults(alias_ref<jobject>,
|
||||||
jlong nativePointer,
|
jlong nativePointer,
|
||||||
jboolean useWebDefaults) {
|
jboolean useWebDefaults) {
|
||||||
@@ -488,10 +541,10 @@ void jni_YGConfigSetUseLegacyStretchBehaviour(alias_ref<jobject>,
|
|||||||
YGConfigSetUseLegacyStretchBehaviour(config, useLegacyStretchBehaviour);
|
YGConfigSetUseLegacyStretchBehaviour(config, useLegacyStretchBehaviour);
|
||||||
}
|
}
|
||||||
|
|
||||||
void jni_YGConfigSetHasNodeClonedFunc(
|
void jni_YGConfigSetHasCloneNodeFunc(
|
||||||
alias_ref<jobject> thiz,
|
alias_ref<jobject> thiz,
|
||||||
jlong nativePointer,
|
jlong nativePointer,
|
||||||
jboolean hasNodeClonedFunc) {
|
jboolean hasCloneNodeFunc) {
|
||||||
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
||||||
auto context = reinterpret_cast<YGConfigContext*>(YGConfigGetContext(config));
|
auto context = reinterpret_cast<YGConfigContext*>(YGConfigGetContext(config));
|
||||||
if (context && context->config) {
|
if (context && context->config) {
|
||||||
@@ -499,15 +552,15 @@ void jni_YGConfigSetHasNodeClonedFunc(
|
|||||||
context->config = nullptr;
|
context->config = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasNodeClonedFunc) {
|
if (hasCloneNodeFunc) {
|
||||||
if (!context) {
|
if (!context) {
|
||||||
context = new YGConfigContext();
|
context = new YGConfigContext();
|
||||||
YGConfigSetContext(config, context);
|
YGConfigSetContext(config, context);
|
||||||
}
|
}
|
||||||
context->config = new global_ref<jobject>(make_global(thiz));
|
context->config = new global_ref<jobject>(make_global(thiz));
|
||||||
YGConfigSetNodeClonedFunc(config, YGJNIOnNodeClonedFunc);
|
YGConfigSetCloneNodeFunc(config, YGJNIOnNodeClonedFunc);
|
||||||
} else {
|
} else {
|
||||||
YGConfigSetNodeClonedFunc(config, nullptr);
|
YGConfigSetCloneNodeFunc(config, nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -549,7 +602,9 @@ jint JNI_OnLoad(JavaVM *vm, void *) {
|
|||||||
YGMakeNativeMethod(jni_YGNodeNewWithConfig),
|
YGMakeNativeMethod(jni_YGNodeNewWithConfig),
|
||||||
YGMakeNativeMethod(jni_YGNodeFree),
|
YGMakeNativeMethod(jni_YGNodeFree),
|
||||||
YGMakeNativeMethod(jni_YGNodeReset),
|
YGMakeNativeMethod(jni_YGNodeReset),
|
||||||
|
YGMakeNativeMethod(jni_YGNodeClearChildren),
|
||||||
YGMakeNativeMethod(jni_YGNodeInsertChild),
|
YGMakeNativeMethod(jni_YGNodeInsertChild),
|
||||||
|
YGMakeNativeMethod(jni_YGNodeInsertSharedChild),
|
||||||
YGMakeNativeMethod(jni_YGNodeRemoveChild),
|
YGMakeNativeMethod(jni_YGNodeRemoveChild),
|
||||||
YGMakeNativeMethod(jni_YGNodeCalculateLayout),
|
YGMakeNativeMethod(jni_YGNodeCalculateLayout),
|
||||||
YGMakeNativeMethod(jni_YGNodeMarkDirty),
|
YGMakeNativeMethod(jni_YGNodeMarkDirty),
|
||||||
@@ -624,7 +679,8 @@ jint JNI_OnLoad(JavaVM *vm, void *) {
|
|||||||
YGMakeNativeMethod(jni_YGNodePrint),
|
YGMakeNativeMethod(jni_YGNodePrint),
|
||||||
YGMakeNativeMethod(jni_YGNodeClone),
|
YGMakeNativeMethod(jni_YGNodeClone),
|
||||||
});
|
});
|
||||||
registerNatives("com/facebook/yoga/YogaConfig",
|
registerNatives(
|
||||||
|
"com/facebook/yoga/YogaConfig",
|
||||||
{
|
{
|
||||||
YGMakeNativeMethod(jni_YGConfigNew),
|
YGMakeNativeMethod(jni_YGConfigNew),
|
||||||
YGMakeNativeMethod(jni_YGConfigFree),
|
YGMakeNativeMethod(jni_YGConfigFree),
|
||||||
@@ -633,7 +689,9 @@ jint JNI_OnLoad(JavaVM *vm, void *) {
|
|||||||
YGMakeNativeMethod(jni_YGConfigSetPointScaleFactor),
|
YGMakeNativeMethod(jni_YGConfigSetPointScaleFactor),
|
||||||
YGMakeNativeMethod(jni_YGConfigSetUseLegacyStretchBehaviour),
|
YGMakeNativeMethod(jni_YGConfigSetUseLegacyStretchBehaviour),
|
||||||
YGMakeNativeMethod(jni_YGConfigSetLogger),
|
YGMakeNativeMethod(jni_YGConfigSetLogger),
|
||||||
YGMakeNativeMethod(jni_YGConfigSetHasNodeClonedFunc),
|
YGMakeNativeMethod(jni_YGConfigSetHasCloneNodeFunc),
|
||||||
|
YGMakeNativeMethod(
|
||||||
|
jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -3,9 +3,9 @@
|
|||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
load("//:yoga_defs.bzl", "YOGA_ROOTS", "java_library")
|
load("//:yoga_defs.bzl", "YOGA_ROOTS", "yoga_java_library")
|
||||||
|
|
||||||
java_library(
|
yoga_java_library(
|
||||||
name = "annotations",
|
name = "annotations",
|
||||||
srcs = glob(["*.java"]),
|
srcs = glob(["*.java"]),
|
||||||
source = "1.7",
|
source = "1.7",
|
||||||
|
@@ -8,7 +8,9 @@
|
|||||||
package com.facebook.yoga;
|
package com.facebook.yoga;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotSame;
|
import static org.junit.Assert.assertNotSame;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
@@ -109,21 +111,23 @@ public class YogaNodeTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMeasureFloatMax() {
|
public void testMeasureFloatBigNumber() {
|
||||||
final YogaNode node = new YogaNode();
|
final YogaNode node = new YogaNode();
|
||||||
node.setMeasureFunction(new YogaMeasureFunction() {
|
final float bigNumber = (float) 10E5;
|
||||||
|
node.setMeasureFunction(
|
||||||
|
new YogaMeasureFunction() {
|
||||||
public long measure(
|
public long measure(
|
||||||
YogaNode node,
|
YogaNode node,
|
||||||
float width,
|
float width,
|
||||||
YogaMeasureMode widthMode,
|
YogaMeasureMode widthMode,
|
||||||
float height,
|
float height,
|
||||||
YogaMeasureMode heightMode) {
|
YogaMeasureMode heightMode) {
|
||||||
return YogaMeasureOutput.make(Float.MAX_VALUE, Float.MAX_VALUE);
|
return YogaMeasureOutput.make(bigNumber, bigNumber);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
node.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
node.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||||
assertEquals(Float.MAX_VALUE, node.getLayoutWidth(), 0.01f);
|
assertEquals(bigNumber, node.getLayoutWidth(), 0.01f);
|
||||||
assertEquals(Float.MAX_VALUE, node.getLayoutHeight(), 0.01f);
|
assertEquals(bigNumber, node.getLayoutHeight(), 0.01f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -248,16 +252,58 @@ public class YogaNodeTest {
|
|||||||
assertEquals(1, clonedChild.getChildCount());
|
assertEquals(1, clonedChild.getChildCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCloneWithNewChildren() throws Exception {
|
||||||
|
YogaConfig config = new YogaConfig();
|
||||||
|
YogaNode root = new YogaNode(config);
|
||||||
|
YogaNode child = new YogaNode(config);
|
||||||
|
YogaNode grandChild = new YogaNode(config);
|
||||||
|
root.addChildAt(child, 0);
|
||||||
|
child.addChildAt(grandChild, 0);
|
||||||
|
child.setFlexDirection(YogaFlexDirection.ROW);
|
||||||
|
|
||||||
|
YogaNode clonedChild = child.cloneWithNewChildren();
|
||||||
|
|
||||||
|
assertNotSame(clonedChild, child);
|
||||||
|
assertEquals(YogaFlexDirection.ROW, clonedChild.getFlexDirection());
|
||||||
|
assertEquals(child.getFlexDirection(), clonedChild.getFlexDirection());
|
||||||
|
assertEquals(0, clonedChild.getChildCount());
|
||||||
|
assertEquals(1, child.getChildCount());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAddSharedChildCloneWithNewChildren() throws Exception {
|
||||||
|
YogaConfig config = new YogaConfig();
|
||||||
|
YogaNode root = new YogaNode(config);
|
||||||
|
YogaNode child = new YogaNode(config);
|
||||||
|
YogaNode grandChild = new YogaNode(config);
|
||||||
|
root.addChildAt(child, 0);
|
||||||
|
child.addChildAt(grandChild, 0);
|
||||||
|
child.setFlexDirection(YogaFlexDirection.ROW);
|
||||||
|
|
||||||
|
YogaNode clonedChild = child.cloneWithNewChildren();
|
||||||
|
|
||||||
|
assertNotSame(clonedChild, child);
|
||||||
|
assertEquals(YogaFlexDirection.ROW, clonedChild.getFlexDirection());
|
||||||
|
assertEquals(child.getFlexDirection(), clonedChild.getFlexDirection());
|
||||||
|
assertEquals(0, clonedChild.getChildCount());
|
||||||
|
assertEquals(1, child.getChildCount());
|
||||||
|
|
||||||
|
clonedChild.addSharedChildAt(grandChild, 0);
|
||||||
|
assertEquals(1, clonedChild.getChildCount());
|
||||||
|
assertNull(grandChild.getOwner());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCloneNodeListener() throws Exception {
|
public void testCloneNodeListener() throws Exception {
|
||||||
final AtomicBoolean onNodeClonedExecuted = new AtomicBoolean(false);
|
final AtomicBoolean onNodeClonedExecuted = new AtomicBoolean(false);
|
||||||
YogaConfig config = new YogaConfig();
|
YogaConfig config = new YogaConfig();
|
||||||
config.setOnNodeCloned(
|
config.setOnCloneNode(
|
||||||
new YogaNodeClonedFunction() {
|
new YogaNodeCloneFunction() {
|
||||||
@Override
|
@Override
|
||||||
public void onNodeCloned(
|
public YogaNode cloneNode(YogaNode oldNode, YogaNode owner, int childIndex) {
|
||||||
YogaNode oldNode, YogaNode newNode, YogaNode parent, int childIndex) {
|
|
||||||
onNodeClonedExecuted.set(true);
|
onNodeClonedExecuted.set(true);
|
||||||
|
return oldNode.clone();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
YogaNode root = new YogaNode(config);
|
YogaNode root = new YogaNode(config);
|
||||||
@@ -265,6 +311,7 @@ public class YogaNodeTest {
|
|||||||
root.setHeight(100f);
|
root.setHeight(100f);
|
||||||
YogaNode child0 = new YogaNode(config);
|
YogaNode child0 = new YogaNode(config);
|
||||||
root.addChildAt(child0, 0);
|
root.addChildAt(child0, 0);
|
||||||
|
child0.setWidth(50f);
|
||||||
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||||
|
|
||||||
// Force a clone to happen.
|
// Force a clone to happen.
|
||||||
@@ -273,20 +320,24 @@ public class YogaNodeTest {
|
|||||||
root2.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
root2.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||||
|
|
||||||
assertTrue(onNodeClonedExecuted.get());
|
assertTrue(onNodeClonedExecuted.get());
|
||||||
|
assertEquals(1, root2.getChildCount());
|
||||||
|
YogaNode clonedNode = root2.getChildAt(0);
|
||||||
|
assertNotSame(child0, clonedNode);
|
||||||
|
assertEquals(child0.getWidth(), clonedNode.getWidth());
|
||||||
|
assertEquals(50f, clonedNode.getWidth().value, 0.01f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOnNodeClonedLeak() throws Exception {
|
public void testOnNodeClonedLeak() throws Exception {
|
||||||
YogaConfig config = new YogaConfig();
|
YogaConfig config = new YogaConfig();
|
||||||
config.setOnNodeCloned(
|
config.setOnCloneNode(
|
||||||
new YogaNodeClonedFunction() {
|
new YogaNodeCloneFunction() {
|
||||||
@Override
|
@Override
|
||||||
public void onNodeCloned(
|
public YogaNode cloneNode(YogaNode oldNode, YogaNode owner, int childIndex) {
|
||||||
YogaNode oldNode, YogaNode newNode, YogaNode parent, int childIndex) {
|
return oldNode.clone();
|
||||||
// Do nothing
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
config.setOnNodeCloned(null);
|
config.setOnCloneNode(null);
|
||||||
WeakReference<Object> ref = new WeakReference<Object>(config);
|
WeakReference<Object> ref = new WeakReference<Object>(config);
|
||||||
// noinspection UnusedAssignment
|
// noinspection UnusedAssignment
|
||||||
config = null;
|
config = null;
|
||||||
@@ -302,4 +353,27 @@ public class YogaNodeTest {
|
|||||||
}
|
}
|
||||||
fail("YogaConfig leaked");
|
fail("YogaConfig leaked");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFlagShouldDiffLayoutWithoutLegacyStretchBehaviour() throws Exception {
|
||||||
|
YogaConfig config = new YogaConfig();
|
||||||
|
config.setShouldDiffLayoutWithoutLegacyStretchBehaviour(true);
|
||||||
|
config.setUseLegacyStretchBehaviour(true);
|
||||||
|
YogaNode root = new YogaNode(config);
|
||||||
|
root.setWidth(500);
|
||||||
|
root.setHeight(500);
|
||||||
|
YogaNode root_child0 = new YogaNode(config);
|
||||||
|
root_child0.setAlignItems(YogaAlign.FLEX_START);
|
||||||
|
root.addChildAt(root_child0, 0);
|
||||||
|
YogaNode root_child0_child0 = new YogaNode(config);
|
||||||
|
root_child0_child0.setFlexGrow(1);
|
||||||
|
root_child0_child0.setFlexShrink(1);
|
||||||
|
root_child0.addChildAt(root_child0_child0, 0);
|
||||||
|
YogaNode root_child0_child0_child0 = new YogaNode(config);
|
||||||
|
root_child0_child0_child0.setFlexGrow(1);
|
||||||
|
root_child0_child0_child0.setFlexShrink(1);
|
||||||
|
root_child0_child0.addChildAt(root_child0_child0_child0, 0);
|
||||||
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||||
|
assertFalse(root.getDoesLegacyStretchFlagAffectsLayout());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -3,9 +3,9 @@
|
|||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
load("//:yoga_defs.bzl", "YOGA_ROOTS", "prebuilt_jar")
|
load("//:yoga_defs.bzl", "YOGA_ROOTS", "yoga_prebuilt_jar")
|
||||||
|
|
||||||
prebuilt_jar(
|
yoga_prebuilt_jar(
|
||||||
name = "android-support",
|
name = "android-support",
|
||||||
binary_jar = "android-support-v4.jar",
|
binary_jar = "android-support-v4.jar",
|
||||||
visibility = YOGA_ROOTS,
|
visibility = YOGA_ROOTS,
|
||||||
|
@@ -3,9 +3,9 @@
|
|||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
include_defs("//yoga_defs.bzl")
|
load("//:yoga_defs.bzl", "yoga_prebuilt_cxx_library", "yoga_cxx_library", "YOGA_ROOTS", "FBJNI_JAVA_TARGET", "JNI_TARGET", "ANDROID")
|
||||||
|
|
||||||
prebuilt_cxx_library(
|
yoga_prebuilt_cxx_library(
|
||||||
name = "ndklog",
|
name = "ndklog",
|
||||||
exported_platform_linker_flags = [
|
exported_platform_linker_flags = [
|
||||||
(
|
(
|
||||||
@@ -17,7 +17,7 @@ prebuilt_cxx_library(
|
|||||||
visibility = YOGA_ROOTS,
|
visibility = YOGA_ROOTS,
|
||||||
)
|
)
|
||||||
|
|
||||||
cxx_library(
|
yoga_cxx_library(
|
||||||
name = "fbjni",
|
name = "fbjni",
|
||||||
srcs = glob(["src/main/cpp/**/*.cpp"]),
|
srcs = glob(["src/main/cpp/**/*.cpp"]),
|
||||||
header_namespace = "",
|
header_namespace = "",
|
||||||
@@ -35,6 +35,7 @@ cxx_library(
|
|||||||
"-Wno-unused-parameter",
|
"-Wno-unused-parameter",
|
||||||
"-std=c++11",
|
"-std=c++11",
|
||||||
],
|
],
|
||||||
|
platforms = (ANDROID,),
|
||||||
visibility = ["PUBLIC"],
|
visibility = ["PUBLIC"],
|
||||||
deps = [
|
deps = [
|
||||||
":ndklog",
|
":ndklog",
|
||||||
|
@@ -3,9 +3,9 @@
|
|||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
load("//:yoga_defs.bzl", "PROGRUARD_ANNOTATIONS_TARGET", "SOLOADER_TARGET", "JSR_305_TARGET", "java_library")
|
load("//:yoga_defs.bzl", "PROGRUARD_ANNOTATIONS_TARGET", "SOLOADER_TARGET", "JSR_305_TARGET", "yoga_java_library")
|
||||||
|
|
||||||
java_library(
|
yoga_java_library(
|
||||||
name = "jni",
|
name = "jni",
|
||||||
srcs = glob(["**/*.java"]),
|
srcs = glob(["**/*.java"]),
|
||||||
proguard_config = "fbjni.pro",
|
proguard_config = "fbjni.pro",
|
||||||
|
@@ -3,14 +3,14 @@
|
|||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
load("//:yoga_defs.bzl", "cxx_library", "YOGA_ROOTS")
|
load("//:yoga_defs.bzl", "yoga_cxx_library", "YOGA_ROOTS")
|
||||||
|
|
||||||
COMPILER_FLAGS = [
|
COMPILER_FLAGS = [
|
||||||
"-std=c++11",
|
"-std=c++11",
|
||||||
"-Wno-missing-prototypes",
|
"-Wno-missing-prototypes",
|
||||||
]
|
]
|
||||||
|
|
||||||
cxx_library(
|
yoga_cxx_library(
|
||||||
name = "gtest",
|
name = "gtest",
|
||||||
srcs = glob(["googletest/googletest/src/*.cc"]),
|
srcs = glob(["googletest/googletest/src/*.cc"]),
|
||||||
header_namespace = "",
|
header_namespace = "",
|
||||||
|
@@ -3,14 +3,14 @@
|
|||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
load("//:yoga_defs.bzl", "YOGA_ROOTS", "prebuilt_jar", "java_library")
|
load("//:yoga_defs.bzl", "YOGA_ROOTS", "yoga_prebuilt_jar", "yoga_java_library")
|
||||||
|
|
||||||
prebuilt_jar(
|
yoga_prebuilt_jar(
|
||||||
name = "infer-annotations-jar",
|
name = "infer-annotations-jar",
|
||||||
binary_jar = "infer-annotations-1.4.jar",
|
binary_jar = "infer-annotations-1.4.jar",
|
||||||
)
|
)
|
||||||
|
|
||||||
java_library(
|
yoga_java_library(
|
||||||
name = "infer-annotations",
|
name = "infer-annotations",
|
||||||
exported_deps = [
|
exported_deps = [
|
||||||
":infer-annotations-jar",
|
":infer-annotations-jar",
|
||||||
|
@@ -3,9 +3,9 @@
|
|||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
load("//:yoga_defs.bzl", "cxx_library")
|
load("//:yoga_defs.bzl", "yoga_cxx_library")
|
||||||
|
|
||||||
cxx_library(
|
yoga_cxx_library(
|
||||||
name = "jni",
|
name = "jni",
|
||||||
header_namespace = "",
|
header_namespace = "",
|
||||||
exported_headers = [
|
exported_headers = [
|
||||||
|
@@ -3,14 +3,14 @@
|
|||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
load("//:yoga_defs.bzl", "YOGA_ROOTS", "prebuilt_jar", "java_library")
|
load("//:yoga_defs.bzl", "YOGA_ROOTS", "yoga_prebuilt_jar", "yoga_java_library")
|
||||||
|
|
||||||
prebuilt_jar(
|
yoga_prebuilt_jar(
|
||||||
name = "jsr305-jar",
|
name = "jsr305-jar",
|
||||||
binary_jar = "jsr305.jar",
|
binary_jar = "jsr305.jar",
|
||||||
)
|
)
|
||||||
|
|
||||||
java_library(
|
yoga_java_library(
|
||||||
name = "jsr-305",
|
name = "jsr-305",
|
||||||
exported_deps = [
|
exported_deps = [
|
||||||
":jsr305-jar",
|
":jsr305-jar",
|
||||||
|
@@ -3,14 +3,14 @@
|
|||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
load("//:yoga_defs.bzl", "YOGA_ROOTS", "prebuilt_jar", "java_library")
|
load("//:yoga_defs.bzl", "YOGA_ROOTS", "yoga_prebuilt_jar", "yoga_java_library")
|
||||||
|
|
||||||
prebuilt_jar(
|
yoga_prebuilt_jar(
|
||||||
name = "junit-jar",
|
name = "junit-jar",
|
||||||
binary_jar = "junit4.jar",
|
binary_jar = "junit4.jar",
|
||||||
)
|
)
|
||||||
|
|
||||||
java_library(
|
yoga_java_library(
|
||||||
name = "junit",
|
name = "junit",
|
||||||
exported_deps = [
|
exported_deps = [
|
||||||
":junit-jar",
|
":junit-jar",
|
||||||
|
@@ -1,7 +1,8 @@
|
|||||||
|
set -e
|
||||||
|
|
||||||
function download() {
|
function download() {
|
||||||
echo "Downloading '$1' to '$2' ..."
|
|
||||||
if hash curl 2>/dev/null; then
|
if hash curl 2>/dev/null; then
|
||||||
curl --retry 10 -L -o "$2" "$1"
|
curl -s -L -o "$2" "$1"
|
||||||
elif hash wget 2>/dev/null; then
|
elif hash wget 2>/dev/null; then
|
||||||
wget -O "$2" "$1"
|
wget -O "$2" "$1"
|
||||||
else
|
else
|
||||||
@@ -12,38 +13,38 @@ function download() {
|
|||||||
|
|
||||||
function installsdk() {
|
function installsdk() {
|
||||||
PROXY_ARGS=""
|
PROXY_ARGS=""
|
||||||
if [[ ! -z "$https_proxy" ]]; then
|
if [[ ! -z "$HTTPS_PROXY" ]]; then
|
||||||
PROXY_HOST="$(cut -d : "$https_proxy" -f 1,1)"
|
PROXY_HOST="$(echo $HTTPS_PROXY | cut -d : -f 1,1)"
|
||||||
PROXY_PORT="$(cut -d : "$https_proxy" -f 2,2)"
|
PROXY_PORT="$(echo $HTTPS_PROXY | cut -d : -f 2,2)"
|
||||||
PROXY_ARGS="--proxy=http --proxy_host=$PROXY_HOST --proxy_port=$PROXY_PORT"
|
PROXY_ARGS="--proxy=http --proxy_host=$PROXY_HOST --proxy_port=$PROXY_PORT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
yes | "$ANDROID_HOME/tools/bin/sdkmanager" $PROXY_ARGS $@
|
echo y | "$ANDROID_HOME"/tools/bin/sdkmanager $PROXY_ARGS "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
function installAndroidSDK {
|
function installAndroidSDK {
|
||||||
export ANDROID_HOME=$HOME/android-sdk
|
if [[ ! -d "$HOME/android-sdk" ]]; then
|
||||||
export ANDROID_NDK_REPOSITORY=$HOME/android-ndk
|
|
||||||
export PATH="$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$PATH"
|
|
||||||
|
|
||||||
if [[ ! -f "$ANDROID_HOME/tools/bin/sdkmanager" ]]; then
|
|
||||||
TMP=/tmp/sdk$$.zip
|
TMP=/tmp/sdk$$.zip
|
||||||
download 'https://dl.google.com/android/repository/sdk-tools-darwin-3859397.zip' $TMP
|
download 'https://dl.google.com/android/repository/tools_r25.2.3-linux.zip' $TMP
|
||||||
unzip -qod "$ANDROID_HOME" "$TMP"
|
unzip -qod "$HOME/android-sdk" $TMP
|
||||||
rm $TMP
|
rm $TMP
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
export ANDROID_NDK_REPOSITORY=$HOME/android-ndk
|
||||||
if [[ ! -d "$ANDROID_NDK_REPOSITORY/android-ndk-r15c" ]]; then
|
if [[ ! -d "$ANDROID_NDK_REPOSITORY/android-ndk-r15c" ]]; then
|
||||||
TMP=/tmp/ndk$$.zip
|
TMP=/tmp/ndk$$.zip
|
||||||
mkdir -p "$ANDROID_NDK_REPOSITORY"
|
mkdir -p "$ANDROID_NDK_REPOSITORY"
|
||||||
download 'https://dl.google.com/android/repository/android-ndk-r15c-darwin-x86_64.zip' $TMP
|
download 'https://dl.google.com/android/repository/android-ndk-r15c-linux-x86_64.zip' $TMP
|
||||||
unzip -qod "$ANDROID_NDK_REPOSITORY" "$TMP"
|
unzip -qod "$ANDROID_NDK_REPOSITORY" "$TMP"
|
||||||
rm $TMP
|
rm $TMP
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p "$ANDROID_HOME/licenses/"
|
export ANDROID_HOME=$HOME/android-sdk
|
||||||
echo > "$ANDROID_HOME/licenses/android-sdk-license"
|
export PATH="$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$PATH"
|
||||||
echo -n d56f5187479451eabf01fb78af6dfcb131a6481e >> "$ANDROID_HOME/licenses/android-sdk-license"
|
|
||||||
|
|
||||||
installsdk 'build-tools;26.0.2' 'platform-tools' 'platforms;android-23' 'platforms;android-25' 'extras;android;m2repository'
|
mkdir -p $ANDROID_HOME/licenses/
|
||||||
|
echo > $ANDROID_HOME/licenses/android-sdk-license
|
||||||
|
echo -n d56f5187479451eabf01fb78af6dfcb131a6481e > $ANDROID_HOME/licenses/android-sdk-license
|
||||||
|
|
||||||
|
installsdk 'build-tools;25.0.3' 'build-tools;26.0.2' 'platforms;android-25' 'platforms;android-26' 'ndk-bundle' 'extras;android;m2repository'
|
||||||
}
|
}
|
||||||
|
@@ -57,3 +57,26 @@ TEST(YogaTest, copy_style_modified_same) {
|
|||||||
YGNodeFree(node0);
|
YGNodeFree(node0);
|
||||||
YGNodeFree(node1);
|
YGNodeFree(node1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(YogaTest, initialise_flexShrink_flexGrow) {
|
||||||
|
const YGNodeRef node0 = YGNodeNew();
|
||||||
|
YGNodeStyleSetFlexShrink(node0, 1);
|
||||||
|
ASSERT_EQ(1, YGNodeStyleGetFlexShrink(node0));
|
||||||
|
|
||||||
|
YGNodeStyleSetFlexShrink(node0, YGUndefined);
|
||||||
|
YGNodeStyleSetFlexGrow(node0, 3);
|
||||||
|
ASSERT_EQ(
|
||||||
|
0,
|
||||||
|
YGNodeStyleGetFlexShrink(
|
||||||
|
node0)); // Default value is Zero, if flex shrink is not defined
|
||||||
|
ASSERT_EQ(3, YGNodeStyleGetFlexGrow(node0));
|
||||||
|
|
||||||
|
YGNodeStyleSetFlexGrow(node0, YGUndefined);
|
||||||
|
YGNodeStyleSetFlexShrink(node0, 3);
|
||||||
|
ASSERT_EQ(
|
||||||
|
0,
|
||||||
|
YGNodeStyleGetFlexGrow(
|
||||||
|
node0)); // Default value is Zero, if flex grow is not defined
|
||||||
|
ASSERT_EQ(3, YGNodeStyleGetFlexShrink(node0));
|
||||||
|
YGNodeFree(node0);
|
||||||
|
}
|
||||||
|
34
tests/YGTraversalTest.cpp
Normal file
34
tests/YGTraversalTest.cpp
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include <yoga/Yoga.h>
|
||||||
|
|
||||||
|
TEST(YogaTest, pre_order_traversal) {
|
||||||
|
YGNodeRef const root = YGNodeNew();
|
||||||
|
YGNodeRef const root_child0 = YGNodeNew();
|
||||||
|
YGNodeRef const root_child1 = YGNodeNew();
|
||||||
|
YGNodeRef const root_child0_child0 = YGNodeNew();
|
||||||
|
|
||||||
|
YGNodeSetChildren(root, {root_child0, root_child1});
|
||||||
|
YGNodeInsertChild(root_child0, root_child0_child0, 0);
|
||||||
|
|
||||||
|
std::vector<YGNodeRef> visited;
|
||||||
|
YGTraversePreOrder(root, [&visited](YGNodeRef node) {
|
||||||
|
visited.push_back(node);
|
||||||
|
});
|
||||||
|
|
||||||
|
const std::vector<YGNodeRef> expected = {
|
||||||
|
root,
|
||||||
|
root_child0,
|
||||||
|
root_child0_child0,
|
||||||
|
root_child1
|
||||||
|
};
|
||||||
|
ASSERT_EQ(visited, expected);
|
||||||
|
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
}
|
111
tests/YGTreeMutationTest.cpp
Normal file
111
tests/YGTreeMutationTest.cpp
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include <yoga/Yoga.h>
|
||||||
|
|
||||||
|
static std::vector<YGNodeRef> getChildren(YGNodeRef const node)
|
||||||
|
{
|
||||||
|
const uint32_t count = YGNodeGetChildCount(node);
|
||||||
|
std::vector<YGNodeRef> children;
|
||||||
|
children.reserve(count);
|
||||||
|
for (uint32_t i = 0 ; i < count ; i++) {
|
||||||
|
children.push_back(YGNodeGetChild(node, i));
|
||||||
|
}
|
||||||
|
return children;
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(YogaTest, set_children_adds_children_to_parent) {
|
||||||
|
YGNodeRef const root = YGNodeNew();
|
||||||
|
YGNodeRef const root_child0 = YGNodeNew();
|
||||||
|
YGNodeRef const root_child1 = YGNodeNew();
|
||||||
|
|
||||||
|
YGNodeSetChildren(root, {root_child0, root_child1});
|
||||||
|
|
||||||
|
const std::vector<YGNodeRef> children = getChildren(root);
|
||||||
|
const std::vector<YGNodeRef> expectedChildren = {root_child0, root_child1};
|
||||||
|
ASSERT_EQ(children, expectedChildren);
|
||||||
|
|
||||||
|
const std::vector<YGNodeRef> owners = {YGNodeGetOwner(root_child0), YGNodeGetOwner(root_child1)};
|
||||||
|
const std::vector<YGNodeRef> expectedOwners = {root, root};
|
||||||
|
ASSERT_EQ(owners, expectedOwners);
|
||||||
|
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(YogaTest, set_children_to_empty_removes_old_children) {
|
||||||
|
YGNodeRef const root = YGNodeNew();
|
||||||
|
YGNodeRef const root_child0 = YGNodeNew();
|
||||||
|
YGNodeRef const root_child1 = YGNodeNew();
|
||||||
|
|
||||||
|
YGNodeSetChildren(root, {root_child0, root_child1});
|
||||||
|
YGNodeSetChildren(root, {});
|
||||||
|
|
||||||
|
const std::vector<YGNodeRef> children = getChildren(root);
|
||||||
|
const std::vector<YGNodeRef> expectedChildren = {};
|
||||||
|
ASSERT_EQ(children, expectedChildren);
|
||||||
|
|
||||||
|
const std::vector<YGNodeRef> owners = {YGNodeGetOwner(root_child0), YGNodeGetOwner(root_child1)};
|
||||||
|
const std::vector<YGNodeRef> expectedOwners = {nullptr, nullptr};
|
||||||
|
ASSERT_EQ(owners, expectedOwners);
|
||||||
|
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(YogaTest, set_children_replaces_non_common_children) {
|
||||||
|
YGNodeRef const root = YGNodeNew();
|
||||||
|
YGNodeRef const root_child0 = YGNodeNew();
|
||||||
|
YGNodeRef const root_child1 = YGNodeNew();
|
||||||
|
|
||||||
|
YGNodeSetChildren(root, {root_child0, root_child1});
|
||||||
|
|
||||||
|
YGNodeRef const root_child2 = YGNodeNew();
|
||||||
|
YGNodeRef const root_child3 = YGNodeNew();
|
||||||
|
|
||||||
|
YGNodeSetChildren(root, {root_child2, root_child3});
|
||||||
|
|
||||||
|
const std::vector<YGNodeRef> children = getChildren(root);
|
||||||
|
const std::vector<YGNodeRef> expectedChildren = {root_child2, root_child3};
|
||||||
|
ASSERT_EQ(children, expectedChildren);
|
||||||
|
|
||||||
|
const std::vector<YGNodeRef> owners = {YGNodeGetOwner(root_child0), YGNodeGetOwner(root_child1)};
|
||||||
|
const std::vector<YGNodeRef> expectedOwners = {nullptr, nullptr};
|
||||||
|
ASSERT_EQ(owners, expectedOwners);
|
||||||
|
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
YGNodeFree(root_child0);
|
||||||
|
YGNodeFree(root_child1);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(YogaTest, set_children_keeps_and_reorders_common_children) {
|
||||||
|
YGNodeRef const root = YGNodeNew();
|
||||||
|
YGNodeRef const root_child0 = YGNodeNew();
|
||||||
|
YGNodeRef const root_child1 = YGNodeNew();
|
||||||
|
YGNodeRef const root_child2 = YGNodeNew();
|
||||||
|
|
||||||
|
YGNodeSetChildren(root, {root_child0, root_child1, root_child2});
|
||||||
|
|
||||||
|
YGNodeRef const root_child3 = YGNodeNew();
|
||||||
|
|
||||||
|
YGNodeSetChildren(root, {root_child2, root_child1, root_child3});
|
||||||
|
|
||||||
|
const std::vector<YGNodeRef> children = getChildren(root);
|
||||||
|
const std::vector<YGNodeRef> expectedChildren = {root_child2, root_child1, root_child3};
|
||||||
|
ASSERT_EQ(children, expectedChildren);
|
||||||
|
|
||||||
|
const std::vector<YGNodeRef> owners = {
|
||||||
|
YGNodeGetOwner(root_child0),
|
||||||
|
YGNodeGetOwner(root_child1),
|
||||||
|
YGNodeGetOwner(root_child2),
|
||||||
|
YGNodeGetOwner(root_child3)
|
||||||
|
};
|
||||||
|
const std::vector<YGNodeRef> expectedOwners = {nullptr, root, root, root};
|
||||||
|
ASSERT_EQ(owners, expectedOwners);
|
||||||
|
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
YGNodeFree(root_child0);
|
||||||
|
}
|
@@ -18,10 +18,45 @@ dependencies {
|
|||||||
|
|
||||||
### Javascript
|
### Javascript
|
||||||
|
|
||||||
|
The JavaScript bindings for Yoga can be used from node.js and within the browser.
|
||||||
|
When using Yoga from node.js the native library is used, in browesers a pure JS
|
||||||
|
version is used (corss-compiled using [emscripten](http://kripken.github.io/emscripten-site/)).
|
||||||
|
|
||||||
```
|
```
|
||||||
$> yarn add yoga-layout
|
$> yarn add yoga-layout
|
||||||
```
|
```
|
||||||
|
|
||||||
|
This is an example on how to use Yoga in JavaScript, for a full API reference,
|
||||||
|
have a look at the [flow-type definitions](https://github.com/facebook/yoga/blob/master/javascript/sources/entry-common.js#L123).
|
||||||
|
|
||||||
|
```js
|
||||||
|
import yoga, {Node} from 'yoga-layout';
|
||||||
|
|
||||||
|
const root = Node.create();
|
||||||
|
root.setWidth(500);
|
||||||
|
root.setHeight(300);
|
||||||
|
root.setJustifyContent(yoga.JUSTIFY_CENTER);
|
||||||
|
|
||||||
|
const node1 = Node.create();
|
||||||
|
node1.setWidth(100);
|
||||||
|
node1.setHeight(100);
|
||||||
|
|
||||||
|
const node2 = Node.create();
|
||||||
|
node2.setWidth(100);
|
||||||
|
node2.setHeight(100);
|
||||||
|
|
||||||
|
root.insertChild(node1, 0);
|
||||||
|
root.insertChild(node2, 1);
|
||||||
|
|
||||||
|
root.calculateLayout(500, 300, yoga.DIRECTION_LTR);
|
||||||
|
console.log(root.getComputedLayout());
|
||||||
|
// {left: 0, top: 0, width: 500, height: 300}
|
||||||
|
console.log(node1.getComputedLayout());
|
||||||
|
// {left: 150, top: 0, width: 100, height: 100}
|
||||||
|
console.log(node2.getComputedLayout());
|
||||||
|
// {left: 250, top: 0, width: 100, height: 100}
|
||||||
|
```
|
||||||
|
|
||||||
### iOS
|
### iOS
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@@ -31,6 +31,6 @@
|
|||||||
"develop": "gatsby develop"
|
"develop": "gatsby develop"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"prettier": "^1.10.2"
|
"prettier": "1.12.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,10 +10,12 @@
|
|||||||
|
|
||||||
import React, {Component} from 'react';
|
import React, {Component} from 'react';
|
||||||
|
|
||||||
export default () => <svg viewBox="0 0 1133.9 1133.9">
|
export default () => (
|
||||||
|
<svg viewBox="0 0 1133.9 1133.9">
|
||||||
<g>
|
<g>
|
||||||
<path d="M 498.3 3.7 c 153.6 88.9 307.3 177.7 461.1 266.2 c 7.6 4.4 10.3 9.1 10.3 17.8 c -0.3 179.1 -0.2 358.3 0 537.4 c 0 8.1 -2.4 12.8 -9.7 17.1 c -154.5 88.9 -308.8 178.1 -462.9 267.5 c -9 5.2 -15.5 5.3 -24.6 0.1 c -153.9 -89.2 -307.9 -178 -462.1 -266.8 C 3 838.8 0 833.9 0 825.1 c 0.3 -179.1 0.2 -358.3 0 -537.4 c 0 -8.6 2.6 -13.6 10.2 -18 C 164.4 180.9 318.4 92 472.4 3 C 477 -1.5 494.3 -0.7 498.3 3.7 Z M 48.8 555.3 c 0 79.9 0.2 159.9 -0.2 239.8 c -0.1 10 3 15.6 11.7 20.6 c 137.2 78.8 274.2 157.8 411 237.3 c 9.9 5.7 17 5.7 26.8 0.1 c 137.5 -79.8 275.2 -159.2 412.9 -238.5 c 7.4 -4.3 10.5 -8.9 10.5 -17.8 c -0.3 -160.2 -0.3 -320.5 0 -480.7 c 0 -8.8 -2.8 -13.6 -10.3 -18 C 772.1 218 633.1 137.8 494.2 57.4 c -6.5 -3.8 -11.5 -4.5 -18.5 -0.5 C 336.8 137.4 197.9 217.7 58.8 297.7 c -7.7 4.4 -10.2 9.2 -10.2 17.9 C 48.9 395.5 48.8 475.4 48.8 555.3 Z" />
|
<path d="M 498.3 3.7 c 153.6 88.9 307.3 177.7 461.1 266.2 c 7.6 4.4 10.3 9.1 10.3 17.8 c -0.3 179.1 -0.2 358.3 0 537.4 c 0 8.1 -2.4 12.8 -9.7 17.1 c -154.5 88.9 -308.8 178.1 -462.9 267.5 c -9 5.2 -15.5 5.3 -24.6 0.1 c -153.9 -89.2 -307.9 -178 -462.1 -266.8 C 3 838.8 0 833.9 0 825.1 c 0.3 -179.1 0.2 -358.3 0 -537.4 c 0 -8.6 2.6 -13.6 10.2 -18 C 164.4 180.9 318.4 92 472.4 3 C 477 -1.5 494.3 -0.7 498.3 3.7 Z M 48.8 555.3 c 0 79.9 0.2 159.9 -0.2 239.8 c -0.1 10 3 15.6 11.7 20.6 c 137.2 78.8 274.2 157.8 411 237.3 c 9.9 5.7 17 5.7 26.8 0.1 c 137.5 -79.8 275.2 -159.2 412.9 -238.5 c 7.4 -4.3 10.5 -8.9 10.5 -17.8 c -0.3 -160.2 -0.3 -320.5 0 -480.7 c 0 -8.8 -2.8 -13.6 -10.3 -18 C 772.1 218 633.1 137.8 494.2 57.4 c -6.5 -3.8 -11.5 -4.5 -18.5 -0.5 C 336.8 137.4 197.9 217.7 58.8 297.7 c -7.7 4.4 -10.2 9.2 -10.2 17.9 C 48.9 395.5 48.8 475.4 48.8 555.3 Z" />
|
||||||
<path d="M 184.4 555.9 c 0 -33.3 -1 -66.7 0.3 -100 c 1.9 -48 24.1 -86 64.7 -110.9 c 54.8 -33.6 110.7 -65.5 167 -96.6 c 45.7 -25.2 92.9 -24.7 138.6 1 c 54.4 30.6 108.7 61.5 162.2 93.7 c 44 26.5 67.3 66.8 68 118.4 c 0.9 63.2 0.9 126.5 0 189.7 c -0.7 50.6 -23.4 90.7 -66.6 116.9 c -55 33.4 -110.8 65.4 -167.1 96.5 c -43.4 24 -89 24.2 -132.3 0.5 c -57.5 -31.3 -114.2 -64 -170 -98.3 c -41 -25.1 -62.9 -63.7 -64.5 -112.2 C 183.5 621.9 184.3 588.9 184.4 555.9 Z M 232.9 556.3 c 0 29.5 0.5 59.1 -0.1 88.6 c -0.8 39.2 16.9 67.1 50.2 86.2 c 51.2 29.4 102.2 59.2 153.4 88.4 c 31.4 17.9 63.6 18.3 95 0.6 c 53.7 -30.3 107.1 -61.2 160.3 -92.5 c 29.7 -17.5 45 -44.5 45.3 -78.8 c 0.6 -61.7 0.5 -123.5 0 -185.2 c -0.3 -34.4 -15.3 -61.5 -44.9 -79 C 637.7 352.6 583 320.8 527.9 290 c -27.5 -15.4 -57.2 -16.1 -84.7 -0.7 c -56.9 31.6 -113.4 64 -169.1 97.6 c -26.4 15.9 -40.7 41.3 -41.1 72.9 C 232.6 491.9 232.9 524.1 232.9 556.3 Z" />
|
<path d="M 184.4 555.9 c 0 -33.3 -1 -66.7 0.3 -100 c 1.9 -48 24.1 -86 64.7 -110.9 c 54.8 -33.6 110.7 -65.5 167 -96.6 c 45.7 -25.2 92.9 -24.7 138.6 1 c 54.4 30.6 108.7 61.5 162.2 93.7 c 44 26.5 67.3 66.8 68 118.4 c 0.9 63.2 0.9 126.5 0 189.7 c -0.7 50.6 -23.4 90.7 -66.6 116.9 c -55 33.4 -110.8 65.4 -167.1 96.5 c -43.4 24 -89 24.2 -132.3 0.5 c -57.5 -31.3 -114.2 -64 -170 -98.3 c -41 -25.1 -62.9 -63.7 -64.5 -112.2 C 183.5 621.9 184.3 588.9 184.4 555.9 Z M 232.9 556.3 c 0 29.5 0.5 59.1 -0.1 88.6 c -0.8 39.2 16.9 67.1 50.2 86.2 c 51.2 29.4 102.2 59.2 153.4 88.4 c 31.4 17.9 63.6 18.3 95 0.6 c 53.7 -30.3 107.1 -61.2 160.3 -92.5 c 29.7 -17.5 45 -44.5 45.3 -78.8 c 0.6 -61.7 0.5 -123.5 0 -185.2 c -0.3 -34.4 -15.3 -61.5 -44.9 -79 C 637.7 352.6 583 320.8 527.9 290 c -27.5 -15.4 -57.2 -16.1 -84.7 -0.7 c -56.9 31.6 -113.4 64 -169.1 97.6 c -26.4 15.9 -40.7 41.3 -41.1 72.9 C 232.6 491.9 232.9 524.1 232.9 556.3 Z" />
|
||||||
<path d="M 484.9 424.4 c 69.8 -2.8 133.2 57.8 132.6 132 C 617 630 558.5 688.7 484.9 689.1 c -75.1 0.4 -132.6 -63.6 -132.7 -132.7 C 352.1 485 413.4 421.5 484.9 424.4 Z M 401.3 556.7 c -3.4 37.2 30.5 83.6 83 84.1 c 46.6 0.4 84.8 -37.6 84.9 -84 c 0.1 -46.6 -37.2 -84.4 -84.2 -84.6 C 432.2 472.1 397.9 518.3 401.3 556.7 Z" />
|
<path d="M 484.9 424.4 c 69.8 -2.8 133.2 57.8 132.6 132 C 617 630 558.5 688.7 484.9 689.1 c -75.1 0.4 -132.6 -63.6 -132.7 -132.7 C 352.1 485 413.4 421.5 484.9 424.4 Z M 401.3 556.7 c -3.4 37.2 30.5 83.6 83 84.1 c 46.6 0.4 84.8 -37.6 84.9 -84 c 0.1 -46.6 -37.2 -84.4 -84.2 -84.6 C 432.2 472.1 397.9 518.3 401.3 556.7 Z" />
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
|
);
|
||||||
|
@@ -46,7 +46,9 @@ function dipOrPercent(value) {
|
|||||||
console.log(value);
|
console.log(value);
|
||||||
return value === 'auto'
|
return value === 'auto'
|
||||||
? 'Auto'
|
? 'Auto'
|
||||||
: typeof value === 'string' && /%$/.test(value) ? 'Percent' : 'Dip';
|
: typeof value === 'string' && /%$/.test(value)
|
||||||
|
? 'Percent'
|
||||||
|
: 'Dip';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getValue(value) {
|
function getValue(value) {
|
||||||
|
@@ -49,7 +49,7 @@ export default class URLShortener extends Component<{}, State> {
|
|||||||
window.ga('send', {
|
window.ga('send', {
|
||||||
hitType: 'event',
|
hitType: 'event',
|
||||||
eventCategory: 'URLShortener',
|
eventCategory: 'URLShortener',
|
||||||
eventAction: 'created'
|
eventAction: 'created',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -6862,9 +6862,9 @@ preserve@^0.2.0:
|
|||||||
version "0.2.0"
|
version "0.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b"
|
resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b"
|
||||||
|
|
||||||
prettier@^1.10.2:
|
prettier@1.12.1:
|
||||||
version "1.10.2"
|
version "1.12.1"
|
||||||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.10.2.tgz#1af8356d1842276a99a5b5529c82dd9e9ad3cc93"
|
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.12.1.tgz#c1ad20e803e7749faf905a409d2367e06bbe7325"
|
||||||
|
|
||||||
pretty-bytes@^4.0.2:
|
pretty-bytes@^4.0.2:
|
||||||
version "4.0.2"
|
version "4.0.2"
|
||||||
|
@@ -49,3 +49,20 @@ bool YGFloatsEqual(const float a, const float b) {
|
|||||||
}
|
}
|
||||||
return YGFloatIsUndefined(a) && YGFloatIsUndefined(b);
|
return YGFloatIsUndefined(a) && YGFloatIsUndefined(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float YGFloatSanitize(const float& val) {
|
||||||
|
return YGFloatIsUndefined(val) ? 0 : val;
|
||||||
|
}
|
||||||
|
|
||||||
|
float YGUnwrapFloatOptional(const YGFloatOptional& op) {
|
||||||
|
return op.isUndefined() ? YGUndefined : op.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
YGFloatOptional YGFloatOptionalMax(
|
||||||
|
const YGFloatOptional& op1,
|
||||||
|
const YGFloatOptional& op2) {
|
||||||
|
if (!op1.isUndefined() && !op2.isUndefined()) {
|
||||||
|
return op1.getValue() > op2.getValue() ? op1 : op2;
|
||||||
|
}
|
||||||
|
return op1.isUndefined() ? op2 : op1;
|
||||||
|
}
|
||||||
|
34
yoga/Utils.h
34
yoga/Utils.h
@@ -40,12 +40,12 @@ struct YGCollectFlexItemsRowValues {
|
|||||||
float sizeConsumedOnCurrentLine;
|
float sizeConsumedOnCurrentLine;
|
||||||
float totalFlexGrowFactors;
|
float totalFlexGrowFactors;
|
||||||
float totalFlexShrinkScaledFactors;
|
float totalFlexShrinkScaledFactors;
|
||||||
float endOfLineIndex;
|
uint32_t endOfLineIndex;
|
||||||
std::vector<YGNodeRef> relativeChildren;
|
std::vector<YGNodeRef> relativeChildren;
|
||||||
float remainingFreeSpace;
|
float remainingFreeSpace;
|
||||||
// The size of the mainDim for the row after considering size, padding, margin
|
// The size of the mainDim for the row after considering size, padding, margin
|
||||||
// and border of flex items. This is used to calculate maxLineDim after going
|
// and border of flex items. This is used to calculate maxLineDim after going
|
||||||
// through all the rows to decide on the main axis size of parent.
|
// through all the rows to decide on the main axis size of owner.
|
||||||
float mainDim;
|
float mainDim;
|
||||||
// The size of the crossDim for the row after considering size, padding,
|
// The size of the crossDim for the row after considering size, padding,
|
||||||
// margin and border of flex items. Used for calculating containers crossSize.
|
// margin and border of flex items. Used for calculating containers crossSize.
|
||||||
@@ -65,6 +65,10 @@ bool YGFloatsEqual(const float a, const float b);
|
|||||||
// compiler flag.
|
// compiler flag.
|
||||||
float YGFloatMax(const float a, const float b);
|
float YGFloatMax(const float a, const float b);
|
||||||
|
|
||||||
|
YGFloatOptional YGFloatOptionalMax(
|
||||||
|
const YGFloatOptional& op1,
|
||||||
|
const YGFloatOptional& op2);
|
||||||
|
|
||||||
// We need custom min function, since we want that, if one argument is
|
// We need custom min function, since we want that, if one argument is
|
||||||
// YGUndefined then the min funtion should return the other argument as the min
|
// YGUndefined then the min funtion should return the other argument as the min
|
||||||
// value. We wouldn't have needed a custom min function if YGUndefined was NAN
|
// value. We wouldn't have needed a custom min function if YGUndefined was NAN
|
||||||
@@ -86,6 +90,14 @@ bool YGFloatArrayEqual(
|
|||||||
return areEqual;
|
return areEqual;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This function returns 0 if YGFloatIsUndefined(val) is true and val otherwise
|
||||||
|
float YGFloatSanitize(const float& val);
|
||||||
|
|
||||||
|
// This function unwraps optional and returns YGUndefined if not defined or
|
||||||
|
// op.value otherwise
|
||||||
|
// TODO: Get rid off this function
|
||||||
|
float YGUnwrapFloatOptional(const YGFloatOptional& op);
|
||||||
|
|
||||||
YGFlexDirection YGFlexDirectionCross(
|
YGFlexDirection YGFlexDirectionCross(
|
||||||
const YGFlexDirection flexDirection,
|
const YGFlexDirection flexDirection,
|
||||||
const YGDirection direction);
|
const YGDirection direction);
|
||||||
@@ -95,17 +107,18 @@ inline bool YGFlexDirectionIsRow(const YGFlexDirection flexDirection) {
|
|||||||
flexDirection == YGFlexDirectionRowReverse;
|
flexDirection == YGFlexDirectionRowReverse;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline float YGResolveValue(const YGValue value, const float parentSize) {
|
inline YGFloatOptional YGResolveValue(const YGValue value, const float ownerSize) {
|
||||||
switch (value.unit) {
|
switch (value.unit) {
|
||||||
case YGUnitUndefined:
|
case YGUnitUndefined:
|
||||||
case YGUnitAuto:
|
case YGUnitAuto:
|
||||||
return YGUndefined;
|
return YGFloatOptional();
|
||||||
case YGUnitPoint:
|
case YGUnitPoint:
|
||||||
return value.value;
|
return YGFloatOptional(value.value);
|
||||||
case YGUnitPercent:
|
case YGUnitPercent:
|
||||||
return value.value * parentSize * 0.01;
|
return YGFloatOptional(
|
||||||
|
static_cast<float>(value.value * ownerSize * 0.01));
|
||||||
}
|
}
|
||||||
return YGUndefined;
|
return YGFloatOptional();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool YGFlexDirectionIsColumn(const YGFlexDirection flexDirection) {
|
inline bool YGFlexDirectionIsColumn(const YGFlexDirection flexDirection) {
|
||||||
@@ -127,8 +140,9 @@ inline YGFlexDirection YGResolveFlexDirection(
|
|||||||
return flexDirection;
|
return flexDirection;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline float YGResolveValueMargin(
|
static inline YGFloatOptional YGResolveValueMargin(
|
||||||
const YGValue value,
|
const YGValue value,
|
||||||
const float parentSize) {
|
const float ownerSize) {
|
||||||
return value.unit == YGUnitAuto ? 0 : YGResolveValue(value, parentSize);
|
return value.unit == YGUnitAuto ? YGFloatOptional(0)
|
||||||
|
: YGResolveValue(value, ownerSize);
|
||||||
}
|
}
|
||||||
|
19
yoga/YGConfig.cpp
Normal file
19
yoga/YGConfig.cpp
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "YGConfig.h"
|
||||||
|
|
||||||
|
const std::array<bool, YGExperimentalFeatureCount>
|
||||||
|
kYGDefaultExperimentalFeatures = {{false}};
|
||||||
|
|
||||||
|
YGConfig::YGConfig(YGLogger logger)
|
||||||
|
: experimentalFeatures(kYGDefaultExperimentalFeatures),
|
||||||
|
useWebDefaults(false),
|
||||||
|
useLegacyStretchBehaviour(false),
|
||||||
|
shouldDiffLayoutWithoutLegacyStretchBehaviour(false),
|
||||||
|
pointScaleFactor(1.0f), logger(logger), cloneNodeCallback(nullptr),
|
||||||
|
context(nullptr) {}
|
23
yoga/YGConfig.h
Normal file
23
yoga/YGConfig.h
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "Yoga-internal.h"
|
||||||
|
#include "Yoga.h"
|
||||||
|
|
||||||
|
struct YGConfig {
|
||||||
|
std::array<bool, YGExperimentalFeatureCount> experimentalFeatures;
|
||||||
|
bool useWebDefaults;
|
||||||
|
bool useLegacyStretchBehaviour;
|
||||||
|
bool shouldDiffLayoutWithoutLegacyStretchBehaviour;
|
||||||
|
float pointScaleFactor;
|
||||||
|
YGLogger logger;
|
||||||
|
YGCloneNodeFunc cloneNodeCallback;
|
||||||
|
void* context;
|
||||||
|
|
||||||
|
YGConfig(YGLogger logger);
|
||||||
|
};
|
92
yoga/YGFloatOptional.cpp
Normal file
92
yoga/YGFloatOptional.cpp
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "YGFloatOptional.h"
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <iostream>
|
||||||
|
#include "Yoga.h"
|
||||||
|
|
||||||
|
YGFloatOptional::YGFloatOptional(const float& value) {
|
||||||
|
if (YGFloatIsUndefined(value)) {
|
||||||
|
isUndefined_ = true;
|
||||||
|
value_ = 0;
|
||||||
|
} else {
|
||||||
|
value_ = value;
|
||||||
|
isUndefined_ = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
YGFloatOptional::YGFloatOptional() : value_(0), isUndefined_(true) {}
|
||||||
|
|
||||||
|
const float& YGFloatOptional::getValue() const {
|
||||||
|
if (isUndefined_) {
|
||||||
|
// Abort, accessing a value of an undefined float optional
|
||||||
|
std::cerr << "Tried to get value of an undefined YGFloatOptional\n";
|
||||||
|
std::exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
return value_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void YGFloatOptional::setValue(const float& val) {
|
||||||
|
value_ = val;
|
||||||
|
isUndefined_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const bool& YGFloatOptional::isUndefined() const {
|
||||||
|
return isUndefined_;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool YGFloatOptional::operator==(const YGFloatOptional& op) const {
|
||||||
|
if (isUndefined_ == op.isUndefined()) {
|
||||||
|
return isUndefined_ ? true : value_ == op.getValue();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool YGFloatOptional::operator!=(const YGFloatOptional& op) const {
|
||||||
|
return !(*this == op);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool YGFloatOptional::operator==(const float& val) const {
|
||||||
|
if (YGFloatIsUndefined(val) == isUndefined_) {
|
||||||
|
return isUndefined_ ? true : val == value_;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool YGFloatOptional::operator!=(const float& val) const {
|
||||||
|
return !(*this == val);
|
||||||
|
}
|
||||||
|
|
||||||
|
YGFloatOptional YGFloatOptional::operator+(const YGFloatOptional& op) {
|
||||||
|
if (!isUndefined_ && !op.isUndefined_) {
|
||||||
|
return YGFloatOptional(value_ + op.value_);
|
||||||
|
}
|
||||||
|
return YGFloatOptional();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool YGFloatOptional::operator>(const YGFloatOptional& op) const {
|
||||||
|
if (isUndefined_ || op.isUndefined_) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return value_ > op.value_;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool YGFloatOptional::operator<(const YGFloatOptional& op) const {
|
||||||
|
if (isUndefined_ || op.isUndefined_) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return value_ < op.value_;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool YGFloatOptional::operator>=(const YGFloatOptional& op) const {
|
||||||
|
return *this == op ? true : *this > op;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool YGFloatOptional::operator<=(const YGFloatOptional& op) const {
|
||||||
|
return *this == op ? true : *this < op;
|
||||||
|
}
|
39
yoga/YGFloatOptional.h
Normal file
39
yoga/YGFloatOptional.h
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
struct YGFloatOptional {
|
||||||
|
private:
|
||||||
|
float value_;
|
||||||
|
bool isUndefined_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit YGFloatOptional(const float& value);
|
||||||
|
explicit YGFloatOptional();
|
||||||
|
|
||||||
|
// Program will terminate if the value of an undefined is accessed. Please
|
||||||
|
// make sure to check if the optional is defined before calling this function.
|
||||||
|
// To check if float optional is defined, use `isUndefined()`.
|
||||||
|
const float& getValue() const;
|
||||||
|
|
||||||
|
// Sets the value of float optional, and thus isUndefined is assigned false.
|
||||||
|
void setValue(const float& val);
|
||||||
|
|
||||||
|
const bool& isUndefined() const;
|
||||||
|
|
||||||
|
YGFloatOptional operator+(const YGFloatOptional& op);
|
||||||
|
bool operator>(const YGFloatOptional& op) const;
|
||||||
|
bool operator<(const YGFloatOptional& op) const;
|
||||||
|
bool operator>=(const YGFloatOptional& op) const;
|
||||||
|
bool operator<=(const YGFloatOptional& op) const;
|
||||||
|
bool operator==(const YGFloatOptional& op) const;
|
||||||
|
bool operator!=(const YGFloatOptional& op) const;
|
||||||
|
|
||||||
|
bool operator==(const float& val) const;
|
||||||
|
bool operator!=(const float& val) const;
|
||||||
|
};
|
@@ -19,10 +19,10 @@ YGLayout::YGLayout()
|
|||||||
padding(),
|
padding(),
|
||||||
direction(YGDirectionInherit),
|
direction(YGDirectionInherit),
|
||||||
computedFlexBasisGeneration(0),
|
computedFlexBasisGeneration(0),
|
||||||
computedFlexBasis(YGUndefined),
|
computedFlexBasis(YGFloatOptional()),
|
||||||
hadOverflow(false),
|
hadOverflow(false),
|
||||||
generationCount(0),
|
generationCount(0),
|
||||||
lastParentDirection((YGDirection)-1),
|
lastOwnerDirection((YGDirection)-1),
|
||||||
nextCachedMeasurementsIndex(0),
|
nextCachedMeasurementsIndex(0),
|
||||||
cachedMeasurements(),
|
cachedMeasurements(),
|
||||||
measuredDimensions(kYGDefaultDimensionValues),
|
measuredDimensions(kYGDefaultDimensionValues),
|
||||||
@@ -37,18 +37,15 @@ bool YGLayout::operator==(YGLayout layout) const {
|
|||||||
YGFloatArrayEqual(border, layout.border) &&
|
YGFloatArrayEqual(border, layout.border) &&
|
||||||
YGFloatArrayEqual(padding, layout.padding) &&
|
YGFloatArrayEqual(padding, layout.padding) &&
|
||||||
direction == layout.direction && hadOverflow == layout.hadOverflow &&
|
direction == layout.direction && hadOverflow == layout.hadOverflow &&
|
||||||
lastParentDirection == layout.lastParentDirection &&
|
lastOwnerDirection == layout.lastOwnerDirection &&
|
||||||
nextCachedMeasurementsIndex == layout.nextCachedMeasurementsIndex &&
|
nextCachedMeasurementsIndex == layout.nextCachedMeasurementsIndex &&
|
||||||
cachedLayout == layout.cachedLayout;
|
cachedLayout == layout.cachedLayout &&
|
||||||
|
computedFlexBasis == layout.computedFlexBasis;
|
||||||
|
|
||||||
for (uint32_t i = 0; i < YG_MAX_CACHED_RESULT_COUNT && isEqual; ++i) {
|
for (uint32_t i = 0; i < YG_MAX_CACHED_RESULT_COUNT && isEqual; ++i) {
|
||||||
isEqual = isEqual && cachedMeasurements[i] == layout.cachedMeasurements[i];
|
isEqual = isEqual && cachedMeasurements[i] == layout.cachedMeasurements[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!YGFloatIsUndefined(computedFlexBasis) ||
|
|
||||||
!YGFloatIsUndefined(layout.computedFlexBasis)) {
|
|
||||||
isEqual = isEqual && (computedFlexBasis == layout.computedFlexBasis);
|
|
||||||
}
|
|
||||||
if (!YGFloatIsUndefined(measuredDimensions[0]) ||
|
if (!YGFloatIsUndefined(measuredDimensions[0]) ||
|
||||||
!YGFloatIsUndefined(layout.measuredDimensions[0])) {
|
!YGFloatIsUndefined(layout.measuredDimensions[0])) {
|
||||||
isEqual =
|
isEqual =
|
||||||
|
@@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "YGFloatOptional.h"
|
||||||
#include "Yoga-internal.h"
|
#include "Yoga-internal.h"
|
||||||
|
|
||||||
struct YGLayout {
|
struct YGLayout {
|
||||||
@@ -17,13 +18,13 @@ struct YGLayout {
|
|||||||
YGDirection direction;
|
YGDirection direction;
|
||||||
|
|
||||||
uint32_t computedFlexBasisGeneration;
|
uint32_t computedFlexBasisGeneration;
|
||||||
float computedFlexBasis;
|
YGFloatOptional computedFlexBasis;
|
||||||
bool hadOverflow;
|
bool hadOverflow;
|
||||||
|
|
||||||
// Instead of recomputing the entire layout every single time, we
|
// Instead of recomputing the entire layout every single time, we
|
||||||
// cache some information to break early when nothing changed
|
// cache some information to break early when nothing changed
|
||||||
uint32_t generationCount;
|
uint32_t generationCount;
|
||||||
YGDirection lastParentDirection;
|
YGDirection lastOwnerDirection;
|
||||||
|
|
||||||
uint32_t nextCachedMeasurementsIndex;
|
uint32_t nextCachedMeasurementsIndex;
|
||||||
std::array<YGCachedMeasurement, YG_MAX_CACHED_RESULT_COUNT>
|
std::array<YGCachedMeasurement, YG_MAX_CACHED_RESULT_COUNT>
|
||||||
|
220
yoga/YGNode.cpp
220
yoga/YGNode.cpp
@@ -49,8 +49,8 @@ uint32_t YGNode::getLineIndex() const {
|
|||||||
return lineIndex_;
|
return lineIndex_;
|
||||||
}
|
}
|
||||||
|
|
||||||
YGNodeRef YGNode::getParent() const {
|
YGNodeRef YGNode::getOwner() const {
|
||||||
return parent_;
|
return owner_;
|
||||||
}
|
}
|
||||||
|
|
||||||
YGVector YGNode::getChildren() const {
|
YGVector YGNode::getChildren() const {
|
||||||
@@ -85,9 +85,9 @@ std::array<YGValue, 2> YGNode::getResolvedDimensions() const {
|
|||||||
return resolvedDimensions_;
|
return resolvedDimensions_;
|
||||||
}
|
}
|
||||||
|
|
||||||
float YGNode::getLeadingPosition(
|
YGFloatOptional YGNode::getLeadingPosition(
|
||||||
const YGFlexDirection axis,
|
const YGFlexDirection& axis,
|
||||||
const float axisSize) {
|
const float& axisSize) const {
|
||||||
if (YGFlexDirectionIsRow(axis)) {
|
if (YGFlexDirectionIsRow(axis)) {
|
||||||
const YGValue* leadingPosition =
|
const YGValue* leadingPosition =
|
||||||
YGComputedEdgeValue(style_.position, YGEdgeStart, &YGValueUndefined);
|
YGComputedEdgeValue(style_.position, YGEdgeStart, &YGValueUndefined);
|
||||||
@@ -100,13 +100,13 @@ float YGNode::getLeadingPosition(
|
|||||||
YGComputedEdgeValue(style_.position, leading[axis], &YGValueUndefined);
|
YGComputedEdgeValue(style_.position, leading[axis], &YGValueUndefined);
|
||||||
|
|
||||||
return leadingPosition->unit == YGUnitUndefined
|
return leadingPosition->unit == YGUnitUndefined
|
||||||
? 0.0f
|
? YGFloatOptional(0)
|
||||||
: YGResolveValue(*leadingPosition, axisSize);
|
: YGResolveValue(*leadingPosition, axisSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
float YGNode::getTrailingPosition(
|
YGFloatOptional YGNode::getTrailingPosition(
|
||||||
const YGFlexDirection axis,
|
const YGFlexDirection& axis,
|
||||||
const float axisSize) {
|
const float& axisSize) const {
|
||||||
if (YGFlexDirectionIsRow(axis)) {
|
if (YGFlexDirectionIsRow(axis)) {
|
||||||
const YGValue* trailingPosition =
|
const YGValue* trailingPosition =
|
||||||
YGComputedEdgeValue(style_.position, YGEdgeEnd, &YGValueUndefined);
|
YGComputedEdgeValue(style_.position, YGEdgeEnd, &YGValueUndefined);
|
||||||
@@ -119,11 +119,11 @@ float YGNode::getTrailingPosition(
|
|||||||
YGComputedEdgeValue(style_.position, trailing[axis], &YGValueUndefined);
|
YGComputedEdgeValue(style_.position, trailing[axis], &YGValueUndefined);
|
||||||
|
|
||||||
return trailingPosition->unit == YGUnitUndefined
|
return trailingPosition->unit == YGUnitUndefined
|
||||||
? 0.0f
|
? YGFloatOptional(0)
|
||||||
: YGResolveValue(*trailingPosition, axisSize);
|
: YGResolveValue(*trailingPosition, axisSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool YGNode::isLeadingPositionDefined(const YGFlexDirection axis) {
|
bool YGNode::isLeadingPositionDefined(const YGFlexDirection& axis) const {
|
||||||
return (YGFlexDirectionIsRow(axis) &&
|
return (YGFlexDirectionIsRow(axis) &&
|
||||||
YGComputedEdgeValue(style_.position, YGEdgeStart, &YGValueUndefined)
|
YGComputedEdgeValue(style_.position, YGEdgeStart, &YGValueUndefined)
|
||||||
->unit != YGUnitUndefined) ||
|
->unit != YGUnitUndefined) ||
|
||||||
@@ -131,7 +131,7 @@ bool YGNode::isLeadingPositionDefined(const YGFlexDirection axis) {
|
|||||||
->unit != YGUnitUndefined;
|
->unit != YGUnitUndefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool YGNode::isTrailingPosDefined(const YGFlexDirection axis) {
|
bool YGNode::isTrailingPosDefined(const YGFlexDirection& axis) const {
|
||||||
return (YGFlexDirectionIsRow(axis) &&
|
return (YGFlexDirectionIsRow(axis) &&
|
||||||
YGComputedEdgeValue(style_.position, YGEdgeEnd, &YGValueUndefined)
|
YGComputedEdgeValue(style_.position, YGEdgeEnd, &YGValueUndefined)
|
||||||
->unit != YGUnitUndefined) ||
|
->unit != YGUnitUndefined) ||
|
||||||
@@ -139,9 +139,9 @@ bool YGNode::isTrailingPosDefined(const YGFlexDirection axis) {
|
|||||||
->unit != YGUnitUndefined;
|
->unit != YGUnitUndefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
float YGNode::getLeadingMargin(
|
YGFloatOptional YGNode::getLeadingMargin(
|
||||||
const YGFlexDirection axis,
|
const YGFlexDirection& axis,
|
||||||
const float widthSize) {
|
const float& widthSize) const {
|
||||||
if (YGFlexDirectionIsRow(axis) &&
|
if (YGFlexDirectionIsRow(axis) &&
|
||||||
style_.margin[YGEdgeStart].unit != YGUnitUndefined) {
|
style_.margin[YGEdgeStart].unit != YGUnitUndefined) {
|
||||||
return YGResolveValueMargin(style_.margin[YGEdgeStart], widthSize);
|
return YGResolveValueMargin(style_.margin[YGEdgeStart], widthSize);
|
||||||
@@ -152,9 +152,9 @@ float YGNode::getLeadingMargin(
|
|||||||
widthSize);
|
widthSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
float YGNode::getTrailingMargin(
|
YGFloatOptional YGNode::getTrailingMargin(
|
||||||
const YGFlexDirection axis,
|
const YGFlexDirection& axis,
|
||||||
const float widthSize) {
|
const float& widthSize) const {
|
||||||
if (YGFlexDirectionIsRow(axis) &&
|
if (YGFlexDirectionIsRow(axis) &&
|
||||||
style_.margin[YGEdgeEnd].unit != YGUnitUndefined) {
|
style_.margin[YGEdgeEnd].unit != YGUnitUndefined) {
|
||||||
return YGResolveValueMargin(style_.margin[YGEdgeEnd], widthSize);
|
return YGResolveValueMargin(style_.margin[YGEdgeEnd], widthSize);
|
||||||
@@ -165,9 +165,9 @@ float YGNode::getTrailingMargin(
|
|||||||
widthSize);
|
widthSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
float YGNode::getMarginForAxis(
|
YGFloatOptional YGNode::getMarginForAxis(
|
||||||
const YGFlexDirection axis,
|
const YGFlexDirection& axis,
|
||||||
const float widthSize) {
|
const float& widthSize) const {
|
||||||
return getLeadingMargin(axis, widthSize) + getTrailingMargin(axis, widthSize);
|
return getLeadingMargin(axis, widthSize) + getTrailingMargin(axis, widthSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -225,11 +225,11 @@ void YGNode::setDirtiedFunc(YGDirtiedFunc dirtiedFunc) {
|
|||||||
dirtied_ = dirtiedFunc;
|
dirtied_ = dirtiedFunc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNode::setStyle(YGStyle style) {
|
void YGNode::setStyle(const YGStyle& style) {
|
||||||
style_ = style;
|
style_ = style;
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNode::setLayout(YGLayout layout) {
|
void YGNode::setLayout(const YGLayout& layout) {
|
||||||
layout_ = layout;
|
layout_ = layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,11 +237,11 @@ void YGNode::setLineIndex(uint32_t lineIndex) {
|
|||||||
lineIndex_ = lineIndex;
|
lineIndex_ = lineIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNode::setParent(YGNodeRef parent) {
|
void YGNode::setOwner(YGNodeRef owner) {
|
||||||
parent_ = parent;
|
owner_ = owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNode::setChildren(YGVector children) {
|
void YGNode::setChildren(const YGVector& children) {
|
||||||
children_ = children;
|
children_ = children;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,11 +305,12 @@ void YGNode::setLayoutPadding(float padding, int index) {
|
|||||||
layout_.padding[index] = padding;
|
layout_.padding[index] = padding;
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNode::setLayoutLastParentDirection(YGDirection direction) {
|
void YGNode::setLayoutLastOwnerDirection(YGDirection direction) {
|
||||||
layout_.lastParentDirection = direction;
|
layout_.lastOwnerDirection = direction;
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNode::setLayoutComputedFlexBasis(float computedFlexBasis) {
|
void YGNode::setLayoutComputedFlexBasis(
|
||||||
|
const YGFloatOptional& computedFlexBasis) {
|
||||||
layout_.computedFlexBasis = computedFlexBasis;
|
layout_.computedFlexBasis = computedFlexBasis;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -336,41 +337,54 @@ void YGNode::setLayoutDimension(float dimension, int index) {
|
|||||||
|
|
||||||
// If both left and right are defined, then use left. Otherwise return
|
// If both left and right are defined, then use left. Otherwise return
|
||||||
// +left or -right depending on which is defined.
|
// +left or -right depending on which is defined.
|
||||||
float YGNode::relativePosition(
|
YGFloatOptional YGNode::relativePosition(
|
||||||
const YGFlexDirection axis,
|
const YGFlexDirection& axis,
|
||||||
const float axisSize) {
|
const float& axisSize) const {
|
||||||
return isLeadingPositionDefined(axis) ? getLeadingPosition(axis, axisSize)
|
if (isLeadingPositionDefined(axis)) {
|
||||||
: -getTrailingPosition(axis, axisSize);
|
return getLeadingPosition(axis, axisSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
YGFloatOptional trailingPosition = getTrailingPosition(axis, axisSize);
|
||||||
|
if (!trailingPosition.isUndefined()) {
|
||||||
|
trailingPosition.setValue(-1 * trailingPosition.getValue());
|
||||||
|
}
|
||||||
|
return trailingPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNode::setPosition(
|
void YGNode::setPosition(
|
||||||
const YGDirection direction,
|
const YGDirection direction,
|
||||||
const float mainSize,
|
const float mainSize,
|
||||||
const float crossSize,
|
const float crossSize,
|
||||||
const float parentWidth) {
|
const float ownerWidth) {
|
||||||
/* Root nodes should be always layouted as LTR, so we don't return negative
|
/* Root nodes should be always layouted as LTR, so we don't return negative
|
||||||
* values. */
|
* values. */
|
||||||
const YGDirection directionRespectingRoot =
|
const YGDirection directionRespectingRoot =
|
||||||
parent_ != nullptr ? direction : YGDirectionLTR;
|
owner_ != nullptr ? direction : YGDirectionLTR;
|
||||||
const YGFlexDirection mainAxis =
|
const YGFlexDirection mainAxis =
|
||||||
YGResolveFlexDirection(style_.flexDirection, directionRespectingRoot);
|
YGResolveFlexDirection(style_.flexDirection, directionRespectingRoot);
|
||||||
const YGFlexDirection crossAxis =
|
const YGFlexDirection crossAxis =
|
||||||
YGFlexDirectionCross(mainAxis, directionRespectingRoot);
|
YGFlexDirectionCross(mainAxis, directionRespectingRoot);
|
||||||
|
|
||||||
const float relativePositionMain = relativePosition(mainAxis, mainSize);
|
const YGFloatOptional relativePositionMain =
|
||||||
const float relativePositionCross = relativePosition(crossAxis, crossSize);
|
relativePosition(mainAxis, mainSize);
|
||||||
|
const YGFloatOptional relativePositionCross =
|
||||||
|
relativePosition(crossAxis, crossSize);
|
||||||
|
|
||||||
setLayoutPosition(
|
setLayoutPosition(
|
||||||
getLeadingMargin(mainAxis, parentWidth) + relativePositionMain,
|
YGUnwrapFloatOptional(
|
||||||
|
getLeadingMargin(mainAxis, ownerWidth) + relativePositionMain),
|
||||||
leading[mainAxis]);
|
leading[mainAxis]);
|
||||||
setLayoutPosition(
|
setLayoutPosition(
|
||||||
getTrailingMargin(mainAxis, parentWidth) + relativePositionMain,
|
YGUnwrapFloatOptional(
|
||||||
|
getTrailingMargin(mainAxis, ownerWidth) + relativePositionMain),
|
||||||
trailing[mainAxis]);
|
trailing[mainAxis]);
|
||||||
setLayoutPosition(
|
setLayoutPosition(
|
||||||
getLeadingMargin(crossAxis, parentWidth) + relativePositionCross,
|
YGUnwrapFloatOptional(
|
||||||
|
getLeadingMargin(crossAxis, ownerWidth) + relativePositionCross),
|
||||||
leading[crossAxis]);
|
leading[crossAxis]);
|
||||||
setLayoutPosition(
|
setLayoutPosition(
|
||||||
getTrailingMargin(crossAxis, parentWidth) + relativePositionCross,
|
YGUnwrapFloatOptional(
|
||||||
|
getTrailingMargin(crossAxis, ownerWidth) + relativePositionCross),
|
||||||
trailing[crossAxis]);
|
trailing[crossAxis]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -385,7 +399,7 @@ YGNode::YGNode()
|
|||||||
style_(YGStyle()),
|
style_(YGStyle()),
|
||||||
layout_(YGLayout()),
|
layout_(YGLayout()),
|
||||||
lineIndex_(0),
|
lineIndex_(0),
|
||||||
parent_(nullptr),
|
owner_(nullptr),
|
||||||
children_(YGVector()),
|
children_(YGVector()),
|
||||||
nextChild_(nullptr),
|
nextChild_(nullptr),
|
||||||
config_(nullptr),
|
config_(nullptr),
|
||||||
@@ -403,7 +417,7 @@ YGNode::YGNode(const YGNode& node)
|
|||||||
style_(node.style_),
|
style_(node.style_),
|
||||||
layout_(node.layout_),
|
layout_(node.layout_),
|
||||||
lineIndex_(node.lineIndex_),
|
lineIndex_(node.lineIndex_),
|
||||||
parent_(node.parent_),
|
owner_(node.owner_),
|
||||||
children_(node.children_),
|
children_(node.children_),
|
||||||
nextChild_(node.nextChild_),
|
nextChild_(node.nextChild_),
|
||||||
config_(node.config_),
|
config_(node.config_),
|
||||||
@@ -423,10 +437,10 @@ YGNode::YGNode(
|
|||||||
YGBaselineFunc baseline,
|
YGBaselineFunc baseline,
|
||||||
YGDirtiedFunc dirtied,
|
YGDirtiedFunc dirtied,
|
||||||
YGStyle style,
|
YGStyle style,
|
||||||
YGLayout layout,
|
const YGLayout& layout,
|
||||||
uint32_t lineIndex,
|
uint32_t lineIndex,
|
||||||
YGNodeRef parent,
|
YGNodeRef owner,
|
||||||
YGVector children,
|
const YGVector& children,
|
||||||
YGNodeRef nextChild,
|
YGNodeRef nextChild,
|
||||||
YGConfigRef config,
|
YGConfigRef config,
|
||||||
bool isDirty,
|
bool isDirty,
|
||||||
@@ -441,7 +455,7 @@ YGNode::YGNode(
|
|||||||
style_(style),
|
style_(style),
|
||||||
layout_(layout),
|
layout_(layout),
|
||||||
lineIndex_(lineIndex),
|
lineIndex_(lineIndex),
|
||||||
parent_(parent),
|
owner_(owner),
|
||||||
children_(children),
|
children_(children),
|
||||||
nextChild_(nextChild),
|
nextChild_(nextChild),
|
||||||
config_(config),
|
config_(config),
|
||||||
@@ -467,7 +481,7 @@ YGNode& YGNode::operator=(const YGNode& node) {
|
|||||||
style_ = node.style_;
|
style_ = node.style_;
|
||||||
layout_ = node.layout_;
|
layout_ = node.layout_;
|
||||||
lineIndex_ = node.getLineIndex();
|
lineIndex_ = node.getLineIndex();
|
||||||
parent_ = node.getParent();
|
owner_ = node.getOwner();
|
||||||
children_ = node.getChildren();
|
children_ = node.getChildren();
|
||||||
nextChild_ = node.getNextChild();
|
nextChild_ = node.getNextChild();
|
||||||
config_ = node.getConfig();
|
config_ = node.getConfig();
|
||||||
@@ -500,7 +514,7 @@ YGValue YGNode::resolveFlexBasisPtr() const {
|
|||||||
if (flexBasis.unit != YGUnitAuto && flexBasis.unit != YGUnitUndefined) {
|
if (flexBasis.unit != YGUnitAuto && flexBasis.unit != YGUnitUndefined) {
|
||||||
return flexBasis;
|
return flexBasis;
|
||||||
}
|
}
|
||||||
if (!YGFloatIsUndefined(style_.flex) && style_.flex > 0.0f) {
|
if (!style_.flex.isUndefined() && style_.flex.getValue() > 0.0f) {
|
||||||
return config_->useWebDefaults ? YGValueAuto : YGValueZero;
|
return config_->useWebDefaults ? YGValueAuto : YGValueZero;
|
||||||
}
|
}
|
||||||
return YGValueAuto;
|
return YGValueAuto;
|
||||||
@@ -518,9 +532,9 @@ void YGNode::resolveDimension() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
YGDirection YGNode::resolveDirection(const YGDirection parentDirection) {
|
YGDirection YGNode::resolveDirection(const YGDirection ownerDirection) {
|
||||||
if (style_.direction == YGDirectionInherit) {
|
if (style_.direction == YGDirectionInherit) {
|
||||||
return parentDirection > YGDirectionInherit ? parentDirection
|
return ownerDirection > YGDirectionInherit ? ownerDirection
|
||||||
: YGDirectionLTR;
|
: YGDirectionLTR;
|
||||||
} else {
|
} else {
|
||||||
return style_.direction;
|
return style_.direction;
|
||||||
@@ -550,32 +564,35 @@ void YGNode::cloneChildrenIfNeeded() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const YGNodeRef firstChild = children_.front();
|
const YGNodeRef firstChild = children_.front();
|
||||||
if (firstChild->getParent() == this) {
|
if (firstChild->getOwner() == this) {
|
||||||
// If the first child has this node as its parent, we assume that it is
|
// If the first child has this node as its owner, we assume that it is
|
||||||
// already unique. We can do this because if we have it has a child, that
|
// already unique. We can do this because if we have it has a child, that
|
||||||
// means that its parent was at some point cloned which made that subtree
|
// means that its owner was at some point cloned which made that subtree
|
||||||
// immutable. We also assume that all its sibling are cloned as well.
|
// immutable. We also assume that all its sibling are cloned as well.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const YGNodeClonedFunc cloneNodeCallback = config_->cloneNodeCallback;
|
const YGCloneNodeFunc cloneNodeCallback = config_->cloneNodeCallback;
|
||||||
for (uint32_t i = 0; i < childCount; ++i) {
|
for (uint32_t i = 0; i < childCount; ++i) {
|
||||||
const YGNodeRef oldChild = children_[i];
|
const YGNodeRef oldChild = children_[i];
|
||||||
const YGNodeRef newChild = YGNodeClone(oldChild);
|
YGNodeRef newChild = nullptr;
|
||||||
replaceChild(newChild, i);
|
|
||||||
newChild->setParent(this);
|
|
||||||
if (cloneNodeCallback) {
|
if (cloneNodeCallback) {
|
||||||
cloneNodeCallback(oldChild, newChild, this, i);
|
newChild = cloneNodeCallback(oldChild, this, i);
|
||||||
}
|
}
|
||||||
|
if (newChild == nullptr) {
|
||||||
|
newChild = YGNodeClone(oldChild);
|
||||||
|
}
|
||||||
|
replaceChild(newChild, i);
|
||||||
|
newChild->setOwner(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNode::markDirtyAndPropogate() {
|
void YGNode::markDirtyAndPropogate() {
|
||||||
if (!isDirty_) {
|
if (!isDirty_) {
|
||||||
setDirty(true);
|
setDirty(true);
|
||||||
setLayoutComputedFlexBasis(YGUndefined);
|
setLayoutComputedFlexBasis(YGFloatOptional());
|
||||||
if (parent_) {
|
if (owner_) {
|
||||||
parent_->markDirtyAndPropogate();
|
owner_->markDirtyAndPropogate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -589,28 +606,28 @@ void YGNode::markDirtyAndPropogateDownwards() {
|
|||||||
|
|
||||||
float YGNode::resolveFlexGrow() {
|
float YGNode::resolveFlexGrow() {
|
||||||
// Root nodes flexGrow should always be 0
|
// Root nodes flexGrow should always be 0
|
||||||
if (parent_ == nullptr) {
|
if (owner_ == nullptr) {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
if (!YGFloatIsUndefined(style_.flexGrow)) {
|
if (!style_.flexGrow.isUndefined()) {
|
||||||
return style_.flexGrow;
|
return style_.flexGrow.getValue();
|
||||||
}
|
}
|
||||||
if (!YGFloatIsUndefined(style_.flex) && style_.flex > 0.0f) {
|
if (!style_.flex.isUndefined() && style_.flex.getValue() > 0.0f) {
|
||||||
return style_.flex;
|
return style_.flex.getValue();
|
||||||
}
|
}
|
||||||
return kDefaultFlexGrow;
|
return kDefaultFlexGrow;
|
||||||
}
|
}
|
||||||
|
|
||||||
float YGNode::resolveFlexShrink() {
|
float YGNode::resolveFlexShrink() {
|
||||||
if (parent_ == nullptr) {
|
if (owner_ == nullptr) {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
if (!YGFloatIsUndefined(style_.flexShrink)) {
|
if (!style_.flexShrink.isUndefined()) {
|
||||||
return style_.flexShrink;
|
return style_.flexShrink.getValue();
|
||||||
}
|
}
|
||||||
if (!config_->useWebDefaults && !YGFloatIsUndefined(style_.flex) &&
|
if (!config_->useWebDefaults && !style_.flex.isUndefined() &&
|
||||||
style_.flex < 0.0f) {
|
style_.flex.getValue() < 0.0f) {
|
||||||
return -style_.flex;
|
return -style_.flex.getValue();
|
||||||
}
|
}
|
||||||
return config_->useWebDefaults ? kWebDefaultFlexShrink : kDefaultFlexShrink;
|
return config_->useWebDefaults ? kWebDefaultFlexShrink : kDefaultFlexShrink;
|
||||||
}
|
}
|
||||||
@@ -621,7 +638,7 @@ bool YGNode::isNodeFlexible() {
|
|||||||
(resolveFlexGrow() != 0 || resolveFlexShrink() != 0));
|
(resolveFlexGrow() != 0 || resolveFlexShrink() != 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
float YGNode::getLeadingBorder(const YGFlexDirection axis) {
|
float YGNode::getLeadingBorder(const YGFlexDirection& axis) const {
|
||||||
if (YGFlexDirectionIsRow(axis) &&
|
if (YGFlexDirectionIsRow(axis) &&
|
||||||
style_.border[YGEdgeStart].unit != YGUnitUndefined &&
|
style_.border[YGEdgeStart].unit != YGUnitUndefined &&
|
||||||
!YGFloatIsUndefined(style_.border[YGEdgeStart].value) &&
|
!YGFloatIsUndefined(style_.border[YGEdgeStart].value) &&
|
||||||
@@ -634,7 +651,7 @@ float YGNode::getLeadingBorder(const YGFlexDirection axis) {
|
|||||||
return YGFloatMax(computedEdgeValue, 0.0f);
|
return YGFloatMax(computedEdgeValue, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
float YGNode::getTrailingBorder(const YGFlexDirection flexDirection) {
|
float YGNode::getTrailingBorder(const YGFlexDirection& flexDirection) const {
|
||||||
if (YGFlexDirectionIsRow(flexDirection) &&
|
if (YGFlexDirectionIsRow(flexDirection) &&
|
||||||
style_.border[YGEdgeEnd].unit != YGUnitUndefined &&
|
style_.border[YGEdgeEnd].unit != YGUnitUndefined &&
|
||||||
!YGFloatIsUndefined(style_.border[YGEdgeEnd].value) &&
|
!YGFloatIsUndefined(style_.border[YGEdgeEnd].value) &&
|
||||||
@@ -648,51 +665,52 @@ float YGNode::getTrailingBorder(const YGFlexDirection flexDirection) {
|
|||||||
return YGFloatMax(computedEdgeValue, 0.0f);
|
return YGFloatMax(computedEdgeValue, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
float YGNode::getLeadingPadding(
|
YGFloatOptional YGNode::getLeadingPadding(
|
||||||
const YGFlexDirection axis,
|
const YGFlexDirection& axis,
|
||||||
const float widthSize) {
|
const float& widthSize) const {
|
||||||
|
const YGFloatOptional& paddingEdgeStart =
|
||||||
|
YGResolveValue(style_.padding[YGEdgeStart], widthSize);
|
||||||
if (YGFlexDirectionIsRow(axis) &&
|
if (YGFlexDirectionIsRow(axis) &&
|
||||||
style_.padding[YGEdgeStart].unit != YGUnitUndefined &&
|
style_.padding[YGEdgeStart].unit != YGUnitUndefined &&
|
||||||
!YGFloatIsUndefined(
|
!paddingEdgeStart.isUndefined() && paddingEdgeStart.getValue() > 0.0f) {
|
||||||
YGResolveValue(style_.padding[YGEdgeStart], widthSize)) &&
|
return paddingEdgeStart;
|
||||||
YGResolveValue(style_.padding[YGEdgeStart], widthSize) > 0.0f) {
|
|
||||||
return YGResolveValue(style_.padding[YGEdgeStart], widthSize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float resolvedValue = YGResolveValue(
|
YGFloatOptional resolvedValue = YGResolveValue(
|
||||||
*YGComputedEdgeValue(style_.padding, leading[axis], &YGValueZero),
|
*YGComputedEdgeValue(style_.padding, leading[axis], &YGValueZero),
|
||||||
widthSize);
|
widthSize);
|
||||||
return YGFloatMax(resolvedValue, 0.0f);
|
return YGFloatOptionalMax(resolvedValue, YGFloatOptional(0.0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
float YGNode::getTrailingPadding(
|
YGFloatOptional YGNode::getTrailingPadding(
|
||||||
const YGFlexDirection axis,
|
const YGFlexDirection& axis,
|
||||||
const float widthSize) {
|
const float& widthSize) const {
|
||||||
if (YGFlexDirectionIsRow(axis) &&
|
if (YGFlexDirectionIsRow(axis) &&
|
||||||
style_.padding[YGEdgeEnd].unit != YGUnitUndefined &&
|
style_.padding[YGEdgeEnd].unit != YGUnitUndefined &&
|
||||||
!YGFloatIsUndefined(
|
!YGResolveValue(style_.padding[YGEdgeEnd], widthSize).isUndefined() &&
|
||||||
YGResolveValue(style_.padding[YGEdgeEnd], widthSize)) &&
|
YGResolveValue(style_.padding[YGEdgeEnd], widthSize).getValue() >= 0.0f) {
|
||||||
YGResolveValue(style_.padding[YGEdgeEnd], widthSize) >= 0.0f) {
|
|
||||||
return YGResolveValue(style_.padding[YGEdgeEnd], widthSize);
|
return YGResolveValue(style_.padding[YGEdgeEnd], widthSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
float resolvedValue = YGResolveValue(
|
YGFloatOptional resolvedValue = YGResolveValue(
|
||||||
*YGComputedEdgeValue(style_.padding, trailing[axis], &YGValueZero),
|
*YGComputedEdgeValue(style_.padding, trailing[axis], &YGValueZero),
|
||||||
widthSize);
|
widthSize);
|
||||||
|
|
||||||
return YGFloatMax(resolvedValue, 0.0f);
|
return YGFloatOptionalMax(resolvedValue, YGFloatOptional(0.0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
float YGNode::getLeadingPaddingAndBorder(
|
YGFloatOptional YGNode::getLeadingPaddingAndBorder(
|
||||||
const YGFlexDirection axis,
|
const YGFlexDirection& axis,
|
||||||
const float widthSize) {
|
const float& widthSize) const {
|
||||||
return getLeadingPadding(axis, widthSize) + getLeadingBorder(axis);
|
return getLeadingPadding(axis, widthSize) +
|
||||||
|
YGFloatOptional(getLeadingBorder(axis));
|
||||||
}
|
}
|
||||||
|
|
||||||
float YGNode::getTrailingPaddingAndBorder(
|
YGFloatOptional YGNode::getTrailingPaddingAndBorder(
|
||||||
const YGFlexDirection axis,
|
const YGFlexDirection& axis,
|
||||||
const float widthSize) {
|
const float& widthSize) const {
|
||||||
return getTrailingPadding(axis, widthSize) + getTrailingBorder(axis);
|
return getTrailingPadding(axis, widthSize) +
|
||||||
|
YGFloatOptional(getTrailingBorder(axis));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool YGNode::didUseLegacyFlag() {
|
bool YGNode::didUseLegacyFlag() {
|
||||||
|
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include "YGConfig.h"
|
||||||
#include "YGLayout.h"
|
#include "YGLayout.h"
|
||||||
#include "YGStyle.h"
|
#include "YGStyle.h"
|
||||||
#include "Yoga-internal.h"
|
#include "Yoga-internal.h"
|
||||||
@@ -23,14 +24,16 @@ struct YGNode {
|
|||||||
YGStyle style_;
|
YGStyle style_;
|
||||||
YGLayout layout_;
|
YGLayout layout_;
|
||||||
uint32_t lineIndex_;
|
uint32_t lineIndex_;
|
||||||
YGNodeRef parent_;
|
YGNodeRef owner_;
|
||||||
YGVector children_;
|
YGVector children_;
|
||||||
YGNodeRef nextChild_;
|
YGNodeRef nextChild_;
|
||||||
YGConfigRef config_;
|
YGConfigRef config_;
|
||||||
bool isDirty_;
|
bool isDirty_;
|
||||||
std::array<YGValue, 2> resolvedDimensions_;
|
std::array<YGValue, 2> resolvedDimensions_;
|
||||||
|
|
||||||
float relativePosition(const YGFlexDirection axis, const float axisSize);
|
YGFloatOptional relativePosition(
|
||||||
|
const YGFlexDirection& axis,
|
||||||
|
const float& axisSize) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
YGNode();
|
YGNode();
|
||||||
@@ -47,10 +50,10 @@ struct YGNode {
|
|||||||
YGBaselineFunc baseline,
|
YGBaselineFunc baseline,
|
||||||
YGDirtiedFunc dirtied,
|
YGDirtiedFunc dirtied,
|
||||||
YGStyle style,
|
YGStyle style,
|
||||||
YGLayout layout,
|
const YGLayout& layout,
|
||||||
uint32_t lineIndex,
|
uint32_t lineIndex,
|
||||||
YGNodeRef parent,
|
YGNodeRef owner,
|
||||||
YGVector children,
|
const YGVector& children,
|
||||||
YGNodeRef nextChild,
|
YGNodeRef nextChild,
|
||||||
YGConfigRef config,
|
YGConfigRef config,
|
||||||
bool isDirty,
|
bool isDirty,
|
||||||
@@ -69,7 +72,12 @@ struct YGNode {
|
|||||||
// For Performance reasons passing as reference.
|
// For Performance reasons passing as reference.
|
||||||
YGLayout& getLayout();
|
YGLayout& getLayout();
|
||||||
uint32_t getLineIndex() const;
|
uint32_t getLineIndex() const;
|
||||||
YGNodeRef getParent() const;
|
// returns the YGNodeRef that owns this YGNode. An owner is used to identify
|
||||||
|
// the YogaTree that a YGNode belongs to.
|
||||||
|
// This method will return the parent of the YGNode when a YGNode only belongs
|
||||||
|
// to one YogaTree or nullptr when the YGNode is shared between two or more
|
||||||
|
// YogaTrees.
|
||||||
|
YGNodeRef getOwner() const;
|
||||||
YGVector getChildren() const;
|
YGVector getChildren() const;
|
||||||
uint32_t getChildrenCount() const;
|
uint32_t getChildrenCount() const;
|
||||||
YGNodeRef getChild(uint32_t index) const;
|
YGNodeRef getChild(uint32_t index) const;
|
||||||
@@ -80,23 +88,36 @@ struct YGNode {
|
|||||||
YGValue getResolvedDimension(int index);
|
YGValue getResolvedDimension(int index);
|
||||||
|
|
||||||
// Methods related to positions, margin, padding and border
|
// Methods related to positions, margin, padding and border
|
||||||
float getLeadingPosition(const YGFlexDirection axis, const float axisSize);
|
YGFloatOptional getLeadingPosition(const YGFlexDirection& axis,
|
||||||
bool isLeadingPositionDefined(const YGFlexDirection axis);
|
const float& axisSize) const;
|
||||||
bool isTrailingPosDefined(const YGFlexDirection axis);
|
bool isLeadingPositionDefined(const YGFlexDirection& axis) const;
|
||||||
float getTrailingPosition(const YGFlexDirection axis, const float axisSize);
|
bool isTrailingPosDefined(const YGFlexDirection& axis) const;
|
||||||
float getLeadingMargin(const YGFlexDirection axis, const float widthSize);
|
YGFloatOptional getTrailingPosition(
|
||||||
float getTrailingMargin(const YGFlexDirection axis, const float widthSize);
|
const YGFlexDirection& axis,
|
||||||
float getLeadingBorder(const YGFlexDirection flexDirection);
|
const float& axisSize) const;
|
||||||
float getTrailingBorder(const YGFlexDirection flexDirection);
|
YGFloatOptional getLeadingMargin(
|
||||||
float getLeadingPadding(const YGFlexDirection axis, const float widthSize);
|
const YGFlexDirection& axis,
|
||||||
float getTrailingPadding(const YGFlexDirection axis, const float widthSize);
|
const float& widthSize) const;
|
||||||
float getLeadingPaddingAndBorder(
|
YGFloatOptional getTrailingMargin(
|
||||||
const YGFlexDirection axis,
|
const YGFlexDirection& axis,
|
||||||
const float widthSize);
|
const float& widthSize) const;
|
||||||
float getTrailingPaddingAndBorder(
|
float getLeadingBorder(const YGFlexDirection& flexDirection) const;
|
||||||
const YGFlexDirection axis,
|
float getTrailingBorder(const YGFlexDirection& flexDirection) const;
|
||||||
const float widthSize);
|
YGFloatOptional getLeadingPadding(
|
||||||
float getMarginForAxis(const YGFlexDirection axis, const float widthSize);
|
const YGFlexDirection& axis,
|
||||||
|
const float& widthSize) const;
|
||||||
|
YGFloatOptional getTrailingPadding(
|
||||||
|
const YGFlexDirection& axis,
|
||||||
|
const float& widthSize) const;
|
||||||
|
YGFloatOptional getLeadingPaddingAndBorder(
|
||||||
|
const YGFlexDirection& axis,
|
||||||
|
const float& widthSize) const;
|
||||||
|
YGFloatOptional getTrailingPaddingAndBorder(
|
||||||
|
const YGFlexDirection& axis,
|
||||||
|
const float& widthSize) const;
|
||||||
|
YGFloatOptional getMarginForAxis(
|
||||||
|
const YGFlexDirection& axis,
|
||||||
|
const float& widthSize) const;
|
||||||
// Setters
|
// Setters
|
||||||
|
|
||||||
void setContext(void* context);
|
void setContext(void* context);
|
||||||
@@ -106,18 +127,18 @@ struct YGNode {
|
|||||||
void setMeasureFunc(YGMeasureFunc measureFunc);
|
void setMeasureFunc(YGMeasureFunc measureFunc);
|
||||||
void setBaseLineFunc(YGBaselineFunc baseLineFunc);
|
void setBaseLineFunc(YGBaselineFunc baseLineFunc);
|
||||||
void setDirtiedFunc(YGDirtiedFunc dirtiedFunc);
|
void setDirtiedFunc(YGDirtiedFunc dirtiedFunc);
|
||||||
void setStyle(YGStyle style);
|
void setStyle(const YGStyle& style);
|
||||||
void setStyleFlexDirection(YGFlexDirection direction);
|
void setStyleFlexDirection(YGFlexDirection direction);
|
||||||
void setStyleAlignContent(YGAlign alignContent);
|
void setStyleAlignContent(YGAlign alignContent);
|
||||||
void setLayout(YGLayout layout);
|
void setLayout(const YGLayout& layout);
|
||||||
void setLineIndex(uint32_t lineIndex);
|
void setLineIndex(uint32_t lineIndex);
|
||||||
void setParent(YGNodeRef parent);
|
void setOwner(YGNodeRef owner);
|
||||||
void setChildren(YGVector children);
|
void setChildren(const YGVector& children);
|
||||||
void setNextChild(YGNodeRef nextChild);
|
void setNextChild(YGNodeRef nextChild);
|
||||||
void setConfig(YGConfigRef config);
|
void setConfig(YGConfigRef config);
|
||||||
void setDirty(bool isDirty);
|
void setDirty(bool isDirty);
|
||||||
void setLayoutLastParentDirection(YGDirection direction);
|
void setLayoutLastOwnerDirection(YGDirection direction);
|
||||||
void setLayoutComputedFlexBasis(float computedFlexBasis);
|
void setLayoutComputedFlexBasis(const YGFloatOptional& computedFlexBasis);
|
||||||
void setLayoutComputedFlexBasisGeneration(
|
void setLayoutComputedFlexBasisGeneration(
|
||||||
uint32_t computedFlexBasisGeneration);
|
uint32_t computedFlexBasisGeneration);
|
||||||
void setLayoutMeasuredDimension(float measuredDimension, int index);
|
void setLayoutMeasuredDimension(float measuredDimension, int index);
|
||||||
@@ -132,7 +153,7 @@ struct YGNode {
|
|||||||
const YGDirection direction,
|
const YGDirection direction,
|
||||||
const float mainSize,
|
const float mainSize,
|
||||||
const float crossSize,
|
const float crossSize,
|
||||||
const float parentWidth);
|
const float ownerWidth);
|
||||||
void setAndPropogateUseLegacyFlag(bool useLegacyFlag);
|
void setAndPropogateUseLegacyFlag(bool useLegacyFlag);
|
||||||
void setLayoutDoesLegacyFlagAffectsLayout(bool doesLegacyFlagAffectsLayout);
|
void setLayoutDoesLegacyFlagAffectsLayout(bool doesLegacyFlagAffectsLayout);
|
||||||
void setLayoutDidUseLegacyFlag(bool didUseLegacyFlag);
|
void setLayoutDidUseLegacyFlag(bool didUseLegacyFlag);
|
||||||
@@ -143,7 +164,7 @@ struct YGNode {
|
|||||||
YGValue marginTrailingValue(const YGFlexDirection axis) const;
|
YGValue marginTrailingValue(const YGFlexDirection axis) const;
|
||||||
YGValue resolveFlexBasisPtr() const;
|
YGValue resolveFlexBasisPtr() const;
|
||||||
void resolveDimension();
|
void resolveDimension();
|
||||||
YGDirection resolveDirection(const YGDirection parentDirection);
|
YGDirection resolveDirection(const YGDirection ownerDirection);
|
||||||
void clearChildren();
|
void clearChildren();
|
||||||
/// Replaces the occurrences of oldChild with newChild
|
/// Replaces the occurrences of oldChild with newChild
|
||||||
void replaceChild(YGNodeRef oldChild, YGNodeRef newChild);
|
void replaceChild(YGNodeRef oldChild, YGNodeRef newChild);
|
||||||
|
@@ -39,10 +39,12 @@ static void appendFormatedString(string* str, const char* fmt, ...) {
|
|||||||
str->append(result);
|
str->append(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void appendFloatOptionalIfDefined(
|
||||||
appendFloatIfNotUndefined(string* base, const string key, const float num) {
|
string* base,
|
||||||
if (!YGFloatIsUndefined(num)) {
|
const string key,
|
||||||
appendFormatedString(base, "%s: %g; ", key.c_str(), num);
|
const YGFloatOptional num) {
|
||||||
|
if (!num.isUndefined()) {
|
||||||
|
appendFormatedString(base, "%s: %g; ", key.c_str(), num.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,7 +72,10 @@ appendNumberIfNotAuto(string* base, const string& key, const YGValue number) {
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
appendNumberIfNotZero(string* base, const string& str, const YGValue number) {
|
appendNumberIfNotZero(string* base, const string& str, const YGValue number) {
|
||||||
if (!YGFloatsEqual(number.value, 0)) {
|
|
||||||
|
if (number.unit == YGUnitAuto) {
|
||||||
|
base->append(str + ": auto; ");
|
||||||
|
} else if (!YGFloatsEqual(number.value, 0)) {
|
||||||
appendNumberIfNotUndefined(base, str, number);
|
appendNumberIfNotUndefined(base, str, number);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -152,10 +157,11 @@ void YGNodeToString(
|
|||||||
appendFormatedString(
|
appendFormatedString(
|
||||||
str, "align-self: %s; ", YGAlignToString(node->getStyle().alignSelf));
|
str, "align-self: %s; ", YGAlignToString(node->getStyle().alignSelf));
|
||||||
}
|
}
|
||||||
appendFloatIfNotUndefined(str, "flex-grow", node->getStyle().flexGrow);
|
appendFloatOptionalIfDefined(str, "flex-grow", node->getStyle().flexGrow);
|
||||||
appendFloatIfNotUndefined(str, "flex-shrink", node->getStyle().flexShrink);
|
appendFloatOptionalIfDefined(
|
||||||
|
str, "flex-shrink", node->getStyle().flexShrink);
|
||||||
appendNumberIfNotAuto(str, "flex-basis", node->getStyle().flexBasis);
|
appendNumberIfNotAuto(str, "flex-basis", node->getStyle().flexBasis);
|
||||||
appendFloatIfNotUndefined(str, "flex", node->getStyle().flex);
|
appendFloatOptionalIfDefined(str, "flex", node->getStyle().flex);
|
||||||
|
|
||||||
if (node->getStyle().flexWrap != YGNode().getStyle().flexWrap) {
|
if (node->getStyle().flexWrap != YGNode().getStyle().flexWrap) {
|
||||||
appendFormatedString(
|
appendFormatedString(
|
||||||
|
@@ -7,9 +7,9 @@
|
|||||||
|
|
||||||
#include "YGStyle.h"
|
#include "YGStyle.h"
|
||||||
|
|
||||||
const YGValue kYGValueUndefined = {YGUndefined, YGUnitUndefined};
|
const YGValue kYGValueUndefined = {0, YGUnitUndefined};
|
||||||
|
|
||||||
const YGValue kYGValueAuto = {YGUndefined, YGUnitAuto};
|
const YGValue kYGValueAuto = {0, YGUnitAuto};
|
||||||
|
|
||||||
const std::array<YGValue, YGEdgeCount> kYGDefaultEdgeValuesUnit = {
|
const std::array<YGValue, YGEdgeCount> kYGDefaultEdgeValuesUnit = {
|
||||||
{kYGValueUndefined,
|
{kYGValueUndefined,
|
||||||
@@ -39,9 +39,9 @@ YGStyle::YGStyle()
|
|||||||
flexWrap(YGWrapNoWrap),
|
flexWrap(YGWrapNoWrap),
|
||||||
overflow(YGOverflowVisible),
|
overflow(YGOverflowVisible),
|
||||||
display(YGDisplayFlex),
|
display(YGDisplayFlex),
|
||||||
flex(YGUndefined),
|
flex(YGFloatOptional()),
|
||||||
flexGrow(YGUndefined),
|
flexGrow(YGFloatOptional()),
|
||||||
flexShrink(YGUndefined),
|
flexShrink(YGFloatOptional()),
|
||||||
flexBasis(kYGValueAuto),
|
flexBasis(kYGValueAuto),
|
||||||
margin(kYGDefaultEdgeValuesUnit),
|
margin(kYGDefaultEdgeValuesUnit),
|
||||||
position(kYGDefaultEdgeValuesUnit),
|
position(kYGDefaultEdgeValuesUnit),
|
||||||
@@ -50,7 +50,7 @@ YGStyle::YGStyle()
|
|||||||
dimensions(kYGDefaultDimensionValuesAutoUnit),
|
dimensions(kYGDefaultDimensionValuesAutoUnit),
|
||||||
minDimensions(kYGDefaultDimensionValuesUnit),
|
minDimensions(kYGDefaultDimensionValuesUnit),
|
||||||
maxDimensions(kYGDefaultDimensionValuesUnit),
|
maxDimensions(kYGDefaultDimensionValuesUnit),
|
||||||
aspectRatio(YGUndefined) {}
|
aspectRatio(YGFloatOptional()) {}
|
||||||
|
|
||||||
// Yoga specific properties, not compatible with flexbox specification
|
// Yoga specific properties, not compatible with flexbox specification
|
||||||
bool YGStyle::operator==(const YGStyle& style) {
|
bool YGStyle::operator==(const YGStyle& style) {
|
||||||
@@ -69,25 +69,31 @@ bool YGStyle::operator==(const YGStyle& style) {
|
|||||||
YGValueArrayEqual(minDimensions, style.minDimensions) &&
|
YGValueArrayEqual(minDimensions, style.minDimensions) &&
|
||||||
YGValueArrayEqual(maxDimensions, style.maxDimensions);
|
YGValueArrayEqual(maxDimensions, style.maxDimensions);
|
||||||
|
|
||||||
if (!(YGFloatIsUndefined(flex) && YGFloatIsUndefined(style.flex))) {
|
areNonFloatValuesEqual =
|
||||||
areNonFloatValuesEqual = areNonFloatValuesEqual && flex == style.flex;
|
areNonFloatValuesEqual && flex.isUndefined() == style.flex.isUndefined();
|
||||||
|
if (areNonFloatValuesEqual && !flex.isUndefined() &&
|
||||||
|
!style.flex.isUndefined()) {
|
||||||
|
areNonFloatValuesEqual =
|
||||||
|
areNonFloatValuesEqual && flex.getValue() == style.flex.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(YGFloatIsUndefined(flexGrow) && YGFloatIsUndefined(style.flexGrow))) {
|
areNonFloatValuesEqual = areNonFloatValuesEqual &&
|
||||||
areNonFloatValuesEqual =
|
flexGrow.isUndefined() == style.flexGrow.isUndefined();
|
||||||
areNonFloatValuesEqual && flexGrow == style.flexGrow;
|
if (areNonFloatValuesEqual && !flexGrow.isUndefined()) {
|
||||||
|
areNonFloatValuesEqual = areNonFloatValuesEqual &&
|
||||||
|
flexGrow.getValue() == style.flexGrow.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(YGFloatIsUndefined(flexShrink) &&
|
areNonFloatValuesEqual = areNonFloatValuesEqual &&
|
||||||
YGFloatIsUndefined(style.flexShrink))) {
|
flexShrink.isUndefined() == style.flexShrink.isUndefined();
|
||||||
areNonFloatValuesEqual =
|
if (areNonFloatValuesEqual && !style.flexShrink.isUndefined()) {
|
||||||
areNonFloatValuesEqual && flexShrink == style.flexShrink;
|
areNonFloatValuesEqual = areNonFloatValuesEqual &&
|
||||||
|
flexShrink.getValue() == style.flexShrink.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(YGFloatIsUndefined(aspectRatio) &&
|
if (!(aspectRatio.isUndefined() && style.aspectRatio.isUndefined())) {
|
||||||
YGFloatIsUndefined(style.aspectRatio))) {
|
areNonFloatValuesEqual = areNonFloatValuesEqual &&
|
||||||
areNonFloatValuesEqual =
|
aspectRatio.getValue() == style.aspectRatio.getValue();
|
||||||
areNonFloatValuesEqual && aspectRatio == style.aspectRatio;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return areNonFloatValuesEqual;
|
return areNonFloatValuesEqual;
|
||||||
|
@@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "YGFloatOptional.h"
|
||||||
#include "Yoga-internal.h"
|
#include "Yoga-internal.h"
|
||||||
#include "Yoga.h"
|
#include "Yoga.h"
|
||||||
|
|
||||||
@@ -20,9 +21,9 @@ struct YGStyle {
|
|||||||
YGWrap flexWrap;
|
YGWrap flexWrap;
|
||||||
YGOverflow overflow;
|
YGOverflow overflow;
|
||||||
YGDisplay display;
|
YGDisplay display;
|
||||||
float flex;
|
YGFloatOptional flex;
|
||||||
float flexGrow;
|
YGFloatOptional flexGrow;
|
||||||
float flexShrink;
|
YGFloatOptional flexShrink;
|
||||||
YGValue flexBasis;
|
YGValue flexBasis;
|
||||||
std::array<YGValue, YGEdgeCount> margin;
|
std::array<YGValue, YGEdgeCount> margin;
|
||||||
std::array<YGValue, YGEdgeCount> position;
|
std::array<YGValue, YGEdgeCount> position;
|
||||||
@@ -31,7 +32,7 @@ struct YGStyle {
|
|||||||
std::array<YGValue, 2> dimensions;
|
std::array<YGValue, 2> dimensions;
|
||||||
std::array<YGValue, 2> minDimensions;
|
std::array<YGValue, 2> minDimensions;
|
||||||
std::array<YGValue, 2> maxDimensions;
|
std::array<YGValue, 2> maxDimensions;
|
||||||
float aspectRatio;
|
YGFloatOptional aspectRatio;
|
||||||
|
|
||||||
YGStyle();
|
YGStyle();
|
||||||
// Yoga specific properties, not compatible with flexbox specification
|
// Yoga specific properties, not compatible with flexbox specification
|
||||||
|
@@ -87,16 +87,6 @@ struct YGCachedMeasurement {
|
|||||||
// layouts should not require more than 16 entries to fit within the cache.
|
// layouts should not require more than 16 entries to fit within the cache.
|
||||||
#define YG_MAX_CACHED_RESULT_COUNT 16
|
#define YG_MAX_CACHED_RESULT_COUNT 16
|
||||||
|
|
||||||
struct YGConfig {
|
|
||||||
bool experimentalFeatures[YGExperimentalFeatureCount + 1];
|
|
||||||
bool useWebDefaults;
|
|
||||||
bool useLegacyStretchBehaviour;
|
|
||||||
bool shouldDiffLayoutWithoutLegacyStretchBehaviour;
|
|
||||||
float pointScaleFactor;
|
|
||||||
YGLogger logger;
|
|
||||||
YGNodeClonedFunc cloneNodeCallback;
|
|
||||||
void* context;
|
|
||||||
};
|
|
||||||
|
|
||||||
static const float kDefaultFlexGrow = 0.0f;
|
static const float kDefaultFlexGrow = 0.0f;
|
||||||
static const float kDefaultFlexShrink = 0.0f;
|
static const float kDefaultFlexShrink = 0.0f;
|
||||||
|
1136
yoga/Yoga.cpp
1136
yoga/Yoga.cpp
File diff suppressed because it is too large
Load Diff
49
yoga/Yoga.h
49
yoga/Yoga.h
@@ -62,10 +62,8 @@ typedef int (*YGLogger)(const YGConfigRef config,
|
|||||||
YGLogLevel level,
|
YGLogLevel level,
|
||||||
const char *format,
|
const char *format,
|
||||||
va_list args);
|
va_list args);
|
||||||
typedef void (*YGNodeClonedFunc)(YGNodeRef oldNode,
|
typedef YGNodeRef (
|
||||||
YGNodeRef newNode,
|
*YGCloneNodeFunc)(YGNodeRef oldNode, YGNodeRef owner, int childIndex);
|
||||||
YGNodeRef parent,
|
|
||||||
int childIndex);
|
|
||||||
|
|
||||||
// YGNode
|
// YGNode
|
||||||
WIN_EXPORT YGNodeRef YGNodeNew(void);
|
WIN_EXPORT YGNodeRef YGNodeNew(void);
|
||||||
@@ -79,16 +77,31 @@ WIN_EXPORT int32_t YGNodeGetInstanceCount(void);
|
|||||||
WIN_EXPORT void YGNodeInsertChild(const YGNodeRef node,
|
WIN_EXPORT void YGNodeInsertChild(const YGNodeRef node,
|
||||||
const YGNodeRef child,
|
const YGNodeRef child,
|
||||||
const uint32_t index);
|
const uint32_t index);
|
||||||
|
|
||||||
|
// This function inserts the child YGNodeRef as a children of the node received
|
||||||
|
// by parameter and set the Owner of the child object to null. This function is
|
||||||
|
// expected to be called when using Yoga in persistent mode in order to share a
|
||||||
|
// YGNodeRef object as a child of two different Yoga trees. The child YGNodeRef
|
||||||
|
// is expected to be referenced from its original owner and from a clone of its
|
||||||
|
// original owner.
|
||||||
|
WIN_EXPORT void YGNodeInsertSharedChild(
|
||||||
|
const YGNodeRef node,
|
||||||
|
const YGNodeRef child,
|
||||||
|
const uint32_t index);
|
||||||
WIN_EXPORT void YGNodeRemoveChild(const YGNodeRef node, const YGNodeRef child);
|
WIN_EXPORT void YGNodeRemoveChild(const YGNodeRef node, const YGNodeRef child);
|
||||||
WIN_EXPORT void YGNodeRemoveAllChildren(const YGNodeRef node);
|
WIN_EXPORT void YGNodeRemoveAllChildren(const YGNodeRef node);
|
||||||
WIN_EXPORT YGNodeRef YGNodeGetChild(const YGNodeRef node, const uint32_t index);
|
WIN_EXPORT YGNodeRef YGNodeGetChild(const YGNodeRef node, const uint32_t index);
|
||||||
WIN_EXPORT YGNodeRef YGNodeGetParent(const YGNodeRef node);
|
WIN_EXPORT YGNodeRef YGNodeGetOwner(const YGNodeRef node);
|
||||||
WIN_EXPORT uint32_t YGNodeGetChildCount(const YGNodeRef node);
|
WIN_EXPORT uint32_t YGNodeGetChildCount(const YGNodeRef node);
|
||||||
|
WIN_EXPORT void YGNodeSetChildren(
|
||||||
|
YGNodeRef const owner,
|
||||||
|
const YGNodeRef children[],
|
||||||
|
const uint32_t count);
|
||||||
|
|
||||||
WIN_EXPORT void YGNodeCalculateLayout(const YGNodeRef node,
|
WIN_EXPORT void YGNodeCalculateLayout(const YGNodeRef node,
|
||||||
const float availableWidth,
|
const float availableWidth,
|
||||||
const float availableHeight,
|
const float availableHeight,
|
||||||
const YGDirection parentDirection);
|
const YGDirection ownerDirection);
|
||||||
|
|
||||||
// Mark a node as dirty. Only valid for nodes with a custom measure function
|
// Mark a node as dirty. Only valid for nodes with a custom measure function
|
||||||
// set.
|
// set.
|
||||||
@@ -190,7 +203,6 @@ YG_NODE_STYLE_PROPERTY(YGPositionType, PositionType, positionType);
|
|||||||
YG_NODE_STYLE_PROPERTY(YGWrap, FlexWrap, flexWrap);
|
YG_NODE_STYLE_PROPERTY(YGWrap, FlexWrap, flexWrap);
|
||||||
YG_NODE_STYLE_PROPERTY(YGOverflow, Overflow, overflow);
|
YG_NODE_STYLE_PROPERTY(YGOverflow, Overflow, overflow);
|
||||||
YG_NODE_STYLE_PROPERTY(YGDisplay, Display, display);
|
YG_NODE_STYLE_PROPERTY(YGDisplay, Display, display);
|
||||||
|
|
||||||
YG_NODE_STYLE_PROPERTY(float, Flex, flex);
|
YG_NODE_STYLE_PROPERTY(float, Flex, flex);
|
||||||
YG_NODE_STYLE_PROPERTY(float, FlexGrow, flexGrow);
|
YG_NODE_STYLE_PROPERTY(float, FlexGrow, flexGrow);
|
||||||
YG_NODE_STYLE_PROPERTY(float, FlexShrink, flexShrink);
|
YG_NODE_STYLE_PROPERTY(float, FlexShrink, flexShrink);
|
||||||
@@ -232,6 +244,7 @@ YG_NODE_LAYOUT_PROPERTY(float, Width);
|
|||||||
YG_NODE_LAYOUT_PROPERTY(float, Height);
|
YG_NODE_LAYOUT_PROPERTY(float, Height);
|
||||||
YG_NODE_LAYOUT_PROPERTY(YGDirection, Direction);
|
YG_NODE_LAYOUT_PROPERTY(YGDirection, Direction);
|
||||||
YG_NODE_LAYOUT_PROPERTY(bool, HadOverflow);
|
YG_NODE_LAYOUT_PROPERTY(bool, HadOverflow);
|
||||||
|
bool YGNodeLayoutGetDidLegacyStretchFlagAffectLayout(const YGNodeRef node);
|
||||||
|
|
||||||
// Get the computed values for these nodes after performing layout. If they were set using
|
// Get the computed values for these nodes after performing layout. If they were set using
|
||||||
// point values then the returned value will be the same as YGNodeStyleGetXXX. However if
|
// point values then the returned value will be the same as YGNodeStyleGetXXX. However if
|
||||||
@@ -249,10 +262,12 @@ WIN_EXPORT void YGAssertWithNode(const YGNodeRef node, const bool condition, con
|
|||||||
WIN_EXPORT void YGAssertWithConfig(const YGConfigRef config,
|
WIN_EXPORT void YGAssertWithConfig(const YGConfigRef config,
|
||||||
const bool condition,
|
const bool condition,
|
||||||
const char *message);
|
const char *message);
|
||||||
|
|
||||||
// Set this to number of pixels in 1 point to round calculation results
|
// Set this to number of pixels in 1 point to round calculation results
|
||||||
// If you want to avoid rounding - set PointScaleFactor to 0
|
// If you want to avoid rounding - set PointScaleFactor to 0
|
||||||
WIN_EXPORT void YGConfigSetPointScaleFactor(const YGConfigRef config, const float pixelsInPoint);
|
WIN_EXPORT void YGConfigSetPointScaleFactor(const YGConfigRef config, const float pixelsInPoint);
|
||||||
|
void YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(
|
||||||
|
const YGConfigRef config,
|
||||||
|
const bool shouldDiffLayout);
|
||||||
|
|
||||||
// Yoga previously had an error where containers would take the maximum space possible instead of
|
// Yoga previously had an error where containers would take the maximum space possible instead of
|
||||||
// the minimum
|
// the minimum
|
||||||
@@ -280,8 +295,8 @@ WIN_EXPORT bool YGConfigIsExperimentalFeatureEnabled(const YGConfigRef config,
|
|||||||
WIN_EXPORT void YGConfigSetUseWebDefaults(const YGConfigRef config, const bool enabled);
|
WIN_EXPORT void YGConfigSetUseWebDefaults(const YGConfigRef config, const bool enabled);
|
||||||
WIN_EXPORT bool YGConfigGetUseWebDefaults(const YGConfigRef config);
|
WIN_EXPORT bool YGConfigGetUseWebDefaults(const YGConfigRef config);
|
||||||
|
|
||||||
WIN_EXPORT void YGConfigSetNodeClonedFunc(const YGConfigRef config,
|
WIN_EXPORT void YGConfigSetCloneNodeFunc(const YGConfigRef config,
|
||||||
const YGNodeClonedFunc callback);
|
const YGCloneNodeFunc callback);
|
||||||
|
|
||||||
// Export only for C#
|
// Export only for C#
|
||||||
WIN_EXPORT YGConfigRef YGConfigGetDefault(void);
|
WIN_EXPORT YGConfigRef YGConfigGetDefault(void);
|
||||||
@@ -296,3 +311,17 @@ WIN_EXPORT float YGRoundValueToPixelGrid(
|
|||||||
const bool forceFloor);
|
const bool forceFloor);
|
||||||
|
|
||||||
YG_EXTERN_C_END
|
YG_EXTERN_C_END
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
// Calls f on each node in the tree including the given node argument.
|
||||||
|
extern void YGTraversePreOrder(YGNodeRef const node, std::function<void(YGNodeRef node)>&& f);
|
||||||
|
|
||||||
|
extern void YGNodeSetChildren(
|
||||||
|
YGNodeRef const owner,
|
||||||
|
const std::vector<YGNodeRef>& children);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@@ -12,6 +12,7 @@ JNI_TARGET = '//lib/jni:jni'
|
|||||||
FBJNI_TARGET = '//lib/fb:fbjni'
|
FBJNI_TARGET = '//lib/fb:fbjni'
|
||||||
FBJNI_JAVA_TARGET = '//lib/fb/src/main/java/com/facebook/jni:jni'
|
FBJNI_JAVA_TARGET = '//lib/fb/src/main/java/com/facebook/jni:jni'
|
||||||
APPCOMPAT_TARGET = '//lib/appcompat:appcompat'
|
APPCOMPAT_TARGET = '//lib/appcompat:appcompat'
|
||||||
|
APPLE = ''
|
||||||
ANDROID = ''
|
ANDROID = ''
|
||||||
ANDROID_SUPPORT_TARGET = '//lib/android-support:android-support'
|
ANDROID_SUPPORT_TARGET = '//lib/android-support:android-support'
|
||||||
ANDROID_TARGET = '//android:android'
|
ANDROID_TARGET = '//android:android'
|
||||||
@@ -32,6 +33,7 @@ BASE_COMPILER_FLAGS = [
|
|||||||
'-Wall',
|
'-Wall',
|
||||||
'-Werror',
|
'-Werror',
|
||||||
'-O3',
|
'-O3',
|
||||||
|
'-ffast-math',
|
||||||
]
|
]
|
||||||
|
|
||||||
LIBRARY_COMPILER_FLAGS = BASE_COMPILER_FLAGS + [
|
LIBRARY_COMPILER_FLAGS = BASE_COMPILER_FLAGS + [
|
||||||
@@ -43,73 +45,59 @@ def yoga_dep(dep):
|
|||||||
return '//' + dep
|
return '//' + dep
|
||||||
|
|
||||||
|
|
||||||
_original_android_aar = android_aar
|
def yoga_android_aar(*args, **kwargs):
|
||||||
def android_aar(*args, **kwargs):
|
native.android_aar(*args, **kwargs)
|
||||||
_original_android_aar(*args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
_original_android_binary = android_binary
|
def yoga_android_binary(*args, **kwargs):
|
||||||
def android_binary(*args, **kwargs):
|
native.android_binary(*args, **kwargs)
|
||||||
_original_android_binary(*args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
_original_android_library = android_library
|
def yoga_android_library(*args, **kwargs):
|
||||||
def android_library(*args, **kwargs):
|
native.android_library(*args, **kwargs)
|
||||||
_original_android_library(*args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
_original_android_resource = android_resource
|
def yoga_android_resource(*args, **kwargs):
|
||||||
def android_resource(*args, **kwargs):
|
native.android_resource(*args, **kwargs)
|
||||||
_original_android_resource(*args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
_original_apple_library = apple_library
|
def yoga_apple_library(*args, **kwargs):
|
||||||
def apple_library(*args, **kwargs):
|
native.apple_library(*args, **kwargs)
|
||||||
_original_apple_library(*args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
_original_apple_test = apple_test
|
def yoga_apple_test(*args, **kwargs):
|
||||||
def apple_test(*args, **kwargs):
|
native.apple_test(*args, **kwargs)
|
||||||
_original_apple_test(*args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
_original_cxx_library = cxx_library
|
def yoga_cxx_library(*args, **kwargs):
|
||||||
def cxx_library(*args, **kwargs):
|
|
||||||
# Currently unused
|
# Currently unused
|
||||||
kwargs.pop("platforms", None)
|
kwargs.pop("platforms", None)
|
||||||
_original_cxx_library(*args, **kwargs)
|
native.cxx_library(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
_original_cxx_test = cxx_test
|
def yoga_cxx_test(*args, **kwargs):
|
||||||
def cxx_test(*args, **kwargs):
|
native.cxx_test(*args, **kwargs)
|
||||||
_original_cxx_test(*args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
_original_java_binary = java_binary
|
def yoga_java_binary(*args, **kwargs):
|
||||||
def java_binary(*args, **kwargs):
|
native.java_binary(*args, **kwargs)
|
||||||
_original_java_binary(*args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
_original_java_library = java_library
|
def yoga_java_library(*args, **kwargs):
|
||||||
def java_library(*args, **kwargs):
|
native.java_library(*args, **kwargs)
|
||||||
_original_java_library(*args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
_original_java_test = java_test
|
def yoga_java_test(*args, **kwargs):
|
||||||
def java_test(*args, **kwargs):
|
native.java_test(*args, **kwargs)
|
||||||
_original_java_test(*args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
_original_prebuilt_cxx_library = prebuilt_cxx_library
|
def yoga_prebuilt_cxx_library(*args, **kwargs):
|
||||||
def prebuilt_cxx_library(*args, **kwargs):
|
native.prebuilt_cxx_library(*args, **kwargs)
|
||||||
_original_prebuilt_cxx_library(*args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
_original_prebuilt_jar = prebuilt_jar
|
def yoga_prebuilt_jar(*args, **kwargs):
|
||||||
def prebuilt_jar(*args, **kwargs):
|
native.prebuilt_jar(*args, **kwargs)
|
||||||
_original_prebuilt_jar(*args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
def is_apple_platform():
|
def is_apple_platform():
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user