Rename C api

Differential Revision: D4259190

fbshipit-source-id: 26c8b356ca464d4304f5f9dc4192bff10cea2dc9
This commit is contained in:
Emil Sjolander 2016-12-03 04:40:18 -08:00 committed by Facebook Github Bot
parent b1a23914fa
commit 85ac5fc354
30 changed files with 3139 additions and 2959 deletions

View File

@ -28,10 +28,10 @@
{
[super setUp];
self.parentView = [self _shadowViewWithConfig:^(CSSNodeRef node) {
CSSNodeStyleSetFlexDirection(node, YGFlexDirectionColumn);
CSSNodeStyleSetWidth(node, 440);
CSSNodeStyleSetHeight(node, 440);
self.parentView = [self _shadowViewWithConfig:^(YGNodeRef node) {
YGNodeStyleSetFlexDirection(node, YGFlexDirectionColumn);
YGNodeStyleSetWidth(node, 440);
YGNodeStyleSetHeight(node, 440);
}];
self.parentView.reactTag = @1; // must be valid rootView tag
}
@ -50,43 +50,43 @@
//
- (void)testApplyingLayoutRecursivelyToShadowView
{
RCTShadowView *leftView = [self _shadowViewWithConfig:^(CSSNodeRef node) {
CSSNodeStyleSetFlex(node, 1);
RCTShadowView *leftView = [self _shadowViewWithConfig:^(YGNodeRef node) {
YGNodeStyleSetFlex(node, 1);
}];
RCTShadowView *centerView = [self _shadowViewWithConfig:^(CSSNodeRef node) {
CSSNodeStyleSetFlex(node, 2);
CSSNodeStyleSetMargin(node, YGEdgeLeft, 10);
CSSNodeStyleSetMargin(node, YGEdgeRight, 10);
RCTShadowView *centerView = [self _shadowViewWithConfig:^(YGNodeRef node) {
YGNodeStyleSetFlex(node, 2);
YGNodeStyleSetMargin(node, YGEdgeLeft, 10);
YGNodeStyleSetMargin(node, YGEdgeRight, 10);
}];
RCTShadowView *rightView = [self _shadowViewWithConfig:^(CSSNodeRef node) {
CSSNodeStyleSetFlex(node, 1);
RCTShadowView *rightView = [self _shadowViewWithConfig:^(YGNodeRef node) {
YGNodeStyleSetFlex(node, 1);
}];
RCTShadowView *mainView = [self _shadowViewWithConfig:^(CSSNodeRef node) {
CSSNodeStyleSetFlexDirection(node, YGFlexDirectionRow);
CSSNodeStyleSetFlex(node, 2);
CSSNodeStyleSetMargin(node, YGEdgeTop, 10);
CSSNodeStyleSetMargin(node, YGEdgeBottom, 10);
RCTShadowView *mainView = [self _shadowViewWithConfig:^(YGNodeRef node) {
YGNodeStyleSetFlexDirection(node, YGFlexDirectionRow);
YGNodeStyleSetFlex(node, 2);
YGNodeStyleSetMargin(node, YGEdgeTop, 10);
YGNodeStyleSetMargin(node, YGEdgeBottom, 10);
}];
[mainView insertReactSubview:leftView atIndex:0];
[mainView insertReactSubview:centerView atIndex:1];
[mainView insertReactSubview:rightView atIndex:2];
RCTShadowView *headerView = [self _shadowViewWithConfig:^(CSSNodeRef node) {
CSSNodeStyleSetFlex(node, 1);
RCTShadowView *headerView = [self _shadowViewWithConfig:^(YGNodeRef node) {
YGNodeStyleSetFlex(node, 1);
}];
RCTShadowView *footerView = [self _shadowViewWithConfig:^(CSSNodeRef node) {
CSSNodeStyleSetFlex(node, 1);
RCTShadowView *footerView = [self _shadowViewWithConfig:^(YGNodeRef node) {
YGNodeStyleSetFlex(node, 1);
}];
CSSNodeStyleSetPadding(self.parentView.cssNode, YGEdgeLeft, 10);
CSSNodeStyleSetPadding(self.parentView.cssNode, YGEdgeTop, 10);
CSSNodeStyleSetPadding(self.parentView.cssNode, YGEdgeRight, 10);
CSSNodeStyleSetPadding(self.parentView.cssNode, YGEdgeBottom, 10);
YGNodeStyleSetPadding(self.parentView.cssNode, YGEdgeLeft, 10);
YGNodeStyleSetPadding(self.parentView.cssNode, YGEdgeTop, 10);
YGNodeStyleSetPadding(self.parentView.cssNode, YGEdgeRight, 10);
YGNodeStyleSetPadding(self.parentView.cssNode, YGEdgeBottom, 10);
[self.parentView insertReactSubview:headerView atIndex:0];
[self.parentView insertReactSubview:mainView atIndex:1];
@ -108,18 +108,18 @@
- (void)testAncestorCheck
{
RCTShadowView *centerView = [self _shadowViewWithConfig:^(CSSNodeRef node) {
CSSNodeStyleSetFlex(node, 1);
RCTShadowView *centerView = [self _shadowViewWithConfig:^(YGNodeRef node) {
YGNodeStyleSetFlex(node, 1);
}];
RCTShadowView *mainView = [self _shadowViewWithConfig:^(CSSNodeRef node) {
CSSNodeStyleSetFlex(node, 1);
RCTShadowView *mainView = [self _shadowViewWithConfig:^(YGNodeRef node) {
YGNodeStyleSetFlex(node, 1);
}];
[mainView insertReactSubview:centerView atIndex:0];
RCTShadowView *footerView = [self _shadowViewWithConfig:^(CSSNodeRef node) {
CSSNodeStyleSetFlex(node, 1);
RCTShadowView *footerView = [self _shadowViewWithConfig:^(YGNodeRef node) {
YGNodeStyleSetFlex(node, 1);
}];
[self.parentView insertReactSubview:mainView atIndex:0];
@ -131,10 +131,10 @@
- (void)testAssignsSuggestedWidthDimension
{
[self _withShadowViewWithStyle:^(CSSNodeRef node) {
CSSNodeStyleSetPosition(node, YGEdgeLeft, 0);
CSSNodeStyleSetPosition(node, YGEdgeTop, 0);
CSSNodeStyleSetHeight(node, 10);
[self _withShadowViewWithStyle:^(YGNodeRef node) {
YGNodeStyleSetPosition(node, YGEdgeLeft, 0);
YGNodeStyleSetPosition(node, YGEdgeTop, 0);
YGNodeStyleSetHeight(node, 10);
}
assertRelativeLayout:CGRectMake(0, 0, 3, 10)
withIntrinsicContentSize:CGSizeMake(3, UIViewNoIntrinsicMetric)];
@ -142,10 +142,10 @@
- (void)testAssignsSuggestedHeightDimension
{
[self _withShadowViewWithStyle:^(CSSNodeRef node) {
CSSNodeStyleSetPosition(node, YGEdgeLeft, 0);
CSSNodeStyleSetPosition(node, YGEdgeTop, 0);
CSSNodeStyleSetWidth(node, 10);
[self _withShadowViewWithStyle:^(YGNodeRef node) {
YGNodeStyleSetPosition(node, YGEdgeLeft, 0);
YGNodeStyleSetPosition(node, YGEdgeTop, 0);
YGNodeStyleSetWidth(node, 10);
}
assertRelativeLayout:CGRectMake(0, 0, 10, 4)
withIntrinsicContentSize:CGSizeMake(UIViewNoIntrinsicMetric, 4)];
@ -153,11 +153,11 @@
- (void)testDoesNotOverrideDimensionStyleWithSuggestedDimensions
{
[self _withShadowViewWithStyle:^(CSSNodeRef node) {
CSSNodeStyleSetPosition(node, YGEdgeLeft, 0);
CSSNodeStyleSetPosition(node, YGEdgeTop, 0);
CSSNodeStyleSetWidth(node, 10);
CSSNodeStyleSetHeight(node, 10);
[self _withShadowViewWithStyle:^(YGNodeRef node) {
YGNodeStyleSetPosition(node, YGEdgeLeft, 0);
YGNodeStyleSetPosition(node, YGEdgeTop, 0);
YGNodeStyleSetWidth(node, 10);
YGNodeStyleSetHeight(node, 10);
}
assertRelativeLayout:CGRectMake(0, 0, 10, 10)
withIntrinsicContentSize:CGSizeMake(3, 4)];
@ -165,16 +165,16 @@
- (void)testDoesNotAssignSuggestedDimensionsWhenStyledWithFlexAttribute
{
float parentWidth = CSSNodeStyleGetWidth(self.parentView.cssNode);
float parentHeight = CSSNodeStyleGetHeight(self.parentView.cssNode);
[self _withShadowViewWithStyle:^(CSSNodeRef node) {
CSSNodeStyleSetFlex(node, 1);
float parentWidth = YGNodeStyleGetWidth(self.parentView.cssNode);
float parentHeight = YGNodeStyleGetHeight(self.parentView.cssNode);
[self _withShadowViewWithStyle:^(YGNodeRef node) {
YGNodeStyleSetFlex(node, 1);
}
assertRelativeLayout:CGRectMake(0, 0, parentWidth, parentHeight)
withIntrinsicContentSize:CGSizeMake(3, 4)];
}
- (void)_withShadowViewWithStyle:(void(^)(CSSNodeRef node))configBlock
- (void)_withShadowViewWithStyle:(void(^)(YGNodeRef node))configBlock
assertRelativeLayout:(CGRect)expectedRect
withIntrinsicContentSize:(CGSize)contentSize
{
@ -189,7 +189,7 @@
NSStringFromCGRect(actualRect));
}
- (RCTRootShadowView *)_shadowViewWithConfig:(void(^)(CSSNodeRef node))configBlock
- (RCTRootShadowView *)_shadowViewWithConfig:(void(^)(YGNodeRef node))configBlock
{
RCTRootShadowView *shadowView = [RCTRootShadowView new];
configBlock(shadowView.cssNode);

View File

@ -39,16 +39,16 @@ CGFloat const RCTTextAutoSizeGranularity = 0.001f;
CGFloat _effectiveLetterSpacing;
}
static CSSSize RCTMeasure(CSSNodeRef node, float width, YGMeasureMode widthMode, float height, YGMeasureMode heightMode)
static YGSize RCTMeasure(YGNodeRef node, float width, YGMeasureMode widthMode, float height, YGMeasureMode heightMode)
{
RCTShadowText *shadowText = (__bridge RCTShadowText *)CSSNodeGetContext(node);
RCTShadowText *shadowText = (__bridge RCTShadowText *)YGNodeGetContext(node);
NSTextStorage *textStorage = [shadowText buildTextStorageForWidth:width widthMode:widthMode];
[shadowText calculateTextFrame:textStorage];
NSLayoutManager *layoutManager = textStorage.layoutManagers.firstObject;
NSTextContainer *textContainer = layoutManager.textContainers.firstObject;
CGSize computedSize = [layoutManager usedRectForTextContainer:textContainer].size;
CSSSize result;
YGSize result;
result.width = RCTCeilPixelValue(computedSize.width);
if (shadowText->_effectiveLetterSpacing < 0) {
result.width -= shadowText->_effectiveLetterSpacing;
@ -68,7 +68,7 @@ static CSSSize RCTMeasure(CSSNodeRef node, float width, YGMeasureMode widthMode,
_cachedTextStorageWidth = -1;
_cachedTextStorageWidthMode = -1;
_fontSizeMultiplier = 1.0;
CSSNodeSetMeasureFunc(self.cssNode, RCTMeasure);
YGNodeSetMeasureFunc(self.cssNode, RCTMeasure);
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(contentSizeMultiplierDidChange:)
name:RCTUIManagerWillUpdateViewsDueToContentSizeMultiplierChangeNotification
@ -95,7 +95,7 @@ static CSSSize RCTMeasure(CSSNodeRef node, float width, YGMeasureMode widthMode,
- (void)contentSizeMultiplierDidChange:(NSNotification *)note
{
CSSNodeMarkDirty(self.cssNode);
YGNodeMarkDirty(self.cssNode);
[self dirtyText];
}
@ -140,7 +140,7 @@ static CSSSize RCTMeasure(CSSNodeRef node, float width, YGMeasureMode widthMode,
return parentProperties;
}
- (void)applyLayoutNode:(CSSNodeRef)node
- (void)applyLayoutNode:(YGNodeRef)node
viewsWithNewFrame:(NSMutableSet<RCTShadowView *> *)viewsWithNewFrame
absolutePosition:(CGPoint)absolutePosition
{
@ -148,7 +148,7 @@ static CSSSize RCTMeasure(CSSNodeRef node, float width, YGMeasureMode widthMode,
[self dirtyPropagation];
}
- (void)applyLayoutToChildren:(CSSNodeRef)node
- (void)applyLayoutToChildren:(YGNodeRef)node
viewsWithNewFrame:(NSMutableSet<RCTShadowView *> *)viewsWithNewFrame
absolutePosition:(CGPoint)absolutePosition
{
@ -160,10 +160,10 @@ static CSSSize RCTMeasure(CSSNodeRef node, float width, YGMeasureMode widthMode,
NSRange characterRange = [layoutManager characterRangeForGlyphRange:glyphRange actualGlyphRange:NULL];
[layoutManager.textStorage enumerateAttribute:RCTShadowViewAttributeName inRange:characterRange options:0 usingBlock:^(RCTShadowView *child, NSRange range, BOOL *_) {
if (child) {
CSSNodeRef childNode = child.cssNode;
float width = CSSNodeStyleGetWidth(childNode);
float height = CSSNodeStyleGetHeight(childNode);
if (CSSValueIsUndefined(width) || CSSValueIsUndefined(height)) {
YGNodeRef childNode = child.cssNode;
float width = YGNodeStyleGetWidth(childNode);
float height = YGNodeStyleGetHeight(childNode);
if (YGValueIsUndefined(width) || YGValueIsUndefined(height)) {
RCTLogError(@"Views nested within a <Text> must have a width and height");
}
UIFont *font = [textStorage attribute:NSFontAttributeName atIndex:range.location effectiveRange:nil];
@ -307,9 +307,9 @@ static CSSSize RCTMeasure(CSSNodeRef node, float width, YGMeasureMode widthMode,
[attributedString appendAttributedString:[[NSAttributedString alloc] initWithString:shadowRawText.text ?: @""]];
[child setTextComputed];
} else {
float width = CSSNodeStyleGetWidth(child.cssNode);
float height = CSSNodeStyleGetHeight(child.cssNode);
if (CSSValueIsUndefined(width) || CSSValueIsUndefined(height)) {
float width = YGNodeStyleGetWidth(child.cssNode);
float height = YGNodeStyleGetHeight(child.cssNode);
if (YGValueIsUndefined(width) || YGValueIsUndefined(height)) {
RCTLogError(@"Views nested within a <Text> must have a width and height");
}
NSTextAttachment *attachment = [NSTextAttachment new];
@ -348,7 +348,7 @@ static CSSSize RCTMeasure(CSSNodeRef node, float width, YGMeasureMode widthMode,
// create a non-mutable attributedString for use by the Text system which avoids copies down the line
_cachedAttributedString = [[NSAttributedString alloc] initWithAttributedString:attributedString];
CSSNodeMarkDirty(self.cssNode);
YGNodeMarkDirty(self.cssNode);
return _cachedAttributedString;
}
@ -403,10 +403,10 @@ static CSSSize RCTMeasure(CSSNodeRef node, float width, YGMeasureMode widthMode,
// We will climb up to the first node which style has been setted as non-inherit
if (newTextAlign == NSTextAlignmentRight || newTextAlign == NSTextAlignmentLeft) {
RCTShadowView *view = self;
while (view != nil && CSSNodeStyleGetDirection(view.cssNode) == YGDirectionInherit) {
while (view != nil && YGNodeStyleGetDirection(view.cssNode) == YGDirectionInherit) {
view = [view reactSuperview];
}
if (view != nil && CSSNodeStyleGetDirection(view.cssNode) == YGDirectionRTL) {
if (view != nil && YGNodeStyleGetDirection(view.cssNode) == YGDirectionRTL) {
if (newTextAlign == NSTextAlignmentRight) {
newTextAlign = NSTextAlignmentLeft;
} else if (newTextAlign == NSTextAlignmentLeft) {

View File

@ -9,7 +9,7 @@
#import "RCTTextManager.h"
#import <CSSLayout/CSSLayout.h>
#import <CSSLayout/Yoga.h>
#import <React/RCTAccessibilityManager.h>
#import <React/RCTAssert.h>
#import <React/RCTConvert.h>

View File

@ -10,7 +10,7 @@
#import <QuartzCore/QuartzCore.h>
#import <UIKit/UIKit.h>
#import <CSSLayout/CSSLayout.h>
#import <CSSLayout/Yoga.h>
#import <React/RCTAnimationType.h>
#import <React/RCTBorderStyle.h>
#import <React/RCTDefines.h>

View File

@ -1,183 +0,0 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* 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 <assert.h>
#include <math.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#ifndef __cplusplus
#include <stdbool.h>
#endif
// Not defined in MSVC++
#ifndef NAN
static const unsigned long __nan[2] = {0xffffffff, 0x7fffffff};
#define NAN (*(const float *) __nan)
#endif
#define YGUndefined NAN
#include "CSSEnums.h"
#include "CSSMacros.h"
CSS_EXTERN_C_BEGIN
typedef struct CSSSize {
float width;
float height;
} CSSSize;
typedef struct CSSNode *CSSNodeRef;
typedef CSSSize (*CSSMeasureFunc)(CSSNodeRef node,
float width,
YGMeasureMode widthMode,
float height,
YGMeasureMode heightMode);
typedef void (*CSSPrintFunc)(CSSNodeRef node);
typedef int (*CSSLogger)(YGLogLevel level, const char *format, va_list args);
typedef void *(*CSSMalloc)(size_t size);
typedef void *(*CSSCalloc)(size_t count, size_t size);
typedef void *(*CSSRealloc)(void *ptr, size_t size);
typedef void (*CSSFree)(void *ptr);
// CSSNode
WIN_EXPORT CSSNodeRef CSSNodeNew(void);
WIN_EXPORT void CSSNodeInit(const CSSNodeRef node);
WIN_EXPORT void CSSNodeFree(const CSSNodeRef node);
WIN_EXPORT void CSSNodeFreeRecursive(const CSSNodeRef node);
WIN_EXPORT void CSSNodeReset(const CSSNodeRef node);
WIN_EXPORT int32_t CSSNodeGetInstanceCount(void);
WIN_EXPORT void CSSNodeInsertChild(const CSSNodeRef node,
const CSSNodeRef child,
const uint32_t index);
WIN_EXPORT void CSSNodeRemoveChild(const CSSNodeRef node, const CSSNodeRef child);
WIN_EXPORT CSSNodeRef CSSNodeGetChild(const CSSNodeRef node, const uint32_t index);
WIN_EXPORT uint32_t CSSNodeChildCount(const CSSNodeRef node);
WIN_EXPORT void CSSNodeCalculateLayout(const CSSNodeRef node,
const float availableWidth,
const float availableHeight,
const YGDirection parentDirection);
// Mark a node as dirty. Only valid for nodes with a custom measure function
// set.
// CSSLayout knows when to mark all other nodes as dirty but because nodes with
// measure functions
// depends on information not known to CSSLayout they must perform this dirty
// marking manually.
WIN_EXPORT void CSSNodeMarkDirty(const CSSNodeRef node);
WIN_EXPORT bool CSSNodeIsDirty(const CSSNodeRef node);
WIN_EXPORT void CSSNodePrint(const CSSNodeRef node, const YGPrintOptions options);
WIN_EXPORT bool CSSValueIsUndefined(const float value);
WIN_EXPORT bool CSSNodeCanUseCachedMeasurement(const YGMeasureMode widthMode,
const float width,
const YGMeasureMode heightMode,
const float height,
const YGMeasureMode lastWidthMode,
const float lastWidth,
const YGMeasureMode lastHeightMode,
const float lastHeight,
const float lastComputedWidth,
const float lastComputedHeight,
const float marginRow,
const float marginColumn);
WIN_EXPORT void CSSNodeCopyStyle(const CSSNodeRef dstNode, const CSSNodeRef srcNode);
#define CSS_NODE_PROPERTY(type, name, paramName) \
WIN_EXPORT void CSSNodeSet##name(const CSSNodeRef node, type paramName); \
WIN_EXPORT type CSSNodeGet##name(const CSSNodeRef node);
#define CSS_NODE_STYLE_PROPERTY(type, name, paramName) \
WIN_EXPORT void CSSNodeStyleSet##name(const CSSNodeRef node, const type paramName); \
WIN_EXPORT type CSSNodeStyleGet##name(const CSSNodeRef node);
#define CSS_NODE_STYLE_EDGE_PROPERTY(type, name, paramName) \
WIN_EXPORT void CSSNodeStyleSet##name(const CSSNodeRef node, \
const YGEdge edge, \
const type paramName); \
WIN_EXPORT type CSSNodeStyleGet##name(const CSSNodeRef node, const YGEdge edge);
#define CSS_NODE_LAYOUT_PROPERTY(type, name) \
WIN_EXPORT type CSSNodeLayoutGet##name(const CSSNodeRef node);
CSS_NODE_PROPERTY(void *, Context, context);
CSS_NODE_PROPERTY(CSSMeasureFunc, MeasureFunc, measureFunc);
CSS_NODE_PROPERTY(CSSPrintFunc, PrintFunc, printFunc);
CSS_NODE_PROPERTY(bool, HasNewLayout, hasNewLayout);
CSS_NODE_STYLE_PROPERTY(YGDirection, Direction, direction);
CSS_NODE_STYLE_PROPERTY(YGFlexDirection, FlexDirection, flexDirection);
CSS_NODE_STYLE_PROPERTY(YGJustify, JustifyContent, justifyContent);
CSS_NODE_STYLE_PROPERTY(YGAlign, AlignContent, alignContent);
CSS_NODE_STYLE_PROPERTY(YGAlign, AlignItems, alignItems);
CSS_NODE_STYLE_PROPERTY(YGAlign, AlignSelf, alignSelf);
CSS_NODE_STYLE_PROPERTY(YGPositionType, PositionType, positionType);
CSS_NODE_STYLE_PROPERTY(YGWrap, FlexWrap, flexWrap);
CSS_NODE_STYLE_PROPERTY(YGOverflow, Overflow, overflow);
WIN_EXPORT void CSSNodeStyleSetFlex(const CSSNodeRef node, const float flex);
CSS_NODE_STYLE_PROPERTY(float, FlexGrow, flexGrow);
CSS_NODE_STYLE_PROPERTY(float, FlexShrink, flexShrink);
CSS_NODE_STYLE_PROPERTY(float, FlexBasis, flexBasis);
CSS_NODE_STYLE_EDGE_PROPERTY(float, Position, position);
CSS_NODE_STYLE_EDGE_PROPERTY(float, Margin, margin);
CSS_NODE_STYLE_EDGE_PROPERTY(float, Padding, padding);
CSS_NODE_STYLE_EDGE_PROPERTY(float, Border, border);
CSS_NODE_STYLE_PROPERTY(float, Width, width);
CSS_NODE_STYLE_PROPERTY(float, Height, height);
CSS_NODE_STYLE_PROPERTY(float, MinWidth, minWidth);
CSS_NODE_STYLE_PROPERTY(float, MinHeight, minHeight);
CSS_NODE_STYLE_PROPERTY(float, MaxWidth, maxWidth);
CSS_NODE_STYLE_PROPERTY(float, MaxHeight, maxHeight);
// Yoga specific properties, not compatible with flexbox specification
// Aspect ratio control the size of the undefined dimension of a node.
// - On a node with a set width/height aspect ratio control the size of the unset dimension
// - On a node with a set flex basis aspect ratio controls the size of the node in the cross axis if
// unset
// - On a node with a measure function aspect ratio works as though the measure function measures
// the flex basis
// - On a node with flex grow/shrink aspect ratio controls the size of the node in the cross axis if
// unset
// - Aspect ratio takes min/max dimensions into account
CSS_NODE_STYLE_PROPERTY(float, AspectRatio, aspectRatio);
CSS_NODE_LAYOUT_PROPERTY(float, Left);
CSS_NODE_LAYOUT_PROPERTY(float, Top);
CSS_NODE_LAYOUT_PROPERTY(float, Right);
CSS_NODE_LAYOUT_PROPERTY(float, Bottom);
CSS_NODE_LAYOUT_PROPERTY(float, Width);
CSS_NODE_LAYOUT_PROPERTY(float, Height);
CSS_NODE_LAYOUT_PROPERTY(YGDirection, Direction);
WIN_EXPORT void CSSLayoutSetLogger(CSSLogger logger);
WIN_EXPORT void CSSLog(YGLogLevel level, const char *message, ...);
WIN_EXPORT void CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeature feature, bool enabled);
WIN_EXPORT bool CSSLayoutIsExperimentalFeatureEnabled(YGExperimentalFeature feature);
WIN_EXPORT void CSSLayoutSetMemoryFuncs(CSSMalloc cssMalloc,
CSSCalloc cssCalloc,
CSSRealloc cssRealloc,
CSSFree cssFree);
CSS_EXTERN_C_END

View File

@ -10,11 +10,11 @@
#pragma once
#ifdef __cplusplus
#define CSS_EXTERN_C_BEGIN extern "C" {
#define CSS_EXTERN_C_END }
#define YG_EXTERN_C_BEGIN extern "C" {
#define YG_EXTERN_C_END }
#else
#define CSS_EXTERN_C_BEGIN
#define CSS_EXTERN_C_END
#define YG_EXTERN_C_BEGIN
#define YG_EXTERN_C_END
#endif
#ifdef _WINDLL
@ -28,15 +28,15 @@
#endif
#if FB_ASSERTIONS_ENABLED
#define CSS_ABORT() abort()
#define YG_ABORT() abort()
#else
#define CSS_ABORT()
#define YG_ABORT()
#endif
#ifndef CSS_ASSERT
#define CSS_ASSERT(X, message) \
if (!(X)) { \
CSSLog(YGLogLevelError, "%s", message); \
CSS_ABORT(); \
#ifndef YG_ASSERT
#define YG_ASSERT(X, message) \
if (!(X)) { \
YGLog(YGLogLevelError, "%s", message); \
YG_ABORT(); \
}
#endif

View File

@ -0,0 +1,104 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* 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.
*/
#include "YGNodeList.h"
extern YGMalloc gYGMalloc;
extern YGRealloc gYGRealloc;
extern YGFree gYGFree;
struct YGNodeList {
uint32_t capacity;
uint32_t count;
YGNodeRef *items;
};
YGNodeListRef YGNodeListNew(const uint32_t initialCapacity) {
const YGNodeListRef list = gYGMalloc(sizeof(struct YGNodeList));
YG_ASSERT(list != NULL, "Could not allocate memory for list");
list->capacity = initialCapacity;
list->count = 0;
list->items = gYGMalloc(sizeof(YGNodeRef) * list->capacity);
YG_ASSERT(list->items != NULL, "Could not allocate memory for items");
return list;
}
void YGNodeListFree(const YGNodeListRef list) {
if (list) {
gYGFree(list->items);
gYGFree(list);
}
}
uint32_t YGNodeListCount(const YGNodeListRef list) {
if (list) {
return list->count;
}
return 0;
}
void YGNodeListAdd(YGNodeListRef *listp, const YGNodeRef node) {
if (!*listp) {
*listp = YGNodeListNew(4);
}
YGNodeListInsert(listp, node, (*listp)->count);
}
void YGNodeListInsert(YGNodeListRef *listp, const YGNodeRef node, const uint32_t index) {
if (!*listp) {
*listp = YGNodeListNew(4);
}
YGNodeListRef list = *listp;
if (list->count == list->capacity) {
list->capacity *= 2;
list->items = gYGRealloc(list->items, sizeof(YGNodeRef) * list->capacity);
YG_ASSERT(list->items != NULL, "Could not extend allocation for items");
}
for (uint32_t i = list->count; i > index; i--) {
list->items[i] = list->items[i - 1];
}
list->count++;
list->items[index] = node;
}
YGNodeRef YGNodeListRemove(const YGNodeListRef list, const uint32_t index) {
const YGNodeRef removed = list->items[index];
list->items[index] = NULL;
for (uint32_t i = index; i < list->count - 1; i++) {
list->items[i] = list->items[i + 1];
list->items[i + 1] = NULL;
}
list->count--;
return removed;
}
YGNodeRef YGNodeListDelete(const YGNodeListRef list, const YGNodeRef node) {
for (uint32_t i = 0; i < list->count; i++) {
if (list->items[i] == node) {
return YGNodeListRemove(list, i);
}
}
return NULL;
}
YGNodeRef YGNodeListGet(const YGNodeListRef list, const uint32_t index) {
if (YGNodeListCount(list) > 0) {
return list->items[index];
}
return NULL;
}

View File

@ -0,0 +1,33 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* 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 <assert.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include "YGMacros.h"
#include "Yoga.h"
YG_EXTERN_C_BEGIN
typedef struct YGNodeList *YGNodeListRef;
YGNodeListRef YGNodeListNew(const uint32_t initialCapacity);
void YGNodeListFree(const YGNodeListRef list);
uint32_t YGNodeListCount(const YGNodeListRef list);
void YGNodeListAdd(YGNodeListRef *listp, const YGNodeRef node);
void YGNodeListInsert(YGNodeListRef *listp, const YGNodeRef node, const uint32_t index);
YGNodeRef YGNodeListRemove(const YGNodeListRef list, const uint32_t index);
YGNodeRef YGNodeListDelete(const YGNodeListRef list, const YGNodeRef node);
YGNodeRef YGNodeListGet(const YGNodeListRef list, const uint32_t index);
YG_EXTERN_C_END

File diff suppressed because it is too large Load Diff

181
React/CSSLayout/Yoga.h Normal file
View File

@ -0,0 +1,181 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* 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 <assert.h>
#include <math.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#ifndef __cplusplus
#include <stdbool.h>
#endif
// Not defined in MSVC++
#ifndef NAN
static const unsigned long __nan[2] = {0xffffffff, 0x7fffffff};
#define NAN (*(const float *) __nan)
#endif
#define YGUndefined NAN
#include "YGEnums.h"
#include "YGMacros.h"
YG_EXTERN_C_BEGIN
typedef struct YGSize {
float width;
float height;
} YGSize;
typedef struct YGNode *YGNodeRef;
typedef YGSize (*YGMeasureFunc)(YGNodeRef node,
float width,
YGMeasureMode widthMode,
float height,
YGMeasureMode heightMode);
typedef void (*YGPrintFunc)(YGNodeRef node);
typedef int (*YGLogger)(YGLogLevel level, const char *format, va_list args);
typedef void *(*YGMalloc)(size_t size);
typedef void *(*YGCalloc)(size_t count, size_t size);
typedef void *(*YGRealloc)(void *ptr, size_t size);
typedef void (*YGFree)(void *ptr);
// YGNode
WIN_EXPORT YGNodeRef YGNodeNew(void);
WIN_EXPORT void YGNodeInit(const YGNodeRef node);
WIN_EXPORT void YGNodeFree(const YGNodeRef node);
WIN_EXPORT void YGNodeFreeRecursive(const YGNodeRef node);
WIN_EXPORT void YGNodeReset(const YGNodeRef node);
WIN_EXPORT int32_t YGNodeGetInstanceCount(void);
WIN_EXPORT void YGNodeInsertChild(const YGNodeRef node,
const YGNodeRef child,
const uint32_t index);
WIN_EXPORT void YGNodeRemoveChild(const YGNodeRef node, const YGNodeRef child);
WIN_EXPORT YGNodeRef YGNodeGetChild(const YGNodeRef node, const uint32_t index);
WIN_EXPORT uint32_t YGNodeChildCount(const YGNodeRef node);
WIN_EXPORT void YGNodeCalculateLayout(const YGNodeRef node,
const float availableWidth,
const float availableHeight,
const YGDirection parentDirection);
// Mark a node as dirty. Only valid for nodes with a custom measure function
// set.
// YG knows when to mark all other nodes as dirty but because nodes with
// measure functions
// depends on information not known to YG they must perform this dirty
// marking manually.
WIN_EXPORT void YGNodeMarkDirty(const YGNodeRef node);
WIN_EXPORT bool YGNodeIsDirty(const YGNodeRef node);
WIN_EXPORT void YGNodePrint(const YGNodeRef node, const YGPrintOptions options);
WIN_EXPORT bool YGValueIsUndefined(const float value);
WIN_EXPORT bool YGNodeCanUseCachedMeasurement(const YGMeasureMode widthMode,
const float width,
const YGMeasureMode heightMode,
const float height,
const YGMeasureMode lastWidthMode,
const float lastWidth,
const YGMeasureMode lastHeightMode,
const float lastHeight,
const float lastComputedWidth,
const float lastComputedHeight,
const float marginRow,
const float marginColumn);
WIN_EXPORT void YGNodeCopyStyle(const YGNodeRef dstNode, const YGNodeRef srcNode);
#define YG_NODE_PROPERTY(type, name, paramName) \
WIN_EXPORT void YGNodeSet##name(const YGNodeRef node, type paramName); \
WIN_EXPORT type YGNodeGet##name(const YGNodeRef node);
#define YG_NODE_STYLE_PROPERTY(type, name, paramName) \
WIN_EXPORT void YGNodeStyleSet##name(const YGNodeRef node, const type paramName); \
WIN_EXPORT type YGNodeStyleGet##name(const YGNodeRef node);
#define YG_NODE_STYLE_EDGE_PROPERTY(type, name, paramName) \
WIN_EXPORT void YGNodeStyleSet##name(const YGNodeRef node, \
const YGEdge edge, \
const type paramName); \
WIN_EXPORT type YGNodeStyleGet##name(const YGNodeRef node, const YGEdge edge);
#define YG_NODE_LAYOUT_PROPERTY(type, name) \
WIN_EXPORT type YGNodeLayoutGet##name(const YGNodeRef node);
YG_NODE_PROPERTY(void *, Context, context);
YG_NODE_PROPERTY(YGMeasureFunc, MeasureFunc, measureFunc);
YG_NODE_PROPERTY(YGPrintFunc, PrintFunc, printFunc);
YG_NODE_PROPERTY(bool, HasNewLayout, hasNewLayout);
YG_NODE_STYLE_PROPERTY(YGDirection, Direction, direction);
YG_NODE_STYLE_PROPERTY(YGFlexDirection, FlexDirection, flexDirection);
YG_NODE_STYLE_PROPERTY(YGJustify, JustifyContent, justifyContent);
YG_NODE_STYLE_PROPERTY(YGAlign, AlignContent, alignContent);
YG_NODE_STYLE_PROPERTY(YGAlign, AlignItems, alignItems);
YG_NODE_STYLE_PROPERTY(YGAlign, AlignSelf, alignSelf);
YG_NODE_STYLE_PROPERTY(YGPositionType, PositionType, positionType);
YG_NODE_STYLE_PROPERTY(YGWrap, FlexWrap, flexWrap);
YG_NODE_STYLE_PROPERTY(YGOverflow, Overflow, overflow);
WIN_EXPORT void YGNodeStyleSetFlex(const YGNodeRef node, const float flex);
YG_NODE_STYLE_PROPERTY(float, FlexGrow, flexGrow);
YG_NODE_STYLE_PROPERTY(float, FlexShrink, flexShrink);
YG_NODE_STYLE_PROPERTY(float, FlexBasis, flexBasis);
YG_NODE_STYLE_EDGE_PROPERTY(float, Position, position);
YG_NODE_STYLE_EDGE_PROPERTY(float, Margin, margin);
YG_NODE_STYLE_EDGE_PROPERTY(float, Padding, padding);
YG_NODE_STYLE_EDGE_PROPERTY(float, Border, border);
YG_NODE_STYLE_PROPERTY(float, Width, width);
YG_NODE_STYLE_PROPERTY(float, Height, height);
YG_NODE_STYLE_PROPERTY(float, MinWidth, minWidth);
YG_NODE_STYLE_PROPERTY(float, MinHeight, minHeight);
YG_NODE_STYLE_PROPERTY(float, MaxWidth, maxWidth);
YG_NODE_STYLE_PROPERTY(float, MaxHeight, maxHeight);
// Yoga specific properties, not compatible with flexbox specification
// Aspect ratio control the size of the undefined dimension of a node.
// - On a node with a set width/height aspect ratio control the size of the unset dimension
// - On a node with a set flex basis aspect ratio controls the size of the node in the cross axis if
// unset
// - On a node with a measure function aspect ratio works as though the measure function measures
// the flex basis
// - On a node with flex grow/shrink aspect ratio controls the size of the node in the cross axis if
// unset
// - Aspect ratio takes min/max dimensions into account
YG_NODE_STYLE_PROPERTY(float, AspectRatio, aspectRatio);
YG_NODE_LAYOUT_PROPERTY(float, Left);
YG_NODE_LAYOUT_PROPERTY(float, Top);
YG_NODE_LAYOUT_PROPERTY(float, Right);
YG_NODE_LAYOUT_PROPERTY(float, Bottom);
YG_NODE_LAYOUT_PROPERTY(float, Width);
YG_NODE_LAYOUT_PROPERTY(float, Height);
YG_NODE_LAYOUT_PROPERTY(YGDirection, Direction);
WIN_EXPORT void YGSetLogger(YGLogger logger);
WIN_EXPORT void YGLog(YGLogLevel level, const char *message, ...);
WIN_EXPORT void YGSetExperimentalFeatureEnabled(YGExperimentalFeature feature, bool enabled);
WIN_EXPORT bool YGIsExperimentalFeatureEnabled(YGExperimentalFeature feature);
WIN_EXPORT void
YGSetMemoryFuncs(YGMalloc cssMalloc, YGCalloc cssCalloc, YGRealloc cssRealloc, YGFree cssFree);
YG_EXTERN_C_END

View File

@ -11,7 +11,7 @@
#import <AVFoundation/AVFoundation.h>
#import <CSSLayout/CSSLayout.h>
#import <CSSLayout/Yoga.h>
#import "RCTAccessibilityManager.h"
#import "RCTAnimationType.h"

View File

@ -180,29 +180,29 @@
3D1FA09A1DE4F50100E03CC6 /* RCTPushNotificationManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 3D1FA08D1DE4F4EE00E03CC6 /* RCTPushNotificationManager.h */; settings = {ATTRIBUTES = (Public, ); }; };
3D37B5821D522B190042D5B5 /* RCTFont.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3D37B5811D522B190042D5B5 /* RCTFont.mm */; };
3D3C04AB1DE3337C00C268FA /* RCTAlertManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 13B07FE71A69327A00A75B9A /* RCTAlertManager.h */; settings = {ATTRIBUTES = (Public, ); }; };
3D3C083B1DE334D900C268FA /* CSSEnums.h in Headers */ = {isa = PBXBuildFile; fileRef = 3D10A3C81DDF3D16004A0F9D /* CSSEnums.h */; settings = {ATTRIBUTES = (Public, ); }; };
3D3C083C1DE334D900C268FA /* CSSLayout.h in Headers */ = {isa = PBXBuildFile; fileRef = 133683451D37ACA10077D0C3 /* CSSLayout.h */; settings = {ATTRIBUTES = (Public, ); }; };
3D3C083D1DE334D900C268FA /* CSSMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 133683481D37ACA10077D0C3 /* CSSMacros.h */; settings = {ATTRIBUTES = (Public, ); }; };
3D3C083E1DE334D900C268FA /* CSSNodeList.h in Headers */ = {isa = PBXBuildFile; fileRef = 1321C8CF1D3EB50800D58318 /* CSSNodeList.h */; settings = {ATTRIBUTES = (Public, ); }; };
3D3C083F1DE334DA00C268FA /* CSSEnums.h in Headers */ = {isa = PBXBuildFile; fileRef = 3D10A3C81DDF3D16004A0F9D /* CSSEnums.h */; settings = {ATTRIBUTES = (Public, ); }; };
3D3C08401DE334DA00C268FA /* CSSLayout.h in Headers */ = {isa = PBXBuildFile; fileRef = 133683451D37ACA10077D0C3 /* CSSLayout.h */; settings = {ATTRIBUTES = (Public, ); }; };
3D3C08411DE334DA00C268FA /* CSSMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 133683481D37ACA10077D0C3 /* CSSMacros.h */; settings = {ATTRIBUTES = (Public, ); }; };
3D3C08421DE334DA00C268FA /* CSSNodeList.h in Headers */ = {isa = PBXBuildFile; fileRef = 1321C8CF1D3EB50800D58318 /* CSSNodeList.h */; settings = {ATTRIBUTES = (Public, ); }; };
3D3C085A1DE33E4400C268FA /* CSSLayout.c in Sources */ = {isa = PBXBuildFile; fileRef = 133683441D37ACA10077D0C3 /* CSSLayout.c */; };
3D3C085C1DE33E4E00C268FA /* CSSLayout.c in Sources */ = {isa = PBXBuildFile; fileRef = 133683441D37ACA10077D0C3 /* CSSLayout.c */; };
3D3C085E1DE33E6100C268FA /* CSSNodeList.c in Sources */ = {isa = PBXBuildFile; fileRef = 1321C8CE1D3EB50800D58318 /* CSSNodeList.c */; };
3D3C085F1DE33E6100C268FA /* CSSNodeList.c in Sources */ = {isa = PBXBuildFile; fileRef = 1321C8CE1D3EB50800D58318 /* CSSNodeList.c */; };
3D3C083B1DE334D900C268FA /* YGEnums.h in Headers */ = {isa = PBXBuildFile; fileRef = 3D10A3C81DDF3D16004A0F9D /* YGEnums.h */; settings = {ATTRIBUTES = (Public, ); }; };
3D3C083C1DE334D900C268FA /* Yoga.h in Headers */ = {isa = PBXBuildFile; fileRef = 133683451D37ACA10077D0C3 /* Yoga.h */; settings = {ATTRIBUTES = (Public, ); }; };
3D3C083D1DE334D900C268FA /* YGMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 133683481D37ACA10077D0C3 /* YGMacros.h */; settings = {ATTRIBUTES = (Public, ); }; };
3D3C083E1DE334D900C268FA /* YGNodeList.h in Headers */ = {isa = PBXBuildFile; fileRef = 1321C8CF1D3EB50800D58318 /* YGNodeList.h */; settings = {ATTRIBUTES = (Public, ); }; };
3D3C083F1DE334DA00C268FA /* YGEnums.h in Headers */ = {isa = PBXBuildFile; fileRef = 3D10A3C81DDF3D16004A0F9D /* YGEnums.h */; settings = {ATTRIBUTES = (Public, ); }; };
3D3C08401DE334DA00C268FA /* Yoga.h in Headers */ = {isa = PBXBuildFile; fileRef = 133683451D37ACA10077D0C3 /* Yoga.h */; settings = {ATTRIBUTES = (Public, ); }; };
3D3C08411DE334DA00C268FA /* YGMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 133683481D37ACA10077D0C3 /* YGMacros.h */; settings = {ATTRIBUTES = (Public, ); }; };
3D3C08421DE334DA00C268FA /* YGNodeList.h in Headers */ = {isa = PBXBuildFile; fileRef = 1321C8CF1D3EB50800D58318 /* YGNodeList.h */; settings = {ATTRIBUTES = (Public, ); }; };
3D3C085A1DE33E4400C268FA /* Yoga.c in Sources */ = {isa = PBXBuildFile; fileRef = 133683441D37ACA10077D0C3 /* Yoga.c */; };
3D3C085C1DE33E4E00C268FA /* Yoga.c in Sources */ = {isa = PBXBuildFile; fileRef = 133683441D37ACA10077D0C3 /* Yoga.c */; };
3D3C085E1DE33E6100C268FA /* YGNodeList.c in Sources */ = {isa = PBXBuildFile; fileRef = 1321C8CE1D3EB50800D58318 /* YGNodeList.c */; };
3D3C085F1DE33E6100C268FA /* YGNodeList.c in Sources */ = {isa = PBXBuildFile; fileRef = 1321C8CE1D3EB50800D58318 /* YGNodeList.c */; };
3D3C08891DE342FB00C268FA /* libCSSLayout.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3D3C059A1DE3340900C268FA /* libCSSLayout.a */; };
3D3C088C1DE3430500C268FA /* libCSSLayout-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3D3C06751DE3340C00C268FA /* libCSSLayout-tvOS.a */; };
3D3CD8F81DE5FB2D00167DC4 /* JSBundleType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AC70D2EB1DE48A22002E6351 /* JSBundleType.cpp */; };
3D3CD9061DE5FBD600167DC4 /* CSSLayout.c in Sources */ = {isa = PBXBuildFile; fileRef = 133683441D37ACA10077D0C3 /* CSSLayout.c */; };
3D3CD9071DE5FBD600167DC4 /* CSSNodeList.c in Sources */ = {isa = PBXBuildFile; fileRef = 1321C8CE1D3EB50800D58318 /* CSSNodeList.c */; };
3D3CD9131DE5FBD800167DC4 /* CSSLayout.c in Sources */ = {isa = PBXBuildFile; fileRef = 133683441D37ACA10077D0C3 /* CSSLayout.c */; };
3D3CD9141DE5FBD800167DC4 /* CSSNodeList.c in Sources */ = {isa = PBXBuildFile; fileRef = 1321C8CE1D3EB50800D58318 /* CSSNodeList.c */; };
3D3CD9201DE5FBEC00167DC4 /* CSSLayout.c in Sources */ = {isa = PBXBuildFile; fileRef = 133683441D37ACA10077D0C3 /* CSSLayout.c */; };
3D3CD9211DE5FBEC00167DC4 /* CSSNodeList.c in Sources */ = {isa = PBXBuildFile; fileRef = 1321C8CE1D3EB50800D58318 /* CSSNodeList.c */; };
3D3CD92D1DE5FBEE00167DC4 /* CSSLayout.c in Sources */ = {isa = PBXBuildFile; fileRef = 133683441D37ACA10077D0C3 /* CSSLayout.c */; };
3D3CD92E1DE5FBEE00167DC4 /* CSSNodeList.c in Sources */ = {isa = PBXBuildFile; fileRef = 1321C8CE1D3EB50800D58318 /* CSSNodeList.c */; };
3D3CD9061DE5FBD600167DC4 /* Yoga.c in Sources */ = {isa = PBXBuildFile; fileRef = 133683441D37ACA10077D0C3 /* Yoga.c */; };
3D3CD9071DE5FBD600167DC4 /* YGNodeList.c in Sources */ = {isa = PBXBuildFile; fileRef = 1321C8CE1D3EB50800D58318 /* YGNodeList.c */; };
3D3CD9131DE5FBD800167DC4 /* Yoga.c in Sources */ = {isa = PBXBuildFile; fileRef = 133683441D37ACA10077D0C3 /* Yoga.c */; };
3D3CD9141DE5FBD800167DC4 /* YGNodeList.c in Sources */ = {isa = PBXBuildFile; fileRef = 1321C8CE1D3EB50800D58318 /* YGNodeList.c */; };
3D3CD9201DE5FBEC00167DC4 /* Yoga.c in Sources */ = {isa = PBXBuildFile; fileRef = 133683441D37ACA10077D0C3 /* Yoga.c */; };
3D3CD9211DE5FBEC00167DC4 /* YGNodeList.c in Sources */ = {isa = PBXBuildFile; fileRef = 1321C8CE1D3EB50800D58318 /* YGNodeList.c */; };
3D3CD92D1DE5FBEE00167DC4 /* Yoga.c in Sources */ = {isa = PBXBuildFile; fileRef = 133683441D37ACA10077D0C3 /* Yoga.c */; };
3D3CD92E1DE5FBEE00167DC4 /* YGNodeList.c in Sources */ = {isa = PBXBuildFile; fileRef = 1321C8CE1D3EB50800D58318 /* YGNodeList.c */; };
3D3CD93D1DE5FC1400167DC4 /* JavaScriptCore.h in Headers */ = {isa = PBXBuildFile; fileRef = 3D7A27DC1DE32541002E3F95 /* JavaScriptCore.h */; settings = {ATTRIBUTES = (Public, ); }; };
3D3CD93E1DE5FC1400167DC4 /* JSCWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 3D7A27DE1DE32541002E3F95 /* JSCWrapper.h */; settings = {ATTRIBUTES = (Public, ); }; };
3D3CD93F1DE5FC1400167DC4 /* JavaScriptCore.h in Headers */ = {isa = PBXBuildFile; fileRef = 3D7A27DC1DE32541002E3F95 /* JavaScriptCore.h */; settings = {ATTRIBUTES = (Public, ); }; };
@ -543,11 +543,11 @@
131B6AF11AF1093D00FFC3E0 /* RCTSegmentedControl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTSegmentedControl.m; sourceTree = "<group>"; };
131B6AF21AF1093D00FFC3E0 /* RCTSegmentedControlManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTSegmentedControlManager.h; sourceTree = "<group>"; };
131B6AF31AF1093D00FFC3E0 /* RCTSegmentedControlManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTSegmentedControlManager.m; sourceTree = "<group>"; };
1321C8CE1D3EB50800D58318 /* CSSNodeList.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CSSNodeList.c; sourceTree = "<group>"; };
1321C8CF1D3EB50800D58318 /* CSSNodeList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSNodeList.h; sourceTree = "<group>"; };
133683441D37ACA10077D0C3 /* CSSLayout.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CSSLayout.c; sourceTree = "<group>"; };
133683451D37ACA10077D0C3 /* CSSLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSLayout.h; sourceTree = "<group>"; };
133683481D37ACA10077D0C3 /* CSSMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSMacros.h; sourceTree = "<group>"; };
1321C8CE1D3EB50800D58318 /* YGNodeList.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = YGNodeList.c; sourceTree = "<group>"; };
1321C8CF1D3EB50800D58318 /* YGNodeList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YGNodeList.h; sourceTree = "<group>"; };
133683441D37ACA10077D0C3 /* Yoga.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = Yoga.c; sourceTree = "<group>"; };
133683451D37ACA10077D0C3 /* Yoga.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Yoga.h; sourceTree = "<group>"; };
133683481D37ACA10077D0C3 /* YGMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YGMacros.h; sourceTree = "<group>"; };
133CAE8C1B8E5CFD00F6AD92 /* RCTDatePicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTDatePicker.h; sourceTree = "<group>"; };
133CAE8D1B8E5CFD00F6AD92 /* RCTDatePicker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTDatePicker.m; sourceTree = "<group>"; };
13442BF21AA90E0B0037E5B0 /* RCTAnimationType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTAnimationType.h; sourceTree = "<group>"; };
@ -693,7 +693,7 @@
369123E01DDC75850095B341 /* JSCSamplingProfiler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JSCSamplingProfiler.m; sourceTree = "<group>"; };
391E86A21C623EC800009732 /* RCTTouchEvent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTTouchEvent.m; sourceTree = "<group>"; };
391E86A31C623EC800009732 /* RCTTouchEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTTouchEvent.h; sourceTree = "<group>"; };
3D10A3C81DDF3D16004A0F9D /* CSSEnums.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSEnums.h; sourceTree = "<group>"; };
3D10A3C81DDF3D16004A0F9D /* YGEnums.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YGEnums.h; sourceTree = "<group>"; };
3D1E68D81CABD13900DD7465 /* RCTDisplayLink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTDisplayLink.h; sourceTree = "<group>"; };
3D1E68D91CABD13900DD7465 /* RCTDisplayLink.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTDisplayLink.m; sourceTree = "<group>"; };
3D1FA07A1DE4F2EA00E03CC6 /* RCTNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTNetworking.h; sourceTree = "<group>"; };
@ -803,12 +803,12 @@
133683431D37ACA10077D0C3 /* CSSLayout */ = {
isa = PBXGroup;
children = (
3D10A3C81DDF3D16004A0F9D /* CSSEnums.h */,
133683441D37ACA10077D0C3 /* CSSLayout.c */,
133683451D37ACA10077D0C3 /* CSSLayout.h */,
133683481D37ACA10077D0C3 /* CSSMacros.h */,
1321C8CE1D3EB50800D58318 /* CSSNodeList.c */,
1321C8CF1D3EB50800D58318 /* CSSNodeList.h */,
3D10A3C81DDF3D16004A0F9D /* YGEnums.h */,
133683441D37ACA10077D0C3 /* Yoga.c */,
133683451D37ACA10077D0C3 /* Yoga.h */,
133683481D37ACA10077D0C3 /* YGMacros.h */,
1321C8CE1D3EB50800D58318 /* YGNodeList.c */,
1321C8CF1D3EB50800D58318 /* YGNodeList.h */,
);
name = CSSLayout;
path = CSSLayout/CSSLayout;
@ -1188,10 +1188,10 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
3D3C083D1DE334D900C268FA /* CSSMacros.h in Headers */,
3D3C083C1DE334D900C268FA /* CSSLayout.h in Headers */,
3D3C083E1DE334D900C268FA /* CSSNodeList.h in Headers */,
3D3C083B1DE334D900C268FA /* CSSEnums.h in Headers */,
3D3C083D1DE334D900C268FA /* YGMacros.h in Headers */,
3D3C083C1DE334D900C268FA /* Yoga.h in Headers */,
3D3C083E1DE334D900C268FA /* YGNodeList.h in Headers */,
3D3C083B1DE334D900C268FA /* YGEnums.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -1199,10 +1199,10 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
3D3C08411DE334DA00C268FA /* CSSMacros.h in Headers */,
3D3C08401DE334DA00C268FA /* CSSLayout.h in Headers */,
3D3C08421DE334DA00C268FA /* CSSNodeList.h in Headers */,
3D3C083F1DE334DA00C268FA /* CSSEnums.h in Headers */,
3D3C08411DE334DA00C268FA /* YGMacros.h in Headers */,
3D3C08401DE334DA00C268FA /* Yoga.h in Headers */,
3D3C08421DE334DA00C268FA /* YGNodeList.h in Headers */,
3D3C083F1DE334DA00C268FA /* YGEnums.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -1846,8 +1846,8 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
3D3C085A1DE33E4400C268FA /* CSSLayout.c in Sources */,
3D3C085E1DE33E6100C268FA /* CSSNodeList.c in Sources */,
3D3C085A1DE33E4400C268FA /* Yoga.c in Sources */,
3D3C085E1DE33E6100C268FA /* YGNodeList.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -1855,8 +1855,8 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
3D3C085C1DE33E4E00C268FA /* CSSLayout.c in Sources */,
3D3C085F1DE33E6100C268FA /* CSSNodeList.c in Sources */,
3D3C085C1DE33E4E00C268FA /* Yoga.c in Sources */,
3D3C085F1DE33E6100C268FA /* YGNodeList.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -1864,8 +1864,8 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
3D3CD9061DE5FBD600167DC4 /* CSSLayout.c in Sources */,
3D3CD9071DE5FBD600167DC4 /* CSSNodeList.c in Sources */,
3D3CD9061DE5FBD600167DC4 /* Yoga.c in Sources */,
3D3CD9071DE5FBD600167DC4 /* YGNodeList.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -1873,8 +1873,8 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
3D3CD9131DE5FBD800167DC4 /* CSSLayout.c in Sources */,
3D3CD9141DE5FBD800167DC4 /* CSSNodeList.c in Sources */,
3D3CD9131DE5FBD800167DC4 /* Yoga.c in Sources */,
3D3CD9141DE5FBD800167DC4 /* YGNodeList.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -1882,8 +1882,8 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
3D3CD9201DE5FBEC00167DC4 /* CSSLayout.c in Sources */,
3D3CD9211DE5FBEC00167DC4 /* CSSNodeList.c in Sources */,
3D3CD9201DE5FBEC00167DC4 /* Yoga.c in Sources */,
3D3CD9211DE5FBEC00167DC4 /* YGNodeList.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -1891,8 +1891,8 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
3D3CD92D1DE5FBEE00167DC4 /* CSSLayout.c in Sources */,
3D3CD92E1DE5FBEE00167DC4 /* CSSNodeList.c in Sources */,
3D3CD92D1DE5FBEE00167DC4 /* Yoga.c in Sources */,
3D3CD92E1DE5FBEE00167DC4 /* YGNodeList.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@ -21,7 +21,7 @@
self = [super init];
if (self) {
if ([[RCTI18nUtil sharedInstance] isRTL]) {
CSSNodeStyleSetDirection(self.cssNode, YGDirectionRTL);
YGNodeStyleSetDirection(self.cssNode, YGDirectionRTL);
}
}
return self;
@ -33,14 +33,14 @@
case RCTRootViewSizeFlexibilityNone:
break;
case RCTRootViewSizeFlexibilityWidth:
CSSNodeStyleSetWidth(self.cssNode, YGUndefined);
YGNodeStyleSetWidth(self.cssNode, YGUndefined);
break;
case RCTRootViewSizeFlexibilityHeight:
CSSNodeStyleSetHeight(self.cssNode, YGUndefined);
YGNodeStyleSetHeight(self.cssNode, YGUndefined);
break;
case RCTRootViewSizeFlexibilityWidthAndHeight:
CSSNodeStyleSetWidth(self.cssNode, YGUndefined);
CSSNodeStyleSetHeight(self.cssNode, YGUndefined);
YGNodeStyleSetWidth(self.cssNode, YGUndefined);
YGNodeStyleSetHeight(self.cssNode, YGUndefined);
break;
}
}
@ -49,7 +49,7 @@
{
[self applySizeConstraints];
CSSNodeCalculateLayout(self.cssNode, YGUndefined, YGUndefined, YGDirectionInherit);
YGNodeCalculateLayout(self.cssNode, YGUndefined, YGUndefined, YGDirectionInherit);
NSMutableSet<RCTShadowView *> *viewsWithNewFrame = [NSMutableSet set];
[self applyLayoutNode:self.cssNode viewsWithNewFrame:viewsWithNewFrame absolutePosition:CGPointZero];

View File

@ -9,7 +9,7 @@
#import <UIKit/UIKit.h>
#import <CSSLayout/CSSLayout.h>
#import <CSSLayout/Yoga.h>
#import <React/RCTComponent.h>
#import <React/RCTRootView.h>
@ -44,7 +44,7 @@ typedef void (^RCTApplierBlock)(NSDictionary<NSNumber *, UIView *> *viewRegistry
- (void)removeReactSubview:(RCTShadowView *)subview NS_REQUIRES_SUPER;
@property (nonatomic, weak, readonly) RCTShadowView *superview;
@property (nonatomic, assign, readonly) CSSNodeRef cssNode;
@property (nonatomic, assign, readonly) YGNodeRef cssNode;
@property (nonatomic, copy) NSString *viewName;
@property (nonatomic, strong) UIColor *backgroundColor; // Used to propagate to children
@property (nonatomic, copy) RCTDirectEventBlock onLayout;
@ -183,21 +183,21 @@ typedef void (^RCTApplierBlock)(NSDictionary<NSNumber *, UIView *> *viewRegistry
* is split into two methods so subclasses can override `applyLayoutToChildren:`
* while using default implementation of `applyLayoutNode:`.
*/
- (void)applyLayoutNode:(CSSNodeRef)node
- (void)applyLayoutNode:(YGNodeRef)node
viewsWithNewFrame:(NSMutableSet<RCTShadowView *> *)viewsWithNewFrame
absolutePosition:(CGPoint)absolutePosition NS_REQUIRES_SUPER;
/**
* Enumerate the child nodes and tell them to apply layout.
*/
- (void)applyLayoutToChildren:(CSSNodeRef)node
- (void)applyLayoutToChildren:(YGNodeRef)node
viewsWithNewFrame:(NSMutableSet<RCTShadowView *> *)viewsWithNewFrame
absolutePosition:(CGPoint)absolutePosition;
/**
* Return whether or not this node acts as a leaf node in the eyes of CSSLayout. For example
* RCTShadowText has children which it does not want CSSLayout to lay out so in the eyes of
* CSSLayout it is a leaf node.
* Return whether or not this node acts as a leaf node in the eyes of Yoga. For example
* RCTShadowText has children which it does not want Yoga to lay out so in the eyes of
* Yoga it is a leaf node.
*/
- (BOOL)isCSSLeafNode;

View File

@ -50,53 +50,53 @@ typedef NS_ENUM(unsigned int, meta_prop_t) {
// cssNode api
static void RCTPrint(CSSNodeRef node)
static void RCTPrint(YGNodeRef node)
{
RCTShadowView *shadowView = (__bridge RCTShadowView *)CSSNodeGetContext(node);
RCTShadowView *shadowView = (__bridge RCTShadowView *)YGNodeGetContext(node);
printf("%s(%zd), ", shadowView.viewName.UTF8String, shadowView.reactTag.integerValue);
}
// Enforces precedence rules, e.g. marginLeft > marginHorizontal > margin.
#define DEFINE_PROCESS_META_PROPS(type) \
static void RCTProcessMetaProps##type(const float metaProps[META_PROP_COUNT], CSSNodeRef node) { \
if (!CSSValueIsUndefined(metaProps[META_PROP_LEFT])) { \
CSSNodeStyleSet##type(node, YGEdgeStart, metaProps[META_PROP_LEFT]); \
} else if (!CSSValueIsUndefined(metaProps[META_PROP_HORIZONTAL])) { \
CSSNodeStyleSet##type(node, YGEdgeStart, metaProps[META_PROP_HORIZONTAL]); \
} else if (!CSSValueIsUndefined(metaProps[META_PROP_ALL])) { \
CSSNodeStyleSet##type(node, YGEdgeStart, metaProps[META_PROP_ALL]); \
static void RCTProcessMetaProps##type(const float metaProps[META_PROP_COUNT], YGNodeRef node) { \
if (!YGValueIsUndefined(metaProps[META_PROP_LEFT])) { \
YGNodeStyleSet##type(node, YGEdgeStart, metaProps[META_PROP_LEFT]); \
} else if (!YGValueIsUndefined(metaProps[META_PROP_HORIZONTAL])) { \
YGNodeStyleSet##type(node, YGEdgeStart, metaProps[META_PROP_HORIZONTAL]); \
} else if (!YGValueIsUndefined(metaProps[META_PROP_ALL])) { \
YGNodeStyleSet##type(node, YGEdgeStart, metaProps[META_PROP_ALL]); \
} else { \
CSSNodeStyleSet##type(node, YGEdgeStart, 0); \
YGNodeStyleSet##type(node, YGEdgeStart, 0); \
} \
\
if (!CSSValueIsUndefined(metaProps[META_PROP_RIGHT])) { \
CSSNodeStyleSet##type(node, YGEdgeEnd, metaProps[META_PROP_RIGHT]); \
} else if (!CSSValueIsUndefined(metaProps[META_PROP_HORIZONTAL])) { \
CSSNodeStyleSet##type(node, YGEdgeEnd, metaProps[META_PROP_HORIZONTAL]); \
} else if (!CSSValueIsUndefined(metaProps[META_PROP_ALL])) { \
CSSNodeStyleSet##type(node, YGEdgeEnd, metaProps[META_PROP_ALL]); \
if (!YGValueIsUndefined(metaProps[META_PROP_RIGHT])) { \
YGNodeStyleSet##type(node, YGEdgeEnd, metaProps[META_PROP_RIGHT]); \
} else if (!YGValueIsUndefined(metaProps[META_PROP_HORIZONTAL])) { \
YGNodeStyleSet##type(node, YGEdgeEnd, metaProps[META_PROP_HORIZONTAL]); \
} else if (!YGValueIsUndefined(metaProps[META_PROP_ALL])) { \
YGNodeStyleSet##type(node, YGEdgeEnd, metaProps[META_PROP_ALL]); \
} else { \
CSSNodeStyleSet##type(node, YGEdgeEnd, 0); \
YGNodeStyleSet##type(node, YGEdgeEnd, 0); \
} \
\
if (!CSSValueIsUndefined(metaProps[META_PROP_TOP])) { \
CSSNodeStyleSet##type(node, YGEdgeTop, metaProps[META_PROP_TOP]); \
} else if (!CSSValueIsUndefined(metaProps[META_PROP_VERTICAL])) { \
CSSNodeStyleSet##type(node, YGEdgeTop, metaProps[META_PROP_VERTICAL]); \
} else if (!CSSValueIsUndefined(metaProps[META_PROP_ALL])) { \
CSSNodeStyleSet##type(node, YGEdgeTop, metaProps[META_PROP_ALL]); \
if (!YGValueIsUndefined(metaProps[META_PROP_TOP])) { \
YGNodeStyleSet##type(node, YGEdgeTop, metaProps[META_PROP_TOP]); \
} else if (!YGValueIsUndefined(metaProps[META_PROP_VERTICAL])) { \
YGNodeStyleSet##type(node, YGEdgeTop, metaProps[META_PROP_VERTICAL]); \
} else if (!YGValueIsUndefined(metaProps[META_PROP_ALL])) { \
YGNodeStyleSet##type(node, YGEdgeTop, metaProps[META_PROP_ALL]); \
} else { \
CSSNodeStyleSet##type(node, YGEdgeTop, 0); \
YGNodeStyleSet##type(node, YGEdgeTop, 0); \
} \
\
if (!CSSValueIsUndefined(metaProps[META_PROP_BOTTOM])) { \
CSSNodeStyleSet##type(node, YGEdgeBottom, metaProps[META_PROP_BOTTOM]); \
} else if (!CSSValueIsUndefined(metaProps[META_PROP_VERTICAL])) { \
CSSNodeStyleSet##type(node, YGEdgeBottom, metaProps[META_PROP_VERTICAL]); \
} else if (!CSSValueIsUndefined(metaProps[META_PROP_ALL])) { \
CSSNodeStyleSet##type(node, YGEdgeBottom, metaProps[META_PROP_ALL]); \
if (!YGValueIsUndefined(metaProps[META_PROP_BOTTOM])) { \
YGNodeStyleSet##type(node, YGEdgeBottom, metaProps[META_PROP_BOTTOM]); \
} else if (!YGValueIsUndefined(metaProps[META_PROP_VERTICAL])) { \
YGNodeStyleSet##type(node, YGEdgeBottom, metaProps[META_PROP_VERTICAL]); \
} else if (!YGValueIsUndefined(metaProps[META_PROP_ALL])) { \
YGNodeStyleSet##type(node, YGEdgeBottom, metaProps[META_PROP_ALL]); \
} else { \
CSSNodeStyleSet##type(node, YGEdgeBottom, 0); \
YGNodeStyleSet##type(node, YGEdgeBottom, 0); \
} \
}
@ -133,38 +133,38 @@ DEFINE_PROCESS_META_PROPS(Border);
// width = 213.5 - 106.5 = 107
// You'll notice that this is the same width we calculated for the parent view because we've taken its position into account.
- (void)applyLayoutNode:(CSSNodeRef)node
- (void)applyLayoutNode:(YGNodeRef)node
viewsWithNewFrame:(NSMutableSet<RCTShadowView *> *)viewsWithNewFrame
absolutePosition:(CGPoint)absolutePosition
{
if (!CSSNodeGetHasNewLayout(node)) {
if (!YGNodeGetHasNewLayout(node)) {
return;
}
CSSNodeSetHasNewLayout(node, false);
YGNodeSetHasNewLayout(node, false);
#if RCT_DEBUG
// This works around a breaking change in css-layout where setting flexBasis needs to be set explicitly, instead of relying on flex to propagate.
// We check for it by seeing if a width/height is provided along with a flexBasis of 0 and the width/height is laid out as 0.
if ((!CSSValueIsUndefined(CSSNodeStyleGetFlexBasis(node)) && CSSNodeStyleGetFlexBasis(node) == 0) &&
((!CSSValueIsUndefined(CSSNodeStyleGetWidth(node)) && CSSNodeStyleGetWidth(node) > 0 && CSSNodeLayoutGetWidth(node) == 0) ||
(!CSSValueIsUndefined(CSSNodeStyleGetHeight(node)) && CSSNodeStyleGetHeight(node) > 0 && CSSNodeLayoutGetHeight(node) == 0))) {
if ((!YGValueIsUndefined(YGNodeStyleGetFlexBasis(node)) && YGNodeStyleGetFlexBasis(node) == 0) &&
((!YGValueIsUndefined(YGNodeStyleGetWidth(node)) && YGNodeStyleGetWidth(node) > 0 && YGNodeLayoutGetWidth(node) == 0) ||
(!YGValueIsUndefined(YGNodeStyleGetHeight(node)) && YGNodeStyleGetHeight(node) > 0 && YGNodeLayoutGetHeight(node) == 0))) {
RCTLogError(@"View was rendered with explicitly set width/height but with a 0 flexBasis. (This might be fixed by changing flex: to flexGrow:) View: %@", self);
}
#endif
CGPoint absoluteTopLeft = {
absolutePosition.x + CSSNodeLayoutGetLeft(node),
absolutePosition.y + CSSNodeLayoutGetTop(node)
absolutePosition.x + YGNodeLayoutGetLeft(node),
absolutePosition.y + YGNodeLayoutGetTop(node)
};
CGPoint absoluteBottomRight = {
absolutePosition.x + CSSNodeLayoutGetLeft(node) + CSSNodeLayoutGetWidth(node),
absolutePosition.y + CSSNodeLayoutGetTop(node) + CSSNodeLayoutGetHeight(node)
absolutePosition.x + YGNodeLayoutGetLeft(node) + YGNodeLayoutGetWidth(node),
absolutePosition.y + YGNodeLayoutGetTop(node) + YGNodeLayoutGetHeight(node)
};
CGRect frame = {{
RCTRoundPixelValue(CSSNodeLayoutGetLeft(node)),
RCTRoundPixelValue(CSSNodeLayoutGetTop(node)),
RCTRoundPixelValue(YGNodeLayoutGetLeft(node)),
RCTRoundPixelValue(YGNodeLayoutGetTop(node)),
}, {
RCTRoundPixelValue(absoluteBottomRight.x - absoluteTopLeft.x),
RCTRoundPixelValue(absoluteBottomRight.y - absoluteTopLeft.y)
@ -175,19 +175,19 @@ DEFINE_PROCESS_META_PROPS(Border);
[viewsWithNewFrame addObject:self];
}
absolutePosition.x += CSSNodeLayoutGetLeft(node);
absolutePosition.y += CSSNodeLayoutGetTop(node);
absolutePosition.x += YGNodeLayoutGetLeft(node);
absolutePosition.y += YGNodeLayoutGetTop(node);
[self applyLayoutToChildren:node viewsWithNewFrame:viewsWithNewFrame absolutePosition:absolutePosition];
}
- (void)applyLayoutToChildren:(CSSNodeRef)node
- (void)applyLayoutToChildren:(YGNodeRef)node
viewsWithNewFrame:(NSMutableSet<RCTShadowView *> *)viewsWithNewFrame
absolutePosition:(CGPoint)absolutePosition
{
for (unsigned int i = 0; i < CSSNodeChildCount(node); ++i) {
for (unsigned int i = 0; i < YGNodeChildCount(node); ++i) {
RCTShadowView *child = (RCTShadowView *)_reactSubviews[i];
[child applyLayoutNode:CSSNodeGetChild(node, i)
[child applyLayoutNode:YGNodeGetChild(node, i)
viewsWithNewFrame:viewsWithNewFrame
absolutePosition:absolutePosition];
}
@ -261,14 +261,14 @@ DEFINE_PROCESS_META_PROPS(Border);
}
if (!CGRectEqualToRect(frame, _frame)) {
CSSNodeStyleSetPositionType(_cssNode, YGPositionTypeAbsolute);
CSSNodeStyleSetWidth(_cssNode, frame.size.width);
CSSNodeStyleSetHeight(_cssNode, frame.size.height);
CSSNodeStyleSetPosition(_cssNode, YGEdgeLeft, frame.origin.x);
CSSNodeStyleSetPosition(_cssNode, YGEdgeTop, frame.origin.y);
YGNodeStyleSetPositionType(_cssNode, YGPositionTypeAbsolute);
YGNodeStyleSetWidth(_cssNode, frame.size.width);
YGNodeStyleSetHeight(_cssNode, frame.size.height);
YGNodeStyleSetPosition(_cssNode, YGEdgeLeft, frame.origin.x);
YGNodeStyleSetPosition(_cssNode, YGEdgeTop, frame.origin.y);
}
CSSNodeCalculateLayout(_cssNode, frame.size.width, frame.size.height, YGDirectionInherit);
YGNodeCalculateLayout(_cssNode, frame.size.width, frame.size.height, YGDirectionInherit);
[self applyLayoutNode:_cssNode viewsWithNewFrame:viewsWithNewFrame absolutePosition:absolutePosition];
}
@ -318,9 +318,9 @@ DEFINE_PROCESS_META_PROPS(Border);
_reactSubviews = [NSMutableArray array];
_cssNode = CSSNodeNew();
CSSNodeSetContext(_cssNode, (__bridge void *)self);
CSSNodeSetPrintFunc(_cssNode, RCTPrint);
_cssNode = YGNodeNew();
YGNodeSetContext(_cssNode, (__bridge void *)self);
YGNodeSetPrintFunc(_cssNode, RCTPrint);
}
return self;
}
@ -332,7 +332,7 @@ DEFINE_PROCESS_META_PROPS(Border);
- (void)dealloc
{
CSSNodeFree(_cssNode);
YGNodeFree(_cssNode);
}
- (BOOL)isCSSLeafNode
@ -375,7 +375,7 @@ DEFINE_PROCESS_META_PROPS(Border);
{
[_reactSubviews insertObject:subview atIndex:atIndex];
if (![self isCSSLeafNode]) {
CSSNodeInsertChild(_cssNode, subview.cssNode, (uint32_t)atIndex);
YGNodeInsertChild(_cssNode, subview.cssNode, (uint32_t)atIndex);
}
subview->_superview = self;
_didUpdateSubviews = YES;
@ -391,7 +391,7 @@ DEFINE_PROCESS_META_PROPS(Border);
subview->_superview = nil;
[_reactSubviews removeObject:subview];
if (![self isCSSLeafNode]) {
CSSNodeRemoveChild(_cssNode, subview.cssNode);
YGNodeRemoveChild(_cssNode, subview.cssNode);
}
}
@ -491,27 +491,27 @@ RCT_PADDING_PROPERTY(Right, RIGHT)
- (UIEdgeInsets)paddingAsInsets
{
if (CSSNodeLayoutGetDirection(_cssNode) == YGDirectionRTL) {
if (YGNodeLayoutGetDirection(_cssNode) == YGDirectionRTL) {
return (UIEdgeInsets){
CSSNodeStyleGetPadding(_cssNode, YGEdgeTop),
!CSSValueIsUndefined(CSSNodeStyleGetPadding(_cssNode, YGEdgeEnd)) ?
CSSNodeStyleGetPadding(_cssNode, YGEdgeEnd) :
CSSNodeStyleGetPadding(_cssNode, YGEdgeLeft),
CSSNodeStyleGetPadding(_cssNode, YGEdgeBottom),
!CSSValueIsUndefined(CSSNodeStyleGetPadding(_cssNode, YGEdgeStart)) ?
CSSNodeStyleGetPadding(_cssNode, YGEdgeStart) :
CSSNodeStyleGetPadding(_cssNode, YGEdgeRight)
YGNodeStyleGetPadding(_cssNode, YGEdgeTop),
!YGValueIsUndefined(YGNodeStyleGetPadding(_cssNode, YGEdgeEnd)) ?
YGNodeStyleGetPadding(_cssNode, YGEdgeEnd) :
YGNodeStyleGetPadding(_cssNode, YGEdgeLeft),
YGNodeStyleGetPadding(_cssNode, YGEdgeBottom),
!YGValueIsUndefined(YGNodeStyleGetPadding(_cssNode, YGEdgeStart)) ?
YGNodeStyleGetPadding(_cssNode, YGEdgeStart) :
YGNodeStyleGetPadding(_cssNode, YGEdgeRight)
};
} else {
return (UIEdgeInsets){
CSSNodeStyleGetPadding(_cssNode, YGEdgeTop),
!CSSValueIsUndefined(CSSNodeStyleGetPadding(_cssNode, YGEdgeStart)) ?
CSSNodeStyleGetPadding(_cssNode, YGEdgeStart) :
CSSNodeStyleGetPadding(_cssNode, YGEdgeLeft),
CSSNodeStyleGetPadding(_cssNode, YGEdgeBottom),
!CSSValueIsUndefined(CSSNodeStyleGetPadding(_cssNode, YGEdgeEnd)) ?
CSSNodeStyleGetPadding(_cssNode, YGEdgeEnd) :
CSSNodeStyleGetPadding(_cssNode, YGEdgeRight)
YGNodeStyleGetPadding(_cssNode, YGEdgeTop),
!YGValueIsUndefined(YGNodeStyleGetPadding(_cssNode, YGEdgeStart)) ?
YGNodeStyleGetPadding(_cssNode, YGEdgeStart) :
YGNodeStyleGetPadding(_cssNode, YGEdgeLeft),
YGNodeStyleGetPadding(_cssNode, YGEdgeBottom),
!YGValueIsUndefined(YGNodeStyleGetPadding(_cssNode, YGEdgeEnd)) ?
YGNodeStyleGetPadding(_cssNode, YGEdgeEnd) :
YGNodeStyleGetPadding(_cssNode, YGEdgeRight)
};
}
}
@ -541,12 +541,12 @@ RCT_BORDER_PROPERTY(Right, RIGHT)
#define RCT_DIMENSION_PROPERTY(setProp, getProp, cssProp) \
- (void)set##setProp:(float)value \
{ \
CSSNodeStyleSet##cssProp(_cssNode, value); \
YGNodeStyleSet##cssProp(_cssNode, value); \
[self dirtyText]; \
} \
- (float)getProp \
{ \
return CSSNodeStyleGet##cssProp(_cssNode); \
return YGNodeStyleGet##cssProp(_cssNode); \
}
RCT_DIMENSION_PROPERTY(Width, width, Width)
@ -561,12 +561,12 @@ RCT_DIMENSION_PROPERTY(MaxHeight, maxHeight, MaxHeight)
#define RCT_POSITION_PROPERTY(setProp, getProp, edge) \
- (void)set##setProp:(float)value \
{ \
CSSNodeStyleSetPosition(_cssNode, edge, value); \
YGNodeStyleSetPosition(_cssNode, edge, value); \
[self dirtyText]; \
} \
- (float)getProp \
{ \
return CSSNodeStyleGetPosition(_cssNode, edge); \
return YGNodeStyleGetPosition(_cssNode, edge); \
}
RCT_POSITION_PROPERTY(Top, top, YGEdgeTop)
@ -578,25 +578,25 @@ RCT_POSITION_PROPERTY(Left, left, YGEdgeStart)
{
if (!CGRectEqualToRect(frame, _frame)) {
_frame = frame;
CSSNodeStyleSetPosition(_cssNode, YGEdgeLeft, CGRectGetMinX(frame));
CSSNodeStyleSetPosition(_cssNode, YGEdgeTop, CGRectGetMinY(frame));
CSSNodeStyleSetWidth(_cssNode, CGRectGetWidth(frame));
CSSNodeStyleSetHeight(_cssNode, CGRectGetHeight(frame));
YGNodeStyleSetPosition(_cssNode, YGEdgeLeft, CGRectGetMinX(frame));
YGNodeStyleSetPosition(_cssNode, YGEdgeTop, CGRectGetMinY(frame));
YGNodeStyleSetWidth(_cssNode, CGRectGetWidth(frame));
YGNodeStyleSetHeight(_cssNode, CGRectGetHeight(frame));
}
}
static inline void RCTAssignSuggestedDimension(CSSNodeRef cssNode, YGDimension dimension, CGFloat amount)
static inline void RCTAssignSuggestedDimension(YGNodeRef cssNode, YGDimension dimension, CGFloat amount)
{
if (amount != UIViewNoIntrinsicMetric) {
switch (dimension) {
case YGDimensionWidth:
if (isnan(CSSNodeStyleGetWidth(cssNode))) {
CSSNodeStyleSetWidth(cssNode, amount);
if (isnan(YGNodeStyleGetWidth(cssNode))) {
YGNodeStyleSetWidth(cssNode, amount);
}
break;
case YGDimensionHeight:
if (isnan(CSSNodeStyleGetHeight(cssNode))) {
CSSNodeStyleSetHeight(cssNode, amount);
if (isnan(YGNodeStyleGetHeight(cssNode))) {
YGNodeStyleSetHeight(cssNode, amount);
}
break;
case YGDimensionCount:
@ -607,7 +607,7 @@ static inline void RCTAssignSuggestedDimension(CSSNodeRef cssNode, YGDimension d
- (void)setIntrinsicContentSize:(CGSize)size
{
if (CSSNodeStyleGetFlexGrow(_cssNode) == 0 && CSSNodeStyleGetFlexShrink(_cssNode) == 0) {
if (YGNodeStyleGetFlexGrow(_cssNode) == 0 && YGNodeStyleGetFlexShrink(_cssNode) == 0) {
RCTAssignSuggestedDimension(_cssNode, YGDimensionHeight, size.height);
RCTAssignSuggestedDimension(_cssNode, YGDimensionWidth, size.width);
}
@ -615,31 +615,31 @@ static inline void RCTAssignSuggestedDimension(CSSNodeRef cssNode, YGDimension d
- (void)setTopLeft:(CGPoint)topLeft
{
CSSNodeStyleSetPosition(_cssNode, YGEdgeLeft, topLeft.x);
CSSNodeStyleSetPosition(_cssNode, YGEdgeTop, topLeft.y);
YGNodeStyleSetPosition(_cssNode, YGEdgeLeft, topLeft.x);
YGNodeStyleSetPosition(_cssNode, YGEdgeTop, topLeft.y);
}
- (void)setSize:(CGSize)size
{
CSSNodeStyleSetWidth(_cssNode, size.width);
CSSNodeStyleSetHeight(_cssNode, size.height);
YGNodeStyleSetWidth(_cssNode, size.width);
YGNodeStyleSetHeight(_cssNode, size.height);
}
// Flex
- (void)setFlex:(float)value
{
CSSNodeStyleSetFlex(_cssNode, value);
YGNodeStyleSetFlex(_cssNode, value);
}
#define RCT_STYLE_PROPERTY(setProp, getProp, cssProp, type) \
- (void)set##setProp:(type)value \
{ \
CSSNodeStyleSet##cssProp(_cssNode, value); \
YGNodeStyleSet##cssProp(_cssNode, value); \
} \
- (type)getProp \
{ \
return CSSNodeStyleGet##cssProp(_cssNode); \
return YGNodeStyleGet##cssProp(_cssNode); \
}
RCT_STYLE_PROPERTY(FlexGrow, flexGrow, FlexGrow, float)

View File

@ -27,26 +27,26 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
/**
* Get native instance count. Useful for testing only.
*/
static native int jni_CSSNodeGetInstanceCount();
static native void jni_CSSLog(int level, String message);
static native int jni_YGNodeGetInstanceCount();
static native void jni_YGLog(int level, String message);
private static native void jni_CSSLayoutSetLogger(Object logger);
private static native void jni_YGSetLogger(Object logger);
public static void setLogger(CSSLogger logger) {
jni_CSSLayoutSetLogger(logger);
jni_YGSetLogger(logger);
}
private static native void jni_CSSLayoutSetExperimentalFeatureEnabled(
private static native void jni_YGSetExperimentalFeatureEnabled(
int feature,
boolean enabled);
public static void setExperimentalFeatureEnabled(
YogaExperimentalFeature feature,
boolean enabled) {
jni_CSSLayoutSetExperimentalFeatureEnabled(feature.intValue(), enabled);
jni_YGSetExperimentalFeatureEnabled(feature.intValue(), enabled);
}
private static native boolean jni_CSSLayoutIsExperimentalFeatureEnabled(int feature);
private static native boolean jni_YGIsExperimentalFeatureEnabled(int feature);
public static boolean isExperimentalFeatureEnabled(YogaExperimentalFeature feature) {
return jni_CSSLayoutIsExperimentalFeatureEnabled(feature.intValue());
return jni_YGIsExperimentalFeatureEnabled(feature.intValue());
}
private CSSNode mParent;
@ -71,25 +71,25 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
@DoNotStrip
private int mLayoutDirection = 0;
private native long jni_CSSNodeNew();
private native long jni_YGNodeNew();
public CSSNode() {
mNativePointer = jni_CSSNodeNew();
mNativePointer = jni_YGNodeNew();
if (mNativePointer == 0) {
throw new IllegalStateException("Failed to allocate native memory");
}
}
private native void jni_CSSNodeFree(long nativePointer);
private native void jni_YGNodeFree(long nativePointer);
@Override
protected void finalize() throws Throwable {
try {
jni_CSSNodeFree(mNativePointer);
jni_YGNodeFree(mNativePointer);
} finally {
super.finalize();
}
}
private native void jni_CSSNodeReset(long nativePointer);
private native void jni_YGNodeReset(long nativePointer);
@Override
public void reset() {
mHasSetPadding = false;
@ -106,7 +106,7 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
mMeasureFunction = null;
mData = null;
jni_CSSNodeReset(mNativePointer);
jni_YGNodeReset(mNativePointer);
}
@Override
@ -119,7 +119,7 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
return mChildren.get(i);
}
private native void jni_CSSNodeInsertChild(long nativePointer, long childPointer, int index);
private native void jni_YGNodeInsertChild(long nativePointer, long childPointer, int index);
@Override
public void addChildAt(CSSNode child, int i) {
if (child.mParent != null) {
@ -131,16 +131,16 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
}
mChildren.add(i, child);
child.mParent = this;
jni_CSSNodeInsertChild(mNativePointer, child.mNativePointer, i);
jni_YGNodeInsertChild(mNativePointer, child.mNativePointer, i);
}
private native void jni_CSSNodeRemoveChild(long nativePointer, long childPointer);
private native void jni_YGNodeRemoveChild(long nativePointer, long childPointer);
@Override
public CSSNode removeChildAt(int i) {
final CSSNode child = mChildren.remove(i);
child.mParent = null;
jni_CSSNodeRemoveChild(mNativePointer, child.mNativePointer);
jni_YGNodeRemoveChild(mNativePointer, child.mNativePointer);
return child;
}
@ -155,330 +155,330 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
return mChildren == null ? -1 : mChildren.indexOf(child);
}
private native void jni_CSSNodeCalculateLayout(long nativePointer);
private native void jni_YGNodeCalculateLayout(long nativePointer);
@Override
public void calculateLayout() {
jni_CSSNodeCalculateLayout(mNativePointer);
jni_YGNodeCalculateLayout(mNativePointer);
}
private native boolean jni_CSSNodeHasNewLayout(long nativePointer);
private native boolean jni_YGNodeHasNewLayout(long nativePointer);
@Override
public boolean hasNewLayout() {
return jni_CSSNodeHasNewLayout(mNativePointer);
return jni_YGNodeHasNewLayout(mNativePointer);
}
private native void jni_CSSNodeMarkDirty(long nativePointer);
private native void jni_YGNodeMarkDirty(long nativePointer);
@Override
public void dirty() {
jni_CSSNodeMarkDirty(mNativePointer);
jni_YGNodeMarkDirty(mNativePointer);
}
private native boolean jni_CSSNodeIsDirty(long nativePointer);
private native boolean jni_YGNodeIsDirty(long nativePointer);
@Override
public boolean isDirty() {
return jni_CSSNodeIsDirty(mNativePointer);
return jni_YGNodeIsDirty(mNativePointer);
}
private native void jni_CSSNodeMarkLayoutSeen(long nativePointer);
private native void jni_YGNodeMarkLayoutSeen(long nativePointer);
@Override
public void markLayoutSeen() {
jni_CSSNodeMarkLayoutSeen(mNativePointer);
jni_YGNodeMarkLayoutSeen(mNativePointer);
}
private native void jni_CSSNodeCopyStyle(long dstNativePointer, long srcNativePointer);
private native void jni_YGNodeCopyStyle(long dstNativePointer, long srcNativePointer);
@Override
public void copyStyle(CSSNode srcNode) {
jni_CSSNodeCopyStyle(mNativePointer, srcNode.mNativePointer);
jni_YGNodeCopyStyle(mNativePointer, srcNode.mNativePointer);
}
private native int jni_CSSNodeStyleGetDirection(long nativePointer);
private native int jni_YGNodeStyleGetDirection(long nativePointer);
@Override
public YogaDirection getStyleDirection() {
return YogaDirection.values()[jni_CSSNodeStyleGetDirection(mNativePointer)];
return YogaDirection.values()[jni_YGNodeStyleGetDirection(mNativePointer)];
}
private native void jni_CSSNodeStyleSetDirection(long nativePointer, int direction);
private native void jni_YGNodeStyleSetDirection(long nativePointer, int direction);
@Override
public void setDirection(YogaDirection direction) {
jni_CSSNodeStyleSetDirection(mNativePointer, direction.intValue());
jni_YGNodeStyleSetDirection(mNativePointer, direction.intValue());
}
private native int jni_CSSNodeStyleGetFlexDirection(long nativePointer);
private native int jni_YGNodeStyleGetFlexDirection(long nativePointer);
@Override
public YogaFlexDirection getFlexDirection() {
return YogaFlexDirection.values()[jni_CSSNodeStyleGetFlexDirection(mNativePointer)];
return YogaFlexDirection.values()[jni_YGNodeStyleGetFlexDirection(mNativePointer)];
}
private native void jni_CSSNodeStyleSetFlexDirection(long nativePointer, int flexDirection);
private native void jni_YGNodeStyleSetFlexDirection(long nativePointer, int flexDirection);
@Override
public void setFlexDirection(YogaFlexDirection flexDirection) {
jni_CSSNodeStyleSetFlexDirection(mNativePointer, flexDirection.intValue());
jni_YGNodeStyleSetFlexDirection(mNativePointer, flexDirection.intValue());
}
private native int jni_CSSNodeStyleGetJustifyContent(long nativePointer);
private native int jni_YGNodeStyleGetJustifyContent(long nativePointer);
@Override
public YogaJustify getJustifyContent() {
return YogaJustify.values()[jni_CSSNodeStyleGetJustifyContent(mNativePointer)];
return YogaJustify.values()[jni_YGNodeStyleGetJustifyContent(mNativePointer)];
}
private native void jni_CSSNodeStyleSetJustifyContent(long nativePointer, int justifyContent);
private native void jni_YGNodeStyleSetJustifyContent(long nativePointer, int justifyContent);
@Override
public void setJustifyContent(YogaJustify justifyContent) {
jni_CSSNodeStyleSetJustifyContent(mNativePointer, justifyContent.intValue());
jni_YGNodeStyleSetJustifyContent(mNativePointer, justifyContent.intValue());
}
private native int jni_CSSNodeStyleGetAlignItems(long nativePointer);
private native int jni_YGNodeStyleGetAlignItems(long nativePointer);
@Override
public YogaAlign getAlignItems() {
return YogaAlign.values()[jni_CSSNodeStyleGetAlignItems(mNativePointer)];
return YogaAlign.values()[jni_YGNodeStyleGetAlignItems(mNativePointer)];
}
private native void jni_CSSNodeStyleSetAlignItems(long nativePointer, int alignItems);
private native void jni_YGNodeStyleSetAlignItems(long nativePointer, int alignItems);
@Override
public void setAlignItems(YogaAlign alignItems) {
jni_CSSNodeStyleSetAlignItems(mNativePointer, alignItems.intValue());
jni_YGNodeStyleSetAlignItems(mNativePointer, alignItems.intValue());
}
private native int jni_CSSNodeStyleGetAlignSelf(long nativePointer);
private native int jni_YGNodeStyleGetAlignSelf(long nativePointer);
@Override
public YogaAlign getAlignSelf() {
return YogaAlign.values()[jni_CSSNodeStyleGetAlignSelf(mNativePointer)];
return YogaAlign.values()[jni_YGNodeStyleGetAlignSelf(mNativePointer)];
}
private native void jni_CSSNodeStyleSetAlignSelf(long nativePointer, int alignSelf);
private native void jni_YGNodeStyleSetAlignSelf(long nativePointer, int alignSelf);
@Override
public void setAlignSelf(YogaAlign alignSelf) {
jni_CSSNodeStyleSetAlignSelf(mNativePointer, alignSelf.intValue());
jni_YGNodeStyleSetAlignSelf(mNativePointer, alignSelf.intValue());
}
private native int jni_CSSNodeStyleGetAlignContent(long nativePointer);
private native int jni_YGNodeStyleGetAlignContent(long nativePointer);
@Override
public YogaAlign getAlignContent() {
return YogaAlign.values()[jni_CSSNodeStyleGetAlignContent(mNativePointer)];
return YogaAlign.values()[jni_YGNodeStyleGetAlignContent(mNativePointer)];
}
private native void jni_CSSNodeStyleSetAlignContent(long nativePointer, int alignContent);
private native void jni_YGNodeStyleSetAlignContent(long nativePointer, int alignContent);
@Override
public void setAlignContent(YogaAlign alignContent) {
jni_CSSNodeStyleSetAlignContent(mNativePointer, alignContent.intValue());
jni_YGNodeStyleSetAlignContent(mNativePointer, alignContent.intValue());
}
private native int jni_CSSNodeStyleGetPositionType(long nativePointer);
private native int jni_YGNodeStyleGetPositionType(long nativePointer);
@Override
public YogaPositionType getPositionType() {
return YogaPositionType.values()[jni_CSSNodeStyleGetPositionType(mNativePointer)];
return YogaPositionType.values()[jni_YGNodeStyleGetPositionType(mNativePointer)];
}
private native void jni_CSSNodeStyleSetPositionType(long nativePointer, int positionType);
private native void jni_YGNodeStyleSetPositionType(long nativePointer, int positionType);
@Override
public void setPositionType(YogaPositionType positionType) {
jni_CSSNodeStyleSetPositionType(mNativePointer, positionType.intValue());
jni_YGNodeStyleSetPositionType(mNativePointer, positionType.intValue());
}
private native void jni_CSSNodeStyleSetFlexWrap(long nativePointer, int wrapType);
private native void jni_YGNodeStyleSetFlexWrap(long nativePointer, int wrapType);
@Override
public void setWrap(YogaWrap flexWrap) {
jni_CSSNodeStyleSetFlexWrap(mNativePointer, flexWrap.intValue());
jni_YGNodeStyleSetFlexWrap(mNativePointer, flexWrap.intValue());
}
private native int jni_CSSNodeStyleGetOverflow(long nativePointer);
private native int jni_YGNodeStyleGetOverflow(long nativePointer);
@Override
public YogaOverflow getOverflow() {
return YogaOverflow.values()[jni_CSSNodeStyleGetOverflow(mNativePointer)];
return YogaOverflow.values()[jni_YGNodeStyleGetOverflow(mNativePointer)];
}
private native void jni_CSSNodeStyleSetOverflow(long nativePointer, int overflow);
private native void jni_YGNodeStyleSetOverflow(long nativePointer, int overflow);
@Override
public void setOverflow(YogaOverflow overflow) {
jni_CSSNodeStyleSetOverflow(mNativePointer, overflow.intValue());
jni_YGNodeStyleSetOverflow(mNativePointer, overflow.intValue());
}
private native void jni_CSSNodeStyleSetFlex(long nativePointer, float flex);
private native void jni_YGNodeStyleSetFlex(long nativePointer, float flex);
@Override
public void setFlex(float flex) {
jni_CSSNodeStyleSetFlex(mNativePointer, flex);
jni_YGNodeStyleSetFlex(mNativePointer, flex);
}
private native float jni_CSSNodeStyleGetFlexGrow(long nativePointer);
private native float jni_YGNodeStyleGetFlexGrow(long nativePointer);
@Override
public float getFlexGrow() {
return jni_CSSNodeStyleGetFlexGrow(mNativePointer);
return jni_YGNodeStyleGetFlexGrow(mNativePointer);
}
private native void jni_CSSNodeStyleSetFlexGrow(long nativePointer, float flexGrow);
private native void jni_YGNodeStyleSetFlexGrow(long nativePointer, float flexGrow);
@Override
public void setFlexGrow(float flexGrow) {
jni_CSSNodeStyleSetFlexGrow(mNativePointer, flexGrow);
jni_YGNodeStyleSetFlexGrow(mNativePointer, flexGrow);
}
private native float jni_CSSNodeStyleGetFlexShrink(long nativePointer);
private native float jni_YGNodeStyleGetFlexShrink(long nativePointer);
@Override
public float getFlexShrink() {
return jni_CSSNodeStyleGetFlexShrink(mNativePointer);
return jni_YGNodeStyleGetFlexShrink(mNativePointer);
}
private native void jni_CSSNodeStyleSetFlexShrink(long nativePointer, float flexShrink);
private native void jni_YGNodeStyleSetFlexShrink(long nativePointer, float flexShrink);
@Override
public void setFlexShrink(float flexShrink) {
jni_CSSNodeStyleSetFlexShrink(mNativePointer, flexShrink);
jni_YGNodeStyleSetFlexShrink(mNativePointer, flexShrink);
}
private native float jni_CSSNodeStyleGetFlexBasis(long nativePointer);
private native float jni_YGNodeStyleGetFlexBasis(long nativePointer);
@Override
public float getFlexBasis() {
return jni_CSSNodeStyleGetFlexBasis(mNativePointer);
return jni_YGNodeStyleGetFlexBasis(mNativePointer);
}
private native void jni_CSSNodeStyleSetFlexBasis(long nativePointer, float flexBasis);
private native void jni_YGNodeStyleSetFlexBasis(long nativePointer, float flexBasis);
@Override
public void setFlexBasis(float flexBasis) {
jni_CSSNodeStyleSetFlexBasis(mNativePointer, flexBasis);
jni_YGNodeStyleSetFlexBasis(mNativePointer, flexBasis);
}
private native float jni_CSSNodeStyleGetMargin(long nativePointer, int edge);
private native float jni_YGNodeStyleGetMargin(long nativePointer, int edge);
@Override
public float getMargin(YogaEdge edge) {
if (!mHasSetMargin) {
return edge.intValue() < YogaEdge.START.intValue() ? 0 : YogaConstants.UNDEFINED;
}
return jni_CSSNodeStyleGetMargin(mNativePointer, edge.intValue());
return jni_YGNodeStyleGetMargin(mNativePointer, edge.intValue());
}
private native void jni_CSSNodeStyleSetMargin(long nativePointer, int edge, float margin);
private native void jni_YGNodeStyleSetMargin(long nativePointer, int edge, float margin);
@Override
public void setMargin(YogaEdge edge, float margin) {
mHasSetMargin = true;
jni_CSSNodeStyleSetMargin(mNativePointer, edge.intValue(), margin);
jni_YGNodeStyleSetMargin(mNativePointer, edge.intValue(), margin);
}
private native float jni_CSSNodeStyleGetPadding(long nativePointer, int edge);
private native float jni_YGNodeStyleGetPadding(long nativePointer, int edge);
@Override
public float getPadding(YogaEdge edge) {
if (!mHasSetPadding) {
return edge.intValue() < YogaEdge.START.intValue() ? 0 : YogaConstants.UNDEFINED;
}
return jni_CSSNodeStyleGetPadding(mNativePointer, edge.intValue());
return jni_YGNodeStyleGetPadding(mNativePointer, edge.intValue());
}
private native void jni_CSSNodeStyleSetPadding(long nativePointer, int edge, float padding);
private native void jni_YGNodeStyleSetPadding(long nativePointer, int edge, float padding);
@Override
public void setPadding(YogaEdge edge, float padding) {
mHasSetPadding = true;
jni_CSSNodeStyleSetPadding(mNativePointer, edge.intValue(), padding);
jni_YGNodeStyleSetPadding(mNativePointer, edge.intValue(), padding);
}
private native float jni_CSSNodeStyleGetBorder(long nativePointer, int edge);
private native float jni_YGNodeStyleGetBorder(long nativePointer, int edge);
@Override
public float getBorder(YogaEdge edge) {
if (!mHasSetBorder) {
return edge.intValue() < YogaEdge.START.intValue() ? 0 : YogaConstants.UNDEFINED;
}
return jni_CSSNodeStyleGetBorder(mNativePointer, edge.intValue());
return jni_YGNodeStyleGetBorder(mNativePointer, edge.intValue());
}
private native void jni_CSSNodeStyleSetBorder(long nativePointer, int edge, float border);
private native void jni_YGNodeStyleSetBorder(long nativePointer, int edge, float border);
@Override
public void setBorder(YogaEdge edge, float border) {
mHasSetBorder = true;
jni_CSSNodeStyleSetBorder(mNativePointer, edge.intValue(), border);
jni_YGNodeStyleSetBorder(mNativePointer, edge.intValue(), border);
}
private native float jni_CSSNodeStyleGetPosition(long nativePointer, int edge);
private native float jni_YGNodeStyleGetPosition(long nativePointer, int edge);
@Override
public float getPosition(YogaEdge edge) {
if (!mHasSetPosition) {
return YogaConstants.UNDEFINED;
}
return jni_CSSNodeStyleGetPosition(mNativePointer, edge.intValue());
return jni_YGNodeStyleGetPosition(mNativePointer, edge.intValue());
}
private native void jni_CSSNodeStyleSetPosition(long nativePointer, int edge, float position);
private native void jni_YGNodeStyleSetPosition(long nativePointer, int edge, float position);
@Override
public void setPosition(YogaEdge edge, float position) {
mHasSetPosition = true;
jni_CSSNodeStyleSetPosition(mNativePointer, edge.intValue(), position);
jni_YGNodeStyleSetPosition(mNativePointer, edge.intValue(), position);
}
private native float jni_CSSNodeStyleGetWidth(long nativePointer);
private native float jni_YGNodeStyleGetWidth(long nativePointer);
@Override
public float getWidth() {
return jni_CSSNodeStyleGetWidth(mNativePointer);
return jni_YGNodeStyleGetWidth(mNativePointer);
}
private native void jni_CSSNodeStyleSetWidth(long nativePointer, float width);
private native void jni_YGNodeStyleSetWidth(long nativePointer, float width);
@Override
public void setWidth(float width) {
jni_CSSNodeStyleSetWidth(mNativePointer, width);
jni_YGNodeStyleSetWidth(mNativePointer, width);
}
private native float jni_CSSNodeStyleGetHeight(long nativePointer);
private native float jni_YGNodeStyleGetHeight(long nativePointer);
@Override
public float getHeight() {
return jni_CSSNodeStyleGetHeight(mNativePointer);
return jni_YGNodeStyleGetHeight(mNativePointer);
}
private native void jni_CSSNodeStyleSetHeight(long nativePointer, float height);
private native void jni_YGNodeStyleSetHeight(long nativePointer, float height);
@Override
public void setHeight(float height) {
jni_CSSNodeStyleSetHeight(mNativePointer, height);
jni_YGNodeStyleSetHeight(mNativePointer, height);
}
private native float jni_CSSNodeStyleGetMinWidth(long nativePointer);
private native float jni_YGNodeStyleGetMinWidth(long nativePointer);
@Override
public float getMinWidth() {
return jni_CSSNodeStyleGetMinWidth(mNativePointer);
return jni_YGNodeStyleGetMinWidth(mNativePointer);
}
private native void jni_CSSNodeStyleSetMinWidth(long nativePointer, float minWidth);
private native void jni_YGNodeStyleSetMinWidth(long nativePointer, float minWidth);
@Override
public void setMinWidth(float minWidth) {
jni_CSSNodeStyleSetMinWidth(mNativePointer, minWidth);
jni_YGNodeStyleSetMinWidth(mNativePointer, minWidth);
}
private native float jni_CSSNodeStyleGetMinHeight(long nativePointer);
private native float jni_YGNodeStyleGetMinHeight(long nativePointer);
@Override
public float getMinHeight() {
return jni_CSSNodeStyleGetMinHeight(mNativePointer);
return jni_YGNodeStyleGetMinHeight(mNativePointer);
}
private native void jni_CSSNodeStyleSetMinHeight(long nativePointer, float minHeight);
private native void jni_YGNodeStyleSetMinHeight(long nativePointer, float minHeight);
@Override
public void setMinHeight(float minHeight) {
jni_CSSNodeStyleSetMinHeight(mNativePointer, minHeight);
jni_YGNodeStyleSetMinHeight(mNativePointer, minHeight);
}
private native float jni_CSSNodeStyleGetMaxWidth(long nativePointer);
private native float jni_YGNodeStyleGetMaxWidth(long nativePointer);
@Override
public float getMaxWidth() {
return jni_CSSNodeStyleGetMaxWidth(mNativePointer);
return jni_YGNodeStyleGetMaxWidth(mNativePointer);
}
private native void jni_CSSNodeStyleSetMaxWidth(long nativePointer, float maxWidth);
private native void jni_YGNodeStyleSetMaxWidth(long nativePointer, float maxWidth);
@Override
public void setMaxWidth(float maxWidth) {
jni_CSSNodeStyleSetMaxWidth(mNativePointer, maxWidth);
jni_YGNodeStyleSetMaxWidth(mNativePointer, maxWidth);
}
private native float jni_CSSNodeStyleGetMaxHeight(long nativePointer);
private native float jni_YGNodeStyleGetMaxHeight(long nativePointer);
@Override
public float getMaxHeight() {
return jni_CSSNodeStyleGetMaxHeight(mNativePointer);
return jni_YGNodeStyleGetMaxHeight(mNativePointer);
}
private native void jni_CSSNodeStyleSetMaxHeight(long nativePointer, float maxheight);
private native void jni_YGNodeStyleSetMaxHeight(long nativePointer, float maxheight);
@Override
public void setMaxHeight(float maxheight) {
jni_CSSNodeStyleSetMaxHeight(mNativePointer, maxheight);
jni_YGNodeStyleSetMaxHeight(mNativePointer, maxheight);
}
private native float jni_CSSNodeStyleGetAspectRatio(long nativePointer);
private native float jni_YGNodeStyleGetAspectRatio(long nativePointer);
public float getAspectRatio() {
return jni_CSSNodeStyleGetAspectRatio(mNativePointer);
return jni_YGNodeStyleGetAspectRatio(mNativePointer);
}
private native void jni_CSSNodeStyleSetAspectRatio(long nativePointer, float aspectRatio);
private native void jni_YGNodeStyleSetAspectRatio(long nativePointer, float aspectRatio);
public void setAspectRatio(float aspectRatio) {
jni_CSSNodeStyleSetAspectRatio(mNativePointer, aspectRatio);
jni_YGNodeStyleSetAspectRatio(mNativePointer, aspectRatio);
}
@Override
@ -506,11 +506,11 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
return YogaDirection.values()[mLayoutDirection];
}
private native void jni_CSSNodeSetHasMeasureFunc(long nativePointer, boolean hasMeasureFunc);
private native void jni_YGNodeSetHasMeasureFunc(long nativePointer, boolean hasMeasureFunc);
@Override
public void setMeasureFunction(MeasureFunction measureFunction) {
mMeasureFunction = measureFunction;
jni_CSSNodeSetHasMeasureFunc(mNativePointer, measureFunction != null);
jni_YGNodeSetHasMeasureFunc(mNativePointer, measureFunction != null);
}
// Implementation Note: Why this method needs to stay final

View File

@ -5,7 +5,7 @@ include $(CLEAR_VARS)
LOCAL_MODULE := csslayout
LOCAL_SRC_FILES := \
jni/CSSJNI.cpp
jni/YGJNI.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH)/jni

View File

@ -1,340 +0,0 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* 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.
*/
#include <CSSLayout/CSSLayout.h>
#include <fb/fbjni.h>
#include <iostream>
using namespace facebook::jni;
using namespace std;
static inline weak_ref<jobject> *jobjectContext(CSSNodeRef node) {
return reinterpret_cast<weak_ref<jobject> *>(CSSNodeGetContext(node));
}
static void _jniTransferLayoutDirection(CSSNodeRef node, alias_ref<jobject> javaNode) {
static auto layoutDirectionField = javaNode->getClass()->getField<jint>("mLayoutDirection");
javaNode->setFieldValue(layoutDirectionField, static_cast<jint>(CSSNodeLayoutGetDirection(node)));
}
static void _jniTransferLayoutOutputsRecursive(CSSNodeRef root) {
if (auto obj = jobjectContext(root)->lockLocal()) {
static auto widthField = obj->getClass()->getField<jfloat>("mWidth");
static auto heightField = obj->getClass()->getField<jfloat>("mHeight");
static auto leftField = obj->getClass()->getField<jfloat>("mLeft");
static auto topField = obj->getClass()->getField<jfloat>("mTop");
obj->setFieldValue(widthField, CSSNodeLayoutGetWidth(root));
obj->setFieldValue(heightField, CSSNodeLayoutGetHeight(root));
obj->setFieldValue(leftField, CSSNodeLayoutGetLeft(root));
obj->setFieldValue(topField, CSSNodeLayoutGetTop(root));
_jniTransferLayoutDirection(root, obj);
for (uint32_t i = 0; i < CSSNodeChildCount(root); i++) {
_jniTransferLayoutOutputsRecursive(CSSNodeGetChild(root, i));
}
} else {
CSSLog(YGLogLevelError, "Java CSSNode was GCed during layout calculation\n");
}
}
static void _jniPrint(CSSNodeRef node) {
if (auto obj = jobjectContext(node)->lockLocal()) {
cout << obj->toString() << endl;
} else {
CSSLog(YGLogLevelError, "Java CSSNode was GCed during layout calculation\n");
}
}
static CSSSize _jniMeasureFunc(CSSNodeRef node,
float width,
YGMeasureMode widthMode,
float height,
YGMeasureMode heightMode) {
if (auto obj = jobjectContext(node)->lockLocal()) {
static auto measureFunc = findClassLocal("com/facebook/csslayout/CSSNode")
->getMethod<jlong(jfloat, jint, jfloat, jint)>("measure");
_jniTransferLayoutDirection(node, obj);
const auto measureResult = measureFunc(obj, width, widthMode, height, heightMode);
static_assert(sizeof(measureResult) == 8,
"Expected measureResult to be 8 bytes, or two 32 bit ints");
const float measuredWidth = static_cast<float>(0xFFFFFFFF & (measureResult >> 32));
const float measuredHeight = static_cast<float>(0xFFFFFFFF & measureResult);
return CSSSize{measuredWidth, measuredHeight};
} else {
CSSLog(YGLogLevelError, "Java CSSNode was GCed during layout calculation\n");
return CSSSize{
widthMode == YGMeasureModeUndefined ? 0 : width,
heightMode == YGMeasureModeUndefined ? 0 : height,
};
}
}
struct JYogaLogLevel : public JavaClass<JYogaLogLevel> {
static constexpr auto kJavaDescriptor = "Lcom/facebook/csslayout/YogaLogLevel;";
};
static global_ref<jobject> *jLogger;
static int _jniLog(YGLogLevel level, const char *format, va_list args) {
char buffer[256];
int result = vsnprintf(buffer, sizeof(buffer), format, args);
static auto logFunc = findClassLocal("com/facebook/csslayout/CSSLogger")
->getMethod<void(local_ref<JYogaLogLevel>, jstring)>("log");
static auto logLevelFromInt =
JYogaLogLevel::javaClassStatic()->getStaticMethod<JYogaLogLevel::javaobject(jint)>("fromInt");
logFunc(jLogger->get(),
logLevelFromInt(JYogaLogLevel::javaClassStatic(), static_cast<jint>(level)),
Environment::current()->NewStringUTF(buffer));
return result;
}
static inline CSSNodeRef _jlong2CSSNodeRef(jlong addr) {
return reinterpret_cast<CSSNodeRef>(static_cast<intptr_t>(addr));
}
void jni_CSSLayoutSetLogger(alias_ref<jclass> clazz, alias_ref<jobject> logger) {
if (jLogger) {
jLogger->releaseAlias();
delete jLogger;
}
if (logger) {
jLogger = new global_ref<jobject>(make_global(logger));
CSSLayoutSetLogger(_jniLog);
} else {
jLogger = NULL;
CSSLayoutSetLogger(NULL);
}
}
void jni_CSSLog(alias_ref<jclass> clazz, jint level, jstring message) {
const char *nMessage = Environment::current()->GetStringUTFChars(message, 0);
CSSLog(static_cast<YGLogLevel>(level), "%s", nMessage);
Environment::current()->ReleaseStringUTFChars(message, nMessage);
}
void jni_CSSLayoutSetExperimentalFeatureEnabled(alias_ref<jclass> clazz,
jint feature,
jboolean enabled) {
CSSLayoutSetExperimentalFeatureEnabled(static_cast<YGExperimentalFeature>(feature), enabled);
}
jboolean jni_CSSLayoutIsExperimentalFeatureEnabled(alias_ref<jclass> clazz, jint feature) {
return CSSLayoutIsExperimentalFeatureEnabled(static_cast<YGExperimentalFeature>(feature));
}
jint jni_CSSNodeGetInstanceCount(alias_ref<jclass> clazz) {
return CSSNodeGetInstanceCount();
}
jlong jni_CSSNodeNew(alias_ref<jobject> thiz) {
const CSSNodeRef node = CSSNodeNew();
CSSNodeSetContext(node, new weak_ref<jobject>(make_weak(thiz)));
CSSNodeSetPrintFunc(node, _jniPrint);
return reinterpret_cast<jlong>(node);
}
void jni_CSSNodeFree(alias_ref<jobject> thiz, jlong nativePointer) {
const CSSNodeRef node = _jlong2CSSNodeRef(nativePointer);
delete jobjectContext(node);
CSSNodeFree(node);
}
void jni_CSSNodeReset(alias_ref<jobject> thiz, jlong nativePointer) {
const CSSNodeRef node = _jlong2CSSNodeRef(nativePointer);
void *context = CSSNodeGetContext(node);
CSSNodeReset(node);
CSSNodeSetContext(node, context);
CSSNodeSetPrintFunc(node, _jniPrint);
}
void jni_CSSNodeInsertChild(alias_ref<jobject>,
jlong nativePointer,
jlong childPointer,
jint index) {
CSSNodeInsertChild(_jlong2CSSNodeRef(nativePointer), _jlong2CSSNodeRef(childPointer), index);
}
void jni_CSSNodeRemoveChild(alias_ref<jobject>, jlong nativePointer, jlong childPointer) {
CSSNodeRemoveChild(_jlong2CSSNodeRef(nativePointer), _jlong2CSSNodeRef(childPointer));
}
void jni_CSSNodeCalculateLayout(alias_ref<jobject>, jlong nativePointer) {
const CSSNodeRef root = _jlong2CSSNodeRef(nativePointer);
CSSNodeCalculateLayout(root,
YGUndefined,
YGUndefined,
CSSNodeStyleGetDirection(_jlong2CSSNodeRef(nativePointer)));
_jniTransferLayoutOutputsRecursive(root);
}
void jni_CSSNodeMarkDirty(alias_ref<jobject>, jlong nativePointer) {
CSSNodeMarkDirty(_jlong2CSSNodeRef(nativePointer));
}
jboolean jni_CSSNodeIsDirty(alias_ref<jobject>, jlong nativePointer) {
return (jboolean) CSSNodeIsDirty(_jlong2CSSNodeRef(nativePointer));
}
void jni_CSSNodeSetHasMeasureFunc(alias_ref<jobject>,
jlong nativePointer,
jboolean hasMeasureFunc) {
CSSNodeSetMeasureFunc(_jlong2CSSNodeRef(nativePointer), hasMeasureFunc ? _jniMeasureFunc : NULL);
}
jboolean jni_CSSNodeHasNewLayout(alias_ref<jobject>, jlong nativePointer) {
return (jboolean) CSSNodeGetHasNewLayout(_jlong2CSSNodeRef(nativePointer));
}
void jni_CSSNodeMarkLayoutSeen(alias_ref<jobject>, jlong nativePointer) {
CSSNodeSetHasNewLayout(_jlong2CSSNodeRef(nativePointer), false);
}
void jni_CSSNodeCopyStyle(alias_ref<jobject>, jlong dstNativePointer, jlong srcNativePointer) {
CSSNodeCopyStyle(_jlong2CSSNodeRef(dstNativePointer), _jlong2CSSNodeRef(srcNativePointer));
}
#define CSS_NODE_JNI_STYLE_PROP(javatype, type, name) \
javatype jni_CSSNodeStyleGet##name(alias_ref<jobject>, jlong nativePointer) { \
return (javatype) CSSNodeStyleGet##name(_jlong2CSSNodeRef(nativePointer)); \
} \
\
void jni_CSSNodeStyleSet##name(alias_ref<jobject>, jlong nativePointer, javatype value) { \
CSSNodeStyleSet##name(_jlong2CSSNodeRef(nativePointer), static_cast<type>(value)); \
}
#define CSS_NODE_JNI_STYLE_EDGE_PROP(javatype, type, name) \
javatype jni_CSSNodeStyleGet##name(alias_ref<jobject>, jlong nativePointer, jint edge) { \
return (javatype) CSSNodeStyleGet##name(_jlong2CSSNodeRef(nativePointer), \
static_cast<YGEdge>(edge)); \
} \
\
void jni_CSSNodeStyleSet##name(alias_ref<jobject>, \
jlong nativePointer, \
jint edge, \
javatype value) { \
CSSNodeStyleSet##name(_jlong2CSSNodeRef(nativePointer), \
static_cast<YGEdge>(edge), \
static_cast<type>(value)); \
}
CSS_NODE_JNI_STYLE_PROP(jint, YGDirection, Direction);
CSS_NODE_JNI_STYLE_PROP(jint, YGFlexDirection, FlexDirection);
CSS_NODE_JNI_STYLE_PROP(jint, YGJustify, JustifyContent);
CSS_NODE_JNI_STYLE_PROP(jint, YGAlign, AlignItems);
CSS_NODE_JNI_STYLE_PROP(jint, YGAlign, AlignSelf);
CSS_NODE_JNI_STYLE_PROP(jint, YGAlign, AlignContent);
CSS_NODE_JNI_STYLE_PROP(jint, YGPositionType, PositionType);
CSS_NODE_JNI_STYLE_PROP(jint, YGWrap, FlexWrap);
CSS_NODE_JNI_STYLE_PROP(jint, YGOverflow, Overflow);
void jni_CSSNodeStyleSetFlex(alias_ref<jobject>, jlong nativePointer, jfloat value) {
CSSNodeStyleSetFlex(_jlong2CSSNodeRef(nativePointer), static_cast<float>(value));
}
CSS_NODE_JNI_STYLE_PROP(jfloat, float, FlexGrow);
CSS_NODE_JNI_STYLE_PROP(jfloat, float, FlexShrink);
CSS_NODE_JNI_STYLE_PROP(jfloat, float, FlexBasis);
CSS_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Position);
CSS_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Margin);
CSS_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Padding);
CSS_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Border);
CSS_NODE_JNI_STYLE_PROP(jfloat, float, Width);
CSS_NODE_JNI_STYLE_PROP(jfloat, float, MinWidth);
CSS_NODE_JNI_STYLE_PROP(jfloat, float, MaxWidth);
CSS_NODE_JNI_STYLE_PROP(jfloat, float, Height);
CSS_NODE_JNI_STYLE_PROP(jfloat, float, MinHeight);
CSS_NODE_JNI_STYLE_PROP(jfloat, float, MaxHeight);
// Yoga specific properties, not compatible with flexbox specification
CSS_NODE_JNI_STYLE_PROP(jfloat, float, AspectRatio);
#define CSSMakeNativeMethod(name) makeNativeMethod(#name, name)
jint JNI_OnLoad(JavaVM *vm, void *) {
return initialize(vm, [] {
registerNatives("com/facebook/csslayout/CSSNode",
{
CSSMakeNativeMethod(jni_CSSNodeNew),
CSSMakeNativeMethod(jni_CSSNodeFree),
CSSMakeNativeMethod(jni_CSSNodeReset),
CSSMakeNativeMethod(jni_CSSNodeInsertChild),
CSSMakeNativeMethod(jni_CSSNodeRemoveChild),
CSSMakeNativeMethod(jni_CSSNodeCalculateLayout),
CSSMakeNativeMethod(jni_CSSNodeHasNewLayout),
CSSMakeNativeMethod(jni_CSSNodeMarkDirty),
CSSMakeNativeMethod(jni_CSSNodeIsDirty),
CSSMakeNativeMethod(jni_CSSNodeMarkLayoutSeen),
CSSMakeNativeMethod(jni_CSSNodeSetHasMeasureFunc),
CSSMakeNativeMethod(jni_CSSNodeCopyStyle),
CSSMakeNativeMethod(jni_CSSNodeStyleGetDirection),
CSSMakeNativeMethod(jni_CSSNodeStyleSetDirection),
CSSMakeNativeMethod(jni_CSSNodeStyleGetFlexDirection),
CSSMakeNativeMethod(jni_CSSNodeStyleSetFlexDirection),
CSSMakeNativeMethod(jni_CSSNodeStyleGetJustifyContent),
CSSMakeNativeMethod(jni_CSSNodeStyleSetJustifyContent),
CSSMakeNativeMethod(jni_CSSNodeStyleGetAlignItems),
CSSMakeNativeMethod(jni_CSSNodeStyleSetAlignItems),
CSSMakeNativeMethod(jni_CSSNodeStyleGetAlignSelf),
CSSMakeNativeMethod(jni_CSSNodeStyleSetAlignSelf),
CSSMakeNativeMethod(jni_CSSNodeStyleGetAlignContent),
CSSMakeNativeMethod(jni_CSSNodeStyleSetAlignContent),
CSSMakeNativeMethod(jni_CSSNodeStyleGetPositionType),
CSSMakeNativeMethod(jni_CSSNodeStyleSetPositionType),
CSSMakeNativeMethod(jni_CSSNodeStyleSetFlexWrap),
CSSMakeNativeMethod(jni_CSSNodeStyleGetOverflow),
CSSMakeNativeMethod(jni_CSSNodeStyleSetOverflow),
CSSMakeNativeMethod(jni_CSSNodeStyleSetFlex),
CSSMakeNativeMethod(jni_CSSNodeStyleGetFlexGrow),
CSSMakeNativeMethod(jni_CSSNodeStyleSetFlexGrow),
CSSMakeNativeMethod(jni_CSSNodeStyleGetFlexShrink),
CSSMakeNativeMethod(jni_CSSNodeStyleSetFlexShrink),
CSSMakeNativeMethod(jni_CSSNodeStyleGetFlexBasis),
CSSMakeNativeMethod(jni_CSSNodeStyleSetFlexBasis),
CSSMakeNativeMethod(jni_CSSNodeStyleGetMargin),
CSSMakeNativeMethod(jni_CSSNodeStyleSetMargin),
CSSMakeNativeMethod(jni_CSSNodeStyleGetPadding),
CSSMakeNativeMethod(jni_CSSNodeStyleSetPadding),
CSSMakeNativeMethod(jni_CSSNodeStyleGetBorder),
CSSMakeNativeMethod(jni_CSSNodeStyleSetBorder),
CSSMakeNativeMethod(jni_CSSNodeStyleGetPosition),
CSSMakeNativeMethod(jni_CSSNodeStyleSetPosition),
CSSMakeNativeMethod(jni_CSSNodeStyleGetWidth),
CSSMakeNativeMethod(jni_CSSNodeStyleSetWidth),
CSSMakeNativeMethod(jni_CSSNodeStyleGetHeight),
CSSMakeNativeMethod(jni_CSSNodeStyleSetHeight),
CSSMakeNativeMethod(jni_CSSNodeStyleGetMinWidth),
CSSMakeNativeMethod(jni_CSSNodeStyleSetMinWidth),
CSSMakeNativeMethod(jni_CSSNodeStyleGetMinHeight),
CSSMakeNativeMethod(jni_CSSNodeStyleSetMinHeight),
CSSMakeNativeMethod(jni_CSSNodeStyleGetMaxWidth),
CSSMakeNativeMethod(jni_CSSNodeStyleSetMaxWidth),
CSSMakeNativeMethod(jni_CSSNodeStyleGetMaxHeight),
CSSMakeNativeMethod(jni_CSSNodeStyleSetMaxHeight),
CSSMakeNativeMethod(jni_CSSNodeStyleGetAspectRatio),
CSSMakeNativeMethod(jni_CSSNodeStyleSetAspectRatio),
CSSMakeNativeMethod(jni_CSSNodeGetInstanceCount),
CSSMakeNativeMethod(jni_CSSLayoutSetLogger),
CSSMakeNativeMethod(jni_CSSLog),
CSSMakeNativeMethod(jni_CSSLayoutSetExperimentalFeatureEnabled),
CSSMakeNativeMethod(jni_CSSLayoutIsExperimentalFeatureEnabled),
});
});
}

View File

@ -0,0 +1,333 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* 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.
*/
#include <CSSLayout/Yoga.h>
#include <fb/fbjni.h>
#include <iostream>
using namespace facebook::jni;
using namespace std;
static inline weak_ref<jobject> *YGNodeJobject(YGNodeRef node) {
return reinterpret_cast<weak_ref<jobject> *>(YGNodeGetContext(node));
}
static void YGTransferLayoutDirection(YGNodeRef node, alias_ref<jobject> javaNode) {
static auto layoutDirectionField = javaNode->getClass()->getField<jint>("mLayoutDirection");
javaNode->setFieldValue(layoutDirectionField, static_cast<jint>(YGNodeLayoutGetDirection(node)));
}
static void YGTransferLayoutOutputsRecursive(YGNodeRef root) {
if (auto obj = YGNodeJobject(root)->lockLocal()) {
static auto widthField = obj->getClass()->getField<jfloat>("mWidth");
static auto heightField = obj->getClass()->getField<jfloat>("mHeight");
static auto leftField = obj->getClass()->getField<jfloat>("mLeft");
static auto topField = obj->getClass()->getField<jfloat>("mTop");
obj->setFieldValue(widthField, YGNodeLayoutGetWidth(root));
obj->setFieldValue(heightField, YGNodeLayoutGetHeight(root));
obj->setFieldValue(leftField, YGNodeLayoutGetLeft(root));
obj->setFieldValue(topField, YGNodeLayoutGetTop(root));
YGTransferLayoutDirection(root, obj);
for (uint32_t i = 0; i < YGNodeChildCount(root); i++) {
YGTransferLayoutOutputsRecursive(YGNodeGetChild(root, i));
}
} else {
YGLog(YGLogLevelError, "Java YGNode was GCed during layout calculation\n");
}
}
static void YGPrint(YGNodeRef node) {
if (auto obj = YGNodeJobject(node)->lockLocal()) {
cout << obj->toString() << endl;
} else {
YGLog(YGLogLevelError, "Java YGNode was GCed during layout calculation\n");
}
}
static YGSize YGJNIMeasureFunc(YGNodeRef node,
float width,
YGMeasureMode widthMode,
float height,
YGMeasureMode heightMode) {
if (auto obj = YGNodeJobject(node)->lockLocal()) {
static auto measureFunc = findClassLocal("com/facebook/csslayout/CSSNode")
->getMethod<jlong(jfloat, jint, jfloat, jint)>("measure");
YGTransferLayoutDirection(node, obj);
const auto measureResult = measureFunc(obj, width, widthMode, height, heightMode);
static_assert(sizeof(measureResult) == 8,
"Expected measureResult to be 8 bytes, or two 32 bit ints");
const float measuredWidth = static_cast<float>(0xFFFFFFFF & (measureResult >> 32));
const float measuredHeight = static_cast<float>(0xFFFFFFFF & measureResult);
return YGSize{measuredWidth, measuredHeight};
} else {
YGLog(YGLogLevelError, "Java YGNode was GCed during layout calculation\n");
return YGSize{
widthMode == YGMeasureModeUndefined ? 0 : width,
heightMode == YGMeasureModeUndefined ? 0 : height,
};
}
}
struct JYogaLogLevel : public JavaClass<JYogaLogLevel> {
static constexpr auto kJavaDescriptor = "Lcom/facebook/csslayout/YogaLogLevel;";
};
static global_ref<jobject> *jLogger;
static int YGLog(YGLogLevel level, const char *format, va_list args) {
char buffer[256];
int result = vsnprintf(buffer, sizeof(buffer), format, args);
static auto logFunc = findClassLocal("com/facebook/csslayout/CSSLogger")
->getMethod<void(local_ref<JYogaLogLevel>, jstring)>("log");
static auto logLevelFromInt =
JYogaLogLevel::javaClassStatic()->getStaticMethod<JYogaLogLevel::javaobject(jint)>("fromInt");
logFunc(jLogger->get(),
logLevelFromInt(JYogaLogLevel::javaClassStatic(), static_cast<jint>(level)),
Environment::current()->NewStringUTF(buffer));
return result;
}
static inline YGNodeRef _jlong2YGNodeRef(jlong addr) {
return reinterpret_cast<YGNodeRef>(static_cast<intptr_t>(addr));
}
void jni_YGSetLogger(alias_ref<jclass> clazz, alias_ref<jobject> logger) {
if (jLogger) {
jLogger->releaseAlias();
delete jLogger;
}
if (logger) {
jLogger = new global_ref<jobject>(make_global(logger));
YGSetLogger(YGLog);
} else {
jLogger = NULL;
YGSetLogger(NULL);
}
}
void jni_YGLog(alias_ref<jclass> clazz, jint level, jstring message) {
const char *nMessage = Environment::current()->GetStringUTFChars(message, 0);
YGLog(static_cast<YGLogLevel>(level), "%s", nMessage);
Environment::current()->ReleaseStringUTFChars(message, nMessage);
}
void jni_YGSetExperimentalFeatureEnabled(alias_ref<jclass> clazz, jint feature, jboolean enabled) {
YGSetExperimentalFeatureEnabled(static_cast<YGExperimentalFeature>(feature), enabled);
}
jboolean jni_YGIsExperimentalFeatureEnabled(alias_ref<jclass> clazz, jint feature) {
return YGIsExperimentalFeatureEnabled(static_cast<YGExperimentalFeature>(feature));
}
jint jni_YGNodeGetInstanceCount(alias_ref<jclass> clazz) {
return YGNodeGetInstanceCount();
}
jlong jni_YGNodeNew(alias_ref<jobject> thiz) {
const YGNodeRef node = YGNodeNew();
YGNodeSetContext(node, new weak_ref<jobject>(make_weak(thiz)));
YGNodeSetPrintFunc(node, YGPrint);
return reinterpret_cast<jlong>(node);
}
void jni_YGNodeFree(alias_ref<jobject> thiz, jlong nativePointer) {
const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
delete YGNodeJobject(node);
YGNodeFree(node);
}
void jni_YGNodeReset(alias_ref<jobject> thiz, jlong nativePointer) {
const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
void *context = YGNodeGetContext(node);
YGNodeReset(node);
YGNodeSetContext(node, context);
YGNodeSetPrintFunc(node, YGPrint);
}
void jni_YGNodeInsertChild(alias_ref<jobject>, jlong nativePointer, jlong childPointer, jint index) {
YGNodeInsertChild(_jlong2YGNodeRef(nativePointer), _jlong2YGNodeRef(childPointer), index);
}
void jni_YGNodeRemoveChild(alias_ref<jobject>, jlong nativePointer, jlong childPointer) {
YGNodeRemoveChild(_jlong2YGNodeRef(nativePointer), _jlong2YGNodeRef(childPointer));
}
void jni_YGNodeCalculateLayout(alias_ref<jobject>, jlong nativePointer) {
const YGNodeRef root = _jlong2YGNodeRef(nativePointer);
YGNodeCalculateLayout(root,
YGUndefined,
YGUndefined,
YGNodeStyleGetDirection(_jlong2YGNodeRef(nativePointer)));
YGTransferLayoutOutputsRecursive(root);
}
void jni_YGNodeMarkDirty(alias_ref<jobject>, jlong nativePointer) {
YGNodeMarkDirty(_jlong2YGNodeRef(nativePointer));
}
jboolean jni_YGNodeIsDirty(alias_ref<jobject>, jlong nativePointer) {
return (jboolean) YGNodeIsDirty(_jlong2YGNodeRef(nativePointer));
}
void jni_YGNodeSetHasMeasureFunc(alias_ref<jobject>, jlong nativePointer, jboolean hasMeasureFunc) {
YGNodeSetMeasureFunc(_jlong2YGNodeRef(nativePointer), hasMeasureFunc ? YGJNIMeasureFunc : NULL);
}
jboolean jni_YGNodeHasNewLayout(alias_ref<jobject>, jlong nativePointer) {
return (jboolean) YGNodeGetHasNewLayout(_jlong2YGNodeRef(nativePointer));
}
void jni_YGNodeMarkLayoutSeen(alias_ref<jobject>, jlong nativePointer) {
YGNodeSetHasNewLayout(_jlong2YGNodeRef(nativePointer), false);
}
void jni_YGNodeCopyStyle(alias_ref<jobject>, jlong dstNativePointer, jlong srcNativePointer) {
YGNodeCopyStyle(_jlong2YGNodeRef(dstNativePointer), _jlong2YGNodeRef(srcNativePointer));
}
#define YG_NODE_JNI_STYLE_PROP(javatype, type, name) \
javatype jni_YGNodeStyleGet##name(alias_ref<jobject>, jlong nativePointer) { \
return (javatype) YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer)); \
} \
\
void jni_YGNodeStyleSet##name(alias_ref<jobject>, jlong nativePointer, javatype value) { \
YGNodeStyleSet##name(_jlong2YGNodeRef(nativePointer), static_cast<type>(value)); \
}
#define YG_NODE_JNI_STYLE_EDGE_PROP(javatype, type, name) \
javatype jni_YGNodeStyleGet##name(alias_ref<jobject>, jlong nativePointer, jint edge) { \
return (javatype) YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer), \
static_cast<YGEdge>(edge)); \
} \
\
void jni_YGNodeStyleSet##name(alias_ref<jobject>, \
jlong nativePointer, \
jint edge, \
javatype value) { \
YGNodeStyleSet##name(_jlong2YGNodeRef(nativePointer), \
static_cast<YGEdge>(edge), \
static_cast<type>(value)); \
}
YG_NODE_JNI_STYLE_PROP(jint, YGDirection, Direction);
YG_NODE_JNI_STYLE_PROP(jint, YGFlexDirection, FlexDirection);
YG_NODE_JNI_STYLE_PROP(jint, YGJustify, JustifyContent);
YG_NODE_JNI_STYLE_PROP(jint, YGAlign, AlignItems);
YG_NODE_JNI_STYLE_PROP(jint, YGAlign, AlignSelf);
YG_NODE_JNI_STYLE_PROP(jint, YGAlign, AlignContent);
YG_NODE_JNI_STYLE_PROP(jint, YGPositionType, PositionType);
YG_NODE_JNI_STYLE_PROP(jint, YGWrap, FlexWrap);
YG_NODE_JNI_STYLE_PROP(jint, YGOverflow, Overflow);
void jni_YGNodeStyleSetFlex(alias_ref<jobject>, jlong nativePointer, jfloat value) {
YGNodeStyleSetFlex(_jlong2YGNodeRef(nativePointer), static_cast<float>(value));
}
YG_NODE_JNI_STYLE_PROP(jfloat, float, FlexGrow);
YG_NODE_JNI_STYLE_PROP(jfloat, float, FlexShrink);
YG_NODE_JNI_STYLE_PROP(jfloat, float, FlexBasis);
YG_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Position);
YG_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Margin);
YG_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Padding);
YG_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Border);
YG_NODE_JNI_STYLE_PROP(jfloat, float, Width);
YG_NODE_JNI_STYLE_PROP(jfloat, float, MinWidth);
YG_NODE_JNI_STYLE_PROP(jfloat, float, MaxWidth);
YG_NODE_JNI_STYLE_PROP(jfloat, float, Height);
YG_NODE_JNI_STYLE_PROP(jfloat, float, MinHeight);
YG_NODE_JNI_STYLE_PROP(jfloat, float, MaxHeight);
// Yoga specific properties, not compatible with flexbox specification
YG_NODE_JNI_STYLE_PROP(jfloat, float, AspectRatio);
#define YGMakeNativeMethod(name) makeNativeMethod(#name, name)
jint JNI_OnLoad(JavaVM *vm, void *) {
return initialize(vm, [] {
registerNatives("com/facebook/csslayout/CSSNode",
{
YGMakeNativeMethod(jni_YGNodeNew),
YGMakeNativeMethod(jni_YGNodeFree),
YGMakeNativeMethod(jni_YGNodeReset),
YGMakeNativeMethod(jni_YGNodeInsertChild),
YGMakeNativeMethod(jni_YGNodeRemoveChild),
YGMakeNativeMethod(jni_YGNodeCalculateLayout),
YGMakeNativeMethod(jni_YGNodeHasNewLayout),
YGMakeNativeMethod(jni_YGNodeMarkDirty),
YGMakeNativeMethod(jni_YGNodeIsDirty),
YGMakeNativeMethod(jni_YGNodeMarkLayoutSeen),
YGMakeNativeMethod(jni_YGNodeSetHasMeasureFunc),
YGMakeNativeMethod(jni_YGNodeCopyStyle),
YGMakeNativeMethod(jni_YGNodeStyleGetDirection),
YGMakeNativeMethod(jni_YGNodeStyleSetDirection),
YGMakeNativeMethod(jni_YGNodeStyleGetFlexDirection),
YGMakeNativeMethod(jni_YGNodeStyleSetFlexDirection),
YGMakeNativeMethod(jni_YGNodeStyleGetJustifyContent),
YGMakeNativeMethod(jni_YGNodeStyleSetJustifyContent),
YGMakeNativeMethod(jni_YGNodeStyleGetAlignItems),
YGMakeNativeMethod(jni_YGNodeStyleSetAlignItems),
YGMakeNativeMethod(jni_YGNodeStyleGetAlignSelf),
YGMakeNativeMethod(jni_YGNodeStyleSetAlignSelf),
YGMakeNativeMethod(jni_YGNodeStyleGetAlignContent),
YGMakeNativeMethod(jni_YGNodeStyleSetAlignContent),
YGMakeNativeMethod(jni_YGNodeStyleGetPositionType),
YGMakeNativeMethod(jni_YGNodeStyleSetPositionType),
YGMakeNativeMethod(jni_YGNodeStyleSetFlexWrap),
YGMakeNativeMethod(jni_YGNodeStyleGetOverflow),
YGMakeNativeMethod(jni_YGNodeStyleSetOverflow),
YGMakeNativeMethod(jni_YGNodeStyleSetFlex),
YGMakeNativeMethod(jni_YGNodeStyleGetFlexGrow),
YGMakeNativeMethod(jni_YGNodeStyleSetFlexGrow),
YGMakeNativeMethod(jni_YGNodeStyleGetFlexShrink),
YGMakeNativeMethod(jni_YGNodeStyleSetFlexShrink),
YGMakeNativeMethod(jni_YGNodeStyleGetFlexBasis),
YGMakeNativeMethod(jni_YGNodeStyleSetFlexBasis),
YGMakeNativeMethod(jni_YGNodeStyleGetMargin),
YGMakeNativeMethod(jni_YGNodeStyleSetMargin),
YGMakeNativeMethod(jni_YGNodeStyleGetPadding),
YGMakeNativeMethod(jni_YGNodeStyleSetPadding),
YGMakeNativeMethod(jni_YGNodeStyleGetBorder),
YGMakeNativeMethod(jni_YGNodeStyleSetBorder),
YGMakeNativeMethod(jni_YGNodeStyleGetPosition),
YGMakeNativeMethod(jni_YGNodeStyleSetPosition),
YGMakeNativeMethod(jni_YGNodeStyleGetWidth),
YGMakeNativeMethod(jni_YGNodeStyleSetWidth),
YGMakeNativeMethod(jni_YGNodeStyleGetHeight),
YGMakeNativeMethod(jni_YGNodeStyleSetHeight),
YGMakeNativeMethod(jni_YGNodeStyleGetMinWidth),
YGMakeNativeMethod(jni_YGNodeStyleSetMinWidth),
YGMakeNativeMethod(jni_YGNodeStyleGetMinHeight),
YGMakeNativeMethod(jni_YGNodeStyleSetMinHeight),
YGMakeNativeMethod(jni_YGNodeStyleGetMaxWidth),
YGMakeNativeMethod(jni_YGNodeStyleSetMaxWidth),
YGMakeNativeMethod(jni_YGNodeStyleGetMaxHeight),
YGMakeNativeMethod(jni_YGNodeStyleSetMaxHeight),
YGMakeNativeMethod(jni_YGNodeStyleGetAspectRatio),
YGMakeNativeMethod(jni_YGNodeStyleSetAspectRatio),
YGMakeNativeMethod(jni_YGNodeGetInstanceCount),
YGMakeNativeMethod(jni_YGSetLogger),
YGMakeNativeMethod(jni_YGLog),
YGMakeNativeMethod(jni_YGSetExperimentalFeatureEnabled),
YGMakeNativeMethod(jni_YGIsExperimentalFeatureEnabled),
});
});
}

View File

@ -5,8 +5,8 @@ include $(CLEAR_VARS)
LOCAL_MODULE := csslayoutcore
LOCAL_SRC_FILES := \
CSSLayout/CSSLayout.c \
CSSLayout/CSSNodeList.c
CSSLayout/Yoga.c \
CSSLayout/YGNodeList.c
LOCAL_C_INCLUDES := $(LOCAL_PATH)
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)

View File

@ -1,183 +0,0 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* 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 <assert.h>
#include <math.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#ifndef __cplusplus
#include <stdbool.h>
#endif
// Not defined in MSVC++
#ifndef NAN
static const unsigned long __nan[2] = {0xffffffff, 0x7fffffff};
#define NAN (*(const float *) __nan)
#endif
#define YGUndefined NAN
#include "CSSEnums.h"
#include "CSSMacros.h"
CSS_EXTERN_C_BEGIN
typedef struct CSSSize {
float width;
float height;
} CSSSize;
typedef struct CSSNode *CSSNodeRef;
typedef CSSSize (*CSSMeasureFunc)(CSSNodeRef node,
float width,
YGMeasureMode widthMode,
float height,
YGMeasureMode heightMode);
typedef void (*CSSPrintFunc)(CSSNodeRef node);
typedef int (*CSSLogger)(YGLogLevel level, const char *format, va_list args);
typedef void *(*CSSMalloc)(size_t size);
typedef void *(*CSSCalloc)(size_t count, size_t size);
typedef void *(*CSSRealloc)(void *ptr, size_t size);
typedef void (*CSSFree)(void *ptr);
// CSSNode
WIN_EXPORT CSSNodeRef CSSNodeNew(void);
WIN_EXPORT void CSSNodeInit(const CSSNodeRef node);
WIN_EXPORT void CSSNodeFree(const CSSNodeRef node);
WIN_EXPORT void CSSNodeFreeRecursive(const CSSNodeRef node);
WIN_EXPORT void CSSNodeReset(const CSSNodeRef node);
WIN_EXPORT int32_t CSSNodeGetInstanceCount(void);
WIN_EXPORT void CSSNodeInsertChild(const CSSNodeRef node,
const CSSNodeRef child,
const uint32_t index);
WIN_EXPORT void CSSNodeRemoveChild(const CSSNodeRef node, const CSSNodeRef child);
WIN_EXPORT CSSNodeRef CSSNodeGetChild(const CSSNodeRef node, const uint32_t index);
WIN_EXPORT uint32_t CSSNodeChildCount(const CSSNodeRef node);
WIN_EXPORT void CSSNodeCalculateLayout(const CSSNodeRef node,
const float availableWidth,
const float availableHeight,
const YGDirection parentDirection);
// Mark a node as dirty. Only valid for nodes with a custom measure function
// set.
// CSSLayout knows when to mark all other nodes as dirty but because nodes with
// measure functions
// depends on information not known to CSSLayout they must perform this dirty
// marking manually.
WIN_EXPORT void CSSNodeMarkDirty(const CSSNodeRef node);
WIN_EXPORT bool CSSNodeIsDirty(const CSSNodeRef node);
WIN_EXPORT void CSSNodePrint(const CSSNodeRef node, const YGPrintOptions options);
WIN_EXPORT bool CSSValueIsUndefined(const float value);
WIN_EXPORT bool CSSNodeCanUseCachedMeasurement(const YGMeasureMode widthMode,
const float width,
const YGMeasureMode heightMode,
const float height,
const YGMeasureMode lastWidthMode,
const float lastWidth,
const YGMeasureMode lastHeightMode,
const float lastHeight,
const float lastComputedWidth,
const float lastComputedHeight,
const float marginRow,
const float marginColumn);
WIN_EXPORT void CSSNodeCopyStyle(const CSSNodeRef dstNode, const CSSNodeRef srcNode);
#define CSS_NODE_PROPERTY(type, name, paramName) \
WIN_EXPORT void CSSNodeSet##name(const CSSNodeRef node, type paramName); \
WIN_EXPORT type CSSNodeGet##name(const CSSNodeRef node);
#define CSS_NODE_STYLE_PROPERTY(type, name, paramName) \
WIN_EXPORT void CSSNodeStyleSet##name(const CSSNodeRef node, const type paramName); \
WIN_EXPORT type CSSNodeStyleGet##name(const CSSNodeRef node);
#define CSS_NODE_STYLE_EDGE_PROPERTY(type, name, paramName) \
WIN_EXPORT void CSSNodeStyleSet##name(const CSSNodeRef node, \
const YGEdge edge, \
const type paramName); \
WIN_EXPORT type CSSNodeStyleGet##name(const CSSNodeRef node, const YGEdge edge);
#define CSS_NODE_LAYOUT_PROPERTY(type, name) \
WIN_EXPORT type CSSNodeLayoutGet##name(const CSSNodeRef node);
CSS_NODE_PROPERTY(void *, Context, context);
CSS_NODE_PROPERTY(CSSMeasureFunc, MeasureFunc, measureFunc);
CSS_NODE_PROPERTY(CSSPrintFunc, PrintFunc, printFunc);
CSS_NODE_PROPERTY(bool, HasNewLayout, hasNewLayout);
CSS_NODE_STYLE_PROPERTY(YGDirection, Direction, direction);
CSS_NODE_STYLE_PROPERTY(YGFlexDirection, FlexDirection, flexDirection);
CSS_NODE_STYLE_PROPERTY(YGJustify, JustifyContent, justifyContent);
CSS_NODE_STYLE_PROPERTY(YGAlign, AlignContent, alignContent);
CSS_NODE_STYLE_PROPERTY(YGAlign, AlignItems, alignItems);
CSS_NODE_STYLE_PROPERTY(YGAlign, AlignSelf, alignSelf);
CSS_NODE_STYLE_PROPERTY(YGPositionType, PositionType, positionType);
CSS_NODE_STYLE_PROPERTY(YGWrap, FlexWrap, flexWrap);
CSS_NODE_STYLE_PROPERTY(YGOverflow, Overflow, overflow);
WIN_EXPORT void CSSNodeStyleSetFlex(const CSSNodeRef node, const float flex);
CSS_NODE_STYLE_PROPERTY(float, FlexGrow, flexGrow);
CSS_NODE_STYLE_PROPERTY(float, FlexShrink, flexShrink);
CSS_NODE_STYLE_PROPERTY(float, FlexBasis, flexBasis);
CSS_NODE_STYLE_EDGE_PROPERTY(float, Position, position);
CSS_NODE_STYLE_EDGE_PROPERTY(float, Margin, margin);
CSS_NODE_STYLE_EDGE_PROPERTY(float, Padding, padding);
CSS_NODE_STYLE_EDGE_PROPERTY(float, Border, border);
CSS_NODE_STYLE_PROPERTY(float, Width, width);
CSS_NODE_STYLE_PROPERTY(float, Height, height);
CSS_NODE_STYLE_PROPERTY(float, MinWidth, minWidth);
CSS_NODE_STYLE_PROPERTY(float, MinHeight, minHeight);
CSS_NODE_STYLE_PROPERTY(float, MaxWidth, maxWidth);
CSS_NODE_STYLE_PROPERTY(float, MaxHeight, maxHeight);
// Yoga specific properties, not compatible with flexbox specification
// Aspect ratio control the size of the undefined dimension of a node.
// - On a node with a set width/height aspect ratio control the size of the unset dimension
// - On a node with a set flex basis aspect ratio controls the size of the node in the cross axis if
// unset
// - On a node with a measure function aspect ratio works as though the measure function measures
// the flex basis
// - On a node with flex grow/shrink aspect ratio controls the size of the node in the cross axis if
// unset
// - Aspect ratio takes min/max dimensions into account
CSS_NODE_STYLE_PROPERTY(float, AspectRatio, aspectRatio);
CSS_NODE_LAYOUT_PROPERTY(float, Left);
CSS_NODE_LAYOUT_PROPERTY(float, Top);
CSS_NODE_LAYOUT_PROPERTY(float, Right);
CSS_NODE_LAYOUT_PROPERTY(float, Bottom);
CSS_NODE_LAYOUT_PROPERTY(float, Width);
CSS_NODE_LAYOUT_PROPERTY(float, Height);
CSS_NODE_LAYOUT_PROPERTY(YGDirection, Direction);
WIN_EXPORT void CSSLayoutSetLogger(CSSLogger logger);
WIN_EXPORT void CSSLog(YGLogLevel level, const char *message, ...);
WIN_EXPORT void CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeature feature, bool enabled);
WIN_EXPORT bool CSSLayoutIsExperimentalFeatureEnabled(YGExperimentalFeature feature);
WIN_EXPORT void CSSLayoutSetMemoryFuncs(CSSMalloc cssMalloc,
CSSCalloc cssCalloc,
CSSRealloc cssRealloc,
CSSFree cssFree);
CSS_EXTERN_C_END

View File

@ -1,104 +0,0 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* 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.
*/
#include "CSSNodeList.h"
extern CSSMalloc gCSSMalloc;
extern CSSRealloc gCSSRealloc;
extern CSSFree gCSSFree;
struct CSSNodeList {
uint32_t capacity;
uint32_t count;
CSSNodeRef *items;
};
CSSNodeListRef CSSNodeListNew(const uint32_t initialCapacity) {
const CSSNodeListRef list = gCSSMalloc(sizeof(struct CSSNodeList));
CSS_ASSERT(list != NULL, "Could not allocate memory for list");
list->capacity = initialCapacity;
list->count = 0;
list->items = gCSSMalloc(sizeof(CSSNodeRef) * list->capacity);
CSS_ASSERT(list->items != NULL, "Could not allocate memory for items");
return list;
}
void CSSNodeListFree(const CSSNodeListRef list) {
if (list) {
gCSSFree(list->items);
gCSSFree(list);
}
}
uint32_t CSSNodeListCount(const CSSNodeListRef list) {
if (list) {
return list->count;
}
return 0;
}
void CSSNodeListAdd(CSSNodeListRef *listp, const CSSNodeRef node) {
if (!*listp) {
*listp = CSSNodeListNew(4);
}
CSSNodeListInsert(listp, node, (*listp)->count);
}
void CSSNodeListInsert(CSSNodeListRef *listp, const CSSNodeRef node, const uint32_t index) {
if (!*listp) {
*listp = CSSNodeListNew(4);
}
CSSNodeListRef list = *listp;
if (list->count == list->capacity) {
list->capacity *= 2;
list->items = gCSSRealloc(list->items, sizeof(CSSNodeRef) * list->capacity);
CSS_ASSERT(list->items != NULL, "Could not extend allocation for items");
}
for (uint32_t i = list->count; i > index; i--) {
list->items[i] = list->items[i - 1];
}
list->count++;
list->items[index] = node;
}
CSSNodeRef CSSNodeListRemove(const CSSNodeListRef list, const uint32_t index) {
const CSSNodeRef removed = list->items[index];
list->items[index] = NULL;
for (uint32_t i = index; i < list->count - 1; i++) {
list->items[i] = list->items[i + 1];
list->items[i + 1] = NULL;
}
list->count--;
return removed;
}
CSSNodeRef CSSNodeListDelete(const CSSNodeListRef list, const CSSNodeRef node) {
for (uint32_t i = 0; i < list->count; i++) {
if (list->items[i] == node) {
return CSSNodeListRemove(list, i);
}
}
return NULL;
}
CSSNodeRef CSSNodeListGet(const CSSNodeListRef list, const uint32_t index) {
if (CSSNodeListCount(list) > 0) {
return list->items[index];
}
return NULL;
}

View File

@ -1,33 +0,0 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* 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 <assert.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include "CSSLayout.h"
#include "CSSMacros.h"
CSS_EXTERN_C_BEGIN
typedef struct CSSNodeList *CSSNodeListRef;
CSSNodeListRef CSSNodeListNew(const uint32_t initialCapacity);
void CSSNodeListFree(const CSSNodeListRef list);
uint32_t CSSNodeListCount(const CSSNodeListRef list);
void CSSNodeListAdd(CSSNodeListRef *listp, const CSSNodeRef node);
void CSSNodeListInsert(CSSNodeListRef *listp, const CSSNodeRef node, const uint32_t index);
CSSNodeRef CSSNodeListRemove(const CSSNodeListRef list, const uint32_t index);
CSSNodeRef CSSNodeListDelete(const CSSNodeListRef list, const CSSNodeRef node);
CSSNodeRef CSSNodeListGet(const CSSNodeListRef list, const uint32_t index);
CSS_EXTERN_C_END

View File

@ -10,11 +10,11 @@
#pragma once
#ifdef __cplusplus
#define CSS_EXTERN_C_BEGIN extern "C" {
#define CSS_EXTERN_C_END }
#define YG_EXTERN_C_BEGIN extern "C" {
#define YG_EXTERN_C_END }
#else
#define CSS_EXTERN_C_BEGIN
#define CSS_EXTERN_C_END
#define YG_EXTERN_C_BEGIN
#define YG_EXTERN_C_END
#endif
#ifdef _WINDLL
@ -28,15 +28,15 @@
#endif
#if FB_ASSERTIONS_ENABLED
#define CSS_ABORT() abort()
#define YG_ABORT() abort()
#else
#define CSS_ABORT()
#define YG_ABORT()
#endif
#ifndef CSS_ASSERT
#define CSS_ASSERT(X, message) \
if (!(X)) { \
CSSLog(YGLogLevelError, "%s", message); \
CSS_ABORT(); \
#ifndef YG_ASSERT
#define YG_ASSERT(X, message) \
if (!(X)) { \
YGLog(YGLogLevelError, "%s", message); \
YG_ABORT(); \
}
#endif

View File

@ -0,0 +1,104 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* 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.
*/
#include "YGNodeList.h"
extern YGMalloc gYGMalloc;
extern YGRealloc gYGRealloc;
extern YGFree gYGFree;
struct YGNodeList {
uint32_t capacity;
uint32_t count;
YGNodeRef *items;
};
YGNodeListRef YGNodeListNew(const uint32_t initialCapacity) {
const YGNodeListRef list = gYGMalloc(sizeof(struct YGNodeList));
YG_ASSERT(list != NULL, "Could not allocate memory for list");
list->capacity = initialCapacity;
list->count = 0;
list->items = gYGMalloc(sizeof(YGNodeRef) * list->capacity);
YG_ASSERT(list->items != NULL, "Could not allocate memory for items");
return list;
}
void YGNodeListFree(const YGNodeListRef list) {
if (list) {
gYGFree(list->items);
gYGFree(list);
}
}
uint32_t YGNodeListCount(const YGNodeListRef list) {
if (list) {
return list->count;
}
return 0;
}
void YGNodeListAdd(YGNodeListRef *listp, const YGNodeRef node) {
if (!*listp) {
*listp = YGNodeListNew(4);
}
YGNodeListInsert(listp, node, (*listp)->count);
}
void YGNodeListInsert(YGNodeListRef *listp, const YGNodeRef node, const uint32_t index) {
if (!*listp) {
*listp = YGNodeListNew(4);
}
YGNodeListRef list = *listp;
if (list->count == list->capacity) {
list->capacity *= 2;
list->items = gYGRealloc(list->items, sizeof(YGNodeRef) * list->capacity);
YG_ASSERT(list->items != NULL, "Could not extend allocation for items");
}
for (uint32_t i = list->count; i > index; i--) {
list->items[i] = list->items[i - 1];
}
list->count++;
list->items[index] = node;
}
YGNodeRef YGNodeListRemove(const YGNodeListRef list, const uint32_t index) {
const YGNodeRef removed = list->items[index];
list->items[index] = NULL;
for (uint32_t i = index; i < list->count - 1; i++) {
list->items[i] = list->items[i + 1];
list->items[i + 1] = NULL;
}
list->count--;
return removed;
}
YGNodeRef YGNodeListDelete(const YGNodeListRef list, const YGNodeRef node) {
for (uint32_t i = 0; i < list->count; i++) {
if (list->items[i] == node) {
return YGNodeListRemove(list, i);
}
}
return NULL;
}
YGNodeRef YGNodeListGet(const YGNodeListRef list, const uint32_t index) {
if (YGNodeListCount(list) > 0) {
return list->items[index];
}
return NULL;
}

View File

@ -0,0 +1,33 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* 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 <assert.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include "YGMacros.h"
#include "Yoga.h"
YG_EXTERN_C_BEGIN
typedef struct YGNodeList *YGNodeListRef;
YGNodeListRef YGNodeListNew(const uint32_t initialCapacity);
void YGNodeListFree(const YGNodeListRef list);
uint32_t YGNodeListCount(const YGNodeListRef list);
void YGNodeListAdd(YGNodeListRef *listp, const YGNodeRef node);
void YGNodeListInsert(YGNodeListRef *listp, const YGNodeRef node, const uint32_t index);
YGNodeRef YGNodeListRemove(const YGNodeListRef list, const uint32_t index);
YGNodeRef YGNodeListDelete(const YGNodeListRef list, const YGNodeRef node);
YGNodeRef YGNodeListGet(const YGNodeListRef list, const uint32_t index);
YG_EXTERN_C_END

View File

@ -0,0 +1,181 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* 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 <assert.h>
#include <math.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#ifndef __cplusplus
#include <stdbool.h>
#endif
// Not defined in MSVC++
#ifndef NAN
static const unsigned long __nan[2] = {0xffffffff, 0x7fffffff};
#define NAN (*(const float *) __nan)
#endif
#define YGUndefined NAN
#include "YGEnums.h"
#include "YGMacros.h"
YG_EXTERN_C_BEGIN
typedef struct YGSize {
float width;
float height;
} YGSize;
typedef struct YGNode *YGNodeRef;
typedef YGSize (*YGMeasureFunc)(YGNodeRef node,
float width,
YGMeasureMode widthMode,
float height,
YGMeasureMode heightMode);
typedef void (*YGPrintFunc)(YGNodeRef node);
typedef int (*YGLogger)(YGLogLevel level, const char *format, va_list args);
typedef void *(*YGMalloc)(size_t size);
typedef void *(*YGCalloc)(size_t count, size_t size);
typedef void *(*YGRealloc)(void *ptr, size_t size);
typedef void (*YGFree)(void *ptr);
// YGNode
WIN_EXPORT YGNodeRef YGNodeNew(void);
WIN_EXPORT void YGNodeInit(const YGNodeRef node);
WIN_EXPORT void YGNodeFree(const YGNodeRef node);
WIN_EXPORT void YGNodeFreeRecursive(const YGNodeRef node);
WIN_EXPORT void YGNodeReset(const YGNodeRef node);
WIN_EXPORT int32_t YGNodeGetInstanceCount(void);
WIN_EXPORT void YGNodeInsertChild(const YGNodeRef node,
const YGNodeRef child,
const uint32_t index);
WIN_EXPORT void YGNodeRemoveChild(const YGNodeRef node, const YGNodeRef child);
WIN_EXPORT YGNodeRef YGNodeGetChild(const YGNodeRef node, const uint32_t index);
WIN_EXPORT uint32_t YGNodeChildCount(const YGNodeRef node);
WIN_EXPORT void YGNodeCalculateLayout(const YGNodeRef node,
const float availableWidth,
const float availableHeight,
const YGDirection parentDirection);
// Mark a node as dirty. Only valid for nodes with a custom measure function
// set.
// YG knows when to mark all other nodes as dirty but because nodes with
// measure functions
// depends on information not known to YG they must perform this dirty
// marking manually.
WIN_EXPORT void YGNodeMarkDirty(const YGNodeRef node);
WIN_EXPORT bool YGNodeIsDirty(const YGNodeRef node);
WIN_EXPORT void YGNodePrint(const YGNodeRef node, const YGPrintOptions options);
WIN_EXPORT bool YGValueIsUndefined(const float value);
WIN_EXPORT bool YGNodeCanUseCachedMeasurement(const YGMeasureMode widthMode,
const float width,
const YGMeasureMode heightMode,
const float height,
const YGMeasureMode lastWidthMode,
const float lastWidth,
const YGMeasureMode lastHeightMode,
const float lastHeight,
const float lastComputedWidth,
const float lastComputedHeight,
const float marginRow,
const float marginColumn);
WIN_EXPORT void YGNodeCopyStyle(const YGNodeRef dstNode, const YGNodeRef srcNode);
#define YG_NODE_PROPERTY(type, name, paramName) \
WIN_EXPORT void YGNodeSet##name(const YGNodeRef node, type paramName); \
WIN_EXPORT type YGNodeGet##name(const YGNodeRef node);
#define YG_NODE_STYLE_PROPERTY(type, name, paramName) \
WIN_EXPORT void YGNodeStyleSet##name(const YGNodeRef node, const type paramName); \
WIN_EXPORT type YGNodeStyleGet##name(const YGNodeRef node);
#define YG_NODE_STYLE_EDGE_PROPERTY(type, name, paramName) \
WIN_EXPORT void YGNodeStyleSet##name(const YGNodeRef node, \
const YGEdge edge, \
const type paramName); \
WIN_EXPORT type YGNodeStyleGet##name(const YGNodeRef node, const YGEdge edge);
#define YG_NODE_LAYOUT_PROPERTY(type, name) \
WIN_EXPORT type YGNodeLayoutGet##name(const YGNodeRef node);
YG_NODE_PROPERTY(void *, Context, context);
YG_NODE_PROPERTY(YGMeasureFunc, MeasureFunc, measureFunc);
YG_NODE_PROPERTY(YGPrintFunc, PrintFunc, printFunc);
YG_NODE_PROPERTY(bool, HasNewLayout, hasNewLayout);
YG_NODE_STYLE_PROPERTY(YGDirection, Direction, direction);
YG_NODE_STYLE_PROPERTY(YGFlexDirection, FlexDirection, flexDirection);
YG_NODE_STYLE_PROPERTY(YGJustify, JustifyContent, justifyContent);
YG_NODE_STYLE_PROPERTY(YGAlign, AlignContent, alignContent);
YG_NODE_STYLE_PROPERTY(YGAlign, AlignItems, alignItems);
YG_NODE_STYLE_PROPERTY(YGAlign, AlignSelf, alignSelf);
YG_NODE_STYLE_PROPERTY(YGPositionType, PositionType, positionType);
YG_NODE_STYLE_PROPERTY(YGWrap, FlexWrap, flexWrap);
YG_NODE_STYLE_PROPERTY(YGOverflow, Overflow, overflow);
WIN_EXPORT void YGNodeStyleSetFlex(const YGNodeRef node, const float flex);
YG_NODE_STYLE_PROPERTY(float, FlexGrow, flexGrow);
YG_NODE_STYLE_PROPERTY(float, FlexShrink, flexShrink);
YG_NODE_STYLE_PROPERTY(float, FlexBasis, flexBasis);
YG_NODE_STYLE_EDGE_PROPERTY(float, Position, position);
YG_NODE_STYLE_EDGE_PROPERTY(float, Margin, margin);
YG_NODE_STYLE_EDGE_PROPERTY(float, Padding, padding);
YG_NODE_STYLE_EDGE_PROPERTY(float, Border, border);
YG_NODE_STYLE_PROPERTY(float, Width, width);
YG_NODE_STYLE_PROPERTY(float, Height, height);
YG_NODE_STYLE_PROPERTY(float, MinWidth, minWidth);
YG_NODE_STYLE_PROPERTY(float, MinHeight, minHeight);
YG_NODE_STYLE_PROPERTY(float, MaxWidth, maxWidth);
YG_NODE_STYLE_PROPERTY(float, MaxHeight, maxHeight);
// Yoga specific properties, not compatible with flexbox specification
// Aspect ratio control the size of the undefined dimension of a node.
// - On a node with a set width/height aspect ratio control the size of the unset dimension
// - On a node with a set flex basis aspect ratio controls the size of the node in the cross axis if
// unset
// - On a node with a measure function aspect ratio works as though the measure function measures
// the flex basis
// - On a node with flex grow/shrink aspect ratio controls the size of the node in the cross axis if
// unset
// - Aspect ratio takes min/max dimensions into account
YG_NODE_STYLE_PROPERTY(float, AspectRatio, aspectRatio);
YG_NODE_LAYOUT_PROPERTY(float, Left);
YG_NODE_LAYOUT_PROPERTY(float, Top);
YG_NODE_LAYOUT_PROPERTY(float, Right);
YG_NODE_LAYOUT_PROPERTY(float, Bottom);
YG_NODE_LAYOUT_PROPERTY(float, Width);
YG_NODE_LAYOUT_PROPERTY(float, Height);
YG_NODE_LAYOUT_PROPERTY(YGDirection, Direction);
WIN_EXPORT void YGSetLogger(YGLogger logger);
WIN_EXPORT void YGLog(YGLogLevel level, const char *message, ...);
WIN_EXPORT void YGSetExperimentalFeatureEnabled(YGExperimentalFeature feature, bool enabled);
WIN_EXPORT bool YGIsExperimentalFeatureEnabled(YGExperimentalFeature feature);
WIN_EXPORT void
YGSetMemoryFuncs(YGMalloc cssMalloc, YGCalloc cssCalloc, YGRealloc cssRealloc, YGFree cssFree);
YG_EXTERN_C_END