mirror of
https://github.com/status-im/react-native.git
synced 2025-02-26 16:10:58 +00:00
Run lint on Yoga.cpp
/Yoga.h
Summary: @public auto-fixes formatting for `Yoga.cpp`/`Yoga.h`. Submitted separately to keep other diffs cleaner. Reviewed By: astreet Differential Revision: D8868179 fbshipit-source-id: d0667f8bb909bb5ada1263aac6e22b0a8f8875ad
This commit is contained in:
parent
1d7a24ff0c
commit
ce4c2de3a3
File diff suppressed because it is too large
Load Diff
@ -1,10 +1,10 @@
|
||||
/**
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
/*
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*
|
||||
* 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 <assert.h>
|
||||
@ -45,23 +45,26 @@ typedef struct YGValue {
|
||||
extern const YGValue YGValueUndefined;
|
||||
extern const YGValue YGValueAuto;
|
||||
|
||||
typedef struct YGConfig *YGConfigRef;
|
||||
typedef struct YGConfig* YGConfigRef;
|
||||
|
||||
typedef struct YGNode* YGNodeRef;
|
||||
|
||||
typedef YGSize (*YGMeasureFunc)(YGNodeRef node,
|
||||
float width,
|
||||
YGMeasureMode widthMode,
|
||||
float height,
|
||||
YGMeasureMode heightMode);
|
||||
typedef float (*YGBaselineFunc)(YGNodeRef node, const float width, const float height);
|
||||
typedef YGSize (*YGMeasureFunc)(
|
||||
YGNodeRef node,
|
||||
float width,
|
||||
YGMeasureMode widthMode,
|
||||
float height,
|
||||
YGMeasureMode heightMode);
|
||||
typedef float (
|
||||
*YGBaselineFunc)(YGNodeRef node, const float width, const float height);
|
||||
typedef void (*YGDirtiedFunc)(YGNodeRef node);
|
||||
typedef void (*YGPrintFunc)(YGNodeRef node);
|
||||
typedef int (*YGLogger)(const YGConfigRef config,
|
||||
const YGNodeRef node,
|
||||
YGLogLevel level,
|
||||
const char *format,
|
||||
va_list args);
|
||||
typedef int (*YGLogger)(
|
||||
const YGConfigRef config,
|
||||
const YGNodeRef node,
|
||||
YGLogLevel level,
|
||||
const char* format,
|
||||
va_list args);
|
||||
typedef YGNodeRef (
|
||||
*YGCloneNodeFunc)(YGNodeRef oldNode, YGNodeRef owner, int childIndex);
|
||||
|
||||
@ -74,9 +77,10 @@ WIN_EXPORT void YGNodeFreeRecursive(const YGNodeRef node);
|
||||
WIN_EXPORT void YGNodeReset(const YGNodeRef node);
|
||||
WIN_EXPORT int32_t YGNodeGetInstanceCount(void);
|
||||
|
||||
WIN_EXPORT void YGNodeInsertChild(const YGNodeRef node,
|
||||
const YGNodeRef child,
|
||||
const uint32_t index);
|
||||
WIN_EXPORT void YGNodeInsertChild(
|
||||
const YGNodeRef node,
|
||||
const YGNodeRef child,
|
||||
const uint32_t index);
|
||||
|
||||
// This function inserts the child YGNodeRef as a children of the node received
|
||||
// by parameter and set the Owner of the child object to null. This function is
|
||||
@ -99,10 +103,11 @@ WIN_EXPORT void YGNodeSetChildren(
|
||||
const YGNodeRef children[],
|
||||
const uint32_t count);
|
||||
|
||||
WIN_EXPORT void YGNodeCalculateLayout(const YGNodeRef node,
|
||||
const float availableWidth,
|
||||
const float availableHeight,
|
||||
const YGDirection ownerDirection);
|
||||
WIN_EXPORT void YGNodeCalculateLayout(
|
||||
const YGNodeRef node,
|
||||
const float availableWidth,
|
||||
const float availableHeight,
|
||||
const YGDirection ownerDirection);
|
||||
|
||||
// Mark a node as dirty. Only valid for nodes with a custom measure function
|
||||
// set.
|
||||
@ -112,70 +117,78 @@ WIN_EXPORT void YGNodeCalculateLayout(const YGNodeRef node,
|
||||
// marking manually.
|
||||
WIN_EXPORT void YGNodeMarkDirty(const YGNodeRef node);
|
||||
|
||||
// This function marks the current node and all its descendants as dirty. This function is added to test yoga benchmarks.
|
||||
// This function is not expected to be used in production as calling `YGCalculateLayout` will cause the recalculation of each and every node.
|
||||
// This function marks the current node and all its descendants as dirty. This
|
||||
// function is added to test yoga benchmarks. This function is not expected to
|
||||
// be used in production as calling `YGCalculateLayout` will cause the
|
||||
// recalculation of each and every node.
|
||||
WIN_EXPORT void YGNodeMarkDirtyAndPropogateToDescendants(const YGNodeRef node);
|
||||
|
||||
WIN_EXPORT void YGNodePrint(const YGNodeRef node, const YGPrintOptions options);
|
||||
|
||||
WIN_EXPORT bool YGFloatIsUndefined(const float value);
|
||||
|
||||
WIN_EXPORT bool YGNodeCanUseCachedMeasurement(const YGMeasureMode widthMode,
|
||||
const float width,
|
||||
const YGMeasureMode heightMode,
|
||||
const float height,
|
||||
const YGMeasureMode lastWidthMode,
|
||||
const float lastWidth,
|
||||
const YGMeasureMode lastHeightMode,
|
||||
const float lastHeight,
|
||||
const float lastComputedWidth,
|
||||
const float lastComputedHeight,
|
||||
const float marginRow,
|
||||
const float marginColumn,
|
||||
const YGConfigRef config);
|
||||
WIN_EXPORT bool YGNodeCanUseCachedMeasurement(
|
||||
const YGMeasureMode widthMode,
|
||||
const float width,
|
||||
const YGMeasureMode heightMode,
|
||||
const float height,
|
||||
const YGMeasureMode lastWidthMode,
|
||||
const float lastWidth,
|
||||
const YGMeasureMode lastHeightMode,
|
||||
const float lastHeight,
|
||||
const float lastComputedWidth,
|
||||
const float lastComputedHeight,
|
||||
const float marginRow,
|
||||
const float marginColumn,
|
||||
const YGConfigRef config);
|
||||
|
||||
WIN_EXPORT void YGNodeCopyStyle(const YGNodeRef dstNode, const YGNodeRef srcNode);
|
||||
WIN_EXPORT void YGNodeCopyStyle(
|
||||
const YGNodeRef dstNode,
|
||||
const YGNodeRef srcNode);
|
||||
|
||||
#define YG_NODE_PROPERTY(type, name, paramName) \
|
||||
WIN_EXPORT void YGNodeSet##name(const YGNodeRef node, type paramName); \
|
||||
WIN_EXPORT type YGNodeGet##name(const YGNodeRef node);
|
||||
|
||||
#define YG_NODE_STYLE_PROPERTY(type, name, paramName) \
|
||||
WIN_EXPORT void YGNodeStyleSet##name(const YGNodeRef node, const type paramName); \
|
||||
#define YG_NODE_STYLE_PROPERTY(type, name, paramName) \
|
||||
WIN_EXPORT void YGNodeStyleSet##name( \
|
||||
const YGNodeRef node, const type paramName); \
|
||||
WIN_EXPORT type YGNodeStyleGet##name(const YGNodeRef node);
|
||||
|
||||
#define YG_NODE_STYLE_PROPERTY_UNIT(type, name, paramName) \
|
||||
WIN_EXPORT void YGNodeStyleSet##name(const YGNodeRef node, const float paramName); \
|
||||
WIN_EXPORT void YGNodeStyleSet##name##Percent(const YGNodeRef node, const float paramName); \
|
||||
#define YG_NODE_STYLE_PROPERTY_UNIT(type, name, paramName) \
|
||||
WIN_EXPORT void YGNodeStyleSet##name( \
|
||||
const YGNodeRef node, const float paramName); \
|
||||
WIN_EXPORT void YGNodeStyleSet##name##Percent( \
|
||||
const YGNodeRef node, const float paramName); \
|
||||
WIN_EXPORT type YGNodeStyleGet##name(const YGNodeRef node);
|
||||
|
||||
#define YG_NODE_STYLE_PROPERTY_UNIT_AUTO(type, name, paramName) \
|
||||
YG_NODE_STYLE_PROPERTY_UNIT(type, name, paramName) \
|
||||
WIN_EXPORT void YGNodeStyleSet##name##Auto(const YGNodeRef node);
|
||||
|
||||
#define YG_NODE_STYLE_EDGE_PROPERTY(type, name, paramName) \
|
||||
WIN_EXPORT void YGNodeStyleSet##name(const YGNodeRef node, \
|
||||
const YGEdge edge, \
|
||||
const type paramName); \
|
||||
#define YG_NODE_STYLE_EDGE_PROPERTY(type, name, paramName) \
|
||||
WIN_EXPORT void YGNodeStyleSet##name( \
|
||||
const YGNodeRef node, const YGEdge edge, const type paramName); \
|
||||
WIN_EXPORT type YGNodeStyleGet##name(const YGNodeRef node, const YGEdge edge);
|
||||
|
||||
#define YG_NODE_STYLE_EDGE_PROPERTY_UNIT(type, name, paramName) \
|
||||
WIN_EXPORT void YGNodeStyleSet##name(const YGNodeRef node, \
|
||||
const YGEdge edge, \
|
||||
const float paramName); \
|
||||
WIN_EXPORT void YGNodeStyleSet##name##Percent(const YGNodeRef node, \
|
||||
const YGEdge edge, \
|
||||
const float paramName); \
|
||||
WIN_EXPORT WIN_STRUCT(type) YGNodeStyleGet##name(const YGNodeRef node, const YGEdge edge);
|
||||
#define YG_NODE_STYLE_EDGE_PROPERTY_UNIT(type, name, paramName) \
|
||||
WIN_EXPORT void YGNodeStyleSet##name( \
|
||||
const YGNodeRef node, const YGEdge edge, const float paramName); \
|
||||
WIN_EXPORT void YGNodeStyleSet##name##Percent( \
|
||||
const YGNodeRef node, const YGEdge edge, const float paramName); \
|
||||
WIN_EXPORT WIN_STRUCT(type) \
|
||||
YGNodeStyleGet##name(const YGNodeRef node, const YGEdge edge);
|
||||
|
||||
#define YG_NODE_STYLE_EDGE_PROPERTY_UNIT_AUTO(type, name) \
|
||||
WIN_EXPORT void YGNodeStyleSet##name##Auto(const YGNodeRef node, const YGEdge edge);
|
||||
WIN_EXPORT void YGNodeStyleSet##name##Auto( \
|
||||
const YGNodeRef node, const YGEdge edge);
|
||||
|
||||
#define YG_NODE_LAYOUT_PROPERTY(type, name) \
|
||||
WIN_EXPORT type YGNodeLayoutGet##name(const YGNodeRef node);
|
||||
|
||||
#define YG_NODE_LAYOUT_EDGE_PROPERTY(type, name) \
|
||||
WIN_EXPORT type YGNodeLayoutGet##name(const YGNodeRef node, const YGEdge edge);
|
||||
WIN_EXPORT type YGNodeLayoutGet##name( \
|
||||
const YGNodeRef node, const YGEdge edge);
|
||||
|
||||
void* YGNodeGetContext(YGNodeRef node);
|
||||
void YGNodeSetContext(YGNodeRef node, void* context);
|
||||
@ -224,16 +237,18 @@ YG_NODE_STYLE_PROPERTY_UNIT(YGValue, MaxHeight, maxHeight);
|
||||
|
||||
// Yoga specific properties, not compatible with flexbox specification
|
||||
// Aspect ratio control the size of the undefined dimension of a node.
|
||||
// Aspect ratio is encoded as a floating point value width/height. e.g. A value of 2 leads to a node
|
||||
// with a width twice the size of its height while a value of 0.5 gives the opposite effect.
|
||||
// Aspect ratio is encoded as a floating point value width/height. e.g. A value
|
||||
// of 2 leads to a node with a width twice the size of its height while a value
|
||||
// of 0.5 gives the opposite effect.
|
||||
//
|
||||
// - On a node with a set width/height aspect ratio control the size of the unset dimension
|
||||
// - On a node with a set flex basis aspect ratio controls the size of the node in the cross axis if
|
||||
// unset
|
||||
// - On a node with a measure function aspect ratio works as though the measure function measures
|
||||
// the flex basis
|
||||
// - On a node with flex grow/shrink aspect ratio controls the size of the node in the cross axis if
|
||||
// unset
|
||||
// - On a node with a set width/height aspect ratio control the size of the
|
||||
// unset dimension
|
||||
// - On a node with a set flex basis aspect ratio controls the size of the node
|
||||
// in the cross axis if unset
|
||||
// - On a node with a measure function aspect ratio works as though the measure
|
||||
// function measures the flex basis
|
||||
// - On a node with flex grow/shrink aspect ratio controls the size of the node
|
||||
// in the cross axis if unset
|
||||
// - Aspect ratio takes min/max dimensions into account
|
||||
YG_NODE_STYLE_PROPERTY(float, AspectRatio, aspectRatio);
|
||||
|
||||
@ -247,37 +262,48 @@ YG_NODE_LAYOUT_PROPERTY(YGDirection, Direction);
|
||||
YG_NODE_LAYOUT_PROPERTY(bool, HadOverflow);
|
||||
bool YGNodeLayoutGetDidLegacyStretchFlagAffectLayout(const YGNodeRef node);
|
||||
|
||||
// Get the computed values for these nodes after performing layout. If they were set using
|
||||
// point values then the returned value will be the same as YGNodeStyleGetXXX. However if
|
||||
// they were set using a percentage value then the returned value is the computed value used
|
||||
// during layout.
|
||||
// Get the computed values for these nodes after performing layout. If they were
|
||||
// set using point values then the returned value will be the same as
|
||||
// YGNodeStyleGetXXX. However if they were set using a percentage value then the
|
||||
// returned value is the computed value used during layout.
|
||||
YG_NODE_LAYOUT_EDGE_PROPERTY(float, Margin);
|
||||
YG_NODE_LAYOUT_EDGE_PROPERTY(float, Border);
|
||||
YG_NODE_LAYOUT_EDGE_PROPERTY(float, Padding);
|
||||
|
||||
WIN_EXPORT void YGConfigSetLogger(const YGConfigRef config, YGLogger logger);
|
||||
WIN_EXPORT void YGLog(const YGNodeRef node, YGLogLevel level, const char *message, ...);
|
||||
WIN_EXPORT void YGLogWithConfig(const YGConfigRef config, YGLogLevel level, const char *format, ...);
|
||||
WIN_EXPORT void YGAssert(const bool condition, const char *message);
|
||||
WIN_EXPORT void YGAssertWithNode(const YGNodeRef node, const bool condition, const char *message);
|
||||
WIN_EXPORT void YGAssertWithConfig(const YGConfigRef config,
|
||||
const bool condition,
|
||||
const char *message);
|
||||
WIN_EXPORT void
|
||||
YGLog(const YGNodeRef node, YGLogLevel level, const char* message, ...);
|
||||
WIN_EXPORT void YGLogWithConfig(
|
||||
const YGConfigRef config,
|
||||
YGLogLevel level,
|
||||
const char* format,
|
||||
...);
|
||||
WIN_EXPORT void YGAssert(const bool condition, const char* message);
|
||||
WIN_EXPORT void YGAssertWithNode(
|
||||
const YGNodeRef node,
|
||||
const bool condition,
|
||||
const char* message);
|
||||
WIN_EXPORT void YGAssertWithConfig(
|
||||
const YGConfigRef config,
|
||||
const bool condition,
|
||||
const char* message);
|
||||
// Set this to number of pixels in 1 point to round calculation results
|
||||
// If you want to avoid rounding - set PointScaleFactor to 0
|
||||
WIN_EXPORT void YGConfigSetPointScaleFactor(const YGConfigRef config, const float pixelsInPoint);
|
||||
WIN_EXPORT void YGConfigSetPointScaleFactor(
|
||||
const YGConfigRef config,
|
||||
const float pixelsInPoint);
|
||||
void YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(
|
||||
const YGConfigRef config,
|
||||
const bool shouldDiffLayout);
|
||||
|
||||
// Yoga previously had an error where containers would take the maximum space possible instead of
|
||||
// the minimum
|
||||
// like they are supposed to. In practice this resulted in implicit behaviour similar to align-self:
|
||||
// stretch;
|
||||
// Because this was such a long-standing bug we must allow legacy users to switch back to this
|
||||
// behaviour.
|
||||
WIN_EXPORT void YGConfigSetUseLegacyStretchBehaviour(const YGConfigRef config,
|
||||
const bool useLegacyStretchBehaviour);
|
||||
// Yoga previously had an error where containers would take the maximum space
|
||||
// possible instead of the minimum like they are supposed to. In practice this
|
||||
// resulted in implicit behaviour similar to align-self: stretch; Because this
|
||||
// was such a long-standing bug we must allow legacy users to switch back to
|
||||
// this behaviour.
|
||||
WIN_EXPORT void YGConfigSetUseLegacyStretchBehaviour(
|
||||
const YGConfigRef config,
|
||||
const bool useLegacyStretchBehaviour);
|
||||
|
||||
// YGConfig
|
||||
WIN_EXPORT YGConfigRef YGConfigNew(void);
|
||||
@ -285,25 +311,30 @@ WIN_EXPORT void YGConfigFree(const YGConfigRef config);
|
||||
WIN_EXPORT void YGConfigCopy(const YGConfigRef dest, const YGConfigRef src);
|
||||
WIN_EXPORT int32_t YGConfigGetInstanceCount(void);
|
||||
|
||||
WIN_EXPORT void YGConfigSetExperimentalFeatureEnabled(const YGConfigRef config,
|
||||
const YGExperimentalFeature feature,
|
||||
const bool enabled);
|
||||
WIN_EXPORT bool YGConfigIsExperimentalFeatureEnabled(const YGConfigRef config,
|
||||
const YGExperimentalFeature feature);
|
||||
WIN_EXPORT void YGConfigSetExperimentalFeatureEnabled(
|
||||
const YGConfigRef config,
|
||||
const YGExperimentalFeature feature,
|
||||
const bool enabled);
|
||||
WIN_EXPORT bool YGConfigIsExperimentalFeatureEnabled(
|
||||
const YGConfigRef config,
|
||||
const YGExperimentalFeature feature);
|
||||
|
||||
// Using the web defaults is the prefered configuration for new projects.
|
||||
// Usage of non web defaults should be considered as legacy.
|
||||
WIN_EXPORT void YGConfigSetUseWebDefaults(const YGConfigRef config, const bool enabled);
|
||||
WIN_EXPORT void YGConfigSetUseWebDefaults(
|
||||
const YGConfigRef config,
|
||||
const bool enabled);
|
||||
WIN_EXPORT bool YGConfigGetUseWebDefaults(const YGConfigRef config);
|
||||
|
||||
WIN_EXPORT void YGConfigSetCloneNodeFunc(const YGConfigRef config,
|
||||
const YGCloneNodeFunc callback);
|
||||
WIN_EXPORT void YGConfigSetCloneNodeFunc(
|
||||
const YGConfigRef config,
|
||||
const YGCloneNodeFunc callback);
|
||||
|
||||
// Export only for C#
|
||||
WIN_EXPORT YGConfigRef YGConfigGetDefault(void);
|
||||
|
||||
WIN_EXPORT void YGConfigSetContext(const YGConfigRef config, void *context);
|
||||
WIN_EXPORT void *YGConfigGetContext(const YGConfigRef config);
|
||||
WIN_EXPORT void YGConfigSetContext(const YGConfigRef config, void* context);
|
||||
WIN_EXPORT void* YGConfigGetContext(const YGConfigRef config);
|
||||
|
||||
WIN_EXPORT float YGRoundValueToPixelGrid(
|
||||
const float value,
|
||||
@ -319,7 +350,9 @@ YG_EXTERN_C_END
|
||||
#include <vector>
|
||||
|
||||
// Calls f on each node in the tree including the given node argument.
|
||||
extern void YGTraversePreOrder(YGNodeRef const node, std::function<void(YGNodeRef node)>&& f);
|
||||
extern void YGTraversePreOrder(
|
||||
YGNodeRef const node,
|
||||
std::function<void(YGNodeRef node)>&& f);
|
||||
|
||||
extern void YGNodeSetChildren(
|
||||
YGNodeRef const owner,
|
||||
|
Loading…
x
Reference in New Issue
Block a user