Encapsulate arrays of YGValue within YGStyle

Summary:
@public

Enforce more encapsulation of arrays of `YGValue` in `YGSty;e`.
This will allow us to use `CompactValue` in `YGStyle` while (mostly) retaining API compatibility.

Reviewed By: SidharthGuglani

Differential Revision: D13452042

fbshipit-source-id: 382b1c7245c4bea4280126ab1413e7e931b62eaa
This commit is contained in:
David Aurelio
2018-12-14 09:20:27 -08:00
committed by Facebook Github Bot
parent 8bc89651d6
commit 3df41aefdb
4 changed files with 83 additions and 48 deletions

View File

@@ -5,6 +5,9 @@
* file in the root directory of this source tree.
*/
#pragma once
#include <algorithm>
#include <array>
#include <initializer_list>
#include "YGFloatOptional.h"
#include "Yoga-internal.h"
#include "Yoga.h"
@@ -13,22 +16,9 @@ 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 {
using Dimensions = std::array<YGValue, 2>;
using Dimensions = facebook::yoga::detail::Values<2>;
using Edges = facebook::yoga::detail::Values<YGEdgeCount>;
YGDirection direction : 2;
YGFlexDirection flexDirection : 2;
@@ -44,13 +34,13 @@ struct YGStyle {
YGFloatOptional flexGrow = {};
YGFloatOptional flexShrink = {};
YGValue flexBasis = kYGValueAuto;
std::array<YGValue, YGEdgeCount> margin = kYGDefaultEdgeValuesUnit;
std::array<YGValue, YGEdgeCount> position = kYGDefaultEdgeValuesUnit;
std::array<YGValue, YGEdgeCount> padding = kYGDefaultEdgeValuesUnit;
std::array<YGValue, YGEdgeCount> border = kYGDefaultEdgeValuesUnit;
Dimensions dimensions = {{kYGValueAuto, kYGValueAuto}};
Dimensions minDimensions = kYGDefaultDimensionValuesUnit;
Dimensions maxDimensions = kYGDefaultDimensionValuesUnit;
Edges margin{kYGValueUndefined};
Edges position{kYGValueUndefined};
Edges padding{kYGValueUndefined};
Edges border{kYGValueUndefined};
Dimensions dimensions{kYGValueAuto};
Dimensions minDimensions{kYGValueUndefined};
Dimensions maxDimensions{kYGValueUndefined};
// Yoga specific properties, not compatible with flexbox specification
YGFloatOptional aspectRatio = {};