Compare commits
27 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
b16c22a8f3 | ||
|
56ec33a463 | ||
|
367c3a28be | ||
|
653150a7c4 | ||
|
542fc50409 | ||
|
4f192481ee | ||
|
0bb2955c5c | ||
|
191ac98b89 | ||
|
32c175ac55 | ||
|
4b61cdccea | ||
|
b9c4c403a9 | ||
|
56aa279fef | ||
|
7e4bb732ff | ||
|
32ba5ae647 | ||
|
2fa6f5087d | ||
|
c2aac9f46e | ||
|
ef81d4b0c7 | ||
|
667858990c | ||
|
d80bac4234 | ||
|
d1c555fede | ||
|
ac4d0ab2a1 | ||
|
603321e1ab | ||
|
129437f49e | ||
|
204aba80b9 | ||
|
e6702e1168 | ||
|
b99172d28b | ||
|
7a3df9999b |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,7 +4,6 @@
|
||||
/buck-out/
|
||||
/.buckconfig.local
|
||||
/.buckd
|
||||
/lib/gtest/googletest-*/
|
||||
/gentest/test.html
|
||||
|
||||
# Visual studio code
|
||||
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
[submodule "lib/gtest/googletest"]
|
||||
path = lib/gtest/googletest
|
||||
url = https://github.com/google/googletest.git
|
@@ -4,8 +4,7 @@
|
||||
/buck-out/
|
||||
/.buckconfig.local
|
||||
/.buckd
|
||||
/lib/gtest/googletest-*/
|
||||
/gentest/test.html
|
||||
|
||||
# Visual studio code
|
||||
.vscode
|
||||
.vscode
|
||||
|
@@ -14,14 +14,17 @@ before_install:
|
||||
- brew update
|
||||
- brew tap facebook/fb
|
||||
- brew install buck
|
||||
- brew cask install java
|
||||
- brew outdated xctool || brew upgrade xctool
|
||||
- brew install mono
|
||||
- export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
|
||||
- export PATH=$JAVA_HOME/bin:$PATH
|
||||
|
||||
script:
|
||||
- buck test //:CSSLayout
|
||||
- buck test //java:java
|
||||
- buck test //CSSLayoutKit:CSSLayoutKit --config cxx.default_platform=iphonesimulator-x86_64
|
||||
- buck test //CSSLayoutKit:CSSLayoutKit --config cxx.default_platform=iphonesimulator-x86_64 --config cxx.cflags=-DTRAVIS_CI
|
||||
- sh csharp/tests/Facebook.CSSLayout/test_macos.sh
|
||||
- buck run //benchmark:benchmark
|
||||
- buck run //benchmark:benchmark
|
||||
- git checkout HEAD^
|
||||
- buck run //benchmark:benchmark
|
||||
- buck run //benchmark:benchmark
|
||||
|
@@ -6,8 +6,6 @@ JUNIT_TARGET = '//lib/junit:junit'
|
||||
PROGRUARD_ANNOTATIONS_TARGET = '//java/com/facebook/proguard/annotations:annotations'
|
||||
SOLOADER_TARGET = '//lib/soloader:soloader'
|
||||
GTEST_TARGET = '//lib/gtest:gtest'
|
||||
GTEST_DL_URL = 'https://github.com/google/googletest/archive/release-1.7.0.zip'
|
||||
|
||||
JNI_TARGET = '//lib/jni:jni'
|
||||
FBJNI_TARGET = '//lib/fb:fbjni'
|
||||
|
||||
|
106
CSSLayout/CSSEnums.h
Normal file
106
CSSLayout/CSSEnums.h
Normal file
@@ -0,0 +1,106 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
typedef enum CSSOverflow {
|
||||
CSSOverflowVisible,
|
||||
CSSOverflowHidden,
|
||||
CSSOverflowScroll,
|
||||
CSSOverflowCount,
|
||||
} CSSOverflow;
|
||||
|
||||
typedef enum CSSJustify {
|
||||
CSSJustifyFlexStart,
|
||||
CSSJustifyCenter,
|
||||
CSSJustifyFlexEnd,
|
||||
CSSJustifySpaceBetween,
|
||||
CSSJustifySpaceAround,
|
||||
CSSJustifyCount,
|
||||
} CSSJustify;
|
||||
|
||||
typedef enum CSSFlexDirection {
|
||||
CSSFlexDirectionColumn,
|
||||
CSSFlexDirectionColumnReverse,
|
||||
CSSFlexDirectionRow,
|
||||
CSSFlexDirectionRowReverse,
|
||||
CSSFlexDirectionCount,
|
||||
} CSSFlexDirection;
|
||||
|
||||
typedef enum CSSAlign {
|
||||
CSSAlignAuto,
|
||||
CSSAlignFlexStart,
|
||||
CSSAlignCenter,
|
||||
CSSAlignFlexEnd,
|
||||
CSSAlignStretch,
|
||||
CSSAlignCount,
|
||||
} CSSAlign;
|
||||
|
||||
typedef enum CSSEdge {
|
||||
CSSEdgeLeft,
|
||||
CSSEdgeTop,
|
||||
CSSEdgeRight,
|
||||
CSSEdgeBottom,
|
||||
CSSEdgeStart,
|
||||
CSSEdgeEnd,
|
||||
CSSEdgeHorizontal,
|
||||
CSSEdgeVertical,
|
||||
CSSEdgeAll,
|
||||
CSSEdgeCount,
|
||||
} CSSEdge;
|
||||
|
||||
typedef enum CSSWrap {
|
||||
CSSWrapNoWrap,
|
||||
CSSWrapWrap,
|
||||
CSSWrapCount,
|
||||
} CSSWrap;
|
||||
|
||||
typedef enum CSSDirection {
|
||||
CSSDirectionInherit,
|
||||
CSSDirectionLTR,
|
||||
CSSDirectionRTL,
|
||||
CSSDirectionCount,
|
||||
} CSSDirection;
|
||||
|
||||
typedef enum CSSExperimentalFeature {
|
||||
CSSExperimentalFeatureCount,
|
||||
} CSSExperimentalFeature;
|
||||
|
||||
typedef enum CSSLogLevel {
|
||||
CSSLogLevelError,
|
||||
CSSLogLevelWarn,
|
||||
CSSLogLevelInfo,
|
||||
CSSLogLevelDebug,
|
||||
CSSLogLevelVerbose,
|
||||
CSSLogLevelCount,
|
||||
} CSSLogLevel;
|
||||
|
||||
typedef enum CSSDimension {
|
||||
CSSDimensionWidth,
|
||||
CSSDimensionHeight,
|
||||
CSSDimensionCount,
|
||||
} CSSDimension;
|
||||
|
||||
typedef enum CSSMeasureMode {
|
||||
CSSMeasureModeUndefined,
|
||||
CSSMeasureModeExactly,
|
||||
CSSMeasureModeAtMost,
|
||||
CSSMeasureModeCount,
|
||||
} CSSMeasureMode;
|
||||
|
||||
typedef enum CSSPositionType {
|
||||
CSSPositionTypeRelative,
|
||||
CSSPositionTypeAbsolute,
|
||||
CSSPositionTypeCount,
|
||||
} CSSPositionType;
|
||||
|
||||
typedef enum CSSPrintOptions {
|
||||
CSSPrintOptionsLayout = 1,
|
||||
CSSPrintOptionsStyle = 2,
|
||||
CSSPrintOptionsChildren = 4,
|
||||
CSSPrintOptionsCount,
|
||||
} CSSPrintOptions;
|
@@ -14,7 +14,9 @@
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <float.h>
|
||||
#ifndef isnan
|
||||
#define isnan _isnan
|
||||
#endif
|
||||
|
||||
#ifndef __cplusplus
|
||||
#define inline __inline
|
||||
@@ -47,6 +49,7 @@ typedef struct CSSLayout {
|
||||
float dimensions[2];
|
||||
CSSDirection direction;
|
||||
|
||||
uint32_t computedFlexBasisGeneration;
|
||||
float computedFlexBasis;
|
||||
|
||||
// Instead of recomputing the entire layout every single time, we
|
||||
@@ -69,7 +72,7 @@ typedef struct CSSStyle {
|
||||
CSSAlign alignItems;
|
||||
CSSAlign alignSelf;
|
||||
CSSPositionType positionType;
|
||||
CSSWrapType flexWrap;
|
||||
CSSWrap flexWrap;
|
||||
CSSOverflow overflow;
|
||||
float flex;
|
||||
float flexGrow;
|
||||
@@ -102,6 +105,11 @@ typedef struct CSSNode {
|
||||
|
||||
static void _CSSNodeMarkDirty(const CSSNodeRef node);
|
||||
|
||||
CSSMalloc gCSSMalloc = &malloc;
|
||||
CSSCalloc gCSSCalloc = &calloc;
|
||||
CSSRealloc gCSSRealloc = &realloc;
|
||||
CSSFree gCSSFree = &free;
|
||||
|
||||
#ifdef ANDROID
|
||||
#include <android/log.h>
|
||||
static int _csslayoutAndroidLog(CSSLogLevel level, const char *format, va_list args) {
|
||||
@@ -122,6 +130,8 @@ static int _csslayoutAndroidLog(CSSLogLevel level, const char *format, va_list a
|
||||
case CSSLogLevelVerbose:
|
||||
androidLevel = ANDROID_LOG_VERBOSE;
|
||||
break;
|
||||
case CSSLogLevelCount:
|
||||
break;
|
||||
}
|
||||
const int result = __android_log_vprint(androidLevel, "css-layout", format, args);
|
||||
return result;
|
||||
@@ -173,10 +183,10 @@ static inline float computedEdgeValue(const float edges[CSSEdgeCount],
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
static int32_t gNodeInstanceCount = 0;
|
||||
int32_t gNodeInstanceCount = 0;
|
||||
|
||||
CSSNodeRef CSSNodeNew(void) {
|
||||
const CSSNodeRef node = calloc(1, sizeof(CSSNode));
|
||||
const CSSNodeRef node = gCSSCalloc(1, sizeof(CSSNode));
|
||||
CSS_ASSERT(node, "Could not allocate memory for node");
|
||||
gNodeInstanceCount++;
|
||||
|
||||
@@ -197,7 +207,7 @@ void CSSNodeFree(const CSSNodeRef node) {
|
||||
}
|
||||
|
||||
CSSNodeListFree(node->children);
|
||||
free(node);
|
||||
gCSSFree(node);
|
||||
gNodeInstanceCount--;
|
||||
}
|
||||
|
||||
@@ -334,7 +344,14 @@ bool CSSNodeIsDirty(const CSSNodeRef node) {
|
||||
return node->isDirty;
|
||||
}
|
||||
|
||||
inline float CSSNodeStyleGetFlexGrow(CSSNodeRef node) {
|
||||
void CSSNodeCopyStyle(const CSSNodeRef dstNode, const CSSNodeRef srcNode) {
|
||||
if (memcmp(&dstNode->style, &srcNode->style, sizeof(CSSStyle)) != 0) {
|
||||
memcpy(&dstNode->style, &srcNode->style, sizeof(CSSStyle));
|
||||
_CSSNodeMarkDirty(dstNode);
|
||||
}
|
||||
}
|
||||
|
||||
inline float CSSNodeStyleGetFlexGrow(const CSSNodeRef node) {
|
||||
if (!CSSValueIsUndefined(node->style.flexGrow)) {
|
||||
return node->style.flexGrow;
|
||||
}
|
||||
@@ -344,7 +361,7 @@ inline float CSSNodeStyleGetFlexGrow(CSSNodeRef node) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline float CSSNodeStyleGetFlexShrink(CSSNodeRef node) {
|
||||
inline float CSSNodeStyleGetFlexShrink(const CSSNodeRef node) {
|
||||
if (!CSSValueIsUndefined(node->style.flexShrink)) {
|
||||
return node->style.flexShrink;
|
||||
}
|
||||
@@ -354,7 +371,7 @@ inline float CSSNodeStyleGetFlexShrink(CSSNodeRef node) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline float CSSNodeStyleGetFlexBasis(CSSNodeRef node) {
|
||||
inline float CSSNodeStyleGetFlexBasis(const CSSNodeRef node) {
|
||||
if (!CSSValueIsUndefined(node->style.flexBasis)) {
|
||||
return node->style.flexBasis;
|
||||
}
|
||||
@@ -423,7 +440,7 @@ CSS_NODE_STYLE_PROPERTY_IMPL(CSSAlign, AlignContent, alignContent, alignContent)
|
||||
CSS_NODE_STYLE_PROPERTY_IMPL(CSSAlign, AlignItems, alignItems, alignItems);
|
||||
CSS_NODE_STYLE_PROPERTY_IMPL(CSSAlign, AlignSelf, alignSelf, alignSelf);
|
||||
CSS_NODE_STYLE_PROPERTY_IMPL(CSSPositionType, PositionType, positionType, positionType);
|
||||
CSS_NODE_STYLE_PROPERTY_IMPL(CSSWrapType, FlexWrap, flexWrap, flexWrap);
|
||||
CSS_NODE_STYLE_PROPERTY_IMPL(CSSWrap, FlexWrap, flexWrap, flexWrap);
|
||||
CSS_NODE_STYLE_PROPERTY_IMPL(CSSOverflow, Overflow, overflow, overflow);
|
||||
|
||||
CSS_NODE_STYLE_PROPERTY_SETTER_IMPL(float, FlexGrow, flexGrow, flexGrow);
|
||||
@@ -951,7 +968,8 @@ static void computeChildFlexBasis(const CSSNodeRef node,
|
||||
|
||||
if (!CSSValueIsUndefined(CSSNodeStyleGetFlexBasis(child)) &&
|
||||
!CSSValueIsUndefined(isMainAxisRow ? width : height)) {
|
||||
if (CSSValueIsUndefined(child->layout.computedFlexBasis)) {
|
||||
if (CSSValueIsUndefined(child->layout.computedFlexBasis) ||
|
||||
child->layout.computedFlexBasisGeneration != gCurrentGenerationCount) {
|
||||
child->layout.computedFlexBasis =
|
||||
fmaxf(CSSNodeStyleGetFlexBasis(child), getPaddingAndBorderAxis(child, mainAxis));
|
||||
}
|
||||
@@ -1036,6 +1054,8 @@ static void computeChildFlexBasis(const CSSNodeRef node,
|
||||
: child->layout.measuredDimensions[CSSDimensionHeight],
|
||||
getPaddingAndBorderAxis(child, mainAxis));
|
||||
}
|
||||
|
||||
child->layout.computedFlexBasisGeneration = gCurrentGenerationCount;
|
||||
}
|
||||
|
||||
static void absoluteLayoutChild(const CSSNodeRef node,
|
||||
@@ -1395,7 +1415,7 @@ static void layoutNodeImpl(const CSSNodeRef node,
|
||||
const CSSFlexDirection crossAxis = getCrossFlexDirection(mainAxis, direction);
|
||||
const bool isMainAxisRow = isRowDirection(mainAxis);
|
||||
const CSSJustify justifyContent = node->style.justifyContent;
|
||||
const bool isNodeFlexWrap = node->style.flexWrap == CSSWrapTypeWrap;
|
||||
const bool isNodeFlexWrap = node->style.flexWrap == CSSWrapWrap;
|
||||
|
||||
CSSNodeRef firstAbsoluteChild = NULL;
|
||||
CSSNodeRef currentAbsoluteChild = NULL;
|
||||
@@ -1461,6 +1481,7 @@ static void layoutNodeImpl(const CSSNodeRef node,
|
||||
child->nextChild = NULL;
|
||||
} else {
|
||||
if (child == singleFlexChild) {
|
||||
child->layout.computedFlexBasisGeneration = gCurrentGenerationCount;
|
||||
child->layout.computedFlexBasis = 0;
|
||||
} else {
|
||||
computeChildFlexBasis(node,
|
||||
@@ -1796,9 +1817,9 @@ static void layoutNodeImpl(const CSSNodeRef node,
|
||||
if (measureModeMainDim == CSSMeasureModeAtMost && remainingFreeSpace > 0) {
|
||||
if (!CSSValueIsUndefined(node->style.minDimensions[dim[mainAxis]]) &&
|
||||
node->style.minDimensions[dim[mainAxis]] >= 0) {
|
||||
remainingFreeSpace = fmax(0,
|
||||
node->style.minDimensions[dim[mainAxis]] -
|
||||
(availableInnerMainDim - remainingFreeSpace));
|
||||
remainingFreeSpace = fmaxf(0,
|
||||
node->style.minDimensions[dim[mainAxis]] -
|
||||
(availableInnerMainDim - remainingFreeSpace));
|
||||
} else {
|
||||
remainingFreeSpace = 0;
|
||||
}
|
||||
@@ -1824,6 +1845,7 @@ static void layoutNodeImpl(const CSSNodeRef node,
|
||||
leadingMainDim = betweenMainDim / 2;
|
||||
break;
|
||||
case CSSJustifyFlexStart:
|
||||
case CSSJustifyCount:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2015,6 +2037,7 @@ static void layoutNodeImpl(const CSSNodeRef node,
|
||||
break;
|
||||
case CSSAlignAuto:
|
||||
case CSSAlignFlexStart:
|
||||
case CSSAlignCount:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2074,6 +2097,7 @@ static void layoutNodeImpl(const CSSNodeRef node,
|
||||
break;
|
||||
}
|
||||
case CSSAlignAuto:
|
||||
case CSSAlignCount:
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2156,7 +2180,7 @@ bool gPrintSkips = false;
|
||||
static const char *spacer = " ";
|
||||
|
||||
static const char *getSpacer(const unsigned long level) {
|
||||
const unsigned long spacerLen = strlen(spacer);
|
||||
const size_t spacerLen = strlen(spacer);
|
||||
if (level > spacerLen) {
|
||||
return &spacer[0];
|
||||
} else {
|
||||
@@ -2508,3 +2532,35 @@ void CSSLog(CSSLogLevel level, const char *format, ...) {
|
||||
gLogger(level, format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
static bool experimentalFeatures[CSSExperimentalFeatureCount + 1];
|
||||
|
||||
void CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeature feature, bool enabled) {
|
||||
experimentalFeatures[feature] = enabled;
|
||||
}
|
||||
|
||||
bool CSSLayoutIsExperimentalFeatureEnabled(CSSExperimentalFeature feature) {
|
||||
return experimentalFeatures[feature];
|
||||
}
|
||||
|
||||
void CSSLayoutSetMemoryFuncs(CSSMalloc cssMalloc,
|
||||
CSSCalloc cssCalloc,
|
||||
CSSRealloc cssRealloc,
|
||||
CSSFree cssFree) {
|
||||
CSS_ASSERT(gNodeInstanceCount == 0, "Cannot set memory functions: all node must be freed first");
|
||||
CSS_ASSERT((cssMalloc == NULL && cssCalloc == NULL && cssRealloc == NULL && cssFree == NULL) ||
|
||||
(cssMalloc != NULL && cssCalloc != NULL && cssRealloc != NULL && cssFree != NULL),
|
||||
"Cannot set memory functions: functions must be all NULL or Non-NULL");
|
||||
|
||||
if (cssMalloc == NULL || cssCalloc == NULL || cssRealloc == NULL || cssFree == NULL) {
|
||||
gCSSMalloc = &malloc;
|
||||
gCSSCalloc = &calloc;
|
||||
gCSSRealloc = &realloc;
|
||||
gCSSFree = &free;
|
||||
} else {
|
||||
gCSSMalloc = cssMalloc;
|
||||
gCSSCalloc = cssCalloc;
|
||||
gCSSRealloc = cssRealloc;
|
||||
gCSSFree = cssFree;
|
||||
}
|
||||
}
|
||||
|
@@ -28,101 +28,16 @@ static const unsigned long __nan[2] = {0xffffffff, 0x7fffffff};
|
||||
|
||||
#define CSSUndefined NAN
|
||||
|
||||
#include "CSSEnums.h"
|
||||
#include "CSSMacros.h"
|
||||
|
||||
CSS_EXTERN_C_BEGIN
|
||||
|
||||
typedef enum CSSDirection {
|
||||
CSSDirectionInherit,
|
||||
CSSDirectionLTR,
|
||||
CSSDirectionRTL,
|
||||
} CSSDirection;
|
||||
|
||||
typedef enum CSSFlexDirection {
|
||||
CSSFlexDirectionColumn,
|
||||
CSSFlexDirectionColumnReverse,
|
||||
CSSFlexDirectionRow,
|
||||
CSSFlexDirectionRowReverse,
|
||||
} CSSFlexDirection;
|
||||
|
||||
typedef enum CSSJustify {
|
||||
CSSJustifyFlexStart,
|
||||
CSSJustifyCenter,
|
||||
CSSJustifyFlexEnd,
|
||||
CSSJustifySpaceBetween,
|
||||
CSSJustifySpaceAround,
|
||||
} CSSJustify;
|
||||
|
||||
typedef enum CSSOverflow {
|
||||
CSSOverflowVisible,
|
||||
CSSOverflowHidden,
|
||||
CSSOverflowScroll,
|
||||
} CSSOverflow;
|
||||
|
||||
// Note: auto is only a valid value for alignSelf. It is NOT a valid value for
|
||||
// alignItems.
|
||||
typedef enum CSSAlign {
|
||||
CSSAlignAuto,
|
||||
CSSAlignFlexStart,
|
||||
CSSAlignCenter,
|
||||
CSSAlignFlexEnd,
|
||||
CSSAlignStretch,
|
||||
} CSSAlign;
|
||||
|
||||
typedef enum CSSPositionType {
|
||||
CSSPositionTypeRelative,
|
||||
CSSPositionTypeAbsolute,
|
||||
} CSSPositionType;
|
||||
|
||||
typedef enum CSSWrapType {
|
||||
CSSWrapTypeNoWrap,
|
||||
CSSWrapTypeWrap,
|
||||
} CSSWrapType;
|
||||
|
||||
typedef enum CSSMeasureMode {
|
||||
CSSMeasureModeUndefined,
|
||||
CSSMeasureModeExactly,
|
||||
CSSMeasureModeAtMost,
|
||||
CSSMeasureModeCount,
|
||||
} CSSMeasureMode;
|
||||
|
||||
typedef enum CSSDimension {
|
||||
CSSDimensionWidth,
|
||||
CSSDimensionHeight,
|
||||
} CSSDimension;
|
||||
|
||||
typedef enum CSSEdge {
|
||||
CSSEdgeLeft,
|
||||
CSSEdgeTop,
|
||||
CSSEdgeRight,
|
||||
CSSEdgeBottom,
|
||||
CSSEdgeStart,
|
||||
CSSEdgeEnd,
|
||||
CSSEdgeHorizontal,
|
||||
CSSEdgeVertical,
|
||||
CSSEdgeAll,
|
||||
CSSEdgeCount,
|
||||
} CSSEdge;
|
||||
|
||||
typedef enum CSSPrintOptions {
|
||||
CSSPrintOptionsLayout = 1,
|
||||
CSSPrintOptionsStyle = 2,
|
||||
CSSPrintOptionsChildren = 4,
|
||||
} CSSPrintOptions;
|
||||
|
||||
typedef struct CSSSize {
|
||||
float width;
|
||||
float height;
|
||||
} CSSSize;
|
||||
|
||||
typedef enum CSSLogLevel {
|
||||
CSSLogLevelError,
|
||||
CSSLogLevelWarn,
|
||||
CSSLogLevelInfo,
|
||||
CSSLogLevelDebug,
|
||||
CSSLogLevelVerbose,
|
||||
} CSSLogLevel;
|
||||
|
||||
typedef struct CSSNode *CSSNodeRef;
|
||||
typedef CSSSize (*CSSMeasureFunc)(CSSNodeRef node,
|
||||
float width,
|
||||
@@ -132,6 +47,11 @@ typedef CSSSize (*CSSMeasureFunc)(CSSNodeRef node,
|
||||
typedef void (*CSSPrintFunc)(CSSNodeRef node);
|
||||
typedef int (*CSSLogger)(CSSLogLevel 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);
|
||||
@@ -178,6 +98,8 @@ WIN_EXPORT bool CSSNodeCanUseCachedMeasurement(const CSSMeasureMode widthMode,
|
||||
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);
|
||||
@@ -207,7 +129,7 @@ CSS_NODE_STYLE_PROPERTY(CSSAlign, AlignContent, alignContent);
|
||||
CSS_NODE_STYLE_PROPERTY(CSSAlign, AlignItems, alignItems);
|
||||
CSS_NODE_STYLE_PROPERTY(CSSAlign, AlignSelf, alignSelf);
|
||||
CSS_NODE_STYLE_PROPERTY(CSSPositionType, PositionType, positionType);
|
||||
CSS_NODE_STYLE_PROPERTY(CSSWrapType, FlexWrap, flexWrap);
|
||||
CSS_NODE_STYLE_PROPERTY(CSSWrap, FlexWrap, flexWrap);
|
||||
CSS_NODE_STYLE_PROPERTY(CSSOverflow, Overflow, overflow);
|
||||
|
||||
WIN_EXPORT void CSSNodeStyleSetFlex(const CSSNodeRef node, const float flex);
|
||||
@@ -238,4 +160,13 @@ CSS_NODE_LAYOUT_PROPERTY(CSSDirection, Direction);
|
||||
WIN_EXPORT void CSSLayoutSetLogger(CSSLogger logger);
|
||||
WIN_EXPORT void CSSLog(CSSLogLevel level, const char *message, ...);
|
||||
|
||||
WIN_EXPORT void CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeature feature,
|
||||
bool enabled);
|
||||
WIN_EXPORT bool CSSLayoutIsExperimentalFeatureEnabled(CSSExperimentalFeature feature);
|
||||
|
||||
WIN_EXPORT void CSSLayoutSetMemoryFuncs(CSSMalloc cssMalloc,
|
||||
CSSCalloc cssCalloc,
|
||||
CSSRealloc cssRealloc,
|
||||
CSSFree cssFree);
|
||||
|
||||
CSS_EXTERN_C_END
|
||||
|
@@ -9,6 +9,10 @@
|
||||
|
||||
#include "CSSNodeList.h"
|
||||
|
||||
extern CSSMalloc gCSSMalloc;
|
||||
extern CSSRealloc gCSSRealloc;
|
||||
extern CSSFree gCSSFree;
|
||||
|
||||
struct CSSNodeList {
|
||||
uint32_t capacity;
|
||||
uint32_t count;
|
||||
@@ -16,12 +20,12 @@ struct CSSNodeList {
|
||||
};
|
||||
|
||||
CSSNodeListRef CSSNodeListNew(const uint32_t initialCapacity) {
|
||||
const CSSNodeListRef list = malloc(sizeof(struct CSSNodeList));
|
||||
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 = malloc(sizeof(CSSNodeRef) * list->capacity);
|
||||
list->items = gCSSMalloc(sizeof(CSSNodeRef) * list->capacity);
|
||||
CSS_ASSERT(list->items != NULL, "Could not allocate memory for items");
|
||||
|
||||
return list;
|
||||
@@ -29,8 +33,8 @@ CSSNodeListRef CSSNodeListNew(const uint32_t initialCapacity) {
|
||||
|
||||
void CSSNodeListFree(const CSSNodeListRef list) {
|
||||
if (list) {
|
||||
free(list->items);
|
||||
free(list);
|
||||
gCSSFree(list->items);
|
||||
gCSSFree(list);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +60,7 @@ void CSSNodeListInsert(CSSNodeListRef *listp, const CSSNodeRef node, const uint3
|
||||
|
||||
if (list->count == list->capacity) {
|
||||
list->capacity *= 2;
|
||||
list->items = realloc(list->items, sizeof(CSSNodeRef) * list->capacity);
|
||||
list->items = gCSSRealloc(list->items, sizeof(CSSNodeRef) * list->capacity);
|
||||
CSS_ASSERT(list->items != NULL, "Could not extend allocation for items");
|
||||
}
|
||||
|
||||
|
202
CSSLayoutKit/Tests/CSSLayoutKitTests.m
Normal file
202
CSSLayoutKit/Tests/CSSLayoutKitTests.m
Normal file
@@ -0,0 +1,202 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#import <XCTest/XCTest.h>
|
||||
|
||||
#import "UIView+CSSLayout.h"
|
||||
|
||||
@interface CSSLayoutKitTests : XCTestCase
|
||||
@end
|
||||
|
||||
@implementation CSSLayoutKitTests
|
||||
|
||||
#ifndef TRAVIS_CI
|
||||
|
||||
- (void)testNodesAreDeallocedWithSingleView
|
||||
{
|
||||
XCTAssertEqual(0, CSSNodeGetInstanceCount());
|
||||
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[view css_setFlexBasis:1];
|
||||
XCTAssertEqual(1, CSSNodeGetInstanceCount());
|
||||
view = nil;
|
||||
|
||||
XCTAssertEqual(0, CSSNodeGetInstanceCount());
|
||||
}
|
||||
|
||||
- (void)testNodesAreDeallocedCascade
|
||||
{
|
||||
XCTAssertEqual(0, CSSNodeGetInstanceCount());
|
||||
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[view css_setFlexBasis:1];
|
||||
|
||||
for (int i=0; i<10; i++) {
|
||||
UIView *subview = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[subview css_setFlexBasis:1];
|
||||
[view addSubview:subview];
|
||||
}
|
||||
XCTAssertEqual(11, CSSNodeGetInstanceCount());
|
||||
view = nil;
|
||||
|
||||
XCTAssertEqual(0, CSSNodeGetInstanceCount());
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
- (void)testUsesFlexbox
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
XCTAssertFalse([view css_usesFlexbox]);
|
||||
|
||||
[view css_setUsesFlexbox:YES];
|
||||
XCTAssertTrue([view css_usesFlexbox]);
|
||||
|
||||
[view css_setUsesFlexbox:NO];
|
||||
XCTAssertFalse([view css_usesFlexbox]);
|
||||
}
|
||||
|
||||
- (void)testSizeThatFitsAsserts
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
dispatch_sync(dispatch_queue_create("com.facebook.CSSLayout.testing", DISPATCH_QUEUE_SERIAL), ^(void){
|
||||
XCTAssertThrows([view css_intrinsicSize]);
|
||||
});
|
||||
}
|
||||
|
||||
- (void)testSizeThatFitsSmoke
|
||||
{
|
||||
UIView *container = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[container css_setUsesFlexbox:YES];
|
||||
[container css_setFlexDirection:CSSFlexDirectionRow];
|
||||
[container css_setAlignItems:CSSAlignFlexStart];
|
||||
|
||||
UILabel *longTextLabel = [[UILabel alloc] initWithFrame:CGRectZero];
|
||||
longTextLabel.text = @"This is a very very very very very very very very long piece of text.";
|
||||
longTextLabel.lineBreakMode = NSLineBreakByTruncatingTail;
|
||||
longTextLabel.numberOfLines = 1;
|
||||
[longTextLabel css_setUsesFlexbox:YES];
|
||||
[longTextLabel css_setFlexShrink:1];
|
||||
[container addSubview:longTextLabel];
|
||||
|
||||
UIView *textBadgeView = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[textBadgeView css_setUsesFlexbox:YES];
|
||||
[textBadgeView css_setMargin:3.0 forEdge:CSSEdgeLeft];
|
||||
[textBadgeView css_setWidth:10];
|
||||
[textBadgeView css_setHeight:10];
|
||||
[container addSubview:textBadgeView];
|
||||
|
||||
const CGSize containerSize = [container css_intrinsicSize];
|
||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(514,21), containerSize), @"Size is actually %@", NSStringFromCGSize(containerSize));
|
||||
}
|
||||
|
||||
- (void)testFrameAndOriginPlacement
|
||||
{
|
||||
const CGSize containerSize = CGSizeMake(320, 50);
|
||||
|
||||
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, containerSize.width, containerSize.height)];
|
||||
[container css_setUsesFlexbox:YES];
|
||||
[container css_setFlexDirection:CSSFlexDirectionRow];
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
UIView *subview = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[subview css_setUsesFlexbox:YES];
|
||||
[subview css_setFlexGrow:1];
|
||||
|
||||
[container addSubview:subview];
|
||||
}
|
||||
[container css_applyLayout];
|
||||
|
||||
XCTAssertFalse(CGRectIntersectsRect([container.subviews objectAtIndex:0].frame, [container.subviews objectAtIndex:1].frame));
|
||||
XCTAssertFalse(CGRectIntersectsRect([container.subviews objectAtIndex:1].frame, [container.subviews objectAtIndex:2].frame));
|
||||
XCTAssertFalse(CGRectIntersectsRect([container.subviews objectAtIndex:0].frame, [container.subviews objectAtIndex:2].frame));
|
||||
|
||||
CGFloat totalWidth = 0;
|
||||
for (UIView *view in container.subviews) {
|
||||
totalWidth += view.bounds.size.width;
|
||||
}
|
||||
|
||||
XCTAssertEqual(containerSize.width, totalWidth, @"The container's width is %.6f, the subviews take up %.6f", containerSize.width, totalWidth);
|
||||
}
|
||||
|
||||
- (void)testThatWeRespectIncludeInLayoutFlag
|
||||
{
|
||||
const CGSize containerSize = CGSizeMake(300, 50);
|
||||
|
||||
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, containerSize.width, containerSize.height)];
|
||||
[container css_setUsesFlexbox:YES];
|
||||
[container css_setFlexDirection:CSSFlexDirectionRow];
|
||||
|
||||
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[subview1 css_setUsesFlexbox:YES];
|
||||
[subview1 css_setFlexGrow:1];
|
||||
[container addSubview:subview1];
|
||||
|
||||
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[subview2 css_setUsesFlexbox:YES];
|
||||
[subview2 css_setFlexGrow:1];
|
||||
[container addSubview:subview2];
|
||||
|
||||
UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[subview3 css_setUsesFlexbox:YES];
|
||||
[subview3 css_setFlexGrow:1];
|
||||
[container addSubview:subview3];
|
||||
|
||||
[container css_applyLayout];
|
||||
|
||||
for (UIView *view in container.subviews) {
|
||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(100, 50), subview1.bounds.size), @"Actual size is %@", NSStringFromCGSize(view.bounds.size));
|
||||
}
|
||||
|
||||
[subview3 css_setIncludeInLayout:NO];
|
||||
[container css_applyLayout];
|
||||
|
||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(150, 50), subview1.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview1.bounds.size));
|
||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(150, 50), subview2.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview2.bounds.size));
|
||||
|
||||
// We don't set the frame to zero, so, it should be set to what it was previously at.
|
||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(100, 50), subview3.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview3.bounds.size));
|
||||
}
|
||||
|
||||
- (void)testThatViewNotIncludedInFirstLayoutPassAreIncludedInSecond
|
||||
{
|
||||
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 50)];
|
||||
[container css_setUsesFlexbox:YES];
|
||||
[container css_setFlexDirection:CSSFlexDirectionRow];
|
||||
|
||||
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[subview1 css_setUsesFlexbox:YES];
|
||||
[subview1 css_setFlexGrow:1];
|
||||
[container addSubview:subview1];
|
||||
|
||||
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[subview2 css_setUsesFlexbox:YES];
|
||||
[subview2 css_setFlexGrow:1];
|
||||
[container addSubview:subview2];
|
||||
|
||||
UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[subview3 css_setUsesFlexbox:YES];
|
||||
[subview3 css_setFlexGrow:1];
|
||||
[subview3 css_setIncludeInLayout:NO];
|
||||
[container addSubview:subview3];
|
||||
|
||||
[container css_applyLayout];
|
||||
|
||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(150, 50), subview1.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview1.bounds.size));
|
||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(150, 50), subview2.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview2.bounds.size));
|
||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeZero, subview3.bounds.size), @"Actual size %@", NSStringFromCGSize(subview3.bounds.size));
|
||||
|
||||
[subview3 css_setIncludeInLayout:YES];
|
||||
[container css_applyLayout];
|
||||
for (UIView *view in container.subviews) {
|
||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(100, 50), subview1.bounds.size), @"Actual size is %@", NSStringFromCGSize(view.bounds.size));
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
@@ -1,110 +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.
|
||||
*/
|
||||
|
||||
#import <XCTest/XCTest.h>
|
||||
|
||||
#import "UIView+CSSLayout.h"
|
||||
|
||||
@interface CSSLayoutTests : XCTestCase
|
||||
@end
|
||||
|
||||
@implementation CSSLayoutTests
|
||||
|
||||
- (void)testNodesAreDeallocedWithSingleView
|
||||
{
|
||||
XCTAssertEqual(0, CSSNodeGetInstanceCount());
|
||||
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[view css_setFlexBasis:1];
|
||||
XCTAssertEqual(1, CSSNodeGetInstanceCount());
|
||||
view = nil;
|
||||
|
||||
XCTAssertEqual(0, CSSNodeGetInstanceCount());
|
||||
}
|
||||
|
||||
- (void)testNodesAreDeallocedCascade
|
||||
{
|
||||
XCTAssertEqual(0, CSSNodeGetInstanceCount());
|
||||
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[view css_setFlexBasis:1];
|
||||
|
||||
for (int i=0; i<10; i++) {
|
||||
UIView *subview = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[subview css_setFlexBasis:1];
|
||||
[view addSubview:subview];
|
||||
}
|
||||
XCTAssertEqual(11, CSSNodeGetInstanceCount());
|
||||
view = nil;
|
||||
|
||||
XCTAssertEqual(0, CSSNodeGetInstanceCount());
|
||||
}
|
||||
|
||||
- (void)testUsesFlexbox
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
XCTAssertFalse([view css_usesFlexbox]);
|
||||
|
||||
[view css_setUsesFlexbox:YES];
|
||||
XCTAssertTrue([view css_usesFlexbox]);
|
||||
|
||||
[view css_setUsesFlexbox:NO];
|
||||
XCTAssertFalse([view css_usesFlexbox]);
|
||||
}
|
||||
|
||||
- (void)testSizeThatFitsAsserts
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
XCTAssertThrows([view css_sizeThatFits:CGSizeZero]);
|
||||
|
||||
dispatch_sync(dispatch_queue_create("com.facebook.CSSLayout.testing", DISPATCH_QUEUE_SERIAL), ^(void){
|
||||
XCTAssertThrows([view css_sizeThatFits:CGSizeZero]);
|
||||
});
|
||||
}
|
||||
|
||||
- (void)testSizeThatFitsSmoke
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[view css_setUsesFlexbox:YES];
|
||||
|
||||
const CGSize constrainedSize = CGSizeMake(50, 50);
|
||||
const CGSize actualSize = [view css_sizeThatFits:constrainedSize];
|
||||
XCTAssertTrue(CGSizeEqualToSize(constrainedSize, actualSize), @"Actual Size: %@", NSStringFromCGSize(actualSize));
|
||||
}
|
||||
|
||||
- (void)testFrameAndOriginPlacement
|
||||
{
|
||||
const CGSize containerSize = CGSizeMake(320, 50);
|
||||
|
||||
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, containerSize.width, containerSize.height)];
|
||||
[container css_setUsesFlexbox:YES];
|
||||
[container css_setFlexDirection:CSSFlexDirectionRow];
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
UIView *subview = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[subview css_setUsesFlexbox:YES];
|
||||
[subview css_setFlexGrow:1];
|
||||
|
||||
[container addSubview:subview];
|
||||
}
|
||||
[container css_applyLayout];
|
||||
|
||||
XCTAssertFalse(CGRectIntersectsRect([container.subviews objectAtIndex:0].frame, [container.subviews objectAtIndex:1].frame));
|
||||
XCTAssertFalse(CGRectIntersectsRect([container.subviews objectAtIndex:1].frame, [container.subviews objectAtIndex:2].frame));
|
||||
XCTAssertFalse(CGRectIntersectsRect([container.subviews objectAtIndex:0].frame, [container.subviews objectAtIndex:2].frame));
|
||||
|
||||
CGFloat totalWidth = 0;
|
||||
for (UIView *view in container.subviews) {
|
||||
totalWidth += view.bounds.size.width;
|
||||
}
|
||||
|
||||
XCTAssertEqual(containerSize.width, totalWidth, @"The container's width is %.6f, the subviews take up %.6f", containerSize.width, totalWidth);
|
||||
}
|
||||
|
||||
@end
|
@@ -12,6 +12,11 @@
|
||||
|
||||
@interface UIView (CSSLayout)
|
||||
|
||||
/**
|
||||
The property that decides if we should include this view when calculating layout. Defaults to YES.
|
||||
*/
|
||||
@property (nonatomic, readwrite, assign, setter=css_setIncludeInLayout:) BOOL css_includeInLayout;
|
||||
|
||||
/**
|
||||
The property that decides during layout/sizing whether or not css_* properties should be applied. Defaults to NO.
|
||||
*/
|
||||
@@ -24,7 +29,7 @@
|
||||
- (void)css_setAlignItems:(CSSAlign)alignItems;
|
||||
- (void)css_setAlignSelf:(CSSAlign)alignSelf;
|
||||
- (void)css_setPositionType:(CSSPositionType)positionType;
|
||||
- (void)css_setFlexWrap:(CSSWrapType)flexWrap;
|
||||
- (void)css_setFlexWrap:(CSSWrap)flexWrap;
|
||||
|
||||
- (void)css_setFlexGrow:(CGFloat)flexGrow;
|
||||
- (void)css_setFlexShrink:(CGFloat)flexShrink;
|
||||
@@ -52,8 +57,8 @@
|
||||
- (void)css_applyLayout;
|
||||
|
||||
/**
|
||||
Compute the size of a layout with a constrained size.
|
||||
Returns the size of the view if no constraints were given. This could equivalent to calling [self sizeThatFits:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)];
|
||||
*/
|
||||
- (CGSize)css_sizeThatFits:(CGSize)constrainedSize;
|
||||
- (CGSize)css_intrinsicSize;
|
||||
|
||||
@end
|
||||
|
@@ -39,8 +39,23 @@
|
||||
return [usesFlexbox boolValue];
|
||||
}
|
||||
|
||||
- (BOOL)css_includeInLayout
|
||||
{
|
||||
NSNumber *includeInLayout = objc_getAssociatedObject(self, @selector(css_includeInLayout));
|
||||
return (includeInLayout != nil) ? [includeInLayout boolValue] : YES;
|
||||
}
|
||||
|
||||
#pragma mark - Setters
|
||||
|
||||
- (void)css_setIncludeInLayout:(BOOL)includeInLayout
|
||||
{
|
||||
objc_setAssociatedObject(
|
||||
self,
|
||||
@selector(css_includeInLayout),
|
||||
@(includeInLayout),
|
||||
OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
}
|
||||
|
||||
- (void)css_setUsesFlexbox:(BOOL)enabled
|
||||
{
|
||||
objc_setAssociatedObject(
|
||||
@@ -85,7 +100,7 @@
|
||||
CSSNodeStyleSetPositionType([self cssNode], positionType);
|
||||
}
|
||||
|
||||
- (void)css_setFlexWrap:(CSSWrapType)flexWrap
|
||||
- (void)css_setFlexWrap:(CSSWrap)flexWrap
|
||||
{
|
||||
CSSNodeStyleSetFlexWrap([self cssNode], flexWrap);
|
||||
}
|
||||
@@ -157,30 +172,19 @@
|
||||
return CSSNodeLayoutGetDirection([self cssNode]);
|
||||
}
|
||||
|
||||
- (CGSize)css_sizeThatFits:(CGSize)constrainedSize
|
||||
{
|
||||
NSAssert([NSThread isMainThread], @"CSS Layout calculation must be done on main.");
|
||||
NSAssert([self css_usesFlexbox], @"CSS Layout is not enabled for this view.");
|
||||
|
||||
CLKAttachNodesFromViewHierachy(self);
|
||||
|
||||
const CSSNodeRef node = [self cssNode];
|
||||
CSSNodeCalculateLayout(
|
||||
node,
|
||||
constrainedSize.width,
|
||||
constrainedSize.height,
|
||||
CSSNodeStyleGetDirection(node));
|
||||
|
||||
return (CGSize) {
|
||||
.width = CSSNodeLayoutGetWidth(node),
|
||||
.height = CSSNodeLayoutGetHeight(node),
|
||||
};
|
||||
}
|
||||
|
||||
- (void)css_applyLayout
|
||||
{
|
||||
[self css_sizeThatFits:self.bounds.size];
|
||||
CLKApplyLayoutToViewHierarchy(self);
|
||||
[self calculateLayoutWithSize:self.bounds.size];
|
||||
CSSApplyLayoutToViewHierarchy(self);
|
||||
}
|
||||
|
||||
- (CGSize)css_intrinsicSize
|
||||
{
|
||||
const CGSize constrainedSize = {
|
||||
.width = CSSUndefined,
|
||||
.height = CSSUndefined,
|
||||
};
|
||||
return [self calculateLayoutWithSize:constrainedSize];
|
||||
}
|
||||
|
||||
#pragma mark - Private
|
||||
@@ -197,7 +201,27 @@
|
||||
return node.cnode;
|
||||
}
|
||||
|
||||
static CSSSize CLKMeasureView(
|
||||
- (CGSize)calculateLayoutWithSize:(CGSize)size
|
||||
{
|
||||
NSAssert([NSThread isMainThread], @"CSS Layout calculation must be done on main.");
|
||||
NSAssert([self css_usesFlexbox], @"CSS Layout is not enabled for this view.");
|
||||
|
||||
CSSAttachNodesFromViewHierachy(self);
|
||||
|
||||
const CSSNodeRef node = [self cssNode];
|
||||
CSSNodeCalculateLayout(
|
||||
node,
|
||||
size.width,
|
||||
size.height,
|
||||
CSSNodeStyleGetDirection(node));
|
||||
|
||||
return (CGSize) {
|
||||
.width = CSSNodeLayoutGetWidth(node),
|
||||
.height = CSSNodeLayoutGetHeight(node),
|
||||
};
|
||||
}
|
||||
|
||||
static CSSSize CSSMeasureView(
|
||||
CSSNodeRef node,
|
||||
float width,
|
||||
CSSMeasureMode widthMode,
|
||||
@@ -214,12 +238,12 @@ static CSSSize CLKMeasureView(
|
||||
}];
|
||||
|
||||
return (CSSSize) {
|
||||
.width = CLKSanitizeMeasurement(constrainedWidth, sizeThatFits.width, widthMode),
|
||||
.height = CLKSanitizeMeasurement(constrainedHeight, sizeThatFits.height, heightMode),
|
||||
.width = CSSSanitizeMeasurement(constrainedWidth, sizeThatFits.width, widthMode),
|
||||
.height = CSSSanitizeMeasurement(constrainedHeight, sizeThatFits.height, heightMode),
|
||||
};
|
||||
}
|
||||
|
||||
static CGFloat CLKSanitizeMeasurement(
|
||||
static CGFloat CSSSanitizeMeasurement(
|
||||
CGFloat constrainedSize,
|
||||
CGFloat measuredSize,
|
||||
CSSMeasureMode measureMode)
|
||||
@@ -236,14 +260,14 @@ static CGFloat CLKSanitizeMeasurement(
|
||||
return result;
|
||||
}
|
||||
|
||||
static void CLKAttachNodesFromViewHierachy(UIView *view) {
|
||||
static void CSSAttachNodesFromViewHierachy(UIView *view) {
|
||||
CSSNodeRef node = [view cssNode];
|
||||
const BOOL usesFlexbox = [view css_usesFlexbox];
|
||||
const BOOL isLeaf = !usesFlexbox || view.subviews.count == 0;
|
||||
|
||||
// Only leaf nodes should have a measure function
|
||||
if (isLeaf) {
|
||||
CSSNodeSetMeasureFunc(node, CLKMeasureView);
|
||||
CSSNodeSetMeasureFunc(node, CSSMeasureView);
|
||||
|
||||
// Clear any children
|
||||
while (CSSNodeChildCount(node) > 0) {
|
||||
@@ -252,23 +276,30 @@ static void CLKAttachNodesFromViewHierachy(UIView *view) {
|
||||
} else {
|
||||
CSSNodeSetMeasureFunc(node, NULL);
|
||||
|
||||
NSUInteger numSubviewsInLayout = 0;
|
||||
// Add any children which were added since the last call to css_applyLayout
|
||||
for (NSUInteger i = 0; i < view.subviews.count; i++) {
|
||||
CSSNodeRef childNode = [view.subviews[i] cssNode];
|
||||
UIView *const subview = view.subviews[i];
|
||||
if (![subview css_includeInLayout]) {
|
||||
continue;
|
||||
}
|
||||
numSubviewsInLayout++;
|
||||
|
||||
CSSNodeRef childNode = [subview cssNode];
|
||||
if (CSSNodeChildCount(node) < i + 1 || CSSNodeGetChild(node, i) != childNode) {
|
||||
CSSNodeInsertChild(node, childNode, i);
|
||||
}
|
||||
CLKAttachNodesFromViewHierachy(view.subviews[i]);
|
||||
CSSAttachNodesFromViewHierachy(subview);
|
||||
}
|
||||
|
||||
// Remove any children which were removed since the last call to css_applyLayout
|
||||
while (view.subviews.count < CSSNodeChildCount(node)) {
|
||||
while (numSubviewsInLayout < CSSNodeChildCount(node)) {
|
||||
CSSNodeRemoveChild(node, CSSNodeGetChild(node, CSSNodeChildCount(node) - 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static CGFloat CLKRoundPixelValue(CGFloat value)
|
||||
static CGFloat CSSRoundPixelValue(CGFloat value)
|
||||
{
|
||||
static CGFloat scale;
|
||||
static dispatch_once_t onceToken;
|
||||
@@ -279,10 +310,13 @@ static CGFloat CLKRoundPixelValue(CGFloat value)
|
||||
return round(value * scale) / scale;
|
||||
}
|
||||
|
||||
static void CLKApplyLayoutToViewHierarchy(UIView *view) {
|
||||
static void CSSApplyLayoutToViewHierarchy(UIView *view) {
|
||||
NSCAssert([NSThread isMainThread], @"Framesetting should only be done on the main thread.");
|
||||
CSSNodeRef node = [view cssNode];
|
||||
if (![view css_includeInLayout]) {
|
||||
return;
|
||||
}
|
||||
|
||||
CSSNodeRef node = [view cssNode];
|
||||
const CGPoint topLeft = {
|
||||
CSSNodeLayoutGetLeft(node),
|
||||
CSSNodeLayoutGetTop(node),
|
||||
@@ -295,19 +329,19 @@ static void CLKApplyLayoutToViewHierarchy(UIView *view) {
|
||||
|
||||
view.frame = (CGRect) {
|
||||
.origin = {
|
||||
.x = CLKRoundPixelValue(topLeft.x),
|
||||
.y = CLKRoundPixelValue(topLeft.y),
|
||||
.x = CSSRoundPixelValue(topLeft.x),
|
||||
.y = CSSRoundPixelValue(topLeft.y),
|
||||
},
|
||||
.size = {
|
||||
.width = CLKRoundPixelValue(bottomRight.x) - CLKRoundPixelValue(topLeft.x),
|
||||
.height = CLKRoundPixelValue(bottomRight.y) - CLKRoundPixelValue(topLeft.y),
|
||||
.width = CSSRoundPixelValue(bottomRight.x) - CSSRoundPixelValue(topLeft.x),
|
||||
.height = CSSRoundPixelValue(bottomRight.y) - CSSRoundPixelValue(topLeft.y),
|
||||
},
|
||||
};
|
||||
|
||||
const BOOL isLeaf = ![view css_usesFlexbox] || view.subviews.count == 0;
|
||||
if (!isLeaf) {
|
||||
for (NSUInteger i = 0; i < view.subviews.count; i++) {
|
||||
CLKApplyLayoutToViewHierarchy(view.subviews[i]);
|
||||
CSSApplyLayoutToViewHierarchy(view.subviews[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -15,6 +15,6 @@ namespace Facebook.CSSLayout
|
||||
FlexStart,
|
||||
Center,
|
||||
FlexEnd,
|
||||
Stretch
|
||||
Stretch,
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -12,7 +12,11 @@ namespace Facebook.CSSLayout
|
||||
public enum CSSDirection
|
||||
{
|
||||
Inherit,
|
||||
LeftToRight,
|
||||
RightToLeft
|
||||
LTR,
|
||||
RTL,
|
||||
[System.Obsolete("Use LTR instead")]
|
||||
LeftToRight = LTR,
|
||||
[System.Obsolete("Use RTL instead")]
|
||||
RightToLeft = RTL,
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -12,6 +12,6 @@ namespace Facebook.CSSLayout
|
||||
public enum CSSDimension
|
||||
{
|
||||
Width,
|
||||
Height
|
||||
Height,
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -20,6 +20,5 @@ namespace Facebook.CSSLayout
|
||||
Horizontal,
|
||||
Vertical,
|
||||
All,
|
||||
Count,
|
||||
}
|
||||
}
|
||||
|
15
csharp/Facebook.CSSLayout/CSSExperimentalFeature.cs
Normal file
15
csharp/Facebook.CSSLayout/CSSExperimentalFeature.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
{
|
||||
public enum CSSExperimentalFeature
|
||||
{
|
||||
}
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -14,6 +14,5 @@ namespace Facebook.CSSLayout
|
||||
Undefined,
|
||||
Exactly,
|
||||
AtMost,
|
||||
Count,
|
||||
}
|
||||
}
|
||||
|
234
csharp/Facebook.CSSLayout/CSSNode.Create.cs
Normal file
234
csharp/Facebook.CSSLayout/CSSNode.Create.cs
Normal file
@@ -0,0 +1,234 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
{
|
||||
public partial class CSSNode
|
||||
{
|
||||
public static CSSNode Create(
|
||||
CSSDirection? styleDirection = null,
|
||||
CSSFlexDirection? flexDirection = null,
|
||||
CSSJustify? justifyContent = null,
|
||||
CSSAlign? alignContent = null,
|
||||
CSSAlign? alignItems = null,
|
||||
CSSAlign? alignSelf = null,
|
||||
CSSPositionType? positionType = null,
|
||||
CSSWrap? wrap = null,
|
||||
CSSOverflow? overflow = null,
|
||||
float? flex = null,
|
||||
float? flexGrow = null,
|
||||
float? flexShrink = null,
|
||||
float? flexBasis = null,
|
||||
Spacing position = null,
|
||||
Spacing margin = null,
|
||||
Spacing padding = null,
|
||||
Spacing border = null,
|
||||
float? styleWidth = null,
|
||||
float? styleHeight = null,
|
||||
float? styleMaxWidth = null,
|
||||
float? styleMaxHeight = null,
|
||||
float? styleMinWidth = null,
|
||||
float? styleMinHeight = null)
|
||||
{
|
||||
CSSNode node = new CSSNode();
|
||||
|
||||
if (styleDirection.HasValue)
|
||||
{
|
||||
node.StyleDirection = styleDirection.Value;
|
||||
}
|
||||
|
||||
if (flexDirection.HasValue)
|
||||
{
|
||||
node.FlexDirection = flexDirection.Value;
|
||||
}
|
||||
|
||||
if (justifyContent.HasValue)
|
||||
{
|
||||
node.JustifyContent = justifyContent.Value;
|
||||
}
|
||||
|
||||
if (alignContent.HasValue)
|
||||
{
|
||||
node.AlignContent = alignContent.Value;
|
||||
}
|
||||
|
||||
if (alignItems.HasValue)
|
||||
{
|
||||
node.AlignItems = alignItems.Value;
|
||||
}
|
||||
|
||||
if (alignSelf.HasValue)
|
||||
{
|
||||
node.AlignSelf = alignSelf.Value;
|
||||
}
|
||||
|
||||
if (positionType.HasValue)
|
||||
{
|
||||
node.PositionType = positionType.Value;
|
||||
}
|
||||
|
||||
if (wrap.HasValue)
|
||||
{
|
||||
node.Wrap = wrap.Value;
|
||||
}
|
||||
|
||||
if (overflow.HasValue)
|
||||
{
|
||||
node.Overflow = overflow.Value;
|
||||
}
|
||||
|
||||
if (flex.HasValue)
|
||||
{
|
||||
node.Flex = flex.Value;
|
||||
}
|
||||
|
||||
if (flexGrow.HasValue)
|
||||
{
|
||||
node.FlexGrow = flexGrow.Value;
|
||||
}
|
||||
|
||||
if (flexShrink.HasValue)
|
||||
{
|
||||
node.FlexShrink = flexShrink.Value;
|
||||
}
|
||||
|
||||
if (flexBasis.HasValue)
|
||||
{
|
||||
node.FlexBasis = flexBasis.Value;
|
||||
}
|
||||
|
||||
if (position != null)
|
||||
{
|
||||
if (position.Top.HasValue)
|
||||
{
|
||||
node.SetPosition(CSSEdge.Top, position.Top.Value);
|
||||
}
|
||||
|
||||
if (position.Bottom.HasValue)
|
||||
{
|
||||
node.SetPosition(CSSEdge.Bottom, position.Bottom.Value);
|
||||
}
|
||||
|
||||
if (position.Left.HasValue)
|
||||
{
|
||||
node.SetPosition(CSSEdge.Left, position.Left.Value);
|
||||
}
|
||||
|
||||
if (position.Right.HasValue)
|
||||
{
|
||||
node.SetPosition(CSSEdge.Right, position.Right.Value);
|
||||
}
|
||||
}
|
||||
|
||||
if (margin != null)
|
||||
{
|
||||
if (margin.Top.HasValue)
|
||||
{
|
||||
node.SetMargin(CSSEdge.Top, margin.Top.Value);
|
||||
}
|
||||
|
||||
if (margin.Bottom.HasValue)
|
||||
{
|
||||
node.SetMargin(CSSEdge.Bottom, margin.Bottom.Value);
|
||||
}
|
||||
|
||||
if (margin.Left.HasValue)
|
||||
{
|
||||
node.SetMargin(CSSEdge.Left, margin.Left.Value);
|
||||
}
|
||||
|
||||
if (margin.Right.HasValue)
|
||||
{
|
||||
node.SetMargin(CSSEdge.Right, margin.Right.Value);
|
||||
}
|
||||
}
|
||||
|
||||
if (padding != null)
|
||||
{
|
||||
if (padding.Top.HasValue)
|
||||
{
|
||||
node.SetPadding(CSSEdge.Top, padding.Top.Value);
|
||||
}
|
||||
|
||||
if (padding.Bottom.HasValue)
|
||||
{
|
||||
node.SetPadding(CSSEdge.Bottom, padding.Bottom.Value);
|
||||
}
|
||||
|
||||
if (padding.Left.HasValue)
|
||||
{
|
||||
node.SetPadding(CSSEdge.Left, padding.Left.Value);
|
||||
}
|
||||
|
||||
if (padding.Right.HasValue)
|
||||
{
|
||||
node.SetPadding(CSSEdge.Right, padding.Right.Value);
|
||||
}
|
||||
}
|
||||
|
||||
if (border != null)
|
||||
{
|
||||
if (border.Top.HasValue)
|
||||
{
|
||||
node.SetBorder(CSSEdge.Top, border.Top.Value);
|
||||
}
|
||||
|
||||
if (border.Bottom.HasValue)
|
||||
{
|
||||
node.SetBorder(CSSEdge.Bottom, border.Bottom.Value);
|
||||
}
|
||||
|
||||
if (border.Left.HasValue)
|
||||
{
|
||||
node.SetBorder(CSSEdge.Left, border.Left.Value);
|
||||
}
|
||||
|
||||
if (border.Right.HasValue)
|
||||
{
|
||||
node.SetBorder(CSSEdge.Right, border.Right.Value);
|
||||
}
|
||||
}
|
||||
|
||||
if (styleWidth.HasValue)
|
||||
{
|
||||
node.StyleWidth = styleWidth.Value;
|
||||
}
|
||||
|
||||
if (styleHeight.HasValue)
|
||||
{
|
||||
node.StyleHeight = styleHeight.Value;
|
||||
}
|
||||
|
||||
if (styleMinWidth.HasValue)
|
||||
{
|
||||
node.StyleMinWidth = styleMinWidth.Value;
|
||||
}
|
||||
|
||||
if (styleMinHeight.HasValue)
|
||||
{
|
||||
node.StyleMinHeight = styleMinHeight.Value;
|
||||
}
|
||||
|
||||
if (styleMaxWidth.HasValue)
|
||||
{
|
||||
node.StyleMaxWidth = styleMaxWidth.Value;
|
||||
}
|
||||
|
||||
if (styleMaxHeight.HasValue)
|
||||
{
|
||||
node.StyleMaxHeight = styleMaxHeight.Value;
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -15,7 +15,7 @@ using System.Text;
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
{
|
||||
public class CSSNode : IEnumerable<CSSNode>
|
||||
public partial class CSSNode : IEnumerable<CSSNode>
|
||||
{
|
||||
private IntPtr _cssNode;
|
||||
private WeakReference _parent;
|
||||
@@ -90,6 +90,11 @@ namespace Facebook.CSSLayout
|
||||
}
|
||||
}
|
||||
|
||||
public void CopyStyle(CSSNode srcNode)
|
||||
{
|
||||
Native.CSSNodeCopyStyle(_cssNode, srcNode._cssNode);
|
||||
}
|
||||
|
||||
public CSSDirection StyleDirection
|
||||
{
|
||||
get
|
||||
@@ -550,5 +555,17 @@ namespace Facebook.CSSLayout
|
||||
{
|
||||
return Native.CSSNodeGetInstanceCount();
|
||||
}
|
||||
|
||||
public static void setExperimentalFeatureEnabled(
|
||||
CSSExperimentalFeature feature,
|
||||
bool enabled)
|
||||
{
|
||||
Native.CSSLayoutSetExperimentalFeatureEnabled(feature, enabled);
|
||||
}
|
||||
|
||||
public static bool isExperimentalFeatureEnabled(CSSExperimentalFeature feature)
|
||||
{
|
||||
return Native.CSSLayoutIsExperimentalFeatureEnabled(feature);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -13,5 +13,6 @@ namespace Facebook.CSSLayout
|
||||
{
|
||||
Visible,
|
||||
Hidden,
|
||||
Scroll,
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -12,6 +12,6 @@ namespace Facebook.CSSLayout
|
||||
public enum CSSPositionType
|
||||
{
|
||||
Relative,
|
||||
Absolute
|
||||
Absolute,
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
|
@@ -18,7 +18,7 @@ namespace Facebook.CSSLayout
|
||||
|
||||
public static long Make(int width, int height)
|
||||
{
|
||||
return (long)(((ulong) width) << 32 | ((ulong) height));
|
||||
return (long)(((ulong) width) << 32 | ((uint) height));
|
||||
}
|
||||
|
||||
public static int GetWidth(long measureOutput)
|
||||
|
@@ -39,6 +39,15 @@ namespace Facebook.CSSLayout
|
||||
[DllImport(DllName)]
|
||||
public static extern int CSSNodeGetInstanceCount();
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void CSSLayoutSetExperimentalFeatureEnabled(
|
||||
CSSExperimentalFeature feature,
|
||||
bool enabled);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern bool CSSLayoutIsExperimentalFeatureEnabled(
|
||||
CSSExperimentalFeature feature);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void CSSNodeInsertChild(IntPtr node, IntPtr child, uint index);
|
||||
|
||||
@@ -71,6 +80,9 @@ namespace Facebook.CSSLayout
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool CSSValueIsUndefined(float value);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void CSSNodeCopyStyle(IntPtr dstNode, IntPtr srcNode);
|
||||
|
||||
#region CSS_NODE_PROPERTY
|
||||
|
||||
[DllImport(DllName)]
|
||||
|
31
csharp/Facebook.CSSLayout/Spacing.cs
Normal file
31
csharp/Facebook.CSSLayout/Spacing.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
{
|
||||
public class Spacing
|
||||
{
|
||||
public float? Top;
|
||||
public float? Bottom;
|
||||
public float? Left;
|
||||
public float? Right;
|
||||
|
||||
public Spacing(
|
||||
float? top = null,
|
||||
float? bottom = null,
|
||||
float? left = null,
|
||||
float? right = null)
|
||||
{
|
||||
Top = top;
|
||||
Bottom = bottom;
|
||||
Left = left;
|
||||
Right = right;
|
||||
}
|
||||
}
|
||||
}
|
@@ -61,7 +61,7 @@ namespace Facebook.CSSLayout
|
||||
root_child0.StyleWidth = 10;
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -74,7 +74,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -102,7 +102,7 @@ namespace Facebook.CSSLayout
|
||||
root_child0.StyleWidth = 10;
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -115,7 +115,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -143,7 +143,7 @@ namespace Facebook.CSSLayout
|
||||
root_child0.SetPosition(CSSEdge.End, 10);
|
||||
root_child0.SetPosition(CSSEdge.Bottom, 10);
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -156,7 +156,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(80, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(80, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -186,7 +186,7 @@ namespace Facebook.CSSLayout
|
||||
root_child0.StyleWidth = 10;
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -199,7 +199,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -232,7 +232,7 @@ namespace Facebook.CSSLayout
|
||||
root_child0_child0.StyleWidth = 100;
|
||||
root_child0_child0.StyleHeight = 100;
|
||||
root_child0.Insert(0, root_child0_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -250,7 +250,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(100, root_child0_child0.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child0_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -303,7 +303,7 @@ namespace Facebook.CSSLayout
|
||||
root_child1.StyleWidth = 50;
|
||||
root_child1.StyleHeight = 50;
|
||||
root.Insert(1, root_child1);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(10, root.LayoutX);
|
||||
@@ -321,7 +321,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(50, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(50, root_child1.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(10, root.LayoutX);
|
||||
|
@@ -84,7 +84,7 @@ namespace Facebook.CSSLayout
|
||||
root_child4.StyleWidth = 50;
|
||||
root_child4.StyleHeight = 10;
|
||||
root.Insert(4, root_child4);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -117,7 +117,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(50, root_child4.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child4.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -184,7 +184,7 @@ namespace Facebook.CSSLayout
|
||||
root_child4.StyleWidth = 50;
|
||||
root_child4.StyleHeight = 10;
|
||||
root.Insert(4, root_child4);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -217,7 +217,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(50, root_child4.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child4.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -284,7 +284,7 @@ namespace Facebook.CSSLayout
|
||||
root_child4.StyleWidth = 50;
|
||||
root_child4.StyleHeight = 10;
|
||||
root.Insert(4, root_child4);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -317,7 +317,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(50, root_child4.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child4.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -379,7 +379,7 @@ namespace Facebook.CSSLayout
|
||||
CSSNode root_child4 = new CSSNode();
|
||||
root_child4.StyleWidth = 50;
|
||||
root.Insert(4, root_child4);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -412,7 +412,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(50, root_child4.LayoutWidth);
|
||||
Assert.AreEqual(0, root_child4.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
|
@@ -46,7 +46,7 @@ namespace Facebook.CSSLayout
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -59,7 +59,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(100, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -85,7 +85,7 @@ namespace Facebook.CSSLayout
|
||||
root_child0.StyleWidth = 10;
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -98,7 +98,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -124,7 +124,7 @@ namespace Facebook.CSSLayout
|
||||
root_child0.StyleWidth = 10;
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -137,7 +137,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -163,7 +163,7 @@ namespace Facebook.CSSLayout
|
||||
root_child0.StyleWidth = 10;
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -176,7 +176,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
|
@@ -48,7 +48,7 @@ namespace Facebook.CSSLayout
|
||||
root_child0.StyleWidth = 10;
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -61,7 +61,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -87,7 +87,7 @@ namespace Facebook.CSSLayout
|
||||
root_child0.StyleWidth = 10;
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -100,7 +100,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -126,7 +126,7 @@ namespace Facebook.CSSLayout
|
||||
root_child0.StyleWidth = 10;
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -139,7 +139,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -166,7 +166,7 @@ namespace Facebook.CSSLayout
|
||||
root_child0.StyleWidth = 10;
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -179,7 +179,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
|
@@ -47,7 +47,7 @@ namespace Facebook.CSSLayout
|
||||
root.SetBorder(CSSEdge.Top, 10);
|
||||
root.SetBorder(CSSEdge.Right, 10);
|
||||
root.SetBorder(CSSEdge.Bottom, 10);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -55,7 +55,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(20, root.LayoutWidth);
|
||||
Assert.AreEqual(20, root.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -77,7 +77,7 @@ namespace Facebook.CSSLayout
|
||||
root_child0.StyleWidth = 10;
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -90,7 +90,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -119,7 +119,7 @@ namespace Facebook.CSSLayout
|
||||
root_child0.FlexGrow = 1;
|
||||
root_child0.StyleWidth = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -132,7 +132,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(80, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -160,7 +160,7 @@ namespace Facebook.CSSLayout
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -173,7 +173,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(80, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -203,7 +203,7 @@ namespace Facebook.CSSLayout
|
||||
root_child0.StyleWidth = 10;
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -216,7 +216,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
|
@@ -73,7 +73,7 @@ namespace Facebook.CSSLayout
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleHeight = 10;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -96,7 +96,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(100, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -138,7 +138,7 @@ namespace Facebook.CSSLayout
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 10;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -161,7 +161,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -203,7 +203,7 @@ namespace Facebook.CSSLayout
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleHeight = 10;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -226,7 +226,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(100, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -269,7 +269,7 @@ namespace Facebook.CSSLayout
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 10;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -292,7 +292,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -335,7 +335,7 @@ namespace Facebook.CSSLayout
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleHeight = 10;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -358,7 +358,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(100, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -401,7 +401,7 @@ namespace Facebook.CSSLayout
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 10;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -424,7 +424,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
|
@@ -73,7 +73,7 @@ namespace Facebook.CSSLayout
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.FlexGrow = 1;
|
||||
root.Insert(1, root_child1);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -91,7 +91,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(100, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(25, root_child1.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -126,7 +126,7 @@ namespace Facebook.CSSLayout
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.FlexGrow = 1;
|
||||
root.Insert(1, root_child1);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -144,7 +144,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(25, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child1.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -178,7 +178,7 @@ namespace Facebook.CSSLayout
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.FlexBasis = 50;
|
||||
root.Insert(1, root_child1);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -196,7 +196,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(100, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(50, root_child1.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -231,7 +231,7 @@ namespace Facebook.CSSLayout
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.FlexBasis = 50;
|
||||
root.Insert(1, root_child1);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -249,7 +249,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(50, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child1.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -289,7 +289,7 @@ namespace Facebook.CSSLayout
|
||||
root_child2.StyleWidth = 50;
|
||||
root_child2.StyleHeight = 50;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -312,7 +312,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(50, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(50, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -358,7 +358,7 @@ namespace Facebook.CSSLayout
|
||||
root_child2.FlexGrow = 1;
|
||||
root_child2.StyleHeight = 10;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -381,7 +381,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(100, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(20, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -419,7 +419,7 @@ namespace Facebook.CSSLayout
|
||||
root_child0_child0.FlexGrow = 1;
|
||||
root_child0_child0.FlexShrink = 1;
|
||||
root_child0.Insert(0, root_child0_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -437,7 +437,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(100, root_child0_child0.LayoutWidth);
|
||||
Assert.AreEqual(0, root_child0_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
|
@@ -74,7 +74,7 @@ namespace Facebook.CSSLayout
|
||||
root_child3.StyleWidth = 30;
|
||||
root_child3.StyleHeight = 30;
|
||||
root.Insert(3, root_child3);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -102,7 +102,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(30, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(30, root_child3.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -158,7 +158,7 @@ namespace Facebook.CSSLayout
|
||||
root_child3.StyleWidth = 30;
|
||||
root_child3.StyleHeight = 30;
|
||||
root.Insert(3, root_child3);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -186,7 +186,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(30, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(30, root_child3.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -243,7 +243,7 @@ namespace Facebook.CSSLayout
|
||||
root_child3.StyleWidth = 30;
|
||||
root_child3.StyleHeight = 30;
|
||||
root.Insert(3, root_child3);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -271,7 +271,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(30, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(30, root_child3.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -328,7 +328,7 @@ namespace Facebook.CSSLayout
|
||||
root_child3.StyleWidth = 30;
|
||||
root_child3.StyleHeight = 30;
|
||||
root.Insert(3, root_child3);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -356,7 +356,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(30, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(30, root_child3.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
|
@@ -99,7 +99,7 @@ namespace Facebook.CSSLayout
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 10;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -122,7 +122,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(102, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -166,7 +166,7 @@ namespace Facebook.CSSLayout
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 10;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -189,7 +189,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(102, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -233,7 +233,7 @@ namespace Facebook.CSSLayout
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 10;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -256,7 +256,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(102, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -300,7 +300,7 @@ namespace Facebook.CSSLayout
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 10;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -323,7 +323,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(102, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -367,7 +367,7 @@ namespace Facebook.CSSLayout
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 10;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -390,7 +390,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(102, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -431,7 +431,7 @@ namespace Facebook.CSSLayout
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleHeight = 10;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -454,7 +454,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(102, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -497,7 +497,7 @@ namespace Facebook.CSSLayout
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleHeight = 10;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -520,7 +520,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(102, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -563,7 +563,7 @@ namespace Facebook.CSSLayout
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleHeight = 10;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -586,7 +586,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(102, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -629,7 +629,7 @@ namespace Facebook.CSSLayout
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleHeight = 10;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -652,7 +652,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(102, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -695,7 +695,7 @@ namespace Facebook.CSSLayout
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleHeight = 10;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -718,7 +718,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(102, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
|
@@ -74,7 +74,7 @@ namespace Facebook.CSSLayout
|
||||
root_child0.SetMargin(CSSEdge.Start, 10);
|
||||
root_child0.StyleWidth = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -87,7 +87,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -112,7 +112,7 @@ namespace Facebook.CSSLayout
|
||||
root_child0.SetMargin(CSSEdge.Top, 10);
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -125,7 +125,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(100, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -152,7 +152,7 @@ namespace Facebook.CSSLayout
|
||||
root_child0.SetMargin(CSSEdge.End, 10);
|
||||
root_child0.StyleWidth = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -165,7 +165,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -191,7 +191,7 @@ namespace Facebook.CSSLayout
|
||||
root_child0.SetMargin(CSSEdge.Bottom, 10);
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -204,7 +204,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(100, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -230,7 +230,7 @@ namespace Facebook.CSSLayout
|
||||
root_child0.FlexGrow = 1;
|
||||
root_child0.SetMargin(CSSEdge.Start, 10);
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -243,7 +243,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(90, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -268,7 +268,7 @@ namespace Facebook.CSSLayout
|
||||
root_child0.FlexGrow = 1;
|
||||
root_child0.SetMargin(CSSEdge.Top, 10);
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -281,7 +281,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(100, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(90, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -307,7 +307,7 @@ namespace Facebook.CSSLayout
|
||||
root_child0.FlexGrow = 1;
|
||||
root_child0.SetMargin(CSSEdge.Top, 10);
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -320,7 +320,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(100, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(90, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -345,7 +345,7 @@ namespace Facebook.CSSLayout
|
||||
root_child0.FlexGrow = 1;
|
||||
root_child0.SetMargin(CSSEdge.Start, 10);
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -358,7 +358,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(90, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -387,7 +387,7 @@ namespace Facebook.CSSLayout
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.FlexGrow = 1;
|
||||
root.Insert(1, root_child1);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -405,7 +405,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(50, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child1.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -438,7 +438,7 @@ namespace Facebook.CSSLayout
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.FlexGrow = 1;
|
||||
root.Insert(1, root_child1);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -456,7 +456,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(100, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(50, root_child1.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
|
@@ -75,7 +75,7 @@ namespace Facebook.CSSLayout
|
||||
root_child0.StyleMaxWidth = 50;
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -88,7 +88,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(50, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -114,7 +114,7 @@ namespace Facebook.CSSLayout
|
||||
root_child0.StyleWidth = 10;
|
||||
root_child0.StyleMaxHeight = 50;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -127,7 +127,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(50, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -156,7 +156,7 @@ namespace Facebook.CSSLayout
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.FlexGrow = 1;
|
||||
root.Insert(1, root_child1);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -174,7 +174,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(100, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(20, root_child1.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -209,7 +209,7 @@ namespace Facebook.CSSLayout
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.FlexGrow = 1;
|
||||
root.Insert(1, root_child1);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -227,7 +227,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(20, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(100, root_child1.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -259,7 +259,7 @@ namespace Facebook.CSSLayout
|
||||
root_child0.StyleWidth = 60;
|
||||
root_child0.StyleHeight = 60;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -272,7 +272,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(60, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(60, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -299,7 +299,7 @@ namespace Facebook.CSSLayout
|
||||
root_child0.StyleWidth = 60;
|
||||
root_child0.StyleHeight = 60;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -312,7 +312,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(60, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(60, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -348,7 +348,7 @@ namespace Facebook.CSSLayout
|
||||
root_child2.StyleWidth = 50;
|
||||
root_child2.StyleHeight = 50;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -371,7 +371,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(50, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(50, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -411,7 +411,7 @@ namespace Facebook.CSSLayout
|
||||
root_child0_child0.FlexGrow = 1;
|
||||
root_child0_child0.StyleHeight = 20;
|
||||
root_child0.Insert(0, root_child0_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -429,7 +429,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(100, root_child0_child0.LayoutWidth);
|
||||
Assert.AreEqual(20, root_child0_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -464,7 +464,7 @@ namespace Facebook.CSSLayout
|
||||
root_child0_child0.FlexGrow = 1;
|
||||
root_child0_child0.StyleHeight = 20;
|
||||
root_child0.Insert(0, root_child0_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -482,7 +482,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(200, root_child0_child0.LayoutWidth);
|
||||
Assert.AreEqual(20, root_child0_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
|
@@ -47,7 +47,7 @@ namespace Facebook.CSSLayout
|
||||
root.SetPadding(CSSEdge.Top, 10);
|
||||
root.SetPadding(CSSEdge.Right, 10);
|
||||
root.SetPadding(CSSEdge.Bottom, 10);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -55,7 +55,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(20, root.LayoutWidth);
|
||||
Assert.AreEqual(20, root.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -77,7 +77,7 @@ namespace Facebook.CSSLayout
|
||||
root_child0.StyleWidth = 10;
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -90,7 +90,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -119,7 +119,7 @@ namespace Facebook.CSSLayout
|
||||
root_child0.FlexGrow = 1;
|
||||
root_child0.StyleWidth = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -132,7 +132,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(80, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -160,7 +160,7 @@ namespace Facebook.CSSLayout
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -173,7 +173,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(80, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -203,7 +203,7 @@ namespace Facebook.CSSLayout
|
||||
root_child0.StyleWidth = 10;
|
||||
root_child0.StyleHeight = 10;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LeftToRight;
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
@@ -216,7 +216,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RightToLeft;
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0, root.LayoutX);
|
||||
|
143
csharp/tests/Facebook.CSSLayout/CSSNodeCreateTest.cs
Normal file
143
csharp/tests/Facebook.CSSLayout/CSSNodeCreateTest.cs
Normal file
@@ -0,0 +1,143 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
|
||||
/**
|
||||
* Tests for {@link CSSNode}.
|
||||
*/
|
||||
namespace Facebook.CSSLayout
|
||||
{
|
||||
[TestFixture]
|
||||
public class CSSNodeCreateTest
|
||||
{
|
||||
[Test]
|
||||
public void TestSimple()
|
||||
{
|
||||
CSSNode nodeDefault = new CSSNode();
|
||||
CSSNode nodeCreated = CSSNode.Create(flexDirection: CSSFlexDirection.Row);
|
||||
Assert.AreEqual(CSSFlexDirection.Row, nodeCreated.FlexDirection);
|
||||
Assert.IsFalse(nodeDefault.IsDirty);
|
||||
nodeDefault.CopyStyle(nodeCreated);
|
||||
Assert.IsTrue(nodeDefault.IsDirty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSame()
|
||||
{
|
||||
CSSNode nodeDefault = new CSSNode();
|
||||
CSSNode nodeCreated = CSSNode.Create();
|
||||
Assert.IsFalse(nodeDefault.IsDirty);
|
||||
nodeDefault.CopyStyle(nodeCreated);
|
||||
Assert.IsFalse(nodeDefault.IsDirty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMultiple()
|
||||
{
|
||||
CSSNode node = CSSNode.Create(
|
||||
positionType: CSSPositionType.Absolute,
|
||||
wrap: CSSWrap.Wrap,
|
||||
position: new Spacing(top:6, right:4),
|
||||
margin: new Spacing(bottom:5, left:3));
|
||||
|
||||
Assert.AreEqual(CSSFlexDirection.Column, node.FlexDirection);
|
||||
Assert.AreEqual(CSSPositionType.Absolute, node.PositionType);
|
||||
Assert.AreEqual(CSSWrap.Wrap, node.Wrap);
|
||||
Assert.AreEqual(6, node.GetPosition(CSSEdge.Top));
|
||||
Assert.IsTrue(CSSConstants.IsUndefined(node.GetPosition(CSSEdge.Bottom)));
|
||||
Assert.AreEqual(4, node.GetPosition(CSSEdge.Right));
|
||||
Assert.IsTrue(CSSConstants.IsUndefined(node.GetPosition(CSSEdge.Left)));
|
||||
Assert.AreEqual(0, node.GetMargin(CSSEdge.Top));
|
||||
Assert.AreEqual(5, node.GetMargin(CSSEdge.Bottom));
|
||||
Assert.AreEqual(3, node.GetMargin(CSSEdge.Left));
|
||||
Assert.AreEqual(0, node.GetMargin(CSSEdge.Right));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestFull()
|
||||
{
|
||||
CSSNode node = CSSNode.Create(
|
||||
styleDirection: CSSDirection.RTL,
|
||||
flexDirection: CSSFlexDirection.RowReverse,
|
||||
|
||||
justifyContent: CSSJustify.SpaceAround,
|
||||
alignContent: CSSAlign.Center,
|
||||
alignItems: CSSAlign.FlexEnd,
|
||||
alignSelf: CSSAlign.Stretch,
|
||||
|
||||
positionType: CSSPositionType.Absolute,
|
||||
wrap: CSSWrap.Wrap,
|
||||
overflow: CSSOverflow.Scroll,
|
||||
|
||||
flex: 1,
|
||||
flexGrow: 2,
|
||||
flexShrink: 3,
|
||||
flexBasis: 4,
|
||||
|
||||
position: new Spacing(top: 5, bottom: 6, left: 7, right: 8),
|
||||
margin: new Spacing(top: 9, bottom: 10, left: 11, right: 12),
|
||||
padding: new Spacing(top: 13, bottom: 14, left: 15, right: 16),
|
||||
border: new Spacing(top: 17, bottom: 18, left: 19, right: 20),
|
||||
|
||||
styleWidth: 21,
|
||||
styleHeight: 22,
|
||||
styleMinWidth: 23,
|
||||
styleMinHeight: 24,
|
||||
styleMaxWidth: 25,
|
||||
styleMaxHeight: 26);
|
||||
|
||||
Assert.AreEqual(CSSDirection.RTL, node.StyleDirection);
|
||||
Assert.AreEqual(CSSFlexDirection.RowReverse, node.FlexDirection);
|
||||
|
||||
Assert.AreEqual(CSSJustify.SpaceAround, node.JustifyContent);
|
||||
Assert.AreEqual(CSSAlign.Center, node.AlignContent);
|
||||
Assert.AreEqual(CSSAlign.FlexEnd, node.AlignItems);
|
||||
Assert.AreEqual(CSSAlign.Stretch, node.AlignSelf);
|
||||
|
||||
Assert.AreEqual(CSSPositionType.Absolute, node.PositionType);
|
||||
Assert.AreEqual(CSSWrap.Wrap, node.Wrap);
|
||||
Assert.AreEqual(CSSOverflow.Scroll, node.Overflow);
|
||||
|
||||
Assert.AreEqual(2, node.FlexGrow);
|
||||
Assert.AreEqual(3, node.FlexShrink);
|
||||
Assert.AreEqual(4, node.FlexBasis);
|
||||
node.FlexGrow = CSSConstants.Undefined;
|
||||
Assert.AreEqual(1, node.FlexGrow);
|
||||
|
||||
Assert.AreEqual(5, node.GetPosition(CSSEdge.Top));
|
||||
Assert.AreEqual(6, node.GetPosition(CSSEdge.Bottom));
|
||||
Assert.AreEqual(7, node.GetPosition(CSSEdge.Left));
|
||||
Assert.AreEqual(8, node.GetPosition(CSSEdge.Right));
|
||||
|
||||
Assert.AreEqual(9, node.GetMargin(CSSEdge.Top));
|
||||
Assert.AreEqual(10, node.GetMargin(CSSEdge.Bottom));
|
||||
Assert.AreEqual(11, node.GetMargin(CSSEdge.Left));
|
||||
Assert.AreEqual(12, node.GetMargin(CSSEdge.Right));
|
||||
|
||||
Assert.AreEqual(13, node.GetPadding(CSSEdge.Top));
|
||||
Assert.AreEqual(14, node.GetPadding(CSSEdge.Bottom));
|
||||
Assert.AreEqual(15, node.GetPadding(CSSEdge.Left));
|
||||
Assert.AreEqual(16, node.GetPadding(CSSEdge.Right));
|
||||
|
||||
Assert.AreEqual(17, node.GetBorder(CSSEdge.Top));
|
||||
Assert.AreEqual(18, node.GetBorder(CSSEdge.Bottom));
|
||||
Assert.AreEqual(19, node.GetBorder(CSSEdge.Left));
|
||||
Assert.AreEqual(20, node.GetBorder(CSSEdge.Right));
|
||||
|
||||
Assert.AreEqual(21, node.StyleWidth);
|
||||
Assert.AreEqual(22, node.StyleHeight);
|
||||
Assert.AreEqual(23, node.StyleMinWidth);
|
||||
Assert.AreEqual(24, node.StyleMinHeight);
|
||||
Assert.AreEqual(25, node.StyleMaxWidth);
|
||||
Assert.AreEqual(26, node.StyleMaxHeight);
|
||||
}
|
||||
}
|
||||
}
|
@@ -215,13 +215,26 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(parent.Print(), "{layout: {width: 100, height: 120, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 100, height: 120, children: [\n {layout: {width: 35, height: 45, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 35, height: 45, },\n {layout: {width: 30, height: 40, top: 45, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 30, height: 40, },\n]},\n");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCopyStyle()
|
||||
{
|
||||
CSSNode node0 = new CSSNode();
|
||||
Assert.IsTrue(CSSConstants.IsUndefined(node0.StyleMaxHeight));
|
||||
|
||||
CSSNode node1 = new CSSNode();
|
||||
node1.StyleMaxHeight = 100;
|
||||
|
||||
node0.CopyStyle(node1);
|
||||
Assert.AreEqual(100, node0.StyleMaxHeight);
|
||||
}
|
||||
|
||||
#if !UNITY_EDITOR
|
||||
private void ForceGC()
|
||||
{
|
||||
GC.Collect(GC.MaxGeneration);
|
||||
GC.WaitForPendingFinalizers();
|
||||
}
|
||||
|
||||
#if !UNITY_EDITOR
|
||||
[Test]
|
||||
public void TestDestructor()
|
||||
{
|
||||
|
182
enums.py
Normal file
182
enums.py
Normal file
@@ -0,0 +1,182 @@
|
||||
# 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.
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
import os
|
||||
|
||||
ENUMS = {
|
||||
'CSSDirection': [
|
||||
'Inherit',
|
||||
'LTR',
|
||||
'RTL',
|
||||
],
|
||||
'CSSFlexDirection': [
|
||||
'Column',
|
||||
'ColumnReverse',
|
||||
'Row',
|
||||
'RowReverse',
|
||||
],
|
||||
'CSSJustify': [
|
||||
'FlexStart',
|
||||
'Center',
|
||||
'FlexEnd',
|
||||
'SpaceBetween',
|
||||
'SpaceAround',
|
||||
],
|
||||
'CSSOverflow': [
|
||||
'Visible',
|
||||
'Hidden',
|
||||
'Scroll',
|
||||
],
|
||||
'CSSAlign': [
|
||||
'Auto',
|
||||
'FlexStart',
|
||||
'Center',
|
||||
'FlexEnd',
|
||||
'Stretch',
|
||||
],
|
||||
'CSSPositionType': [
|
||||
'Relative',
|
||||
'Absolute',
|
||||
],
|
||||
'CSSWrap': [
|
||||
'NoWrap',
|
||||
'Wrap',
|
||||
],
|
||||
'CSSMeasureMode': [
|
||||
'Undefined',
|
||||
'Exactly',
|
||||
'AtMost',
|
||||
],
|
||||
'CSSDimension': [
|
||||
'Width',
|
||||
'Height',
|
||||
],
|
||||
'CSSEdge': [
|
||||
'Left',
|
||||
'Top',
|
||||
'Right',
|
||||
'Bottom',
|
||||
'Start',
|
||||
'End',
|
||||
'Horizontal',
|
||||
'Vertical',
|
||||
'All',
|
||||
],
|
||||
'CSSLogLevel': [
|
||||
'Error',
|
||||
'Warn',
|
||||
'Info',
|
||||
'Debug',
|
||||
'Verbose',
|
||||
],
|
||||
'CSSExperimentalFeature': [],
|
||||
'CSSPrintOptions': [
|
||||
('Layout', 1),
|
||||
('Style', 2),
|
||||
('Children', 4),
|
||||
],
|
||||
}
|
||||
|
||||
LICENSE = """/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
"""
|
||||
|
||||
def to_java_upper(symbol):
|
||||
symbol = str(symbol)
|
||||
out = ''
|
||||
for i in range(0, len(symbol)):
|
||||
c = symbol[i]
|
||||
if str.istitle(c) and i is not 0 and not str.istitle(symbol[i - 1]):
|
||||
out += '_'
|
||||
out += c.upper()
|
||||
return out
|
||||
|
||||
|
||||
root = os.path.dirname(__file__)
|
||||
|
||||
# write out C header
|
||||
with open(root + '/CSSLayout/CSSEnums.h', 'w') as f:
|
||||
f.write(LICENSE)
|
||||
remaining = len(ENUMS)
|
||||
for name, values in ENUMS.items():
|
||||
f.write('typedef enum %s {\n' % name)
|
||||
for value in values:
|
||||
if isinstance(value, tuple):
|
||||
f.write(' %s%s = %d,\n' % (name, value[0], value[1]))
|
||||
else:
|
||||
f.write(' %s%s,\n' % (name, value))
|
||||
f.write(' %sCount,\n' % name)
|
||||
f.write('} %s;\n' % name)
|
||||
if remaining > 1:
|
||||
f.write('\n')
|
||||
remaining = remaining - 1
|
||||
|
||||
# write out java files
|
||||
for name, values in ENUMS.items():
|
||||
with open(root + '/java/com/facebook/csslayout/%s.java' % name, 'w') as f:
|
||||
f.write(LICENSE)
|
||||
f.write('package com.facebook.csslayout;\n\n')
|
||||
f.write('public enum %s {\n' % name)
|
||||
if len(values) > 0:
|
||||
for value in values:
|
||||
if isinstance(value, tuple):
|
||||
f.write(' %s(%d)' % (to_java_upper(value[0]), value[1]))
|
||||
else:
|
||||
f.write(' %s(%d)' % (to_java_upper(value), values.index(value)))
|
||||
if values.index(value) is len(values) - 1:
|
||||
f.write(';\n')
|
||||
else:
|
||||
f.write(',\n')
|
||||
else:
|
||||
f.write('__EMPTY(-1);')
|
||||
f.write('\n')
|
||||
f.write(' private int mIntValue;\n')
|
||||
f.write('\n')
|
||||
f.write(' %s(int intValue) {\n' % name)
|
||||
f.write(' mIntValue = intValue;\n')
|
||||
f.write(' }\n')
|
||||
f.write('\n')
|
||||
f.write(' public int intValue() {\n')
|
||||
f.write(' return mIntValue;\n')
|
||||
f.write(' }\n')
|
||||
f.write('\n')
|
||||
f.write(' public static %s fromInt(int value) {\n' % name)
|
||||
f.write(' switch (value) {\n')
|
||||
for value in values:
|
||||
if isinstance(value, tuple):
|
||||
f.write(' case %d: return %s;\n' % (value[1], to_java_upper(value[0])))
|
||||
else:
|
||||
f.write(' case %d: return %s;\n' % (values.index(value), to_java_upper(value)))
|
||||
f.write(' default: throw new IllegalArgumentException("Unkown enum value: " + value);\n')
|
||||
f.write(' }\n')
|
||||
f.write(' }\n')
|
||||
f.write('}\n')
|
||||
|
||||
# write out csharp files
|
||||
for name, values in ENUMS.items():
|
||||
with open(root + '/csharp/Facebook.CSSLayout/%s.cs' % name, 'w') as f:
|
||||
f.write(LICENSE)
|
||||
f.write('namespace Facebook.CSSLayout\n{\n')
|
||||
f.write(' public enum %s\n {\n' % name)
|
||||
for value in values:
|
||||
if isinstance(value, tuple):
|
||||
f.write(' %s = %d,\n' % (value[0], value[1]))
|
||||
else:
|
||||
f.write(' %s,\n' % value)
|
||||
f.write(' }\n')
|
||||
f.write('}\n')
|
@@ -84,8 +84,8 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
|
||||
CSSPositionTypeAbsolute:{value:'CSSPositionTypeAbsolute'},
|
||||
CSSPositionTypeRelative:{value:'CSSPositionTypeRelative'},
|
||||
|
||||
CSSWrapTypeNoWrap:{value:'CSSWrapTypeNoWrap'},
|
||||
CSSWrapTypeWrap:{value:'CSSWrapTypeWrap'},
|
||||
CSSWrapNoWrap:{value:'CSSWrapNoWrap'},
|
||||
CSSWrapWrap:{value:'CSSWrapWrap'},
|
||||
|
||||
CSSUndefined:{value:'CSSUndefined'},
|
||||
|
||||
|
@@ -71,8 +71,8 @@ CSEmitter.prototype = Object.create(Emitter.prototype, {
|
||||
CSSAlignStretch:{value:'CSSAlign.Stretch'},
|
||||
|
||||
CSSDirectionInherit:{value:'CSSDirection.Inherit'},
|
||||
CSSDirectionLTR:{value:'CSSDirection.LeftToRight'},
|
||||
CSSDirectionRTL:{value:'CSSDirection.RightToLeft'},
|
||||
CSSDirectionLTR:{value:'CSSDirection.LTR'},
|
||||
CSSDirectionRTL:{value:'CSSDirection.RTL'},
|
||||
|
||||
CSSEdgeBottom:{value:'CSSEdge.Bottom'},
|
||||
CSSEdgeEnd:{value:'CSSEdge.End'},
|
||||
@@ -100,8 +100,8 @@ CSEmitter.prototype = Object.create(Emitter.prototype, {
|
||||
|
||||
CSSUndefined:{value:'CSSConstants.Undefined'},
|
||||
|
||||
CSSWrapTypeNoWrap:{value:'CSSWrap.NoWrap'},
|
||||
CSSWrapTypeWrap:{value:'CSSWrap.Wrap'},
|
||||
CSSWrapNoWrap:{value:'CSSWrap.NoWrap'},
|
||||
CSSWrapWrap:{value:'CSSWrap.Wrap'},
|
||||
|
||||
CSSNodeCalculateLayout:{value:function(node, dir) {
|
||||
this.push(node + '.StyleDirection = ' + dir + ';');
|
||||
|
@@ -93,8 +93,8 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
|
||||
|
||||
CSSUndefined:{value:'CSSConstants.UNDEFINED'},
|
||||
|
||||
CSSWrapTypeNoWrap:{value:'CSSWrap.NO_WRAP'},
|
||||
CSSWrapTypeWrap:{value:'CSSWrap.WRAP'},
|
||||
CSSWrapNoWrap:{value:'CSSWrap.NO_WRAP'},
|
||||
CSSWrapWrap:{value:'CSSWrap.WRAP'},
|
||||
|
||||
CSSNodeCalculateLayout:{value:function(node, dir) {
|
||||
this.push(node + '.setDirection(' + dir + ');');
|
||||
|
@@ -354,8 +354,8 @@ function overflowValue(e, value) {
|
||||
|
||||
function wrapValue(e, value) {
|
||||
switch (value) {
|
||||
case 'wrap': return e.CSSWrapTypeWrap;
|
||||
case 'nowrap': return e.CSSWrapTypeNoWrap;
|
||||
case 'wrap': return e.CSSWrapWrap;
|
||||
case 'nowrap': return e.CSSWrapNoWrap;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -10,9 +10,30 @@
|
||||
package com.facebook.csslayout;
|
||||
|
||||
public enum CSSAlign {
|
||||
AUTO,
|
||||
FLEX_START,
|
||||
CENTER,
|
||||
FLEX_END,
|
||||
STRETCH,
|
||||
AUTO(0),
|
||||
FLEX_START(1),
|
||||
CENTER(2),
|
||||
FLEX_END(3),
|
||||
STRETCH(4);
|
||||
|
||||
private int mIntValue;
|
||||
|
||||
CSSAlign(int intValue) {
|
||||
mIntValue = intValue;
|
||||
}
|
||||
|
||||
public int intValue() {
|
||||
return mIntValue;
|
||||
}
|
||||
|
||||
public static CSSAlign fromInt(int value) {
|
||||
switch (value) {
|
||||
case 0: return AUTO;
|
||||
case 1: return FLEX_START;
|
||||
case 2: return CENTER;
|
||||
case 3: return FLEX_END;
|
||||
case 4: return STRETCH;
|
||||
default: throw new IllegalArgumentException("Unkown enum value: " + value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
33
java/com/facebook/csslayout/CSSDimension.java
Normal file
33
java/com/facebook/csslayout/CSSDimension.java
Normal 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.
|
||||
*/
|
||||
|
||||
package com.facebook.csslayout;
|
||||
|
||||
public enum CSSDimension {
|
||||
WIDTH(0),
|
||||
HEIGHT(1);
|
||||
|
||||
private int mIntValue;
|
||||
|
||||
CSSDimension(int intValue) {
|
||||
mIntValue = intValue;
|
||||
}
|
||||
|
||||
public int intValue() {
|
||||
return mIntValue;
|
||||
}
|
||||
|
||||
public static CSSDimension fromInt(int value) {
|
||||
switch (value) {
|
||||
case 0: return WIDTH;
|
||||
case 1: return HEIGHT;
|
||||
default: throw new IllegalArgumentException("Unkown enum value: " + value);
|
||||
}
|
||||
}
|
||||
}
|
@@ -10,7 +10,26 @@
|
||||
package com.facebook.csslayout;
|
||||
|
||||
public enum CSSDirection {
|
||||
INHERIT,
|
||||
LTR,
|
||||
RTL,
|
||||
INHERIT(0),
|
||||
LTR(1),
|
||||
RTL(2);
|
||||
|
||||
private int mIntValue;
|
||||
|
||||
CSSDirection(int intValue) {
|
||||
mIntValue = intValue;
|
||||
}
|
||||
|
||||
public int intValue() {
|
||||
return mIntValue;
|
||||
}
|
||||
|
||||
public static CSSDirection fromInt(int value) {
|
||||
switch (value) {
|
||||
case 0: return INHERIT;
|
||||
case 1: return LTR;
|
||||
case 2: return RTL;
|
||||
default: throw new IllegalArgumentException("Unkown enum value: " + value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
47
java/com/facebook/csslayout/CSSEdge.java
Normal file
47
java/com/facebook/csslayout/CSSEdge.java
Normal file
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.facebook.csslayout;
|
||||
|
||||
public enum CSSEdge {
|
||||
LEFT(0),
|
||||
TOP(1),
|
||||
RIGHT(2),
|
||||
BOTTOM(3),
|
||||
START(4),
|
||||
END(5),
|
||||
HORIZONTAL(6),
|
||||
VERTICAL(7),
|
||||
ALL(8);
|
||||
|
||||
private int mIntValue;
|
||||
|
||||
CSSEdge(int intValue) {
|
||||
mIntValue = intValue;
|
||||
}
|
||||
|
||||
public int intValue() {
|
||||
return mIntValue;
|
||||
}
|
||||
|
||||
public static CSSEdge fromInt(int value) {
|
||||
switch (value) {
|
||||
case 0: return LEFT;
|
||||
case 1: return TOP;
|
||||
case 2: return RIGHT;
|
||||
case 3: return BOTTOM;
|
||||
case 4: return START;
|
||||
case 5: return END;
|
||||
case 6: return HORIZONTAL;
|
||||
case 7: return VERTICAL;
|
||||
case 8: return ALL;
|
||||
default: throw new IllegalArgumentException("Unkown enum value: " + value);
|
||||
}
|
||||
}
|
||||
}
|
29
java/com/facebook/csslayout/CSSExperimentalFeature.java
Normal file
29
java/com/facebook/csslayout/CSSExperimentalFeature.java
Normal file
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.facebook.csslayout;
|
||||
|
||||
public enum CSSExperimentalFeature {
|
||||
__EMPTY(-1);
|
||||
private int mIntValue;
|
||||
|
||||
CSSExperimentalFeature(int intValue) {
|
||||
mIntValue = intValue;
|
||||
}
|
||||
|
||||
public int intValue() {
|
||||
return mIntValue;
|
||||
}
|
||||
|
||||
public static CSSExperimentalFeature fromInt(int value) {
|
||||
switch (value) {
|
||||
default: throw new IllegalArgumentException("Unkown enum value: " + value);
|
||||
}
|
||||
}
|
||||
}
|
@@ -10,8 +10,28 @@
|
||||
package com.facebook.csslayout;
|
||||
|
||||
public enum CSSFlexDirection {
|
||||
COLUMN,
|
||||
COLUMN_REVERSE,
|
||||
ROW,
|
||||
ROW_REVERSE
|
||||
COLUMN(0),
|
||||
COLUMN_REVERSE(1),
|
||||
ROW(2),
|
||||
ROW_REVERSE(3);
|
||||
|
||||
private int mIntValue;
|
||||
|
||||
CSSFlexDirection(int intValue) {
|
||||
mIntValue = intValue;
|
||||
}
|
||||
|
||||
public int intValue() {
|
||||
return mIntValue;
|
||||
}
|
||||
|
||||
public static CSSFlexDirection fromInt(int value) {
|
||||
switch (value) {
|
||||
case 0: return COLUMN;
|
||||
case 1: return COLUMN_REVERSE;
|
||||
case 2: return ROW;
|
||||
case 3: return ROW_REVERSE;
|
||||
default: throw new IllegalArgumentException("Unkown enum value: " + value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -10,9 +10,30 @@
|
||||
package com.facebook.csslayout;
|
||||
|
||||
public enum CSSJustify {
|
||||
FLEX_START,
|
||||
CENTER,
|
||||
FLEX_END,
|
||||
SPACE_BETWEEN,
|
||||
SPACE_AROUND,
|
||||
FLEX_START(0),
|
||||
CENTER(1),
|
||||
FLEX_END(2),
|
||||
SPACE_BETWEEN(3),
|
||||
SPACE_AROUND(4);
|
||||
|
||||
private int mIntValue;
|
||||
|
||||
CSSJustify(int intValue) {
|
||||
mIntValue = intValue;
|
||||
}
|
||||
|
||||
public int intValue() {
|
||||
return mIntValue;
|
||||
}
|
||||
|
||||
public static CSSJustify fromInt(int value) {
|
||||
switch (value) {
|
||||
case 0: return FLEX_START;
|
||||
case 1: return CENTER;
|
||||
case 2: return FLEX_END;
|
||||
case 3: return SPACE_BETWEEN;
|
||||
case 4: return SPACE_AROUND;
|
||||
default: throw new IllegalArgumentException("Unkown enum value: " + value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
39
java/com/facebook/csslayout/CSSLogLevel.java
Normal file
39
java/com/facebook/csslayout/CSSLogLevel.java
Normal file
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.facebook.csslayout;
|
||||
|
||||
public enum CSSLogLevel {
|
||||
ERROR(0),
|
||||
WARN(1),
|
||||
INFO(2),
|
||||
DEBUG(3),
|
||||
VERBOSE(4);
|
||||
|
||||
private int mIntValue;
|
||||
|
||||
CSSLogLevel(int intValue) {
|
||||
mIntValue = intValue;
|
||||
}
|
||||
|
||||
public int intValue() {
|
||||
return mIntValue;
|
||||
}
|
||||
|
||||
public static CSSLogLevel fromInt(int value) {
|
||||
switch (value) {
|
||||
case 0: return ERROR;
|
||||
case 1: return WARN;
|
||||
case 2: return INFO;
|
||||
case 3: return DEBUG;
|
||||
case 4: return VERBOSE;
|
||||
default: throw new IllegalArgumentException("Unkown enum value: " + value);
|
||||
}
|
||||
}
|
||||
}
|
@@ -13,15 +13,9 @@ import com.facebook.proguard.annotations.DoNotStrip;
|
||||
|
||||
/**
|
||||
* Inteface for recieving logs from native layer. Use by setting CSSNode.setLogger(myLogger);
|
||||
* LOG_LEVEL_ERROR indicated a fatal error.
|
||||
* See CSSLogLevel for the different log levels.
|
||||
*/
|
||||
public interface CSSLogger {
|
||||
public final int LOG_LEVEL_ERROR = 0;
|
||||
public final int LOG_LEVEL_WARN = 1;
|
||||
public final int LOG_LEVEL_INFO = 2;
|
||||
public final int LOG_LEVEL_DEBUG = 3;
|
||||
public final int LOG_LEVEL_VERBOSE = 4;
|
||||
|
||||
@DoNotStrip
|
||||
void log(int level, String message);
|
||||
void log(CSSLogLevel level, String message);
|
||||
}
|
||||
|
@@ -10,7 +10,26 @@
|
||||
package com.facebook.csslayout;
|
||||
|
||||
public enum CSSMeasureMode {
|
||||
UNDEFINED,
|
||||
EXACTLY,
|
||||
AT_MOST,
|
||||
UNDEFINED(0),
|
||||
EXACTLY(1),
|
||||
AT_MOST(2);
|
||||
|
||||
private int mIntValue;
|
||||
|
||||
CSSMeasureMode(int intValue) {
|
||||
mIntValue = intValue;
|
||||
}
|
||||
|
||||
public int intValue() {
|
||||
return mIntValue;
|
||||
}
|
||||
|
||||
public static CSSMeasureMode fromInt(int value) {
|
||||
switch (value) {
|
||||
case 0: return UNDEFINED;
|
||||
case 1: return EXACTLY;
|
||||
case 2: return AT_MOST;
|
||||
default: throw new IllegalArgumentException("Unkown enum value: " + value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -40,6 +40,20 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
|
||||
jni_CSSLayoutSetLogger(logger);
|
||||
}
|
||||
|
||||
private static native void jni_CSSLayoutSetExperimentalFeatureEnabled(
|
||||
int feature,
|
||||
boolean enabled);
|
||||
public static void setExperimentalFeatureEnabled(
|
||||
CSSExperimentalFeature feature,
|
||||
boolean enabled) {
|
||||
jni_CSSLayoutSetExperimentalFeatureEnabled(feature.intValue(), enabled);
|
||||
}
|
||||
|
||||
private static native boolean jni_CSSLayoutIsExperimentalFeatureEnabled(int feature);
|
||||
public static boolean isExperimentalFeatureEnabled(CSSExperimentalFeature feature) {
|
||||
return jni_CSSLayoutIsExperimentalFeatureEnabled(feature.intValue());
|
||||
}
|
||||
|
||||
private CSSNode mParent;
|
||||
private List<CSSNode> mChildren;
|
||||
private MeasureFunction mMeasureFunction;
|
||||
@@ -176,6 +190,12 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
|
||||
jni_CSSNodeMarkLayoutSeen(mNativePointer);
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeCopyStyle(long dstNativePointer, long srcNativePointer);
|
||||
@Override
|
||||
public void copyStyle(CSSNode srcNode) {
|
||||
jni_CSSNodeCopyStyle(mNativePointer, srcNode.mNativePointer);
|
||||
}
|
||||
|
||||
private native int jni_CSSNodeStyleGetDirection(long nativePointer);
|
||||
@Override
|
||||
public CSSDirection getStyleDirection() {
|
||||
@@ -185,7 +205,7 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
|
||||
private native void jni_CSSNodeStyleSetDirection(long nativePointer, int direction);
|
||||
@Override
|
||||
public void setDirection(CSSDirection direction) {
|
||||
jni_CSSNodeStyleSetDirection(mNativePointer, direction.ordinal());
|
||||
jni_CSSNodeStyleSetDirection(mNativePointer, direction.intValue());
|
||||
}
|
||||
|
||||
private native int jni_CSSNodeStyleGetFlexDirection(long nativePointer);
|
||||
@@ -197,7 +217,7 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
|
||||
private native void jni_CSSNodeStyleSetFlexDirection(long nativePointer, int flexDirection);
|
||||
@Override
|
||||
public void setFlexDirection(CSSFlexDirection flexDirection) {
|
||||
jni_CSSNodeStyleSetFlexDirection(mNativePointer, flexDirection.ordinal());
|
||||
jni_CSSNodeStyleSetFlexDirection(mNativePointer, flexDirection.intValue());
|
||||
}
|
||||
|
||||
private native int jni_CSSNodeStyleGetJustifyContent(long nativePointer);
|
||||
@@ -209,7 +229,7 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
|
||||
private native void jni_CSSNodeStyleSetJustifyContent(long nativePointer, int justifyContent);
|
||||
@Override
|
||||
public void setJustifyContent(CSSJustify justifyContent) {
|
||||
jni_CSSNodeStyleSetJustifyContent(mNativePointer, justifyContent.ordinal());
|
||||
jni_CSSNodeStyleSetJustifyContent(mNativePointer, justifyContent.intValue());
|
||||
}
|
||||
|
||||
private native int jni_CSSNodeStyleGetAlignItems(long nativePointer);
|
||||
@@ -221,7 +241,7 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
|
||||
private native void jni_CSSNodeStyleSetAlignItems(long nativePointer, int alignItems);
|
||||
@Override
|
||||
public void setAlignItems(CSSAlign alignItems) {
|
||||
jni_CSSNodeStyleSetAlignItems(mNativePointer, alignItems.ordinal());
|
||||
jni_CSSNodeStyleSetAlignItems(mNativePointer, alignItems.intValue());
|
||||
}
|
||||
|
||||
private native int jni_CSSNodeStyleGetAlignSelf(long nativePointer);
|
||||
@@ -233,7 +253,7 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
|
||||
private native void jni_CSSNodeStyleSetAlignSelf(long nativePointer, int alignSelf);
|
||||
@Override
|
||||
public void setAlignSelf(CSSAlign alignSelf) {
|
||||
jni_CSSNodeStyleSetAlignSelf(mNativePointer, alignSelf.ordinal());
|
||||
jni_CSSNodeStyleSetAlignSelf(mNativePointer, alignSelf.intValue());
|
||||
}
|
||||
|
||||
private native int jni_CSSNodeStyleGetAlignContent(long nativePointer);
|
||||
@@ -245,7 +265,7 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
|
||||
private native void jni_CSSNodeStyleSetAlignContent(long nativePointer, int alignContent);
|
||||
@Override
|
||||
public void setAlignContent(CSSAlign alignContent) {
|
||||
jni_CSSNodeStyleSetAlignContent(mNativePointer, alignContent.ordinal());
|
||||
jni_CSSNodeStyleSetAlignContent(mNativePointer, alignContent.intValue());
|
||||
}
|
||||
|
||||
private native int jni_CSSNodeStyleGetPositionType(long nativePointer);
|
||||
@@ -257,13 +277,13 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
|
||||
private native void jni_CSSNodeStyleSetPositionType(long nativePointer, int positionType);
|
||||
@Override
|
||||
public void setPositionType(CSSPositionType positionType) {
|
||||
jni_CSSNodeStyleSetPositionType(mNativePointer, positionType.ordinal());
|
||||
jni_CSSNodeStyleSetPositionType(mNativePointer, positionType.intValue());
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeStyleSetFlexWrap(long nativePointer, int wrapType);
|
||||
@Override
|
||||
public void setWrap(CSSWrap flexWrap) {
|
||||
jni_CSSNodeStyleSetFlexWrap(mNativePointer, flexWrap.ordinal());
|
||||
jni_CSSNodeStyleSetFlexWrap(mNativePointer, flexWrap.intValue());
|
||||
}
|
||||
|
||||
private native int jni_CSSNodeStyleGetOverflow(long nativePointer);
|
||||
@@ -275,7 +295,7 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
|
||||
private native void jni_CSSNodeStyleSetOverflow(long nativePointer, int overflow);
|
||||
@Override
|
||||
public void setOverflow(CSSOverflow overflow) {
|
||||
jni_CSSNodeStyleSetOverflow(mNativePointer, overflow.ordinal());
|
||||
jni_CSSNodeStyleSetOverflow(mNativePointer, overflow.intValue());
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeStyleSetFlex(long nativePointer, float flex);
|
||||
|
@@ -37,6 +37,7 @@ public interface CSSNodeAPI<CSSNodeType extends CSSNodeAPI> {
|
||||
void dirty();
|
||||
void markLayoutSeen();
|
||||
boolean valuesEqual(float f1, float f2);
|
||||
void copyStyle(CSSNodeType srcNode);
|
||||
CSSDirection getStyleDirection();
|
||||
void setDirection(CSSDirection direction);
|
||||
CSSFlexDirection getFlexDirection();
|
||||
|
@@ -222,6 +222,11 @@ public class CSSNodeDEPRECATED implements CSSNodeAPI<CSSNodeDEPRECATED> {
|
||||
return FloatUtil.floatsEqual(f1, f2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyStyle(CSSNodeDEPRECATED srcNode) {
|
||||
throw new UnsupportedOperationException("copyStyle is not implemented");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get this node's direction, as defined in the style.
|
||||
*/
|
||||
|
@@ -10,7 +10,26 @@
|
||||
package com.facebook.csslayout;
|
||||
|
||||
public enum CSSOverflow {
|
||||
VISIBLE,
|
||||
HIDDEN,
|
||||
SCROLL,
|
||||
VISIBLE(0),
|
||||
HIDDEN(1),
|
||||
SCROLL(2);
|
||||
|
||||
private int mIntValue;
|
||||
|
||||
CSSOverflow(int intValue) {
|
||||
mIntValue = intValue;
|
||||
}
|
||||
|
||||
public int intValue() {
|
||||
return mIntValue;
|
||||
}
|
||||
|
||||
public static CSSOverflow fromInt(int value) {
|
||||
switch (value) {
|
||||
case 0: return VISIBLE;
|
||||
case 1: return HIDDEN;
|
||||
case 2: return SCROLL;
|
||||
default: throw new IllegalArgumentException("Unkown enum value: " + value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -10,6 +10,24 @@
|
||||
package com.facebook.csslayout;
|
||||
|
||||
public enum CSSPositionType {
|
||||
RELATIVE,
|
||||
ABSOLUTE,
|
||||
RELATIVE(0),
|
||||
ABSOLUTE(1);
|
||||
|
||||
private int mIntValue;
|
||||
|
||||
CSSPositionType(int intValue) {
|
||||
mIntValue = intValue;
|
||||
}
|
||||
|
||||
public int intValue() {
|
||||
return mIntValue;
|
||||
}
|
||||
|
||||
public static CSSPositionType fromInt(int value) {
|
||||
switch (value) {
|
||||
case 0: return RELATIVE;
|
||||
case 1: return ABSOLUTE;
|
||||
default: throw new IllegalArgumentException("Unkown enum value: " + value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
35
java/com/facebook/csslayout/CSSPrintOptions.java
Normal file
35
java/com/facebook/csslayout/CSSPrintOptions.java
Normal file
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.facebook.csslayout;
|
||||
|
||||
public enum CSSPrintOptions {
|
||||
LAYOUT(1),
|
||||
STYLE(2),
|
||||
CHILDREN(4);
|
||||
|
||||
private int mIntValue;
|
||||
|
||||
CSSPrintOptions(int intValue) {
|
||||
mIntValue = intValue;
|
||||
}
|
||||
|
||||
public int intValue() {
|
||||
return mIntValue;
|
||||
}
|
||||
|
||||
public static CSSPrintOptions fromInt(int value) {
|
||||
switch (value) {
|
||||
case 1: return LAYOUT;
|
||||
case 2: return STYLE;
|
||||
case 4: return CHILDREN;
|
||||
default: throw new IllegalArgumentException("Unkown enum value: " + value);
|
||||
}
|
||||
}
|
||||
}
|
@@ -54,7 +54,7 @@ public class CSSStyle {
|
||||
alignItems = CSSAlign.STRETCH;
|
||||
alignSelf = CSSAlign.AUTO;
|
||||
positionType = CSSPositionType.RELATIVE;
|
||||
flexWrap = CSSWrap.NOWRAP;
|
||||
flexWrap = CSSWrap.NO_WRAP;
|
||||
overflow = CSSOverflow.VISIBLE;
|
||||
flexGrow = 0;
|
||||
flexShrink = 0;
|
||||
|
@@ -10,6 +10,24 @@
|
||||
package com.facebook.csslayout;
|
||||
|
||||
public enum CSSWrap {
|
||||
NOWRAP,
|
||||
WRAP,
|
||||
NO_WRAP(0),
|
||||
WRAP(1);
|
||||
|
||||
private int mIntValue;
|
||||
|
||||
CSSWrap(int intValue) {
|
||||
mIntValue = intValue;
|
||||
}
|
||||
|
||||
public int intValue() {
|
||||
return mIntValue;
|
||||
}
|
||||
|
||||
public static CSSWrap fromInt(int value) {
|
||||
switch (value) {
|
||||
case 0: return NO_WRAP;
|
||||
case 1: return WRAP;
|
||||
default: throw new IllegalArgumentException("Unkown enum value: " + value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -68,14 +68,24 @@ static CSSSize _jniMeasureFunc(CSSNodeRef node,
|
||||
return CSSSize{measuredWidth, measuredHeight};
|
||||
}
|
||||
|
||||
struct JCSSLogLevel : public JavaClass<JCSSLogLevel> {
|
||||
static constexpr auto kJavaDescriptor = "Lcom/facebook/csslayout/CSSLogLevel;";
|
||||
};
|
||||
|
||||
static global_ref<jobject> *jLogger;
|
||||
static int _jniLog(CSSLogLevel 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(jint, jstring)>("log");
|
||||
logFunc(jLogger->get(), static_cast<jint>(level), Environment::current()->NewStringUTF(buffer));
|
||||
static auto logFunc = findClassLocal("com/facebook/csslayout/CSSLogger")
|
||||
->getMethod<void(local_ref<JCSSLogLevel>, jstring)>("log");
|
||||
|
||||
static auto logLevelFromInt =
|
||||
JCSSLogLevel::javaClassStatic()->getStaticMethod<JCSSLogLevel::javaobject(jint)>("fromInt");
|
||||
|
||||
logFunc(jLogger->get(),
|
||||
logLevelFromInt(JCSSLogLevel::javaClassStatic(), static_cast<jint>(level)),
|
||||
Environment::current()->NewStringUTF(buffer));
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -105,6 +115,16 @@ void jni_CSSLog(alias_ref<jclass> clazz, jint level, jstring message) {
|
||||
Environment::current()->ReleaseStringUTFChars(message, nMessage);
|
||||
}
|
||||
|
||||
void jni_CSSLayoutSetExperimentalFeatureEnabled(alias_ref<jclass> clazz,
|
||||
jint feature,
|
||||
jboolean enabled) {
|
||||
CSSLayoutSetExperimentalFeatureEnabled(static_cast<CSSExperimentalFeature>(feature), enabled);
|
||||
}
|
||||
|
||||
jboolean jni_CSSLayoutIsExperimentalFeatureEnabled(alias_ref<jclass> clazz, jint feature) {
|
||||
return CSSLayoutIsExperimentalFeatureEnabled(static_cast<CSSExperimentalFeature>(feature));
|
||||
}
|
||||
|
||||
jint jni_CSSNodeGetInstanceCount(alias_ref<jclass> clazz) {
|
||||
return CSSNodeGetInstanceCount();
|
||||
}
|
||||
@@ -172,6 +192,10 @@ 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)); \
|
||||
@@ -203,7 +227,7 @@ CSS_NODE_JNI_STYLE_PROP(jint, CSSAlign, AlignItems);
|
||||
CSS_NODE_JNI_STYLE_PROP(jint, CSSAlign, AlignSelf);
|
||||
CSS_NODE_JNI_STYLE_PROP(jint, CSSAlign, AlignContent);
|
||||
CSS_NODE_JNI_STYLE_PROP(jint, CSSPositionType, PositionType);
|
||||
CSS_NODE_JNI_STYLE_PROP(jint, CSSWrapType, FlexWrap);
|
||||
CSS_NODE_JNI_STYLE_PROP(jint, CSSWrap, FlexWrap);
|
||||
CSS_NODE_JNI_STYLE_PROP(jint, CSSOverflow, Overflow);
|
||||
|
||||
void jni_CSSNodeStyleSetFlex(alias_ref<jobject>, jlong nativePointer, jfloat value) {
|
||||
@@ -242,6 +266,7 @@ jint JNI_OnLoad(JavaVM *vm, void *) {
|
||||
CSSMakeNativeMethod(jni_CSSNodeIsDirty),
|
||||
CSSMakeNativeMethod(jni_CSSNodeMarkLayoutSeen),
|
||||
CSSMakeNativeMethod(jni_CSSNodeSetHasMeasureFunc),
|
||||
CSSMakeNativeMethod(jni_CSSNodeCopyStyle),
|
||||
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleGetDirection),
|
||||
CSSMakeNativeMethod(jni_CSSNodeStyleSetDirection),
|
||||
@@ -291,6 +316,8 @@ jint JNI_OnLoad(JavaVM *vm, void *) {
|
||||
CSSMakeNativeMethod(jni_CSSNodeGetInstanceCount),
|
||||
CSSMakeNativeMethod(jni_CSSLayoutSetLogger),
|
||||
CSSMakeNativeMethod(jni_CSSLog),
|
||||
CSSMakeNativeMethod(jni_CSSLayoutSetExperimentalFeatureEnabled),
|
||||
CSSMakeNativeMethod(jni_CSSLayoutIsExperimentalFeatureEnabled),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@@ -12,6 +12,7 @@ package com.facebook.csslayout;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class CSSNodeTest {
|
||||
|
||||
@@ -40,35 +41,47 @@ public class CSSNodeTest {
|
||||
assertEquals(100, (int) node.getLayoutHeight());
|
||||
}
|
||||
|
||||
private int mLogLevel;
|
||||
private CSSLogLevel mLogLevel;
|
||||
private String mLogMessage;
|
||||
|
||||
@Test
|
||||
public void testLogger() {
|
||||
CSSNode.setLogger(new CSSLogger() {
|
||||
public void log(int level, String message) {
|
||||
public void log(CSSLogLevel level, String message) {
|
||||
mLogLevel = level;
|
||||
mLogMessage = message;
|
||||
}
|
||||
});
|
||||
CSSNode.jni_CSSLog(CSSLogger.LOG_LEVEL_DEBUG, "Hello");
|
||||
assertEquals(CSSLogger.LOG_LEVEL_DEBUG, mLogLevel);
|
||||
CSSNode.jni_CSSLog(CSSLogLevel.DEBUG.intValue(), "Hello");
|
||||
assertEquals(CSSLogLevel.DEBUG, mLogLevel);
|
||||
assertEquals("Hello", mLogMessage);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateLogger() {
|
||||
CSSNode.setLogger(new CSSLogger() {
|
||||
public void log(int level, String message) {}
|
||||
public void log(CSSLogLevel level, String message) {}
|
||||
});
|
||||
CSSNode.setLogger(new CSSLogger() {
|
||||
public void log(int level, String message) {
|
||||
public void log(CSSLogLevel level, String message) {
|
||||
mLogLevel = level;
|
||||
mLogMessage = message;
|
||||
}
|
||||
});
|
||||
CSSNode.jni_CSSLog(CSSLogger.LOG_LEVEL_VERBOSE, "Flexbox");
|
||||
assertEquals(CSSLogger.LOG_LEVEL_VERBOSE, mLogLevel);
|
||||
CSSNode.jni_CSSLog(CSSLogLevel.VERBOSE.intValue(), "Flexbox");
|
||||
assertEquals(CSSLogLevel.VERBOSE, mLogLevel);
|
||||
assertEquals("Flexbox", mLogMessage);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCopyStyle() {
|
||||
final CSSNode node0 = new CSSNode();
|
||||
assertTrue(CSSConstants.isUndefined(node0.getStyleMaxHeight()));
|
||||
|
||||
final CSSNode node1 = new CSSNode();
|
||||
node1.setStyleMaxHeight(100);
|
||||
|
||||
node0.copyStyle(node1);
|
||||
assertEquals(100, (int) node0.getStyleMaxHeight());
|
||||
}
|
||||
}
|
||||
|
@@ -7,22 +7,6 @@
|
||||
|
||||
include_defs('//CSSLAYOUT_DEFS')
|
||||
|
||||
with allow_unsafe_import():
|
||||
import os
|
||||
import urllib2
|
||||
import zipfile
|
||||
|
||||
# Download gtest dep if it does not exists in path
|
||||
current_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
gtest_folder = 'googletest-release-1.7.0'
|
||||
if GTEST_DL_URL != None and not os.path.isdir(current_dir + gtest_folder):
|
||||
gtest = urllib2.urlopen('https://github.com/google/googletest/archive/release-1.7.0.zip').read()
|
||||
with open("gtest.zip", 'w') as f:
|
||||
f.write(gtest)
|
||||
with zipfile.ZipFile('gtest.zip',"r") as zip:
|
||||
zip.extractall(os.path.dirname(os.path.realpath(__file__)))
|
||||
os.remove('gtest.zip')
|
||||
|
||||
COMPILER_FLAGS = [
|
||||
'-std=c++11',
|
||||
'-Wno-missing-prototypes',
|
||||
@@ -30,11 +14,11 @@ COMPILER_FLAGS = [
|
||||
|
||||
cxx_library(
|
||||
name = 'gtest',
|
||||
srcs = glob([gtest_folder + '/src/*.cc']),
|
||||
srcs = glob(['googletest/googletest/src/*.cc']),
|
||||
exported_headers = subdir_glob([
|
||||
(gtest_folder + '/include', '**/*.h'),
|
||||
(gtest_folder, 'src/*.h'),
|
||||
(gtest_folder, 'src/*.cc'),
|
||||
('googletest/googletest/include', '**/*.h'),
|
||||
('googletest/googletest', 'src/*.h'),
|
||||
('googletest/googletest', 'src/*.cc'),
|
||||
]),
|
||||
header_namespace = '',
|
||||
compiler_flags = COMPILER_FLAGS,
|
||||
|
1
lib/gtest/googletest
Submodule
1
lib/gtest/googletest
Submodule
Submodule lib/gtest/googletest added at a2b8a8e076
@@ -49,7 +49,7 @@
|
||||
|
||||
TEST(CSSLayoutTest, align_content_flex_start) {
|
||||
const CSSNodeRef root = CSSNodeNew();
|
||||
CSSNodeStyleSetFlexWrap(root, CSSWrapTypeWrap);
|
||||
CSSNodeStyleSetFlexWrap(root, CSSWrapWrap);
|
||||
CSSNodeStyleSetWidth(root, 100);
|
||||
CSSNodeStyleSetHeight(root, 100);
|
||||
|
||||
@@ -147,7 +147,7 @@ TEST(CSSLayoutTest, align_content_flex_start) {
|
||||
TEST(CSSLayoutTest, align_content_flex_end) {
|
||||
const CSSNodeRef root = CSSNodeNew();
|
||||
CSSNodeStyleSetAlignContent(root, CSSAlignFlexEnd);
|
||||
CSSNodeStyleSetFlexWrap(root, CSSWrapTypeWrap);
|
||||
CSSNodeStyleSetFlexWrap(root, CSSWrapWrap);
|
||||
CSSNodeStyleSetWidth(root, 100);
|
||||
CSSNodeStyleSetHeight(root, 100);
|
||||
|
||||
@@ -245,7 +245,7 @@ TEST(CSSLayoutTest, align_content_flex_end) {
|
||||
TEST(CSSLayoutTest, align_content_center) {
|
||||
const CSSNodeRef root = CSSNodeNew();
|
||||
CSSNodeStyleSetAlignContent(root, CSSAlignCenter);
|
||||
CSSNodeStyleSetFlexWrap(root, CSSWrapTypeWrap);
|
||||
CSSNodeStyleSetFlexWrap(root, CSSWrapWrap);
|
||||
CSSNodeStyleSetWidth(root, 100);
|
||||
CSSNodeStyleSetHeight(root, 100);
|
||||
|
||||
@@ -343,7 +343,7 @@ TEST(CSSLayoutTest, align_content_center) {
|
||||
TEST(CSSLayoutTest, align_content_stretch) {
|
||||
const CSSNodeRef root = CSSNodeNew();
|
||||
CSSNodeStyleSetAlignContent(root, CSSAlignStretch);
|
||||
CSSNodeStyleSetFlexWrap(root, CSSWrapTypeWrap);
|
||||
CSSNodeStyleSetFlexWrap(root, CSSWrapWrap);
|
||||
CSSNodeStyleSetWidth(root, 100);
|
||||
CSSNodeStyleSetHeight(root, 100);
|
||||
|
||||
|
@@ -23,7 +23,7 @@ TEST(CSSLayoutTest, assert_default_values) {
|
||||
ASSERT_EQ(CSSAlignStretch, CSSNodeStyleGetAlignItems(root));
|
||||
ASSERT_EQ(CSSAlignAuto, CSSNodeStyleGetAlignSelf(root));
|
||||
ASSERT_EQ(CSSPositionTypeRelative, CSSNodeStyleGetPositionType(root));
|
||||
ASSERT_EQ(CSSWrapTypeNoWrap, CSSNodeStyleGetFlexWrap(root));
|
||||
ASSERT_EQ(CSSWrapNoWrap, CSSNodeStyleGetFlexWrap(root));
|
||||
ASSERT_EQ(CSSOverflowVisible, CSSNodeStyleGetOverflow(root));
|
||||
ASSERT_EQ(0, CSSNodeStyleGetFlexGrow(root));
|
||||
ASSERT_EQ(0, CSSNodeStyleGetFlexShrink(root));
|
||||
|
@@ -83,11 +83,14 @@ TEST(CSSLayoutTest, dirty_node_only_if_children_are_actually_removed) {
|
||||
|
||||
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
|
||||
|
||||
CSSNodeRemoveChild(root, CSSNodeNew());
|
||||
const CSSNodeRef child1 = CSSNodeNew();
|
||||
CSSNodeRemoveChild(root, child1);
|
||||
EXPECT_FALSE(CSSNodeIsDirty(root));
|
||||
CSSNodeFree(child1);
|
||||
|
||||
CSSNodeRemoveChild(root, child0);
|
||||
EXPECT_TRUE(CSSNodeIsDirty(root));
|
||||
CSSNodeFree(child0);
|
||||
|
||||
CSSNodeFreeRecursive(root);
|
||||
}
|
||||
|
@@ -45,7 +45,7 @@
|
||||
|
||||
TEST(CSSLayoutTest, wrap_column) {
|
||||
const CSSNodeRef root = CSSNodeNew();
|
||||
CSSNodeStyleSetFlexWrap(root, CSSWrapTypeWrap);
|
||||
CSSNodeStyleSetFlexWrap(root, CSSWrapWrap);
|
||||
CSSNodeStyleSetHeight(root, 100);
|
||||
|
||||
const CSSNodeRef root_child0 = CSSNodeNew();
|
||||
@@ -127,7 +127,7 @@ TEST(CSSLayoutTest, wrap_column) {
|
||||
TEST(CSSLayoutTest, wrap_row) {
|
||||
const CSSNodeRef root = CSSNodeNew();
|
||||
CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow);
|
||||
CSSNodeStyleSetFlexWrap(root, CSSWrapTypeWrap);
|
||||
CSSNodeStyleSetFlexWrap(root, CSSWrapWrap);
|
||||
CSSNodeStyleSetWidth(root, 100);
|
||||
|
||||
const CSSNodeRef root_child0 = CSSNodeNew();
|
||||
@@ -210,7 +210,7 @@ TEST(CSSLayoutTest, wrap_row_align_items_flex_end) {
|
||||
const CSSNodeRef root = CSSNodeNew();
|
||||
CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow);
|
||||
CSSNodeStyleSetAlignItems(root, CSSAlignFlexEnd);
|
||||
CSSNodeStyleSetFlexWrap(root, CSSWrapTypeWrap);
|
||||
CSSNodeStyleSetFlexWrap(root, CSSWrapWrap);
|
||||
CSSNodeStyleSetWidth(root, 100);
|
||||
|
||||
const CSSNodeRef root_child0 = CSSNodeNew();
|
||||
@@ -293,7 +293,7 @@ TEST(CSSLayoutTest, wrap_row_align_items_center) {
|
||||
const CSSNodeRef root = CSSNodeNew();
|
||||
CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow);
|
||||
CSSNodeStyleSetAlignItems(root, CSSAlignCenter);
|
||||
CSSNodeStyleSetFlexWrap(root, CSSWrapTypeWrap);
|
||||
CSSNodeStyleSetFlexWrap(root, CSSWrapWrap);
|
||||
CSSNodeStyleSetWidth(root, 100);
|
||||
|
||||
const CSSNodeRef root_child0 = CSSNodeNew();
|
||||
|
@@ -43,6 +43,8 @@ TEST(CSSLayoutTest, dont_measure_single_grow_shrink_child) {
|
||||
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
|
||||
|
||||
ASSERT_EQ(0, measureCount);
|
||||
|
||||
CSSNodeFreeRecursive(root);
|
||||
}
|
||||
|
||||
#if GTEST_HAS_DEATH_TEST
|
||||
@@ -52,6 +54,7 @@ TEST(CSSLayoutTest, cannot_add_child_to_node_with_measure_func) {
|
||||
|
||||
const CSSNodeRef root_child0 = CSSNodeNew();
|
||||
ASSERT_DEATH(CSSNodeInsertChild(root, root_child0, 0), "Cannot add child.*");
|
||||
CSSNodeFree(root_child0);
|
||||
CSSNodeFreeRecursive(root);
|
||||
}
|
||||
|
||||
|
77
tests/CSSLayoutMemoryFuncTest.cpp
Normal file
77
tests/CSSLayoutMemoryFuncTest.cpp
Normal file
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* 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 <gtest/gtest.h>
|
||||
|
||||
extern int32_t gNodeInstanceCount;
|
||||
|
||||
static int testMallocCount;
|
||||
static int testCallocCount;
|
||||
static int testReallocCount;
|
||||
static int testFreeCount;
|
||||
|
||||
static void *testMalloc(size_t size) {
|
||||
testMallocCount++;
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
static void *testCalloc(size_t count, size_t size) {
|
||||
testCallocCount++;
|
||||
return calloc(count, size);
|
||||
}
|
||||
|
||||
static void *testRealloc(void *ptr, size_t size) {
|
||||
testReallocCount++;
|
||||
return realloc(ptr, size);
|
||||
}
|
||||
|
||||
static void testFree(void *ptr) {
|
||||
testFreeCount++;
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
TEST(CSSLayoutTest, memory_func_default) {
|
||||
gNodeInstanceCount = 0; // Reset CSSNode instance count for memory func test
|
||||
CSSLayoutSetMemoryFuncs(NULL, NULL, NULL, NULL);
|
||||
const CSSNodeRef root = CSSNodeNew();
|
||||
const CSSNodeRef root_child0 = CSSNodeNew();
|
||||
CSSNodeInsertChild(root, root_child0, 0);
|
||||
CSSNodeFreeRecursive(root);
|
||||
}
|
||||
|
||||
TEST(CSSLayoutTest, memory_func_test_funcs) {
|
||||
gNodeInstanceCount = 0; // Reset CSSNode instance count for memory func test
|
||||
CSSLayoutSetMemoryFuncs(&testMalloc, &testCalloc, &testRealloc, &testFree);
|
||||
const CSSNodeRef root = CSSNodeNew();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
const CSSNodeRef child = CSSNodeNew();
|
||||
CSSNodeInsertChild(root, child, 0);
|
||||
}
|
||||
CSSNodeFreeRecursive(root);
|
||||
ASSERT_NE(testMallocCount, 0);
|
||||
ASSERT_NE(testCallocCount, 0);
|
||||
ASSERT_NE(testReallocCount, 0);
|
||||
ASSERT_NE(testFreeCount, 0);
|
||||
CSSLayoutSetMemoryFuncs(NULL, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
#if GTEST_HAS_DEATH_TEST
|
||||
TEST(CSSLayoutTest, memory_func_assert_zero_nodes) {
|
||||
gNodeInstanceCount = 0; // Reset CSSNode instance count for memory func test
|
||||
const CSSNodeRef root = CSSNodeNew();
|
||||
ASSERT_DEATH(CSSLayoutSetMemoryFuncs(&testMalloc, &testCalloc, &testRealloc, &testFree), "Cannot set memory functions: all node must be freed first");
|
||||
CSSNodeFreeRecursive(root);
|
||||
}
|
||||
|
||||
TEST(CSSLayoutTest, memory_func_assert_all_non_null) {
|
||||
gNodeInstanceCount = 0; // Reset CSSNode instance count for memory func test
|
||||
ASSERT_DEATH(CSSLayoutSetMemoryFuncs(NULL, &testCalloc, &testRealloc, &testFree), "Cannot set memory functions: functions must be all NULL or Non-NULL");
|
||||
}
|
||||
#endif
|
27
tests/CSSLayoutRelayoutTest.cpp
Normal file
27
tests/CSSLayoutRelayoutTest.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* 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 <gtest/gtest.h>
|
||||
|
||||
TEST(CSSLayoutTest, dont_cache_computed_flex_basis_between_layouts) {
|
||||
const CSSNodeRef root = CSSNodeNew();
|
||||
|
||||
const CSSNodeRef root_child0 = CSSNodeNew();
|
||||
CSSNodeStyleSetHeight(root_child0, 10);
|
||||
CSSNodeStyleSetFlexBasis(root_child0, 20);
|
||||
CSSNodeInsertChild(root, root_child0, 0);
|
||||
|
||||
CSSNodeCalculateLayout(root, 100, CSSUndefined, CSSDirectionLTR);
|
||||
CSSNodeCalculateLayout(root, 100, 100, CSSDirectionLTR);
|
||||
|
||||
ASSERT_EQ(20, CSSNodeLayoutGetHeight(root_child0));
|
||||
|
||||
CSSNodeFreeRecursive(root);
|
||||
}
|
60
tests/CSSLayoutStyleTest.cpp
Normal file
60
tests/CSSLayoutStyleTest.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* 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 <gtest/gtest.h>
|
||||
|
||||
TEST(CSSLayoutTest, copy_style_same) {
|
||||
const CSSNodeRef node0 = CSSNodeNew();
|
||||
const CSSNodeRef node1 = CSSNodeNew();
|
||||
ASSERT_FALSE(CSSNodeIsDirty(node0));
|
||||
|
||||
CSSNodeCopyStyle(node0, node1);
|
||||
ASSERT_FALSE(CSSNodeIsDirty(node0));
|
||||
|
||||
CSSNodeFree(node0);
|
||||
CSSNodeFree(node1);
|
||||
}
|
||||
|
||||
TEST(CSSLayoutTest, copy_style_modified) {
|
||||
const CSSNodeRef node0 = CSSNodeNew();
|
||||
ASSERT_FALSE(CSSNodeIsDirty(node0));
|
||||
ASSERT_EQ(CSSFlexDirectionColumn, CSSNodeStyleGetFlexDirection(node0));
|
||||
ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetMaxHeight(node0)));
|
||||
|
||||
const CSSNodeRef node1 = CSSNodeNew();
|
||||
CSSNodeStyleSetFlexDirection(node1, CSSFlexDirectionRow);
|
||||
CSSNodeStyleSetMaxHeight(node1, 10);
|
||||
|
||||
CSSNodeCopyStyle(node0, node1);
|
||||
ASSERT_TRUE(CSSNodeIsDirty(node0));
|
||||
ASSERT_EQ(CSSFlexDirectionRow, CSSNodeStyleGetFlexDirection(node0));
|
||||
ASSERT_EQ(10, CSSNodeStyleGetMaxHeight(node0));
|
||||
|
||||
CSSNodeFree(node0);
|
||||
CSSNodeFree(node1);
|
||||
}
|
||||
|
||||
TEST(CSSLayoutTest, copy_style_modified_same) {
|
||||
const CSSNodeRef node0 = CSSNodeNew();
|
||||
CSSNodeStyleSetFlexDirection(node0, CSSFlexDirectionRow);
|
||||
CSSNodeStyleSetMaxHeight(node0, 10);
|
||||
CSSNodeCalculateLayout(node0, CSSUndefined, CSSUndefined, CSSDirectionLTR);
|
||||
ASSERT_FALSE(CSSNodeIsDirty(node0));
|
||||
|
||||
const CSSNodeRef node1 = CSSNodeNew();
|
||||
CSSNodeStyleSetFlexDirection(node1, CSSFlexDirectionRow);
|
||||
CSSNodeStyleSetMaxHeight(node1, 10);
|
||||
|
||||
CSSNodeCopyStyle(node0, node1);
|
||||
ASSERT_FALSE(CSSNodeIsDirty(node0));
|
||||
|
||||
CSSNodeFree(node0);
|
||||
CSSNodeFree(node1);
|
||||
}
|
Reference in New Issue
Block a user