2016-11-11 10:50:09 -08:00
|
|
|
/**
|
|
|
|
* 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 <string.h>
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
#include "YGNodeList.h"
|
|
|
|
#include "Yoga.h"
|
2016-11-11 10:50:09 -08:00
|
|
|
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
#include <float.h>
|
2016-11-17 20:41:46 -08:00
|
|
|
#ifndef isnan
|
2016-11-11 10:50:09 -08:00
|
|
|
#define isnan _isnan
|
2016-11-17 20:41:46 -08:00
|
|
|
#endif
|
2016-11-11 10:50:09 -08:00
|
|
|
|
|
|
|
#ifndef __cplusplus
|
|
|
|
#define inline __inline
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* define fmaxf if < VC12 */
|
|
|
|
#if _MSC_VER < 1800
|
|
|
|
__forceinline const float fmaxf(const float a, const float b) {
|
|
|
|
return (a > b) ? a : b;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
typedef struct YGCachedMeasurement {
|
2016-11-11 10:50:09 -08:00
|
|
|
float availableWidth;
|
|
|
|
float availableHeight;
|
2016-12-02 05:47:43 -08:00
|
|
|
YGMeasureMode widthMeasureMode;
|
|
|
|
YGMeasureMode heightMeasureMode;
|
2016-11-11 10:50:09 -08:00
|
|
|
|
|
|
|
float computedWidth;
|
|
|
|
float computedHeight;
|
2016-12-03 04:40:18 -08:00
|
|
|
} YGCachedMeasurement;
|
2016-11-11 10:50:09 -08:00
|
|
|
|
|
|
|
// This value was chosen based on empiracle data. Even the most complicated
|
|
|
|
// layouts should not require more than 16 entries to fit within the cache.
|
2016-12-22 02:57:18 -08:00
|
|
|
#define YG_MAX_CACHED_RESULT_COUNT 16
|
2016-11-11 10:50:09 -08:00
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
typedef struct YGLayout {
|
2016-11-11 10:50:09 -08:00
|
|
|
float position[4];
|
|
|
|
float dimensions[2];
|
2017-01-15 15:16:10 -08:00
|
|
|
float margin[6];
|
2017-01-26 13:36:38 -08:00
|
|
|
float border[6];
|
2017-01-05 12:48:07 -08:00
|
|
|
float padding[6];
|
2016-12-02 05:47:43 -08:00
|
|
|
YGDirection direction;
|
2016-11-11 10:50:09 -08:00
|
|
|
|
2016-11-20 04:59:55 -08:00
|
|
|
uint32_t computedFlexBasisGeneration;
|
2016-11-11 10:50:09 -08:00
|
|
|
float computedFlexBasis;
|
|
|
|
|
|
|
|
// Instead of recomputing the entire layout every single time, we
|
|
|
|
// cache some information to break early when nothing changed
|
|
|
|
uint32_t generationCount;
|
2016-12-02 05:47:43 -08:00
|
|
|
YGDirection lastParentDirection;
|
2016-11-11 10:50:09 -08:00
|
|
|
|
|
|
|
uint32_t nextCachedMeasurementsIndex;
|
2016-12-03 04:40:18 -08:00
|
|
|
YGCachedMeasurement cachedMeasurements[YG_MAX_CACHED_RESULT_COUNT];
|
2016-11-11 10:50:09 -08:00
|
|
|
float measuredDimensions[2];
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
YGCachedMeasurement cachedLayout;
|
|
|
|
} YGLayout;
|
2016-11-11 10:50:09 -08:00
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
typedef struct YGStyle {
|
2016-12-02 05:47:43 -08:00
|
|
|
YGDirection direction;
|
|
|
|
YGFlexDirection flexDirection;
|
|
|
|
YGJustify justifyContent;
|
|
|
|
YGAlign alignContent;
|
|
|
|
YGAlign alignItems;
|
|
|
|
YGAlign alignSelf;
|
|
|
|
YGPositionType positionType;
|
|
|
|
YGWrap flexWrap;
|
|
|
|
YGOverflow overflow;
|
2017-02-06 09:31:22 -08:00
|
|
|
YGDisplay display;
|
2016-11-11 10:50:09 -08:00
|
|
|
float flex;
|
|
|
|
float flexGrow;
|
|
|
|
float flexShrink;
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
YGValue flexBasis;
|
|
|
|
YGValue margin[YGEdgeCount];
|
|
|
|
YGValue position[YGEdgeCount];
|
|
|
|
YGValue padding[YGEdgeCount];
|
|
|
|
YGValue border[YGEdgeCount];
|
|
|
|
YGValue dimensions[2];
|
|
|
|
YGValue minDimensions[2];
|
|
|
|
YGValue maxDimensions[2];
|
2016-11-21 10:12:26 -08:00
|
|
|
|
|
|
|
// Yoga specific properties, not compatible with flexbox specification
|
|
|
|
float aspectRatio;
|
2016-12-03 04:40:18 -08:00
|
|
|
} YGStyle;
|
2016-11-11 10:50:09 -08:00
|
|
|
|
2017-03-03 10:47:42 -08:00
|
|
|
typedef struct YGConfig {
|
|
|
|
bool experimentalFeatures[YGExperimentalFeatureCount + 1];
|
|
|
|
bool useWebDefaults;
|
2017-03-09 07:21:23 -08:00
|
|
|
float pointScaleFactor;
|
2017-03-03 10:47:42 -08:00
|
|
|
} YGConfig;
|
2017-03-01 09:19:55 -08:00
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
typedef struct YGNode {
|
|
|
|
YGStyle style;
|
|
|
|
YGLayout layout;
|
2016-11-11 10:50:09 -08:00
|
|
|
uint32_t lineIndex;
|
2017-01-05 12:48:07 -08:00
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeRef parent;
|
|
|
|
YGNodeListRef children;
|
2016-11-11 10:50:09 -08:00
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
struct YGNode *nextChild;
|
2016-11-11 10:50:09 -08:00
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
YGMeasureFunc measure;
|
2017-01-06 06:51:56 -08:00
|
|
|
YGBaselineFunc baseline;
|
2016-12-03 04:40:18 -08:00
|
|
|
YGPrintFunc print;
|
2017-03-01 09:19:55 -08:00
|
|
|
YGConfigRef config;
|
2016-11-11 10:50:09 -08:00
|
|
|
void *context;
|
2017-01-05 12:48:07 -08:00
|
|
|
|
|
|
|
bool isDirty;
|
|
|
|
bool hasNewLayout;
|
2017-02-06 14:36:27 -08:00
|
|
|
|
2017-02-11 08:32:50 -08:00
|
|
|
YGValue const *resolvedDimensions[2];
|
2016-12-03 04:40:18 -08:00
|
|
|
} YGNode;
|
2016-11-11 10:50:09 -08:00
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
#define YG_UNDEFINED_VALUES \
|
|
|
|
{ .value = YGUndefined, .unit = YGUnitUndefined }
|
|
|
|
|
2017-02-14 14:26:09 -08:00
|
|
|
#define YG_AUTO_VALUES \
|
|
|
|
{ .value = YGUndefined, .unit = YGUnitAuto }
|
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
#define YG_DEFAULT_EDGE_VALUES_UNIT \
|
|
|
|
{ \
|
|
|
|
[YGEdgeLeft] = YG_UNDEFINED_VALUES, [YGEdgeTop] = YG_UNDEFINED_VALUES, \
|
|
|
|
[YGEdgeRight] = YG_UNDEFINED_VALUES, [YGEdgeBottom] = YG_UNDEFINED_VALUES, \
|
|
|
|
[YGEdgeStart] = YG_UNDEFINED_VALUES, [YGEdgeEnd] = YG_UNDEFINED_VALUES, \
|
|
|
|
[YGEdgeHorizontal] = YG_UNDEFINED_VALUES, [YGEdgeVertical] = YG_UNDEFINED_VALUES, \
|
|
|
|
[YGEdgeAll] = YG_UNDEFINED_VALUES, \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define YG_DEFAULT_DIMENSION_VALUES \
|
|
|
|
{ [YGDimensionWidth] = YGUndefined, [YGDimensionHeight] = YGUndefined, }
|
|
|
|
|
|
|
|
#define YG_DEFAULT_DIMENSION_VALUES_UNIT \
|
|
|
|
{ [YGDimensionWidth] = YG_UNDEFINED_VALUES, [YGDimensionHeight] = YG_UNDEFINED_VALUES, }
|
|
|
|
|
2017-02-14 14:26:09 -08:00
|
|
|
#define YG_DEFAULT_DIMENSION_VALUES_AUTO_UNIT \
|
|
|
|
{ [YGDimensionWidth] = YG_AUTO_VALUES, [YGDimensionHeight] = YG_AUTO_VALUES, }
|
|
|
|
|
2017-02-28 09:17:17 -08:00
|
|
|
static const float kDefaultFlexGrow = 0.0f;
|
|
|
|
static const float kDefaultFlexShrink = 0.0f;
|
2017-03-03 10:47:42 -08:00
|
|
|
static const float kWebDefaultFlexShrink = 1.0f;
|
2017-02-28 09:17:17 -08:00
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
static YGNode gYGNodeDefaults = {
|
|
|
|
.parent = NULL,
|
|
|
|
.children = NULL,
|
|
|
|
.hasNewLayout = true,
|
|
|
|
.isDirty = false,
|
2017-02-11 08:32:50 -08:00
|
|
|
.resolvedDimensions = {[YGDimensionWidth] = &YGValueUndefined,
|
|
|
|
[YGDimensionHeight] = &YGValueUndefined},
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
|
|
|
|
.style =
|
|
|
|
{
|
|
|
|
.flex = YGUndefined,
|
|
|
|
.flexGrow = YGUndefined,
|
|
|
|
.flexShrink = YGUndefined,
|
2017-02-14 14:26:09 -08:00
|
|
|
.flexBasis = YG_AUTO_VALUES,
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
.justifyContent = YGJustifyFlexStart,
|
|
|
|
.alignItems = YGAlignStretch,
|
|
|
|
.alignContent = YGAlignFlexStart,
|
|
|
|
.direction = YGDirectionInherit,
|
|
|
|
.flexDirection = YGFlexDirectionColumn,
|
|
|
|
.overflow = YGOverflowVisible,
|
2017-02-06 09:31:22 -08:00
|
|
|
.display = YGDisplayFlex,
|
2017-02-14 14:26:09 -08:00
|
|
|
.dimensions = YG_DEFAULT_DIMENSION_VALUES_AUTO_UNIT,
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
.minDimensions = YG_DEFAULT_DIMENSION_VALUES_UNIT,
|
|
|
|
.maxDimensions = YG_DEFAULT_DIMENSION_VALUES_UNIT,
|
|
|
|
.position = YG_DEFAULT_EDGE_VALUES_UNIT,
|
|
|
|
.margin = YG_DEFAULT_EDGE_VALUES_UNIT,
|
|
|
|
.padding = YG_DEFAULT_EDGE_VALUES_UNIT,
|
|
|
|
.border = YG_DEFAULT_EDGE_VALUES_UNIT,
|
|
|
|
.aspectRatio = YGUndefined,
|
|
|
|
},
|
|
|
|
|
|
|
|
.layout =
|
|
|
|
{
|
|
|
|
.dimensions = YG_DEFAULT_DIMENSION_VALUES,
|
|
|
|
.lastParentDirection = (YGDirection) -1,
|
|
|
|
.nextCachedMeasurementsIndex = 0,
|
|
|
|
.computedFlexBasis = YGUndefined,
|
|
|
|
.measuredDimensions = YG_DEFAULT_DIMENSION_VALUES,
|
|
|
|
|
|
|
|
.cachedLayout =
|
|
|
|
{
|
|
|
|
.widthMeasureMode = (YGMeasureMode) -1,
|
|
|
|
.heightMeasureMode = (YGMeasureMode) -1,
|
|
|
|
.computedWidth = -1,
|
|
|
|
.computedHeight = -1,
|
|
|
|
},
|
|
|
|
},
|
2016-12-22 02:57:21 -08:00
|
|
|
};
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
static YGConfig gYGConfigDefaults = {
|
|
|
|
.experimentalFeatures =
|
|
|
|
{
|
2017-04-13 18:01:35 -07:00
|
|
|
[YGExperimentalFeatureMinFlexFix] = false,
|
2017-03-01 09:19:55 -08:00
|
|
|
[YGExperimentalFeatureWebFlexBasis] = false,
|
|
|
|
},
|
2017-03-03 10:47:42 -08:00
|
|
|
.useWebDefaults = false,
|
2017-03-09 07:21:23 -08:00
|
|
|
.pointScaleFactor = 1.0f
|
2017-03-01 09:19:55 -08:00
|
|
|
};
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
static void YGNodeMarkDirtyInternal(const YGNodeRef node);
|
2016-11-11 10:50:09 -08:00
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
YGMalloc gYGMalloc = &malloc;
|
|
|
|
YGCalloc gYGCalloc = &calloc;
|
|
|
|
YGRealloc gYGRealloc = &realloc;
|
|
|
|
YGFree gYGFree = &free;
|
2016-11-15 20:20:09 -08:00
|
|
|
|
2017-02-14 14:26:13 -08:00
|
|
|
static YGValue YGValueZero = {.value = 0, .unit = YGUnitPoint};
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
|
2016-11-11 10:50:09 -08:00
|
|
|
#ifdef ANDROID
|
|
|
|
#include <android/log.h>
|
2016-12-03 04:40:18 -08:00
|
|
|
static int YGAndroidLog(YGLogLevel level, const char *format, va_list args) {
|
2016-12-02 05:47:43 -08:00
|
|
|
int androidLevel = YGLogLevelDebug;
|
2016-11-11 10:50:09 -08:00
|
|
|
switch (level) {
|
2016-12-02 05:47:43 -08:00
|
|
|
case YGLogLevelError:
|
2016-11-11 10:50:09 -08:00
|
|
|
androidLevel = ANDROID_LOG_ERROR;
|
|
|
|
break;
|
2016-12-02 05:47:43 -08:00
|
|
|
case YGLogLevelWarn:
|
2016-11-11 10:50:09 -08:00
|
|
|
androidLevel = ANDROID_LOG_WARN;
|
|
|
|
break;
|
2016-12-02 05:47:43 -08:00
|
|
|
case YGLogLevelInfo:
|
2016-11-11 10:50:09 -08:00
|
|
|
androidLevel = ANDROID_LOG_INFO;
|
|
|
|
break;
|
2016-12-02 05:47:43 -08:00
|
|
|
case YGLogLevelDebug:
|
2016-11-11 10:50:09 -08:00
|
|
|
androidLevel = ANDROID_LOG_DEBUG;
|
|
|
|
break;
|
2016-12-02 05:47:43 -08:00
|
|
|
case YGLogLevelVerbose:
|
2016-11-11 10:50:09 -08:00
|
|
|
androidLevel = ANDROID_LOG_VERBOSE;
|
|
|
|
break;
|
|
|
|
}
|
2016-12-03 04:40:18 -08:00
|
|
|
const int result = __android_log_vprint(androidLevel, "YG-layout", format, args);
|
2016-11-11 10:50:09 -08:00
|
|
|
return result;
|
|
|
|
}
|
2016-12-03 04:40:18 -08:00
|
|
|
static YGLogger gLogger = &YGAndroidLog;
|
2016-11-11 10:50:09 -08:00
|
|
|
#else
|
2016-12-03 04:40:18 -08:00
|
|
|
static int YGDefaultLog(YGLogLevel level, const char *format, va_list args) {
|
2016-11-11 10:50:09 -08:00
|
|
|
switch (level) {
|
2016-12-02 05:47:43 -08:00
|
|
|
case YGLogLevelError:
|
2016-11-11 10:50:09 -08:00
|
|
|
return vfprintf(stderr, format, args);
|
2016-12-02 05:47:43 -08:00
|
|
|
case YGLogLevelWarn:
|
|
|
|
case YGLogLevelInfo:
|
|
|
|
case YGLogLevelDebug:
|
|
|
|
case YGLogLevelVerbose:
|
2016-11-11 10:50:09 -08:00
|
|
|
default:
|
|
|
|
return vprintf(format, args);
|
|
|
|
}
|
|
|
|
}
|
2016-12-03 04:40:18 -08:00
|
|
|
static YGLogger gLogger = &YGDefaultLog;
|
2016-11-11 10:50:09 -08:00
|
|
|
#endif
|
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
static inline const YGValue *YGComputedEdgeValue(const YGValue edges[YGEdgeCount],
|
|
|
|
const YGEdge edge,
|
|
|
|
const YGValue *const defaultValue) {
|
2016-12-03 04:40:18 -08:00
|
|
|
YG_ASSERT(edge <= YGEdgeEnd, "Cannot get computed value of multi-edge shorthands");
|
2016-11-11 10:50:09 -08:00
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
if (edges[edge].unit != YGUnitUndefined) {
|
|
|
|
return &edges[edge];
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
if ((edge == YGEdgeTop || edge == YGEdgeBottom) &&
|
|
|
|
edges[YGEdgeVertical].unit != YGUnitUndefined) {
|
|
|
|
return &edges[YGEdgeVertical];
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2016-12-02 05:47:43 -08:00
|
|
|
if ((edge == YGEdgeLeft || edge == YGEdgeRight || edge == YGEdgeStart || edge == YGEdgeEnd) &&
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
edges[YGEdgeHorizontal].unit != YGUnitUndefined) {
|
|
|
|
return &edges[YGEdgeHorizontal];
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
if (edges[YGEdgeAll].unit != YGUnitUndefined) {
|
|
|
|
return &edges[YGEdgeAll];
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2016-12-02 05:47:43 -08:00
|
|
|
if (edge == YGEdgeStart || edge == YGEdgeEnd) {
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
return &YGValueUndefined;
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
return defaultValue;
|
|
|
|
}
|
|
|
|
|
2017-03-10 06:05:53 -08:00
|
|
|
static inline float YGResolveValue(const YGValue *const value, const float parentSize) {
|
2017-02-03 05:37:47 -08:00
|
|
|
switch (value->unit) {
|
|
|
|
case YGUnitUndefined:
|
2017-02-14 14:26:09 -08:00
|
|
|
case YGUnitAuto:
|
2017-02-03 05:37:47 -08:00
|
|
|
return YGUndefined;
|
2017-02-14 14:26:13 -08:00
|
|
|
case YGUnitPoint:
|
2017-02-03 05:37:47 -08:00
|
|
|
return value->value;
|
|
|
|
case YGUnitPercent:
|
|
|
|
return value->value * parentSize / 100.0f;
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
}
|
2017-02-03 05:37:47 -08:00
|
|
|
return YGUndefined;
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
}
|
|
|
|
|
2017-03-10 06:05:53 -08:00
|
|
|
static inline float YGResolveValueMargin(const YGValue *const value, const float parentSize) {
|
|
|
|
return value->unit == YGUnitAuto ? 0 : YGResolveValue(value, parentSize);
|
2017-02-14 14:26:09 -08:00
|
|
|
}
|
|
|
|
|
2016-12-06 14:37:54 -08:00
|
|
|
int32_t gNodeInstanceCount = 0;
|
2017-04-10 14:22:23 -07:00
|
|
|
int32_t gConfigInstanceCount = 0;
|
2016-12-06 14:37:54 -08:00
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
WIN_EXPORT YGNodeRef YGNodeNewWithConfig(const YGConfigRef config) {
|
2016-12-22 02:57:21 -08:00
|
|
|
const YGNodeRef node = gYGMalloc(sizeof(YGNode));
|
2016-12-06 14:37:54 -08:00
|
|
|
YG_ASSERT(node, "Could not allocate memory for node");
|
|
|
|
gNodeInstanceCount++;
|
|
|
|
|
2016-12-22 02:57:21 -08:00
|
|
|
memcpy(node, &gYGNodeDefaults, sizeof(YGNode));
|
2017-03-03 10:47:42 -08:00
|
|
|
if (config->useWebDefaults) {
|
|
|
|
node->style.flexDirection = YGFlexDirectionRow;
|
|
|
|
node->style.alignContent = YGAlignStretch;
|
|
|
|
}
|
2017-03-01 09:19:55 -08:00
|
|
|
node->config = config;
|
2016-12-06 14:37:54 -08:00
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
YGNodeRef YGNodeNew(void) {
|
|
|
|
return YGNodeNewWithConfig(&gYGConfigDefaults);
|
|
|
|
}
|
|
|
|
|
2016-12-06 14:37:54 -08:00
|
|
|
void YGNodeFree(const YGNodeRef node) {
|
|
|
|
if (node->parent) {
|
|
|
|
YGNodeListDelete(node->parent->children, node);
|
|
|
|
node->parent = NULL;
|
|
|
|
}
|
|
|
|
|
2016-12-16 04:39:13 -08:00
|
|
|
const uint32_t childCount = YGNodeGetChildCount(node);
|
2016-12-06 14:37:54 -08:00
|
|
|
for (uint32_t i = 0; i < childCount; i++) {
|
|
|
|
const YGNodeRef child = YGNodeGetChild(node, i);
|
|
|
|
child->parent = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
YGNodeListFree(node->children);
|
|
|
|
gYGFree(node);
|
|
|
|
gNodeInstanceCount--;
|
|
|
|
}
|
|
|
|
|
|
|
|
void YGNodeFreeRecursive(const YGNodeRef root) {
|
2016-12-16 04:39:13 -08:00
|
|
|
while (YGNodeGetChildCount(root) > 0) {
|
2016-12-06 14:37:54 -08:00
|
|
|
const YGNodeRef child = YGNodeGetChild(root, 0);
|
|
|
|
YGNodeRemoveChild(root, child);
|
|
|
|
YGNodeFreeRecursive(child);
|
|
|
|
}
|
|
|
|
YGNodeFree(root);
|
|
|
|
}
|
|
|
|
|
|
|
|
void YGNodeReset(const YGNodeRef node) {
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
YG_ASSERT(YGNodeGetChildCount(node) == 0,
|
|
|
|
"Cannot reset a node which still has children attached");
|
2016-12-06 14:37:54 -08:00
|
|
|
YG_ASSERT(node->parent == NULL, "Cannot reset a node still attached to a parent");
|
|
|
|
|
|
|
|
YGNodeListFree(node->children);
|
2017-03-01 09:19:55 -08:00
|
|
|
|
|
|
|
const YGConfigRef config = node->config;
|
2016-12-22 02:57:21 -08:00
|
|
|
memcpy(node, &gYGNodeDefaults, sizeof(YGNode));
|
2017-03-29 03:06:19 -07:00
|
|
|
if (config->useWebDefaults) {
|
|
|
|
node->style.flexDirection = YGFlexDirectionRow;
|
|
|
|
node->style.alignContent = YGAlignStretch;
|
|
|
|
}
|
2017-03-01 09:19:55 -08:00
|
|
|
node->config = config;
|
2016-12-06 14:37:54 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
int32_t YGNodeGetInstanceCount(void) {
|
|
|
|
return gNodeInstanceCount;
|
|
|
|
}
|
|
|
|
|
2017-04-10 14:22:23 -07:00
|
|
|
int32_t YGConfigGetInstanceCount(void) {
|
|
|
|
return gConfigInstanceCount;
|
|
|
|
}
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
YGConfigRef YGConfigNew(void) {
|
|
|
|
const YGConfigRef config = gYGMalloc(sizeof(YGConfig));
|
|
|
|
YG_ASSERT(config, "Could not allocate memory for config");
|
2017-04-10 14:22:23 -07:00
|
|
|
gConfigInstanceCount++;
|
2017-03-01 09:19:55 -08:00
|
|
|
memcpy(config, &gYGConfigDefaults, sizeof(YGConfig));
|
|
|
|
return config;
|
|
|
|
}
|
|
|
|
|
|
|
|
void YGConfigFree(const YGConfigRef config) {
|
|
|
|
gYGFree(config);
|
2017-04-10 14:22:23 -07:00
|
|
|
gConfigInstanceCount--;
|
2017-03-01 09:19:55 -08:00
|
|
|
}
|
|
|
|
|
2017-04-26 11:49:26 -07:00
|
|
|
void YGConfigCopy(const YGConfigRef dest, const YGConfigRef src) {
|
|
|
|
memcpy(dest, src, sizeof(YGConfig));
|
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
static void YGNodeMarkDirtyInternal(const YGNodeRef node) {
|
2016-11-11 10:50:09 -08:00
|
|
|
if (!node->isDirty) {
|
|
|
|
node->isDirty = true;
|
2016-12-02 05:47:43 -08:00
|
|
|
node->layout.computedFlexBasis = YGUndefined;
|
2016-11-11 10:50:09 -08:00
|
|
|
if (node->parent) {
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeMarkDirtyInternal(node->parent);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
void YGNodeSetMeasureFunc(const YGNodeRef node, YGMeasureFunc measureFunc) {
|
2016-11-11 10:50:09 -08:00
|
|
|
if (measureFunc == NULL) {
|
|
|
|
node->measure = NULL;
|
|
|
|
} else {
|
2016-12-16 04:39:13 -08:00
|
|
|
YG_ASSERT(YGNodeGetChildCount(node) == 0,
|
2016-12-03 04:40:18 -08:00
|
|
|
"Cannot set measure function: Nodes with measure functions cannot have children.");
|
2016-11-11 10:50:09 -08:00
|
|
|
node->measure = measureFunc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
YGMeasureFunc YGNodeGetMeasureFunc(const YGNodeRef node) {
|
2016-11-11 10:50:09 -08:00
|
|
|
return node->measure;
|
|
|
|
}
|
|
|
|
|
2017-01-06 06:51:56 -08:00
|
|
|
void YGNodeSetBaselineFunc(const YGNodeRef node, YGBaselineFunc baselineFunc) {
|
|
|
|
node->baseline = baselineFunc;
|
|
|
|
}
|
|
|
|
|
|
|
|
YGBaselineFunc YGNodeGetBaselineFunc(const YGNodeRef node) {
|
|
|
|
return node->baseline;
|
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
void YGNodeInsertChild(const YGNodeRef node, const YGNodeRef child, const uint32_t index) {
|
|
|
|
YG_ASSERT(child->parent == NULL, "Child already has a parent, it must be removed first.");
|
|
|
|
YG_ASSERT(node->measure == NULL,
|
|
|
|
"Cannot add child: Nodes with measure functions cannot have children.");
|
|
|
|
YGNodeListInsert(&node->children, child, index);
|
2016-11-11 10:50:09 -08:00
|
|
|
child->parent = node;
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeMarkDirtyInternal(node);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
void YGNodeRemoveChild(const YGNodeRef node, const YGNodeRef child) {
|
|
|
|
if (YGNodeListDelete(node->children, child) != NULL) {
|
2017-03-17 09:07:23 -07:00
|
|
|
child->layout = gYGNodeDefaults.layout; // layout is no longer valid
|
2016-11-11 10:50:09 -08:00
|
|
|
child->parent = NULL;
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeMarkDirtyInternal(node);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeRef YGNodeGetChild(const YGNodeRef node, const uint32_t index) {
|
|
|
|
return YGNodeListGet(node->children, index);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2016-12-15 08:49:51 -08:00
|
|
|
YGNodeRef YGNodeGetParent(const YGNodeRef node) {
|
|
|
|
return node->parent;
|
|
|
|
}
|
|
|
|
|
2016-12-16 04:39:13 -08:00
|
|
|
inline uint32_t YGNodeGetChildCount(const YGNodeRef node) {
|
2016-12-03 04:40:18 -08:00
|
|
|
return YGNodeListCount(node->children);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
void YGNodeMarkDirty(const YGNodeRef node) {
|
|
|
|
YG_ASSERT(node->measure != NULL,
|
|
|
|
"Only leaf nodes with custom measure functions"
|
|
|
|
"should manually mark themselves as dirty");
|
|
|
|
YGNodeMarkDirtyInternal(node);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
bool YGNodeIsDirty(const YGNodeRef node) {
|
2016-11-11 10:50:09 -08:00
|
|
|
return node->isDirty;
|
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
void YGNodeCopyStyle(const YGNodeRef dstNode, const YGNodeRef srcNode) {
|
|
|
|
if (memcmp(&dstNode->style, &srcNode->style, sizeof(YGStyle)) != 0) {
|
|
|
|
memcpy(&dstNode->style, &srcNode->style, sizeof(YGStyle));
|
|
|
|
YGNodeMarkDirtyInternal(dstNode);
|
2016-11-17 09:10:45 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-28 09:17:17 -08:00
|
|
|
static inline float YGResolveFlexGrow(const YGNodeRef node) {
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
if (!YGFloatIsUndefined(node->style.flexGrow)) {
|
2016-11-11 10:50:09 -08:00
|
|
|
return node->style.flexGrow;
|
|
|
|
}
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
if (!YGFloatIsUndefined(node->style.flex) && node->style.flex > 0.0f) {
|
2016-11-11 10:50:09 -08:00
|
|
|
return node->style.flex;
|
|
|
|
}
|
2017-02-28 09:17:17 -08:00
|
|
|
return kDefaultFlexGrow;
|
|
|
|
}
|
|
|
|
|
|
|
|
float YGNodeStyleGetFlexGrow(const YGNodeRef node) {
|
|
|
|
return YGFloatIsUndefined(node->style.flexGrow) ? kDefaultFlexGrow : node->style.flexGrow;
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2017-02-28 09:17:17 -08:00
|
|
|
float YGNodeStyleGetFlexShrink(const YGNodeRef node) {
|
2017-03-03 10:47:42 -08:00
|
|
|
return YGFloatIsUndefined(node->style.flexShrink) ? (node->config->useWebDefaults ? kWebDefaultFlexShrink : kDefaultFlexShrink) : node->style.flexShrink;
|
2017-02-28 09:17:17 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline float YGNodeResolveFlexShrink(const YGNodeRef node) {
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
if (!YGFloatIsUndefined(node->style.flexShrink)) {
|
2016-11-11 10:50:09 -08:00
|
|
|
return node->style.flexShrink;
|
|
|
|
}
|
2017-03-03 10:47:42 -08:00
|
|
|
if (!node->config->useWebDefaults && !YGFloatIsUndefined(node->style.flex) && node->style.flex < 0.0f) {
|
2016-11-11 10:50:09 -08:00
|
|
|
return -node->style.flex;
|
|
|
|
}
|
2017-03-03 10:47:42 -08:00
|
|
|
return node->config->useWebDefaults ? kWebDefaultFlexShrink : kDefaultFlexShrink;
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2017-02-28 09:17:17 -08:00
|
|
|
static inline const YGValue *YGNodeResolveFlexBasisPtr(const YGNodeRef node) {
|
2017-02-16 06:47:28 -08:00
|
|
|
if (node->style.flexBasis.unit != YGUnitAuto && node->style.flexBasis.unit != YGUnitUndefined) {
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
return &node->style.flexBasis;
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
if (!YGFloatIsUndefined(node->style.flex) && node->style.flex > 0.0f) {
|
2017-03-03 10:47:42 -08:00
|
|
|
return node->config->useWebDefaults ? &YGValueAuto : &YGValueZero;
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
2017-02-14 14:26:09 -08:00
|
|
|
return &YGValueAuto;
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
#define YG_NODE_PROPERTY_IMPL(type, name, paramName, instanceName) \
|
|
|
|
void YGNodeSet##name(const YGNodeRef node, type paramName) { \
|
|
|
|
node->instanceName = paramName; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
type YGNodeGet##name(const YGNodeRef node) { \
|
|
|
|
return node->instanceName; \
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
#define YG_NODE_STYLE_PROPERTY_SETTER_IMPL(type, name, paramName, instanceName) \
|
|
|
|
void YGNodeStyleSet##name(const YGNodeRef node, const type paramName) { \
|
|
|
|
if (node->style.instanceName != paramName) { \
|
|
|
|
node->style.instanceName = paramName; \
|
|
|
|
YGNodeMarkDirtyInternal(node); \
|
|
|
|
} \
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
#define YG_NODE_STYLE_PROPERTY_SETTER_UNIT_IMPL(type, name, paramName, instanceName) \
|
|
|
|
void YGNodeStyleSet##name(const YGNodeRef node, const type paramName) { \
|
|
|
|
if (node->style.instanceName.value != paramName || \
|
2017-02-14 14:26:13 -08:00
|
|
|
node->style.instanceName.unit != YGUnitPoint) { \
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
node->style.instanceName.value = paramName; \
|
|
|
|
node->style.instanceName.unit = \
|
2017-02-16 06:47:28 -08:00
|
|
|
YGFloatIsUndefined(paramName) ? YGUnitAuto : YGUnitPoint; \
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
YGNodeMarkDirtyInternal(node); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
void YGNodeStyleSet##name##Percent(const YGNodeRef node, const type paramName) { \
|
|
|
|
if (node->style.instanceName.value != paramName || \
|
|
|
|
node->style.instanceName.unit != YGUnitPercent) { \
|
|
|
|
node->style.instanceName.value = paramName; \
|
|
|
|
node->style.instanceName.unit = \
|
2017-02-16 06:47:28 -08:00
|
|
|
YGFloatIsUndefined(paramName) ? YGUnitAuto : YGUnitPercent; \
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
YGNodeMarkDirtyInternal(node); \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
2017-02-14 14:26:09 -08:00
|
|
|
#define YG_NODE_STYLE_PROPERTY_SETTER_UNIT_AUTO_IMPL(type, name, paramName, instanceName) \
|
|
|
|
void YGNodeStyleSet##name(const YGNodeRef node, const type paramName) { \
|
|
|
|
if (node->style.instanceName.value != paramName || \
|
2017-02-14 14:26:13 -08:00
|
|
|
node->style.instanceName.unit != YGUnitPoint) { \
|
2017-02-16 06:47:28 -08:00
|
|
|
node->style.instanceName.value = paramName; \
|
2017-02-14 14:26:13 -08:00
|
|
|
node->style.instanceName.unit = YGFloatIsUndefined(paramName) ? YGUnitAuto : YGUnitPoint; \
|
2017-02-14 14:26:09 -08:00
|
|
|
YGNodeMarkDirtyInternal(node); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
void YGNodeStyleSet##name##Percent(const YGNodeRef node, const type paramName) { \
|
|
|
|
if (node->style.instanceName.value != paramName || \
|
|
|
|
node->style.instanceName.unit != YGUnitPercent) { \
|
2017-02-16 06:47:28 -08:00
|
|
|
node->style.instanceName.value = paramName; \
|
2017-02-14 14:26:09 -08:00
|
|
|
node->style.instanceName.unit = YGFloatIsUndefined(paramName) ? YGUnitAuto : YGUnitPercent; \
|
|
|
|
YGNodeMarkDirtyInternal(node); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
void YGNodeStyleSet##name##Auto(const YGNodeRef node) { \
|
|
|
|
if (node->style.instanceName.unit != YGUnitAuto) { \
|
|
|
|
node->style.instanceName.value = YGUndefined; \
|
|
|
|
node->style.instanceName.unit = YGUnitAuto; \
|
|
|
|
YGNodeMarkDirtyInternal(node); \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
#define YG_NODE_STYLE_PROPERTY_IMPL(type, name, paramName, instanceName) \
|
|
|
|
YG_NODE_STYLE_PROPERTY_SETTER_IMPL(type, name, paramName, instanceName) \
|
|
|
|
\
|
|
|
|
type YGNodeStyleGet##name(const YGNodeRef node) { \
|
|
|
|
return node->style.instanceName; \
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
#define YG_NODE_STYLE_PROPERTY_UNIT_IMPL(type, name, paramName, instanceName) \
|
|
|
|
YG_NODE_STYLE_PROPERTY_SETTER_UNIT_IMPL(float, name, paramName, instanceName) \
|
|
|
|
\
|
|
|
|
type YGNodeStyleGet##name(const YGNodeRef node) { \
|
|
|
|
return node->style.instanceName; \
|
|
|
|
}
|
|
|
|
|
2017-02-14 14:26:09 -08:00
|
|
|
#define YG_NODE_STYLE_PROPERTY_UNIT_AUTO_IMPL(type, name, paramName, instanceName) \
|
|
|
|
YG_NODE_STYLE_PROPERTY_SETTER_UNIT_AUTO_IMPL(float, name, paramName, instanceName) \
|
|
|
|
\
|
|
|
|
type YGNodeStyleGet##name(const YGNodeRef node) { \
|
|
|
|
return node->style.instanceName; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define YG_NODE_STYLE_EDGE_PROPERTY_UNIT_AUTO_IMPL(type, name, instanceName) \
|
|
|
|
void YGNodeStyleSet##name##Auto(const YGNodeRef node, const YGEdge edge) { \
|
|
|
|
if (node->style.instanceName[edge].unit != YGUnitAuto) { \
|
|
|
|
node->style.instanceName[edge].value = YGUndefined; \
|
|
|
|
node->style.instanceName[edge].unit = YGUnitAuto; \
|
|
|
|
YGNodeMarkDirtyInternal(node); \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
2017-02-03 11:19:40 -08:00
|
|
|
#define YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL(type, name, paramName, instanceName) \
|
|
|
|
void YGNodeStyleSet##name(const YGNodeRef node, const YGEdge edge, const float paramName) { \
|
|
|
|
if (node->style.instanceName[edge].value != paramName || \
|
2017-02-14 14:26:13 -08:00
|
|
|
node->style.instanceName[edge].unit != YGUnitPoint) { \
|
2017-02-03 11:19:40 -08:00
|
|
|
node->style.instanceName[edge].value = paramName; \
|
|
|
|
node->style.instanceName[edge].unit = \
|
2017-02-14 14:26:13 -08:00
|
|
|
YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPoint; \
|
2017-02-03 11:19:40 -08:00
|
|
|
YGNodeMarkDirtyInternal(node); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
void YGNodeStyleSet##name##Percent(const YGNodeRef node, \
|
|
|
|
const YGEdge edge, \
|
|
|
|
const float paramName) { \
|
|
|
|
if (node->style.instanceName[edge].value != paramName || \
|
|
|
|
node->style.instanceName[edge].unit != YGUnitPercent) { \
|
|
|
|
node->style.instanceName[edge].value = paramName; \
|
|
|
|
node->style.instanceName[edge].unit = \
|
|
|
|
YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPercent; \
|
|
|
|
YGNodeMarkDirtyInternal(node); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
\
|
2017-03-06 11:29:52 -08:00
|
|
|
WIN_STRUCT(type) YGNodeStyleGet##name(const YGNodeRef node, const YGEdge edge) { \
|
|
|
|
return WIN_STRUCT_REF(node->style.instanceName[edge]); \
|
2017-02-03 11:19:40 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
#define YG_NODE_STYLE_EDGE_PROPERTY_IMPL(type, name, paramName, instanceName) \
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
void YGNodeStyleSet##name(const YGNodeRef node, const YGEdge edge, const float paramName) { \
|
|
|
|
if (node->style.instanceName[edge].value != paramName || \
|
2017-02-14 14:26:13 -08:00
|
|
|
node->style.instanceName[edge].unit != YGUnitPoint) { \
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
node->style.instanceName[edge].value = paramName; \
|
|
|
|
node->style.instanceName[edge].unit = \
|
2017-02-14 14:26:13 -08:00
|
|
|
YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPoint; \
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
YGNodeMarkDirtyInternal(node); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
float YGNodeStyleGet##name(const YGNodeRef node, const YGEdge edge) { \
|
2017-02-03 11:19:40 -08:00
|
|
|
return node->style.instanceName[edge].value; \
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
#define YG_NODE_LAYOUT_PROPERTY_IMPL(type, name, instanceName) \
|
|
|
|
type YGNodeLayoutGet##name(const YGNodeRef node) { \
|
|
|
|
return node->layout.instanceName; \
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2017-01-26 13:36:39 -08:00
|
|
|
#define YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(type, name, instanceName) \
|
2017-01-15 15:16:10 -08:00
|
|
|
type YGNodeLayoutGet##name(const YGNodeRef node, const YGEdge edge) { \
|
|
|
|
YG_ASSERT(edge <= YGEdgeEnd, "Cannot get layout properties of multi-edge shorthands"); \
|
|
|
|
\
|
|
|
|
if (edge == YGEdgeLeft) { \
|
|
|
|
if (node->layout.direction == YGDirectionRTL) { \
|
|
|
|
return node->layout.instanceName[YGEdgeEnd]; \
|
|
|
|
} else { \
|
|
|
|
return node->layout.instanceName[YGEdgeStart]; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
if (edge == YGEdgeRight) { \
|
|
|
|
if (node->layout.direction == YGDirectionRTL) { \
|
|
|
|
return node->layout.instanceName[YGEdgeStart]; \
|
|
|
|
} else { \
|
|
|
|
return node->layout.instanceName[YGEdgeEnd]; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
return node->layout.instanceName[edge]; \
|
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
YG_NODE_PROPERTY_IMPL(void *, Context, context, context);
|
|
|
|
YG_NODE_PROPERTY_IMPL(YGPrintFunc, PrintFunc, printFunc, print);
|
|
|
|
YG_NODE_PROPERTY_IMPL(bool, HasNewLayout, hasNewLayout, hasNewLayout);
|
2016-11-11 10:50:09 -08:00
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
YG_NODE_STYLE_PROPERTY_IMPL(YGDirection, Direction, direction, direction);
|
|
|
|
YG_NODE_STYLE_PROPERTY_IMPL(YGFlexDirection, FlexDirection, flexDirection, flexDirection);
|
|
|
|
YG_NODE_STYLE_PROPERTY_IMPL(YGJustify, JustifyContent, justifyContent, justifyContent);
|
|
|
|
YG_NODE_STYLE_PROPERTY_IMPL(YGAlign, AlignContent, alignContent, alignContent);
|
|
|
|
YG_NODE_STYLE_PROPERTY_IMPL(YGAlign, AlignItems, alignItems, alignItems);
|
|
|
|
YG_NODE_STYLE_PROPERTY_IMPL(YGAlign, AlignSelf, alignSelf, alignSelf);
|
|
|
|
YG_NODE_STYLE_PROPERTY_IMPL(YGPositionType, PositionType, positionType, positionType);
|
|
|
|
YG_NODE_STYLE_PROPERTY_IMPL(YGWrap, FlexWrap, flexWrap, flexWrap);
|
|
|
|
YG_NODE_STYLE_PROPERTY_IMPL(YGOverflow, Overflow, overflow, overflow);
|
2017-02-06 09:31:22 -08:00
|
|
|
YG_NODE_STYLE_PROPERTY_IMPL(YGDisplay, Display, display, display);
|
2016-11-11 10:50:09 -08:00
|
|
|
|
2017-02-28 09:17:17 -08:00
|
|
|
YG_NODE_STYLE_PROPERTY_IMPL(float, Flex, flex, flex);
|
2016-12-03 04:40:18 -08:00
|
|
|
YG_NODE_STYLE_PROPERTY_SETTER_IMPL(float, FlexGrow, flexGrow, flexGrow);
|
|
|
|
YG_NODE_STYLE_PROPERTY_SETTER_IMPL(float, FlexShrink, flexShrink, flexShrink);
|
2017-02-28 09:17:17 -08:00
|
|
|
YG_NODE_STYLE_PROPERTY_UNIT_AUTO_IMPL(YGValue, FlexBasis, flexBasis, flexBasis);
|
2016-11-11 10:50:09 -08:00
|
|
|
|
2017-02-03 11:19:40 -08:00
|
|
|
YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL(YGValue, Position, position, position);
|
|
|
|
YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL(YGValue, Margin, margin, margin);
|
2017-02-14 14:26:09 -08:00
|
|
|
YG_NODE_STYLE_EDGE_PROPERTY_UNIT_AUTO_IMPL(YGValue, Margin, margin);
|
2017-02-03 11:19:40 -08:00
|
|
|
YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL(YGValue, Padding, padding, padding);
|
|
|
|
YG_NODE_STYLE_EDGE_PROPERTY_IMPL(float, Border, border, border);
|
2016-11-11 10:50:09 -08:00
|
|
|
|
2017-02-14 14:26:09 -08:00
|
|
|
YG_NODE_STYLE_PROPERTY_UNIT_AUTO_IMPL(YGValue, Width, width, dimensions[YGDimensionWidth]);
|
|
|
|
YG_NODE_STYLE_PROPERTY_UNIT_AUTO_IMPL(YGValue, Height, height, dimensions[YGDimensionHeight]);
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
YG_NODE_STYLE_PROPERTY_UNIT_IMPL(YGValue, MinWidth, minWidth, minDimensions[YGDimensionWidth]);
|
|
|
|
YG_NODE_STYLE_PROPERTY_UNIT_IMPL(YGValue, MinHeight, minHeight, minDimensions[YGDimensionHeight]);
|
|
|
|
YG_NODE_STYLE_PROPERTY_UNIT_IMPL(YGValue, MaxWidth, maxWidth, maxDimensions[YGDimensionWidth]);
|
|
|
|
YG_NODE_STYLE_PROPERTY_UNIT_IMPL(YGValue, MaxHeight, maxHeight, maxDimensions[YGDimensionHeight]);
|
2016-11-11 10:50:09 -08:00
|
|
|
|
2016-11-21 10:12:26 -08:00
|
|
|
// Yoga specific properties, not compatible with flexbox specification
|
2016-12-03 04:40:18 -08:00
|
|
|
YG_NODE_STYLE_PROPERTY_IMPL(float, AspectRatio, aspectRatio, aspectRatio);
|
2016-11-21 10:12:26 -08:00
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
YG_NODE_LAYOUT_PROPERTY_IMPL(float, Left, position[YGEdgeLeft]);
|
|
|
|
YG_NODE_LAYOUT_PROPERTY_IMPL(float, Top, position[YGEdgeTop]);
|
|
|
|
YG_NODE_LAYOUT_PROPERTY_IMPL(float, Right, position[YGEdgeRight]);
|
|
|
|
YG_NODE_LAYOUT_PROPERTY_IMPL(float, Bottom, position[YGEdgeBottom]);
|
|
|
|
YG_NODE_LAYOUT_PROPERTY_IMPL(float, Width, dimensions[YGDimensionWidth]);
|
|
|
|
YG_NODE_LAYOUT_PROPERTY_IMPL(float, Height, dimensions[YGDimensionHeight]);
|
|
|
|
YG_NODE_LAYOUT_PROPERTY_IMPL(YGDirection, Direction, direction);
|
2016-11-11 10:50:09 -08:00
|
|
|
|
2017-01-15 15:16:10 -08:00
|
|
|
YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(float, Margin, margin);
|
2017-01-26 13:36:38 -08:00
|
|
|
YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(float, Border, border);
|
2017-01-15 15:16:10 -08:00
|
|
|
YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(float, Padding, padding);
|
2017-01-05 12:48:07 -08:00
|
|
|
|
2016-11-11 10:50:09 -08:00
|
|
|
uint32_t gCurrentGenerationCount = 0;
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
bool YGLayoutNodeInternal(const YGNodeRef node,
|
|
|
|
const float availableWidth,
|
|
|
|
const float availableHeight,
|
|
|
|
const YGDirection parentDirection,
|
|
|
|
const YGMeasureMode widthMeasureMode,
|
|
|
|
const YGMeasureMode heightMeasureMode,
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
const float parentWidth,
|
|
|
|
const float parentHeight,
|
2016-12-03 04:40:18 -08:00
|
|
|
const bool performLayout,
|
2017-03-01 09:19:55 -08:00
|
|
|
const char *reason,
|
|
|
|
const YGConfigRef config);
|
2016-11-11 10:50:09 -08:00
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
inline bool YGFloatIsUndefined(const float value) {
|
2016-11-11 10:50:09 -08:00
|
|
|
return isnan(value);
|
|
|
|
}
|
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
static inline bool YGValueEqual(const YGValue a, const YGValue b) {
|
|
|
|
if (a.unit != b.unit) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (a.unit == YGUnitUndefined) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return fabs(a.value - b.value) < 0.0001f;
|
|
|
|
}
|
|
|
|
|
2017-02-06 14:36:27 -08:00
|
|
|
static inline void YGResolveDimensions(YGNodeRef node) {
|
|
|
|
for (YGDimension dim = YGDimensionWidth; dim <= YGDimensionHeight; dim++) {
|
2017-02-11 05:26:55 -08:00
|
|
|
if (node->style.maxDimensions[dim].unit != YGUnitUndefined &&
|
|
|
|
YGValueEqual(node->style.maxDimensions[dim], node->style.minDimensions[dim])) {
|
2017-02-11 08:32:50 -08:00
|
|
|
node->resolvedDimensions[dim] = &node->style.maxDimensions[dim];
|
2017-02-06 14:36:27 -08:00
|
|
|
} else {
|
2017-02-11 08:32:50 -08:00
|
|
|
node->resolvedDimensions[dim] = &node->style.dimensions[dim];
|
2017-02-06 14:36:27 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
static inline bool YGFloatsEqual(const float a, const float b) {
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
if (YGFloatIsUndefined(a)) {
|
|
|
|
return YGFloatIsUndefined(b);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
return fabs(a - b) < 0.0001f;
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
static void YGIndent(const uint32_t n) {
|
2016-11-11 10:50:09 -08:00
|
|
|
for (uint32_t i = 0; i < n; i++) {
|
2016-12-03 04:40:18 -08:00
|
|
|
YGLog(YGLogLevelDebug, " ");
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
static void YGPrintNumberIfNotUndefinedf(const char *str, const float number) {
|
|
|
|
if (!YGFloatIsUndefined(number)) {
|
2017-04-03 09:34:42 -07:00
|
|
|
YGLog(YGLogLevelDebug, "%s: %g; ", str, number);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
static void YGPrintNumberIfNotUndefined(const char *str, const YGValue *const number) {
|
|
|
|
if (number->unit != YGUnitUndefined) {
|
2017-04-03 09:34:42 -07:00
|
|
|
if (number->unit == YGUnitAuto) {
|
|
|
|
YGLog(YGLogLevelDebug, "%s: auto; ", str);
|
|
|
|
} else {
|
|
|
|
const char *unit = number->unit == YGUnitPoint ? "px" : "%";
|
|
|
|
YGLog(YGLogLevelDebug, "%s: %g%s; ", str, number->value, unit);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void YGPrintNumberIfNotAuto(const char *str, const YGValue *const number) {
|
|
|
|
if (number->unit != YGUnitAuto) {
|
|
|
|
YGPrintNumberIfNotUndefined(str, number);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void YGPrintEdgeIfNotUndefined(const char *str, const YGValue *edges, const YGEdge edge) {
|
|
|
|
YGPrintNumberIfNotUndefined(str, YGComputedEdgeValue(edges, YGEdgeLeft, &YGValueUndefined));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void YGPrintNumberIfNotZero(const char *str, const YGValue *const number) {
|
|
|
|
if (!YGFloatsEqual(number->value, 0)) {
|
|
|
|
YGPrintNumberIfNotUndefined(str, number);
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool YGFourValuesEqual(const YGValue four[4]) {
|
|
|
|
return YGValueEqual(four[0], four[1]) && YGValueEqual(four[0], four[2]) &&
|
|
|
|
YGValueEqual(four[0], four[3]);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2017-04-03 09:34:42 -07:00
|
|
|
static void YGPrintEdges(const char *str, const YGValue *edges) {
|
|
|
|
if (YGFourValuesEqual(edges)) {
|
|
|
|
YGPrintNumberIfNotZero(str, &edges[YGEdgeLeft]);
|
|
|
|
} else {
|
|
|
|
for (YGEdge edge = YGEdgeLeft; edge < YGEdgeCount; edge++) {
|
|
|
|
char buf[30];
|
|
|
|
snprintf(buf, sizeof(buf), "%s-%s", str, YGEdgeToString(edge));
|
|
|
|
YGPrintNumberIfNotZero(buf, &edges[edge]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
static void YGNodePrintInternal(const YGNodeRef node,
|
|
|
|
const YGPrintOptions options,
|
|
|
|
const uint32_t level) {
|
|
|
|
YGIndent(level);
|
2017-04-03 09:34:42 -07:00
|
|
|
YGLog(YGLogLevelDebug, "<div ");
|
2016-11-11 10:50:09 -08:00
|
|
|
|
|
|
|
if (node->print) {
|
|
|
|
node->print(node);
|
|
|
|
}
|
|
|
|
|
2016-12-02 05:47:43 -08:00
|
|
|
if (options & YGPrintOptionsLayout) {
|
2017-04-03 09:34:42 -07:00
|
|
|
YGLog(YGLogLevelDebug, "layout=\"");
|
|
|
|
YGLog(YGLogLevelDebug, "width: %g; ", node->layout.dimensions[YGDimensionWidth]);
|
|
|
|
YGLog(YGLogLevelDebug, "height: %g; ", node->layout.dimensions[YGDimensionHeight]);
|
|
|
|
YGLog(YGLogLevelDebug, "top: %g; ", node->layout.position[YGEdgeTop]);
|
|
|
|
YGLog(YGLogLevelDebug, "left: %g;", node->layout.position[YGEdgeLeft]);
|
|
|
|
YGLog(YGLogLevelDebug, "\" ");
|
2016-12-02 05:47:43 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (options & YGPrintOptionsStyle) {
|
2017-04-03 09:34:42 -07:00
|
|
|
YGLog(YGLogLevelDebug, "style=\"");
|
|
|
|
if (node->style.flexDirection != gYGNodeDefaults.style.flexDirection) {
|
|
|
|
YGLog(YGLogLevelDebug,
|
|
|
|
"flex-direction: %s; ",
|
|
|
|
YGFlexDirectionToString(node->style.flexDirection));
|
|
|
|
}
|
|
|
|
if (node->style.justifyContent != gYGNodeDefaults.style.justifyContent) {
|
|
|
|
YGLog(YGLogLevelDebug,
|
|
|
|
"justify-content: %s; ",
|
|
|
|
YGJustifyToString(node->style.justifyContent));
|
|
|
|
}
|
|
|
|
if (node->style.alignItems != gYGNodeDefaults.style.alignItems) {
|
|
|
|
YGLog(YGLogLevelDebug, "align-items: %s; ", YGAlignToString(node->style.alignItems));
|
|
|
|
}
|
|
|
|
if (node->style.alignContent != gYGNodeDefaults.style.alignContent) {
|
|
|
|
YGLog(YGLogLevelDebug, "align-content: %s; ", YGAlignToString(node->style.alignContent));
|
|
|
|
}
|
|
|
|
if (node->style.alignSelf != gYGNodeDefaults.style.alignSelf) {
|
|
|
|
YGLog(YGLogLevelDebug, "align-self: %s; ", YGAlignToString(node->style.alignSelf));
|
|
|
|
}
|
|
|
|
|
|
|
|
YGPrintNumberIfNotUndefinedf("flex-grow", node->style.flexGrow);
|
|
|
|
YGPrintNumberIfNotUndefinedf("flex-shrink", node->style.flexShrink);
|
|
|
|
YGPrintNumberIfNotAuto("flex-basis", &node->style.flexBasis);
|
|
|
|
YGPrintNumberIfNotUndefinedf("flex", node->style.flex);
|
|
|
|
|
|
|
|
if (node->style.flexWrap != gYGNodeDefaults.style.flexWrap) {
|
|
|
|
YGLog(YGLogLevelDebug, "flexWrap: %s; ", YGWrapToString(node->style.flexWrap));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (node->style.overflow != gYGNodeDefaults.style.overflow) {
|
|
|
|
YGLog(YGLogLevelDebug, "overflow: %s; ", YGOverflowToString(node->style.overflow));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (node->style.display != gYGNodeDefaults.style.display) {
|
|
|
|
YGLog(YGLogLevelDebug, "display: %s; ", YGDisplayToString(node->style.display));
|
|
|
|
}
|
|
|
|
|
|
|
|
YGPrintEdges("margin", node->style.margin);
|
|
|
|
YGPrintEdges("padding", node->style.padding);
|
|
|
|
YGPrintEdges("border", node->style.border);
|
|
|
|
|
|
|
|
YGPrintNumberIfNotAuto("width", &node->style.dimensions[YGDimensionWidth]);
|
|
|
|
YGPrintNumberIfNotAuto("height", &node->style.dimensions[YGDimensionHeight]);
|
|
|
|
YGPrintNumberIfNotAuto("max-width", &node->style.maxDimensions[YGDimensionWidth]);
|
|
|
|
YGPrintNumberIfNotAuto("max-height", &node->style.maxDimensions[YGDimensionHeight]);
|
|
|
|
YGPrintNumberIfNotAuto("min-width", &node->style.minDimensions[YGDimensionWidth]);
|
|
|
|
YGPrintNumberIfNotAuto("min-height", &node->style.minDimensions[YGDimensionHeight]);
|
|
|
|
|
|
|
|
if (node->style.positionType != gYGNodeDefaults.style.positionType) {
|
|
|
|
YGLog(YGLogLevelDebug, "position: %s; ", YGPositionTypeToString(node->style.positionType));
|
|
|
|
}
|
|
|
|
|
|
|
|
YGPrintEdgeIfNotUndefined("left", node->style.position, YGEdgeLeft);
|
|
|
|
YGPrintEdgeIfNotUndefined("right", node->style.position, YGEdgeRight);
|
|
|
|
YGPrintEdgeIfNotUndefined("top", node->style.position, YGEdgeTop);
|
|
|
|
YGPrintEdgeIfNotUndefined("bottom", node->style.position, YGEdgeBottom);
|
|
|
|
YGLog(YGLogLevelDebug, "\" ");
|
|
|
|
|
|
|
|
if (node->measure != NULL) {
|
|
|
|
YGLog(YGLogLevelDebug, "has-custom-measure=\"true\"");
|
|
|
|
}
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
2017-04-03 09:34:42 -07:00
|
|
|
YGLog(YGLogLevelDebug, ">");
|
2016-11-11 10:50:09 -08:00
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
const uint32_t childCount = YGNodeListCount(node->children);
|
2016-12-02 05:47:43 -08:00
|
|
|
if (options & YGPrintOptionsChildren && childCount > 0) {
|
2016-11-11 10:50:09 -08:00
|
|
|
for (uint32_t i = 0; i < childCount; i++) {
|
2017-04-03 09:34:42 -07:00
|
|
|
YGLog(YGLogLevelDebug, "\n");
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodePrintInternal(YGNodeGetChild(node, i), options, level + 1);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
2016-12-03 04:40:18 -08:00
|
|
|
YGIndent(level);
|
2017-04-03 09:34:42 -07:00
|
|
|
YGLog(YGLogLevelDebug, "\n");
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
2017-04-03 09:34:42 -07:00
|
|
|
YGLog(YGLogLevelDebug, "</div>");
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
void YGNodePrint(const YGNodeRef node, const YGPrintOptions options) {
|
|
|
|
YGNodePrintInternal(node, options, 0);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2016-12-02 05:47:43 -08:00
|
|
|
static const YGEdge leading[4] = {
|
|
|
|
[YGFlexDirectionColumn] = YGEdgeTop,
|
|
|
|
[YGFlexDirectionColumnReverse] = YGEdgeBottom,
|
|
|
|
[YGFlexDirectionRow] = YGEdgeLeft,
|
|
|
|
[YGFlexDirectionRowReverse] = YGEdgeRight,
|
2016-11-11 10:50:09 -08:00
|
|
|
};
|
2016-12-02 05:47:43 -08:00
|
|
|
static const YGEdge trailing[4] = {
|
|
|
|
[YGFlexDirectionColumn] = YGEdgeBottom,
|
|
|
|
[YGFlexDirectionColumnReverse] = YGEdgeTop,
|
|
|
|
[YGFlexDirectionRow] = YGEdgeRight,
|
|
|
|
[YGFlexDirectionRowReverse] = YGEdgeLeft,
|
2016-11-11 10:50:09 -08:00
|
|
|
};
|
2016-12-02 05:47:43 -08:00
|
|
|
static const YGEdge pos[4] = {
|
|
|
|
[YGFlexDirectionColumn] = YGEdgeTop,
|
|
|
|
[YGFlexDirectionColumnReverse] = YGEdgeBottom,
|
|
|
|
[YGFlexDirectionRow] = YGEdgeLeft,
|
|
|
|
[YGFlexDirectionRowReverse] = YGEdgeRight,
|
2016-11-11 10:50:09 -08:00
|
|
|
};
|
2016-12-02 05:47:43 -08:00
|
|
|
static const YGDimension dim[4] = {
|
|
|
|
[YGFlexDirectionColumn] = YGDimensionHeight,
|
|
|
|
[YGFlexDirectionColumnReverse] = YGDimensionHeight,
|
|
|
|
[YGFlexDirectionRow] = YGDimensionWidth,
|
|
|
|
[YGFlexDirectionRowReverse] = YGDimensionWidth,
|
2016-11-11 10:50:09 -08:00
|
|
|
};
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
static inline bool YGFlexDirectionIsRow(const YGFlexDirection flexDirection) {
|
2016-12-02 05:47:43 -08:00
|
|
|
return flexDirection == YGFlexDirectionRow || flexDirection == YGFlexDirectionRowReverse;
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
static inline bool YGFlexDirectionIsColumn(const YGFlexDirection flexDirection) {
|
2016-12-02 05:47:43 -08:00
|
|
|
return flexDirection == YGFlexDirectionColumn || flexDirection == YGFlexDirectionColumnReverse;
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
static inline float YGNodeLeadingMargin(const YGNodeRef node,
|
|
|
|
const YGFlexDirection axis,
|
|
|
|
const float widthSize) {
|
|
|
|
if (YGFlexDirectionIsRow(axis) && node->style.margin[YGEdgeStart].unit != YGUnitUndefined) {
|
2017-03-10 06:05:53 -08:00
|
|
|
return YGResolveValueMargin(&node->style.margin[YGEdgeStart], widthSize);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2017-03-10 06:05:53 -08:00
|
|
|
return YGResolveValueMargin(YGComputedEdgeValue(node->style.margin, leading[axis], &YGValueZero),
|
2017-02-14 14:26:09 -08:00
|
|
|
widthSize);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
static float YGNodeTrailingMargin(const YGNodeRef node,
|
|
|
|
const YGFlexDirection axis,
|
|
|
|
const float widthSize) {
|
|
|
|
if (YGFlexDirectionIsRow(axis) && node->style.margin[YGEdgeEnd].unit != YGUnitUndefined) {
|
2017-03-10 06:05:53 -08:00
|
|
|
return YGResolveValueMargin(&node->style.margin[YGEdgeEnd], widthSize);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2017-03-10 06:05:53 -08:00
|
|
|
return YGResolveValueMargin(YGComputedEdgeValue(node->style.margin, trailing[axis], &YGValueZero),
|
2017-02-14 14:26:09 -08:00
|
|
|
widthSize);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
static float YGNodeLeadingPadding(const YGNodeRef node,
|
|
|
|
const YGFlexDirection axis,
|
|
|
|
const float widthSize) {
|
|
|
|
if (YGFlexDirectionIsRow(axis) && node->style.padding[YGEdgeStart].unit != YGUnitUndefined &&
|
2017-03-10 06:05:53 -08:00
|
|
|
YGResolveValue(&node->style.padding[YGEdgeStart], widthSize) >= 0.0f) {
|
|
|
|
return YGResolveValue(&node->style.padding[YGEdgeStart], widthSize);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2017-03-10 06:05:53 -08:00
|
|
|
return fmaxf(YGResolveValue(YGComputedEdgeValue(node->style.padding, leading[axis], &YGValueZero),
|
2017-01-06 06:51:56 -08:00
|
|
|
widthSize),
|
|
|
|
0.0f);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
static float YGNodeTrailingPadding(const YGNodeRef node,
|
|
|
|
const YGFlexDirection axis,
|
|
|
|
const float widthSize) {
|
|
|
|
if (YGFlexDirectionIsRow(axis) && node->style.padding[YGEdgeEnd].unit != YGUnitUndefined &&
|
2017-03-10 06:05:53 -08:00
|
|
|
YGResolveValue(&node->style.padding[YGEdgeEnd], widthSize) >= 0.0f) {
|
|
|
|
return YGResolveValue(&node->style.padding[YGEdgeEnd], widthSize);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2017-03-10 06:05:53 -08:00
|
|
|
return fmaxf(YGResolveValue(YGComputedEdgeValue(node->style.padding, trailing[axis], &YGValueZero),
|
2017-01-06 06:51:56 -08:00
|
|
|
widthSize),
|
|
|
|
0.0f);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
static float YGNodeLeadingBorder(const YGNodeRef node, const YGFlexDirection axis) {
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
if (YGFlexDirectionIsRow(axis) && node->style.border[YGEdgeStart].unit != YGUnitUndefined &&
|
|
|
|
node->style.border[YGEdgeStart].value >= 0.0f) {
|
|
|
|
return node->style.border[YGEdgeStart].value;
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
return fmaxf(YGComputedEdgeValue(node->style.border, leading[axis], &YGValueZero)->value, 0.0f);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
static float YGNodeTrailingBorder(const YGNodeRef node, const YGFlexDirection axis) {
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
if (YGFlexDirectionIsRow(axis) && node->style.border[YGEdgeEnd].unit != YGUnitUndefined &&
|
|
|
|
node->style.border[YGEdgeEnd].value >= 0.0f) {
|
|
|
|
return node->style.border[YGEdgeEnd].value;
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
return fmaxf(YGComputedEdgeValue(node->style.border, trailing[axis], &YGValueZero)->value, 0.0f);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
static inline float YGNodeLeadingPaddingAndBorder(const YGNodeRef node,
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
const YGFlexDirection axis,
|
|
|
|
const float widthSize) {
|
|
|
|
return YGNodeLeadingPadding(node, axis, widthSize) + YGNodeLeadingBorder(node, axis);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
static inline float YGNodeTrailingPaddingAndBorder(const YGNodeRef node,
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
const YGFlexDirection axis,
|
|
|
|
const float widthSize) {
|
|
|
|
return YGNodeTrailingPadding(node, axis, widthSize) + YGNodeTrailingBorder(node, axis);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
static inline float YGNodeMarginForAxis(const YGNodeRef node,
|
|
|
|
const YGFlexDirection axis,
|
|
|
|
const float widthSize) {
|
|
|
|
return YGNodeLeadingMargin(node, axis, widthSize) + YGNodeTrailingMargin(node, axis, widthSize);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
static inline float YGNodePaddingAndBorderForAxis(const YGNodeRef node,
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
const YGFlexDirection axis,
|
|
|
|
const float widthSize) {
|
|
|
|
return YGNodeLeadingPaddingAndBorder(node, axis, widthSize) +
|
|
|
|
YGNodeTrailingPaddingAndBorder(node, axis, widthSize);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
static inline YGAlign YGNodeAlignItem(const YGNodeRef node, const YGNodeRef child) {
|
2017-01-06 06:51:56 -08:00
|
|
|
const YGAlign align =
|
|
|
|
child->style.alignSelf == YGAlignAuto ? node->style.alignItems : child->style.alignSelf;
|
|
|
|
if (align == YGAlignBaseline && YGFlexDirectionIsColumn(node->style.flexDirection)) {
|
|
|
|
return YGAlignFlexStart;
|
|
|
|
}
|
|
|
|
return align;
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
static inline YGDirection YGNodeResolveDirection(const YGNodeRef node,
|
|
|
|
const YGDirection parentDirection) {
|
2016-12-02 05:47:43 -08:00
|
|
|
if (node->style.direction == YGDirectionInherit) {
|
|
|
|
return parentDirection > YGDirectionInherit ? parentDirection : YGDirectionLTR;
|
2016-11-11 10:50:09 -08:00
|
|
|
} else {
|
|
|
|
return node->style.direction;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-06 06:51:56 -08:00
|
|
|
static float YGBaseline(const YGNodeRef node) {
|
|
|
|
if (node->baseline != NULL) {
|
2017-01-16 11:08:46 -08:00
|
|
|
const float baseline = node->baseline(node,
|
|
|
|
node->layout.measuredDimensions[YGDimensionWidth],
|
|
|
|
node->layout.measuredDimensions[YGDimensionHeight]);
|
2017-01-06 06:51:56 -08:00
|
|
|
YG_ASSERT(!YGFloatIsUndefined(baseline), "Expect custom baseline function to not return NaN")
|
|
|
|
return baseline;
|
|
|
|
}
|
|
|
|
|
|
|
|
YGNodeRef baselineChild = NULL;
|
2017-02-15 13:35:24 -08:00
|
|
|
const uint32_t childCount = YGNodeGetChildCount(node);
|
|
|
|
for (uint32_t i = 0; i < childCount; i++) {
|
2017-01-06 06:51:56 -08:00
|
|
|
const YGNodeRef child = YGNodeGetChild(node, i);
|
|
|
|
if (child->lineIndex > 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (child->style.positionType == YGPositionTypeAbsolute) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (YGNodeAlignItem(node, child) == YGAlignBaseline) {
|
|
|
|
baselineChild = child;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (baselineChild == NULL) {
|
|
|
|
baselineChild = child;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (baselineChild == NULL) {
|
|
|
|
return node->layout.measuredDimensions[YGDimensionHeight];
|
|
|
|
}
|
|
|
|
|
|
|
|
const float baseline = YGBaseline(baselineChild);
|
|
|
|
return baseline + baselineChild->layout.position[YGEdgeTop];
|
|
|
|
}
|
|
|
|
|
2017-03-10 06:05:53 -08:00
|
|
|
static inline YGFlexDirection YGResolveFlexDirection(const YGFlexDirection flexDirection,
|
2016-12-03 04:40:18 -08:00
|
|
|
const YGDirection direction) {
|
2016-12-02 05:47:43 -08:00
|
|
|
if (direction == YGDirectionRTL) {
|
|
|
|
if (flexDirection == YGFlexDirectionRow) {
|
|
|
|
return YGFlexDirectionRowReverse;
|
|
|
|
} else if (flexDirection == YGFlexDirectionRowReverse) {
|
|
|
|
return YGFlexDirectionRow;
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return flexDirection;
|
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
static YGFlexDirection YGFlexDirectionCross(const YGFlexDirection flexDirection,
|
|
|
|
const YGDirection direction) {
|
|
|
|
return YGFlexDirectionIsColumn(flexDirection)
|
2017-03-10 06:05:53 -08:00
|
|
|
? YGResolveFlexDirection(YGFlexDirectionRow, direction)
|
2016-12-03 04:40:18 -08:00
|
|
|
: YGFlexDirectionColumn;
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
static inline bool YGNodeIsFlex(const YGNodeRef node) {
|
2016-12-02 05:47:43 -08:00
|
|
|
return (node->style.positionType == YGPositionTypeRelative &&
|
2017-02-28 09:17:17 -08:00
|
|
|
(YGResolveFlexGrow(node) != 0 || YGNodeResolveFlexShrink(node) != 0));
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2017-01-06 06:51:56 -08:00
|
|
|
static bool YGIsBaselineLayout(const YGNodeRef node) {
|
|
|
|
if (YGFlexDirectionIsColumn(node->style.flexDirection)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (node->style.alignItems == YGAlignBaseline) {
|
|
|
|
return true;
|
|
|
|
}
|
2017-02-15 13:35:24 -08:00
|
|
|
const uint32_t childCount = YGNodeGetChildCount(node);
|
|
|
|
for (uint32_t i = 0; i < childCount; i++) {
|
2017-01-06 06:51:56 -08:00
|
|
|
const YGNodeRef child = YGNodeGetChild(node, i);
|
|
|
|
if (child->style.positionType == YGPositionTypeRelative &&
|
|
|
|
child->style.alignSelf == YGAlignBaseline) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
static inline float YGNodeDimWithMargin(const YGNodeRef node,
|
|
|
|
const YGFlexDirection axis,
|
|
|
|
const float widthSize) {
|
|
|
|
return node->layout.measuredDimensions[dim[axis]] + YGNodeLeadingMargin(node, axis, widthSize) +
|
|
|
|
YGNodeTrailingMargin(node, axis, widthSize);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2017-02-03 05:37:44 -08:00
|
|
|
static inline bool YGNodeIsStyleDimDefined(const YGNodeRef node,
|
|
|
|
const YGFlexDirection axis,
|
|
|
|
const float parentSize) {
|
2017-02-14 14:26:09 -08:00
|
|
|
return !(node->resolvedDimensions[dim[axis]]->unit == YGUnitAuto ||
|
|
|
|
node->resolvedDimensions[dim[axis]]->unit == YGUnitUndefined ||
|
2017-02-14 14:26:13 -08:00
|
|
|
(node->resolvedDimensions[dim[axis]]->unit == YGUnitPoint &&
|
2017-02-11 08:32:50 -08:00
|
|
|
node->resolvedDimensions[dim[axis]]->value < 0.0f) ||
|
|
|
|
(node->resolvedDimensions[dim[axis]]->unit == YGUnitPercent &&
|
|
|
|
(node->resolvedDimensions[dim[axis]]->value < 0.0f || YGFloatIsUndefined(parentSize))));
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
static inline bool YGNodeIsLayoutDimDefined(const YGNodeRef node, const YGFlexDirection axis) {
|
2016-11-11 10:50:09 -08:00
|
|
|
const float value = node->layout.measuredDimensions[dim[axis]];
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
return !YGFloatIsUndefined(value) && value >= 0.0f;
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
static inline bool YGNodeIsLeadingPosDefined(const YGNodeRef node, const YGFlexDirection axis) {
|
|
|
|
return (YGFlexDirectionIsRow(axis) &&
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
YGComputedEdgeValue(node->style.position, YGEdgeStart, &YGValueUndefined)->unit !=
|
|
|
|
YGUnitUndefined) ||
|
|
|
|
YGComputedEdgeValue(node->style.position, leading[axis], &YGValueUndefined)->unit !=
|
|
|
|
YGUnitUndefined;
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
static inline bool YGNodeIsTrailingPosDefined(const YGNodeRef node, const YGFlexDirection axis) {
|
|
|
|
return (YGFlexDirectionIsRow(axis) &&
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
YGComputedEdgeValue(node->style.position, YGEdgeEnd, &YGValueUndefined)->unit !=
|
|
|
|
YGUnitUndefined) ||
|
|
|
|
YGComputedEdgeValue(node->style.position, trailing[axis], &YGValueUndefined)->unit !=
|
|
|
|
YGUnitUndefined;
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
static float YGNodeLeadingPosition(const YGNodeRef node,
|
|
|
|
const YGFlexDirection axis,
|
|
|
|
const float axisSize) {
|
2016-12-03 04:40:18 -08:00
|
|
|
if (YGFlexDirectionIsRow(axis)) {
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
const YGValue *leadingPosition =
|
|
|
|
YGComputedEdgeValue(node->style.position, YGEdgeStart, &YGValueUndefined);
|
|
|
|
if (leadingPosition->unit != YGUnitUndefined) {
|
2017-03-10 06:05:53 -08:00
|
|
|
return YGResolveValue(leadingPosition, axisSize);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
const YGValue *leadingPosition =
|
|
|
|
YGComputedEdgeValue(node->style.position, leading[axis], &YGValueUndefined);
|
2016-11-11 10:50:09 -08:00
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
return leadingPosition->unit == YGUnitUndefined ? 0.0f
|
2017-03-10 06:05:53 -08:00
|
|
|
: YGResolveValue(leadingPosition, axisSize);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
static float YGNodeTrailingPosition(const YGNodeRef node,
|
|
|
|
const YGFlexDirection axis,
|
|
|
|
const float axisSize) {
|
2016-12-03 04:40:18 -08:00
|
|
|
if (YGFlexDirectionIsRow(axis)) {
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
const YGValue *trailingPosition =
|
|
|
|
YGComputedEdgeValue(node->style.position, YGEdgeEnd, &YGValueUndefined);
|
|
|
|
if (trailingPosition->unit != YGUnitUndefined) {
|
2017-03-10 06:05:53 -08:00
|
|
|
return YGResolveValue(trailingPosition, axisSize);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
const YGValue *trailingPosition =
|
|
|
|
YGComputedEdgeValue(node->style.position, trailing[axis], &YGValueUndefined);
|
2016-11-11 10:50:09 -08:00
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
return trailingPosition->unit == YGUnitUndefined ? 0.0f
|
2017-03-10 06:05:53 -08:00
|
|
|
: YGResolveValue(trailingPosition, axisSize);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
static float YGNodeBoundAxisWithinMinAndMax(const YGNodeRef node,
|
|
|
|
const YGFlexDirection axis,
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
const float value,
|
|
|
|
const float axisSize) {
|
2016-12-02 05:47:43 -08:00
|
|
|
float min = YGUndefined;
|
|
|
|
float max = YGUndefined;
|
2017-02-11 05:26:55 -08:00
|
|
|
|
|
|
|
if (YGFlexDirectionIsColumn(axis)) {
|
2017-03-10 06:05:53 -08:00
|
|
|
min = YGResolveValue(&node->style.minDimensions[YGDimensionHeight], axisSize);
|
|
|
|
max = YGResolveValue(&node->style.maxDimensions[YGDimensionHeight], axisSize);
|
2017-02-11 05:26:55 -08:00
|
|
|
} else if (YGFlexDirectionIsRow(axis)) {
|
2017-03-10 06:05:53 -08:00
|
|
|
min = YGResolveValue(&node->style.minDimensions[YGDimensionWidth], axisSize);
|
|
|
|
max = YGResolveValue(&node->style.maxDimensions[YGDimensionWidth], axisSize);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
float boundValue = value;
|
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
if (!YGFloatIsUndefined(max) && max >= 0.0f && boundValue > max) {
|
2016-11-11 10:50:09 -08:00
|
|
|
boundValue = max;
|
|
|
|
}
|
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
if (!YGFloatIsUndefined(min) && min >= 0.0f && boundValue < min) {
|
2016-11-11 10:50:09 -08:00
|
|
|
boundValue = min;
|
|
|
|
}
|
|
|
|
|
|
|
|
return boundValue;
|
|
|
|
}
|
|
|
|
|
2017-03-01 09:12:40 -08:00
|
|
|
static inline YGValue *YGMarginLeadingValue(const YGNodeRef node, const YGFlexDirection axis) {
|
|
|
|
if (YGFlexDirectionIsRow(axis) && node->style.margin[YGEdgeStart].unit != YGUnitUndefined) {
|
|
|
|
return &node->style.margin[YGEdgeStart];
|
|
|
|
} else {
|
|
|
|
return &node->style.margin[leading[axis]];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline YGValue *YGMarginTrailingValue(const YGNodeRef node, const YGFlexDirection axis) {
|
|
|
|
if (YGFlexDirectionIsRow(axis) && node->style.margin[YGEdgeEnd].unit != YGUnitUndefined) {
|
|
|
|
return &node->style.margin[YGEdgeEnd];
|
|
|
|
} else {
|
|
|
|
return &node->style.margin[trailing[axis]];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
// Like YGNodeBoundAxisWithinMinAndMax but also ensures that the value doesn't go
|
2016-11-11 10:50:09 -08:00
|
|
|
// below the
|
|
|
|
// padding and border amount.
|
2016-12-03 04:40:18 -08:00
|
|
|
static inline float YGNodeBoundAxis(const YGNodeRef node,
|
|
|
|
const YGFlexDirection axis,
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
const float value,
|
|
|
|
const float axisSize,
|
|
|
|
const float widthSize) {
|
|
|
|
return fmaxf(YGNodeBoundAxisWithinMinAndMax(node, axis, value, axisSize),
|
|
|
|
YGNodePaddingAndBorderForAxis(node, axis, widthSize));
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
static void YGNodeSetChildTrailingPosition(const YGNodeRef node,
|
|
|
|
const YGNodeRef child,
|
|
|
|
const YGFlexDirection axis) {
|
2016-11-11 10:50:09 -08:00
|
|
|
const float size = child->layout.measuredDimensions[dim[axis]];
|
|
|
|
child->layout.position[trailing[axis]] =
|
|
|
|
node->layout.measuredDimensions[dim[axis]] - size - child->layout.position[pos[axis]];
|
|
|
|
}
|
|
|
|
|
|
|
|
// If both left and right are defined, then use left. Otherwise return
|
|
|
|
// +left or -right depending on which is defined.
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
static float YGNodeRelativePosition(const YGNodeRef node,
|
|
|
|
const YGFlexDirection axis,
|
|
|
|
const float axisSize) {
|
|
|
|
return YGNodeIsLeadingPosDefined(node, axis) ? YGNodeLeadingPosition(node, axis, axisSize)
|
|
|
|
: -YGNodeTrailingPosition(node, axis, axisSize);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2017-03-09 03:48:33 -08:00
|
|
|
static void YGConstrainMaxSizeForMode(const YGNodeRef node,
|
|
|
|
const enum YGFlexDirection axis,
|
|
|
|
const float parentAxisSize,
|
|
|
|
const float parentWidth,
|
|
|
|
YGMeasureMode *mode,
|
|
|
|
float *size) {
|
2017-03-10 06:05:53 -08:00
|
|
|
const float maxSize = YGResolveValue(&node->style.maxDimensions[dim[axis]], parentAxisSize) +
|
2017-03-09 03:48:33 -08:00
|
|
|
YGNodeMarginForAxis(node, axis, parentWidth);
|
2016-11-11 10:50:09 -08:00
|
|
|
switch (*mode) {
|
2016-12-02 05:47:43 -08:00
|
|
|
case YGMeasureModeExactly:
|
|
|
|
case YGMeasureModeAtMost:
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
*size = (YGFloatIsUndefined(maxSize) || *size < maxSize) ? *size : maxSize;
|
2016-11-11 10:50:09 -08:00
|
|
|
break;
|
2016-12-02 05:47:43 -08:00
|
|
|
case YGMeasureModeUndefined:
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
if (!YGFloatIsUndefined(maxSize)) {
|
2016-12-02 05:47:43 -08:00
|
|
|
*mode = YGMeasureModeAtMost;
|
2016-11-11 10:50:09 -08:00
|
|
|
*size = maxSize;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
static void YGNodeSetPosition(const YGNodeRef node,
|
|
|
|
const YGDirection direction,
|
|
|
|
const float mainSize,
|
|
|
|
const float crossSize,
|
|
|
|
const float parentWidth) {
|
2017-04-11 13:00:02 -07:00
|
|
|
/* Root nodes should be always layouted as LTR, so we don't return negative values. */
|
|
|
|
const YGDirection directionRespectingRoot = node->parent != NULL ? direction : YGDirectionLTR;
|
|
|
|
const YGFlexDirection mainAxis =
|
|
|
|
YGResolveFlexDirection(node->style.flexDirection, directionRespectingRoot);
|
|
|
|
const YGFlexDirection crossAxis = YGFlexDirectionCross(mainAxis, directionRespectingRoot);
|
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
const float relativePositionMain = YGNodeRelativePosition(node, mainAxis, mainSize);
|
|
|
|
const float relativePositionCross = YGNodeRelativePosition(node, crossAxis, crossSize);
|
2016-11-11 10:50:09 -08:00
|
|
|
|
|
|
|
node->layout.position[leading[mainAxis]] =
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
YGNodeLeadingMargin(node, mainAxis, parentWidth) + relativePositionMain;
|
2016-11-11 10:50:09 -08:00
|
|
|
node->layout.position[trailing[mainAxis]] =
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
YGNodeTrailingMargin(node, mainAxis, parentWidth) + relativePositionMain;
|
2016-11-11 10:50:09 -08:00
|
|
|
node->layout.position[leading[crossAxis]] =
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
YGNodeLeadingMargin(node, crossAxis, parentWidth) + relativePositionCross;
|
2016-11-11 10:50:09 -08:00
|
|
|
node->layout.position[trailing[crossAxis]] =
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
YGNodeTrailingMargin(node, crossAxis, parentWidth) + relativePositionCross;
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
static void YGNodeComputeFlexBasisForChild(const YGNodeRef node,
|
|
|
|
const YGNodeRef child,
|
|
|
|
const float width,
|
|
|
|
const YGMeasureMode widthMode,
|
|
|
|
const float height,
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
const float parentWidth,
|
|
|
|
const float parentHeight,
|
2016-12-03 04:40:18 -08:00
|
|
|
const YGMeasureMode heightMode,
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGDirection direction,
|
|
|
|
const YGConfigRef config) {
|
2017-03-10 06:05:53 -08:00
|
|
|
const YGFlexDirection mainAxis = YGResolveFlexDirection(node->style.flexDirection, direction);
|
2016-12-03 04:40:18 -08:00
|
|
|
const bool isMainAxisRow = YGFlexDirectionIsRow(mainAxis);
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
const float mainAxisSize = isMainAxisRow ? width : height;
|
|
|
|
const float mainAxisParentSize = isMainAxisRow ? parentWidth : parentHeight;
|
2016-11-11 10:50:09 -08:00
|
|
|
|
|
|
|
float childWidth;
|
|
|
|
float childHeight;
|
2016-12-02 05:47:43 -08:00
|
|
|
YGMeasureMode childWidthMeasureMode;
|
|
|
|
YGMeasureMode childHeightMeasureMode;
|
2016-11-11 10:50:09 -08:00
|
|
|
|
2017-02-03 05:37:44 -08:00
|
|
|
const float resolvedFlexBasis =
|
2017-03-10 06:05:53 -08:00
|
|
|
YGResolveValue(YGNodeResolveFlexBasisPtr(child), mainAxisParentSize);
|
2017-02-03 05:37:44 -08:00
|
|
|
const bool isRowStyleDimDefined = YGNodeIsStyleDimDefined(child, YGFlexDirectionRow, parentWidth);
|
|
|
|
const bool isColumnStyleDimDefined =
|
|
|
|
YGNodeIsStyleDimDefined(child, YGFlexDirectionColumn, parentHeight);
|
2016-11-11 10:50:09 -08:00
|
|
|
|
2017-02-03 05:37:44 -08:00
|
|
|
if (!YGFloatIsUndefined(resolvedFlexBasis) && !YGFloatIsUndefined(mainAxisSize)) {
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
if (YGFloatIsUndefined(child->layout.computedFlexBasis) ||
|
2017-03-09 07:21:23 -08:00
|
|
|
(YGConfigIsExperimentalFeatureEnabled(child->config, YGExperimentalFeatureWebFlexBasis) &&
|
2016-11-23 05:25:50 -08:00
|
|
|
child->layout.computedFlexBasisGeneration != gCurrentGenerationCount)) {
|
2016-11-11 10:50:09 -08:00
|
|
|
child->layout.computedFlexBasis =
|
2017-02-03 05:37:44 -08:00
|
|
|
fmaxf(resolvedFlexBasis, YGNodePaddingAndBorderForAxis(child, mainAxis, parentWidth));
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
} else if (isMainAxisRow && isRowStyleDimDefined) {
|
|
|
|
// The width is definite, so use that as the flex basis.
|
2016-12-03 04:40:18 -08:00
|
|
|
child->layout.computedFlexBasis =
|
2017-03-10 06:05:53 -08:00
|
|
|
fmaxf(YGResolveValue(child->resolvedDimensions[YGDimensionWidth], parentWidth),
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
YGNodePaddingAndBorderForAxis(child, YGFlexDirectionRow, parentWidth));
|
2016-11-11 10:50:09 -08:00
|
|
|
} else if (!isMainAxisRow && isColumnStyleDimDefined) {
|
|
|
|
// The height is definite, so use that as the flex basis.
|
2016-12-03 04:40:18 -08:00
|
|
|
child->layout.computedFlexBasis =
|
2017-03-10 06:05:53 -08:00
|
|
|
fmaxf(YGResolveValue(child->resolvedDimensions[YGDimensionHeight], parentHeight),
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
YGNodePaddingAndBorderForAxis(child, YGFlexDirectionColumn, parentWidth));
|
2016-11-11 10:50:09 -08:00
|
|
|
} else {
|
|
|
|
// Compute the flex basis and hypothetical main size (i.e. the clamped
|
|
|
|
// flex basis).
|
2016-12-02 05:47:43 -08:00
|
|
|
childWidth = YGUndefined;
|
|
|
|
childHeight = YGUndefined;
|
|
|
|
childWidthMeasureMode = YGMeasureModeUndefined;
|
|
|
|
childHeightMeasureMode = YGMeasureModeUndefined;
|
2016-11-11 10:50:09 -08:00
|
|
|
|
2017-01-27 09:56:35 -08:00
|
|
|
const float marginRow = YGNodeMarginForAxis(child, YGFlexDirectionRow, parentWidth);
|
|
|
|
const float marginColumn = YGNodeMarginForAxis(child, YGFlexDirectionColumn, parentWidth);
|
|
|
|
|
2016-11-11 10:50:09 -08:00
|
|
|
if (isRowStyleDimDefined) {
|
2017-01-27 09:56:35 -08:00
|
|
|
childWidth =
|
2017-03-10 06:05:53 -08:00
|
|
|
YGResolveValue(child->resolvedDimensions[YGDimensionWidth], parentWidth) + marginRow;
|
2016-12-02 05:47:43 -08:00
|
|
|
childWidthMeasureMode = YGMeasureModeExactly;
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
if (isColumnStyleDimDefined) {
|
2017-02-11 08:32:50 -08:00
|
|
|
childHeight =
|
2017-03-10 06:05:53 -08:00
|
|
|
YGResolveValue(child->resolvedDimensions[YGDimensionHeight], parentHeight) + marginColumn;
|
2016-12-02 05:47:43 -08:00
|
|
|
childHeightMeasureMode = YGMeasureModeExactly;
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// The W3C spec doesn't say anything about the 'overflow' property,
|
|
|
|
// but all major browsers appear to implement the following logic.
|
2016-12-02 05:47:43 -08:00
|
|
|
if ((!isMainAxisRow && node->style.overflow == YGOverflowScroll) ||
|
|
|
|
node->style.overflow != YGOverflowScroll) {
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
if (YGFloatIsUndefined(childWidth) && !YGFloatIsUndefined(width)) {
|
2016-11-11 10:50:09 -08:00
|
|
|
childWidth = width;
|
2016-12-02 05:47:43 -08:00
|
|
|
childWidthMeasureMode = YGMeasureModeAtMost;
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-02 05:47:43 -08:00
|
|
|
if ((isMainAxisRow && node->style.overflow == YGOverflowScroll) ||
|
|
|
|
node->style.overflow != YGOverflowScroll) {
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
if (YGFloatIsUndefined(childHeight) && !YGFloatIsUndefined(height)) {
|
2016-11-11 10:50:09 -08:00
|
|
|
childHeight = height;
|
2016-12-02 05:47:43 -08:00
|
|
|
childHeightMeasureMode = YGMeasureModeAtMost;
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// If child has no defined size in the cross axis and is set to stretch,
|
|
|
|
// set the cross
|
|
|
|
// axis to be measured exactly with the available inner width
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
if (!isMainAxisRow && !YGFloatIsUndefined(width) && !isRowStyleDimDefined &&
|
2016-12-03 04:40:18 -08:00
|
|
|
widthMode == YGMeasureModeExactly && YGNodeAlignItem(node, child) == YGAlignStretch) {
|
2016-11-11 10:50:09 -08:00
|
|
|
childWidth = width;
|
2016-12-02 05:47:43 -08:00
|
|
|
childWidthMeasureMode = YGMeasureModeExactly;
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
if (isMainAxisRow && !YGFloatIsUndefined(height) && !isColumnStyleDimDefined &&
|
2016-12-03 04:40:18 -08:00
|
|
|
heightMode == YGMeasureModeExactly && YGNodeAlignItem(node, child) == YGAlignStretch) {
|
2016-11-11 10:50:09 -08:00
|
|
|
childHeight = height;
|
2016-12-02 05:47:43 -08:00
|
|
|
childHeightMeasureMode = YGMeasureModeExactly;
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
if (!YGFloatIsUndefined(child->style.aspectRatio)) {
|
2016-12-02 05:47:43 -08:00
|
|
|
if (!isMainAxisRow && childWidthMeasureMode == YGMeasureModeExactly) {
|
2016-11-21 10:12:26 -08:00
|
|
|
child->layout.computedFlexBasis =
|
2017-01-27 09:56:35 -08:00
|
|
|
fmaxf((childWidth - marginRow) / child->style.aspectRatio,
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
YGNodePaddingAndBorderForAxis(child, YGFlexDirectionColumn, parentWidth));
|
2016-11-21 10:12:26 -08:00
|
|
|
return;
|
2016-12-02 05:47:43 -08:00
|
|
|
} else if (isMainAxisRow && childHeightMeasureMode == YGMeasureModeExactly) {
|
2016-12-03 04:40:18 -08:00
|
|
|
child->layout.computedFlexBasis =
|
2017-01-27 09:56:35 -08:00
|
|
|
fmaxf((childHeight - marginColumn) * child->style.aspectRatio,
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
YGNodePaddingAndBorderForAxis(child, YGFlexDirectionRow, parentWidth));
|
2016-11-21 10:12:26 -08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-09 03:48:33 -08:00
|
|
|
YGConstrainMaxSizeForMode(
|
|
|
|
child, YGFlexDirectionRow, parentWidth, parentWidth, &childWidthMeasureMode, &childWidth);
|
|
|
|
YGConstrainMaxSizeForMode(
|
|
|
|
child, YGFlexDirectionColumn, parentHeight, parentWidth, &childHeightMeasureMode, &childHeight);
|
2016-11-11 10:50:09 -08:00
|
|
|
|
|
|
|
// Measure the child
|
2016-12-03 04:40:18 -08:00
|
|
|
YGLayoutNodeInternal(child,
|
|
|
|
childWidth,
|
|
|
|
childHeight,
|
|
|
|
direction,
|
|
|
|
childWidthMeasureMode,
|
|
|
|
childHeightMeasureMode,
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
parentWidth,
|
|
|
|
parentHeight,
|
2016-12-03 04:40:18 -08:00
|
|
|
false,
|
2017-03-01 09:19:55 -08:00
|
|
|
"measure",
|
|
|
|
config);
|
2016-11-11 10:50:09 -08:00
|
|
|
|
|
|
|
child->layout.computedFlexBasis =
|
2017-02-16 07:39:14 -08:00
|
|
|
fmaxf(child->layout.measuredDimensions[dim[mainAxis]],
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
YGNodePaddingAndBorderForAxis(child, mainAxis, parentWidth));
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
2016-11-20 04:59:55 -08:00
|
|
|
|
|
|
|
child->layout.computedFlexBasisGeneration = gCurrentGenerationCount;
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
static void YGNodeAbsoluteLayoutChild(const YGNodeRef node,
|
|
|
|
const YGNodeRef child,
|
|
|
|
const float width,
|
|
|
|
const YGMeasureMode widthMode,
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
const float height,
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGDirection direction,
|
|
|
|
const YGConfigRef config) {
|
2017-03-10 06:05:53 -08:00
|
|
|
const YGFlexDirection mainAxis = YGResolveFlexDirection(node->style.flexDirection, direction);
|
2016-12-03 04:40:18 -08:00
|
|
|
const YGFlexDirection crossAxis = YGFlexDirectionCross(mainAxis, direction);
|
|
|
|
const bool isMainAxisRow = YGFlexDirectionIsRow(mainAxis);
|
2016-11-11 10:50:09 -08:00
|
|
|
|
2016-12-02 05:47:43 -08:00
|
|
|
float childWidth = YGUndefined;
|
|
|
|
float childHeight = YGUndefined;
|
|
|
|
YGMeasureMode childWidthMeasureMode = YGMeasureModeUndefined;
|
|
|
|
YGMeasureMode childHeightMeasureMode = YGMeasureModeUndefined;
|
2016-11-11 10:50:09 -08:00
|
|
|
|
2017-01-27 09:56:35 -08:00
|
|
|
const float marginRow = YGNodeMarginForAxis(child, YGFlexDirectionRow, width);
|
|
|
|
const float marginColumn = YGNodeMarginForAxis(child, YGFlexDirectionColumn, width);
|
|
|
|
|
2017-02-03 05:37:44 -08:00
|
|
|
if (YGNodeIsStyleDimDefined(child, YGFlexDirectionRow, width)) {
|
2017-03-10 06:05:53 -08:00
|
|
|
childWidth = YGResolveValue(child->resolvedDimensions[YGDimensionWidth], width) + marginRow;
|
2016-11-11 10:50:09 -08:00
|
|
|
} else {
|
|
|
|
// If the child doesn't have a specified width, compute the width based
|
|
|
|
// on the left/right
|
|
|
|
// offsets if they're defined.
|
2016-12-03 04:40:18 -08:00
|
|
|
if (YGNodeIsLeadingPosDefined(child, YGFlexDirectionRow) &&
|
|
|
|
YGNodeIsTrailingPosDefined(child, YGFlexDirectionRow)) {
|
2016-12-02 05:47:43 -08:00
|
|
|
childWidth = node->layout.measuredDimensions[YGDimensionWidth] -
|
2016-12-03 04:40:18 -08:00
|
|
|
(YGNodeLeadingBorder(node, YGFlexDirectionRow) +
|
|
|
|
YGNodeTrailingBorder(node, YGFlexDirectionRow)) -
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
(YGNodeLeadingPosition(child, YGFlexDirectionRow, width) +
|
|
|
|
YGNodeTrailingPosition(child, YGFlexDirectionRow, width));
|
|
|
|
childWidth = YGNodeBoundAxis(child, YGFlexDirectionRow, childWidth, width, width);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-03 05:37:44 -08:00
|
|
|
if (YGNodeIsStyleDimDefined(child, YGFlexDirectionColumn, height)) {
|
2017-01-27 09:56:35 -08:00
|
|
|
childHeight =
|
2017-03-10 06:05:53 -08:00
|
|
|
YGResolveValue(child->resolvedDimensions[YGDimensionHeight], height) + marginColumn;
|
2016-11-11 10:50:09 -08:00
|
|
|
} else {
|
|
|
|
// If the child doesn't have a specified height, compute the height
|
|
|
|
// based on the top/bottom
|
|
|
|
// offsets if they're defined.
|
2016-12-03 04:40:18 -08:00
|
|
|
if (YGNodeIsLeadingPosDefined(child, YGFlexDirectionColumn) &&
|
|
|
|
YGNodeIsTrailingPosDefined(child, YGFlexDirectionColumn)) {
|
2016-12-02 05:47:43 -08:00
|
|
|
childHeight = node->layout.measuredDimensions[YGDimensionHeight] -
|
2016-12-03 04:40:18 -08:00
|
|
|
(YGNodeLeadingBorder(node, YGFlexDirectionColumn) +
|
|
|
|
YGNodeTrailingBorder(node, YGFlexDirectionColumn)) -
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
(YGNodeLeadingPosition(child, YGFlexDirectionColumn, height) +
|
|
|
|
YGNodeTrailingPosition(child, YGFlexDirectionColumn, height));
|
|
|
|
childHeight = YGNodeBoundAxis(child, YGFlexDirectionColumn, childHeight, height, width);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-21 10:12:26 -08:00
|
|
|
// Exactly one dimension needs to be defined for us to be able to do aspect ratio
|
|
|
|
// calculation. One dimension being the anchor and the other being flexible.
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
if (YGFloatIsUndefined(childWidth) ^ YGFloatIsUndefined(childHeight)) {
|
|
|
|
if (!YGFloatIsUndefined(child->style.aspectRatio)) {
|
|
|
|
if (YGFloatIsUndefined(childWidth)) {
|
2017-01-27 09:56:35 -08:00
|
|
|
childWidth =
|
|
|
|
marginRow + fmaxf((childHeight - marginColumn) * child->style.aspectRatio,
|
|
|
|
YGNodePaddingAndBorderForAxis(child, YGFlexDirectionColumn, width));
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
} else if (YGFloatIsUndefined(childHeight)) {
|
2017-01-27 09:56:35 -08:00
|
|
|
childHeight =
|
|
|
|
marginColumn + fmaxf((childWidth - marginRow) / child->style.aspectRatio,
|
|
|
|
YGNodePaddingAndBorderForAxis(child, YGFlexDirectionRow, width));
|
2016-11-21 10:12:26 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-11 10:50:09 -08:00
|
|
|
// If we're still missing one or the other dimension, measure the content.
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
if (YGFloatIsUndefined(childWidth) || YGFloatIsUndefined(childHeight)) {
|
2016-11-11 10:50:09 -08:00
|
|
|
childWidthMeasureMode =
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
YGFloatIsUndefined(childWidth) ? YGMeasureModeUndefined : YGMeasureModeExactly;
|
2016-11-11 10:50:09 -08:00
|
|
|
childHeightMeasureMode =
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
YGFloatIsUndefined(childHeight) ? YGMeasureModeUndefined : YGMeasureModeExactly;
|
2016-11-11 10:50:09 -08:00
|
|
|
|
2017-01-24 17:04:54 -08:00
|
|
|
// If the size of the parent is defined then try to constrain the absolute child to that size
|
|
|
|
// as well. This allows text within the absolute child to wrap to the size of its parent.
|
|
|
|
// This is the same behavior as many browsers implement.
|
2017-01-26 13:36:39 -08:00
|
|
|
if (!isMainAxisRow && YGFloatIsUndefined(childWidth) && widthMode != YGMeasureModeUndefined &&
|
|
|
|
width > 0) {
|
2016-11-11 10:50:09 -08:00
|
|
|
childWidth = width;
|
2016-12-02 05:47:43 -08:00
|
|
|
childWidthMeasureMode = YGMeasureModeAtMost;
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
YGLayoutNodeInternal(child,
|
|
|
|
childWidth,
|
|
|
|
childHeight,
|
|
|
|
direction,
|
|
|
|
childWidthMeasureMode,
|
|
|
|
childHeightMeasureMode,
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
childWidth,
|
|
|
|
childHeight,
|
2016-12-03 04:40:18 -08:00
|
|
|
false,
|
2017-03-01 09:19:55 -08:00
|
|
|
"abs-measure",
|
|
|
|
config);
|
2016-12-02 05:47:43 -08:00
|
|
|
childWidth = child->layout.measuredDimensions[YGDimensionWidth] +
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
YGNodeMarginForAxis(child, YGFlexDirectionRow, width);
|
2016-12-02 05:47:43 -08:00
|
|
|
childHeight = child->layout.measuredDimensions[YGDimensionHeight] +
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
YGNodeMarginForAxis(child, YGFlexDirectionColumn, width);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
YGLayoutNodeInternal(child,
|
|
|
|
childWidth,
|
|
|
|
childHeight,
|
|
|
|
direction,
|
|
|
|
YGMeasureModeExactly,
|
|
|
|
YGMeasureModeExactly,
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
childWidth,
|
|
|
|
childHeight,
|
2016-12-03 04:40:18 -08:00
|
|
|
true,
|
2017-03-01 09:19:55 -08:00
|
|
|
"abs-layout",
|
|
|
|
config);
|
2016-11-11 10:50:09 -08:00
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
if (YGNodeIsTrailingPosDefined(child, mainAxis) && !YGNodeIsLeadingPosDefined(child, mainAxis)) {
|
2016-11-11 10:50:09 -08:00
|
|
|
child->layout.position[leading[mainAxis]] = node->layout.measuredDimensions[dim[mainAxis]] -
|
|
|
|
child->layout.measuredDimensions[dim[mainAxis]] -
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeTrailingBorder(node, mainAxis) -
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
YGNodeTrailingPosition(child, mainAxis, width);
|
2017-01-26 13:36:39 -08:00
|
|
|
} else if (!YGNodeIsLeadingPosDefined(child, mainAxis) &&
|
|
|
|
node->style.justifyContent == YGJustifyCenter) {
|
2017-01-26 13:36:35 -08:00
|
|
|
child->layout.position[leading[mainAxis]] = (node->layout.measuredDimensions[dim[mainAxis]] -
|
2017-01-26 13:36:39 -08:00
|
|
|
child->layout.measuredDimensions[dim[mainAxis]]) /
|
|
|
|
2.0f;
|
|
|
|
} else if (!YGNodeIsLeadingPosDefined(child, mainAxis) &&
|
|
|
|
node->style.justifyContent == YGJustifyFlexEnd) {
|
2017-01-26 13:36:35 -08:00
|
|
|
child->layout.position[leading[mainAxis]] = (node->layout.measuredDimensions[dim[mainAxis]] -
|
|
|
|
child->layout.measuredDimensions[dim[mainAxis]]);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
if (YGNodeIsTrailingPosDefined(child, crossAxis) &&
|
|
|
|
!YGNodeIsLeadingPosDefined(child, crossAxis)) {
|
2016-11-11 10:50:09 -08:00
|
|
|
child->layout.position[leading[crossAxis]] = node->layout.measuredDimensions[dim[crossAxis]] -
|
|
|
|
child->layout.measuredDimensions[dim[crossAxis]] -
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeTrailingBorder(node, crossAxis) -
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
YGNodeTrailingPosition(child, crossAxis, width);
|
2017-01-26 13:36:39 -08:00
|
|
|
} else if (!YGNodeIsLeadingPosDefined(child, crossAxis) &&
|
|
|
|
YGNodeAlignItem(node, child) == YGAlignCenter) {
|
|
|
|
child->layout.position[leading[crossAxis]] =
|
|
|
|
(node->layout.measuredDimensions[dim[crossAxis]] -
|
|
|
|
child->layout.measuredDimensions[dim[crossAxis]]) /
|
|
|
|
2.0f;
|
|
|
|
} else if (!YGNodeIsLeadingPosDefined(child, crossAxis) &&
|
|
|
|
YGNodeAlignItem(node, child) == YGAlignFlexEnd) {
|
2017-01-26 13:36:35 -08:00
|
|
|
child->layout.position[leading[crossAxis]] = (node->layout.measuredDimensions[dim[crossAxis]] -
|
|
|
|
child->layout.measuredDimensions[dim[crossAxis]]);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
static void YGNodeWithMeasureFuncSetMeasuredDimensions(const YGNodeRef node,
|
|
|
|
const float availableWidth,
|
|
|
|
const float availableHeight,
|
|
|
|
const YGMeasureMode widthMeasureMode,
|
2017-02-11 05:26:55 -08:00
|
|
|
const YGMeasureMode heightMeasureMode,
|
|
|
|
const float parentWidth,
|
|
|
|
const float parentHeight) {
|
2016-12-03 04:40:18 -08:00
|
|
|
YG_ASSERT(node->measure, "Expected node to have custom measure function");
|
2016-11-21 11:03:53 -08:00
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
const float paddingAndBorderAxisRow =
|
|
|
|
YGNodePaddingAndBorderForAxis(node, YGFlexDirectionRow, availableWidth);
|
2016-12-03 04:40:18 -08:00
|
|
|
const float paddingAndBorderAxisColumn =
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
YGNodePaddingAndBorderForAxis(node, YGFlexDirectionColumn, availableWidth);
|
|
|
|
const float marginAxisRow = YGNodeMarginForAxis(node, YGFlexDirectionRow, availableWidth);
|
|
|
|
const float marginAxisColumn = YGNodeMarginForAxis(node, YGFlexDirectionColumn, availableWidth);
|
2016-11-21 11:03:53 -08:00
|
|
|
|
|
|
|
const float innerWidth = availableWidth - marginAxisRow - paddingAndBorderAxisRow;
|
|
|
|
const float innerHeight = availableHeight - marginAxisColumn - paddingAndBorderAxisColumn;
|
|
|
|
|
2016-12-02 05:47:43 -08:00
|
|
|
if (widthMeasureMode == YGMeasureModeExactly && heightMeasureMode == YGMeasureModeExactly) {
|
2016-11-21 11:03:53 -08:00
|
|
|
// Don't bother sizing the text if both dimensions are already defined.
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
node->layout.measuredDimensions[YGDimensionWidth] = YGNodeBoundAxis(
|
2017-02-11 05:26:55 -08:00
|
|
|
node, YGFlexDirectionRow, availableWidth - marginAxisRow, parentWidth, parentWidth);
|
|
|
|
node->layout.measuredDimensions[YGDimensionHeight] = YGNodeBoundAxis(
|
|
|
|
node, YGFlexDirectionColumn, availableHeight - marginAxisColumn, parentHeight, parentWidth);
|
2016-11-21 11:03:53 -08:00
|
|
|
} else {
|
|
|
|
// Measure the text under the current constraints.
|
2016-12-03 04:40:18 -08:00
|
|
|
const YGSize measuredSize =
|
2016-11-21 11:03:53 -08:00
|
|
|
node->measure(node, innerWidth, widthMeasureMode, innerHeight, heightMeasureMode);
|
|
|
|
|
2016-12-02 05:47:43 -08:00
|
|
|
node->layout.measuredDimensions[YGDimensionWidth] =
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeBoundAxis(node,
|
|
|
|
YGFlexDirectionRow,
|
|
|
|
(widthMeasureMode == YGMeasureModeUndefined ||
|
|
|
|
widthMeasureMode == YGMeasureModeAtMost)
|
|
|
|
? measuredSize.width + paddingAndBorderAxisRow
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
: availableWidth - marginAxisRow,
|
|
|
|
availableWidth,
|
|
|
|
availableWidth);
|
2016-12-02 05:47:43 -08:00
|
|
|
node->layout.measuredDimensions[YGDimensionHeight] =
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeBoundAxis(node,
|
|
|
|
YGFlexDirectionColumn,
|
|
|
|
(heightMeasureMode == YGMeasureModeUndefined ||
|
|
|
|
heightMeasureMode == YGMeasureModeAtMost)
|
|
|
|
? measuredSize.height + paddingAndBorderAxisColumn
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
: availableHeight - marginAxisColumn,
|
|
|
|
availableHeight,
|
|
|
|
availableWidth);
|
2016-11-21 11:03:53 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-21 11:03:56 -08:00
|
|
|
// For nodes with no children, use the available values if they were provided,
|
|
|
|
// or the minimum size as indicated by the padding and border sizes.
|
2016-12-03 04:40:18 -08:00
|
|
|
static void YGNodeEmptyContainerSetMeasuredDimensions(const YGNodeRef node,
|
|
|
|
const float availableWidth,
|
|
|
|
const float availableHeight,
|
|
|
|
const YGMeasureMode widthMeasureMode,
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
const YGMeasureMode heightMeasureMode,
|
|
|
|
const float parentWidth,
|
|
|
|
const float parentHeight) {
|
|
|
|
const float paddingAndBorderAxisRow =
|
|
|
|
YGNodePaddingAndBorderForAxis(node, YGFlexDirectionRow, parentWidth);
|
2016-12-03 04:40:18 -08:00
|
|
|
const float paddingAndBorderAxisColumn =
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
YGNodePaddingAndBorderForAxis(node, YGFlexDirectionColumn, parentWidth);
|
|
|
|
const float marginAxisRow = YGNodeMarginForAxis(node, YGFlexDirectionRow, parentWidth);
|
|
|
|
const float marginAxisColumn = YGNodeMarginForAxis(node, YGFlexDirectionColumn, parentWidth);
|
2016-12-02 05:47:43 -08:00
|
|
|
|
|
|
|
node->layout.measuredDimensions[YGDimensionWidth] =
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeBoundAxis(node,
|
|
|
|
YGFlexDirectionRow,
|
|
|
|
(widthMeasureMode == YGMeasureModeUndefined ||
|
|
|
|
widthMeasureMode == YGMeasureModeAtMost)
|
|
|
|
? paddingAndBorderAxisRow
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
: availableWidth - marginAxisRow,
|
|
|
|
parentWidth,
|
|
|
|
parentWidth);
|
2016-12-02 05:47:43 -08:00
|
|
|
node->layout.measuredDimensions[YGDimensionHeight] =
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeBoundAxis(node,
|
|
|
|
YGFlexDirectionColumn,
|
|
|
|
(heightMeasureMode == YGMeasureModeUndefined ||
|
|
|
|
heightMeasureMode == YGMeasureModeAtMost)
|
|
|
|
? paddingAndBorderAxisColumn
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
: availableHeight - marginAxisColumn,
|
|
|
|
parentHeight,
|
|
|
|
parentWidth);
|
2016-12-03 04:40:18 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool YGNodeFixedSizeSetMeasuredDimensions(const YGNodeRef node,
|
|
|
|
const float availableWidth,
|
|
|
|
const float availableHeight,
|
|
|
|
const YGMeasureMode widthMeasureMode,
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
const YGMeasureMode heightMeasureMode,
|
|
|
|
const float parentWidth,
|
|
|
|
const float parentHeight) {
|
|
|
|
if ((widthMeasureMode == YGMeasureModeAtMost && availableWidth <= 0.0f) ||
|
|
|
|
(heightMeasureMode == YGMeasureModeAtMost && availableHeight <= 0.0f) ||
|
2016-12-02 05:47:43 -08:00
|
|
|
(widthMeasureMode == YGMeasureModeExactly && heightMeasureMode == YGMeasureModeExactly)) {
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
const float marginAxisColumn = YGNodeMarginForAxis(node, YGFlexDirectionColumn, parentWidth);
|
|
|
|
const float marginAxisRow = YGNodeMarginForAxis(node, YGFlexDirectionRow, parentWidth);
|
2016-12-02 05:47:43 -08:00
|
|
|
|
|
|
|
node->layout.measuredDimensions[YGDimensionWidth] =
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeBoundAxis(node,
|
|
|
|
YGFlexDirectionRow,
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
YGFloatIsUndefined(availableWidth) ||
|
|
|
|
(widthMeasureMode == YGMeasureModeAtMost && availableWidth < 0.0f)
|
|
|
|
? 0.0f
|
|
|
|
: availableWidth - marginAxisRow,
|
|
|
|
parentWidth,
|
|
|
|
parentWidth);
|
2016-11-21 11:03:57 -08:00
|
|
|
|
2016-12-02 05:47:43 -08:00
|
|
|
node->layout.measuredDimensions[YGDimensionHeight] =
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeBoundAxis(node,
|
|
|
|
YGFlexDirectionColumn,
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
YGFloatIsUndefined(availableHeight) ||
|
|
|
|
(heightMeasureMode == YGMeasureModeAtMost && availableHeight < 0.0f)
|
|
|
|
? 0.0f
|
|
|
|
: availableHeight - marginAxisColumn,
|
|
|
|
parentHeight,
|
|
|
|
parentWidth);
|
2016-11-21 11:03:57 -08:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-02-06 09:31:22 -08:00
|
|
|
static void YGZeroOutLayoutRecursivly(const YGNodeRef node) {
|
|
|
|
node->layout.dimensions[YGDimensionHeight] = 0;
|
|
|
|
node->layout.dimensions[YGDimensionWidth] = 0;
|
|
|
|
node->layout.position[YGEdgeTop] = 0;
|
|
|
|
node->layout.position[YGEdgeBottom] = 0;
|
|
|
|
node->layout.position[YGEdgeLeft] = 0;
|
|
|
|
node->layout.position[YGEdgeRight] = 0;
|
2017-03-03 10:31:47 -08:00
|
|
|
node->layout.cachedLayout.availableHeight = 0;
|
|
|
|
node->layout.cachedLayout.availableWidth = 0;
|
|
|
|
node->layout.cachedLayout.heightMeasureMode = YGMeasureModeExactly;
|
|
|
|
node->layout.cachedLayout.widthMeasureMode = YGMeasureModeExactly;
|
|
|
|
node->layout.cachedLayout.computedWidth = 0;
|
|
|
|
node->layout.cachedLayout.computedHeight = 0;
|
2017-03-28 12:37:49 -07:00
|
|
|
node->hasNewLayout = true;
|
2017-02-15 13:35:24 -08:00
|
|
|
const uint32_t childCount = YGNodeGetChildCount(node);
|
|
|
|
for (uint32_t i = 0; i < childCount; i++) {
|
2017-02-06 09:31:22 -08:00
|
|
|
const YGNodeRef child = YGNodeListGet(node->children, i);
|
|
|
|
YGZeroOutLayoutRecursivly(child);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-11 10:50:09 -08:00
|
|
|
//
|
|
|
|
// This is the main routine that implements a subset of the flexbox layout
|
|
|
|
// algorithm
|
2016-12-03 04:40:18 -08:00
|
|
|
// described in the W3C YG documentation: https://www.w3.org/TR/YG3-flexbox/.
|
2016-11-11 10:50:09 -08:00
|
|
|
//
|
|
|
|
// Limitations of this algorithm, compared to the full standard:
|
|
|
|
// * Display property is always assumed to be 'flex' except for Text nodes,
|
|
|
|
// which
|
|
|
|
// are assumed to be 'inline-flex'.
|
|
|
|
// * The 'zIndex' property (or any form of z ordering) is not supported. Nodes
|
|
|
|
// are
|
|
|
|
// stacked in document order.
|
|
|
|
// * The 'order' property is not supported. The order of flex items is always
|
|
|
|
// defined
|
|
|
|
// by document order.
|
|
|
|
// * The 'visibility' property is always assumed to be 'visible'. Values of
|
|
|
|
// 'collapse'
|
|
|
|
// and 'hidden' are not supported.
|
|
|
|
// * There is no support for forced breaks.
|
|
|
|
// * It does not support vertical inline directions (top-to-bottom or
|
|
|
|
// bottom-to-top text).
|
|
|
|
//
|
|
|
|
// Deviations from standard:
|
|
|
|
// * Section 4.5 of the spec indicates that all flex items have a default
|
|
|
|
// minimum
|
|
|
|
// main size. For text blocks, for example, this is the width of the widest
|
|
|
|
// word.
|
|
|
|
// Calculating the minimum width is expensive, so we forego it and assume a
|
|
|
|
// default
|
|
|
|
// minimum main size of 0.
|
|
|
|
// * Min/Max sizes in the main axis are not honored when resolving flexible
|
|
|
|
// lengths.
|
|
|
|
// * The spec indicates that the default value for 'flexDirection' is 'row',
|
|
|
|
// but
|
|
|
|
// the algorithm below assumes a default of 'column'.
|
|
|
|
//
|
|
|
|
// Input parameters:
|
|
|
|
// - node: current node to be sized and layed out
|
|
|
|
// - availableWidth & availableHeight: available size to be used for sizing
|
|
|
|
// the node
|
2016-12-02 05:47:43 -08:00
|
|
|
// or YGUndefined if the size is not available; interpretation depends on
|
2016-11-11 10:50:09 -08:00
|
|
|
// layout
|
|
|
|
// flags
|
|
|
|
// - parentDirection: the inline (text) direction within the parent
|
|
|
|
// (left-to-right or
|
|
|
|
// right-to-left)
|
|
|
|
// - widthMeasureMode: indicates the sizing rules for the width (see below
|
|
|
|
// for explanation)
|
|
|
|
// - heightMeasureMode: indicates the sizing rules for the height (see below
|
|
|
|
// for explanation)
|
|
|
|
// - performLayout: specifies whether the caller is interested in just the
|
|
|
|
// dimensions
|
|
|
|
// of the node or it requires the entire node and its subtree to be layed
|
|
|
|
// out
|
|
|
|
// (with final positions)
|
|
|
|
//
|
|
|
|
// Details:
|
|
|
|
// This routine is called recursively to lay out subtrees of flexbox
|
|
|
|
// elements. It uses the
|
|
|
|
// information in node.style, which is treated as a read-only input. It is
|
|
|
|
// responsible for
|
|
|
|
// setting the layout.direction and layout.measuredDimensions fields for the
|
|
|
|
// input node as well
|
|
|
|
// as the layout.position and layout.lineIndex fields for its child nodes.
|
|
|
|
// The
|
|
|
|
// layout.measuredDimensions field includes any border or padding for the
|
|
|
|
// node but does
|
|
|
|
// not include margins.
|
|
|
|
//
|
|
|
|
// The spec describes four different layout modes: "fill available", "max
|
|
|
|
// content", "min
|
|
|
|
// content",
|
|
|
|
// and "fit content". Of these, we don't use "min content" because we don't
|
|
|
|
// support default
|
|
|
|
// minimum main sizes (see above for details). Each of our measure modes maps
|
|
|
|
// to a layout mode
|
2016-12-03 04:40:18 -08:00
|
|
|
// from the spec (https://www.w3.org/TR/YG3-sizing/#terms):
|
2016-12-02 05:47:43 -08:00
|
|
|
// - YGMeasureModeUndefined: max content
|
|
|
|
// - YGMeasureModeExactly: fill available
|
|
|
|
// - YGMeasureModeAtMost: fit content
|
2016-11-11 10:50:09 -08:00
|
|
|
//
|
2016-12-03 04:40:18 -08:00
|
|
|
// When calling YGNodelayoutImpl and YGLayoutNodeInternal, if the caller passes
|
2016-11-11 10:50:09 -08:00
|
|
|
// an available size of
|
2016-12-02 05:47:43 -08:00
|
|
|
// undefined then it must also pass a measure mode of YGMeasureModeUndefined
|
2016-11-11 10:50:09 -08:00
|
|
|
// in that dimension.
|
|
|
|
//
|
2016-12-03 04:40:18 -08:00
|
|
|
static void YGNodelayoutImpl(const YGNodeRef node,
|
|
|
|
const float availableWidth,
|
|
|
|
const float availableHeight,
|
|
|
|
const YGDirection parentDirection,
|
|
|
|
const YGMeasureMode widthMeasureMode,
|
|
|
|
const YGMeasureMode heightMeasureMode,
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
const float parentWidth,
|
|
|
|
const float parentHeight,
|
2017-03-01 09:19:55 -08:00
|
|
|
const bool performLayout,
|
|
|
|
const YGConfigRef config) {
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
YG_ASSERT(YGFloatIsUndefined(availableWidth) ? widthMeasureMode == YGMeasureModeUndefined : true,
|
2016-12-03 04:40:18 -08:00
|
|
|
"availableWidth is indefinite so widthMeasureMode must be "
|
|
|
|
"YGMeasureModeUndefined");
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
YG_ASSERT(YGFloatIsUndefined(availableHeight) ? heightMeasureMode == YGMeasureModeUndefined
|
2016-12-03 04:40:18 -08:00
|
|
|
: true,
|
|
|
|
"availableHeight is indefinite so heightMeasureMode must be "
|
|
|
|
"YGMeasureModeUndefined");
|
2016-11-11 10:50:09 -08:00
|
|
|
|
|
|
|
// Set the resolved resolution in the node's layout.
|
2016-12-03 04:40:18 -08:00
|
|
|
const YGDirection direction = YGNodeResolveDirection(node, parentDirection);
|
2016-11-11 10:50:09 -08:00
|
|
|
node->layout.direction = direction;
|
|
|
|
|
2017-03-10 06:05:53 -08:00
|
|
|
const YGFlexDirection flexRowDirection = YGResolveFlexDirection(YGFlexDirectionRow, direction);
|
2017-01-26 13:36:39 -08:00
|
|
|
const YGFlexDirection flexColumnDirection =
|
2017-03-10 06:05:53 -08:00
|
|
|
YGResolveFlexDirection(YGFlexDirectionColumn, direction);
|
2017-01-26 13:36:39 -08:00
|
|
|
|
|
|
|
node->layout.margin[YGEdgeStart] = YGNodeLeadingMargin(node, flexRowDirection, parentWidth);
|
|
|
|
node->layout.margin[YGEdgeEnd] = YGNodeTrailingMargin(node, flexRowDirection, parentWidth);
|
|
|
|
node->layout.margin[YGEdgeTop] = YGNodeLeadingMargin(node, flexColumnDirection, parentWidth);
|
|
|
|
node->layout.margin[YGEdgeBottom] = YGNodeTrailingMargin(node, flexColumnDirection, parentWidth);
|
|
|
|
|
|
|
|
node->layout.border[YGEdgeStart] = YGNodeLeadingBorder(node, flexRowDirection);
|
|
|
|
node->layout.border[YGEdgeEnd] = YGNodeTrailingBorder(node, flexRowDirection);
|
|
|
|
node->layout.border[YGEdgeTop] = YGNodeLeadingBorder(node, flexColumnDirection);
|
|
|
|
node->layout.border[YGEdgeBottom] = YGNodeTrailingBorder(node, flexColumnDirection);
|
|
|
|
|
|
|
|
node->layout.padding[YGEdgeStart] = YGNodeLeadingPadding(node, flexRowDirection, parentWidth);
|
|
|
|
node->layout.padding[YGEdgeEnd] = YGNodeTrailingPadding(node, flexRowDirection, parentWidth);
|
|
|
|
node->layout.padding[YGEdgeTop] = YGNodeLeadingPadding(node, flexColumnDirection, parentWidth);
|
2017-01-06 06:51:56 -08:00
|
|
|
node->layout.padding[YGEdgeBottom] =
|
2017-01-26 13:36:39 -08:00
|
|
|
YGNodeTrailingPadding(node, flexColumnDirection, parentWidth);
|
2017-01-05 12:48:07 -08:00
|
|
|
|
2016-11-11 10:50:09 -08:00
|
|
|
if (node->measure) {
|
2017-02-11 05:26:55 -08:00
|
|
|
YGNodeWithMeasureFuncSetMeasuredDimensions(node,
|
|
|
|
availableWidth,
|
|
|
|
availableHeight,
|
|
|
|
widthMeasureMode,
|
|
|
|
heightMeasureMode,
|
|
|
|
parentWidth,
|
|
|
|
parentHeight);
|
2016-11-11 10:50:09 -08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
const uint32_t childCount = YGNodeListCount(node->children);
|
2016-11-11 10:50:09 -08:00
|
|
|
if (childCount == 0) {
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
YGNodeEmptyContainerSetMeasuredDimensions(node,
|
|
|
|
availableWidth,
|
|
|
|
availableHeight,
|
|
|
|
widthMeasureMode,
|
|
|
|
heightMeasureMode,
|
|
|
|
parentWidth,
|
|
|
|
parentHeight);
|
2016-11-11 10:50:09 -08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-11-21 11:03:57 -08:00
|
|
|
// If we're not being asked to perform a full layout we can skip the algorithm if we already know
|
|
|
|
// the size
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
if (!performLayout && YGNodeFixedSizeSetMeasuredDimensions(node,
|
|
|
|
availableWidth,
|
|
|
|
availableHeight,
|
|
|
|
widthMeasureMode,
|
|
|
|
heightMeasureMode,
|
|
|
|
parentWidth,
|
|
|
|
parentHeight)) {
|
2016-11-21 11:03:57 -08:00
|
|
|
return;
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// STEP 1: CALCULATE VALUES FOR REMAINDER OF ALGORITHM
|
2017-03-10 06:05:53 -08:00
|
|
|
const YGFlexDirection mainAxis = YGResolveFlexDirection(node->style.flexDirection, direction);
|
2016-12-03 04:40:18 -08:00
|
|
|
const YGFlexDirection crossAxis = YGFlexDirectionCross(mainAxis, direction);
|
|
|
|
const bool isMainAxisRow = YGFlexDirectionIsRow(mainAxis);
|
2016-12-02 05:47:43 -08:00
|
|
|
const YGJustify justifyContent = node->style.justifyContent;
|
2017-02-15 13:35:24 -08:00
|
|
|
const bool isNodeFlexWrap = node->style.flexWrap != YGWrapNoWrap;
|
2016-11-11 10:50:09 -08:00
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
const float mainAxisParentSize = isMainAxisRow ? parentWidth : parentHeight;
|
|
|
|
const float crossAxisParentSize = isMainAxisRow ? parentHeight : parentWidth;
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeRef firstAbsoluteChild = NULL;
|
|
|
|
YGNodeRef currentAbsoluteChild = NULL;
|
2016-11-11 10:50:09 -08:00
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
const float leadingPaddingAndBorderMain =
|
|
|
|
YGNodeLeadingPaddingAndBorder(node, mainAxis, parentWidth);
|
|
|
|
const float trailingPaddingAndBorderMain =
|
|
|
|
YGNodeTrailingPaddingAndBorder(node, mainAxis, parentWidth);
|
|
|
|
const float leadingPaddingAndBorderCross =
|
|
|
|
YGNodeLeadingPaddingAndBorder(node, crossAxis, parentWidth);
|
|
|
|
const float paddingAndBorderAxisMain = YGNodePaddingAndBorderForAxis(node, mainAxis, parentWidth);
|
|
|
|
const float paddingAndBorderAxisCross =
|
|
|
|
YGNodePaddingAndBorderForAxis(node, crossAxis, parentWidth);
|
2016-11-11 10:50:09 -08:00
|
|
|
|
2017-02-20 07:16:58 -08:00
|
|
|
YGMeasureMode measureModeMainDim = isMainAxisRow ? widthMeasureMode : heightMeasureMode;
|
|
|
|
YGMeasureMode measureModeCrossDim = isMainAxisRow ? heightMeasureMode : widthMeasureMode;
|
2016-11-11 10:50:09 -08:00
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
const float paddingAndBorderAxisRow =
|
|
|
|
isMainAxisRow ? paddingAndBorderAxisMain : paddingAndBorderAxisCross;
|
|
|
|
const float paddingAndBorderAxisColumn =
|
|
|
|
isMainAxisRow ? paddingAndBorderAxisCross : paddingAndBorderAxisMain;
|
2016-12-23 10:15:50 -08:00
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
const float marginAxisRow = YGNodeMarginForAxis(node, YGFlexDirectionRow, parentWidth);
|
|
|
|
const float marginAxisColumn = YGNodeMarginForAxis(node, YGFlexDirectionColumn, parentWidth);
|
2016-11-21 11:03:57 -08:00
|
|
|
|
2016-11-11 10:50:09 -08:00
|
|
|
// STEP 2: DETERMINE AVAILABLE SIZE IN MAIN AND CROSS DIRECTIONS
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
const float minInnerWidth =
|
2017-03-10 06:05:53 -08:00
|
|
|
YGResolveValue(&node->style.minDimensions[YGDimensionWidth], parentWidth) - marginAxisRow -
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
paddingAndBorderAxisRow;
|
|
|
|
const float maxInnerWidth =
|
2017-03-10 06:05:53 -08:00
|
|
|
YGResolveValue(&node->style.maxDimensions[YGDimensionWidth], parentWidth) - marginAxisRow -
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
paddingAndBorderAxisRow;
|
|
|
|
const float minInnerHeight =
|
2017-03-10 06:05:53 -08:00
|
|
|
YGResolveValue(&node->style.minDimensions[YGDimensionHeight], parentHeight) -
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
marginAxisColumn - paddingAndBorderAxisColumn;
|
|
|
|
const float maxInnerHeight =
|
2017-03-10 06:05:53 -08:00
|
|
|
YGResolveValue(&node->style.maxDimensions[YGDimensionHeight], parentHeight) -
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
marginAxisColumn - paddingAndBorderAxisColumn;
|
2016-12-21 11:37:32 -08:00
|
|
|
const float minInnerMainDim = isMainAxisRow ? minInnerWidth : minInnerHeight;
|
|
|
|
const float maxInnerMainDim = isMainAxisRow ? maxInnerWidth : maxInnerHeight;
|
2016-12-23 10:15:50 -08:00
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
// Max dimension overrides predefined dimension value; Min dimension in turn overrides both of the
|
|
|
|
// above
|
|
|
|
float availableInnerWidth = availableWidth - marginAxisRow - paddingAndBorderAxisRow;
|
|
|
|
if (!YGFloatIsUndefined(availableInnerWidth)) {
|
2017-02-28 16:27:18 -08:00
|
|
|
// We want to make sure our available width does not violate min and max constraints
|
2016-12-21 11:37:32 -08:00
|
|
|
availableInnerWidth = fmaxf(fminf(availableInnerWidth, maxInnerWidth), minInnerWidth);
|
|
|
|
}
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
|
|
|
|
float availableInnerHeight = availableHeight - marginAxisColumn - paddingAndBorderAxisColumn;
|
|
|
|
if (!YGFloatIsUndefined(availableInnerHeight)) {
|
2017-02-28 16:27:18 -08:00
|
|
|
// We want to make sure our available height does not violate min and max constraints
|
2016-12-21 11:37:32 -08:00
|
|
|
availableInnerHeight = fmaxf(fminf(availableInnerHeight, maxInnerHeight), minInnerHeight);
|
|
|
|
}
|
2016-12-23 10:15:50 -08:00
|
|
|
|
2016-12-21 11:37:32 -08:00
|
|
|
float availableInnerMainDim = isMainAxisRow ? availableInnerWidth : availableInnerHeight;
|
2016-11-11 10:50:09 -08:00
|
|
|
const float availableInnerCrossDim = isMainAxisRow ? availableInnerHeight : availableInnerWidth;
|
|
|
|
|
|
|
|
// If there is only one child with flexGrow + flexShrink it means we can set the
|
|
|
|
// computedFlexBasis to 0 instead of measuring and shrinking / flexing the child to exactly
|
|
|
|
// match the remaining space
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeRef singleFlexChild = NULL;
|
2017-02-20 07:16:58 -08:00
|
|
|
if (measureModeMainDim == YGMeasureModeExactly) {
|
2016-11-11 10:50:09 -08:00
|
|
|
for (uint32_t i = 0; i < childCount; i++) {
|
2016-12-03 04:40:18 -08:00
|
|
|
const YGNodeRef child = YGNodeGetChild(node, i);
|
2016-11-11 10:50:09 -08:00
|
|
|
if (singleFlexChild) {
|
2016-12-03 04:40:18 -08:00
|
|
|
if (YGNodeIsFlex(child)) {
|
2016-11-11 10:50:09 -08:00
|
|
|
// There is already a flexible child, abort.
|
|
|
|
singleFlexChild = NULL;
|
|
|
|
break;
|
|
|
|
}
|
2017-02-28 09:17:17 -08:00
|
|
|
} else if (YGResolveFlexGrow(child) > 0.0f && YGNodeResolveFlexShrink(child) > 0.0f) {
|
2016-11-11 10:50:09 -08:00
|
|
|
singleFlexChild = child;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-14 09:16:59 -08:00
|
|
|
float totalFlexBasis = 0;
|
|
|
|
|
2016-11-11 10:50:09 -08:00
|
|
|
// STEP 3: DETERMINE FLEX BASIS FOR EACH ITEM
|
|
|
|
for (uint32_t i = 0; i < childCount; i++) {
|
2016-12-03 04:40:18 -08:00
|
|
|
const YGNodeRef child = YGNodeListGet(node->children, i);
|
2017-02-06 09:31:22 -08:00
|
|
|
if (child->style.display == YGDisplayNone) {
|
|
|
|
YGZeroOutLayoutRecursivly(child);
|
|
|
|
child->hasNewLayout = true;
|
|
|
|
child->isDirty = false;
|
|
|
|
continue;
|
|
|
|
}
|
2017-02-06 14:36:27 -08:00
|
|
|
YGResolveDimensions(child);
|
2016-11-11 10:50:09 -08:00
|
|
|
if (performLayout) {
|
|
|
|
// Set the initial position (relative to the parent).
|
2016-12-03 04:40:18 -08:00
|
|
|
const YGDirection childDirection = YGNodeResolveDirection(child, direction);
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
YGNodeSetPosition(child,
|
|
|
|
childDirection,
|
|
|
|
availableInnerMainDim,
|
|
|
|
availableInnerCrossDim,
|
|
|
|
availableInnerWidth);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Absolute-positioned children don't participate in flex layout. Add them
|
|
|
|
// to a list that we can process later.
|
2016-12-02 05:47:43 -08:00
|
|
|
if (child->style.positionType == YGPositionTypeAbsolute) {
|
2016-11-11 10:50:09 -08:00
|
|
|
// Store a private linked list of absolutely positioned children
|
|
|
|
// so that we can efficiently traverse them later.
|
|
|
|
if (firstAbsoluteChild == NULL) {
|
|
|
|
firstAbsoluteChild = child;
|
|
|
|
}
|
|
|
|
if (currentAbsoluteChild != NULL) {
|
|
|
|
currentAbsoluteChild->nextChild = child;
|
|
|
|
}
|
|
|
|
currentAbsoluteChild = child;
|
|
|
|
child->nextChild = NULL;
|
|
|
|
} else {
|
|
|
|
if (child == singleFlexChild) {
|
2016-11-20 04:59:55 -08:00
|
|
|
child->layout.computedFlexBasisGeneration = gCurrentGenerationCount;
|
2016-11-11 10:50:09 -08:00
|
|
|
child->layout.computedFlexBasis = 0;
|
|
|
|
} else {
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeComputeFlexBasisForChild(node,
|
|
|
|
child,
|
|
|
|
availableInnerWidth,
|
|
|
|
widthMeasureMode,
|
|
|
|
availableInnerHeight,
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
availableInnerWidth,
|
|
|
|
availableInnerHeight,
|
2016-12-03 04:40:18 -08:00
|
|
|
heightMeasureMode,
|
2017-03-01 09:19:55 -08:00
|
|
|
direction,
|
|
|
|
config);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
}
|
2017-02-14 09:16:59 -08:00
|
|
|
|
|
|
|
totalFlexBasis += child->layout.computedFlexBasis;
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2017-02-14 09:16:59 -08:00
|
|
|
const bool flexBasisOverflows =
|
2017-02-28 06:57:55 -08:00
|
|
|
measureModeMainDim == YGMeasureModeUndefined ? false : totalFlexBasis > availableInnerMainDim;
|
2017-02-20 07:16:58 -08:00
|
|
|
if (isNodeFlexWrap && flexBasisOverflows && measureModeMainDim == YGMeasureModeAtMost) {
|
|
|
|
measureModeMainDim = YGMeasureModeExactly;
|
|
|
|
}
|
2017-02-14 09:16:59 -08:00
|
|
|
|
2016-11-11 10:50:09 -08:00
|
|
|
// STEP 4: COLLECT FLEX ITEMS INTO FLEX LINES
|
|
|
|
|
|
|
|
// Indexes of children that represent the first and last items in the line.
|
|
|
|
uint32_t startOfLineIndex = 0;
|
|
|
|
uint32_t endOfLineIndex = 0;
|
|
|
|
|
|
|
|
// Number of lines.
|
|
|
|
uint32_t lineCount = 0;
|
|
|
|
|
|
|
|
// Accumulated cross dimensions of all lines so far.
|
|
|
|
float totalLineCrossDim = 0;
|
|
|
|
|
|
|
|
// Max main dimension of all the lines.
|
|
|
|
float maxLineMainDim = 0;
|
|
|
|
|
|
|
|
for (; endOfLineIndex < childCount; lineCount++, startOfLineIndex = endOfLineIndex) {
|
|
|
|
// Number of items on the currently line. May be different than the
|
|
|
|
// difference
|
|
|
|
// between start and end indicates because we skip over absolute-positioned
|
|
|
|
// items.
|
|
|
|
uint32_t itemsOnLine = 0;
|
|
|
|
|
|
|
|
// sizeConsumedOnCurrentLine is accumulation of the dimensions and margin
|
|
|
|
// of all the children on the current line. This will be used in order to
|
|
|
|
// either set the dimensions of the node if none already exist or to compute
|
|
|
|
// the remaining space left for the flexible children.
|
|
|
|
float sizeConsumedOnCurrentLine = 0;
|
2017-04-11 13:00:03 -07:00
|
|
|
float sizeConsumedOnCurrentLineIncludingMinConstraint = 0;
|
2016-11-11 10:50:09 -08:00
|
|
|
|
|
|
|
float totalFlexGrowFactors = 0;
|
|
|
|
float totalFlexShrinkScaledFactors = 0;
|
|
|
|
|
|
|
|
// Maintain a linked list of the child nodes that can shrink and/or grow.
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeRef firstRelativeChild = NULL;
|
|
|
|
YGNodeRef currentRelativeChild = NULL;
|
2016-11-11 10:50:09 -08:00
|
|
|
|
|
|
|
// Add items to the current line until it's full or we run out of items.
|
|
|
|
for (uint32_t i = startOfLineIndex; i < childCount; i++, endOfLineIndex++) {
|
2016-12-03 04:40:18 -08:00
|
|
|
const YGNodeRef child = YGNodeListGet(node->children, i);
|
2017-02-06 09:31:22 -08:00
|
|
|
if (child->style.display == YGDisplayNone) {
|
|
|
|
continue;
|
|
|
|
}
|
2016-11-11 10:50:09 -08:00
|
|
|
child->lineIndex = lineCount;
|
|
|
|
|
2016-12-02 05:47:43 -08:00
|
|
|
if (child->style.positionType != YGPositionTypeAbsolute) {
|
2017-04-11 13:00:03 -07:00
|
|
|
const float childMarginMainAxis = YGNodeMarginForAxis(child, mainAxis, availableInnerWidth);
|
2017-04-26 11:31:06 -07:00
|
|
|
const float flexBasisWithMaxConstraints =
|
|
|
|
fminf(YGResolveValue(&child->style.maxDimensions[dim[mainAxis]], mainAxisParentSize),
|
|
|
|
fmaxf(YGResolveValue(&child->style.minDimensions[dim[mainAxis]],
|
|
|
|
mainAxisParentSize),
|
|
|
|
child->layout.computedFlexBasis));
|
|
|
|
const float flexBasisWithMinAndMaxConstraints =
|
2017-03-10 06:05:53 -08:00
|
|
|
fmaxf(YGResolveValue(&child->style.minDimensions[dim[mainAxis]], mainAxisParentSize),
|
2017-04-26 11:31:06 -07:00
|
|
|
flexBasisWithMaxConstraints);
|
2016-11-11 10:50:09 -08:00
|
|
|
|
|
|
|
// If this is a multi-line flow and this item pushes us over the
|
|
|
|
// available size, we've
|
|
|
|
// hit the end of the current line. Break out of the loop and lay out
|
|
|
|
// the current line.
|
2017-04-26 11:31:06 -07:00
|
|
|
if (sizeConsumedOnCurrentLineIncludingMinConstraint + flexBasisWithMinAndMaxConstraints +
|
|
|
|
childMarginMainAxis >
|
2017-04-11 13:00:03 -07:00
|
|
|
availableInnerMainDim &&
|
|
|
|
isNodeFlexWrap && itemsOnLine > 0) {
|
2016-11-11 10:50:09 -08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-04-26 11:31:06 -07:00
|
|
|
sizeConsumedOnCurrentLineIncludingMinConstraint +=
|
|
|
|
flexBasisWithMinAndMaxConstraints + childMarginMainAxis;
|
|
|
|
sizeConsumedOnCurrentLine += flexBasisWithMaxConstraints + childMarginMainAxis;
|
2016-11-11 10:50:09 -08:00
|
|
|
itemsOnLine++;
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
if (YGNodeIsFlex(child)) {
|
2017-02-28 09:17:17 -08:00
|
|
|
totalFlexGrowFactors += YGResolveFlexGrow(child);
|
2016-11-11 10:50:09 -08:00
|
|
|
|
|
|
|
// Unlike the grow factor, the shrink factor is scaled relative to the
|
|
|
|
// child
|
|
|
|
// dimension.
|
|
|
|
totalFlexShrinkScaledFactors +=
|
2017-02-28 09:17:17 -08:00
|
|
|
-YGNodeResolveFlexShrink(child) * child->layout.computedFlexBasis;
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Store a private linked list of children that need to be layed out.
|
|
|
|
if (firstRelativeChild == NULL) {
|
|
|
|
firstRelativeChild = child;
|
|
|
|
}
|
|
|
|
if (currentRelativeChild != NULL) {
|
|
|
|
currentRelativeChild->nextChild = child;
|
|
|
|
}
|
|
|
|
currentRelativeChild = child;
|
|
|
|
child->nextChild = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we don't need to measure the cross axis, we can skip the entire flex
|
|
|
|
// step.
|
2016-12-02 05:47:43 -08:00
|
|
|
const bool canSkipFlex = !performLayout && measureModeCrossDim == YGMeasureModeExactly;
|
2016-11-11 10:50:09 -08:00
|
|
|
|
|
|
|
// In order to position the elements in the main axis, we have two
|
|
|
|
// controls. The space between the beginning and the first element
|
|
|
|
// and the space between each two elements.
|
|
|
|
float leadingMainDim = 0;
|
|
|
|
float betweenMainDim = 0;
|
|
|
|
|
|
|
|
// STEP 5: RESOLVING FLEXIBLE LENGTHS ON MAIN AXIS
|
|
|
|
// Calculate the remaining available space that needs to be allocated.
|
|
|
|
// If the main dimension size isn't known, it is computed based on
|
|
|
|
// the line length, so there's no more space left to distribute.
|
2016-12-23 10:15:50 -08:00
|
|
|
|
2017-02-28 16:27:18 -08:00
|
|
|
// If we don't measure with exact main dimension we want to ensure we don't violate min and max
|
|
|
|
if (measureModeMainDim != YGMeasureModeExactly) {
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
if (!YGFloatIsUndefined(minInnerMainDim) && sizeConsumedOnCurrentLine < minInnerMainDim) {
|
2016-12-21 11:37:32 -08:00
|
|
|
availableInnerMainDim = minInnerMainDim;
|
2017-02-28 16:27:18 -08:00
|
|
|
} else if (!YGFloatIsUndefined(maxInnerMainDim) && sizeConsumedOnCurrentLine > maxInnerMainDim) {
|
2016-12-21 11:37:32 -08:00
|
|
|
availableInnerMainDim = maxInnerMainDim;
|
2017-04-19 13:27:03 -07:00
|
|
|
} else if (YGConfigIsExperimentalFeatureEnabled(node->config, YGExperimentalFeatureMinFlexFix) &&
|
|
|
|
(totalFlexGrowFactors == 0 || YGResolveFlexGrow(node) == 0)) {
|
2017-04-13 18:01:35 -07:00
|
|
|
// TODO: this needs to be moved out of experimental feature, as this is legitimate fix
|
2017-04-19 13:27:03 -07:00
|
|
|
// If we don't have any children to flex or we can't flex the node itself,
|
|
|
|
// space we've used is all space we need
|
2017-02-28 16:27:18 -08:00
|
|
|
availableInnerMainDim = sizeConsumedOnCurrentLine;
|
2016-12-21 11:37:32 -08:00
|
|
|
}
|
|
|
|
}
|
2016-12-23 10:15:50 -08:00
|
|
|
|
2016-11-11 10:50:09 -08:00
|
|
|
float remainingFreeSpace = 0;
|
2017-04-13 09:51:45 -07:00
|
|
|
if (!YGFloatIsUndefined(availableInnerMainDim)) {
|
2016-11-11 10:50:09 -08:00
|
|
|
remainingFreeSpace = availableInnerMainDim - sizeConsumedOnCurrentLine;
|
|
|
|
} else if (sizeConsumedOnCurrentLine < 0) {
|
|
|
|
// availableInnerMainDim is indefinite which means the node is being sized
|
|
|
|
// based on its
|
|
|
|
// content.
|
|
|
|
// sizeConsumedOnCurrentLine is negative which means the node will
|
2017-02-14 14:26:13 -08:00
|
|
|
// allocate 0 points for
|
2016-11-11 10:50:09 -08:00
|
|
|
// its content. Consequently, remainingFreeSpace is 0 -
|
|
|
|
// sizeConsumedOnCurrentLine.
|
|
|
|
remainingFreeSpace = -sizeConsumedOnCurrentLine;
|
|
|
|
}
|
|
|
|
|
|
|
|
const float originalRemainingFreeSpace = remainingFreeSpace;
|
|
|
|
float deltaFreeSpace = 0;
|
|
|
|
|
|
|
|
if (!canSkipFlex) {
|
|
|
|
float childFlexBasis;
|
|
|
|
float flexShrinkScaledFactor;
|
|
|
|
float flexGrowFactor;
|
|
|
|
float baseMainSize;
|
|
|
|
float boundMainSize;
|
|
|
|
|
|
|
|
// Do two passes over the flex items to figure out how to distribute the
|
|
|
|
// remaining space.
|
|
|
|
// The first pass finds the items whose min/max constraints trigger,
|
|
|
|
// freezes them at those
|
|
|
|
// sizes, and excludes those sizes from the remaining space. The second
|
|
|
|
// pass sets the size
|
|
|
|
// of each flexible item. It distributes the remaining space amongst the
|
|
|
|
// items whose min/max
|
|
|
|
// constraints didn't trigger in pass 1. For the other items, it sets
|
|
|
|
// their sizes by forcing
|
|
|
|
// their min/max constraints to trigger again.
|
|
|
|
//
|
|
|
|
// This two pass approach for resolving min/max constraints deviates from
|
|
|
|
// the spec. The
|
2016-12-03 04:40:18 -08:00
|
|
|
// spec (https://www.w3.org/TR/YG-flexbox-1/#resolve-flexible-lengths)
|
2016-11-11 10:50:09 -08:00
|
|
|
// describes a process
|
|
|
|
// that needs to be repeated a variable number of times. The algorithm
|
|
|
|
// implemented here
|
|
|
|
// won't handle all cases but it was simpler to implement and it mitigates
|
|
|
|
// performance
|
|
|
|
// concerns because we know exactly how many passes it'll do.
|
|
|
|
|
|
|
|
// First pass: detect the flex items whose min/max constraints trigger
|
|
|
|
float deltaFlexShrinkScaledFactors = 0;
|
|
|
|
float deltaFlexGrowFactors = 0;
|
|
|
|
currentRelativeChild = firstRelativeChild;
|
|
|
|
while (currentRelativeChild != NULL) {
|
|
|
|
childFlexBasis = currentRelativeChild->layout.computedFlexBasis;
|
|
|
|
|
|
|
|
if (remainingFreeSpace < 0) {
|
2017-02-28 09:17:17 -08:00
|
|
|
flexShrinkScaledFactor = -YGNodeResolveFlexShrink(currentRelativeChild) * childFlexBasis;
|
2016-11-11 10:50:09 -08:00
|
|
|
|
|
|
|
// Is this child able to shrink?
|
|
|
|
if (flexShrinkScaledFactor != 0) {
|
|
|
|
baseMainSize =
|
|
|
|
childFlexBasis +
|
|
|
|
remainingFreeSpace / totalFlexShrinkScaledFactors * flexShrinkScaledFactor;
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
boundMainSize = YGNodeBoundAxis(currentRelativeChild,
|
|
|
|
mainAxis,
|
|
|
|
baseMainSize,
|
|
|
|
availableInnerMainDim,
|
|
|
|
availableInnerWidth);
|
2016-11-11 10:50:09 -08:00
|
|
|
if (baseMainSize != boundMainSize) {
|
|
|
|
// By excluding this item's size and flex factor from remaining,
|
|
|
|
// this item's
|
|
|
|
// min/max constraints should also trigger in the second pass
|
|
|
|
// resulting in the
|
|
|
|
// item's size calculation being identical in the first and second
|
|
|
|
// passes.
|
|
|
|
deltaFreeSpace -= boundMainSize - childFlexBasis;
|
|
|
|
deltaFlexShrinkScaledFactors -= flexShrinkScaledFactor;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (remainingFreeSpace > 0) {
|
2017-02-28 09:17:17 -08:00
|
|
|
flexGrowFactor = YGResolveFlexGrow(currentRelativeChild);
|
2016-11-11 10:50:09 -08:00
|
|
|
|
|
|
|
// Is this child able to grow?
|
|
|
|
if (flexGrowFactor != 0) {
|
|
|
|
baseMainSize =
|
|
|
|
childFlexBasis + remainingFreeSpace / totalFlexGrowFactors * flexGrowFactor;
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
boundMainSize = YGNodeBoundAxis(currentRelativeChild,
|
|
|
|
mainAxis,
|
|
|
|
baseMainSize,
|
|
|
|
availableInnerMainDim,
|
|
|
|
availableInnerWidth);
|
2016-11-11 10:50:09 -08:00
|
|
|
if (baseMainSize != boundMainSize) {
|
|
|
|
// By excluding this item's size and flex factor from remaining,
|
|
|
|
// this item's
|
|
|
|
// min/max constraints should also trigger in the second pass
|
|
|
|
// resulting in the
|
|
|
|
// item's size calculation being identical in the first and second
|
|
|
|
// passes.
|
|
|
|
deltaFreeSpace -= boundMainSize - childFlexBasis;
|
|
|
|
deltaFlexGrowFactors -= flexGrowFactor;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
currentRelativeChild = currentRelativeChild->nextChild;
|
|
|
|
}
|
|
|
|
|
|
|
|
totalFlexShrinkScaledFactors += deltaFlexShrinkScaledFactors;
|
|
|
|
totalFlexGrowFactors += deltaFlexGrowFactors;
|
|
|
|
remainingFreeSpace += deltaFreeSpace;
|
|
|
|
|
|
|
|
// Second pass: resolve the sizes of the flexible items
|
|
|
|
deltaFreeSpace = 0;
|
|
|
|
currentRelativeChild = firstRelativeChild;
|
|
|
|
while (currentRelativeChild != NULL) {
|
|
|
|
childFlexBasis = currentRelativeChild->layout.computedFlexBasis;
|
|
|
|
float updatedMainSize = childFlexBasis;
|
|
|
|
|
|
|
|
if (remainingFreeSpace < 0) {
|
2017-02-28 09:17:17 -08:00
|
|
|
flexShrinkScaledFactor = -YGNodeResolveFlexShrink(currentRelativeChild) * childFlexBasis;
|
2016-11-11 10:50:09 -08:00
|
|
|
// Is this child able to shrink?
|
|
|
|
if (flexShrinkScaledFactor != 0) {
|
|
|
|
float childSize;
|
|
|
|
|
|
|
|
if (totalFlexShrinkScaledFactors == 0) {
|
|
|
|
childSize = childFlexBasis + flexShrinkScaledFactor;
|
|
|
|
} else {
|
|
|
|
childSize =
|
|
|
|
childFlexBasis +
|
|
|
|
(remainingFreeSpace / totalFlexShrinkScaledFactors) * flexShrinkScaledFactor;
|
|
|
|
}
|
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
updatedMainSize = YGNodeBoundAxis(currentRelativeChild,
|
|
|
|
mainAxis,
|
|
|
|
childSize,
|
|
|
|
availableInnerMainDim,
|
|
|
|
availableInnerWidth);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
} else if (remainingFreeSpace > 0) {
|
2017-02-28 09:17:17 -08:00
|
|
|
flexGrowFactor = YGResolveFlexGrow(currentRelativeChild);
|
2016-11-11 10:50:09 -08:00
|
|
|
|
|
|
|
// Is this child able to grow?
|
|
|
|
if (flexGrowFactor != 0) {
|
|
|
|
updatedMainSize =
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeBoundAxis(currentRelativeChild,
|
|
|
|
mainAxis,
|
|
|
|
childFlexBasis +
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
remainingFreeSpace / totalFlexGrowFactors * flexGrowFactor,
|
|
|
|
availableInnerMainDim,
|
|
|
|
availableInnerWidth);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
deltaFreeSpace -= updatedMainSize - childFlexBasis;
|
|
|
|
|
2017-02-16 07:39:14 -08:00
|
|
|
const float marginMain =
|
|
|
|
YGNodeMarginForAxis(currentRelativeChild, mainAxis, availableInnerWidth);
|
|
|
|
const float marginCross =
|
|
|
|
YGNodeMarginForAxis(currentRelativeChild, crossAxis, availableInnerWidth);
|
|
|
|
|
|
|
|
float childCrossSize;
|
|
|
|
float childMainSize = updatedMainSize + marginMain;
|
|
|
|
YGMeasureMode childCrossMeasureMode;
|
|
|
|
YGMeasureMode childMainMeasureMode = YGMeasureModeExactly;
|
|
|
|
|
|
|
|
if (!YGFloatIsUndefined(availableInnerCrossDim) &&
|
|
|
|
!YGNodeIsStyleDimDefined(currentRelativeChild, crossAxis, availableInnerCrossDim) &&
|
|
|
|
measureModeCrossDim == YGMeasureModeExactly &&
|
|
|
|
!(isNodeFlexWrap && flexBasisOverflows) &&
|
|
|
|
YGNodeAlignItem(node, currentRelativeChild) == YGAlignStretch) {
|
|
|
|
childCrossSize = availableInnerCrossDim;
|
|
|
|
childCrossMeasureMode = YGMeasureModeExactly;
|
|
|
|
} else if (!YGNodeIsStyleDimDefined(currentRelativeChild,
|
|
|
|
crossAxis,
|
|
|
|
availableInnerCrossDim)) {
|
|
|
|
childCrossSize = availableInnerCrossDim;
|
|
|
|
childCrossMeasureMode =
|
|
|
|
YGFloatIsUndefined(childCrossSize) ? YGMeasureModeUndefined : YGMeasureModeAtMost;
|
2016-11-11 10:50:09 -08:00
|
|
|
} else {
|
2017-03-10 06:05:53 -08:00
|
|
|
childCrossSize = YGResolveValue(currentRelativeChild->resolvedDimensions[dim[crossAxis]],
|
2017-02-16 07:39:14 -08:00
|
|
|
availableInnerCrossDim) +
|
|
|
|
marginCross;
|
2017-02-28 06:57:55 -08:00
|
|
|
const bool isLoosePercentageMeasurement =
|
|
|
|
currentRelativeChild->resolvedDimensions[dim[crossAxis]]->unit == YGUnitPercent &&
|
|
|
|
measureModeCrossDim != YGMeasureModeExactly;
|
|
|
|
childCrossMeasureMode = YGFloatIsUndefined(childCrossSize) || isLoosePercentageMeasurement
|
|
|
|
? YGMeasureModeUndefined
|
|
|
|
: YGMeasureModeExactly;
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
if (!YGFloatIsUndefined(currentRelativeChild->style.aspectRatio)) {
|
2017-02-16 07:39:14 -08:00
|
|
|
childCrossSize = fmaxf(
|
|
|
|
isMainAxisRow
|
|
|
|
? (childMainSize - marginMain) / currentRelativeChild->style.aspectRatio
|
|
|
|
: (childMainSize - marginMain) * currentRelativeChild->style.aspectRatio,
|
|
|
|
YGNodePaddingAndBorderForAxis(currentRelativeChild, crossAxis, availableInnerWidth));
|
|
|
|
childCrossMeasureMode = YGMeasureModeExactly;
|
|
|
|
|
|
|
|
// Parent size constraint should have higher priority than flex
|
|
|
|
if (YGNodeIsFlex(currentRelativeChild)) {
|
|
|
|
childCrossSize = fminf(childCrossSize - marginCross, availableInnerCrossDim);
|
|
|
|
childMainSize =
|
|
|
|
marginMain + (isMainAxisRow
|
|
|
|
? childCrossSize * currentRelativeChild->style.aspectRatio
|
|
|
|
: childCrossSize / currentRelativeChild->style.aspectRatio);
|
2016-11-21 10:12:26 -08:00
|
|
|
}
|
2017-02-16 07:39:14 -08:00
|
|
|
|
|
|
|
childCrossSize += marginCross;
|
2016-11-21 10:12:26 -08:00
|
|
|
}
|
|
|
|
|
2017-03-09 03:48:33 -08:00
|
|
|
YGConstrainMaxSizeForMode(currentRelativeChild,
|
|
|
|
mainAxis,
|
|
|
|
availableInnerMainDim,
|
|
|
|
availableInnerWidth,
|
|
|
|
&childMainMeasureMode,
|
|
|
|
&childMainSize);
|
|
|
|
YGConstrainMaxSizeForMode(currentRelativeChild,
|
|
|
|
crossAxis,
|
|
|
|
availableInnerCrossDim,
|
|
|
|
availableInnerWidth,
|
|
|
|
&childCrossMeasureMode,
|
|
|
|
&childCrossSize);
|
2016-11-11 10:50:09 -08:00
|
|
|
|
|
|
|
const bool requiresStretchLayout =
|
2017-02-03 05:37:44 -08:00
|
|
|
!YGNodeIsStyleDimDefined(currentRelativeChild, crossAxis, availableInnerCrossDim) &&
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeAlignItem(node, currentRelativeChild) == YGAlignStretch;
|
2016-11-11 10:50:09 -08:00
|
|
|
|
2017-02-16 07:39:14 -08:00
|
|
|
const float childWidth = isMainAxisRow ? childMainSize : childCrossSize;
|
|
|
|
const float childHeight = !isMainAxisRow ? childMainSize : childCrossSize;
|
|
|
|
|
|
|
|
const YGMeasureMode childWidthMeasureMode =
|
|
|
|
isMainAxisRow ? childMainMeasureMode : childCrossMeasureMode;
|
|
|
|
const YGMeasureMode childHeightMeasureMode =
|
|
|
|
!isMainAxisRow ? childMainMeasureMode : childCrossMeasureMode;
|
|
|
|
|
2016-11-11 10:50:09 -08:00
|
|
|
// Recursively call the layout algorithm for this child with the updated
|
|
|
|
// main size.
|
2016-12-03 04:40:18 -08:00
|
|
|
YGLayoutNodeInternal(currentRelativeChild,
|
|
|
|
childWidth,
|
|
|
|
childHeight,
|
|
|
|
direction,
|
|
|
|
childWidthMeasureMode,
|
|
|
|
childHeightMeasureMode,
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
availableInnerWidth,
|
|
|
|
availableInnerHeight,
|
2016-12-03 04:40:18 -08:00
|
|
|
performLayout && !requiresStretchLayout,
|
2017-03-01 09:19:55 -08:00
|
|
|
"flex",
|
|
|
|
config);
|
2016-11-11 10:50:09 -08:00
|
|
|
|
|
|
|
currentRelativeChild = currentRelativeChild->nextChild;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
remainingFreeSpace = originalRemainingFreeSpace + deltaFreeSpace;
|
|
|
|
|
|
|
|
// STEP 6: MAIN-AXIS JUSTIFICATION & CROSS-AXIS SIZE DETERMINATION
|
|
|
|
|
|
|
|
// At this point, all the children have their dimensions set in the main
|
|
|
|
// axis.
|
|
|
|
// Their dimensions are also set in the cross axis with the exception of
|
|
|
|
// items
|
|
|
|
// that are aligned "stretch". We need to compute these stretch values and
|
|
|
|
// set the final positions.
|
|
|
|
|
|
|
|
// If we are using "at most" rules in the main axis. Calculate the remaining space when
|
|
|
|
// constraint by the min size defined for the main axis.
|
|
|
|
|
2016-12-02 05:47:43 -08:00
|
|
|
if (measureModeMainDim == YGMeasureModeAtMost && remainingFreeSpace > 0) {
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
if (node->style.minDimensions[dim[mainAxis]].unit != YGUnitUndefined &&
|
2017-03-10 06:05:53 -08:00
|
|
|
YGResolveValue(&node->style.minDimensions[dim[mainAxis]], mainAxisParentSize) >= 0) {
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
remainingFreeSpace =
|
|
|
|
fmaxf(0,
|
2017-03-10 06:05:53 -08:00
|
|
|
YGResolveValue(&node->style.minDimensions[dim[mainAxis]], mainAxisParentSize) -
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
(availableInnerMainDim - remainingFreeSpace));
|
2016-11-11 10:50:09 -08:00
|
|
|
} else {
|
|
|
|
remainingFreeSpace = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-14 14:26:09 -08:00
|
|
|
int numberOfAutoMarginsOnCurrentLine = 0;
|
|
|
|
for (uint32_t i = startOfLineIndex; i < endOfLineIndex; i++) {
|
|
|
|
const YGNodeRef child = YGNodeListGet(node->children, i);
|
|
|
|
if (child->style.positionType == YGPositionTypeRelative) {
|
2017-03-01 09:12:40 -08:00
|
|
|
if (YGMarginLeadingValue(child, mainAxis)->unit == YGUnitAuto) {
|
2017-02-14 14:26:09 -08:00
|
|
|
numberOfAutoMarginsOnCurrentLine++;
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
2017-03-01 09:12:40 -08:00
|
|
|
if (YGMarginTrailingValue(child, mainAxis)->unit == YGUnitAuto) {
|
2017-02-14 14:26:09 -08:00
|
|
|
numberOfAutoMarginsOnCurrentLine++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (numberOfAutoMarginsOnCurrentLine == 0) {
|
|
|
|
switch (justifyContent) {
|
|
|
|
case YGJustifyCenter:
|
|
|
|
leadingMainDim = remainingFreeSpace / 2;
|
|
|
|
break;
|
|
|
|
case YGJustifyFlexEnd:
|
|
|
|
leadingMainDim = remainingFreeSpace;
|
|
|
|
break;
|
|
|
|
case YGJustifySpaceBetween:
|
|
|
|
if (itemsOnLine > 1) {
|
|
|
|
betweenMainDim = fmaxf(remainingFreeSpace, 0) / (itemsOnLine - 1);
|
|
|
|
} else {
|
|
|
|
betweenMainDim = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case YGJustifySpaceAround:
|
|
|
|
// Space on the edges is half of the space between elements
|
|
|
|
betweenMainDim = remainingFreeSpace / itemsOnLine;
|
|
|
|
leadingMainDim = betweenMainDim / 2;
|
|
|
|
break;
|
|
|
|
case YGJustifyFlexStart:
|
|
|
|
break;
|
|
|
|
}
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
float mainDim = leadingPaddingAndBorderMain + leadingMainDim;
|
|
|
|
float crossDim = 0;
|
|
|
|
|
|
|
|
for (uint32_t i = startOfLineIndex; i < endOfLineIndex; i++) {
|
2016-12-03 04:40:18 -08:00
|
|
|
const YGNodeRef child = YGNodeListGet(node->children, i);
|
2017-02-06 09:31:22 -08:00
|
|
|
if (child->style.display == YGDisplayNone) {
|
|
|
|
continue;
|
|
|
|
}
|
2016-12-02 05:47:43 -08:00
|
|
|
if (child->style.positionType == YGPositionTypeAbsolute &&
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeIsLeadingPosDefined(child, mainAxis)) {
|
2016-11-11 10:50:09 -08:00
|
|
|
if (performLayout) {
|
|
|
|
// In case the child is position absolute and has left/top being
|
|
|
|
// defined, we override the position to whatever the user said
|
|
|
|
// (and margin/border).
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
child->layout.position[pos[mainAxis]] =
|
|
|
|
YGNodeLeadingPosition(child, mainAxis, availableInnerMainDim) +
|
|
|
|
YGNodeLeadingBorder(node, mainAxis) +
|
|
|
|
YGNodeLeadingMargin(child, mainAxis, availableInnerWidth);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Now that we placed the element, we need to update the variables.
|
|
|
|
// We need to do that only for relative elements. Absolute elements
|
|
|
|
// do not take part in that phase.
|
2016-12-02 05:47:43 -08:00
|
|
|
if (child->style.positionType == YGPositionTypeRelative) {
|
2017-03-01 09:12:40 -08:00
|
|
|
if (YGMarginLeadingValue(child, mainAxis)->unit == YGUnitAuto) {
|
2017-02-14 14:26:09 -08:00
|
|
|
mainDim += remainingFreeSpace / numberOfAutoMarginsOnCurrentLine;
|
|
|
|
}
|
|
|
|
|
2016-11-11 10:50:09 -08:00
|
|
|
if (performLayout) {
|
|
|
|
child->layout.position[pos[mainAxis]] += mainDim;
|
|
|
|
}
|
|
|
|
|
2017-03-01 09:12:40 -08:00
|
|
|
if (YGMarginTrailingValue(child, mainAxis)->unit == YGUnitAuto) {
|
2017-02-14 14:26:09 -08:00
|
|
|
mainDim += remainingFreeSpace / numberOfAutoMarginsOnCurrentLine;
|
|
|
|
}
|
|
|
|
|
2016-11-11 10:50:09 -08:00
|
|
|
if (canSkipFlex) {
|
|
|
|
// If we skipped the flex step, then we can't rely on the
|
|
|
|
// measuredDims because
|
2016-12-03 04:40:18 -08:00
|
|
|
// they weren't computed. This means we can't call YGNodeDimWithMargin.
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
mainDim += betweenMainDim + YGNodeMarginForAxis(child, mainAxis, availableInnerWidth) +
|
2016-12-03 04:40:18 -08:00
|
|
|
child->layout.computedFlexBasis;
|
2016-11-11 10:50:09 -08:00
|
|
|
crossDim = availableInnerCrossDim;
|
|
|
|
} else {
|
2017-02-14 09:16:59 -08:00
|
|
|
// The main dimension is the sum of all the elements dimension plus the spacing.
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
mainDim += betweenMainDim + YGNodeDimWithMargin(child, mainAxis, availableInnerWidth);
|
2016-11-11 10:50:09 -08:00
|
|
|
|
2017-02-13 01:05:23 -08:00
|
|
|
// The cross dimension is the max of the elements dimension since
|
2017-02-14 09:16:59 -08:00
|
|
|
// there can only be one element in that cross dimension.
|
2017-02-13 01:05:23 -08:00
|
|
|
crossDim = fmaxf(crossDim, YGNodeDimWithMargin(child, crossAxis, availableInnerWidth));
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
} else if (performLayout) {
|
|
|
|
child->layout.position[pos[mainAxis]] +=
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeLeadingBorder(node, mainAxis) + leadingMainDim;
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mainDim += trailingPaddingAndBorderMain;
|
|
|
|
|
|
|
|
float containerCrossAxis = availableInnerCrossDim;
|
2016-12-02 05:47:43 -08:00
|
|
|
if (measureModeCrossDim == YGMeasureModeUndefined ||
|
|
|
|
measureModeCrossDim == YGMeasureModeAtMost) {
|
2016-11-11 10:50:09 -08:00
|
|
|
// Compute the cross axis from the max cross dimension of the children.
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
containerCrossAxis = YGNodeBoundAxis(node,
|
|
|
|
crossAxis,
|
|
|
|
crossDim + paddingAndBorderAxisCross,
|
|
|
|
crossAxisParentSize,
|
|
|
|
parentWidth) -
|
2016-11-11 10:50:09 -08:00
|
|
|
paddingAndBorderAxisCross;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If there's no flex wrap, the cross dimension is defined by the container.
|
2016-12-02 05:47:43 -08:00
|
|
|
if (!isNodeFlexWrap && measureModeCrossDim == YGMeasureModeExactly) {
|
2016-11-11 10:50:09 -08:00
|
|
|
crossDim = availableInnerCrossDim;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Clamp to the min/max size specified on the container.
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
crossDim = YGNodeBoundAxis(node,
|
|
|
|
crossAxis,
|
|
|
|
crossDim + paddingAndBorderAxisCross,
|
|
|
|
crossAxisParentSize,
|
|
|
|
parentWidth) -
|
2016-11-11 10:50:09 -08:00
|
|
|
paddingAndBorderAxisCross;
|
|
|
|
|
|
|
|
// STEP 7: CROSS-AXIS ALIGNMENT
|
|
|
|
// We can skip child alignment if we're just measuring the container.
|
|
|
|
if (performLayout) {
|
|
|
|
for (uint32_t i = startOfLineIndex; i < endOfLineIndex; i++) {
|
2016-12-03 04:40:18 -08:00
|
|
|
const YGNodeRef child = YGNodeListGet(node->children, i);
|
2017-02-06 09:31:22 -08:00
|
|
|
if (child->style.display == YGDisplayNone) {
|
|
|
|
continue;
|
|
|
|
}
|
2016-12-02 05:47:43 -08:00
|
|
|
if (child->style.positionType == YGPositionTypeAbsolute) {
|
2016-11-11 10:50:09 -08:00
|
|
|
// If the child is absolutely positioned and has a
|
|
|
|
// top/left/bottom/right
|
|
|
|
// set, override all the previously computed positions to set it
|
|
|
|
// correctly.
|
2016-12-03 04:40:18 -08:00
|
|
|
if (YGNodeIsLeadingPosDefined(child, crossAxis)) {
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
child->layout.position[pos[crossAxis]] =
|
|
|
|
YGNodeLeadingPosition(child, crossAxis, availableInnerCrossDim) +
|
|
|
|
YGNodeLeadingBorder(node, crossAxis) +
|
|
|
|
YGNodeLeadingMargin(child, crossAxis, availableInnerWidth);
|
2016-11-11 10:50:09 -08:00
|
|
|
} else {
|
|
|
|
child->layout.position[pos[crossAxis]] =
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
YGNodeLeadingBorder(node, crossAxis) +
|
|
|
|
YGNodeLeadingMargin(child, crossAxis, availableInnerWidth);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
float leadingCrossDim = leadingPaddingAndBorderCross;
|
|
|
|
|
|
|
|
// For a relative children, we're either using alignItems (parent) or
|
|
|
|
// alignSelf (child) in order to determine the position in the cross
|
|
|
|
// axis
|
2016-12-03 04:40:18 -08:00
|
|
|
const YGAlign alignItem = YGNodeAlignItem(node, child);
|
2016-11-11 10:50:09 -08:00
|
|
|
|
|
|
|
// If the child uses align stretch, we need to lay it out one more
|
|
|
|
// time, this time
|
|
|
|
// forcing the cross-axis size to be the computed cross size for the
|
|
|
|
// current line.
|
2017-02-14 14:26:09 -08:00
|
|
|
if (alignItem == YGAlignStretch &&
|
2017-03-01 09:12:40 -08:00
|
|
|
YGMarginLeadingValue(child, crossAxis)->unit != YGUnitAuto &&
|
|
|
|
YGMarginTrailingValue(child, crossAxis)->unit != YGUnitAuto) {
|
2016-11-11 10:50:09 -08:00
|
|
|
// If the child defines a definite size for its cross axis, there's
|
|
|
|
// no need to stretch.
|
2017-02-16 07:39:14 -08:00
|
|
|
if (!YGNodeIsStyleDimDefined(child, crossAxis, availableInnerCrossDim)) {
|
|
|
|
float childMainSize = child->layout.measuredDimensions[dim[mainAxis]];
|
|
|
|
float childCrossSize =
|
|
|
|
!YGFloatIsUndefined(child->style.aspectRatio)
|
|
|
|
? ((YGNodeMarginForAxis(child, crossAxis, availableInnerWidth) +
|
|
|
|
(isMainAxisRow ? childMainSize / child->style.aspectRatio
|
|
|
|
: childMainSize * child->style.aspectRatio)))
|
|
|
|
: crossDim;
|
|
|
|
|
|
|
|
childMainSize += YGNodeMarginForAxis(child, mainAxis, availableInnerWidth);
|
|
|
|
|
|
|
|
YGMeasureMode childMainMeasureMode = YGMeasureModeExactly;
|
|
|
|
YGMeasureMode childCrossMeasureMode = YGMeasureModeExactly;
|
2017-03-09 03:48:33 -08:00
|
|
|
YGConstrainMaxSizeForMode(child,
|
|
|
|
mainAxis,
|
|
|
|
availableInnerMainDim,
|
|
|
|
availableInnerWidth,
|
2017-02-16 07:39:14 -08:00
|
|
|
&childMainMeasureMode,
|
|
|
|
&childMainSize);
|
2017-03-09 03:48:33 -08:00
|
|
|
YGConstrainMaxSizeForMode(child,
|
|
|
|
crossAxis,
|
|
|
|
availableInnerCrossDim,
|
|
|
|
availableInnerWidth,
|
2017-02-16 07:39:14 -08:00
|
|
|
&childCrossMeasureMode,
|
|
|
|
&childCrossSize);
|
|
|
|
|
|
|
|
const float childWidth = isMainAxisRow ? childMainSize : childCrossSize;
|
|
|
|
const float childHeight = !isMainAxisRow ? childMainSize : childCrossSize;
|
|
|
|
|
|
|
|
const YGMeasureMode childWidthMeasureMode =
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
YGFloatIsUndefined(childWidth) ? YGMeasureModeUndefined : YGMeasureModeExactly;
|
2017-02-16 07:39:14 -08:00
|
|
|
const YGMeasureMode childHeightMeasureMode =
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
YGFloatIsUndefined(childHeight) ? YGMeasureModeUndefined : YGMeasureModeExactly;
|
2016-12-03 04:40:18 -08:00
|
|
|
|
|
|
|
YGLayoutNodeInternal(child,
|
|
|
|
childWidth,
|
|
|
|
childHeight,
|
|
|
|
direction,
|
|
|
|
childWidthMeasureMode,
|
|
|
|
childHeightMeasureMode,
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
availableInnerWidth,
|
|
|
|
availableInnerHeight,
|
2016-12-03 04:40:18 -08:00
|
|
|
true,
|
2017-03-01 09:19:55 -08:00
|
|
|
"stretch",
|
|
|
|
config);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
2017-02-14 14:26:09 -08:00
|
|
|
} else {
|
2016-12-03 04:40:18 -08:00
|
|
|
const float remainingCrossDim =
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
containerCrossAxis - YGNodeDimWithMargin(child, crossAxis, availableInnerWidth);
|
2016-11-11 10:50:09 -08:00
|
|
|
|
2017-03-01 09:12:40 -08:00
|
|
|
if (YGMarginLeadingValue(child, crossAxis)->unit == YGUnitAuto &&
|
|
|
|
YGMarginTrailingValue(child, crossAxis)->unit == YGUnitAuto) {
|
2017-03-15 05:20:38 -07:00
|
|
|
leadingCrossDim += fmaxf(0.0f, remainingCrossDim / 2);
|
2017-03-01 09:12:40 -08:00
|
|
|
} else if (YGMarginTrailingValue(child, crossAxis)->unit == YGUnitAuto) {
|
2017-02-14 14:26:09 -08:00
|
|
|
// No-Op
|
2017-03-01 09:12:40 -08:00
|
|
|
} else if (YGMarginLeadingValue(child, crossAxis)->unit == YGUnitAuto) {
|
2017-03-15 05:20:38 -07:00
|
|
|
leadingCrossDim += fmaxf(0.0f, remainingCrossDim);
|
2017-02-14 14:26:09 -08:00
|
|
|
} else if (alignItem == YGAlignFlexStart) {
|
|
|
|
// No-Op
|
|
|
|
} else if (alignItem == YGAlignCenter) {
|
|
|
|
leadingCrossDim += remainingCrossDim / 2;
|
|
|
|
} else {
|
2016-11-11 10:50:09 -08:00
|
|
|
leadingCrossDim += remainingCrossDim;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// And we apply the position
|
|
|
|
child->layout.position[pos[crossAxis]] += totalLineCrossDim + leadingCrossDim;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
totalLineCrossDim += crossDim;
|
|
|
|
maxLineMainDim = fmaxf(maxLineMainDim, mainDim);
|
|
|
|
}
|
|
|
|
|
|
|
|
// STEP 8: MULTI-LINE CONTENT ALIGNMENT
|
2017-02-23 08:25:16 -08:00
|
|
|
if (performLayout && (lineCount > 1 || YGIsBaselineLayout(node)) &&
|
2017-01-06 06:51:56 -08:00
|
|
|
!YGFloatIsUndefined(availableInnerCrossDim)) {
|
2016-11-11 10:50:09 -08:00
|
|
|
const float remainingAlignContentDim = availableInnerCrossDim - totalLineCrossDim;
|
|
|
|
|
|
|
|
float crossDimLead = 0;
|
|
|
|
float currentLead = leadingPaddingAndBorderCross;
|
|
|
|
|
|
|
|
switch (node->style.alignContent) {
|
2016-12-02 05:47:43 -08:00
|
|
|
case YGAlignFlexEnd:
|
2016-11-11 10:50:09 -08:00
|
|
|
currentLead += remainingAlignContentDim;
|
|
|
|
break;
|
2016-12-02 05:47:43 -08:00
|
|
|
case YGAlignCenter:
|
2016-11-11 10:50:09 -08:00
|
|
|
currentLead += remainingAlignContentDim / 2;
|
|
|
|
break;
|
2016-12-02 05:47:43 -08:00
|
|
|
case YGAlignStretch:
|
2016-11-11 10:50:09 -08:00
|
|
|
if (availableInnerCrossDim > totalLineCrossDim) {
|
2017-02-11 08:32:48 -08:00
|
|
|
crossDimLead = remainingAlignContentDim / lineCount;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case YGAlignSpaceAround:
|
|
|
|
if (availableInnerCrossDim > totalLineCrossDim) {
|
|
|
|
currentLead += remainingAlignContentDim / (2 * lineCount);
|
|
|
|
if (lineCount > 1) {
|
|
|
|
crossDimLead = remainingAlignContentDim / lineCount;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
currentLead += remainingAlignContentDim / 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case YGAlignSpaceBetween:
|
|
|
|
if (availableInnerCrossDim > totalLineCrossDim && lineCount > 1) {
|
|
|
|
crossDimLead = remainingAlignContentDim / (lineCount - 1);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
break;
|
2016-12-02 05:47:43 -08:00
|
|
|
case YGAlignAuto:
|
|
|
|
case YGAlignFlexStart:
|
2017-01-06 06:51:56 -08:00
|
|
|
case YGAlignBaseline:
|
2016-11-11 10:50:09 -08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t endIndex = 0;
|
|
|
|
for (uint32_t i = 0; i < lineCount; i++) {
|
2017-02-16 07:39:14 -08:00
|
|
|
const uint32_t startIndex = endIndex;
|
2016-11-11 10:50:09 -08:00
|
|
|
uint32_t ii;
|
|
|
|
|
|
|
|
// compute the line's height and find the endIndex
|
|
|
|
float lineHeight = 0;
|
2017-01-06 06:51:56 -08:00
|
|
|
float maxAscentForCurrentLine = 0;
|
|
|
|
float maxDescentForCurrentLine = 0;
|
2016-11-11 10:50:09 -08:00
|
|
|
for (ii = startIndex; ii < childCount; ii++) {
|
2016-12-03 04:40:18 -08:00
|
|
|
const YGNodeRef child = YGNodeListGet(node->children, ii);
|
2017-02-06 09:31:22 -08:00
|
|
|
if (child->style.display == YGDisplayNone) {
|
|
|
|
continue;
|
|
|
|
}
|
2016-12-02 05:47:43 -08:00
|
|
|
if (child->style.positionType == YGPositionTypeRelative) {
|
2016-11-11 10:50:09 -08:00
|
|
|
if (child->lineIndex != i) {
|
|
|
|
break;
|
|
|
|
}
|
2016-12-03 04:40:18 -08:00
|
|
|
if (YGNodeIsLayoutDimDefined(child, crossAxis)) {
|
2016-11-11 10:50:09 -08:00
|
|
|
lineHeight = fmaxf(lineHeight,
|
|
|
|
child->layout.measuredDimensions[dim[crossAxis]] +
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
YGNodeMarginForAxis(child, crossAxis, availableInnerWidth));
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
2017-01-06 06:51:56 -08:00
|
|
|
if (YGNodeAlignItem(node, child) == YGAlignBaseline) {
|
|
|
|
const float ascent =
|
|
|
|
YGBaseline(child) +
|
|
|
|
YGNodeLeadingMargin(child, YGFlexDirectionColumn, availableInnerWidth);
|
|
|
|
const float descent =
|
|
|
|
child->layout.measuredDimensions[YGDimensionHeight] +
|
|
|
|
YGNodeMarginForAxis(child, YGFlexDirectionColumn, availableInnerWidth) - ascent;
|
|
|
|
maxAscentForCurrentLine = fmaxf(maxAscentForCurrentLine, ascent);
|
|
|
|
maxDescentForCurrentLine = fmaxf(maxDescentForCurrentLine, descent);
|
|
|
|
lineHeight = fmaxf(lineHeight, maxAscentForCurrentLine + maxDescentForCurrentLine);
|
|
|
|
}
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
endIndex = ii;
|
|
|
|
lineHeight += crossDimLead;
|
|
|
|
|
|
|
|
if (performLayout) {
|
|
|
|
for (ii = startIndex; ii < endIndex; ii++) {
|
2016-12-03 04:40:18 -08:00
|
|
|
const YGNodeRef child = YGNodeListGet(node->children, ii);
|
2017-02-06 09:31:22 -08:00
|
|
|
if (child->style.display == YGDisplayNone) {
|
|
|
|
continue;
|
|
|
|
}
|
2016-12-02 05:47:43 -08:00
|
|
|
if (child->style.positionType == YGPositionTypeRelative) {
|
2016-12-03 04:40:18 -08:00
|
|
|
switch (YGNodeAlignItem(node, child)) {
|
2016-12-02 05:47:43 -08:00
|
|
|
case YGAlignFlexStart: {
|
2016-11-11 10:50:09 -08:00
|
|
|
child->layout.position[pos[crossAxis]] =
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
currentLead + YGNodeLeadingMargin(child, crossAxis, availableInnerWidth);
|
2016-11-11 10:50:09 -08:00
|
|
|
break;
|
|
|
|
}
|
2016-12-02 05:47:43 -08:00
|
|
|
case YGAlignFlexEnd: {
|
2016-11-11 10:50:09 -08:00
|
|
|
child->layout.position[pos[crossAxis]] =
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
currentLead + lineHeight -
|
|
|
|
YGNodeTrailingMargin(child, crossAxis, availableInnerWidth) -
|
2016-11-11 10:50:09 -08:00
|
|
|
child->layout.measuredDimensions[dim[crossAxis]];
|
|
|
|
break;
|
|
|
|
}
|
2016-12-02 05:47:43 -08:00
|
|
|
case YGAlignCenter: {
|
2016-11-11 10:50:09 -08:00
|
|
|
float childHeight = child->layout.measuredDimensions[dim[crossAxis]];
|
|
|
|
child->layout.position[pos[crossAxis]] =
|
|
|
|
currentLead + (lineHeight - childHeight) / 2;
|
|
|
|
break;
|
|
|
|
}
|
2016-12-02 05:47:43 -08:00
|
|
|
case YGAlignStretch: {
|
2016-11-11 10:50:09 -08:00
|
|
|
child->layout.position[pos[crossAxis]] =
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
currentLead + YGNodeLeadingMargin(child, crossAxis, availableInnerWidth);
|
2017-02-14 09:16:59 -08:00
|
|
|
|
|
|
|
// Remeasure child with the line height as it as been only measured with the
|
|
|
|
// parents height yet.
|
|
|
|
if (!YGNodeIsStyleDimDefined(child, crossAxis, availableInnerCrossDim)) {
|
|
|
|
const float childWidth =
|
|
|
|
isMainAxisRow ? (child->layout.measuredDimensions[YGDimensionWidth] +
|
|
|
|
YGNodeMarginForAxis(child, crossAxis, availableInnerWidth))
|
|
|
|
: lineHeight;
|
|
|
|
|
|
|
|
const float childHeight =
|
|
|
|
!isMainAxisRow ? (child->layout.measuredDimensions[YGDimensionHeight] +
|
|
|
|
YGNodeMarginForAxis(child, crossAxis, availableInnerWidth))
|
|
|
|
: lineHeight;
|
|
|
|
|
|
|
|
if (!(YGFloatsEqual(childWidth,
|
|
|
|
child->layout.measuredDimensions[YGDimensionWidth]) &&
|
|
|
|
YGFloatsEqual(childHeight,
|
|
|
|
child->layout.measuredDimensions[YGDimensionHeight]))) {
|
|
|
|
YGLayoutNodeInternal(child,
|
|
|
|
childWidth,
|
|
|
|
childHeight,
|
|
|
|
direction,
|
|
|
|
YGMeasureModeExactly,
|
|
|
|
YGMeasureModeExactly,
|
|
|
|
availableInnerWidth,
|
|
|
|
availableInnerHeight,
|
|
|
|
true,
|
2017-03-03 10:20:24 -08:00
|
|
|
"multiline-stretch",
|
2017-03-01 09:19:55 -08:00
|
|
|
config);
|
2017-02-14 09:16:59 -08:00
|
|
|
}
|
|
|
|
}
|
2016-11-11 10:50:09 -08:00
|
|
|
break;
|
|
|
|
}
|
2017-01-06 06:51:56 -08:00
|
|
|
case YGAlignBaseline: {
|
|
|
|
child->layout.position[YGEdgeTop] =
|
|
|
|
currentLead + maxAscentForCurrentLine - YGBaseline(child) +
|
|
|
|
YGNodeLeadingPosition(child, YGFlexDirectionColumn, availableInnerCrossDim);
|
|
|
|
break;
|
|
|
|
}
|
2016-12-02 05:47:43 -08:00
|
|
|
case YGAlignAuto:
|
2017-02-11 08:32:48 -08:00
|
|
|
case YGAlignSpaceBetween:
|
|
|
|
case YGAlignSpaceAround:
|
2016-11-11 10:50:09 -08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
currentLead += lineHeight;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// STEP 9: COMPUTING FINAL DIMENSIONS
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
node->layout.measuredDimensions[YGDimensionWidth] = YGNodeBoundAxis(
|
|
|
|
node, YGFlexDirectionRow, availableWidth - marginAxisRow, parentWidth, parentWidth);
|
|
|
|
node->layout.measuredDimensions[YGDimensionHeight] = YGNodeBoundAxis(
|
|
|
|
node, YGFlexDirectionColumn, availableHeight - marginAxisColumn, parentHeight, parentWidth);
|
2016-11-11 10:50:09 -08:00
|
|
|
|
|
|
|
// If the user didn't specify a width or height for the node, set the
|
|
|
|
// dimensions based on the children.
|
2017-01-16 11:08:46 -08:00
|
|
|
if (measureModeMainDim == YGMeasureModeUndefined ||
|
|
|
|
(node->style.overflow != YGOverflowScroll && measureModeMainDim == YGMeasureModeAtMost)) {
|
2016-11-11 10:50:09 -08:00
|
|
|
// Clamp the size to the min/max size, if specified, and make sure it
|
|
|
|
// doesn't go below the padding and border amount.
|
2016-12-03 04:40:18 -08:00
|
|
|
node->layout.measuredDimensions[dim[mainAxis]] =
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
YGNodeBoundAxis(node, mainAxis, maxLineMainDim, mainAxisParentSize, parentWidth);
|
2017-01-16 11:08:46 -08:00
|
|
|
} else if (measureModeMainDim == YGMeasureModeAtMost &&
|
|
|
|
node->style.overflow == YGOverflowScroll) {
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
node->layout.measuredDimensions[dim[mainAxis]] = fmaxf(
|
|
|
|
fminf(availableInnerMainDim + paddingAndBorderAxisMain,
|
|
|
|
YGNodeBoundAxisWithinMinAndMax(node, mainAxis, maxLineMainDim, mainAxisParentSize)),
|
|
|
|
paddingAndBorderAxisMain);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2017-01-16 11:08:46 -08:00
|
|
|
if (measureModeCrossDim == YGMeasureModeUndefined ||
|
|
|
|
(node->style.overflow != YGOverflowScroll && measureModeCrossDim == YGMeasureModeAtMost)) {
|
2016-11-11 10:50:09 -08:00
|
|
|
// Clamp the size to the min/max size, if specified, and make sure it
|
|
|
|
// doesn't go below the padding and border amount.
|
|
|
|
node->layout.measuredDimensions[dim[crossAxis]] =
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
YGNodeBoundAxis(node,
|
|
|
|
crossAxis,
|
|
|
|
totalLineCrossDim + paddingAndBorderAxisCross,
|
|
|
|
crossAxisParentSize,
|
|
|
|
parentWidth);
|
2017-01-16 11:08:46 -08:00
|
|
|
} else if (measureModeCrossDim == YGMeasureModeAtMost &&
|
|
|
|
node->style.overflow == YGOverflowScroll) {
|
2016-11-11 10:50:09 -08:00
|
|
|
node->layout.measuredDimensions[dim[crossAxis]] =
|
|
|
|
fmaxf(fminf(availableInnerCrossDim + paddingAndBorderAxisCross,
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeBoundAxisWithinMinAndMax(node,
|
|
|
|
crossAxis,
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
totalLineCrossDim + paddingAndBorderAxisCross,
|
|
|
|
crossAxisParentSize)),
|
2016-11-11 10:50:09 -08:00
|
|
|
paddingAndBorderAxisCross);
|
|
|
|
}
|
|
|
|
|
2017-02-15 13:35:24 -08:00
|
|
|
// As we only wrapped in normal direction yet, we need to reverse the positions on wrap-reverse.
|
|
|
|
if (performLayout && node->style.flexWrap == YGWrapWrapReverse) {
|
|
|
|
for (uint32_t i = 0; i < childCount; i++) {
|
|
|
|
const YGNodeRef child = YGNodeGetChild(node, i);
|
|
|
|
if (child->style.positionType == YGPositionTypeRelative) {
|
|
|
|
child->layout.position[pos[crossAxis]] = node->layout.measuredDimensions[dim[crossAxis]] -
|
|
|
|
child->layout.position[pos[crossAxis]] -
|
|
|
|
child->layout.measuredDimensions[dim[crossAxis]];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-11 10:50:09 -08:00
|
|
|
if (performLayout) {
|
|
|
|
// STEP 10: SIZING AND POSITIONING ABSOLUTE CHILDREN
|
|
|
|
for (currentAbsoluteChild = firstAbsoluteChild; currentAbsoluteChild != NULL;
|
|
|
|
currentAbsoluteChild = currentAbsoluteChild->nextChild) {
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
YGNodeAbsoluteLayoutChild(node,
|
|
|
|
currentAbsoluteChild,
|
|
|
|
availableInnerWidth,
|
2017-02-20 07:16:58 -08:00
|
|
|
isMainAxisRow ? measureModeMainDim : measureModeCrossDim,
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
availableInnerHeight,
|
2017-03-01 09:19:55 -08:00
|
|
|
direction,
|
|
|
|
config);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// STEP 11: SETTING TRAILING POSITIONS FOR CHILDREN
|
|
|
|
const bool needsMainTrailingPos =
|
2016-12-02 05:47:43 -08:00
|
|
|
mainAxis == YGFlexDirectionRowReverse || mainAxis == YGFlexDirectionColumnReverse;
|
2016-11-11 10:50:09 -08:00
|
|
|
const bool needsCrossTrailingPos =
|
2016-12-05 09:35:26 -08:00
|
|
|
crossAxis == YGFlexDirectionRowReverse || crossAxis == YGFlexDirectionColumnReverse;
|
2016-11-11 10:50:09 -08:00
|
|
|
|
|
|
|
// Set trailing position if necessary.
|
|
|
|
if (needsMainTrailingPos || needsCrossTrailingPos) {
|
|
|
|
for (uint32_t i = 0; i < childCount; i++) {
|
2016-12-03 04:40:18 -08:00
|
|
|
const YGNodeRef child = YGNodeListGet(node->children, i);
|
2017-02-06 09:31:22 -08:00
|
|
|
if (child->style.display == YGDisplayNone) {
|
|
|
|
continue;
|
|
|
|
}
|
2016-11-11 10:50:09 -08:00
|
|
|
if (needsMainTrailingPos) {
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeSetChildTrailingPosition(node, child, mainAxis);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (needsCrossTrailingPos) {
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeSetChildTrailingPosition(node, child, crossAxis);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t gDepth = 0;
|
|
|
|
bool gPrintTree = false;
|
|
|
|
bool gPrintChanges = false;
|
|
|
|
bool gPrintSkips = false;
|
|
|
|
|
|
|
|
static const char *spacer = " ";
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
static const char *YGSpacer(const unsigned long level) {
|
2016-11-17 20:41:44 -08:00
|
|
|
const size_t spacerLen = strlen(spacer);
|
2016-11-11 10:50:09 -08:00
|
|
|
if (level > spacerLen) {
|
|
|
|
return &spacer[0];
|
|
|
|
} else {
|
|
|
|
return &spacer[spacerLen - level];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
static const char *YGMeasureModeName(const YGMeasureMode mode, const bool performLayout) {
|
2016-12-02 05:47:43 -08:00
|
|
|
const char *kMeasureModeNames[YGMeasureModeCount] = {"UNDEFINED", "EXACTLY", "AT_MOST"};
|
|
|
|
const char *kLayoutModeNames[YGMeasureModeCount] = {"LAY_UNDEFINED",
|
|
|
|
"LAY_EXACTLY",
|
|
|
|
"LAY_AT_"
|
|
|
|
"MOST"};
|
2016-11-11 10:50:09 -08:00
|
|
|
|
2016-12-02 05:47:43 -08:00
|
|
|
if (mode >= YGMeasureModeCount) {
|
2016-11-11 10:50:09 -08:00
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
return performLayout ? kLayoutModeNames[mode] : kMeasureModeNames[mode];
|
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
static inline bool YGMeasureModeSizeIsExactAndMatchesOldMeasuredSize(YGMeasureMode sizeMode,
|
|
|
|
float size,
|
|
|
|
float lastComputedSize) {
|
|
|
|
return sizeMode == YGMeasureModeExactly && YGFloatsEqual(size, lastComputedSize);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
static inline bool YGMeasureModeOldSizeIsUnspecifiedAndStillFits(YGMeasureMode sizeMode,
|
|
|
|
float size,
|
|
|
|
YGMeasureMode lastSizeMode,
|
|
|
|
float lastComputedSize) {
|
2016-12-02 05:47:43 -08:00
|
|
|
return sizeMode == YGMeasureModeAtMost && lastSizeMode == YGMeasureModeUndefined &&
|
2017-01-26 13:36:35 -08:00
|
|
|
(size >= lastComputedSize || YGFloatsEqual(size, lastComputedSize));
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
static inline bool YGMeasureModeNewMeasureSizeIsStricterAndStillValid(YGMeasureMode sizeMode,
|
|
|
|
float size,
|
|
|
|
YGMeasureMode lastSizeMode,
|
|
|
|
float lastSize,
|
|
|
|
float lastComputedSize) {
|
2016-12-02 05:47:43 -08:00
|
|
|
return lastSizeMode == YGMeasureModeAtMost && sizeMode == YGMeasureModeAtMost &&
|
2017-01-26 13:36:35 -08:00
|
|
|
lastSize > size && (lastComputedSize <= size || YGFloatsEqual(size, lastComputedSize));
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
bool YGNodeCanUseCachedMeasurement(const YGMeasureMode widthMode,
|
|
|
|
const float width,
|
|
|
|
const YGMeasureMode heightMode,
|
|
|
|
const float height,
|
|
|
|
const YGMeasureMode lastWidthMode,
|
|
|
|
const float lastWidth,
|
|
|
|
const YGMeasureMode lastHeightMode,
|
|
|
|
const float lastHeight,
|
|
|
|
const float lastComputedWidth,
|
|
|
|
const float lastComputedHeight,
|
|
|
|
const float marginRow,
|
|
|
|
const float marginColumn) {
|
2016-11-11 10:50:09 -08:00
|
|
|
if (lastComputedHeight < 0 || lastComputedWidth < 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
const bool hasSameWidthSpec = lastWidthMode == widthMode && YGFloatsEqual(lastWidth, width);
|
|
|
|
const bool hasSameHeightSpec = lastHeightMode == heightMode && YGFloatsEqual(lastHeight, height);
|
2016-11-11 10:50:09 -08:00
|
|
|
|
|
|
|
const bool widthIsCompatible =
|
2016-12-03 04:40:18 -08:00
|
|
|
hasSameWidthSpec || YGMeasureModeSizeIsExactAndMatchesOldMeasuredSize(widthMode,
|
|
|
|
width - marginRow,
|
|
|
|
lastComputedWidth) ||
|
|
|
|
YGMeasureModeOldSizeIsUnspecifiedAndStillFits(widthMode,
|
|
|
|
width - marginRow,
|
|
|
|
lastWidthMode,
|
|
|
|
lastComputedWidth) ||
|
|
|
|
YGMeasureModeNewMeasureSizeIsStricterAndStillValid(
|
2016-11-11 10:50:09 -08:00
|
|
|
widthMode, width - marginRow, lastWidthMode, lastWidth, lastComputedWidth);
|
|
|
|
|
|
|
|
const bool heightIsCompatible =
|
2016-12-03 04:40:18 -08:00
|
|
|
hasSameHeightSpec || YGMeasureModeSizeIsExactAndMatchesOldMeasuredSize(heightMode,
|
|
|
|
height - marginColumn,
|
|
|
|
lastComputedHeight) ||
|
|
|
|
YGMeasureModeOldSizeIsUnspecifiedAndStillFits(heightMode,
|
|
|
|
height - marginColumn,
|
|
|
|
lastHeightMode,
|
|
|
|
lastComputedHeight) ||
|
|
|
|
YGMeasureModeNewMeasureSizeIsStricterAndStillValid(
|
2016-11-11 10:50:09 -08:00
|
|
|
heightMode, height - marginColumn, lastHeightMode, lastHeight, lastComputedHeight);
|
|
|
|
|
|
|
|
return widthIsCompatible && heightIsCompatible;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2016-12-03 04:40:18 -08:00
|
|
|
// This is a wrapper around the YGNodelayoutImpl function. It determines
|
2016-11-11 10:50:09 -08:00
|
|
|
// whether the layout request is redundant and can be skipped.
|
|
|
|
//
|
|
|
|
// Parameters:
|
2016-12-03 04:40:18 -08:00
|
|
|
// Input parameters are the same as YGNodelayoutImpl (see above)
|
2016-11-11 10:50:09 -08:00
|
|
|
// Return parameter is true if layout was performed, false if skipped
|
|
|
|
//
|
2016-12-03 04:40:18 -08:00
|
|
|
bool YGLayoutNodeInternal(const YGNodeRef node,
|
|
|
|
const float availableWidth,
|
|
|
|
const float availableHeight,
|
|
|
|
const YGDirection parentDirection,
|
|
|
|
const YGMeasureMode widthMeasureMode,
|
|
|
|
const YGMeasureMode heightMeasureMode,
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
const float parentWidth,
|
|
|
|
const float parentHeight,
|
2016-12-03 04:40:18 -08:00
|
|
|
const bool performLayout,
|
2017-03-01 09:19:55 -08:00
|
|
|
const char *reason,
|
|
|
|
const YGConfigRef config) {
|
2016-12-03 04:40:18 -08:00
|
|
|
YGLayout *layout = &node->layout;
|
2016-11-11 10:50:09 -08:00
|
|
|
|
|
|
|
gDepth++;
|
|
|
|
|
|
|
|
const bool needToVisitNode =
|
|
|
|
(node->isDirty && layout->generationCount != gCurrentGenerationCount) ||
|
|
|
|
layout->lastParentDirection != parentDirection;
|
|
|
|
|
|
|
|
if (needToVisitNode) {
|
|
|
|
// Invalidate the cached results.
|
|
|
|
layout->nextCachedMeasurementsIndex = 0;
|
2016-12-02 05:47:43 -08:00
|
|
|
layout->cachedLayout.widthMeasureMode = (YGMeasureMode) -1;
|
|
|
|
layout->cachedLayout.heightMeasureMode = (YGMeasureMode) -1;
|
2016-11-11 10:50:09 -08:00
|
|
|
layout->cachedLayout.computedWidth = -1;
|
|
|
|
layout->cachedLayout.computedHeight = -1;
|
|
|
|
}
|
|
|
|
|
2017-04-28 03:57:13 -07:00
|
|
|
YGCachedMeasurement *cachedResults = NULL;
|
|
|
|
|
2016-11-11 10:50:09 -08:00
|
|
|
// Determine whether the results are already cached. We maintain a separate
|
|
|
|
// cache for layouts and measurements. A layout operation modifies the
|
2017-04-28 03:57:13 -07:00
|
|
|
// positions
|
|
|
|
// and dimensions for nodes in the subtree. The algorithm assumes that each
|
|
|
|
// node
|
|
|
|
// gets layed out a maximum of one time per tree layout, but multiple
|
|
|
|
// measurements
|
|
|
|
// may be required to resolve all of the flex dimensions.
|
|
|
|
// We handle nodes with measure functions specially here because they are the
|
|
|
|
// most
|
|
|
|
// expensive to measure, so it's worth avoiding redundant measurements if at
|
|
|
|
// all possible.
|
|
|
|
if (node->measure) {
|
|
|
|
const float marginAxisRow = YGNodeMarginForAxis(node, YGFlexDirectionRow, parentWidth);
|
|
|
|
const float marginAxisColumn = YGNodeMarginForAxis(node, YGFlexDirectionColumn, parentWidth);
|
2017-04-27 13:02:55 -07:00
|
|
|
|
2017-04-28 03:57:13 -07:00
|
|
|
// First, try to use the layout cache.
|
|
|
|
if (YGNodeCanUseCachedMeasurement(widthMeasureMode,
|
|
|
|
availableWidth,
|
|
|
|
heightMeasureMode,
|
|
|
|
availableHeight,
|
|
|
|
layout->cachedLayout.widthMeasureMode,
|
|
|
|
layout->cachedLayout.availableWidth,
|
|
|
|
layout->cachedLayout.heightMeasureMode,
|
|
|
|
layout->cachedLayout.availableHeight,
|
|
|
|
layout->cachedLayout.computedWidth,
|
|
|
|
layout->cachedLayout.computedHeight,
|
|
|
|
marginAxisRow,
|
|
|
|
marginAxisColumn)) {
|
|
|
|
cachedResults = &layout->cachedLayout;
|
|
|
|
} else {
|
|
|
|
// Try to use the measurement cache.
|
|
|
|
for (uint32_t i = 0; i < layout->nextCachedMeasurementsIndex; i++) {
|
|
|
|
if (YGNodeCanUseCachedMeasurement(widthMeasureMode,
|
|
|
|
availableWidth,
|
|
|
|
heightMeasureMode,
|
|
|
|
availableHeight,
|
|
|
|
layout->cachedMeasurements[i].widthMeasureMode,
|
|
|
|
layout->cachedMeasurements[i].availableWidth,
|
|
|
|
layout->cachedMeasurements[i].heightMeasureMode,
|
|
|
|
layout->cachedMeasurements[i].availableHeight,
|
|
|
|
layout->cachedMeasurements[i].computedWidth,
|
|
|
|
layout->cachedMeasurements[i].computedHeight,
|
|
|
|
marginAxisRow,
|
|
|
|
marginAxisColumn)) {
|
|
|
|
cachedResults = &layout->cachedMeasurements[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (performLayout) {
|
|
|
|
if (YGFloatsEqual(layout->cachedLayout.availableWidth, availableWidth) &&
|
|
|
|
YGFloatsEqual(layout->cachedLayout.availableHeight, availableHeight) &&
|
|
|
|
layout->cachedLayout.widthMeasureMode == widthMeasureMode &&
|
|
|
|
layout->cachedLayout.heightMeasureMode == heightMeasureMode) {
|
|
|
|
cachedResults = &layout->cachedLayout;
|
|
|
|
}
|
|
|
|
} else {
|
2016-11-11 10:50:09 -08:00
|
|
|
for (uint32_t i = 0; i < layout->nextCachedMeasurementsIndex; i++) {
|
2017-04-28 03:57:13 -07:00
|
|
|
if (YGFloatsEqual(layout->cachedMeasurements[i].availableWidth, availableWidth) &&
|
|
|
|
YGFloatsEqual(layout->cachedMeasurements[i].availableHeight, availableHeight) &&
|
|
|
|
layout->cachedMeasurements[i].widthMeasureMode == widthMeasureMode &&
|
|
|
|
layout->cachedMeasurements[i].heightMeasureMode == heightMeasureMode) {
|
2016-11-11 10:50:09 -08:00
|
|
|
cachedResults = &layout->cachedMeasurements[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!needToVisitNode && cachedResults != NULL) {
|
2016-12-02 05:47:43 -08:00
|
|
|
layout->measuredDimensions[YGDimensionWidth] = cachedResults->computedWidth;
|
|
|
|
layout->measuredDimensions[YGDimensionHeight] = cachedResults->computedHeight;
|
2016-11-11 10:50:09 -08:00
|
|
|
|
|
|
|
if (gPrintChanges && gPrintSkips) {
|
2016-12-03 04:40:18 -08:00
|
|
|
printf("%s%d.{[skipped] ", YGSpacer(gDepth), gDepth);
|
2016-11-11 10:50:09 -08:00
|
|
|
if (node->print) {
|
|
|
|
node->print(node);
|
|
|
|
}
|
|
|
|
printf("wm: %s, hm: %s, aw: %f ah: %f => d: (%f, %f) %s\n",
|
2016-12-03 04:40:18 -08:00
|
|
|
YGMeasureModeName(widthMeasureMode, performLayout),
|
|
|
|
YGMeasureModeName(heightMeasureMode, performLayout),
|
2016-11-11 10:50:09 -08:00
|
|
|
availableWidth,
|
|
|
|
availableHeight,
|
|
|
|
cachedResults->computedWidth,
|
|
|
|
cachedResults->computedHeight,
|
|
|
|
reason);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (gPrintChanges) {
|
2016-12-03 04:40:18 -08:00
|
|
|
printf("%s%d.{%s", YGSpacer(gDepth), gDepth, needToVisitNode ? "*" : "");
|
2016-11-11 10:50:09 -08:00
|
|
|
if (node->print) {
|
|
|
|
node->print(node);
|
|
|
|
}
|
|
|
|
printf("wm: %s, hm: %s, aw: %f ah: %f %s\n",
|
2016-12-03 04:40:18 -08:00
|
|
|
YGMeasureModeName(widthMeasureMode, performLayout),
|
|
|
|
YGMeasureModeName(heightMeasureMode, performLayout),
|
2016-11-11 10:50:09 -08:00
|
|
|
availableWidth,
|
|
|
|
availableHeight,
|
|
|
|
reason);
|
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodelayoutImpl(node,
|
|
|
|
availableWidth,
|
|
|
|
availableHeight,
|
|
|
|
parentDirection,
|
|
|
|
widthMeasureMode,
|
|
|
|
heightMeasureMode,
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
parentWidth,
|
|
|
|
parentHeight,
|
2017-03-01 09:19:55 -08:00
|
|
|
performLayout,
|
|
|
|
config);
|
2016-11-11 10:50:09 -08:00
|
|
|
|
|
|
|
if (gPrintChanges) {
|
2016-12-03 04:40:18 -08:00
|
|
|
printf("%s%d.}%s", YGSpacer(gDepth), gDepth, needToVisitNode ? "*" : "");
|
2016-11-11 10:50:09 -08:00
|
|
|
if (node->print) {
|
|
|
|
node->print(node);
|
|
|
|
}
|
|
|
|
printf("wm: %s, hm: %s, d: (%f, %f) %s\n",
|
2016-12-03 04:40:18 -08:00
|
|
|
YGMeasureModeName(widthMeasureMode, performLayout),
|
|
|
|
YGMeasureModeName(heightMeasureMode, performLayout),
|
2016-12-02 05:47:43 -08:00
|
|
|
layout->measuredDimensions[YGDimensionWidth],
|
|
|
|
layout->measuredDimensions[YGDimensionHeight],
|
2016-11-11 10:50:09 -08:00
|
|
|
reason);
|
|
|
|
}
|
|
|
|
|
|
|
|
layout->lastParentDirection = parentDirection;
|
|
|
|
|
|
|
|
if (cachedResults == NULL) {
|
2016-12-03 04:40:18 -08:00
|
|
|
if (layout->nextCachedMeasurementsIndex == YG_MAX_CACHED_RESULT_COUNT) {
|
2016-11-11 10:50:09 -08:00
|
|
|
if (gPrintChanges) {
|
|
|
|
printf("Out of cache entries!\n");
|
|
|
|
}
|
|
|
|
layout->nextCachedMeasurementsIndex = 0;
|
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
YGCachedMeasurement *newCacheEntry;
|
2016-11-11 10:50:09 -08:00
|
|
|
if (performLayout) {
|
|
|
|
// Use the single layout cache entry.
|
|
|
|
newCacheEntry = &layout->cachedLayout;
|
|
|
|
} else {
|
|
|
|
// Allocate a new measurement cache entry.
|
|
|
|
newCacheEntry = &layout->cachedMeasurements[layout->nextCachedMeasurementsIndex];
|
|
|
|
layout->nextCachedMeasurementsIndex++;
|
|
|
|
}
|
|
|
|
|
|
|
|
newCacheEntry->availableWidth = availableWidth;
|
|
|
|
newCacheEntry->availableHeight = availableHeight;
|
|
|
|
newCacheEntry->widthMeasureMode = widthMeasureMode;
|
|
|
|
newCacheEntry->heightMeasureMode = heightMeasureMode;
|
2016-12-02 05:47:43 -08:00
|
|
|
newCacheEntry->computedWidth = layout->measuredDimensions[YGDimensionWidth];
|
|
|
|
newCacheEntry->computedHeight = layout->measuredDimensions[YGDimensionHeight];
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (performLayout) {
|
2016-12-02 05:47:43 -08:00
|
|
|
node->layout.dimensions[YGDimensionWidth] = node->layout.measuredDimensions[YGDimensionWidth];
|
|
|
|
node->layout.dimensions[YGDimensionHeight] = node->layout.measuredDimensions[YGDimensionHeight];
|
2016-11-11 10:50:09 -08:00
|
|
|
node->hasNewLayout = true;
|
|
|
|
node->isDirty = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
gDepth--;
|
|
|
|
layout->generationCount = gCurrentGenerationCount;
|
|
|
|
return (needToVisitNode || cachedResults == NULL);
|
|
|
|
}
|
|
|
|
|
2017-03-09 07:21:23 -08:00
|
|
|
void YGConfigSetPointScaleFactor(const YGConfigRef config, const float pixelsInPoint) {
|
2017-03-03 10:16:41 -08:00
|
|
|
YG_ASSERT(pixelsInPoint >= 0.0f, "Scale factor should not be less than zero");
|
2017-02-24 09:45:31 -08:00
|
|
|
// We store points for Pixel as we will use it for rounding
|
2017-03-03 10:16:41 -08:00
|
|
|
if (pixelsInPoint == 0.0f) {
|
2017-02-24 09:45:31 -08:00
|
|
|
// Zero is used to skip rounding
|
2017-03-09 07:21:23 -08:00
|
|
|
config->pointScaleFactor = 0.0f;
|
2017-02-24 09:45:31 -08:00
|
|
|
} else {
|
2017-03-09 07:21:23 -08:00
|
|
|
config->pointScaleFactor = 1.0f / pixelsInPoint;
|
2017-02-24 09:45:31 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-25 17:29:27 -07:00
|
|
|
static float YGRoundValueToPixelGrid(const float value, const float pointScaleFactor) {
|
|
|
|
float fractial = fmodf(value, pointScaleFactor);
|
|
|
|
return value - fractial + (fractial >= pointScaleFactor / 2.0f ? pointScaleFactor : 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void YGRoundToPixelGrid(const YGNodeRef node, const float pointScaleFactor, const float absoluteLeft, const float absoluteTop) {
|
2017-03-09 07:21:23 -08:00
|
|
|
if (pointScaleFactor == 0.0f) {
|
2017-02-24 09:45:31 -08:00
|
|
|
return;
|
|
|
|
}
|
2017-04-25 17:29:27 -07:00
|
|
|
|
2017-02-24 09:45:31 -08:00
|
|
|
const float nodeLeft = node->layout.position[YGEdgeLeft];
|
|
|
|
const float nodeTop = node->layout.position[YGEdgeTop];
|
|
|
|
|
2017-04-25 17:29:27 -07:00
|
|
|
const float nodeWidth = node->layout.dimensions[YGDimensionWidth];
|
|
|
|
const float nodeHeight = node->layout.dimensions[YGDimensionHeight];
|
2017-03-01 07:10:00 -08:00
|
|
|
|
2017-04-25 17:29:27 -07:00
|
|
|
const float absoluteNodeLeft = absoluteLeft + nodeLeft;
|
|
|
|
const float absoluteNodeTop = absoluteTop + nodeTop;
|
2017-03-01 07:10:00 -08:00
|
|
|
|
2017-04-25 17:29:27 -07:00
|
|
|
const float absoluteNodeRight = absoluteNodeLeft + nodeWidth;
|
|
|
|
const float absoluteNodeBottom = absoluteNodeTop + nodeHeight;
|
2017-03-01 07:10:00 -08:00
|
|
|
|
2017-04-25 17:29:27 -07:00
|
|
|
node->layout.position[YGEdgeLeft] = YGRoundValueToPixelGrid(nodeLeft, pointScaleFactor);
|
|
|
|
node->layout.position[YGEdgeTop] = YGRoundValueToPixelGrid(nodeTop, pointScaleFactor);
|
|
|
|
|
|
|
|
node->layout.dimensions[YGDimensionWidth] =
|
|
|
|
YGRoundValueToPixelGrid(absoluteNodeRight, pointScaleFactor) - YGRoundValueToPixelGrid(absoluteNodeLeft, pointScaleFactor);
|
|
|
|
node->layout.dimensions[YGDimensionHeight] =
|
|
|
|
YGRoundValueToPixelGrid(absoluteNodeBottom, pointScaleFactor) - YGRoundValueToPixelGrid(absoluteNodeTop, pointScaleFactor);
|
2016-11-22 05:33:36 -08:00
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
const uint32_t childCount = YGNodeListCount(node->children);
|
2016-11-22 05:33:36 -08:00
|
|
|
for (uint32_t i = 0; i < childCount; i++) {
|
2017-04-25 17:29:27 -07:00
|
|
|
YGRoundToPixelGrid(YGNodeGetChild(node, i), pointScaleFactor, absoluteNodeLeft, absoluteNodeTop);
|
2016-11-22 05:33:36 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
void YGNodeCalculateLayout(const YGNodeRef node,
|
2017-02-28 08:10:34 -08:00
|
|
|
const float parentWidth,
|
|
|
|
const float parentHeight,
|
2016-12-03 04:40:18 -08:00
|
|
|
const YGDirection parentDirection) {
|
2016-11-11 10:50:09 -08:00
|
|
|
// Increment the generation count. This will force the recursive routine to
|
|
|
|
// visit
|
|
|
|
// all dirty nodes at least once. Subsequent visits will be skipped if the
|
|
|
|
// input
|
|
|
|
// parameters don't change.
|
|
|
|
gCurrentGenerationCount++;
|
|
|
|
|
2017-02-06 14:36:27 -08:00
|
|
|
YGResolveDimensions(node);
|
|
|
|
|
2017-02-28 08:10:34 -08:00
|
|
|
float width = YGUndefined;
|
|
|
|
YGMeasureMode widthMeasureMode = YGMeasureModeUndefined;
|
|
|
|
if (YGNodeIsStyleDimDefined(node, YGFlexDirectionRow, parentWidth)) {
|
2017-03-10 06:05:53 -08:00
|
|
|
width = YGResolveValue(node->resolvedDimensions[dim[YGFlexDirectionRow]], parentWidth) +
|
2017-02-28 08:10:34 -08:00
|
|
|
YGNodeMarginForAxis(node, YGFlexDirectionRow, parentWidth);
|
2016-12-02 05:47:43 -08:00
|
|
|
widthMeasureMode = YGMeasureModeExactly;
|
2017-03-10 06:05:53 -08:00
|
|
|
} else if (YGResolveValue(&node->style.maxDimensions[YGDimensionWidth], parentWidth) >= 0.0f) {
|
|
|
|
width = YGResolveValue(&node->style.maxDimensions[YGDimensionWidth], parentWidth);
|
2016-12-02 05:47:43 -08:00
|
|
|
widthMeasureMode = YGMeasureModeAtMost;
|
2017-03-01 07:10:00 -08:00
|
|
|
} else {
|
|
|
|
width = parentWidth;
|
|
|
|
widthMeasureMode = YGFloatIsUndefined(width) ? YGMeasureModeUndefined : YGMeasureModeExactly;
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2017-02-28 08:10:34 -08:00
|
|
|
float height = YGUndefined;
|
|
|
|
YGMeasureMode heightMeasureMode = YGMeasureModeUndefined;
|
|
|
|
if (YGNodeIsStyleDimDefined(node, YGFlexDirectionColumn, parentHeight)) {
|
2017-03-10 06:05:53 -08:00
|
|
|
height = YGResolveValue(node->resolvedDimensions[dim[YGFlexDirectionColumn]], parentHeight) +
|
2017-02-28 08:10:34 -08:00
|
|
|
YGNodeMarginForAxis(node, YGFlexDirectionColumn, parentWidth);
|
2016-12-02 05:47:43 -08:00
|
|
|
heightMeasureMode = YGMeasureModeExactly;
|
2017-03-10 06:05:53 -08:00
|
|
|
} else if (YGResolveValue(&node->style.maxDimensions[YGDimensionHeight], parentHeight) >=
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
0.0f) {
|
2017-03-10 06:05:53 -08:00
|
|
|
height = YGResolveValue(&node->style.maxDimensions[YGDimensionHeight], parentHeight);
|
2016-12-02 05:47:43 -08:00
|
|
|
heightMeasureMode = YGMeasureModeAtMost;
|
2017-03-01 07:10:00 -08:00
|
|
|
} else {
|
|
|
|
height = parentHeight;
|
|
|
|
heightMeasureMode = YGFloatIsUndefined(height) ? YGMeasureModeUndefined : YGMeasureModeExactly;
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
if (YGLayoutNodeInternal(node,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
parentDirection,
|
|
|
|
widthMeasureMode,
|
|
|
|
heightMeasureMode,
|
2017-02-28 08:10:34 -08:00
|
|
|
parentWidth,
|
|
|
|
parentHeight,
|
2016-12-03 04:40:18 -08:00
|
|
|
true,
|
2017-03-01 09:19:55 -08:00
|
|
|
"initial",
|
|
|
|
node->config)) {
|
|
|
|
YGNodeSetPosition(node, node->layout.direction, parentWidth, parentHeight, parentWidth);
|
2017-04-27 07:09:24 -07:00
|
|
|
YGRoundToPixelGrid(node, node->config->pointScaleFactor, 0.0f, 0.0f);
|
2016-11-22 05:33:36 -08:00
|
|
|
|
2016-11-11 10:50:09 -08:00
|
|
|
if (gPrintTree) {
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodePrint(node, YGPrintOptionsLayout | YGPrintOptionsChildren | YGPrintOptionsStyle);
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
void YGSetLogger(YGLogger logger) {
|
2017-04-03 09:34:42 -07:00
|
|
|
if (logger != NULL) {
|
|
|
|
gLogger = logger;
|
|
|
|
} else {
|
|
|
|
#ifdef ANDROID
|
|
|
|
gLogger = &YGAndroidLog;
|
|
|
|
#else
|
|
|
|
gLogger = &YGDefaultLog;
|
|
|
|
#endif
|
|
|
|
}
|
2016-11-11 10:50:09 -08:00
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
void YGLog(YGLogLevel level, const char *format, ...) {
|
2016-11-11 10:50:09 -08:00
|
|
|
va_list args;
|
|
|
|
va_start(args, format);
|
|
|
|
gLogger(level, format, args);
|
|
|
|
va_end(args);
|
|
|
|
}
|
2016-11-14 03:27:33 -08:00
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
void YGConfigSetExperimentalFeatureEnabled(const YGConfigRef config,
|
|
|
|
const YGExperimentalFeature feature,
|
|
|
|
const bool enabled) {
|
|
|
|
config->experimentalFeatures[feature] = enabled;
|
2016-11-14 03:27:33 -08:00
|
|
|
}
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
inline bool YGConfigIsExperimentalFeatureEnabled(const YGConfigRef config,
|
|
|
|
const YGExperimentalFeature feature) {
|
|
|
|
return config->experimentalFeatures[feature];
|
2016-11-14 03:27:33 -08:00
|
|
|
}
|
2016-11-15 20:20:09 -08:00
|
|
|
|
2017-03-03 10:47:42 -08:00
|
|
|
void YGConfigSetUseWebDefaults(const YGConfigRef config, const bool enabled) {
|
|
|
|
config->useWebDefaults = enabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool YGConfigGetUseWebDefaults(const YGConfigRef config) {
|
|
|
|
return config->useWebDefaults;
|
|
|
|
}
|
|
|
|
|
2016-12-07 05:12:11 -08:00
|
|
|
void YGSetMemoryFuncs(YGMalloc ygmalloc, YGCalloc yccalloc, YGRealloc ygrealloc, YGFree ygfree) {
|
2017-04-10 14:22:23 -07:00
|
|
|
YG_ASSERT(gNodeInstanceCount == 0 && gConfigInstanceCount == 0,
|
|
|
|
"Cannot set memory functions: all node must be freed first");
|
2016-12-07 05:12:11 -08:00
|
|
|
YG_ASSERT((ygmalloc == NULL && yccalloc == NULL && ygrealloc == NULL && ygfree == NULL) ||
|
|
|
|
(ygmalloc != NULL && yccalloc != NULL && ygrealloc != NULL && ygfree != NULL),
|
2016-12-03 04:40:18 -08:00
|
|
|
"Cannot set memory functions: functions must be all NULL or Non-NULL");
|
|
|
|
|
2016-12-07 05:12:11 -08:00
|
|
|
if (ygmalloc == NULL || yccalloc == NULL || ygrealloc == NULL || ygfree == NULL) {
|
2016-12-03 04:40:18 -08:00
|
|
|
gYGMalloc = &malloc;
|
|
|
|
gYGCalloc = &calloc;
|
|
|
|
gYGRealloc = &realloc;
|
|
|
|
gYGFree = &free;
|
2016-11-15 20:20:09 -08:00
|
|
|
} else {
|
2016-12-07 05:12:11 -08:00
|
|
|
gYGMalloc = ygmalloc;
|
|
|
|
gYGCalloc = yccalloc;
|
|
|
|
gYGRealloc = ygrealloc;
|
|
|
|
gYGFree = ygfree;
|
2016-11-15 20:20:09 -08:00
|
|
|
}
|
|
|
|
}
|