Compare commits

..

1 Commits

Author SHA1 Message Date
shiyizju
36607d3457 minus total outer flex basis for available width or height 2019-01-30 17:44:23 +08:00
243 changed files with 2574 additions and 6470 deletions

View File

@@ -1,56 +0,0 @@
Language: Cpp
AccessModifierOffset: -2
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: false
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
BreakBeforeBinaryOperators: false
BreakBeforeBraces: Attach
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
BreakStringLiterals: true
ColumnLimit: 80
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
FixNamespaceComments: true
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 2
IndentWrappedFunctionNames: false
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
PenaltyReturnTypeOnItsOwnLine: 2000
PointerAlignment: Left
ReflowComments: true
SortIncludes: false
SortUsingDeclarations: true
SpaceAfterCStyleCast: true
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
Standard: Cpp11
UseTab: Never

View File

@@ -1 +0,0 @@
^lib/.*

2
BUCK
View File

@@ -20,7 +20,6 @@ TEST_COMPILER_FLAGS = BASE_COMPILER_FLAGS + GMOCK_OVERRIDE_FLAGS + [
yoga_cxx_library( yoga_cxx_library(
name = "yoga", name = "yoga",
srcs = glob(["yoga/*.cpp"]), srcs = glob(["yoga/*.cpp"]),
headers = subdir_glob([("", "yoga/**/*.h")]),
header_namespace = "", header_namespace = "",
exported_headers = subdir_glob([("", "yoga/*.h")]), exported_headers = subdir_glob([("", "yoga/*.h")]),
compiler_flags = COMPILER_FLAGS, compiler_flags = COMPILER_FLAGS,
@@ -35,7 +34,6 @@ yoga_cxx_library(
yoga_cxx_test( yoga_cxx_test(
name = "YogaTests", name = "YogaTests",
srcs = glob(["tests/*.cpp"]), srcs = glob(["tests/*.cpp"]),
headers = subdir_glob([("", "yoga/**/*.h")]),
compiler_flags = TEST_COMPILER_FLAGS, compiler_flags = TEST_COMPILER_FLAGS,
contacts = ["emilsj@fb.com"], contacts = ["emilsj@fb.com"],
visibility = ["PUBLIC"], visibility = ["PUBLIC"],

View File

@@ -1,9 +1,3 @@
#
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the LICENSE
# file in the root directory of this source tree.
#
Pod::Spec.new do |spec| Pod::Spec.new do |spec|
spec.name = 'Yoga' spec.name = 'Yoga'
spec.version = '1.9.0' spec.version = '1.9.0'
@@ -19,7 +13,7 @@ Pod::Spec.new do |spec|
:git => 'https://github.com/facebook/yoga.git', :git => 'https://github.com/facebook/yoga.git',
:tag => spec.version.to_s, :tag => spec.version.to_s,
} }
spec.platforms = { :ios => "4.3", :osx => "10.7", :tvos => "10.0", :watchos => "2.0" } spec.platforms = { :ios => "8.0", :tvos => "10.0" }
spec.module_name = 'yoga' spec.module_name = 'yoga'
spec.requires_arc = false spec.requires_arc = false
spec.pod_target_xcconfig = { spec.pod_target_xcconfig = {
@@ -34,6 +28,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,YGValue}.h' spec.public_header_files = 'yoga/{Yoga,YGEnums,YGMacros}.h'
end end

View File

@@ -1,12 +1,6 @@
#
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the LICENSE
# file in the root directory of this source tree.
#
podspec = Pod::Spec.new do |spec| podspec = Pod::Spec.new do |spec|
spec.name = 'YogaKit' spec.name = 'YogaKit'
spec.version = '1.10.0' spec.version = '1.9.0'
spec.license = { :type => 'MIT', :file => "LICENSE" } spec.license = { :type => 'MIT', :file => "LICENSE" }
spec.homepage = 'https://facebook.github.io/yoga/' spec.homepage = 'https://facebook.github.io/yoga/'
spec.documentation_url = 'https://facebook.github.io/yoga/docs/api/yogakit/' spec.documentation_url = 'https://facebook.github.io/yoga/docs/api/yogakit/'
@@ -28,7 +22,6 @@ podspec = Pod::Spec.new do |spec|
spec.source_files = 'YogaKit/Source/*.{h,m,swift}' spec.source_files = 'YogaKit/Source/*.{h,m,swift}'
spec.public_header_files = 'YogaKit/Source/{YGLayout,UIView+Yoga}.h' spec.public_header_files = 'YogaKit/Source/{YGLayout,UIView+Yoga}.h'
spec.private_header_files = 'YogaKit/Source/YGLayout+Private.h' spec.private_header_files = 'YogaKit/Source/YGLayout+Private.h'
spec.swift_version = '3.0'
end end
# See https://github.com/facebook/yoga/pull/366 # See https://github.com/facebook/yoga/pull/366

View File

@@ -1,9 +1,10 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the
* file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#import "YGLayout.h" #import "YGLayout.h"
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>

View File

@@ -1,9 +1,10 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the
* file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#import "YGLayout.h" #import "YGLayout.h"
#import <yoga/Yoga.h> #import <yoga/Yoga.h>

View File

@@ -1,9 +1,10 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the
* file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <yoga/YGEnums.h> #import <yoga/YGEnums.h>
#import <yoga/Yoga.h> #import <yoga/Yoga.h>
@@ -62,7 +63,6 @@ typedef NS_OPTIONS(NSInteger, YGDimensionFlexibility) {
@property (nonatomic, readwrite, assign) YGOverflow overflow; @property (nonatomic, readwrite, assign) YGOverflow overflow;
@property (nonatomic, readwrite, assign) YGDisplay display; @property (nonatomic, readwrite, assign) YGDisplay display;
@property (nonatomic, readwrite, assign) CGFloat flex;
@property (nonatomic, readwrite, assign) CGFloat flexGrow; @property (nonatomic, readwrite, assign) CGFloat flexGrow;
@property (nonatomic, readwrite, assign) CGFloat flexShrink; @property (nonatomic, readwrite, assign) CGFloat flexShrink;
@property (nonatomic, readwrite, assign) YGValue flexBasis; @property (nonatomic, readwrite, assign) YGValue flexBasis;

View File

@@ -129,7 +129,6 @@ static YGConfigRef globalConfig;
@interface YGLayout () @interface YGLayout ()
@property (nonatomic, weak, readonly) UIView *view; @property (nonatomic, weak, readonly) UIView *view;
@property(nonatomic, assign, readonly) BOOL isUIView;
@end @end
@@ -154,7 +153,6 @@ static YGConfigRef globalConfig;
YGNodeSetContext(_node, (__bridge void *) view); YGNodeSetContext(_node, (__bridge void *) view);
_isEnabled = NO; _isEnabled = NO;
_isIncludedInLayout = YES; _isIncludedInLayout = YES;
_isUIView = [view isMemberOfClass:[UIView class]];
} }
return self; return self;
@@ -229,7 +227,6 @@ YG_PROPERTY(YGWrap, flexWrap, FlexWrap)
YG_PROPERTY(YGOverflow, overflow, Overflow) YG_PROPERTY(YGOverflow, overflow, Overflow)
YG_PROPERTY(YGDisplay, display, Display) YG_PROPERTY(YGDisplay, display, Display)
YG_PROPERTY(CGFloat, flex, Flex)
YG_PROPERTY(CGFloat, flexGrow, FlexGrow) YG_PROPERTY(CGFloat, flexGrow, FlexGrow)
YG_PROPERTY(CGFloat, flexShrink, FlexShrink) YG_PROPERTY(CGFloat, flexShrink, FlexShrink)
YG_AUTO_VALUE_PROPERTY(flexBasis, FlexBasis) YG_AUTO_VALUE_PROPERTY(flexBasis, FlexBasis)
@@ -334,20 +331,10 @@ static YGSize YGMeasureView(
const CGFloat constrainedHeight = (heightMode == YGMeasureModeUndefined) ? CGFLOAT_MAX: height; const CGFloat constrainedHeight = (heightMode == YGMeasureModeUndefined) ? CGFLOAT_MAX: height;
UIView *view = (__bridge UIView*) YGNodeGetContext(node); UIView *view = (__bridge UIView*) YGNodeGetContext(node);
CGSize sizeThatFits = CGSizeZero; const CGSize sizeThatFits = [view sizeThatFits:(CGSize) {
// The default implementation of sizeThatFits: returns the existing size of
// the view. That means that if we want to layout an empty UIView, which
// already has got a frame set, its measured size should be CGSizeZero, but
// UIKit returns the existing size.
//
// See https://github.com/facebook/yoga/issues/606 for more information.
if (!view.yoga.isUIView || [view.subviews count] > 0) {
sizeThatFits = [view sizeThatFits:(CGSize){
.width = constrainedWidth, .width = constrainedWidth,
.height = constrainedHeight, .height = constrainedHeight,
}]; }];
}
return (YGSize) { return (YGSize) {
.width = YGSanitizeMeasurement(constrainedWidth, sizeThatFits.width, widthMode), .width = YGSanitizeMeasurement(constrainedWidth, sizeThatFits.width, widthMode),

View File

@@ -127,15 +127,6 @@
XCTAssertEqual(longTextLabelSize.width + textBadgeView.yoga.intrinsicSize.width, containerSize.width); XCTAssertEqual(longTextLabelSize.width + textBadgeView.yoga.intrinsicSize.width, containerSize.width);
} }
- (void)testSizeThatFitsEmptyView {
UIView* view = [[UIView alloc] initWithFrame:CGRectMake(10, 10, 200, 200)];
view.yoga.isEnabled = YES;
const CGSize viewSize = view.yoga.intrinsicSize;
XCTAssertEqual(viewSize.height, 0);
XCTAssertEqual(viewSize.width, 0);
}
- (void)testPreservingOrigin - (void)testPreservingOrigin
{ {
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0,0,50,75)]; UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0,0,50,75)];

View File

@@ -1,10 +1,3 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// !$*UTF8*$! // !$*UTF8*$!
{ {
archiveVersion = 1; archiveVersion = 1;

View File

@@ -1,10 +1,3 @@
<!--
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
-->
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Workspace <Workspace
version = "1.0"> version = "1.0">

View File

@@ -1,10 +1,3 @@
<!--
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
-->
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Workspace <Workspace
version = "1.0"> version = "1.0">

View File

@@ -1,10 +1,3 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
apply plugin: 'com.jfrog.bintray' apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'com.github.dcendents.android-maven'

View File

@@ -1,10 +1,3 @@
#
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the LICENSE
# file in the root directory of this source tree.
#
GROUP=com.facebook.yoga.android GROUP=com.facebook.yoga.android
POM_NAME=YogaLayout POM_NAME=YogaLayout
POM_DESCRIPTION=YogaLayout POM_DESCRIPTION=YogaLayout

View File

@@ -4,7 +4,6 @@
# 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("//tools/build_defs:fb_native_wrapper.bzl", "fb_native")
load("//tools/build_defs/oss:yoga_defs.bzl", "ANDROID_RES_TARGET", "ANDROID_SAMPLE_JAVA_TARGET", "ANDROID_SAMPLE_RES_TARGET", "yoga_android_binary", "yoga_android_resource") load("//tools/build_defs/oss:yoga_defs.bzl", "ANDROID_RES_TARGET", "ANDROID_SAMPLE_JAVA_TARGET", "ANDROID_SAMPLE_RES_TARGET", "yoga_android_binary", "yoga_android_resource")
yoga_android_binary( yoga_android_binary(
@@ -29,7 +28,7 @@ yoga_android_resource(
], ],
) )
fb_native.keystore( keystore(
name = "debug_keystore", name = "debug_keystore",
properties = "debug.keystore.properties", properties = "debug.keystore.properties",
store = "debug.keystore", store = "debug.keystore",

View File

@@ -1,9 +1,10 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the
* file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#include <math.h> #include <math.h>
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
@@ -15,7 +16,7 @@
#define NUM_REPETITIONS 1000 #define NUM_REPETITIONS 1000
#define YGBENCHMARKS(BLOCK) \ #define YGBENCHMARKS(BLOCK) \
int main(int argc, char const* argv[]) { \ int main(int argc, char const *argv[]) { \
clock_t __start; \ clock_t __start; \
clock_t __endTimes[NUM_REPETITIONS]; \ clock_t __endTimes[NUM_REPETITIONS]; \
{ BLOCK } \ { BLOCK } \
@@ -25,13 +26,14 @@
#define YGBENCHMARK(NAME, BLOCK) \ #define YGBENCHMARK(NAME, BLOCK) \
__start = clock(); \ __start = clock(); \
for (uint32_t __i = 0; __i < NUM_REPETITIONS; __i++) { \ for (uint32_t __i = 0; __i < NUM_REPETITIONS; __i++) { \
{BLOCK} __endTimes[__i] = clock(); \ { BLOCK } \
__endTimes[__i] = clock(); \
} \ } \
__printBenchmarkResult(NAME, __start, __endTimes); __printBenchmarkResult(NAME, __start, __endTimes);
static int __compareDoubles(const void* a, const void* b) { static int __compareDoubles(const void *a, const void *b) {
double arg1 = *(const double*) a; double arg1 = *(const double *) a;
double arg2 = *(const double*) b; double arg2 = *(const double *) b;
if (arg1 < arg2) { if (arg1 < arg2) {
return -1; return -1;
@@ -44,10 +46,7 @@ static int __compareDoubles(const void* a, const void* b) {
return 0; return 0;
} }
static void __printBenchmarkResult( static void __printBenchmarkResult(char *name, clock_t start, clock_t *endTimes) {
char* name,
clock_t start,
clock_t* endTimes) {
double timesInMs[NUM_REPETITIONS]; double timesInMs[NUM_REPETITIONS];
double mean = 0; double mean = 0;
clock_t lastEnd = start; clock_t lastEnd = start;
@@ -71,8 +70,8 @@ static void __printBenchmarkResult(
printf("%s: median: %lf ms, stddev: %lf ms\n", name, median, stddev); printf("%s: median: %lf ms, stddev: %lf ms\n", name, median, stddev);
} }
static YGSize _measure(
YGNodeRef node, static YGSize _measure(YGNodeRef node,
float width, float width,
YGMeasureMode widthMode, YGMeasureMode widthMode,
float height, float height,
@@ -84,6 +83,7 @@ static YGSize _measure(
} }
YGBENCHMARKS({ YGBENCHMARKS({
YGBENCHMARK("Stack with flex", { YGBENCHMARK("Stack with flex", {
const YGNodeRef root = YGNodeNew(); const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 100); YGNodeStyleSetWidth(root, 100);
@@ -161,8 +161,7 @@ YGBENCHMARKS({
for (uint32_t iiii = 0; iiii < 10; iiii++) { for (uint32_t iiii = 0; iiii < 10; iiii++) {
const YGNodeRef grandGrandGrandChild = YGNodeNew(); const YGNodeRef grandGrandGrandChild = YGNodeNew();
YGNodeStyleSetFlexDirection( YGNodeStyleSetFlexDirection(grandGrandGrandChild, YGFlexDirectionRow);
grandGrandGrandChild, YGFlexDirectionRow);
YGNodeStyleSetFlexGrow(grandGrandGrandChild, 1); YGNodeStyleSetFlexGrow(grandGrandGrandChild, 1);
YGNodeStyleSetWidth(grandGrandGrandChild, 10); YGNodeStyleSetWidth(grandGrandGrandChild, 10);
YGNodeStyleSetHeight(grandGrandGrandChild, 10); YGNodeStyleSetHeight(grandGrandGrandChild, 10);
@@ -175,4 +174,5 @@ YGBENCHMARKS({
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeFreeRecursive(root); YGNodeFreeRecursive(root);
}); });
}); });

View File

@@ -1,10 +1,3 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// Top-level build file where you can add configuration options common to all sub-projects/modules. // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript { buildscript {

View File

@@ -3,7 +3,6 @@
# 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("//tools/build_defs:fb_native_wrapper.bzl", "fb_native")
load( load(
"//tools/build_defs/oss:yoga_defs.bzl", "//tools/build_defs/oss:yoga_defs.bzl",
"BASE_COMPILER_FLAGS", "BASE_COMPILER_FLAGS",
@@ -14,14 +13,14 @@ load(
COMPILER_FLAGS = BASE_COMPILER_FLAGS + ["-std=c++11"] COMPILER_FLAGS = BASE_COMPILER_FLAGS + ["-std=c++11"]
fb_native.csharp_library( csharp_library(
name = "yogalibnet46", name = "yogalibnet46",
srcs = glob(["**/*.cs"]), srcs = glob(["**/*.cs"]),
dll_name = "Facebook.Yoga.dll", dll_name = "Facebook.Yoga.dll",
framework_ver = "net46", framework_ver = "net46",
) )
fb_native.csharp_library( csharp_library(
name = "yogalibnet45", name = "yogalibnet45",
srcs = glob(["**/*.cs"]), srcs = glob(["**/*.cs"]),
dll_name = "Facebook.Yoga.dll", dll_name = "Facebook.Yoga.dll",
@@ -30,7 +29,7 @@ fb_native.csharp_library(
yoga_cxx_library( yoga_cxx_library(
name = "yoganet", name = "yoganet",
srcs = ["Yoga/YGInterop.cpp"], srcs = glob(["Yoga/YGInterop.cpp"]),
compiler_flags = COMPILER_FLAGS, compiler_flags = COMPILER_FLAGS,
link_style = "static", link_style = "static",
link_whole = True, link_whole = True,

View File

@@ -10,6 +10,12 @@ using System.Runtime.InteropServices;
namespace Facebook.Yoga namespace Facebook.Yoga
{ {
#if WINDOWS_UWP_ARM
using YogaValueType = IntPtr;
#else
using YogaValueType = YogaValue;
#endif
internal static class Native internal static class Native
{ {
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__ #if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
@@ -68,14 +74,6 @@ namespace Facebook.Yoga
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern bool YGConfigGetUseWebDefaults(YGConfigHandle config); public static extern bool YGConfigGetUseWebDefaults(YGConfigHandle config);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGConfigSetUseLegacyStretchBehaviour(
YGConfigHandle config,
bool useLegacyStretchBehavior);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern bool YGConfigGetUseLegacyStretchBehaviour(YGConfigHandle config);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGConfigSetPointScaleFactor( public static extern void YGConfigSetPointScaleFactor(
YGConfigHandle config, YGConfigHandle config,
@@ -90,14 +88,6 @@ namespace Facebook.Yoga
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeRemoveChild(YGNodeHandle node, YGNodeHandle child); public static extern void YGNodeRemoveChild(YGNodeHandle node, YGNodeHandle child);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeSetIsReferenceBaseline(
YGNodeHandle node,
bool isReferenceBaseline);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern bool YGNodeIsReferenceBaseline(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeCalculateLayout( public static extern void YGNodeCalculateLayout(
YGNodeHandle node, YGNodeHandle node,
@@ -228,7 +218,7 @@ namespace Facebook.Yoga
public static extern void YGNodeStyleSetFlexBasisAuto(YGNodeHandle node); public static extern void YGNodeStyleSetFlexBasisAuto(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValue YGNodeStyleGetFlexBasis(YGNodeHandle node); public static extern YogaValueType YGNodeStyleGetFlexBasis(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetWidth(YGNodeHandle node, float width); public static extern void YGNodeStyleSetWidth(YGNodeHandle node, float width);
@@ -240,7 +230,7 @@ namespace Facebook.Yoga
public static extern void YGNodeStyleSetWidthAuto(YGNodeHandle node); public static extern void YGNodeStyleSetWidthAuto(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValue YGNodeStyleGetWidth(YGNodeHandle node); public static extern YogaValueType YGNodeStyleGetWidth(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetHeight(YGNodeHandle node, float height); public static extern void YGNodeStyleSetHeight(YGNodeHandle node, float height);
@@ -252,7 +242,7 @@ namespace Facebook.Yoga
public static extern void YGNodeStyleSetHeightAuto(YGNodeHandle node); public static extern void YGNodeStyleSetHeightAuto(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValue YGNodeStyleGetHeight(YGNodeHandle node); public static extern YogaValueType YGNodeStyleGetHeight(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetMinWidth(YGNodeHandle node, float minWidth); public static extern void YGNodeStyleSetMinWidth(YGNodeHandle node, float minWidth);
@@ -261,7 +251,7 @@ namespace Facebook.Yoga
public static extern void YGNodeStyleSetMinWidthPercent(YGNodeHandle node, float minWidth); public static extern void YGNodeStyleSetMinWidthPercent(YGNodeHandle node, float minWidth);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValue YGNodeStyleGetMinWidth(YGNodeHandle node); public static extern YogaValueType YGNodeStyleGetMinWidth(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetMinHeight(YGNodeHandle node, float minHeight); public static extern void YGNodeStyleSetMinHeight(YGNodeHandle node, float minHeight);
@@ -270,7 +260,7 @@ namespace Facebook.Yoga
public static extern void YGNodeStyleSetMinHeightPercent(YGNodeHandle node, float minHeight); public static extern void YGNodeStyleSetMinHeightPercent(YGNodeHandle node, float minHeight);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValue YGNodeStyleGetMinHeight(YGNodeHandle node); public static extern YogaValueType YGNodeStyleGetMinHeight(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetMaxWidth(YGNodeHandle node, float maxWidth); public static extern void YGNodeStyleSetMaxWidth(YGNodeHandle node, float maxWidth);
@@ -279,7 +269,7 @@ namespace Facebook.Yoga
public static extern void YGNodeStyleSetMaxWidthPercent(YGNodeHandle node, float maxWidth); public static extern void YGNodeStyleSetMaxWidthPercent(YGNodeHandle node, float maxWidth);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValue YGNodeStyleGetMaxWidth(YGNodeHandle node); public static extern YogaValueType YGNodeStyleGetMaxWidth(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetMaxHeight(YGNodeHandle node, float maxHeight); public static extern void YGNodeStyleSetMaxHeight(YGNodeHandle node, float maxHeight);
@@ -288,7 +278,7 @@ namespace Facebook.Yoga
public static extern void YGNodeStyleSetMaxHeightPercent(YGNodeHandle node, float maxHeight); public static extern void YGNodeStyleSetMaxHeightPercent(YGNodeHandle node, float maxHeight);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValue YGNodeStyleGetMaxHeight(YGNodeHandle node); public static extern YogaValueType YGNodeStyleGetMaxHeight(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetAspectRatio(YGNodeHandle node, float aspectRatio); public static extern void YGNodeStyleSetAspectRatio(YGNodeHandle node, float aspectRatio);
@@ -307,7 +297,7 @@ namespace Facebook.Yoga
public static extern void YGNodeStyleSetPositionPercent(YGNodeHandle node, YogaEdge edge, float position); public static extern void YGNodeStyleSetPositionPercent(YGNodeHandle node, YogaEdge edge, float position);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValue YGNodeStyleGetPosition(YGNodeHandle node, YogaEdge edge); public static extern YogaValueType YGNodeStyleGetPosition(YGNodeHandle node, YogaEdge edge);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetMargin(YGNodeHandle node, YogaEdge edge, float margin); public static extern void YGNodeStyleSetMargin(YGNodeHandle node, YogaEdge edge, float margin);
@@ -319,7 +309,7 @@ namespace Facebook.Yoga
public static extern void YGNodeStyleSetMarginAuto(YGNodeHandle node, YogaEdge edge); public static extern void YGNodeStyleSetMarginAuto(YGNodeHandle node, YogaEdge edge);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValue YGNodeStyleGetMargin(YGNodeHandle node, YogaEdge edge); public static extern YogaValueType YGNodeStyleGetMargin(YGNodeHandle node, YogaEdge edge);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetPadding(YGNodeHandle node, YogaEdge edge, float padding); public static extern void YGNodeStyleSetPadding(YGNodeHandle node, YogaEdge edge, float padding);
@@ -328,7 +318,7 @@ namespace Facebook.Yoga
public static extern void YGNodeStyleSetPaddingPercent(YGNodeHandle node, YogaEdge edge, float padding); public static extern void YGNodeStyleSetPaddingPercent(YGNodeHandle node, YogaEdge edge, float padding);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValue YGNodeStyleGetPadding(YGNodeHandle node, YogaEdge edge); public static extern YogaValueType YGNodeStyleGetPadding(YGNodeHandle node, YogaEdge edge);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetBorder(YGNodeHandle node, YogaEdge edge, float border); public static extern void YGNodeStyleSetBorder(YGNodeHandle node, YogaEdge edge, float border);

View File

@@ -1,4 +1,4 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the * This source code is licensed under the MIT license found in the
@@ -117,19 +117,6 @@ namespace Facebook.Yoga
} }
} }
public bool UseLegacyStretchBehaviour
{
get
{
return Native.YGConfigGetUseLegacyStretchBehaviour(_ygConfig);
}
set
{
Native.YGConfigSetUseLegacyStretchBehaviour(_ygConfig, value);
}
}
public float PointScaleFactor public float PointScaleFactor
{ {
set set

View File

@@ -1,4 +1,4 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the * This source code is licensed under the MIT license found in the

View File

@@ -1,4 +1,4 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the * This source code is licensed under the MIT license found in the
@@ -13,7 +13,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Left); return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Left));
} }
set set
@@ -26,7 +26,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Top); return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Top));
} }
set set
@@ -39,7 +39,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Right); return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Right));
} }
set set
@@ -52,7 +52,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Bottom); return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Bottom));
} }
set set
@@ -65,7 +65,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Start); return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Start));
} }
set set
@@ -78,7 +78,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.End); return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.End));
} }
set set
@@ -103,7 +103,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Left); return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Left));
} }
set set
@@ -116,7 +116,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Top); return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Top));
} }
set set
@@ -129,7 +129,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Right); return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Right));
} }
set set
@@ -142,7 +142,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Bottom); return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Bottom));
} }
set set
@@ -155,7 +155,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Start); return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Start));
} }
set set
@@ -168,7 +168,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.End); return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.End));
} }
set set
@@ -181,7 +181,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Horizontal); return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Horizontal));
} }
set set
@@ -194,7 +194,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Vertical); return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Vertical));
} }
set set
@@ -207,7 +207,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.All); return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.All));
} }
set set
@@ -236,7 +236,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Left); return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Left));
} }
set set
@@ -249,7 +249,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Top); return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Top));
} }
set set
@@ -262,7 +262,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Right); return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Right));
} }
set set
@@ -275,7 +275,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Bottom); return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Bottom));
} }
set set
@@ -288,7 +288,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Start); return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Start));
} }
set set
@@ -301,7 +301,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.End); return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.End));
} }
set set
@@ -314,7 +314,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Horizontal); return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Horizontal));
} }
set set
@@ -327,7 +327,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Vertical); return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Vertical));
} }
set set
@@ -340,7 +340,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.All); return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.All));
} }
set set

View File

@@ -1,4 +1,4 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the * This source code is licensed under the MIT license found in the
@@ -271,7 +271,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return Native.YGNodeStyleGetFlexBasis(_ygNode); return YogaValue.MarshalValue(Native.YGNodeStyleGetFlexBasis(_ygNode));
} }
set set
@@ -295,7 +295,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return Native.YGNodeStyleGetWidth(_ygNode); return YogaValue.MarshalValue(Native.YGNodeStyleGetWidth(_ygNode));
} }
set set
@@ -319,7 +319,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return Native.YGNodeStyleGetHeight(_ygNode); return YogaValue.MarshalValue(Native.YGNodeStyleGetHeight(_ygNode));
} }
set set
@@ -343,7 +343,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return Native.YGNodeStyleGetMaxWidth(_ygNode); return YogaValue.MarshalValue(Native.YGNodeStyleGetMaxWidth(_ygNode));
} }
set set
@@ -363,7 +363,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return Native.YGNodeStyleGetMaxHeight(_ygNode); return YogaValue.MarshalValue(Native.YGNodeStyleGetMaxHeight(_ygNode));
} }
set set
@@ -383,7 +383,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return Native.YGNodeStyleGetMinWidth(_ygNode); return YogaValue.MarshalValue(Native.YGNodeStyleGetMinWidth(_ygNode));
} }
set set
@@ -403,7 +403,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return Native.YGNodeStyleGetMinHeight(_ygNode); return YogaValue.MarshalValue(Native.YGNodeStyleGetMinHeight(_ygNode));
} }
set set
@@ -519,19 +519,6 @@ namespace Facebook.Yoga
Native.YGNodeSetHasNewLayout(_ygNode, false); Native.YGNodeSetHasNewLayout(_ygNode, false);
} }
public bool IsReferenceBaseline
{
get
{
return Native.YGNodeIsReferenceBaseline(_ygNode);
}
set
{
Native.YGNodeSetIsReferenceBaseline(_ygNode, value);
}
}
public bool ValuesEqual(float f1, float f2) public bool ValuesEqual(float f1, float f2)
{ {
if (float.IsNaN(f1) || float.IsNaN(f2)) if (float.IsNaN(f1) || float.IsNaN(f2))

View File

@@ -91,5 +91,17 @@ namespace Facebook.Yoga
{ {
return Point(pointValue); return Point(pointValue);
} }
#if WINDOWS_UWP_ARM
internal static YogaValue MarshalValue(IntPtr ptr)
{
return Marshal.PtrToStructure<YogaValue>(ptr);
}
#else
internal static YogaValue MarshalValue(YogaValue value)
{
return value;
}
#endif
} }
} }

View File

@@ -1,10 +1,2 @@
#!/bin/sh #!/bin/sh
#
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
#
./csharp/Mac/Facebook.Yoga.Mac.Tests/bin/Release/Facebook.Yoga.Mac.Tests.app/Contents/MacOS/Facebook.Yoga.Mac.Tests ./csharp/Mac/Facebook.Yoga.Mac.Tests/bin/Release/Facebook.Yoga.Mac.Tests.app/Contents/MacOS/Facebook.Yoga.Mac.Tests

View File

@@ -1,4 +1,4 @@
using System; using System;
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using Facebook.Yoga; using Facebook.Yoga;
@@ -206,8 +206,8 @@ namespace Facebook.Yoga.Universal.Tests
return MeasureOutput.Make(123.4f, 81.7f); return MeasureOutput.Make(123.4f, 81.7f);
}); });
node.CalculateLayout(); node.CalculateLayout();
Assert.AreEqual(124, node.LayoutWidth); Assert.AreEqual(123, node.LayoutWidth);
Assert.AreEqual(82, node.LayoutHeight); Assert.AreEqual(81, node.LayoutHeight);
} }
[TestMethod] [TestMethod]
@@ -268,12 +268,7 @@ namespace Facebook.Yoga.Universal.Tests
parent.Insert(0, child0); parent.Insert(0, child0);
parent.Insert(0, child1); parent.Insert(0, child1);
parent.CalculateLayout(); parent.CalculateLayout();
Assert.AreEqual(parent.Print(), Assert.AreEqual(parent.Print(), "{layout: {width: 100, height: 120, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 100, height: 120, children: [\n {layout: {width: 35, height: 45, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 35, height: 45, },\n {layout: {width: 30, height: 40, top: 45, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 30, height: 40, },\n]},\n");
"<div layout=\"width: 100; height: 120; top: 0; left: 0;\" style=\"width: 100px; height: 120px; \" >\n" +
" <div layout=\"width: 35; height: 45; top: 0; left: 0;\" style=\"width: 35px; height: 45px; \" ></div>\n" +
" <div layout=\"width: 30; height: 40; top: 45; left: 0;\" style=\"width: 30px; height: 40px; \" ></div>\n" +
"</div>"
);
} }
[TestMethod] [TestMethod]

View File

@@ -1,9 +1,10 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the
* file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#include "YGInterop.h" #include "YGInterop.h"
static YGInteropLogger gManagedLogger; static YGInteropLogger gManagedLogger;

View File

@@ -1,9 +1,10 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the
* file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#pragma once #pragma once
#include <yoga/Yoga.h> #include <yoga/Yoga.h>

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations"> <ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|ARM"> <ProjectConfiguration Include="Debug|ARM">
@@ -33,47 +33,47 @@
<RootNamespace>Yoga</RootNamespace> <RootNamespace>Yoga</RootNamespace>
<AppContainerApplication>true</AppContainerApplication> <AppContainerApplication>true</AppContainerApplication>
<ApplicationType>Windows Store</ApplicationType> <ApplicationType>Windows Store</ApplicationType>
<WindowsTargetPlatformVersion>10.0.14393.0</WindowsTargetPlatformVersion> <WindowsTargetPlatformVersion>10.0.10586.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformMinVersion>10.0.14393.0</WindowsTargetPlatformMinVersion> <WindowsTargetPlatformMinVersion>10.0.10240.0</WindowsTargetPlatformMinVersion>
<ApplicationTypeRevision>10.0</ApplicationTypeRevision> <ApplicationTypeRevision>10.0</ApplicationTypeRevision>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset> <PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset> <PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries> <UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset> <PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries> <UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset> <PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset> <PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries> <UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset> <PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
@@ -116,7 +116,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental> <LinkIncremental>true</LinkIncremental>
<OutDir>bin\Universal\$(PlatformTarget)\$(Configuration)\</OutDir> <OutDir>bin\Universal\$(PlatformTarget)\$(Configuration)\</OutDir>
<IntDir>obj\Universal\$(PlatformTarget)\$(Configuration)\</IntDir> <IntDir>obj\$(PlatformTarget)\$(Configuration)\</IntDir>
<TargetName>yoga</TargetName> <TargetName>yoga</TargetName>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@@ -242,31 +242,19 @@
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<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\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="..\..\yoga\Yoga.h" />
<ClInclude Include="..\..\yoga\YGMacros.h" />
<ClInclude Include="..\..\yoga\YGNodeList.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\Utils.cpp" /> <ClCompile Include="..\..\yoga\YGEnums.c" />
<ClCompile Include="..\..\yoga\YGConfig.cpp" /> <ClCompile Include="..\..\yoga\Yoga.c" />
<ClCompile Include="..\..\yoga\YGEnums.cpp" /> <ClCompile Include="..\..\yoga\YGNodeList.c" />
<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>

View File

@@ -21,40 +21,22 @@
<ClInclude Include="targetver.h"> <ClInclude Include="targetver.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="resource.h"> <ClInclude Include="..\..\yoga\Yoga.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\YGNode.h"> <ClInclude Include="..\..\yoga\YGNodeList.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\yoga\YGNodePrint.h"> <ClInclude Include="YGInterop.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\yoga\YGStyle.h"> <ClInclude Include="resource.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\yoga\Yoga.h"> <ClInclude Include="..\..\yoga\YGEnums.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>
@@ -65,34 +47,16 @@
<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"> <ClCompile Include="..\..\yoga\YGEnums.c">
<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> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>

View File

@@ -38,39 +38,39 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset> <PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset> <PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries> <UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset> <PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries> <UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset> <PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset> <PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries> <UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset> <PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>

View File

@@ -1,9 +1,10 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the
* file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
// dllmain.cpp : Defines the entry point for the DLL application. // dllmain.cpp : Defines the entry point for the DLL application.
#include "stdafx.h" #include "stdafx.h"

View File

@@ -1,9 +1,10 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the
* file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
// stdafx.cpp : source file that includes just the standard includes // stdafx.cpp : source file that includes just the standard includes
// Yoga.pch will be the pre-compiled header // Yoga.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information // stdafx.obj will contain the pre-compiled type information

View File

@@ -1,9 +1,10 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the
* file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
// stdafx.h : include file for standard system include files, // stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but // or project specific include files that are used frequently, but
// are changed infrequently // are changed infrequently

View File

@@ -1,9 +1,10 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the
* file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#pragma once #pragma once
// Including SDKDDKVer.h defines the highest available Windows platform. // Including SDKDDKVer.h defines the highest available Windows platform.

View File

@@ -1,12 +1,4 @@
#!/bin/sh #!/bin/sh
#
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
#
cd `dirname "$0"` cd `dirname "$0"`
echo $ANDROID_SDK echo $ANDROID_SDK
BUCK_RELEASE=2018.02.16.01 BUCK_RELEASE=2018.02.16.01
@@ -30,3 +22,4 @@ $BUCK build \
//csharp:yoganet-macosx \ //csharp:yoganet-macosx \
//csharp:yoganet#android-armv7,shared \ //csharp:yoganet#android-armv7,shared \
//csharp:yoganet#android-x86,shared //csharp:yoganet#android-x86,shared

View File

@@ -1,104 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
using System;
using NUnit.Framework;
namespace Facebook.Yoga
{
[TestFixture]
public class YGAlignBaselineTest
{
[Test]
public void Test_align_baseline_parent_using_child_in_column_as_reference()
{
YogaConfig config = new YogaConfig();
YogaNode root = createYGNode(config, YogaFlexDirection.Row, 1000, 1000, true);
YogaNode root_child0 = createYGNode(config, YogaFlexDirection.Column, 500, 600, false);
root.Insert(0, root_child0);
YogaNode root_child1 = createYGNode(config, YogaFlexDirection.Column, 500, 800, false);
root.Insert(1, root_child1);
YogaNode root_child1_child0 = createYGNode(config, YogaFlexDirection.Column, 500, 300, false);
root_child1.Insert(0, root_child1_child0);
YogaNode root_child1_child1 = createYGNode(config, YogaFlexDirection.Column, 500, 400, false);
root_child1_child1.SetBaselineFunction((_, width, height) => {
return height / 2;
});
root_child1_child1.IsReferenceBaseline = true;
root_child1.Insert(1, root_child1_child1);
root.CalculateLayout();
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(500f, root_child1.LayoutX);
Assert.AreEqual(100f, root_child1.LayoutY);
Assert.AreEqual(0f, root_child1_child0.LayoutX);
Assert.AreEqual(0f, root_child1_child0.LayoutY);
Assert.AreEqual(0f, root_child1_child1.LayoutX);
Assert.AreEqual(300f, root_child1_child1.LayoutY);
}
[Test]
public void Test_align_baseline_parent_using_child_in_row_as_reference()
{
YogaConfig config = new YogaConfig();
YogaNode root = createYGNode(config, YogaFlexDirection.Row, 1000, 1000, true);
YogaNode root_child0 = createYGNode(config, YogaFlexDirection.Column, 500, 600, false);
root.Insert(0, root_child0);
YogaNode root_child1 = createYGNode(config, YogaFlexDirection.Row, 500, 800, true);
root.Insert(1, root_child1);
YogaNode root_child1_child0 = createYGNode(config, YogaFlexDirection.Row, 500, 500, false);
root_child1.Insert(0, root_child1_child0);
YogaNode root_child1_child1 = createYGNode(config, YogaFlexDirection.Row, 500, 400, false);
root_child1_child1.SetBaselineFunction((_, width, height) => {
return height / 2;
});
root_child1_child1.IsReferenceBaseline = true;
root_child1.Insert(1, root_child1_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(500f, root_child1.LayoutX);
Assert.AreEqual(100f, root_child1.LayoutY);
Assert.AreEqual(0f, root_child1_child0.LayoutX);
Assert.AreEqual(0f, root_child1_child0.LayoutY);
Assert.AreEqual(500f, root_child1_child1.LayoutX);
Assert.AreEqual(300f, root_child1_child1.LayoutY);
}
private YogaNode createYGNode(YogaConfig config, YogaFlexDirection flexDirection, int width, int height, bool alignBaseline) {
YogaNode node = new YogaNode(config);
node.FlexDirection = flexDirection;
node.Width = width;
node.Height = height;
if (alignBaseline) {
node.AlignItems = YogaAlign.Baseline;
}
return node;
}
}
}

View File

@@ -69,123 +69,6 @@ namespace Facebook.Yoga
Assert.AreEqual(25f, root_child1.LayoutHeight); Assert.AreEqual(25f, root_child1.LayoutHeight);
} }
[Test]
public void Test_flex_shrink_flex_grow_row()
{
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 500;
root.Height = 500;
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexShrink = 1;
root_child0.Width = 500;
root_child0.Height = 100;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexShrink = 1;
root_child1.Width = 500;
root_child1.Height = 100;
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(500f, root.LayoutWidth);
Assert.AreEqual(500f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(250f, root_child0.LayoutWidth);
Assert.AreEqual(100f, root_child0.LayoutHeight);
Assert.AreEqual(250f, root_child1.LayoutX);
Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(250f, root_child1.LayoutWidth);
Assert.AreEqual(100f, root_child1.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(500f, root.LayoutWidth);
Assert.AreEqual(500f, root.LayoutHeight);
Assert.AreEqual(250f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(250f, root_child0.LayoutWidth);
Assert.AreEqual(100f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(250f, root_child1.LayoutWidth);
Assert.AreEqual(100f, root_child1.LayoutHeight);
}
[Test]
public void Test_flex_shrink_flex_grow_child_flex_shrink_other_child()
{
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 500;
root.Height = 500;
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexShrink = 1;
root_child0.Width = 500;
root_child0.Height = 100;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexGrow = 1;
root_child1.FlexShrink = 1;
root_child1.Width = 500;
root_child1.Height = 100;
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(500f, root.LayoutWidth);
Assert.AreEqual(500f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(250f, root_child0.LayoutWidth);
Assert.AreEqual(100f, root_child0.LayoutHeight);
Assert.AreEqual(250f, root_child1.LayoutX);
Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(250f, root_child1.LayoutWidth);
Assert.AreEqual(100f, root_child1.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(500f, root.LayoutWidth);
Assert.AreEqual(500f, root.LayoutHeight);
Assert.AreEqual(250f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(250f, root_child0.LayoutWidth);
Assert.AreEqual(100f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(250f, root_child1.LayoutWidth);
Assert.AreEqual(100f, root_child1.LayoutHeight);
}
[Test] [Test]
public void Test_flex_basis_flex_grow_row() public void Test_flex_basis_flex_grow_row()
{ {

View File

@@ -1003,159 +1003,5 @@ namespace Facebook.Yoga
Assert.AreEqual(10f, root_child2.LayoutHeight); Assert.AreEqual(10f, root_child2.LayoutHeight);
} }
[Test]
public void Test_justify_content_min_width_with_padding_child_width_greater_than_parent()
{
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.AlignContent = YogaAlign.Stretch;
root.Width = 1000;
root.Height = 1584;
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexDirection = YogaFlexDirection.Row;
root_child0.AlignContent = YogaAlign.Stretch;
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.FlexDirection = YogaFlexDirection.Row;
root_child0_child0.JustifyContent = YogaJustify.Center;
root_child0_child0.AlignContent = YogaAlign.Stretch;
root_child0_child0.PaddingLeft = 100;
root_child0_child0.PaddingRight = 100;
root_child0_child0.MinWidth = 400;
root_child0.Insert(0, root_child0_child0);
YogaNode root_child0_child0_child0 = new YogaNode(config);
root_child0_child0_child0.FlexDirection = YogaFlexDirection.Row;
root_child0_child0_child0.AlignContent = YogaAlign.Stretch;
root_child0_child0_child0.Width = 300;
root_child0_child0_child0.Height = 100;
root_child0_child0.Insert(0, root_child0_child0_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(1000f, root.LayoutWidth);
Assert.AreEqual(1584f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(1000f, root_child0.LayoutWidth);
Assert.AreEqual(100f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child0_child0.LayoutX);
Assert.AreEqual(0f, root_child0_child0.LayoutY);
Assert.AreEqual(500f, root_child0_child0.LayoutWidth);
Assert.AreEqual(100f, root_child0_child0.LayoutHeight);
Assert.AreEqual(100f, root_child0_child0_child0.LayoutX);
Assert.AreEqual(0f, root_child0_child0_child0.LayoutY);
Assert.AreEqual(300f, root_child0_child0_child0.LayoutWidth);
Assert.AreEqual(100f, root_child0_child0_child0.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(1000f, root.LayoutWidth);
Assert.AreEqual(1584f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(1000f, root_child0.LayoutWidth);
Assert.AreEqual(100f, root_child0.LayoutHeight);
Assert.AreEqual(500f, root_child0_child0.LayoutX);
Assert.AreEqual(0f, root_child0_child0.LayoutY);
Assert.AreEqual(500f, root_child0_child0.LayoutWidth);
Assert.AreEqual(100f, root_child0_child0.LayoutHeight);
Assert.AreEqual(100f, root_child0_child0_child0.LayoutX);
Assert.AreEqual(0f, root_child0_child0_child0.LayoutY);
Assert.AreEqual(300f, root_child0_child0_child0.LayoutWidth);
Assert.AreEqual(100f, root_child0_child0_child0.LayoutHeight);
}
[Test]
public void Test_justify_content_min_width_with_padding_child_width_lower_than_parent()
{
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.AlignContent = YogaAlign.Stretch;
root.Width = 1080;
root.Height = 1584;
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexDirection = YogaFlexDirection.Row;
root_child0.AlignContent = YogaAlign.Stretch;
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.FlexDirection = YogaFlexDirection.Row;
root_child0_child0.JustifyContent = YogaJustify.Center;
root_child0_child0.AlignContent = YogaAlign.Stretch;
root_child0_child0.PaddingLeft = 100;
root_child0_child0.PaddingRight = 100;
root_child0_child0.MinWidth = 400;
root_child0.Insert(0, root_child0_child0);
YogaNode root_child0_child0_child0 = new YogaNode(config);
root_child0_child0_child0.FlexDirection = YogaFlexDirection.Row;
root_child0_child0_child0.AlignContent = YogaAlign.Stretch;
root_child0_child0_child0.Width = 199;
root_child0_child0_child0.Height = 100;
root_child0_child0.Insert(0, root_child0_child0_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(1080f, root.LayoutWidth);
Assert.AreEqual(1584f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(1080f, root_child0.LayoutWidth);
Assert.AreEqual(100f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child0_child0.LayoutX);
Assert.AreEqual(0f, root_child0_child0.LayoutY);
Assert.AreEqual(400f, root_child0_child0.LayoutWidth);
Assert.AreEqual(100f, root_child0_child0.LayoutHeight);
Assert.AreEqual(101f, root_child0_child0_child0.LayoutX);
Assert.AreEqual(0f, root_child0_child0_child0.LayoutY);
Assert.AreEqual(199f, root_child0_child0_child0.LayoutWidth);
Assert.AreEqual(100f, root_child0_child0_child0.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(1080f, root.LayoutWidth);
Assert.AreEqual(1584f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(1080f, root_child0.LayoutWidth);
Assert.AreEqual(100f, root_child0.LayoutHeight);
Assert.AreEqual(680f, root_child0_child0.LayoutX);
Assert.AreEqual(0f, root_child0_child0.LayoutY);
Assert.AreEqual(400f, root_child0_child0.LayoutWidth);
Assert.AreEqual(100f, root_child0_child0.LayoutHeight);
Assert.AreEqual(101f, root_child0_child0_child0.LayoutX);
Assert.AreEqual(0f, root_child0_child0_child0.LayoutY);
Assert.AreEqual(199f, root_child0_child0_child0.LayoutWidth);
Assert.AreEqual(100f, root_child0_child0_child0.LayoutHeight);
}
} }
} }

View File

@@ -259,7 +259,7 @@ namespace Facebook.Yoga
[Test] [Test]
public void TestPrintWithLogger() public void TestPrintWithLogger()
{ {
YogaNode node = new YogaNode(); YogaNode node = new YogaNode(new YogaConfig{Logger = (c, n, l, m) => {}});
node.Width = 110; node.Width = 110;
node.Height = 105; node.Height = 105;
node.CalculateLayout(); node.CalculateLayout();

View File

@@ -0,0 +1,121 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
* 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.
*/
#pragma once
#include <algorithm>
#include <array>
#include <cmath>
#include <vector>
#include "Yoga.h"
using YGVector = std::vector<YGNodeRef>;
YG_EXTERN_C_BEGIN
WIN_EXPORT float YGRoundValueToPixelGrid(
const float value,
const float pointScaleFactor,
const bool forceCeil,
const bool forceFloor);
YG_EXTERN_C_END
extern const std::array<YGEdge, 4> trailing;
extern const std::array<YGEdge, 4> leading;
extern bool YGValueEqual(const YGValue a, const YGValue b);
extern const YGValue YGValueUndefined;
extern const YGValue YGValueAuto;
extern const YGValue YGValueZero;
template <std::size_t size>
bool YGValueArrayEqual(
const std::array<YGValue, size> val1,
const std::array<YGValue, size> val2) {
bool areEqual = true;
for (uint32_t i = 0; i < size && areEqual; ++i) {
areEqual = YGValueEqual(val1[i], val2[i]);
}
return areEqual;
}
const YGValue kYGValueUndefined = {YGUndefined, YGUnitUndefined};
const YGValue kYGValueAuto = {YGUndefined, YGUnitAuto};
const std::array<YGValue, YGEdgeCount> kYGDefaultEdgeValuesUnit = {
{kYGValueUndefined,
kYGValueUndefined,
kYGValueUndefined,
kYGValueUndefined,
kYGValueUndefined,
kYGValueUndefined,
kYGValueUndefined,
kYGValueUndefined,
kYGValueUndefined}};
const std::array<YGValue, 2> kYGDefaultDimensionValuesAutoUnit = {
{kYGValueAuto, kYGValueAuto}};
const std::array<YGValue, 2> kYGDefaultDimensionValuesUnit = {
{kYGValueUndefined, kYGValueUndefined}};
struct YGCachedMeasurement {
float availableWidth;
float availableHeight;
YGMeasureMode widthMeasureMode;
YGMeasureMode heightMeasureMode;
float computedWidth;
float computedHeight;
bool operator==(YGCachedMeasurement measurement) const {
bool isEqual = widthMeasureMode == measurement.widthMeasureMode &&
heightMeasureMode == measurement.heightMeasureMode;
if (!std::isnan(availableWidth) ||
!std::isnan(measurement.availableWidth)) {
isEqual = isEqual && availableWidth == measurement.availableWidth;
}
if (!std::isnan(availableHeight) ||
!std::isnan(measurement.availableHeight)) {
isEqual = isEqual && availableHeight == measurement.availableHeight;
}
if (!std::isnan(computedWidth) || !std::isnan(measurement.computedWidth)) {
isEqual = isEqual && computedWidth == measurement.computedWidth;
}
if (!std::isnan(computedHeight) ||
!std::isnan(measurement.computedHeight)) {
isEqual = isEqual && computedHeight == measurement.computedHeight;
}
return isEqual;
}
};
// This value was chosen based on empiracle data. Even the most complicated
// layouts should not require more than 16 entries to fit within the cache.
#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 kDefaultFlexShrink = 0.0f;
static const float kWebDefaultFlexShrink = 1.0f;
extern bool YGFloatsEqual(const float a, const float b);
extern bool YGValueEqual(const YGValue a, const YGValue b);
extern const YGValue* YGComputedEdgeValue(
const std::array<YGValue, YGEdgeCount>& edges,
const YGEdge edge,
const YGValue* const defaultValue);

View File

View File

@@ -3,16 +3,6 @@
<div style="flex-grow: 1;"></div> <div style="flex-grow: 1;"></div>
</div> </div>
<div id="flex_shrink_flex_grow_row" style="width: 500px; height: 500px; flex-direction: row;">
<div style="width: 500px; height: 100px; flex-grow: 0; flex-shrink: 1;"></div>
<div style="width: 500px; height: 100px; flex-grow: 0; flex-shrink: 1;"></div>
</div>
<div id="flex_shrink_flex_grow_child_flex_shrink_other_child" style="width: 500px; height: 500px; flex-direction: row;">
<div style="width: 500px; height: 100px; flex-grow: 0; flex-shrink: 1;"></div>
<div style="width: 500px; height: 100px; flex-grow: 1; flex-shrink: 1;"></div>
</div>
<div id="flex_basis_flex_grow_row" style="width: 100px; height: 100px; flex-direction: row;"> <div id="flex_basis_flex_grow_row" style="width: 100px; height: 100px; flex-direction: row;">
<div style="flex-basis: 50px; flex-grow: 1;"></div> <div style="flex-basis: 50px; flex-grow: 1;"></div>
<div style="flex-grow: 1;"></div> <div style="flex-grow: 1;"></div>

View File

@@ -86,7 +86,7 @@
<div style="height: 10px;"></div> <div style="height: 10px;"></div>
</div> </div>
<div id="justify_content_min_width_with_padding_child_width_greater_than_parent" style="width: 1000px; height: 1584px; align-content: stretch;"> <div id="justify_content_min_width_with_padding_child_width_greater_than_parent" style="width: 1000px; height: 1584px;">
<div style="flex-direction: row; align-content: stretch;"> <div style="flex-direction: row; align-content: stretch;">
<div style="flex-direction: row; justify-content: center; align-content: stretch; min-width: 400px; padding-left: 100px; padding-right: 100px;"> <div style="flex-direction: row; justify-content: center; align-content: stretch; min-width: 400px; padding-left: 100px; padding-right: 100px;">
<div style="height: 100px; width: 300px; align-content: stretch; flex-direction: row;"></div> <div style="height: 100px; width: 300px; align-content: stretch; flex-direction: row;"></div>
@@ -94,7 +94,7 @@
</div> </div>
</div> </div>
<div id="justify_content_min_width_with_padding_child_width_lower_than_parent" style="width: 1080px; height: 1584px; align-content: stretch;"> <div id="justify_content_min_width_with_padding_child_width_greater_than_parent" style="width: 1080px; height: 1584px;">
<div style="flex-direction: row; align-content: stretch;"> <div style="flex-direction: row; align-content: stretch;">
<div style="flex-direction: row; justify-content: center; align-content: stretch; min-width: 400px; padding-left: 100px; padding-right: 100px;"> <div style="flex-direction: row; justify-content: center; align-content: stretch; min-width: 400px; padding-left: 100px; padding-right: 100px;">
<div style="height: 100px; width: 199px; align-content: stretch; flex-direction: row;"></div> <div style="height: 100px; width: 199px; align-content: stretch; flex-direction: row;"></div>

View File

@@ -42,29 +42,13 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
this.push([ this.push([
'package com.facebook.yoga;', 'package com.facebook.yoga;',
'', '',
'import org.junit.Test;',
'',
'import static org.junit.Assert.assertEquals;', 'import static org.junit.Assert.assertEquals;',
'', '',
'import org.junit.Test;',
'import org.junit.runner.RunWith;',
'import org.junit.runners.Parameterized;',
'',
'@RunWith(Parameterized.class)',
'public class YogaTest {', 'public class YogaTest {',
]); ]);
this.pushIndent(); this.pushIndent();
this.push([
'@Parameterized.Parameters(name = "{0}")',
'public static Iterable<TestParametrization.NodeFactory> nodeFactories() {',
]);
this.pushIndent();
this.push('return TestParametrization.nodeFactories();');
this.popIndent();
this.push('}');
this.push([
'',
'@Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory;',
'',
]);
}}, }},
emitTestPrologue:{value:function(name, experiments) { emitTestPrologue:{value:function(name, experiments) {
@@ -80,7 +64,7 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
}}, }},
emitTestTreePrologue:{value:function(nodeName) { emitTestTreePrologue:{value:function(nodeName) {
this.push('final YogaNode ' + nodeName + ' = createNode(config);'); this.push('final YogaNode ' + nodeName + ' = new YogaNode(config);');
}}, }},
emitTestEpilogue:{value:function(experiments) { emitTestEpilogue:{value:function(experiments) {
@@ -92,11 +76,6 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
}}, }},
emitEpilogue:{value:function(lines) { emitEpilogue:{value:function(lines) {
this.push('private YogaNode createNode(YogaConfig config) {');
this.pushIndent();
this.push('return mNodeFactory.create(config);');
this.popIndent();
this.push('}');
this.popIndent(); this.popIndent();
this.push([ this.push([
'}', '}',

View File

@@ -42,7 +42,7 @@ function assert(condition, message) {
function printTest(e, LTRContainer, RTLContainer, genericContainer) { function printTest(e, LTRContainer, RTLContainer, genericContainer) {
e.push([ e.push([
'/**', '/**',
' * Copyright (c) Facebook, Inc. and its affiliates.', ' * Copyright (c) 2014-present, Facebook, Inc.',
' *', ' *',
' * 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.',

View File

@@ -1,15 +1,8 @@
#
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the LICENSE
# file in the root directory of this source tree.
#
# Project-wide Gradle settings. # Project-wide Gradle settings.
org.gradle.jvmargs=-Xmx1536M org.gradle.jvmargs=-Xmx1536M
VERSION_NAME=1.11.0 VERSION_NAME=1.10.0-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

View File

@@ -10,14 +10,13 @@ yoga_cxx_library(
srcs = glob(["jni/*.cpp"]), srcs = glob(["jni/*.cpp"]),
headers = glob(["jni/*.h"]), headers = glob(["jni/*.h"]),
header_namespace = "", header_namespace = "",
allow_jni_merging = True,
compiler_flags = [ compiler_flags = [
"-fno-omit-frame-pointer", "-fno-omit-frame-pointer",
"-fexceptions", "-fexceptions",
"-fPIC", "-fPIC",
"-Wall", "-Wall",
"-Werror", "-Werror",
"-Os", "-O3",
"-std=c++11", "-std=c++11",
], ],
platforms = ANDROID, platforms = ANDROID,

View File

@@ -1,10 +1,3 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
apply plugin: 'com.jfrog.bintray' apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'com.github.dcendents.android-maven'

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.
@@ -16,7 +16,7 @@ public class YogaConfig {
public static int SPACING_TYPE = 1; public static int SPACING_TYPE = 1;
static { static {
SoLoader.loadLibrary("yoga"); YogaJNI.init();
} }
long mNativePointer; long mNativePointer;

View File

@@ -1,24 +1,38 @@
/** /*
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.
*
*/ */
package com.facebook.yoga; package com.facebook.yoga;
public class YogaConstants { public class YogaConstants {
public static final float UNDEFINED = Float.NaN; /**
* Large positive number signifies that the property(float) is undefined. Earlier we used to have
* YGundefined as NAN, but the downside of this is that we can't use -ffast-math compiler flag as
* it assumes all floating-point calculation involve and result into finite numbers. For more
* information regarding -ffast-math compiler flag in clang, have a look at
* https://clang.llvm.org/docs/UsersManual.html#cmdoption-ffast-math
*/
public static final float UNDEFINED = (float) (10E20);
public static boolean isUndefined(float value) { public static boolean isUndefined(float value) {
return Float.compare(value, UNDEFINED) == 0; // 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
// was that if NAN is involved in any mathematical expression the result was NAN. But since we
// want to have `-ffast-math`
// flag being used by compiler which assumes that the floating point values are not NAN and Inf,
// we represent YGUndefined as 10.1E20.
// But now if YGUndefined is involved in any mathematical operations this value(10.1E20) would
// change.
// So the following check makes sure that if the value is outside a range (-10E8, 10E8) then it
// is undefined.
return (Float.compare(value, (float) 10E8) >= 0 || Float.compare(value, (float) -10E8) <= 0);
} }
public static boolean isUndefined(YogaValue value) { public static boolean isUndefined(YogaValue value) {
return value.unit == YogaUnit.UNDEFINED; return value.unit == YogaUnit.UNDEFINED;
} }
public static float getUndefined() {
return UNDEFINED;
}
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.

View File

@@ -0,0 +1,30 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree.
*
*/
package com.facebook.yoga;
import com.facebook.soloader.SoLoader;
public class YogaJNI {
// Known constants. 1-3 used in previous experiments. Do not reuse.
public static int JNI_FAST_CALLS = 4;
// set before loading any other Yoga code
public static boolean useFastCall = false;
private static native void jni_bindNativeMethods(boolean useFastCall);
static boolean init() {
if (SoLoader.loadLibrary("yoga")) {
jni_bindNativeMethods(useFastCall);
return true;
}
return false;
}
}

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.

View File

@@ -1,9 +1,11 @@
/** /*
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.
*
*/ */
package com.facebook.yoga; package com.facebook.yoga;
import com.facebook.proguard.annotations.DoNotStrip; import com.facebook.proguard.annotations.DoNotStrip;
@@ -16,7 +18,7 @@ import javax.annotation.Nullable;
public class YogaNode implements Cloneable { public class YogaNode implements Cloneable {
static { static {
SoLoader.loadLibrary("yoga"); YogaJNI.init();
} }
/** /**
@@ -159,7 +161,6 @@ public class YogaNode implements Cloneable {
} }
private static native void jni_YGNodeInsertChild(long nativePointer, long childPointer, int index); private static 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.mOwner != 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.");
@@ -173,16 +174,15 @@ public class YogaNode implements Cloneable {
jni_YGNodeInsertChild(mNativePointer, child.mNativePointer, i); jni_YGNodeInsertChild(mNativePointer, child.mNativePointer, i);
} }
private static native void jni_YGNodeSetIsReferenceBaseline(long nativePointer, boolean isReferenceBaseline); private static native void jni_YGNodeInsertSharedChild(long nativePointer, long childPointer, int index);
public void setIsReferenceBaseline(boolean isReferenceBaseline) { public void addSharedChildAt(YogaNode child, int i) {
jni_YGNodeSetIsReferenceBaseline(mNativePointer, isReferenceBaseline); if (mChildren == null) {
mChildren = new ArrayList<>(4);
} }
mChildren.add(i, child);
private static native boolean jni_YGNodeIsReferenceBaseline(long nativePointer); child.mOwner = null;
jni_YGNodeInsertSharedChild(mNativePointer, child.mNativePointer, i);
public boolean isReferenceBaseline() {
return jni_YGNodeIsReferenceBaseline(mNativePointer);
} }
private static native void jni_YGNodeSetOwner(long nativePointer, long newOwnerNativePointer); private static native void jni_YGNodeSetOwner(long nativePointer, long newOwnerNativePointer);

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.

View File

@@ -1,10 +1,3 @@
#
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the LICENSE
# file in the root directory of this source tree.
#
GROUP=com.facebook.yoga GROUP=com.facebook.yoga
POM_NAME=Yoga POM_NAME=Yoga
POM_DESCRIPTION=Java bindings to libyoga POM_DESCRIPTION=Java bindings to libyoga

View File

@@ -1,8 +1,9 @@
/** /*
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) 2018-present, Facebook, Inc.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.
*
*/ */
#include <fb/fbjni.h> #include <fb/fbjni.h>
#include <yoga/YGNode.h> #include <yoga/YGNode.h>
@@ -100,7 +101,7 @@ static void YGTransferLayoutOutputsRecursive(YGNodeRef root) {
const int PADDING = 2; const int PADDING = 2;
const int BORDER = 4; const int BORDER = 4;
int hasEdgeSetFlag = (int) obj->getFieldValue(edgeSetFlagField); int hasEdgeSetFlag = (int)obj->getFieldValue(edgeSetFlagField);
obj->setFieldValue(widthField, YGNodeLayoutGetWidth(root)); obj->setFieldValue(widthField, YGNodeLayoutGetWidth(root));
obj->setFieldValue(heightField, YGNodeLayoutGetHeight(root)); obj->setFieldValue(heightField, YGNodeLayoutGetHeight(root));
@@ -180,10 +181,8 @@ static inline YGConfigRef _jlong2YGConfigRef(jlong addr) {
return reinterpret_cast<YGConfigRef>(static_cast<intptr_t>(addr)); return reinterpret_cast<YGConfigRef>(static_cast<intptr_t>(addr));
} }
static YGNodeRef YGJNIOnNodeClonedFunc( static YGNodeRef
YGNodeRef oldNode, YGJNIOnNodeClonedFunc(YGNodeRef oldNode, YGNodeRef owner, int childIndex) {
YGNodeRef owner,
int childIndex) {
auto config = oldNode->getConfig(); auto config = oldNode->getConfig();
if (!config) { if (!config) {
return nullptr; return nullptr;
@@ -359,22 +358,19 @@ void jni_YGNodeInsertChild(
_jlong2YGNodeRef(nativePointer), _jlong2YGNodeRef(childPointer), index); _jlong2YGNodeRef(nativePointer), _jlong2YGNodeRef(childPointer), index);
} }
void jni_YGNodeInsertSharedChild(
jlong nativePointer,
jlong childPointer,
jint index) {
YGNodeInsertSharedChild(
_jlong2YGNodeRef(nativePointer), _jlong2YGNodeRef(childPointer), index);
}
void jni_YGNodeRemoveChild(jlong nativePointer, jlong childPointer) { void jni_YGNodeRemoveChild(jlong nativePointer, jlong childPointer) {
YGNodeRemoveChild( YGNodeRemoveChild(
_jlong2YGNodeRef(nativePointer), _jlong2YGNodeRef(childPointer)); _jlong2YGNodeRef(nativePointer), _jlong2YGNodeRef(childPointer));
} }
void jni_YGNodeSetIsReferenceBaseline(
jlong nativePointer,
jboolean isReferenceBaseline) {
YGNodeSetIsReferenceBaseline(
_jlong2YGNodeRef(nativePointer), isReferenceBaseline);
}
jboolean jni_YGNodeIsReferenceBaseline(jlong nativePointer) {
return YGNodeIsReferenceBaseline(_jlong2YGNodeRef(nativePointer));
}
void jni_YGNodeCalculateLayout( void jni_YGNodeCalculateLayout(
alias_ref<jclass>, alias_ref<jclass>,
jlong nativePointer, jlong nativePointer,
@@ -398,7 +394,7 @@ void jni_YGNodeMarkDirtyAndPropogateToDescendants(jlong nativePointer) {
} }
jboolean jni_YGNodeIsDirty(jlong nativePointer) { jboolean jni_YGNodeIsDirty(jlong nativePointer) {
return (jboolean) _jlong2YGNodeRef(nativePointer)->isDirty(); return (jboolean)_jlong2YGNodeRef(nativePointer)->isDirty();
} }
void jni_YGNodeSetHasMeasureFunc(jlong nativePointer, jboolean hasMeasureFunc) { void jni_YGNodeSetHasMeasureFunc(jlong nativePointer, jboolean hasMeasureFunc) {
@@ -428,7 +424,7 @@ struct JYogaValue : public JavaClass<JYogaValue> {
#define YG_NODE_JNI_STYLE_PROP(javatype, type, name) \ #define YG_NODE_JNI_STYLE_PROP(javatype, type, name) \
javatype jni_YGNodeStyleGet##name(jlong nativePointer) { \ javatype jni_YGNodeStyleGet##name(jlong nativePointer) { \
return (javatype) YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer)); \ return (javatype)YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer)); \
} \ } \
\ \
void jni_YGNodeStyleSet##name(jlong nativePointer, javatype value) { \ void jni_YGNodeStyleSet##name(jlong nativePointer, javatype value) { \
@@ -461,7 +457,7 @@ struct JYogaValue : public JavaClass<JYogaValue> {
#define YG_NODE_JNI_STYLE_EDGE_PROP(javatype, type, name) \ #define YG_NODE_JNI_STYLE_EDGE_PROP(javatype, type, name) \
javatype jni_YGNodeStyleGet##name(jlong nativePointer, jint edge) { \ javatype jni_YGNodeStyleGet##name(jlong nativePointer, jint edge) { \
return (javatype) YGNodeStyleGet##name( \ return (javatype)YGNodeStyleGet##name( \
_jlong2YGNodeRef(nativePointer), static_cast<YGEdge>(edge)); \ _jlong2YGNodeRef(nativePointer), static_cast<YGEdge>(edge)); \
} \ } \
\ \
@@ -651,111 +647,130 @@ jint jni_YGNodeGetInstanceCount() {
} }
#define YGMakeNativeMethod(name) makeNativeMethod(#name, name) #define YGMakeNativeMethod(name) makeNativeMethod(#name, name)
#define YGMakeCriticalNativeMethod(name) makeCriticalNativeMethod(#name, name) #define YGRealMakeCriticalNativeMethod(name) \
makeCriticalNativeMethod(#name, name)
#define YGWrapCriticalNativeMethodForRegularCall(name) \
makeNativeMethod( \
#name, \
::facebook::jni::detail::CriticalMethod<decltype(&name)>::call<&name>)
#define YGRegisterNatives(YGMakeCriticalNativeMethod) \
registerNatives( \
"com/facebook/yoga/YogaNode", \
{ \
YGMakeNativeMethod(jni_YGNodeNew), \
YGMakeNativeMethod(jni_YGNodeNewWithConfig), \
YGMakeCriticalNativeMethod(jni_YGNodeFree), \
YGMakeCriticalNativeMethod(jni_YGNodeReset), \
YGMakeCriticalNativeMethod(jni_YGNodeClearChildren), \
YGMakeCriticalNativeMethod(jni_YGNodeInsertChild), \
YGMakeCriticalNativeMethod(jni_YGNodeInsertSharedChild), \
YGMakeCriticalNativeMethod(jni_YGNodeRemoveChild), \
YGMakeNativeMethod(jni_YGNodeCalculateLayout), \
YGMakeCriticalNativeMethod(jni_YGNodeMarkDirty), \
YGMakeCriticalNativeMethod( \
jni_YGNodeMarkDirtyAndPropogateToDescendants), \
YGMakeCriticalNativeMethod(jni_YGNodeIsDirty), \
YGMakeCriticalNativeMethod(jni_YGNodeSetHasMeasureFunc), \
YGMakeCriticalNativeMethod(jni_YGNodeSetHasBaselineFunc), \
YGMakeCriticalNativeMethod(jni_YGNodeCopyStyle), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetDirection), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetDirection), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetFlexDirection), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexDirection), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetJustifyContent), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetJustifyContent), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetAlignItems), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetAlignItems), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetAlignSelf), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetAlignSelf), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetAlignContent), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetAlignContent), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetPositionType), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPositionType), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexWrap), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetOverflow), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetOverflow), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetDisplay), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetDisplay), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlex), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetFlexGrow), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexGrow), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetFlexShrink), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexShrink), \
YGMakeNativeMethod(jni_YGNodeStyleGetFlexBasis), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexBasis), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexBasisPercent), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexBasisAuto), \
YGMakeNativeMethod(jni_YGNodeStyleGetMargin), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMargin), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMarginPercent), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMarginAuto), \
YGMakeNativeMethod(jni_YGNodeStyleGetPadding), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPadding), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPaddingPercent), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetBorder), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetBorder), \
YGMakeNativeMethod(jni_YGNodeStyleGetPosition), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPosition), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPositionPercent), \
YGMakeNativeMethod(jni_YGNodeStyleGetWidth), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetWidth), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetWidthPercent), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetWidthAuto), \
YGMakeNativeMethod(jni_YGNodeStyleGetHeight), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetHeight), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetHeightPercent), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetHeightAuto), \
YGMakeNativeMethod(jni_YGNodeStyleGetMinWidth), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMinWidth), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMinWidthPercent), \
YGMakeNativeMethod(jni_YGNodeStyleGetMinHeight), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMinHeight), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMinHeightPercent), \
YGMakeNativeMethod(jni_YGNodeStyleGetMaxWidth), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMaxWidth), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMaxWidthPercent), \
YGMakeNativeMethod(jni_YGNodeStyleGetMaxHeight), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMaxHeight), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMaxHeightPercent), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetAspectRatio), \
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetAspectRatio), \
YGMakeCriticalNativeMethod(jni_YGNodeGetInstanceCount), \
YGMakeCriticalNativeMethod(jni_YGNodePrint), \
YGMakeNativeMethod(jni_YGNodeClone), \
YGMakeCriticalNativeMethod(jni_YGNodeSetOwner), \
}); \
registerNatives( \
"com/facebook/yoga/YogaConfig", \
{ \
YGMakeNativeMethod(jni_YGConfigNew), \
YGMakeNativeMethod(jni_YGConfigFree), \
YGMakeNativeMethod(jni_YGConfigSetExperimentalFeatureEnabled), \
YGMakeNativeMethod(jni_YGConfigSetUseWebDefaults), \
YGMakeNativeMethod(jni_YGConfigSetPrintTreeFlag), \
YGMakeNativeMethod(jni_YGConfigSetPointScaleFactor), \
YGMakeNativeMethod(jni_YGConfigSetUseLegacyStretchBehaviour), \
YGMakeNativeMethod(jni_YGConfigSetLogger), \
YGMakeNativeMethod(jni_YGConfigSetHasCloneNodeFunc), \
YGMakeNativeMethod( \
jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour), \
});
void jni_bindNativeMethods(alias_ref<jclass>, jboolean useFastCall) {
if (useFastCall) {
YGRegisterNatives(YGRealMakeCriticalNativeMethod);
} else {
YGRegisterNatives(YGWrapCriticalNativeMethodForRegularCall);
}
}
jint JNI_OnLoad(JavaVM* vm, void*) { jint JNI_OnLoad(JavaVM* vm, void*) {
return initialize(vm, [] { return initialize(vm, [] {
registerNatives( registerNatives(
"com/facebook/yoga/YogaNode", "com/facebook/yoga/YogaJNI",
{ {
YGMakeNativeMethod(jni_YGNodeNew), YGMakeNativeMethod(jni_bindNativeMethods),
YGMakeNativeMethod(jni_YGNodeNewWithConfig),
YGMakeCriticalNativeMethod(jni_YGNodeFree),
YGMakeCriticalNativeMethod(jni_YGNodeReset),
YGMakeCriticalNativeMethod(jni_YGNodeClearChildren),
YGMakeCriticalNativeMethod(jni_YGNodeInsertChild),
YGMakeCriticalNativeMethod(jni_YGNodeRemoveChild),
YGMakeCriticalNativeMethod(jni_YGNodeSetIsReferenceBaseline),
YGMakeCriticalNativeMethod(jni_YGNodeIsReferenceBaseline),
YGMakeNativeMethod(jni_YGNodeCalculateLayout),
YGMakeCriticalNativeMethod(jni_YGNodeMarkDirty),
YGMakeCriticalNativeMethod(
jni_YGNodeMarkDirtyAndPropogateToDescendants),
YGMakeCriticalNativeMethod(jni_YGNodeIsDirty),
YGMakeCriticalNativeMethod(jni_YGNodeSetHasMeasureFunc),
YGMakeCriticalNativeMethod(jni_YGNodeSetHasBaselineFunc),
YGMakeCriticalNativeMethod(jni_YGNodeCopyStyle),
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetDirection),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetDirection),
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetFlexDirection),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexDirection),
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetJustifyContent),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetJustifyContent),
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetAlignItems),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetAlignItems),
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetAlignSelf),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetAlignSelf),
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetAlignContent),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetAlignContent),
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetPositionType),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPositionType),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexWrap),
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetOverflow),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetOverflow),
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetDisplay),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetDisplay),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlex),
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetFlexGrow),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexGrow),
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetFlexShrink),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexShrink),
YGMakeNativeMethod(jni_YGNodeStyleGetFlexBasis),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexBasis),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexBasisPercent),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexBasisAuto),
YGMakeNativeMethod(jni_YGNodeStyleGetMargin),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMargin),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMarginPercent),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMarginAuto),
YGMakeNativeMethod(jni_YGNodeStyleGetPadding),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPadding),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPaddingPercent),
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetBorder),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetBorder),
YGMakeNativeMethod(jni_YGNodeStyleGetPosition),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPosition),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPositionPercent),
YGMakeNativeMethod(jni_YGNodeStyleGetWidth),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetWidth),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetWidthPercent),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetWidthAuto),
YGMakeNativeMethod(jni_YGNodeStyleGetHeight),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetHeight),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetHeightPercent),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetHeightAuto),
YGMakeNativeMethod(jni_YGNodeStyleGetMinWidth),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMinWidth),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMinWidthPercent),
YGMakeNativeMethod(jni_YGNodeStyleGetMinHeight),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMinHeight),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMinHeightPercent),
YGMakeNativeMethod(jni_YGNodeStyleGetMaxWidth),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMaxWidth),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMaxWidthPercent),
YGMakeNativeMethod(jni_YGNodeStyleGetMaxHeight),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMaxHeight),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMaxHeightPercent),
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetAspectRatio),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetAspectRatio),
YGMakeCriticalNativeMethod(jni_YGNodeGetInstanceCount),
YGMakeCriticalNativeMethod(jni_YGNodePrint),
YGMakeNativeMethod(jni_YGNodeClone),
YGMakeCriticalNativeMethod(jni_YGNodeSetOwner),
});
registerNatives(
"com/facebook/yoga/YogaConfig",
{
YGMakeNativeMethod(jni_YGConfigNew),
YGMakeNativeMethod(jni_YGConfigFree),
YGMakeNativeMethod(jni_YGConfigSetExperimentalFeatureEnabled),
YGMakeNativeMethod(jni_YGConfigSetUseWebDefaults),
YGMakeNativeMethod(jni_YGConfigSetPrintTreeFlag),
YGMakeNativeMethod(jni_YGConfigSetPointScaleFactor),
YGMakeNativeMethod(jni_YGConfigSetUseLegacyStretchBehaviour),
YGMakeNativeMethod(jni_YGConfigSetLogger),
YGMakeNativeMethod(jni_YGConfigSetHasCloneNodeFunc),
YGMakeNativeMethod(
jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour),
}); });
}); });
} }

View File

@@ -1,8 +1 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
apply plugin: 'java' apply plugin: 'java'

View File

@@ -1,122 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.yoga;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@RunWith(Parameterized.class)
public class YGAlignBaselineTest {
@Parameterized.Parameters(name = "{0}")
public static Iterable<TestParametrization.NodeFactory> nodeFactories() {
return TestParametrization.nodeFactories();
}
@Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory;
private YogaBaselineFunction getBaselineFunc() {
return new YogaBaselineFunction() {
@Override
public float baseline(YogaNode node, float width, float height) {
return height / 2;
}
};
}
@Test
public void test_align_baseline_parent_using_child_in_column_as_reference() {
YogaConfig config = new YogaConfig();
final YogaNode root = createYGNode(config, YogaFlexDirection.ROW, 1000f, 1000f, true);
final YogaNode root_child0 = createYGNode(config, YogaFlexDirection.COLUMN, 500f, 600f, false);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createYGNode(config, YogaFlexDirection.COLUMN, 500f, 800f, false);
root.addChildAt(root_child1, 1);
final YogaNode root_child1_child0 =
createYGNode(config, YogaFlexDirection.COLUMN, 500f, 300f, false);
root_child1.addChildAt(root_child1_child0, 0);
final YogaNode root_child1_child1 =
createYGNode(config, YogaFlexDirection.COLUMN, 500f, 400f, false);
root_child1_child1.setBaselineFunction(getBaselineFunc());
root_child1_child1.setIsReferenceBaseline(true);
root_child1.addChildAt(root_child1_child1, 1);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(500f, root_child1.getLayoutX(), 0.0f);
assertEquals(100f, root_child1.getLayoutY(), 0.0f);
assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f);
assertEquals(0f, root_child1_child1.getLayoutX(), 0.0f);
assertEquals(300f, root_child1_child1.getLayoutY(), 0.0f);
}
@Test
public void test_align_baseline_parent_using_child_in_row_as_reference() {
YogaConfig config = new YogaConfig();
final YogaNode root = createYGNode(config, YogaFlexDirection.ROW, 1000f, 1000f, true);
final YogaNode root_child0 = createYGNode(config, YogaFlexDirection.COLUMN, 500f, 600f, false);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createYGNode(config, YogaFlexDirection.ROW, 500f, 800f, true);
root.addChildAt(root_child1, 1);
final YogaNode root_child1_child0 =
createYGNode(config, YogaFlexDirection.COLUMN, 500f, 500f, false);
root_child1.addChildAt(root_child1_child0, 0);
final YogaNode root_child1_child1 =
createYGNode(config, YogaFlexDirection.COLUMN, 500f, 400f, false);
root_child1_child1.setBaselineFunction(getBaselineFunc());
root_child1_child1.setIsReferenceBaseline(true);
root_child1.addChildAt(root_child1_child1, 1);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(500f, root_child1.getLayoutX(), 0.0f);
assertEquals(100f, root_child1.getLayoutY(), 0.0f);
assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f);
assertEquals(500f, root_child1_child1.getLayoutX(), 0.0f);
assertEquals(300f, root_child1_child1.getLayoutY(), 0.0f);
}
private YogaNode createYGNode(
YogaConfig config,
YogaFlexDirection flexDirection,
float width,
float height,
boolean alignBaseline) {
YogaNode node = mNodeFactory.create(config);
node.setFlexDirection(flexDirection);
node.setWidth(width);
node.setHeight(height);
if (alignBaseline) {
node.setAlignItems(YogaAlign.BASELINE);
}
return node;
}
}

View File

@@ -4,6 +4,7 @@
* This source code is licensed under the MIT license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGFlexTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGFlexTest.html
package com.facebook.yoga; package com.facebook.yoga;
@@ -76,121 +77,6 @@ public class YGFlexTest {
assertEquals(25f, root_child1.getLayoutHeight(), 0.0f); assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
} }
@Test
public void test_flex_shrink_flex_grow_row() {
YogaConfig config = new YogaConfig();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(500f);
root.setHeight(500f);
final YogaNode root_child0 = createNode(config);
root_child0.setFlexShrink(1f);
root_child0.setWidth(500f);
root_child0.setHeight(100f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setFlexShrink(1f);
root_child1.setWidth(500f);
root_child1.setHeight(100f);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(500f, root.getLayoutWidth(), 0.0f);
assertEquals(500f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(250f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(250f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(250f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(500f, root.getLayoutWidth(), 0.0f);
assertEquals(500f, root.getLayoutHeight(), 0.0f);
assertEquals(250f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(250f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(250f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
}
@Test
public void test_flex_shrink_flex_grow_child_flex_shrink_other_child() {
YogaConfig config = new YogaConfig();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(500f);
root.setHeight(500f);
final YogaNode root_child0 = createNode(config);
root_child0.setFlexShrink(1f);
root_child0.setWidth(500f);
root_child0.setHeight(100f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setFlexGrow(1f);
root_child1.setFlexShrink(1f);
root_child1.setWidth(500f);
root_child1.setHeight(100f);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(500f, root.getLayoutWidth(), 0.0f);
assertEquals(500f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(250f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(250f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(250f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(500f, root.getLayoutWidth(), 0.0f);
assertEquals(500f, root.getLayoutHeight(), 0.0f);
assertEquals(250f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(250f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(250f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
}
@Test @Test
public void test_flex_basis_flex_grow_row() { public void test_flex_basis_flex_grow_row() {
YogaConfig config = new YogaConfig(); YogaConfig config = new YogaConfig();

View File

@@ -4,6 +4,7 @@
* This source code is licensed under the MIT license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGJustifyContentTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGJustifyContentTest.html
package com.facebook.yoga; package com.facebook.yoga;
@@ -995,158 +996,6 @@ public class YGJustifyContentTest {
assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
} }
@Test
public void test_justify_content_min_width_with_padding_child_width_greater_than_parent() {
YogaConfig config = new YogaConfig();
final YogaNode root = createNode(config);
root.setAlignContent(YogaAlign.STRETCH);
root.setWidth(1000f);
root.setHeight(1584f);
final YogaNode root_child0 = createNode(config);
root_child0.setFlexDirection(YogaFlexDirection.ROW);
root_child0.setAlignContent(YogaAlign.STRETCH);
root.addChildAt(root_child0, 0);
final YogaNode root_child0_child0 = createNode(config);
root_child0_child0.setFlexDirection(YogaFlexDirection.ROW);
root_child0_child0.setJustifyContent(YogaJustify.CENTER);
root_child0_child0.setAlignContent(YogaAlign.STRETCH);
root_child0_child0.setPadding(YogaEdge.LEFT, 100);
root_child0_child0.setPadding(YogaEdge.RIGHT, 100);
root_child0_child0.setMinWidth(400f);
root_child0.addChildAt(root_child0_child0, 0);
final YogaNode root_child0_child0_child0 = createNode(config);
root_child0_child0_child0.setFlexDirection(YogaFlexDirection.ROW);
root_child0_child0_child0.setAlignContent(YogaAlign.STRETCH);
root_child0_child0_child0.setWidth(300f);
root_child0_child0_child0.setHeight(100f);
root_child0_child0.addChildAt(root_child0_child0_child0, 0);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(1000f, root.getLayoutWidth(), 0.0f);
assertEquals(1584f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(1000f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(500f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(100f, root_child0_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f);
assertEquals(300f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(1000f, root.getLayoutWidth(), 0.0f);
assertEquals(1584f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(1000f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(500f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(500f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(100f, root_child0_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f);
assertEquals(300f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
}
@Test
public void test_justify_content_min_width_with_padding_child_width_lower_than_parent() {
YogaConfig config = new YogaConfig();
final YogaNode root = createNode(config);
root.setAlignContent(YogaAlign.STRETCH);
root.setWidth(1080f);
root.setHeight(1584f);
final YogaNode root_child0 = createNode(config);
root_child0.setFlexDirection(YogaFlexDirection.ROW);
root_child0.setAlignContent(YogaAlign.STRETCH);
root.addChildAt(root_child0, 0);
final YogaNode root_child0_child0 = createNode(config);
root_child0_child0.setFlexDirection(YogaFlexDirection.ROW);
root_child0_child0.setJustifyContent(YogaJustify.CENTER);
root_child0_child0.setAlignContent(YogaAlign.STRETCH);
root_child0_child0.setPadding(YogaEdge.LEFT, 100);
root_child0_child0.setPadding(YogaEdge.RIGHT, 100);
root_child0_child0.setMinWidth(400f);
root_child0.addChildAt(root_child0_child0, 0);
final YogaNode root_child0_child0_child0 = createNode(config);
root_child0_child0_child0.setFlexDirection(YogaFlexDirection.ROW);
root_child0_child0_child0.setAlignContent(YogaAlign.STRETCH);
root_child0_child0_child0.setWidth(199f);
root_child0_child0_child0.setHeight(100f);
root_child0_child0.addChildAt(root_child0_child0_child0, 0);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(1080f, root.getLayoutWidth(), 0.0f);
assertEquals(1584f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(1080f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(400f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(101f, root_child0_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f);
assertEquals(199f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(1080f, root.getLayoutWidth(), 0.0f);
assertEquals(1584f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(1080f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(680f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(400f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(101f, root_child0_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f);
assertEquals(199f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
}
private YogaNode createNode(YogaConfig config) { private YogaNode createNode(YogaConfig config) {
return mNodeFactory.create(config); return mNodeFactory.create(config);
} }

View File

@@ -1,8 +1,9 @@
/** /*
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.
*
*/ */
package com.facebook.yoga; package com.facebook.yoga;
@@ -279,6 +280,29 @@ public class YogaNodeTest {
assertEquals(1, child.getChildCount()); assertEquals(1, child.getChildCount());
} }
@Test
public void testAddSharedChildCloneWithNewChildren() throws Exception {
YogaConfig config = new YogaConfig();
YogaNode root = createNode(config);
YogaNode child = createNode(config);
YogaNode grandChild = createNode(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);
@@ -362,62 +386,6 @@ public class YogaNodeTest {
assertFalse(root.getDoesLegacyStretchFlagAffectsLayout()); assertFalse(root.getDoesLegacyStretchFlagAffectsLayout());
} }
@Test
public void initiallyHasNewLayout() {
YogaNode root = createNode();
assertTrue(root.hasNewLayout());
}
@Test
public void initialLayoutCanBeMarkedSeen() {
YogaNode root = createNode();
root.markLayoutSeen();
assertFalse(root.hasNewLayout());
}
@Test
public void calculatingLayoutMarksLayoutAsUnseen() {
YogaNode root = createNode();
root.markLayoutSeen();
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertTrue(root.hasNewLayout());
}
@Test
public void calculatedLayoutCanBeMarkedSeen() {
YogaNode root = createNode();
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
root.markLayoutSeen();
assertFalse(root.hasNewLayout());
}
@Test
public void recalculatingLayoutDoesMarkAsUnseen() {
YogaNode root = createNode();
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
root.markLayoutSeen();
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertTrue(root.hasNewLayout());
}
@Test
public void resetAlsoResetsLayoutSeen() {
YogaNode root = createNode();
root.markLayoutSeen();
root.reset();
assertTrue(root.hasNewLayout());
}
@Test
public void directionIsPassedThrough() {
YogaNode root = createNode();
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(root.getLayoutDirection(), YogaDirection.RTL);
}
private YogaNode createNode() { private YogaNode createNode() {
return mNodeFactory.create(); return mNodeFactory.create();
} }

View File

@@ -1,9 +1,10 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the
* file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#include <yoga/Yoga.h> #include <yoga/Yoga.h>
#include "./Config.hh" #include "./Config.hh"

View File

@@ -1,9 +1,10 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the
* file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#include <algorithm> #include <algorithm>
#include <yoga/Yoga.h> #include <yoga/Yoga.h>
@@ -23,13 +24,6 @@ static YGSize globalMeasureFunc(YGNodeRef nodeRef, float width, YGMeasureMode wi
return ygSize; return ygSize;
} }
static void globalDirtiedFunc(YGNodeRef nodeRef)
{
Node const & node = *reinterpret_cast<Node const *>(YGNodeGetContext(nodeRef));
node.callDirtiedFunc();
}
/* static */ Node * Node::createDefault(void) /* static */ Node * Node::createDefault(void)
{ {
return new Node(nullptr); return new Node(nullptr);
@@ -53,7 +47,6 @@ static void globalDirtiedFunc(YGNodeRef nodeRef)
Node::Node(Config * config) Node::Node(Config * config)
: m_node(config != nullptr ? YGNodeNewWithConfig(config->m_config) : YGNodeNew()) : m_node(config != nullptr ? YGNodeNewWithConfig(config->m_config) : YGNodeNew())
, m_measureFunc(nullptr) , m_measureFunc(nullptr)
, m_dirtiedFunc(nullptr)
{ {
YGNodeSetContext(m_node, reinterpret_cast<void *>(this)); YGNodeSetContext(m_node, reinterpret_cast<void *>(this));
} }
@@ -66,7 +59,6 @@ Node::~Node(void)
void Node::reset(void) void Node::reset(void)
{ {
m_measureFunc.reset(nullptr); m_measureFunc.reset(nullptr);
m_dirtiedFunc.reset(nullptr);
YGNodeReset(m_node); YGNodeReset(m_node);
} }
@@ -261,10 +253,6 @@ void Node::setPaddingPercent(int edge, double padding)
YGNodeStyleSetPaddingPercent(m_node, static_cast<YGEdge>(edge), padding); YGNodeStyleSetPaddingPercent(m_node, static_cast<YGEdge>(edge), padding);
} }
void Node::setIsReferenceBaseline(bool isReferenceBaseline) {
YGNodeSetIsReferenceBaseline(m_node, isReferenceBaseline);
}
int Node::getPositionType(void) const int Node::getPositionType(void) const
{ {
return YGNodeStyleGetPositionType(m_node); return YGNodeStyleGetPositionType(m_node);
@@ -380,10 +368,6 @@ Value Node::getPadding(int edge) const
return Value::fromYGValue(YGNodeStyleGetPadding(m_node, static_cast<YGEdge>(edge))); return Value::fromYGValue(YGNodeStyleGetPadding(m_node, static_cast<YGEdge>(edge)));
} }
bool Node::isReferenceBaseline() {
return YGNodeIsReferenceBaseline(m_node);
}
void Node::insertChild(Node * child, unsigned index) void Node::insertChild(Node * child, unsigned index)
{ {
YGNodeInsertChild(m_node, child->m_node, index); YGNodeInsertChild(m_node, child->m_node, index);
@@ -438,24 +422,6 @@ Size Node::callMeasureFunc(double width, int widthMode, double height, int heigh
return m_measureFunc->call<Size>(width, widthMode, height, heightMode); return m_measureFunc->call<Size>(width, widthMode, height, heightMode);
} }
void Node::setDirtiedFunc(nbind::cbFunction & dirtiedFunc)
{
m_dirtiedFunc.reset(new nbind::cbFunction(dirtiedFunc));
YGNodeSetDirtiedFunc(m_node, &globalDirtiedFunc);
}
void Node::unsetDirtiedFunc(void) {
m_dirtiedFunc.reset(nullptr);
YGNodeSetDirtiedFunc(m_node, nullptr);
}
void Node::callDirtiedFunc(void) const
{
m_dirtiedFunc->call<void>();
}
void Node::markDirty(void) void Node::markDirty(void)
{ {
YGNodeMarkDirty(m_node); YGNodeMarkDirty(m_node);

View File

@@ -161,15 +161,6 @@ class Node {
Size callMeasureFunc(double width, int widthMode, double height, int heightMode) const; Size callMeasureFunc(double width, int widthMode, double height, int heightMode) const;
public: // Dirtied func mutators
void setDirtiedFunc(nbind::cbFunction & dirtiedFunc);
void unsetDirtiedFunc(void);
public: // Dirtied func inspectors
void callDirtiedFunc(void) const;
public: // Dirtiness accessors public: // Dirtiness accessors
void markDirty(void); void markDirty(void);
@@ -196,12 +187,10 @@ class Node {
double getComputedBorder(int edge) const; double getComputedBorder(int edge) const;
double getComputedPadding(int edge) const; double getComputedPadding(int edge) const;
public: private:
void setIsReferenceBaseline(bool isReferenceBaseline);
bool isReferenceBaseline();
YGNodeRef m_node; YGNodeRef m_node;
std::unique_ptr<nbind::cbFunction> m_measureFunc; std::unique_ptr<nbind::cbFunction> m_measureFunc;
std::unique_ptr<nbind::cbFunction> m_dirtiedFunc;
}; };

View File

@@ -1,10 +1,3 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#pragma once #pragma once
#include <yoga/Yoga.h> #include <yoga/Yoga.h>

View File

@@ -1,9 +1,10 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the
* file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#include <yoga/Yoga.h> #include <yoga/Yoga.h>
#include "./global.hh" #include "./global.hh"

View File

@@ -1,9 +1,10 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the
* file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#include <yoga/Yoga.h> #include <yoga/Yoga.h>
#include "./Node.hh" #include "./Node.hh"
@@ -149,15 +150,9 @@ NBIND_CLASS(Node)
method(getParent); method(getParent);
method(getChild); method(getChild);
method(isReferenceBaseline);
method(setIsReferenceBaseline);
method(setMeasureFunc); method(setMeasureFunc);
method(unsetMeasureFunc); method(unsetMeasureFunc);
method(setDirtiedFunc);
method(unsetDirtiedFunc);
method(markDirty); method(markDirty);
method(isDirty); method(isDirty);

View File

@@ -1,156 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var Yoga = Yoga || require("../../sources/entry-" + process.env.TEST_ENTRY);
it("align_baseline_parent_using_child_in_column_as_reference", function () {
var config = Yoga.Config.create();
try {
var root = Yoga.Node.create(config);
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
root.setWidth(1000);
root.setHeight(1000);
root.setAlignItems(Yoga.ALIGN_BASELINE);
var root_child0 = Yoga.Node.create(config);
root_child0.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN);
root_child0.setWidth(500);
root_child0.setHeight(600);
root.insertChild(root_child0, 0);
var root_child1 = Yoga.Node.create(config);
root_child1.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN);
root_child1.setWidth(500);
root_child1.setHeight(800);
root.insertChild(root_child1, 1);
var root_child1_child0 = Yoga.Node.create(config);
root_child1_child0.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN);
root_child1_child0.setWidth(500);
root_child1_child0.setHeight(300);
root_child1.insertChild(root_child1_child0, 0);
var root_child1_child1 = Yoga.Node.create(config);
root_child1_child1.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN);
root_child1_child1.setWidth(500);
root_child1_child1.setHeight(400);
root_child1_child1.setIsReferenceBaseline(true);
root_child1.insertChild(root_child1_child1, 1);
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
console.assert(0 === root_child0.getComputedLeft(),
"0 === root_child0.getComputedLeft() (" +
root_child0.getComputedLeft() + ")");
console.assert(100 === root_child0.getComputedTop(),
"100 === root_child0.getComputedTop() (" +
root_child0.getComputedTop() + ")");
console.assert(500 === root_child1.getComputedLeft(),
"500 === root_child1.getComputedLeft() (" +
root_child1.getComputedLeft() + ")");
console.assert(0 === root_child1.getComputedTop(),
"0 === root_child1.getComputedTop() (" +
root_child1.getComputedTop() + ")");
console.assert(0 === root_child1_child0.getComputedLeft(),
"0 === root_child1_child0.getComputedLeft() (" +
root_child1_child0.getComputedLeft() + ")");
console.assert(0 === root_child1_child0.getComputedTop(),
"0 === root_child1_child0.getComputedTop() (" +
root_child1_child0.getComputedTop() + ")");
console.assert(0 === root_child1_child1.getComputedLeft(),
"0 === root_child1_child1.getComputedLeft() (" +
root_child1_child1.getComputedLeft() + ")");
console.assert(300 === root_child1_child1.getComputedTop(),
"300 === root_child1_child1.getComputedTop() (" +
root_child1_child1.getComputedTop() + ")");
} finally {
if (typeof root !== "undefined") {
root.freeRecursive();
}
config.free();
}
});
it("align_baseline_parent_using_child_in_row_as_reference", function () {
var config = Yoga.Config.create();
try {
var root = Yoga.Node.create(config);
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
root.setWidth(1000);
root.setHeight(1000);
root.setAlignItems(Yoga.ALIGN_BASELINE);
var root_child0 = Yoga.Node.create(config);
root_child0.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN);
root_child0.setWidth(500);
root_child0.setHeight(600);
root.insertChild(root_child0, 0);
var root_child1 = Yoga.Node.create(config);
root_child1.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
root_child1.setWidth(500);
root_child1.setHeight(800);
root.insertChild(root_child1, 1);
var root_child1_child0 = Yoga.Node.create(config);
root_child1_child0.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN);
root_child1_child0.setWidth(500);
root_child1_child0.setHeight(500);
root_child1.insertChild(root_child1_child0, 0);
var root_child1_child1 = Yoga.Node.create(config);
root_child1_child1.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN);
root_child1_child1.setWidth(500);
root_child1_child1.setHeight(400);
root_child1_child1.setIsReferenceBaseline(true);
root_child1.insertChild(root_child1_child1, 1);
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
console.assert(0 === root_child0.getComputedLeft(),
"0 === root_child0.getComputedLeft() (" +
root_child0.getComputedLeft() + ")");
console.assert(0 === root_child0.getComputedTop(),
"0 === root_child0.getComputedTop() (" +
root_child0.getComputedTop() + ")");
console.assert(500 === root_child1.getComputedLeft(),
"500 === root_child1.getComputedLeft() (" +
root_child1.getComputedLeft() + ")");
console.assert(200 === root_child1.getComputedTop(),
"200 === root_child1.getComputedTop() (" +
root_child1.getComputedTop() + ")");
console.assert(0 === root_child1_child0.getComputedLeft(),
"0 === root_child1_child0.getComputedLeft() (" +
root_child1_child0.getComputedLeft() + ")");
console.assert(0 === root_child1_child0.getComputedTop(),
"0 === root_child1_child0.getComputedTop() (" +
root_child1_child0.getComputedTop() + ")");
console.assert(500 === root_child1_child1.getComputedLeft(),
"500 === root_child1_child1.getComputedLeft() (" +
root_child1_child1.getComputedLeft() + ")");
console.assert(0 === root_child1_child1.getComputedTop(),
"0 === root_child1_child1.getComputedTop() (" +
root_child1_child1.getComputedTop() + ")");
} finally {
if (typeof root !== "undefined") {
root.freeRecursive();
}
config.free();
}
});

View File

@@ -1,168 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var Yoga = Yoga || require("../../sources/entry-" + process.env.TEST_ENTRY);
it("dirtied", function() {
var root = Yoga.Node.create();
root.setAlignItems(Yoga.ALIGN_FLEX_START);
root.setWidth(100);
root.setHeight(100);
root.calculateLayout(undefined, undefined, Yoga.DIRECTION_LTR);
let dirtied = 0;
root.setDirtiedFunc(function() { dirtied++; });
// only nodes with a measure function can be marked dirty
root.setMeasureFunc(function() {});
console.assert(0 === dirtied, "0 === dirtied");
// dirtied func MUST be called in case of explicit dirtying.
root.markDirty();
console.assert(1 === dirtied, "1 === dirtied");
// dirtied func MUST be called ONCE.
root.markDirty();
console.assert(1 === dirtied, "1 === dirtied");
if (typeof root !== "undefined")
root.freeRecursive();
typeof gc !== "undefined" && gc();
console.assert(0 === Yoga.getInstanceCount(), "0 === Yoga.getInstanceCount() (" + Yoga.getInstanceCount() + ")");
});
it("dirtied_propagation", function() {
var root = Yoga.Node.create();
root.setAlignItems(Yoga.ALIGN_FLEX_START);
root.setWidth(100);
root.setHeight(100);
var root_child0 = Yoga.Node.create();
root_child0.setAlignItems(Yoga.ALIGN_FLEX_START);
root_child0.setWidth(50);
root_child0.setHeight(20);
root_child0.setMeasureFunc(function() {});
root.insertChild(root_child0, 0);
var root_child1 = Yoga.Node.create();
root_child1.setAlignItems(Yoga.ALIGN_FLEX_START);
root_child1.setWidth(50);
root_child1.setHeight(20);
root.insertChild(root_child1, 0);
root.calculateLayout(undefined, undefined, Yoga.DIRECTION_LTR);
let dirtied = 0;
root.setDirtiedFunc(function() { dirtied++; });
console.assert(0 === dirtied, "0 === dirtied");
// dirtied func MUST be called for the first time.
root_child0.markDirty();
console.assert(1 === dirtied, "1 === dirtied");
// dirtied func must NOT be called for the second time.
root_child0.markDirty();
console.assert(1 === dirtied, "1 === dirtied");
if (typeof root !== "undefined")
root.freeRecursive();
typeof gc !== "undefined" && gc();
console.assert(0 === Yoga.getInstanceCount(), "0 === Yoga.getInstanceCount() (" + Yoga.getInstanceCount() + ")");
});
it("dirtied_hierarchy", function() {
var root = Yoga.Node.create();
root.setAlignItems(Yoga.ALIGN_FLEX_START);
root.setWidth(100);
root.setHeight(100);
var root_child0 = Yoga.Node.create();
root_child0.setAlignItems(Yoga.ALIGN_FLEX_START);
root_child0.setWidth(50);
root_child0.setHeight(20);
root_child0.setMeasureFunc(function() {});
root.insertChild(root_child0, 0);
var root_child1 = Yoga.Node.create();
root_child1.setAlignItems(Yoga.ALIGN_FLEX_START);
root_child1.setWidth(50);
root_child1.setHeight(20);
root_child1.setMeasureFunc(function() {});
root.insertChild(root_child1, 0);
root.calculateLayout(undefined, undefined, Yoga.DIRECTION_LTR);
let dirtied = 0;
root_child0.setDirtiedFunc(function() {
dirtied++;
});
console.assert(0 === dirtied, "0 === dirtied");
// dirtied func must NOT be called for descendants.
// NOTE: nodes without a measure function cannot be marked dirty manually,
// but nodes with a measure function can not have children.
// Update the width to dirty the node instead.
root.setWidth(110);
console.assert(0 === dirtied, "0 === dirtied");
// dirtied func MUST be called in case of explicit dirtying.
root_child0.markDirty();
console.assert(1 === dirtied, "1 === dirtied");
if (typeof root !== "undefined")
root.freeRecursive();
typeof gc !== "undefined" && gc();
console.assert(0 === Yoga.getInstanceCount(), "0 === Yoga.getInstanceCount() (" + Yoga.getInstanceCount() + ")");
});
it("dirtied_reset", function() {
var root = Yoga.Node.create();
root.setAlignItems(Yoga.ALIGN_FLEX_START);
root.setWidth(100);
root.setHeight(100);
root.setMeasureFunc(function() {});
root.calculateLayout(undefined, undefined, Yoga.DIRECTION_LTR);
let dirtied = 0;
root.setDirtiedFunc(function() {
dirtied++;
});
console.assert(0 === dirtied, "0 === dirtied");
// dirtied func MUST be called in case of explicit dirtying.
root.markDirty();
console.assert(1 === dirtied, "1 === dirtied");
// recalculate so the root is no longer dirty
root.calculateLayout(undefined, undefined, Yoga.DIRECTION_LTR);
root.reset();
root.setAlignItems(Yoga.ALIGN_FLEX_START);
root.setWidth(100);
root.setHeight(100);
root.setMeasureFunc(function() {});
root.markDirty();
// dirtied func must NOT be called after reset.
root.markDirty();
console.assert(1 === dirtied, "1 === dirtied");
if (typeof root !== "undefined")
root.freeRecursive();
typeof gc !== "undefined" && gc();
console.assert(0 === Yoga.getInstanceCount(), "0 === Yoga.getInstanceCount() (" + Yoga.getInstanceCount() + ")");
});

View File

@@ -66,129 +66,6 @@ it("flex_basis_flex_grow_column", function () {
config.free(); config.free();
} }
}); });
it("flex_shrink_flex_grow_row", function () {
var config = Yoga.Config.create();
try {
var root = Yoga.Node.create(config);
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
root.setWidth(500);
root.setHeight(500);
var root_child0 = Yoga.Node.create(config);
root_child0.setFlexShrink(1);
root_child0.setWidth(500);
root_child0.setHeight(100);
root.insertChild(root_child0, 0);
var root_child1 = Yoga.Node.create(config);
root_child1.setFlexShrink(1);
root_child1.setWidth(500);
root_child1.setHeight(100);
root.insertChild(root_child1, 1);
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
console.assert(500 === root.getComputedWidth(), "500 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
console.assert(500 === root.getComputedHeight(), "500 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
console.assert(250 === root_child0.getComputedWidth(), "250 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
console.assert(250 === root_child1.getComputedLeft(), "250 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
console.assert(250 === root_child1.getComputedWidth(), "250 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
console.assert(100 === root_child1.getComputedHeight(), "100 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
console.assert(500 === root.getComputedWidth(), "500 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
console.assert(500 === root.getComputedHeight(), "500 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
console.assert(250 === root_child0.getComputedLeft(), "250 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
console.assert(250 === root_child0.getComputedWidth(), "250 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
console.assert(250 === root_child1.getComputedWidth(), "250 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
console.assert(100 === root_child1.getComputedHeight(), "100 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
} finally {
if (typeof root !== "undefined") {
root.freeRecursive();
}
config.free();
}
});
it("flex_shrink_flex_grow_child_flex_shrink_other_child", function () {
var config = Yoga.Config.create();
try {
var root = Yoga.Node.create(config);
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
root.setWidth(500);
root.setHeight(500);
var root_child0 = Yoga.Node.create(config);
root_child0.setFlexShrink(1);
root_child0.setWidth(500);
root_child0.setHeight(100);
root.insertChild(root_child0, 0);
var root_child1 = Yoga.Node.create(config);
root_child1.setFlexGrow(1);
root_child1.setFlexShrink(1);
root_child1.setWidth(500);
root_child1.setHeight(100);
root.insertChild(root_child1, 1);
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
console.assert(500 === root.getComputedWidth(), "500 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
console.assert(500 === root.getComputedHeight(), "500 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
console.assert(250 === root_child0.getComputedWidth(), "250 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
console.assert(250 === root_child1.getComputedLeft(), "250 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
console.assert(250 === root_child1.getComputedWidth(), "250 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
console.assert(100 === root_child1.getComputedHeight(), "100 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
console.assert(500 === root.getComputedWidth(), "500 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
console.assert(500 === root.getComputedHeight(), "500 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
console.assert(250 === root_child0.getComputedLeft(), "250 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
console.assert(250 === root_child0.getComputedWidth(), "250 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
console.assert(250 === root_child1.getComputedWidth(), "250 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
console.assert(100 === root_child1.getComputedHeight(), "100 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
} finally {
if (typeof root !== "undefined") {
root.freeRecursive();
}
config.free();
}
});
it("flex_basis_flex_grow_row", function () { it("flex_basis_flex_grow_row", function () {
var config = Yoga.Config.create(); var config = Yoga.Config.create();

View File

@@ -1045,163 +1045,3 @@ it("justify_content_row_space_evenly", function () {
config.free(); config.free();
} }
}); });
it("justify_content_min_width_with_padding_child_width_greater_than_parent", function () {
var config = Yoga.Config.create();
try {
var root = Yoga.Node.create(config);
root.setAlignContent(Yoga.ALIGN_STRETCH);
root.setWidth(1000);
root.setHeight(1584);
var root_child0 = Yoga.Node.create(config);
root_child0.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
root_child0.setAlignContent(Yoga.ALIGN_STRETCH);
root.insertChild(root_child0, 0);
var root_child0_child0 = Yoga.Node.create(config);
root_child0_child0.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
root_child0_child0.setJustifyContent(Yoga.JUSTIFY_CENTER);
root_child0_child0.setAlignContent(Yoga.ALIGN_STRETCH);
root_child0_child0.setPadding(Yoga.EDGE_LEFT, 100);
root_child0_child0.setPadding(Yoga.EDGE_RIGHT, 100);
root_child0_child0.setMinWidth(400);
root_child0.insertChild(root_child0_child0, 0);
var root_child0_child0_child0 = Yoga.Node.create(config);
root_child0_child0_child0.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
root_child0_child0_child0.setAlignContent(Yoga.ALIGN_STRETCH);
root_child0_child0_child0.setWidth(300);
root_child0_child0_child0.setHeight(100);
root_child0_child0.insertChild(root_child0_child0_child0, 0);
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
console.assert(1000 === root.getComputedWidth(), "1000 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
console.assert(1584 === root.getComputedHeight(), "1584 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
console.assert(1000 === root_child0.getComputedWidth(), "1000 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
console.assert(0 === root_child0_child0.getComputedLeft(), "0 === root_child0_child0.getComputedLeft() (" + root_child0_child0.getComputedLeft() + ")");
console.assert(0 === root_child0_child0.getComputedTop(), "0 === root_child0_child0.getComputedTop() (" + root_child0_child0.getComputedTop() + ")");
console.assert(500 === root_child0_child0.getComputedWidth(), "500 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
console.assert(100 === root_child0_child0.getComputedHeight(), "100 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
console.assert(100 === root_child0_child0_child0.getComputedLeft(), "100 === root_child0_child0_child0.getComputedLeft() (" + root_child0_child0_child0.getComputedLeft() + ")");
console.assert(0 === root_child0_child0_child0.getComputedTop(), "0 === root_child0_child0_child0.getComputedTop() (" + root_child0_child0_child0.getComputedTop() + ")");
console.assert(300 === root_child0_child0_child0.getComputedWidth(), "300 === root_child0_child0_child0.getComputedWidth() (" + root_child0_child0_child0.getComputedWidth() + ")");
console.assert(100 === root_child0_child0_child0.getComputedHeight(), "100 === root_child0_child0_child0.getComputedHeight() (" + root_child0_child0_child0.getComputedHeight() + ")");
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
console.assert(1000 === root.getComputedWidth(), "1000 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
console.assert(1584 === root.getComputedHeight(), "1584 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
console.assert(1000 === root_child0.getComputedWidth(), "1000 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
console.assert(500 === root_child0_child0.getComputedLeft(), "500 === root_child0_child0.getComputedLeft() (" + root_child0_child0.getComputedLeft() + ")");
console.assert(0 === root_child0_child0.getComputedTop(), "0 === root_child0_child0.getComputedTop() (" + root_child0_child0.getComputedTop() + ")");
console.assert(500 === root_child0_child0.getComputedWidth(), "500 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
console.assert(100 === root_child0_child0.getComputedHeight(), "100 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
console.assert(100 === root_child0_child0_child0.getComputedLeft(), "100 === root_child0_child0_child0.getComputedLeft() (" + root_child0_child0_child0.getComputedLeft() + ")");
console.assert(0 === root_child0_child0_child0.getComputedTop(), "0 === root_child0_child0_child0.getComputedTop() (" + root_child0_child0_child0.getComputedTop() + ")");
console.assert(300 === root_child0_child0_child0.getComputedWidth(), "300 === root_child0_child0_child0.getComputedWidth() (" + root_child0_child0_child0.getComputedWidth() + ")");
console.assert(100 === root_child0_child0_child0.getComputedHeight(), "100 === root_child0_child0_child0.getComputedHeight() (" + root_child0_child0_child0.getComputedHeight() + ")");
} finally {
if (typeof root !== "undefined") {
root.freeRecursive();
}
config.free();
}
});
it("justify_content_min_width_with_padding_child_width_lower_than_parent", function () {
var config = Yoga.Config.create();
try {
var root = Yoga.Node.create(config);
root.setAlignContent(Yoga.ALIGN_STRETCH);
root.setWidth(1080);
root.setHeight(1584);
var root_child0 = Yoga.Node.create(config);
root_child0.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
root_child0.setAlignContent(Yoga.ALIGN_STRETCH);
root.insertChild(root_child0, 0);
var root_child0_child0 = Yoga.Node.create(config);
root_child0_child0.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
root_child0_child0.setJustifyContent(Yoga.JUSTIFY_CENTER);
root_child0_child0.setAlignContent(Yoga.ALIGN_STRETCH);
root_child0_child0.setPadding(Yoga.EDGE_LEFT, 100);
root_child0_child0.setPadding(Yoga.EDGE_RIGHT, 100);
root_child0_child0.setMinWidth(400);
root_child0.insertChild(root_child0_child0, 0);
var root_child0_child0_child0 = Yoga.Node.create(config);
root_child0_child0_child0.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
root_child0_child0_child0.setAlignContent(Yoga.ALIGN_STRETCH);
root_child0_child0_child0.setWidth(199);
root_child0_child0_child0.setHeight(100);
root_child0_child0.insertChild(root_child0_child0_child0, 0);
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
console.assert(1080 === root.getComputedWidth(), "1080 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
console.assert(1584 === root.getComputedHeight(), "1584 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
console.assert(1080 === root_child0.getComputedWidth(), "1080 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
console.assert(0 === root_child0_child0.getComputedLeft(), "0 === root_child0_child0.getComputedLeft() (" + root_child0_child0.getComputedLeft() + ")");
console.assert(0 === root_child0_child0.getComputedTop(), "0 === root_child0_child0.getComputedTop() (" + root_child0_child0.getComputedTop() + ")");
console.assert(400 === root_child0_child0.getComputedWidth(), "400 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
console.assert(100 === root_child0_child0.getComputedHeight(), "100 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
console.assert(101 === root_child0_child0_child0.getComputedLeft(), "101 === root_child0_child0_child0.getComputedLeft() (" + root_child0_child0_child0.getComputedLeft() + ")");
console.assert(0 === root_child0_child0_child0.getComputedTop(), "0 === root_child0_child0_child0.getComputedTop() (" + root_child0_child0_child0.getComputedTop() + ")");
console.assert(199 === root_child0_child0_child0.getComputedWidth(), "199 === root_child0_child0_child0.getComputedWidth() (" + root_child0_child0_child0.getComputedWidth() + ")");
console.assert(100 === root_child0_child0_child0.getComputedHeight(), "100 === root_child0_child0_child0.getComputedHeight() (" + root_child0_child0_child0.getComputedHeight() + ")");
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
console.assert(1080 === root.getComputedWidth(), "1080 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
console.assert(1584 === root.getComputedHeight(), "1584 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
console.assert(1080 === root_child0.getComputedWidth(), "1080 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
console.assert(680 === root_child0_child0.getComputedLeft(), "680 === root_child0_child0.getComputedLeft() (" + root_child0_child0.getComputedLeft() + ")");
console.assert(0 === root_child0_child0.getComputedTop(), "0 === root_child0_child0.getComputedTop() (" + root_child0_child0.getComputedTop() + ")");
console.assert(400 === root_child0_child0.getComputedWidth(), "400 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
console.assert(100 === root_child0_child0.getComputedHeight(), "100 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
console.assert(101 === root_child0_child0_child0.getComputedLeft(), "101 === root_child0_child0_child0.getComputedLeft() (" + root_child0_child0_child0.getComputedLeft() + ")");
console.assert(0 === root_child0_child0_child0.getComputedTop(), "0 === root_child0_child0_child0.getComputedTop() (" + root_child0_child0_child0.getComputedTop() + ")");
console.assert(199 === root_child0_child0_child0.getComputedWidth(), "199 === root_child0_child0_child0.getComputedWidth() (" + root_child0_child0_child0.getComputedWidth() + ")");
console.assert(100 === root_child0_child0_child0.getComputedHeight(), "100 === root_child0_child0_child0.getComputedHeight() (" + root_child0_child0_child0.getComputedHeight() + ")");
} finally {
if (typeof root !== "undefined") {
root.freeRecursive();
}
config.free();
}
});

View File

@@ -3,10 +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("//tools/build_defs:fb_native_wrapper.bzl", "fb_native")
load("//tools/build_defs/oss:yoga_defs.bzl", "YOGA_ROOTS") load("//tools/build_defs/oss:yoga_defs.bzl", "YOGA_ROOTS")
fb_native.android_prebuilt_aar( android_prebuilt_aar(
name = "appcompat", name = "appcompat",
aar = "appcompat-v7-24.2.1.aar", aar = "appcompat-v7-24.2.1.aar",
visibility = YOGA_ROOTS, visibility = YOGA_ROOTS,

View File

@@ -1,10 +1,3 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
android { android {

View File

@@ -1,9 +1,10 @@
/** /*
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the
* file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#include <cstdarg> #include <cstdarg>
#include <stdio.h> #include <stdio.h>

View File

@@ -1,9 +1,10 @@
/** /*
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the
* file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
/** @file ALog.h /** @file ALog.h
* *
* Very simple android only logging. Define LOG_TAG to enable the macros. * Very simple android only logging. Define LOG_TAG to enable the macros.

View File

@@ -1,9 +1,10 @@
/** /*
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the
* file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#pragma once #pragma once
#include <atomic> #include <atomic>
#include <fb/assert.h> #include <fb/assert.h>

View File

@@ -1,9 +1,10 @@
/** /*
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the
* file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#pragma once #pragma once
#include <functional> #include <functional>
#include <string> #include <string>

View File

@@ -1,9 +1,10 @@
/** /*
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the
* file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#pragma once #pragma once
#include <cstring> #include <cstring>
#include <string> #include <string>

View File

@@ -1,9 +1,10 @@
/** /*
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the
* file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#pragma once #pragma once
#include <utility> #include <utility>
#include <fb/assert.h> #include <fb/assert.h>

View File

@@ -1,9 +1,10 @@
/** /*
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the
* file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#pragma once #pragma once
#include <fb/assert.h> #include <fb/assert.h>
#include <utility> #include <utility>

View File

@@ -1,9 +1,10 @@
/** /*
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the
* file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#pragma once #pragma once
#include <pthread.h> #include <pthread.h>

View File

@@ -1,9 +1,10 @@
/** /*
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the
* file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#ifndef FBASSERT_H #ifndef FBASSERT_H
#define FBASSERT_H #define FBASSERT_H

View File

@@ -1,9 +1,10 @@
/** /*
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the
* file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#pragma once #pragma once
#include <jni.h> #include <jni.h>

Some files were not shown because too many files have changed in this diff Show More