Replaced default constructors with member assignments
Reviewed By: davidaurelio Differential Revision: D10466125 fbshipit-source-id: ed92d1e054a8b5b9a6c8c09035173b11da45c368
This commit is contained in:
committed by
Facebook Github Bot
parent
ba9bd4eae3
commit
fad2ee1a64
@@ -7,16 +7,4 @@
|
|||||||
*/
|
*/
|
||||||
#include "YGConfig.h"
|
#include "YGConfig.h"
|
||||||
|
|
||||||
const std::array<bool, YGExperimentalFeatureCount>
|
YGConfig::YGConfig(YGLogger logger) : logger(logger) {}
|
||||||
kYGDefaultExperimentalFeatures = {{false}};
|
|
||||||
|
|
||||||
YGConfig::YGConfig(YGLogger logger)
|
|
||||||
: experimentalFeatures(kYGDefaultExperimentalFeatures),
|
|
||||||
useWebDefaults(false),
|
|
||||||
useLegacyStretchBehaviour(false),
|
|
||||||
shouldDiffLayoutWithoutLegacyStretchBehaviour(false),
|
|
||||||
pointScaleFactor(1.0f),
|
|
||||||
logger(logger),
|
|
||||||
cloneNodeCallback(nullptr),
|
|
||||||
context(nullptr),
|
|
||||||
printTree(false) {}
|
|
||||||
|
@@ -10,15 +10,15 @@
|
|||||||
#include "Yoga.h"
|
#include "Yoga.h"
|
||||||
|
|
||||||
struct YGConfig {
|
struct YGConfig {
|
||||||
std::array<bool, YGExperimentalFeatureCount> experimentalFeatures;
|
std::array<bool, YGExperimentalFeatureCount> experimentalFeatures = {};
|
||||||
bool useWebDefaults;
|
bool useWebDefaults = false;
|
||||||
bool useLegacyStretchBehaviour;
|
bool useLegacyStretchBehaviour = false;
|
||||||
bool shouldDiffLayoutWithoutLegacyStretchBehaviour;
|
bool shouldDiffLayoutWithoutLegacyStretchBehaviour = false;
|
||||||
float pointScaleFactor;
|
float pointScaleFactor = 1.0f;
|
||||||
YGLogger logger;
|
YGLogger logger;
|
||||||
YGCloneNodeFunc cloneNodeCallback;
|
YGCloneNodeFunc cloneNodeCallback = nullptr;
|
||||||
void* context;
|
void* context = nullptr;
|
||||||
bool printTree;
|
bool printTree = false;
|
||||||
|
|
||||||
YGConfig(YGLogger logger);
|
YGConfig(YGLogger logger);
|
||||||
};
|
};
|
||||||
|
@@ -9,12 +9,12 @@
|
|||||||
|
|
||||||
struct YGFloatOptional {
|
struct YGFloatOptional {
|
||||||
private:
|
private:
|
||||||
float value_;
|
float value_ = 0;
|
||||||
bool isUndefined_;
|
bool isUndefined_ = true;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit YGFloatOptional(float value);
|
explicit YGFloatOptional(float value);
|
||||||
explicit YGFloatOptional() : value_(0), isUndefined_(true) {}
|
YGFloatOptional() = default;
|
||||||
|
|
||||||
// Program will terminate if the value of an undefined is accessed. Please
|
// Program will terminate if the value of an undefined is accessed. Please
|
||||||
// make sure to check if the optional is defined before calling this function.
|
// make sure to check if the optional is defined before calling this function.
|
||||||
|
@@ -10,28 +10,6 @@
|
|||||||
|
|
||||||
using namespace facebook;
|
using namespace facebook;
|
||||||
|
|
||||||
const std::array<float, 2> kYGDefaultDimensionValues = {
|
|
||||||
{YGUndefined, YGUndefined}};
|
|
||||||
|
|
||||||
YGLayout::YGLayout()
|
|
||||||
: position(),
|
|
||||||
dimensions(kYGDefaultDimensionValues),
|
|
||||||
margin(),
|
|
||||||
border(),
|
|
||||||
padding(),
|
|
||||||
direction(YGDirectionInherit),
|
|
||||||
computedFlexBasisGeneration(0),
|
|
||||||
computedFlexBasis(YGFloatOptional()),
|
|
||||||
hadOverflow(false),
|
|
||||||
generationCount(0),
|
|
||||||
lastOwnerDirection((YGDirection)-1),
|
|
||||||
nextCachedMeasurementsIndex(0),
|
|
||||||
cachedMeasurements(),
|
|
||||||
measuredDimensions(kYGDefaultDimensionValues),
|
|
||||||
cachedLayout(YGCachedMeasurement()),
|
|
||||||
didUseLegacyFlag(false),
|
|
||||||
doesLegacyStretchFlagAffectsLayout(false) {}
|
|
||||||
|
|
||||||
bool YGLayout::operator==(YGLayout layout) const {
|
bool YGLayout::operator==(YGLayout layout) const {
|
||||||
bool isEqual = YGFloatArrayEqual(position, layout.position) &&
|
bool isEqual = YGFloatArrayEqual(position, layout.position) &&
|
||||||
YGFloatArrayEqual(dimensions, layout.dimensions) &&
|
YGFloatArrayEqual(dimensions, layout.dimensions) &&
|
||||||
|
@@ -9,33 +9,36 @@
|
|||||||
#include "YGFloatOptional.h"
|
#include "YGFloatOptional.h"
|
||||||
#include "Yoga-internal.h"
|
#include "Yoga-internal.h"
|
||||||
|
|
||||||
struct YGLayout {
|
constexpr std::array<float, 2> kYGDefaultDimensionValues = {
|
||||||
std::array<float, 4> position;
|
{YGUndefined, YGUndefined}};
|
||||||
std::array<float, 2> dimensions;
|
|
||||||
std::array<float, 6> margin;
|
|
||||||
std::array<float, 6> border;
|
|
||||||
std::array<float, 6> padding;
|
|
||||||
YGDirection direction;
|
|
||||||
|
|
||||||
uint32_t computedFlexBasisGeneration;
|
struct YGLayout {
|
||||||
YGFloatOptional computedFlexBasis;
|
std::array<float, 4> position = {};
|
||||||
bool hadOverflow;
|
std::array<float, 2> dimensions = kYGDefaultDimensionValues;
|
||||||
|
std::array<float, 6> margin = {};
|
||||||
|
std::array<float, 6> border = {};
|
||||||
|
std::array<float, 6> padding = {};
|
||||||
|
YGDirection direction = YGDirectionInherit;
|
||||||
|
|
||||||
|
uint32_t computedFlexBasisGeneration = 0;
|
||||||
|
YGFloatOptional computedFlexBasis = {};
|
||||||
|
bool hadOverflow = false;
|
||||||
|
|
||||||
// Instead of recomputing the entire layout every single time, we
|
// Instead of recomputing the entire layout every single time, we
|
||||||
// cache some information to break early when nothing changed
|
// cache some information to break early when nothing changed
|
||||||
uint32_t generationCount;
|
uint32_t generationCount = 0;
|
||||||
YGDirection lastOwnerDirection;
|
YGDirection lastOwnerDirection = (YGDirection)-1;
|
||||||
|
|
||||||
uint32_t nextCachedMeasurementsIndex;
|
uint32_t nextCachedMeasurementsIndex = 0;
|
||||||
std::array<YGCachedMeasurement, YG_MAX_CACHED_RESULT_COUNT>
|
std::array<YGCachedMeasurement, YG_MAX_CACHED_RESULT_COUNT>
|
||||||
cachedMeasurements;
|
cachedMeasurements = {};
|
||||||
std::array<float, 2> measuredDimensions;
|
std::array<float, 2> measuredDimensions = kYGDefaultDimensionValues;
|
||||||
|
|
||||||
YGCachedMeasurement cachedLayout;
|
YGCachedMeasurement cachedLayout = YGCachedMeasurement();
|
||||||
bool didUseLegacyFlag;
|
bool didUseLegacyFlag = false;
|
||||||
bool doesLegacyStretchFlagAffectsLayout;
|
bool doesLegacyStretchFlagAffectsLayout = false;
|
||||||
|
|
||||||
YGLayout();
|
YGLayout() = default;
|
||||||
|
|
||||||
bool operator==(YGLayout layout) const;
|
bool operator==(YGLayout layout) const;
|
||||||
bool operator!=(YGLayout layout) const {
|
bool operator!=(YGLayout layout) const {
|
||||||
|
@@ -7,51 +7,6 @@
|
|||||||
*/
|
*/
|
||||||
#include "YGStyle.h"
|
#include "YGStyle.h"
|
||||||
|
|
||||||
const YGValue kYGValueUndefined = {0, YGUnitUndefined};
|
|
||||||
|
|
||||||
const YGValue kYGValueAuto = {0, YGUnitAuto};
|
|
||||||
|
|
||||||
const std::array<YGValue, YGEdgeCount> kYGDefaultEdgeValuesUnit = {
|
|
||||||
{kYGValueUndefined,
|
|
||||||
kYGValueUndefined,
|
|
||||||
kYGValueUndefined,
|
|
||||||
kYGValueUndefined,
|
|
||||||
kYGValueUndefined,
|
|
||||||
kYGValueUndefined,
|
|
||||||
kYGValueUndefined,
|
|
||||||
kYGValueUndefined,
|
|
||||||
kYGValueUndefined}};
|
|
||||||
|
|
||||||
const std::array<YGValue, 2> kYGDefaultDimensionValuesAutoUnit = {
|
|
||||||
{kYGValueAuto, kYGValueAuto}};
|
|
||||||
|
|
||||||
const std::array<YGValue, 2> kYGDefaultDimensionValuesUnit = {
|
|
||||||
{kYGValueUndefined, kYGValueUndefined}};
|
|
||||||
|
|
||||||
YGStyle::YGStyle()
|
|
||||||
: direction(YGDirectionInherit),
|
|
||||||
flexDirection(YGFlexDirectionColumn),
|
|
||||||
justifyContent(YGJustifyFlexStart),
|
|
||||||
alignContent(YGAlignFlexStart),
|
|
||||||
alignItems(YGAlignStretch),
|
|
||||||
alignSelf(YGAlignAuto),
|
|
||||||
positionType(YGPositionTypeRelative),
|
|
||||||
flexWrap(YGWrapNoWrap),
|
|
||||||
overflow(YGOverflowVisible),
|
|
||||||
display(YGDisplayFlex),
|
|
||||||
flex(YGFloatOptional()),
|
|
||||||
flexGrow(YGFloatOptional()),
|
|
||||||
flexShrink(YGFloatOptional()),
|
|
||||||
flexBasis(kYGValueAuto),
|
|
||||||
margin(kYGDefaultEdgeValuesUnit),
|
|
||||||
position(kYGDefaultEdgeValuesUnit),
|
|
||||||
padding(kYGDefaultEdgeValuesUnit),
|
|
||||||
border(kYGDefaultEdgeValuesUnit),
|
|
||||||
dimensions(kYGDefaultDimensionValuesAutoUnit),
|
|
||||||
minDimensions(kYGDefaultDimensionValuesUnit),
|
|
||||||
maxDimensions(kYGDefaultDimensionValuesUnit),
|
|
||||||
aspectRatio(YGFloatOptional()) {}
|
|
||||||
|
|
||||||
// Yoga specific properties, not compatible with flexbox specification
|
// Yoga specific properties, not compatible with flexbox specification
|
||||||
bool YGStyle::operator==(const YGStyle& style) {
|
bool YGStyle::operator==(const YGStyle& style) {
|
||||||
bool areNonFloatValuesEqual = direction == style.direction &&
|
bool areNonFloatValuesEqual = direction == style.direction &&
|
||||||
|
@@ -10,34 +10,52 @@
|
|||||||
#include "Yoga-internal.h"
|
#include "Yoga-internal.h"
|
||||||
#include "Yoga.h"
|
#include "Yoga.h"
|
||||||
|
|
||||||
|
constexpr YGValue kYGValueUndefined = {0, YGUnitUndefined};
|
||||||
|
|
||||||
|
constexpr YGValue kYGValueAuto = {0, YGUnitAuto};
|
||||||
|
|
||||||
|
constexpr std::array<YGValue, YGEdgeCount> kYGDefaultEdgeValuesUnit = {
|
||||||
|
{kYGValueUndefined,
|
||||||
|
kYGValueUndefined,
|
||||||
|
kYGValueUndefined,
|
||||||
|
kYGValueUndefined,
|
||||||
|
kYGValueUndefined,
|
||||||
|
kYGValueUndefined,
|
||||||
|
kYGValueUndefined,
|
||||||
|
kYGValueUndefined,
|
||||||
|
kYGValueUndefined}};
|
||||||
|
|
||||||
|
constexpr std::array<YGValue, 2> kYGDefaultDimensionValuesUnit = {
|
||||||
|
{kYGValueUndefined, kYGValueUndefined}};
|
||||||
|
|
||||||
struct YGStyle {
|
struct YGStyle {
|
||||||
using Dimensions = std::array<YGValue, 2>;
|
using Dimensions = std::array<YGValue, 2>;
|
||||||
|
|
||||||
YGDirection direction;
|
YGDirection direction = YGDirectionInherit;
|
||||||
YGFlexDirection flexDirection;
|
YGFlexDirection flexDirection = YGFlexDirectionColumn;
|
||||||
YGJustify justifyContent;
|
YGJustify justifyContent = YGJustifyFlexStart;
|
||||||
YGAlign alignContent;
|
YGAlign alignContent = YGAlignFlexStart;
|
||||||
YGAlign alignItems;
|
YGAlign alignItems = YGAlignStretch;
|
||||||
YGAlign alignSelf;
|
YGAlign alignSelf = YGAlignAuto;
|
||||||
YGPositionType positionType;
|
YGPositionType positionType = YGPositionTypeRelative;
|
||||||
YGWrap flexWrap;
|
YGWrap flexWrap = YGWrapNoWrap;
|
||||||
YGOverflow overflow;
|
YGOverflow overflow = YGOverflowVisible;
|
||||||
YGDisplay display;
|
YGDisplay display = YGDisplayFlex;
|
||||||
YGFloatOptional flex;
|
YGFloatOptional flex = {};
|
||||||
YGFloatOptional flexGrow;
|
YGFloatOptional flexGrow = {};
|
||||||
YGFloatOptional flexShrink;
|
YGFloatOptional flexShrink = {};
|
||||||
YGValue flexBasis;
|
YGValue flexBasis = kYGValueAuto;
|
||||||
std::array<YGValue, YGEdgeCount> margin;
|
std::array<YGValue, YGEdgeCount> margin = kYGDefaultEdgeValuesUnit;
|
||||||
std::array<YGValue, YGEdgeCount> position;
|
std::array<YGValue, YGEdgeCount> position = kYGDefaultEdgeValuesUnit;
|
||||||
std::array<YGValue, YGEdgeCount> padding;
|
std::array<YGValue, YGEdgeCount> padding = kYGDefaultEdgeValuesUnit;
|
||||||
std::array<YGValue, YGEdgeCount> border;
|
std::array<YGValue, YGEdgeCount> border = kYGDefaultEdgeValuesUnit;
|
||||||
Dimensions dimensions;
|
Dimensions dimensions = {{kYGValueAuto, kYGValueAuto}};
|
||||||
Dimensions minDimensions;
|
Dimensions minDimensions = kYGDefaultDimensionValuesUnit;
|
||||||
Dimensions maxDimensions;
|
Dimensions maxDimensions = kYGDefaultDimensionValuesUnit;
|
||||||
// Yoga specific properties, not compatible with flexbox specification
|
// Yoga specific properties, not compatible with flexbox specification
|
||||||
YGFloatOptional aspectRatio;
|
YGFloatOptional aspectRatio = {};
|
||||||
|
|
||||||
YGStyle();
|
YGStyle() = default;
|
||||||
bool operator==(const YGStyle& style);
|
bool operator==(const YGStyle& style);
|
||||||
|
|
||||||
bool operator!=(YGStyle style) {
|
bool operator!=(YGStyle style) {
|
||||||
|
Reference in New Issue
Block a user