2 * Copyright (c) 2014-present, Facebook, Inc.
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
15 using YGVector = std::vector<YGNodeRef>;
19 WIN_EXPORT float YGRoundValueToPixelGrid(const float value,
20 const float pointScaleFactor,
22 const bool forceFloor);
26 extern const std::array<YGEdge, 4> trailing;
27 extern const std::array<YGEdge, 4> leading;
28 extern bool YGValueEqual(const YGValue a, const YGValue b);
29 extern const YGValue YGValueUndefined;
30 extern const YGValue YGValueAuto;
31 extern const YGValue YGValueZero;
33 template <std::size_t size>
34 bool YGValueArrayEqual(
35 const std::array<YGValue, size> val1,
36 const std::array<YGValue, size> val2) {
38 for (uint32_t i = 0; i < size && areEqual; ++i) {
39 areEqual = YGValueEqual(val1[i], val2[i]);
44 struct YGCachedMeasurement {
46 float availableHeight;
47 YGMeasureMode widthMeasureMode;
48 YGMeasureMode heightMeasureMode;
56 widthMeasureMode((YGMeasureMode)-1),
57 heightMeasureMode((YGMeasureMode)-1),
61 bool operator==(const YGCachedMeasurement& measurement) const {
62 bool isEqual = widthMeasureMode == measurement.widthMeasureMode &&
63 heightMeasureMode == measurement.heightMeasureMode;
65 if (!YGFloatIsUndefined(availableWidth) ||
66 !YGFloatIsUndefined(measurement.availableWidth)) {
67 isEqual = isEqual && availableWidth == measurement.availableWidth;
69 if (!YGFloatIsUndefined(availableHeight) ||
70 !YGFloatIsUndefined(measurement.availableHeight)) {
71 isEqual = isEqual && availableHeight == measurement.availableHeight;
73 if (!YGFloatIsUndefined(computedWidth) ||
74 !YGFloatIsUndefined(measurement.computedWidth)) {
75 isEqual = isEqual && computedWidth == measurement.computedWidth;
77 if (!YGFloatIsUndefined(computedHeight) ||
78 !YGFloatIsUndefined(measurement.computedHeight)) {
79 isEqual = isEqual && computedHeight == measurement.computedHeight;
86 // This value was chosen based on empiracle data. Even the most complicated
87 // layouts should not require more than 16 entries to fit within the cache.
88 #define YG_MAX_CACHED_RESULT_COUNT 16
91 static const float kDefaultFlexGrow = 0.0f;
92 static const float kDefaultFlexShrink = 0.0f;
93 static const float kWebDefaultFlexShrink = 1.0f;
95 extern bool YGFloatsEqual(const float a, const float b);
96 extern bool YGValueEqual(const YGValue a, const YGValue b);
97 extern const YGValue* YGComputedEdgeValue(
98 const std::array<YGValue, YGEdgeCount>& edges,
100 const YGValue* const defaultValue);