Upgrade Yoga to latest
This commit is contained in:
parent
c14c28a042
commit
cbdb43414c
3
.gitignore
vendored
3
.gitignore
vendored
@ -2,4 +2,5 @@ node_modules
|
||||
*.log
|
||||
build
|
||||
dist
|
||||
.vscode
|
||||
.vscode
|
||||
.cache
|
||||
@ -4,18 +4,18 @@
|
||||
"include_dirs": ['../deps/'],
|
||||
"cflags": ['-DSPDLOG_COMPILED_LIB'],
|
||||
"sources": [
|
||||
"../deps/yoga/Yoga.cpp",
|
||||
"../deps/yoga/YGValue.cpp",
|
||||
"../deps/yoga/YGStyle.cpp",
|
||||
"../deps/yoga/YGNodePrint.cpp",
|
||||
"../deps/yoga/YGNode.cpp",
|
||||
"../deps/yoga/YGMarker.cpp",
|
||||
"../deps/yoga/YGLayout.cpp",
|
||||
"../deps/yoga/YGEnums.cpp",
|
||||
"../deps/yoga/YGConfig.cpp",
|
||||
"../deps/yoga/Utils.cpp",
|
||||
"../deps/yoga/log.cpp",
|
||||
"../deps/yoga/event/event.cpp",
|
||||
"../deps/yoga/log.cpp",
|
||||
"../deps/yoga/Utils.cpp",
|
||||
"../deps/yoga/YGConfig.cpp",
|
||||
"../deps/yoga/YGEnums.cpp",
|
||||
"../deps/yoga/YGLayout.cpp",
|
||||
"../deps/yoga/YGNode.cpp",
|
||||
"../deps/yoga/YGNodePrint.cpp",
|
||||
"../deps/yoga/YGStyle.cpp",
|
||||
"../deps/yoga/YGValue.cpp",
|
||||
"../deps/yoga/Yoga.cpp",
|
||||
"../deps/yoga/event/event.cpp",
|
||||
"../deps/yoga/internal/experiments.cpp"
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
2
deps/yoga/CompactValue.h
vendored
2
deps/yoga/CompactValue.h
vendored
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
|
||||
278
deps/yoga/README.md
vendored
278
deps/yoga/README.md
vendored
@ -1,278 +0,0 @@
|
||||
## Copy of old doc
|
||||
|
||||
This doc was originally found at: `https://github.com/facebook/yoga/blob/d66239bea8dc74526343d414a4923237081d7b5c/docs/_docs/api/c.md`
|
||||
|
||||
`YGNodeRef` is the main object you will be interfacing with when using Yoga in C. `YGNodeRef` is a pointer to an internal `YGNode` struct.
|
||||
|
||||
### Lifecycle
|
||||
|
||||
The following functions control the lifecycle of a `YGNodeRef`.
|
||||
|
||||
```c
|
||||
YGNodeRef YGNodeNew();
|
||||
void YGNodeReset(YGNodeRef node);
|
||||
void YGNodeFree(YGNodeRef node);
|
||||
void YGNodeFreeRecursive(YGNodeRef node);
|
||||
```
|
||||
|
||||
- `YGNodeReset` will reset a node to its initial state so it can be re-used without needing to re-allocate a new node.
|
||||
- `YGNodeFreeRecursive` is mostly used for testing and will free not only the node itself but also its children.
|
||||
|
||||
### Children
|
||||
|
||||
The following functions help manage the children of a node.
|
||||
|
||||
```c
|
||||
void YGNodeInsertChild(YGNodeRef node, YGNodeRef child, uint32_t index);
|
||||
void YGNodeRemoveChild(YGNodeRef node, YGNodeRef child);
|
||||
YGNodeRef YGNodeGetChild(YGNodeRef node, uint32_t index);
|
||||
uint32_t YGNodeGetChildCount(YGNodeRef node);
|
||||
```
|
||||
|
||||
### Style getters & setters
|
||||
|
||||
The large part of Yoga's API consists of setters and getters for styles. These all follow the same general structure. Bellow are the function and enums used to control the various styles. For an in depth guide to how each style works see the getting started guide.
|
||||
|
||||
```c
|
||||
typedef enum YGDirection {
|
||||
YGDirectionInherit,
|
||||
YGDirectionLTR,
|
||||
YGDirectionRTL,
|
||||
} YGDirection;
|
||||
|
||||
void YGNodeStyleSetDirection(YGNodeRef node, YGDirection direction);
|
||||
YGDirection YGNodeStyleGetDirection(YGNodeRef node);
|
||||
|
||||
typedef enum YGFlexDirection {
|
||||
YGFlexDirectionColumn,
|
||||
YGFlexDirectionColumnReverse,
|
||||
YGFlexDirectionRow,
|
||||
YGFlexDirectionRowReverse,
|
||||
} YGFlexDirection;
|
||||
|
||||
void YGNodeStyleSetFlexDirection(YGNodeRef node,
|
||||
YGFlexDirection flexDirection);
|
||||
YGFlexDirection YGNodeStyleGetFlexDirection(YGNodeRef node);
|
||||
|
||||
typedef enum YGJustify {
|
||||
YGJustifyFlexStart,
|
||||
YGJustifyCenter,
|
||||
YGJustifyFlexEnd,
|
||||
YGJustifySpaceBetween,
|
||||
YGJustifySpaceAround,
|
||||
} YGJustify;
|
||||
|
||||
void YGNodeStyleSetJustifyContent(YGNodeRef node,
|
||||
YGJustify justifyContent);
|
||||
YGJustify YGNodeStyleGetJustifyContent(YGNodeRef node);
|
||||
|
||||
typedef enum YGAlign {
|
||||
YGAlignAuto,
|
||||
YGAlignFlexStart,
|
||||
YGAlignCenter,
|
||||
YGAlignFlexEnd,
|
||||
YGAlignStretch,
|
||||
} YGAlign;
|
||||
|
||||
void YGNodeStyleSetAlignContent(YGNodeRef node, YGAlign alignContent);
|
||||
YGAlign YGNodeStyleGetAlignContent(YGNodeRef node);
|
||||
|
||||
void YGNodeStyleSetAlignItems(YGNodeRef node, YGAlign alignItems);
|
||||
YGAlign YGNodeStyleGetAlignItems(YGNodeRef node);
|
||||
|
||||
void YGNodeStyleSetAlignSelf(YGNodeRef node, YGAlign alignSelf);
|
||||
YGAlign YGNodeStyleGetAlignSelf(YGNodeRef node);
|
||||
|
||||
typedef enum YGPositionType {
|
||||
YGPositionTypeRelative,
|
||||
YGPositionTypeAbsolute,
|
||||
} YGPositionType;
|
||||
|
||||
void YGNodeStyleSetPositionType(YGNodeRef node,
|
||||
YGPositionType positionType);
|
||||
YGPositionType YGNodeStyleGetPositionType(YGNodeRef node);
|
||||
|
||||
typedef enum YGWrap {
|
||||
YGWrapNoWrap,
|
||||
YGWrapWrap,
|
||||
} YGWrap;
|
||||
|
||||
void YGNodeStyleSetFlexWrap(YGNodeRef node, YGWrap flexWrap);
|
||||
YGWrap YGNodeStyleGetFlexWrap(YGNodeRef node);
|
||||
|
||||
typedef enum YGOverflow {
|
||||
YGOverflowVisible,
|
||||
YGOverflowHidden,
|
||||
YGOverflowScroll,
|
||||
} YGOverflow;
|
||||
|
||||
void YGNodeStyleSetOverflow(YGNodeRef node, YGOverflow overflow);
|
||||
YGOverflow YGNodeStyleGetOverflow(YGNodeRef node);
|
||||
|
||||
void YGNodeStyleSetFlex(YGNodeRef node, float flex);
|
||||
|
||||
void YGNodeStyleSetFlexGrow(YGNodeRef node, float flexGrow);
|
||||
float YGNodeStyleGetFlexGrow(YGNodeRef node);
|
||||
|
||||
void YGNodeStyleSetFlexShrink(YGNodeRef node, float flexShrink);
|
||||
float YGNodeStyleGetFlexShrink(YGNodeRef node);
|
||||
|
||||
void YGNodeStyleSetFlexBasis(YGNodeRef node, float flexBasis);
|
||||
float YGNodeStyleGetFlexBasis(YGNodeRef node);
|
||||
|
||||
typedef enum YGEdge {
|
||||
YGEdgeLeft,
|
||||
YGEdgeTop,
|
||||
YGEdgeRight,
|
||||
YGEdgeBottom,
|
||||
YGEdgeStart,
|
||||
YGEdgeEnd,
|
||||
YGEdgeHorizontal,
|
||||
YGEdgeVertical,
|
||||
YGEdgeAll,
|
||||
} YGEdge;
|
||||
|
||||
void YGNodeStyleSetPosition(YGNodeRef node, YGEdge edge, float position);
|
||||
float YGNodeStyleGetPosition(YGNodeRef node, YGEdge edge);
|
||||
|
||||
void YGNodeStyleSetMargin(YGNodeRef node, YGEdge edge, float margin);
|
||||
float YGNodeStyleGetMargin(YGNodeRef node, YGEdge edge);
|
||||
|
||||
void YGNodeStyleSetPadding(YGNodeRef node, YGEdge edge, float padding);
|
||||
float YGNodeStyleGetPadding(YGNodeRef node, YGEdge edge);
|
||||
|
||||
void YGNodeStyleSetBorder(YGNodeRef node, YGEdge edge, float border);
|
||||
float YGNodeStyleGetBorder(YGNodeRef node, YGEdge edge);
|
||||
|
||||
void YGNodeStyleSetWidth(YGNodeRef node, float width);
|
||||
float YGNodeStyleGetWidth(YGNodeRef node);
|
||||
|
||||
void YGNodeStyleSetHeight(YGNodeRef node, float height);
|
||||
float YGNodeStyleGetHeight(YGNodeRef node);
|
||||
|
||||
void YGNodeStyleSetMinWidth(YGNodeRef node, float minWidth);
|
||||
float YGNodeStyleGetMinWidth(YGNodeRef node);
|
||||
|
||||
void YGNodeStyleSetMinHeight(YGNodeRef node, float minHeight);
|
||||
float YGNodeStyleGetMinHeight(YGNodeRef node);
|
||||
|
||||
void YGNodeStyleSetMaxWidth(YGNodeRef node, float maxWidth);
|
||||
float YGNodeStyleGetMaxWidth(YGNodeRef node);
|
||||
|
||||
void YGNodeStyleSetMaxHeight(YGNodeRef node, float maxHeight);
|
||||
float YGNodeStyleGetMaxHeight(YGNodeRef node);
|
||||
|
||||
void YGNodeStyleSetAspectRatio(YGNodeRef node, float aspectRatio);
|
||||
float YGNodeStyleGetAspectRatio(YGNodeRef node);
|
||||
```
|
||||
|
||||
### Layout results
|
||||
|
||||
Once you have set up a tree of nodes with styles you will want to get the result of a layout calculation. Call `YGNodeCalculateLayout` with the desired width and height or `YGUndefined` to perform the layout calculation. Once this function returns the results of the layout calculation is stored on each node. Traverse the tree and retrieve the values from each node.
|
||||
|
||||
```c
|
||||
void YGNodeCalculateLayout(YGNodeRef node,
|
||||
float availableWidth,
|
||||
float availableHeight,
|
||||
YGDirection parentDirection);
|
||||
float YGNodeLayoutGetLeft(YGNodeRef node);
|
||||
float YGNodeLayoutGetTop(YGNodeRef node);
|
||||
float YGNodeLayoutGetRight(YGNodeRef node);
|
||||
float YGNodeLayoutGetBottom(YGNodeRef node);
|
||||
float YGNodeLayoutGetWidth(YGNodeRef node);
|
||||
float YGNodeLayoutGetHeight(YGNodeRef node);
|
||||
YGDirection YGNodeLayoutGetDirection(YGNodeRef node);
|
||||
```
|
||||
|
||||
### Custom measurements
|
||||
|
||||
Certain nodes need the ability to measure themselves, the most common example is nodes which represent text. Text has an intrinsic size and requires measuring itself to determine that size. This is not something Yoga can do as it requires relying on the host system's text rendering engine.
|
||||
|
||||
- Call `YGNodeMarkDirty` if a node with a custom text measurement function needs to be re-measured during the next layout pass.
|
||||
|
||||
> A measure function can only be attached to a leaf node in the hierarchy.
|
||||
|
||||
```c
|
||||
typedef enum YGMeasureMode {
|
||||
YGMeasureModeUndefined,
|
||||
YGMeasureModeExactly,
|
||||
YGMeasureModeAtMost,
|
||||
} YGMeasureMode;
|
||||
|
||||
typedef struct YGSize {
|
||||
float width;
|
||||
float height;
|
||||
} YGSize;
|
||||
|
||||
typedef YGSize (*YGMeasureFunc)(YGNodeRef node,
|
||||
float width,
|
||||
YGMeasureMode widthMode,
|
||||
float height,
|
||||
YGMeasureMode heightMode);
|
||||
|
||||
void YGNodeSetMeasureFunc(YGNodeRef node, YGMeasureFunc measureFunc);
|
||||
YGMeasureFunc YGNodeGetMeasureFunc(YGNodeRef node);
|
||||
|
||||
void YGNodeMarkDirty(YGNodeRef node);
|
||||
bool YGNodeIsDirty(YGNodeRef node);
|
||||
```
|
||||
|
||||
### Context
|
||||
|
||||
Context is important when integrating Yoga into another layout system. Context allows you to associate another object with a `YGNodeRef`. This context can then be retrieved from a `YGNodeRef` when for example its measure function is called. This is what enables Yoga to rely on the Android and iOS system implementations of text measurement in React Native.
|
||||
|
||||
```c
|
||||
void YGNodeSetContext(YGNodeRef node, void *context);
|
||||
void *YGNodeGetContext(YGNodeRef node);
|
||||
```
|
||||
|
||||
### Logging
|
||||
|
||||
Yoga will by default log to stdout and stderr. You may however customize this to instead log to your own logger.
|
||||
|
||||
```c
|
||||
typedef enum YGLogLevel {
|
||||
YGLogLevelError,
|
||||
YGLogLevelWarn,
|
||||
YGLogLevelInfo,
|
||||
YGLogLevelDebug,
|
||||
YGLogLevelVerbose,
|
||||
} YGLogLevel;
|
||||
|
||||
typedef int (*YGLogger)(YGLogLevel level, char *format, va_list args);
|
||||
void YGSetLogger(YGLogger logger);
|
||||
void YGLog(YGLogLevel level, char *message, ...);
|
||||
```
|
||||
|
||||
### Experiments
|
||||
|
||||
Yoga has the concept of experiments. An experiment is a feature which is not yet stable. To enable a feature use the following functions. Once a feature has been tested and is ready to be released as a stable API we will remove its feature flag.
|
||||
|
||||
```c
|
||||
typedef enum YGExperimentalFeature {
|
||||
// Current experiments
|
||||
} YGExperimentalFeature;
|
||||
|
||||
void YGSetExperimentalFeatureEnabled(YGExperimentalFeature feature,
|
||||
bool enabled);
|
||||
bool YGIsExperimentalFeatureEnabled(YGExperimentalFeature feature);
|
||||
```
|
||||
|
||||
### Printing
|
||||
|
||||
Yoga has some hooks to print debug information while calculating layout. With the printing APIs you can add additional information to a node when it is printed.
|
||||
|
||||
```c
|
||||
typedef enum YGPrintOptions {
|
||||
YGPrintOptionsLayout = 1,
|
||||
YGPrintOptionsStyle = 2,
|
||||
YGPrintOptionsChildren = 4,
|
||||
} YGPrintOptions;
|
||||
|
||||
typedef void (*YGPrintFunc)(YGNodeRef node);
|
||||
|
||||
void YGNodeSetPrintFunc(YGNodeRef node, YGPrintFunc printFunc);
|
||||
YGPrintFunc YGNodeGetPrintFunc(YGNodeRef node);
|
||||
|
||||
void YGNodePrint(YGNodeRef node, YGPrintOptions options);
|
||||
```
|
||||
2
deps/yoga/Utils.cpp
vendored
2
deps/yoga/Utils.cpp
vendored
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
|
||||
8
deps/yoga/Utils.h
vendored
8
deps/yoga/Utils.h
vendored
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
@ -30,7 +30,7 @@
|
||||
//
|
||||
// - endOfLineIndex: Its the end index of the last flex item which was examined
|
||||
// and it may or may not be part of the current line(as it may be absolutely
|
||||
// positioned or inculding it may have caused to overshoot availableInnerDim)
|
||||
// positioned or including it may have caused to overshoot availableInnerDim)
|
||||
//
|
||||
// - relativeChildren: Maintain a vector of the child nodes that can shrink
|
||||
// and/or grow.
|
||||
@ -71,8 +71,8 @@ YGFloatOptional YGFloatOptionalMax(
|
||||
|
||||
float YGFloatMin(const float a, const float b);
|
||||
|
||||
// This custom float comparision function compares the array of float with
|
||||
// YGFloatsEqual, as the default float comparision operator will not work(Look
|
||||
// This custom float comparison function compares the array of float with
|
||||
// YGFloatsEqual, as the default float comparison operator will not work(Look
|
||||
// at the comments of YGFloatsEqual function).
|
||||
template <std::size_t size>
|
||||
bool YGFloatArrayEqual(
|
||||
|
||||
2
deps/yoga/YGConfig.cpp
vendored
2
deps/yoga/YGConfig.cpp
vendored
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
|
||||
4
deps/yoga/YGConfig.h
vendored
4
deps/yoga/YGConfig.h
vendored
@ -1,11 +1,10 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
#pragma once
|
||||
#include "YGMarker.h"
|
||||
#include "Yoga-internal.h"
|
||||
#include "Yoga.h"
|
||||
|
||||
@ -44,7 +43,6 @@ public:
|
||||
std::array<bool, facebook::yoga::enums::count<YGExperimentalFeature>()>
|
||||
experimentalFeatures = {};
|
||||
void* context = nullptr;
|
||||
YGMarkerCallbacks markerCallbacks = {nullptr, nullptr};
|
||||
|
||||
YGConfig(YGLogger logger);
|
||||
void log(YGConfig*, YGNode*, YGLogLevel, void*, const char*, va_list);
|
||||
|
||||
2
deps/yoga/YGEnums.cpp
vendored
2
deps/yoga/YGEnums.cpp
vendored
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
|
||||
2
deps/yoga/YGEnums.h
vendored
2
deps/yoga/YGEnums.h
vendored
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
|
||||
2
deps/yoga/YGFloatOptional.h
vendored
2
deps/yoga/YGFloatOptional.h
vendored
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
|
||||
2
deps/yoga/YGLayout.cpp
vendored
2
deps/yoga/YGLayout.cpp
vendored
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
|
||||
9
deps/yoga/YGLayout.h
vendored
9
deps/yoga/YGLayout.h
vendored
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
@ -8,12 +8,9 @@
|
||||
#include "YGFloatOptional.h"
|
||||
#include "Yoga-internal.h"
|
||||
|
||||
constexpr std::array<float, 2> kYGDefaultDimensionValues = {
|
||||
{YGUndefined, YGUndefined}};
|
||||
|
||||
struct YGLayout {
|
||||
std::array<float, 4> position = {};
|
||||
std::array<float, 2> dimensions = kYGDefaultDimensionValues;
|
||||
std::array<float, 2> dimensions = {{YGUndefined, YGUndefined}};
|
||||
std::array<float, 4> margin = {};
|
||||
std::array<float, 4> border = {};
|
||||
std::array<float, 4> padding = {};
|
||||
@ -33,7 +30,7 @@ struct YGLayout {
|
||||
uint32_t nextCachedMeasurementsIndex = 0;
|
||||
std::array<YGCachedMeasurement, YG_MAX_CACHED_RESULT_COUNT>
|
||||
cachedMeasurements = {};
|
||||
std::array<float, 2> measuredDimensions = kYGDefaultDimensionValues;
|
||||
std::array<float, 2> measuredDimensions = {{YGUndefined, YGUndefined}};
|
||||
|
||||
YGCachedMeasurement cachedLayout = YGCachedMeasurement();
|
||||
|
||||
|
||||
14
deps/yoga/YGMacros.h
vendored
14
deps/yoga/YGMacros.h
vendored
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
@ -30,3 +30,15 @@
|
||||
#define YG_ENUM_BEGIN(name) enum name
|
||||
#define YG_ENUM_END(name) name
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define YG_DEPRECATED __attribute__((deprecated))
|
||||
#elif defined(_MSC_VER)
|
||||
#define YG_DEPRECATED __declspec(deprecated)
|
||||
#elif __cplusplus >= 201402L
|
||||
#if defined(__has_cpp_attribute)
|
||||
#if __has_cpp_attribute(deprecated)
|
||||
#define YG_DEPRECATED [[deprecated]]
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
14
deps/yoga/YGMarker.cpp
vendored
14
deps/yoga/YGMarker.cpp
vendored
@ -1,14 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
#include "YGMarker.h"
|
||||
#include "YGConfig.h"
|
||||
|
||||
void YGConfigSetMarkerCallbacks(
|
||||
YGConfigRef config,
|
||||
YGMarkerCallbacks markerCallbacks) {
|
||||
config->markerCallbacks = markerCallbacks;
|
||||
}
|
||||
90
deps/yoga/YGMarker.h
vendored
90
deps/yoga/YGMarker.h
vendored
@ -1,90 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "YGMacros.h"
|
||||
|
||||
YG_EXTERN_C_BEGIN
|
||||
|
||||
typedef struct YGNode* YGNodeRef;
|
||||
typedef struct YGConfig* YGConfigRef;
|
||||
|
||||
typedef YG_ENUM_BEGIN(YGMarker){
|
||||
YGMarkerLayout,
|
||||
YGMarkerMeasure,
|
||||
YGMarkerBaselineFn,
|
||||
} YG_ENUM_END(YGMarker);
|
||||
|
||||
typedef struct {
|
||||
int layouts;
|
||||
int measures;
|
||||
int maxMeasureCache;
|
||||
int cachedLayouts;
|
||||
int cachedMeasures;
|
||||
} YGMarkerLayoutData;
|
||||
|
||||
typedef struct {
|
||||
bool _unused;
|
||||
} YGMarkerNoData;
|
||||
|
||||
typedef union {
|
||||
YGMarkerLayoutData* layout;
|
||||
YGMarkerNoData* noData;
|
||||
} YGMarkerData;
|
||||
|
||||
typedef struct {
|
||||
// accepts marker type, a node ref, and marker data (depends on marker type)
|
||||
// can return a handle or id that Yoga will pass to endMarker
|
||||
void* (*startMarker)(YGMarker, YGNodeRef, YGMarkerData);
|
||||
// accepts marker type, a node ref, marker data, and marker id as returned by
|
||||
// startMarker
|
||||
void (*endMarker)(YGMarker, YGNodeRef, YGMarkerData, void* id);
|
||||
} YGMarkerCallbacks;
|
||||
|
||||
void YGConfigSetMarkerCallbacks(YGConfigRef, YGMarkerCallbacks);
|
||||
|
||||
YG_EXTERN_C_END
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace facebook {
|
||||
namespace yoga {
|
||||
namespace marker {
|
||||
namespace detail {
|
||||
|
||||
template <YGMarker M>
|
||||
struct MarkerData;
|
||||
|
||||
template <>
|
||||
struct MarkerData<YGMarkerLayout> {
|
||||
using type = YGMarkerLayoutData;
|
||||
static type*& get(YGMarkerData& d) { return d.layout; }
|
||||
};
|
||||
|
||||
struct NoMarkerData {
|
||||
using type = YGMarkerNoData;
|
||||
static type*& get(YGMarkerData& d) { return d.noData; }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct MarkerData<YGMarkerMeasure> : NoMarkerData {};
|
||||
|
||||
template <>
|
||||
struct MarkerData<YGMarkerBaselineFn> : NoMarkerData {};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <YGMarker M>
|
||||
typename detail::MarkerData<M>::type* data(YGMarkerData d) {
|
||||
return detail::MarkerData<M>::get(d);
|
||||
}
|
||||
|
||||
} // namespace marker
|
||||
} // namespace yoga
|
||||
} // namespace facebook
|
||||
|
||||
#endif // __cplusplus
|
||||
2
deps/yoga/YGNode.cpp
vendored
2
deps/yoga/YGNode.cpp
vendored
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
|
||||
5
deps/yoga/YGNode.h
vendored
5
deps/yoga/YGNode.h
vendored
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
@ -11,6 +11,7 @@
|
||||
#include "YGConfig.h"
|
||||
#include "YGLayout.h"
|
||||
#include "YGStyle.h"
|
||||
#include "YGMacros.h"
|
||||
#include "Yoga-internal.h"
|
||||
|
||||
YGConfigRef YGConfigGetDefault();
|
||||
@ -272,7 +273,7 @@ public:
|
||||
|
||||
// TODO: rvalue override for setChildren
|
||||
|
||||
void setConfig(YGConfigRef config) { config_ = config; }
|
||||
YG_DEPRECATED void setConfig(YGConfigRef config) { config_ = config; }
|
||||
|
||||
void setDirty(bool isDirty);
|
||||
void setLayoutLastOwnerDirection(YGDirection direction);
|
||||
|
||||
2
deps/yoga/YGNodePrint.cpp
vendored
2
deps/yoga/YGNodePrint.cpp
vendored
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
|
||||
2
deps/yoga/YGNodePrint.h
vendored
2
deps/yoga/YGNodePrint.h
vendored
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
|
||||
2
deps/yoga/YGStyle.cpp
vendored
2
deps/yoga/YGStyle.cpp
vendored
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
|
||||
12
deps/yoga/YGStyle.h
vendored
12
deps/yoga/YGStyle.h
vendored
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
@ -102,6 +102,11 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wbitfield-constant-conversion"
|
||||
#endif
|
||||
|
||||
YGStyle()
|
||||
: direction_(YGDirectionInherit),
|
||||
flexDirection_(YGFlexDirectionColumn),
|
||||
@ -113,6 +118,11 @@ public:
|
||||
flexWrap_(YGWrapNoWrap),
|
||||
overflow_(YGOverflowVisible),
|
||||
display_(YGDisplayFlex) {}
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
~YGStyle() = default;
|
||||
|
||||
static constexpr int directionBit = 0;
|
||||
|
||||
2
deps/yoga/YGValue.cpp
vendored
2
deps/yoga/YGValue.cpp
vendored
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
|
||||
2
deps/yoga/YGValue.h
vendored
2
deps/yoga/YGValue.h
vendored
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
|
||||
8
deps/yoga/Yoga-internal.h
vendored
8
deps/yoga/Yoga-internal.h
vendored
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
@ -16,12 +16,6 @@ using YGVector = std::vector<YGNodeRef>;
|
||||
|
||||
YG_EXTERN_C_BEGIN
|
||||
|
||||
WIN_EXPORT float YGRoundValueToPixelGrid(
|
||||
const float value,
|
||||
const float pointScaleFactor,
|
||||
const bool forceCeil,
|
||||
const bool forceFloor);
|
||||
|
||||
void YGNodeCalculateLayoutWithContext(
|
||||
YGNodeRef node,
|
||||
float availableWidth,
|
||||
|
||||
266
deps/yoga/Yoga.cpp
vendored
266
deps/yoga/Yoga.cpp
vendored
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
@ -15,7 +15,7 @@
|
||||
#include "YGNodePrint.h"
|
||||
#include "Yoga-internal.h"
|
||||
#include "event/event.h"
|
||||
#include "instrumentation.h"
|
||||
#include "internal/experiments-inl.h"
|
||||
#ifdef _MSC_VER
|
||||
#include <float.h>
|
||||
|
||||
@ -213,9 +213,7 @@ WIN_EXPORT YGNodeRef YGNodeNewWithConfig(const YGConfigRef config) {
|
||||
const YGNodeRef node = new YGNode{config};
|
||||
YGAssertWithConfig(
|
||||
config, node != nullptr, "Could not allocate memory for node");
|
||||
#ifdef YG_ENABLE_EVENTS
|
||||
Event::publish<Event::NodeAllocation>(node, {config});
|
||||
#endif
|
||||
|
||||
return node;
|
||||
}
|
||||
@ -235,9 +233,7 @@ YGNodeRef YGNodeClone(YGNodeRef oldNode) {
|
||||
oldNode->getConfig(),
|
||||
node != nullptr,
|
||||
"Could not allocate memory for node");
|
||||
#ifdef YG_ENABLE_EVENTS
|
||||
Event::publish<Event::NodeAllocation>(node, {node->getConfig()});
|
||||
#endif
|
||||
node->setOwner(nullptr);
|
||||
return node;
|
||||
}
|
||||
@ -253,7 +249,11 @@ static YGConfigRef YGConfigClone(const YGConfig& oldConfig) {
|
||||
}
|
||||
|
||||
static YGNodeRef YGNodeDeepClone(YGNodeRef oldNode) {
|
||||
YGNodeRef node = YGNodeClone(oldNode);
|
||||
auto config = YGConfigClone(*oldNode->getConfig());
|
||||
auto node = new YGNode{*oldNode, config};
|
||||
node->setOwner(nullptr);
|
||||
Event::publish<Event::NodeAllocation>(node, {node->getConfig()});
|
||||
|
||||
YGVector vec = YGVector();
|
||||
vec.reserve(oldNode->getChildren().size());
|
||||
YGNodeRef childNode = nullptr;
|
||||
@ -264,10 +264,6 @@ static YGNodeRef YGNodeDeepClone(YGNodeRef oldNode) {
|
||||
}
|
||||
node->setChildren(vec);
|
||||
|
||||
if (oldNode->getConfig() != nullptr) {
|
||||
node->setConfig(YGConfigClone(*(oldNode->getConfig())));
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
@ -284,9 +280,7 @@ void YGNodeFree(const YGNodeRef node) {
|
||||
}
|
||||
|
||||
node->clearChildren();
|
||||
#ifdef YG_ENABLE_EVENTS
|
||||
Event::publish<Event::NodeDeallocation>(node, {node->getConfig()});
|
||||
#endif
|
||||
delete node;
|
||||
}
|
||||
|
||||
@ -945,10 +939,12 @@ bool YGLayoutNodeInternal(
|
||||
const float ownerWidth,
|
||||
const float ownerHeight,
|
||||
const bool performLayout,
|
||||
const char* reason,
|
||||
const LayoutPassReason reason,
|
||||
const YGConfigRef config,
|
||||
YGMarkerLayoutData& layoutMarkerData,
|
||||
void* const layoutContext);
|
||||
LayoutData& layoutMarkerData,
|
||||
void* const layoutContext,
|
||||
const uint32_t depth,
|
||||
const uint32_t generationCount);
|
||||
|
||||
#ifdef DEBUG
|
||||
static void YGNodePrintInternal(
|
||||
@ -1001,12 +997,16 @@ static inline YGAlign YGNodeAlignItem(const YGNode* node, const YGNode* child) {
|
||||
|
||||
static float YGBaseline(const YGNodeRef node, void* layoutContext) {
|
||||
if (node->hasBaselineFunc()) {
|
||||
const float baseline = marker::MarkerSection<YGMarkerBaselineFn>::wrap(
|
||||
node,
|
||||
&YGNode::baseline,
|
||||
|
||||
Event::publish<Event::NodeBaselineStart>(node);
|
||||
|
||||
const float baseline = node->baseline(
|
||||
node->getLayout().measuredDimensions[YGDimensionWidth],
|
||||
node->getLayout().measuredDimensions[YGDimensionHeight],
|
||||
layoutContext);
|
||||
|
||||
Event::publish<Event::NodeBaselineEnd>(node);
|
||||
|
||||
YGAssertWithNode(
|
||||
node,
|
||||
!YGFloatIsUndefined(baseline),
|
||||
@ -1191,8 +1191,10 @@ static void YGNodeComputeFlexBasisForChild(
|
||||
const YGMeasureMode heightMode,
|
||||
const YGDirection direction,
|
||||
const YGConfigRef config,
|
||||
YGMarkerLayoutData& layoutMarkerData,
|
||||
void* const layoutContext) {
|
||||
LayoutData& layoutMarkerData,
|
||||
void* const layoutContext,
|
||||
const uint32_t depth,
|
||||
const uint32_t generationCount) {
|
||||
const YGFlexDirection mainAxis =
|
||||
YGResolveFlexDirection(node->getStyle().flexDirection(), direction);
|
||||
const bool isMainAxisRow = YGFlexDirectionIsRow(mainAxis);
|
||||
@ -1215,8 +1217,7 @@ static void YGNodeComputeFlexBasisForChild(
|
||||
if (child->getLayout().computedFlexBasis.isUndefined() ||
|
||||
(YGConfigIsExperimentalFeatureEnabled(
|
||||
child->getConfig(), YGExperimentalFeatureWebFlexBasis) &&
|
||||
child->getLayout().computedFlexBasisGeneration !=
|
||||
gCurrentGenerationCount)) {
|
||||
child->getLayout().computedFlexBasisGeneration != generationCount)) {
|
||||
const YGFloatOptional paddingAndBorder = YGFloatOptional(
|
||||
YGNodePaddingAndBorderForAxis(child, mainAxis, ownerWidth));
|
||||
child->setLayoutComputedFlexBasis(
|
||||
@ -1364,16 +1365,18 @@ static void YGNodeComputeFlexBasisForChild(
|
||||
ownerWidth,
|
||||
ownerHeight,
|
||||
false,
|
||||
"measure",
|
||||
LayoutPassReason::kMeasureChild,
|
||||
config,
|
||||
layoutMarkerData,
|
||||
layoutContext);
|
||||
layoutContext,
|
||||
depth,
|
||||
generationCount);
|
||||
|
||||
child->setLayoutComputedFlexBasis(YGFloatOptional(YGFloatMax(
|
||||
child->getLayout().measuredDimensions[dim[mainAxis]],
|
||||
YGNodePaddingAndBorderForAxis(child, mainAxis, ownerWidth))));
|
||||
}
|
||||
child->setLayoutComputedFlexBasisGeneration(gCurrentGenerationCount);
|
||||
child->setLayoutComputedFlexBasisGeneration(generationCount);
|
||||
}
|
||||
|
||||
static void YGNodeAbsoluteLayoutChild(
|
||||
@ -1384,8 +1387,10 @@ static void YGNodeAbsoluteLayoutChild(
|
||||
const float height,
|
||||
const YGDirection direction,
|
||||
const YGConfigRef config,
|
||||
YGMarkerLayoutData& layoutMarkerData,
|
||||
void* const layoutContext) {
|
||||
LayoutData& layoutMarkerData,
|
||||
void* const layoutContext,
|
||||
const uint32_t depth,
|
||||
const uint32_t generationCount) {
|
||||
const YGFlexDirection mainAxis =
|
||||
YGResolveFlexDirection(node->getStyle().flexDirection(), direction);
|
||||
const YGFlexDirection crossAxis = YGFlexDirectionCross(mainAxis, direction);
|
||||
@ -1488,10 +1493,12 @@ static void YGNodeAbsoluteLayoutChild(
|
||||
childWidth,
|
||||
childHeight,
|
||||
false,
|
||||
"abs-measure",
|
||||
LayoutPassReason::kAbsMeasureChild,
|
||||
config,
|
||||
layoutMarkerData,
|
||||
layoutContext);
|
||||
layoutContext,
|
||||
depth,
|
||||
generationCount);
|
||||
childWidth = child->getLayout().measuredDimensions[YGDimensionWidth] +
|
||||
child->getMarginForAxis(YGFlexDirectionRow, width).unwrap();
|
||||
childHeight = child->getLayout().measuredDimensions[YGDimensionHeight] +
|
||||
@ -1508,10 +1515,12 @@ static void YGNodeAbsoluteLayoutChild(
|
||||
childWidth,
|
||||
childHeight,
|
||||
true,
|
||||
"abs-layout",
|
||||
LayoutPassReason::kAbsLayout,
|
||||
config,
|
||||
layoutMarkerData,
|
||||
layoutContext);
|
||||
layoutContext,
|
||||
depth,
|
||||
generationCount);
|
||||
|
||||
if (child->isTrailingPosDefined(mainAxis) &&
|
||||
!child->isLeadingPositionDefined(mainAxis)) {
|
||||
@ -1579,7 +1588,9 @@ static void YGNodeWithMeasureFuncSetMeasuredDimensions(
|
||||
const YGMeasureMode heightMeasureMode,
|
||||
const float ownerWidth,
|
||||
const float ownerHeight,
|
||||
void* const layoutContext) {
|
||||
LayoutData& layoutMarkerData,
|
||||
void* const layoutContext,
|
||||
const LayoutPassReason reason) {
|
||||
YGAssertWithNode(
|
||||
node,
|
||||
node->hasMeasureFunc(),
|
||||
@ -1623,16 +1634,38 @@ static void YGNodeWithMeasureFuncSetMeasuredDimensions(
|
||||
ownerWidth),
|
||||
YGDimensionHeight);
|
||||
} else {
|
||||
Event::publish<Event::MeasureCallbackStart>(node);
|
||||
|
||||
// Measure the text under the current constraints.
|
||||
const YGSize measuredSize = marker::MarkerSection<YGMarkerMeasure>::wrap(
|
||||
node,
|
||||
&YGNode::measure,
|
||||
const YGSize measuredSize = node->measure(
|
||||
innerWidth,
|
||||
widthMeasureMode,
|
||||
innerHeight,
|
||||
heightMeasureMode,
|
||||
layoutContext);
|
||||
|
||||
layoutMarkerData.measureCallbacks += 1;
|
||||
|
||||
Event::publish<Event::MeasureCallbackEnd>(
|
||||
node,
|
||||
{layoutContext,
|
||||
innerWidth,
|
||||
widthMeasureMode,
|
||||
innerHeight,
|
||||
heightMeasureMode,
|
||||
measuredSize.width,
|
||||
measuredSize.height,
|
||||
reason});
|
||||
|
||||
if (internal::isEnabled(internal::Experiment::kDoubleMeasureCallbacks)) {
|
||||
node->measure(
|
||||
innerWidth,
|
||||
widthMeasureMode,
|
||||
innerHeight,
|
||||
heightMeasureMode,
|
||||
layoutContext);
|
||||
}
|
||||
|
||||
node->setLayoutMeasuredDimension(
|
||||
YGNodeBoundAxis(
|
||||
node,
|
||||
@ -1814,8 +1847,10 @@ static float YGNodeComputeFlexBasisForChildren(
|
||||
YGFlexDirection mainAxis,
|
||||
const YGConfigRef config,
|
||||
bool performLayout,
|
||||
YGMarkerLayoutData& layoutMarkerData,
|
||||
void* const layoutContext) {
|
||||
LayoutData& layoutMarkerData,
|
||||
void* const layoutContext,
|
||||
const uint32_t depth,
|
||||
const uint32_t generationCount) {
|
||||
float totalOuterFlexBasis = 0.0f;
|
||||
YGNodeRef singleFlexChild = nullptr;
|
||||
YGVector children = node->getChildren();
|
||||
@ -1866,7 +1901,7 @@ static float YGNodeComputeFlexBasisForChildren(
|
||||
continue;
|
||||
}
|
||||
if (child == singleFlexChild) {
|
||||
child->setLayoutComputedFlexBasisGeneration(gCurrentGenerationCount);
|
||||
child->setLayoutComputedFlexBasisGeneration(generationCount);
|
||||
child->setLayoutComputedFlexBasis(YGFloatOptional(0));
|
||||
} else {
|
||||
YGNodeComputeFlexBasisForChild(
|
||||
@ -1881,7 +1916,9 @@ static float YGNodeComputeFlexBasisForChildren(
|
||||
direction,
|
||||
config,
|
||||
layoutMarkerData,
|
||||
layoutContext);
|
||||
layoutContext,
|
||||
depth,
|
||||
generationCount);
|
||||
}
|
||||
|
||||
totalOuterFlexBasis +=
|
||||
@ -1994,8 +2031,10 @@ static float YGDistributeFreeSpaceSecondPass(
|
||||
const YGMeasureMode measureModeCrossDim,
|
||||
const bool performLayout,
|
||||
const YGConfigRef config,
|
||||
YGMarkerLayoutData& layoutMarkerData,
|
||||
void* const layoutContext) {
|
||||
LayoutData& layoutMarkerData,
|
||||
void* const layoutContext,
|
||||
const uint32_t depth,
|
||||
const uint32_t generationCount) {
|
||||
float childFlexBasis = 0;
|
||||
float flexShrinkScaledFactor = 0;
|
||||
float flexGrowFactor = 0;
|
||||
@ -2158,10 +2197,12 @@ static float YGDistributeFreeSpaceSecondPass(
|
||||
availableInnerWidth,
|
||||
availableInnerHeight,
|
||||
performLayout && !requiresStretchLayout,
|
||||
"flex",
|
||||
LayoutPassReason::kFlex,
|
||||
config,
|
||||
layoutMarkerData,
|
||||
layoutContext);
|
||||
layoutContext,
|
||||
depth,
|
||||
generationCount);
|
||||
node->setLayoutHadOverflow(
|
||||
node->getLayout().hadOverflow |
|
||||
currentRelativeChild->getLayout().hadOverflow);
|
||||
@ -2291,8 +2332,10 @@ static void YGResolveFlexibleLength(
|
||||
const YGMeasureMode measureModeCrossDim,
|
||||
const bool performLayout,
|
||||
const YGConfigRef config,
|
||||
YGMarkerLayoutData& layoutMarkerData,
|
||||
void* const layoutContext) {
|
||||
LayoutData& layoutMarkerData,
|
||||
void* const layoutContext,
|
||||
const uint32_t depth,
|
||||
const uint32_t generationCount) {
|
||||
const float originalFreeSpace = collectedFlexItemsValues.remainingFreeSpace;
|
||||
// First pass: detect the flex items whose min/max constraints trigger
|
||||
YGDistributeFreeSpaceFirstPass(
|
||||
@ -2318,7 +2361,9 @@ static void YGResolveFlexibleLength(
|
||||
performLayout,
|
||||
config,
|
||||
layoutMarkerData,
|
||||
layoutContext);
|
||||
layoutContext,
|
||||
depth,
|
||||
generationCount);
|
||||
|
||||
collectedFlexItemsValues.remainingFreeSpace =
|
||||
originalFreeSpace - distributedFreeSpace;
|
||||
@ -2617,8 +2662,11 @@ static void YGNodelayoutImpl(
|
||||
const float ownerHeight,
|
||||
const bool performLayout,
|
||||
const YGConfigRef config,
|
||||
YGMarkerLayoutData& layoutMarkerData,
|
||||
void* const layoutContext) {
|
||||
LayoutData& layoutMarkerData,
|
||||
void* const layoutContext,
|
||||
const uint32_t depth,
|
||||
const uint32_t generationCount,
|
||||
const LayoutPassReason reason) {
|
||||
YGAssertWithNode(
|
||||
node,
|
||||
YGFloatIsUndefined(availableWidth)
|
||||
@ -2686,7 +2734,9 @@ static void YGNodelayoutImpl(
|
||||
heightMeasureMode,
|
||||
ownerWidth,
|
||||
ownerHeight,
|
||||
layoutContext);
|
||||
layoutMarkerData,
|
||||
layoutContext,
|
||||
reason);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2798,7 +2848,9 @@ static void YGNodelayoutImpl(
|
||||
config,
|
||||
performLayout,
|
||||
layoutMarkerData,
|
||||
layoutContext);
|
||||
layoutContext,
|
||||
depth,
|
||||
generationCount);
|
||||
|
||||
const bool flexBasisOverflows = measureModeMainDim == YGMeasureModeUndefined
|
||||
? false
|
||||
@ -2859,8 +2911,11 @@ static void YGNodelayoutImpl(
|
||||
availableInnerMainDim = maxInnerMainDim;
|
||||
} else {
|
||||
if (!node->getConfig()->useLegacyStretchBehaviour &&
|
||||
(collectedFlexItemsValues.totalFlexGrowFactors == 0 ||
|
||||
node->resolveFlexGrow() == 0)) {
|
||||
((YGFloatIsUndefined(
|
||||
collectedFlexItemsValues.totalFlexGrowFactors) &&
|
||||
collectedFlexItemsValues.totalFlexGrowFactors == 0) ||
|
||||
(YGFloatIsUndefined(node->resolveFlexGrow()) &&
|
||||
node->resolveFlexGrow() == 0))) {
|
||||
// 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. Root node also
|
||||
// should be shrunk to minimum
|
||||
@ -2903,7 +2958,9 @@ static void YGNodelayoutImpl(
|
||||
performLayout,
|
||||
config,
|
||||
layoutMarkerData,
|
||||
layoutContext);
|
||||
layoutContext,
|
||||
depth,
|
||||
generationCount);
|
||||
}
|
||||
|
||||
node->setLayoutHadOverflow(
|
||||
@ -3074,10 +3131,12 @@ static void YGNodelayoutImpl(
|
||||
availableInnerWidth,
|
||||
availableInnerHeight,
|
||||
true,
|
||||
"stretch",
|
||||
LayoutPassReason::kStretch,
|
||||
config,
|
||||
layoutMarkerData,
|
||||
layoutContext);
|
||||
layoutContext,
|
||||
depth,
|
||||
generationCount);
|
||||
}
|
||||
} else {
|
||||
const float remainingCrossDim = containerCrossAxis -
|
||||
@ -3282,10 +3341,12 @@ static void YGNodelayoutImpl(
|
||||
availableInnerWidth,
|
||||
availableInnerHeight,
|
||||
true,
|
||||
"multiline-stretch",
|
||||
LayoutPassReason::kMultilineStretch,
|
||||
config,
|
||||
layoutMarkerData,
|
||||
layoutContext);
|
||||
layoutContext,
|
||||
depth,
|
||||
generationCount);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -3425,7 +3486,9 @@ static void YGNodelayoutImpl(
|
||||
direction,
|
||||
config,
|
||||
layoutMarkerData,
|
||||
layoutContext);
|
||||
layoutContext,
|
||||
depth,
|
||||
generationCount);
|
||||
}
|
||||
|
||||
// STEP 11: SETTING TRAILING POSITIONS FOR CHILDREN
|
||||
@ -3453,7 +3516,6 @@ static void YGNodelayoutImpl(
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t gDepth = 0;
|
||||
bool gPrintChanges = false;
|
||||
bool gPrintSkips = false;
|
||||
|
||||
@ -3656,19 +3718,18 @@ bool YGLayoutNodeInternal(
|
||||
const float ownerWidth,
|
||||
const float ownerHeight,
|
||||
const bool performLayout,
|
||||
const char* reason,
|
||||
const LayoutPassReason reason,
|
||||
const YGConfigRef config,
|
||||
YGMarkerLayoutData& layoutMarkerData,
|
||||
void* const layoutContext) {
|
||||
#ifdef YG_ENABLE_EVENTS
|
||||
Event::publish<Event::NodeLayout>(node);
|
||||
#endif
|
||||
LayoutData& layoutMarkerData,
|
||||
void* const layoutContext,
|
||||
uint32_t depth,
|
||||
const uint32_t generationCount) {
|
||||
YGLayout* layout = &node->getLayout();
|
||||
|
||||
gDepth++;
|
||||
depth++;
|
||||
|
||||
const bool needToVisitNode =
|
||||
(node->isDirty() && layout->generationCount != gCurrentGenerationCount) ||
|
||||
(node->isDirty() && layout->generationCount != generationCount) ||
|
||||
layout->lastOwnerDirection != ownerDirection;
|
||||
|
||||
if (needToVisitNode) {
|
||||
@ -3770,8 +3831,8 @@ bool YGLayoutNodeInternal(
|
||||
YGLogLevelVerbose,
|
||||
nullptr,
|
||||
"%s%d.{[skipped] ",
|
||||
YGSpacer(gDepth),
|
||||
gDepth);
|
||||
YGSpacer(depth),
|
||||
depth);
|
||||
node->print(layoutContext);
|
||||
Log::log(
|
||||
node,
|
||||
@ -3784,7 +3845,7 @@ bool YGLayoutNodeInternal(
|
||||
availableHeight,
|
||||
cachedResults->computedWidth,
|
||||
cachedResults->computedHeight,
|
||||
reason);
|
||||
LayoutPassReasonToString(reason));
|
||||
}
|
||||
} else {
|
||||
if (gPrintChanges) {
|
||||
@ -3793,8 +3854,8 @@ bool YGLayoutNodeInternal(
|
||||
YGLogLevelVerbose,
|
||||
nullptr,
|
||||
"%s%d.{%s",
|
||||
YGSpacer(gDepth),
|
||||
gDepth,
|
||||
YGSpacer(depth),
|
||||
depth,
|
||||
needToVisitNode ? "*" : "");
|
||||
node->print(layoutContext);
|
||||
Log::log(
|
||||
@ -3806,7 +3867,7 @@ bool YGLayoutNodeInternal(
|
||||
YGMeasureModeName(heightMeasureMode, performLayout),
|
||||
availableWidth,
|
||||
availableHeight,
|
||||
reason);
|
||||
LayoutPassReasonToString(reason));
|
||||
}
|
||||
|
||||
YGNodelayoutImpl(
|
||||
@ -3821,7 +3882,10 @@ bool YGLayoutNodeInternal(
|
||||
performLayout,
|
||||
config,
|
||||
layoutMarkerData,
|
||||
layoutContext);
|
||||
layoutContext,
|
||||
depth,
|
||||
generationCount,
|
||||
reason);
|
||||
|
||||
if (gPrintChanges) {
|
||||
Log::log(
|
||||
@ -3829,8 +3893,8 @@ bool YGLayoutNodeInternal(
|
||||
YGLogLevelVerbose,
|
||||
nullptr,
|
||||
"%s%d.}%s",
|
||||
YGSpacer(gDepth),
|
||||
gDepth,
|
||||
YGSpacer(depth),
|
||||
depth,
|
||||
needToVisitNode ? "*" : "");
|
||||
node->print(layoutContext);
|
||||
Log::log(
|
||||
@ -3842,7 +3906,7 @@ bool YGLayoutNodeInternal(
|
||||
YGMeasureModeName(heightMeasureMode, performLayout),
|
||||
layout->measuredDimensions[YGDimensionWidth],
|
||||
layout->measuredDimensions[YGDimensionHeight],
|
||||
reason);
|
||||
LayoutPassReasonToString(reason));
|
||||
}
|
||||
|
||||
layout->lastOwnerDirection = ownerDirection;
|
||||
@ -3894,8 +3958,19 @@ bool YGLayoutNodeInternal(
|
||||
node->setDirty(false);
|
||||
}
|
||||
|
||||
gDepth--;
|
||||
layout->generationCount = gCurrentGenerationCount;
|
||||
layout->generationCount = generationCount;
|
||||
|
||||
LayoutType layoutType;
|
||||
if (performLayout) {
|
||||
layoutType = !needToVisitNode && cachedResults == &layout->cachedLayout
|
||||
? LayoutType::kCachedLayout
|
||||
: LayoutType::kLayout;
|
||||
} else {
|
||||
layoutType = cachedResults != nullptr ? LayoutType::kCachedMeasure
|
||||
: LayoutType::kMeasure;
|
||||
}
|
||||
Event::publish<Event::NodeLayout>(node, {layoutType, layoutContext});
|
||||
|
||||
return (needToVisitNode || cachedResults == nullptr);
|
||||
}
|
||||
|
||||
@ -4003,12 +4078,8 @@ void YGNodeCalculateLayoutWithContext(
|
||||
const YGDirection ownerDirection,
|
||||
void* layoutContext) {
|
||||
|
||||
#ifdef YG_ENABLE_EVENTS
|
||||
Event::publish<Event::LayoutPassStart>(node);
|
||||
#endif
|
||||
// unique pointer to allow ending the marker early
|
||||
std::unique_ptr<marker::MarkerSection<YGMarkerLayout>> marker{
|
||||
new marker::MarkerSection<YGMarkerLayout>{node}};
|
||||
Event::publish<Event::LayoutPassStart>(node, {layoutContext});
|
||||
LayoutData markerData = {};
|
||||
|
||||
// Increment the generation count. This will force the recursive routine to
|
||||
// visit all dirty nodes at least once. Subsequent visits will be skipped if
|
||||
@ -4065,10 +4136,12 @@ void YGNodeCalculateLayoutWithContext(
|
||||
ownerWidth,
|
||||
ownerHeight,
|
||||
true,
|
||||
"initial",
|
||||
LayoutPassReason::kInitial,
|
||||
node->getConfig(),
|
||||
marker->data,
|
||||
layoutContext)) {
|
||||
markerData,
|
||||
layoutContext,
|
||||
0, // tree root
|
||||
gCurrentGenerationCount)) {
|
||||
node->setPosition(
|
||||
node->getLayout().direction, ownerWidth, ownerHeight, ownerWidth);
|
||||
YGRoundToPixelGrid(node, node->getConfig()->pointScaleFactor, 0.0f, 0.0f);
|
||||
@ -4084,12 +4157,7 @@ void YGNodeCalculateLayoutWithContext(
|
||||
#endif
|
||||
}
|
||||
|
||||
// end marker here
|
||||
marker = nullptr;
|
||||
|
||||
#ifdef YG_ENABLE_EVENTS
|
||||
Event::publish<Event::LayoutPassEnd>(node);
|
||||
#endif
|
||||
Event::publish<Event::LayoutPassEnd>(node, {layoutContext, &markerData});
|
||||
|
||||
// We want to get rid off `useLegacyStretchBehaviour` from YGConfig. But we
|
||||
// aren't sure whether client's of yoga have gotten rid off this flag or not.
|
||||
@ -4107,7 +4175,7 @@ void YGNodeCalculateLayoutWithContext(
|
||||
gCurrentGenerationCount++;
|
||||
// Rerun the layout, and calculate the diff
|
||||
unsetUseLegacyFlagRecursively(nodeWithoutLegacyFlag);
|
||||
YGMarkerLayoutData layoutMarkerData;
|
||||
LayoutData layoutMarkerData = {};
|
||||
if (YGLayoutNodeInternal(
|
||||
nodeWithoutLegacyFlag,
|
||||
width,
|
||||
@ -4118,10 +4186,12 @@ void YGNodeCalculateLayoutWithContext(
|
||||
ownerWidth,
|
||||
ownerHeight,
|
||||
true,
|
||||
"initial",
|
||||
LayoutPassReason::kInitial,
|
||||
nodeWithoutLegacyFlag->getConfig(),
|
||||
layoutMarkerData,
|
||||
layoutContext)) {
|
||||
layoutContext,
|
||||
0, // tree root
|
||||
gCurrentGenerationCount)) {
|
||||
nodeWithoutLegacyFlag->setPosition(
|
||||
nodeWithoutLegacyFlag->getLayout().direction,
|
||||
ownerWidth,
|
||||
|
||||
4
deps/yoga/Yoga.h
vendored
4
deps/yoga/Yoga.h
vendored
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
@ -330,7 +330,7 @@ WIN_EXPORT bool YGConfigIsExperimentalFeatureEnabled(
|
||||
YGConfigRef config,
|
||||
YGExperimentalFeature feature);
|
||||
|
||||
// Using the web defaults is the prefered configuration for new projects. Usage
|
||||
// Using the web defaults is the preferred configuration for new projects. Usage
|
||||
// of non web defaults should be considered as legacy.
|
||||
WIN_EXPORT void YGConfigSetUseWebDefaults(YGConfigRef config, bool enabled);
|
||||
WIN_EXPORT bool YGConfigGetUseWebDefaults(YGConfigRef config);
|
||||
|
||||
81
deps/yoga/event/event.cpp
vendored
81
deps/yoga/event/event.cpp
vendored
@ -1,55 +1,82 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
#include "event.h"
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <mutex>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace facebook {
|
||||
namespace yoga {
|
||||
|
||||
namespace {
|
||||
|
||||
std::mutex& eventSubscribersMutex() {
|
||||
static std::mutex subscribersMutex;
|
||||
return subscribersMutex;
|
||||
const char* LayoutPassReasonToString(const LayoutPassReason value) {
|
||||
switch (value) {
|
||||
case LayoutPassReason::kInitial:
|
||||
return "initial";
|
||||
case LayoutPassReason::kMeasureChild:
|
||||
return "measure";
|
||||
case LayoutPassReason::kAbsMeasureChild:
|
||||
return "abs_measure";
|
||||
case LayoutPassReason::kFlex:
|
||||
return "flex";
|
||||
case LayoutPassReason::kAbsLayout:
|
||||
return "abs_layout";
|
||||
case LayoutPassReason::kStretch:
|
||||
return "stretch";
|
||||
case LayoutPassReason::kMultilineStretch:
|
||||
return "multiline_stretch";
|
||||
default:
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<Event::Subscribers>& eventSubscribers() {
|
||||
static auto subscribers = std::make_shared<Event::Subscribers>();
|
||||
return subscribers;
|
||||
namespace {
|
||||
|
||||
struct Node {
|
||||
std::function<Event::Subscriber> subscriber = nullptr;
|
||||
Node* next = nullptr;
|
||||
|
||||
Node(std::function<Event::Subscriber>&& subscriber)
|
||||
: subscriber{std::move(subscriber)} {}
|
||||
};
|
||||
|
||||
std::atomic<Node*> subscribers{nullptr};
|
||||
|
||||
Node* push(Node* newHead) {
|
||||
Node* oldHead;
|
||||
do {
|
||||
oldHead = subscribers.load(std::memory_order_relaxed);
|
||||
if (newHead != nullptr) {
|
||||
newHead->next = oldHead;
|
||||
}
|
||||
} while (!subscribers.compare_exchange_weak(
|
||||
oldHead, newHead, std::memory_order_release, std::memory_order_relaxed));
|
||||
return oldHead;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void Event::reset() {
|
||||
eventSubscribers() = std::make_shared<Event::Subscribers>();
|
||||
auto head = push(nullptr);
|
||||
while (head != nullptr) {
|
||||
auto current = head;
|
||||
head = head->next;
|
||||
delete current;
|
||||
}
|
||||
}
|
||||
|
||||
void Event::subscribe(std::function<Subscriber>&& subscriber) {
|
||||
std::lock_guard<std::mutex> guard(eventSubscribersMutex());
|
||||
eventSubscribers() =
|
||||
std::make_shared<Event::Subscribers>(*eventSubscribers());
|
||||
eventSubscribers()->push_back(subscriber);
|
||||
push(new Node{std::move(subscriber)});
|
||||
}
|
||||
|
||||
void Event::publish(const YGNode& node, Type eventType, const Data& eventData) {
|
||||
std::shared_ptr<Event::Subscribers> subscribers;
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(eventSubscribersMutex());
|
||||
subscribers = eventSubscribers();
|
||||
}
|
||||
|
||||
for (auto& subscriber : *subscribers) {
|
||||
if (subscriber) {
|
||||
subscriber(node, eventType, eventData);
|
||||
}
|
||||
for (auto subscriber = subscribers.load(std::memory_order_relaxed);
|
||||
subscriber != nullptr;
|
||||
subscriber = subscriber->next) {
|
||||
subscriber->subscriber(node, eventType, eventData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
68
deps/yoga/event/event.h
vendored
68
deps/yoga/event/event.h
vendored
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
@ -8,6 +8,7 @@
|
||||
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
#include <yoga/YGEnums.h>
|
||||
|
||||
struct YGConfig;
|
||||
struct YGNode;
|
||||
@ -15,13 +16,45 @@ struct YGNode;
|
||||
namespace facebook {
|
||||
namespace yoga {
|
||||
|
||||
enum struct LayoutType : int {
|
||||
kLayout = 0,
|
||||
kMeasure = 1,
|
||||
kCachedLayout = 2,
|
||||
kCachedMeasure = 3
|
||||
};
|
||||
|
||||
struct LayoutData {
|
||||
int layouts;
|
||||
int measures;
|
||||
int maxMeasureCache;
|
||||
int cachedLayouts;
|
||||
int cachedMeasures;
|
||||
int measureCallbacks;
|
||||
};
|
||||
|
||||
enum struct LayoutPassReason : int {
|
||||
kInitial = 0,
|
||||
kMeasureChild = 1,
|
||||
kAbsMeasureChild = 2,
|
||||
kFlex = 3,
|
||||
kAbsLayout = 4,
|
||||
kStretch = 5,
|
||||
kMultilineStretch = 6
|
||||
};
|
||||
|
||||
const char* LayoutPassReasonToString(const LayoutPassReason value);
|
||||
|
||||
struct Event {
|
||||
enum Type {
|
||||
NodeAllocation,
|
||||
NodeDeallocation,
|
||||
NodeLayout,
|
||||
LayoutPassStart,
|
||||
LayoutPassEnd
|
||||
LayoutPassEnd,
|
||||
MeasureCallbackStart,
|
||||
MeasureCallbackEnd,
|
||||
NodeBaselineStart,
|
||||
NodeBaselineEnd,
|
||||
};
|
||||
class Data;
|
||||
using Subscriber = void(const YGNode&, Type, Data);
|
||||
@ -49,7 +82,9 @@ struct Event {
|
||||
|
||||
template <Type E>
|
||||
static void publish(const YGNode& node, const TypedData<E>& eventData = {}) {
|
||||
#ifdef YG_ENABLE_EVENTS
|
||||
publish(node, E, Data{eventData});
|
||||
#endif
|
||||
}
|
||||
|
||||
template <Type E>
|
||||
@ -71,5 +106,34 @@ struct Event::TypedData<Event::NodeDeallocation> {
|
||||
YGConfig* config;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Event::TypedData<Event::LayoutPassStart> {
|
||||
void* layoutContext;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Event::TypedData<Event::LayoutPassEnd> {
|
||||
void* layoutContext;
|
||||
LayoutData* layoutData;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Event::TypedData<Event::MeasureCallbackEnd> {
|
||||
void* layoutContext;
|
||||
float width;
|
||||
YGMeasureMode widthMeasureMode;
|
||||
float height;
|
||||
YGMeasureMode heightMeasureMode;
|
||||
float measuredWidth;
|
||||
float measuredHeight;
|
||||
const LayoutPassReason reason;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Event::TypedData<Event::NodeLayout> {
|
||||
LayoutType layoutType;
|
||||
void* layoutContext;
|
||||
};
|
||||
|
||||
} // namespace yoga
|
||||
} // namespace facebook
|
||||
|
||||
63
deps/yoga/instrumentation.h
vendored
63
deps/yoga/instrumentation.h
vendored
@ -1,63 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
#include "YGConfig.h"
|
||||
#include "YGMarker.h"
|
||||
#include "YGNode.h"
|
||||
|
||||
namespace facebook {
|
||||
namespace yoga {
|
||||
namespace marker {
|
||||
|
||||
template <YGMarker MarkerType>
|
||||
class MarkerSection {
|
||||
private:
|
||||
using Data = detail::MarkerData<MarkerType>;
|
||||
|
||||
public:
|
||||
MarkerSection(YGNodeRef node) : MarkerSection{node, node->getConfig()} {}
|
||||
~MarkerSection() {
|
||||
if (endMarker_) {
|
||||
endMarker_(MarkerType, node_, markerData(&data), userData_);
|
||||
}
|
||||
}
|
||||
|
||||
typename Data::type data = {};
|
||||
|
||||
template <typename Ret, typename... Args>
|
||||
static Ret wrap(
|
||||
YGNodeRef node,
|
||||
Ret (YGNode::*method)(Args...),
|
||||
Args... args) {
|
||||
MarkerSection<MarkerType> section{node};
|
||||
return (node->*method)(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
private:
|
||||
decltype(YGMarkerCallbacks{}.endMarker) endMarker_;
|
||||
YGNodeRef node_;
|
||||
void* userData_;
|
||||
|
||||
MarkerSection(YGNodeRef node, YGConfigRef config)
|
||||
: MarkerSection{node, config ? &config->markerCallbacks : nullptr} {}
|
||||
MarkerSection(YGNodeRef node, YGMarkerCallbacks* callbacks)
|
||||
: endMarker_{callbacks ? callbacks->endMarker : nullptr},
|
||||
node_{node},
|
||||
userData_{
|
||||
callbacks && callbacks->startMarker
|
||||
? callbacks->startMarker(MarkerType, node, markerData(&data))
|
||||
: nullptr} {}
|
||||
|
||||
static YGMarkerData markerData(typename Data::type* d) {
|
||||
YGMarkerData markerData = {};
|
||||
Data::get(markerData) = d;
|
||||
return markerData;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace marker
|
||||
} // namespace yoga
|
||||
} // namespace facebook
|
||||
31
deps/yoga/internal/experiments-inl.h
vendored
Normal file
31
deps/yoga/internal/experiments-inl.h
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "experiments.h"
|
||||
|
||||
#include <bitset>
|
||||
|
||||
namespace facebook {
|
||||
namespace yoga {
|
||||
namespace internal {
|
||||
|
||||
namespace detail {
|
||||
extern std::bitset<sizeof(int)> enabledExperiments;
|
||||
} // namespace detail
|
||||
|
||||
inline bool isEnabled(Experiment experiment) {
|
||||
return detail::enabledExperiments.test(static_cast<size_t>(experiment));
|
||||
}
|
||||
|
||||
inline void disableAllExperiments() {
|
||||
detail::enabledExperiments = 0;
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace yoga
|
||||
} // namespace facebook
|
||||
37
deps/yoga/internal/experiments.cpp
vendored
Normal file
37
deps/yoga/internal/experiments.cpp
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
#include "experiments.h"
|
||||
#include "experiments-inl.h"
|
||||
|
||||
namespace facebook {
|
||||
namespace yoga {
|
||||
namespace internal {
|
||||
|
||||
namespace detail {
|
||||
|
||||
std::bitset<sizeof(int)> enabledExperiments = 0;
|
||||
|
||||
} // namespace detail
|
||||
|
||||
void enable(Experiment experiment) {
|
||||
detail::enabledExperiments.set(static_cast<size_t>(experiment));
|
||||
}
|
||||
|
||||
void disable(Experiment experiment) {
|
||||
detail::enabledExperiments.reset(static_cast<size_t>(experiment));
|
||||
}
|
||||
|
||||
bool toggle(Experiment experiment) {
|
||||
auto bit = static_cast<size_t>(experiment);
|
||||
auto previousState = detail::enabledExperiments.test(bit);
|
||||
detail::enabledExperiments.flip(bit);
|
||||
return previousState;
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace yoga
|
||||
} // namespace facebook
|
||||
25
deps/yoga/internal/experiments.h
vendored
Normal file
25
deps/yoga/internal/experiments.h
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
namespace facebook {
|
||||
namespace yoga {
|
||||
namespace internal {
|
||||
|
||||
enum struct Experiment : size_t {
|
||||
kDoubleMeasureCallbacks,
|
||||
};
|
||||
|
||||
void enable(Experiment);
|
||||
void disable(Experiment);
|
||||
bool toggle(Experiment);
|
||||
|
||||
} // namespace internal
|
||||
} // namespace yoga
|
||||
} // namespace facebook
|
||||
2
deps/yoga/log.cpp
vendored
2
deps/yoga/log.cpp
vendored
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
|
||||
2
deps/yoga/log.h
vendored
2
deps/yoga/log.h
vendored
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
|
||||
@ -14,8 +14,8 @@
|
||||
"outDir": "./dist" /* Redirect output structure to the directory. */,
|
||||
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
||||
// "composite": true, /* Enable project compilation */
|
||||
// "incremental": true, /* Enable incremental compilation */
|
||||
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
|
||||
"incremental": true, /* Enable incremental compilation */
|
||||
"tsBuildInfoFile": ".cache/tsconfig.tsbuildinfo", /* Specify file to store incremental compilation information */
|
||||
// "removeComments": true, /* Do not emit comments to output. */
|
||||
// "noEmit": true, /* Do not emit outputs. */
|
||||
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user