C++ style enums 7/N: MeasureMode #1389
@@ -1 +0,0 @@
|
|||||||
^lib/.*
|
|
50
enums.py
50
enums.py
@@ -4,6 +4,7 @@
|
|||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
|
import math
|
||||||
import os
|
import os
|
||||||
|
|
||||||
ENUMS = {
|
ENUMS = {
|
||||||
@@ -88,7 +89,7 @@ def get_license(ext):
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// @{"generated"} by enums.py
|
// @{"generated"} by enums.py
|
||||||
|
{"// clang-format off" if ext == "cpp" else ""}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
@@ -121,7 +122,6 @@ with open(root + "/yoga/YGEnums.h", "w") as f:
|
|||||||
f.write(get_license("cpp"))
|
f.write(get_license("cpp"))
|
||||||
f.write("#pragma once\n")
|
f.write("#pragma once\n")
|
||||||
f.write("#include <yoga/YGMacros.h>\n\n")
|
f.write("#include <yoga/YGMacros.h>\n\n")
|
||||||
f.write("// clang-format off\n\n\n")
|
|
||||||
|
|
||||||
f.write("YG_EXTERN_C_BEGIN\n\n")
|
f.write("YG_EXTERN_C_BEGIN\n\n")
|
||||||
items = sorted(ENUMS.items())
|
items = sorted(ENUMS.items())
|
||||||
@@ -146,6 +146,52 @@ with open(root + "/yoga/YGEnums.h", "w") as f:
|
|||||||
f.write("\n")
|
f.write("\n")
|
||||||
f.write("YG_EXTERN_C_END\n")
|
f.write("YG_EXTERN_C_END\n")
|
||||||
|
|
||||||
|
# Write out C++ scoped enums
|
||||||
|
for name, values in sorted(ENUMS.items()):
|
||||||
|
with open(f"{root}/yoga/enums/{name}.h", "w") as f:
|
||||||
|
f.write(get_license("cpp"))
|
||||||
|
f.write("#pragma once\n\n")
|
||||||
|
|
||||||
|
f.write("#include <cstdint>\n")
|
||||||
|
f.write("#include <yoga/YGEnums.h>\n")
|
||||||
|
f.write("#include <yoga/enums/YogaEnums.h>\n\n")
|
||||||
|
|
||||||
|
f.write("namespace facebook::yoga {\n\n")
|
||||||
|
|
||||||
|
width = "uint32_t" if name in BITSET_ENUMS else "uint8_t"
|
||||||
|
f.write(f"enum class {name} : {width} {{\n")
|
||||||
|
for value in values:
|
||||||
|
ordinal = value[0] if isinstance(value, tuple) else value
|
||||||
|
f.write(f" {ordinal} = YG{name}{ordinal},\n")
|
||||||
|
f.write("};\n\n")
|
||||||
|
f.write(
|
||||||
|
f"YG_DEFINE_ENUM_FLAG_OPERATORS({name})\n\n" if name in BITSET_ENUMS else ""
|
||||||
|
)
|
||||||
|
|
||||||
|
f.write("template <>\n")
|
||||||
|
f.write(f"constexpr inline int32_t ordinalCount<{name}>() {{\n")
|
||||||
|
f.write(f" return {len(values)};\n")
|
||||||
|
f.write("} \n\n")
|
||||||
|
|
||||||
|
f.write("template <>\n")
|
||||||
|
f.write(f"constexpr inline int32_t bitCount<{name}>() {{\n")
|
||||||
|
f.write(f" return {math.ceil(math.log(len(values), 2))};\n")
|
||||||
|
f.write("} \n\n")
|
||||||
|
|
||||||
|
f.write(f"constexpr inline {name} scopedEnum(YG{name} unscoped) {{\n")
|
||||||
|
f.write(f" return static_cast<{name}>(unscoped);\n")
|
||||||
|
f.write("}\n\n")
|
||||||
|
|
||||||
|
f.write(f"constexpr inline YG{name} unscopedEnum({name} scoped) {{\n")
|
||||||
|
f.write(f" return static_cast<YG{name}>(scoped);\n")
|
||||||
|
f.write("}\n\n")
|
||||||
|
|
||||||
|
f.write(f"inline const char* toString({name} e) {{\n")
|
||||||
|
f.write(f" return YG{name}ToString(unscopedEnum(e));\n")
|
||||||
|
f.write("}\n\n")
|
||||||
|
|
||||||
|
f.write("} // namespace facebook::yoga\n")
|
||||||
|
|
||||||
# write out C body for printing
|
# write out C body for printing
|
||||||
with open(root + "/yoga/YGEnums.cpp", "w") as f:
|
with open(root + "/yoga/YGEnums.cpp", "w") as f:
|
||||||
f.write(get_license("cpp"))
|
f.write(get_license("cpp"))
|
||||||
|
@@ -38,7 +38,7 @@ TEST(Node, measure_with_measure_fn) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
ASSERT_EQ(
|
ASSERT_EQ(
|
||||||
n.measure(23, YGMeasureModeExactly, 24, YGMeasureModeAtMost),
|
n.measure(23, MeasureMode::Exactly, 24, MeasureMode::AtMost),
|
||||||
(YGSize{23, 12}));
|
(YGSize{23, 12}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// @generated by enums.py
|
// @generated by enums.py
|
||||||
|
// clang-format off
|
||||||
#include <yoga/YGEnums.h>
|
#include <yoga/YGEnums.h>
|
||||||
|
|
||||||
const char* YGAlignToString(const YGAlign value) {
|
const char* YGAlignToString(const YGAlign value) {
|
||||||
|
@@ -6,13 +6,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// @generated by enums.py
|
// @generated by enums.py
|
||||||
|
// clang-format off
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <yoga/YGMacros.h>
|
#include <yoga/YGMacros.h>
|
||||||
|
|
||||||
// clang-format off
|
|
||||||
|
|
||||||
|
|
||||||
YG_EXTERN_C_BEGIN
|
YG_EXTERN_C_BEGIN
|
||||||
|
|
||||||
YG_ENUM_SEQ_DECL(
|
YG_ENUM_SEQ_DECL(
|
||||||
|
@@ -81,11 +81,11 @@ void YGNodeSetHasNewLayout(YGNodeRef node, bool hasNewLayout) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
YGNodeType YGNodeGetNodeType(YGNodeConstRef node) {
|
YGNodeType YGNodeGetNodeType(YGNodeConstRef node) {
|
||||||
return resolveRef(node)->getNodeType();
|
return unscopedEnum(resolveRef(node)->getNodeType());
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeSetNodeType(YGNodeRef node, YGNodeType nodeType) {
|
void YGNodeSetNodeType(YGNodeRef node, YGNodeType nodeType) {
|
||||||
return resolveRef(node)->setNodeType(nodeType);
|
return resolveRef(node)->setNodeType(scopedEnum(nodeType));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool YGNodeIsDirty(YGNodeConstRef node) {
|
bool YGNodeIsDirty(YGNodeConstRef node) {
|
||||||
@@ -801,11 +801,8 @@ YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(float, Border, border)
|
|||||||
YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(float, Padding, padding)
|
YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(float, Padding, padding)
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
void YGNodePrint(const YGNodeConstRef nodeRef, const YGPrintOptions options) {
|
void YGNodePrint(const YGNodeConstRef node, const YGPrintOptions options) {
|
||||||
const auto node = resolveRef(nodeRef);
|
yoga::print(resolveRef(node), scopedEnum(options));
|
||||||
std::string str;
|
|
||||||
yoga::nodeToString(str, node, options, 0);
|
|
||||||
yoga::log(node, YGLogLevelDebug, str.c_str());
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -851,13 +848,14 @@ void YGConfigSetExperimentalFeatureEnabled(
|
|||||||
const YGConfigRef config,
|
const YGConfigRef config,
|
||||||
const YGExperimentalFeature feature,
|
const YGExperimentalFeature feature,
|
||||||
const bool enabled) {
|
const bool enabled) {
|
||||||
resolveRef(config)->setExperimentalFeatureEnabled(feature, enabled);
|
resolveRef(config)->setExperimentalFeatureEnabled(
|
||||||
|
scopedEnum(feature), enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool YGConfigIsExperimentalFeatureEnabled(
|
bool YGConfigIsExperimentalFeatureEnabled(
|
||||||
const YGConfigConstRef config,
|
const YGConfigConstRef config,
|
||||||
const YGExperimentalFeature feature) {
|
const YGExperimentalFeature feature) {
|
||||||
return resolveRef(config)->isExperimentalFeatureEnabled(feature);
|
return resolveRef(config)->isExperimentalFeatureEnabled(scopedEnum(feature));
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGConfigSetUseWebDefaults(const YGConfigRef config, const bool enabled) {
|
void YGConfigSetUseWebDefaults(const YGConfigRef config, const bool enabled) {
|
||||||
@@ -877,11 +875,11 @@ void* YGConfigGetContext(const YGConfigConstRef config) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void YGConfigSetErrata(YGConfigRef config, YGErrata errata) {
|
void YGConfigSetErrata(YGConfigRef config, YGErrata errata) {
|
||||||
resolveRef(config)->setErrata(errata);
|
resolveRef(config)->setErrata(scopedEnum(errata));
|
||||||
}
|
}
|
||||||
|
|
||||||
YGErrata YGConfigGetErrata(YGConfigConstRef config) {
|
YGErrata YGConfigGetErrata(YGConfigConstRef config) {
|
||||||
return resolveRef(config)->getErrata();
|
return unscopedEnum(resolveRef(config)->getErrata());
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGConfigSetCloneNodeFunc(
|
void YGConfigSetCloneNodeFunc(
|
||||||
@@ -907,13 +905,13 @@ bool YGNodeCanUseCachedMeasurement(
|
|||||||
float marginColumn,
|
float marginColumn,
|
||||||
YGConfigRef config) {
|
YGConfigRef config) {
|
||||||
return yoga::canUseCachedMeasurement(
|
return yoga::canUseCachedMeasurement(
|
||||||
widthMode,
|
scopedEnum(widthMode),
|
||||||
availableWidth,
|
availableWidth,
|
||||||
heightMode,
|
scopedEnum(heightMode),
|
||||||
availableHeight,
|
availableHeight,
|
||||||
lastWidthMode,
|
scopedEnum(lastWidthMode),
|
||||||
lastAvailableWidth,
|
lastAvailableWidth,
|
||||||
lastHeightMode,
|
scopedEnum(lastHeightMode),
|
||||||
lastAvailableHeight,
|
lastAvailableHeight,
|
||||||
lastComputedWidth,
|
lastComputedWidth,
|
||||||
lastComputedHeight,
|
lastComputedHeight,
|
||||||
|
@@ -5,8 +5,6 @@
|
|||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <yoga/Yoga.h>
|
|
||||||
|
|
||||||
#include <yoga/algorithm/Cache.h>
|
#include <yoga/algorithm/Cache.h>
|
||||||
#include <yoga/algorithm/PixelGrid.h>
|
#include <yoga/algorithm/PixelGrid.h>
|
||||||
#include <yoga/numeric/Comparison.h>
|
#include <yoga/numeric/Comparison.h>
|
||||||
@@ -14,43 +12,43 @@
|
|||||||
namespace facebook::yoga {
|
namespace facebook::yoga {
|
||||||
|
|
||||||
static inline bool sizeIsExactAndMatchesOldMeasuredSize(
|
static inline bool sizeIsExactAndMatchesOldMeasuredSize(
|
||||||
YGMeasureMode sizeMode,
|
MeasureMode sizeMode,
|
||||||
float size,
|
float size,
|
||||||
float lastComputedSize) {
|
float lastComputedSize) {
|
||||||
return sizeMode == YGMeasureModeExactly &&
|
return sizeMode == MeasureMode::Exactly &&
|
||||||
yoga::inexactEquals(size, lastComputedSize);
|
yoga::inexactEquals(size, lastComputedSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool oldSizeIsUnspecifiedAndStillFits(
|
static inline bool oldSizeIsUnspecifiedAndStillFits(
|
||||||
YGMeasureMode sizeMode,
|
MeasureMode sizeMode,
|
||||||
float size,
|
float size,
|
||||||
YGMeasureMode lastSizeMode,
|
MeasureMode lastSizeMode,
|
||||||
float lastComputedSize) {
|
float lastComputedSize) {
|
||||||
return sizeMode == YGMeasureModeAtMost &&
|
return sizeMode == MeasureMode::AtMost &&
|
||||||
lastSizeMode == YGMeasureModeUndefined &&
|
lastSizeMode == MeasureMode::Undefined &&
|
||||||
(size >= lastComputedSize || yoga::inexactEquals(size, lastComputedSize));
|
(size >= lastComputedSize || yoga::inexactEquals(size, lastComputedSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool newMeasureSizeIsStricterAndStillValid(
|
static inline bool newMeasureSizeIsStricterAndStillValid(
|
||||||
YGMeasureMode sizeMode,
|
MeasureMode sizeMode,
|
||||||
float size,
|
float size,
|
||||||
YGMeasureMode lastSizeMode,
|
MeasureMode lastSizeMode,
|
||||||
float lastSize,
|
float lastSize,
|
||||||
float lastComputedSize) {
|
float lastComputedSize) {
|
||||||
return lastSizeMode == YGMeasureModeAtMost &&
|
return lastSizeMode == MeasureMode::AtMost &&
|
||||||
sizeMode == YGMeasureModeAtMost && !std::isnan(lastSize) &&
|
sizeMode == MeasureMode::AtMost && !std::isnan(lastSize) &&
|
||||||
!std::isnan(size) && !std::isnan(lastComputedSize) && lastSize > size &&
|
!std::isnan(size) && !std::isnan(lastComputedSize) && lastSize > size &&
|
||||||
(lastComputedSize <= size || yoga::inexactEquals(size, lastComputedSize));
|
(lastComputedSize <= size || yoga::inexactEquals(size, lastComputedSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool canUseCachedMeasurement(
|
bool canUseCachedMeasurement(
|
||||||
const YGMeasureMode widthMode,
|
const MeasureMode widthMode,
|
||||||
const float availableWidth,
|
const float availableWidth,
|
||||||
const YGMeasureMode heightMode,
|
const MeasureMode heightMode,
|
||||||
const float availableHeight,
|
const float availableHeight,
|
||||||
const YGMeasureMode lastWidthMode,
|
const MeasureMode lastWidthMode,
|
||||||
const float lastAvailableWidth,
|
const float lastAvailableWidth,
|
||||||
const YGMeasureMode lastHeightMode,
|
const MeasureMode lastHeightMode,
|
||||||
const float lastAvailableHeight,
|
const float lastAvailableHeight,
|
||||||
const float lastComputedWidth,
|
const float lastComputedWidth,
|
||||||
const float lastComputedHeight,
|
const float lastComputedHeight,
|
||||||
|
@@ -7,19 +7,19 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <yoga/Yoga.h>
|
|
||||||
#include <yoga/config/Config.h>
|
#include <yoga/config/Config.h>
|
||||||
|
#include <yoga/enums/MeasureMode.h>
|
||||||
|
|
||||||
namespace facebook::yoga {
|
namespace facebook::yoga {
|
||||||
|
|
||||||
bool canUseCachedMeasurement(
|
bool canUseCachedMeasurement(
|
||||||
YGMeasureMode widthMode,
|
MeasureMode widthMode,
|
||||||
float availableWidth,
|
float availableWidth,
|
||||||
YGMeasureMode heightMode,
|
MeasureMode heightMode,
|
||||||
float availableHeight,
|
float availableHeight,
|
||||||
YGMeasureMode lastWidthMode,
|
MeasureMode lastWidthMode,
|
||||||
float lastAvailableWidth,
|
float lastAvailableWidth,
|
||||||
YGMeasureMode lastHeightMode,
|
MeasureMode lastHeightMode,
|
||||||
float lastAvailableHeight,
|
float lastAvailableHeight,
|
||||||
float lastComputedWidth,
|
float lastComputedWidth,
|
||||||
float lastComputedHeight,
|
float lastComputedHeight,
|
||||||
|
@@ -24,6 +24,7 @@
|
|||||||
#include <yoga/algorithm/ResolveValue.h>
|
#include <yoga/algorithm/ResolveValue.h>
|
||||||
#include <yoga/debug/AssertFatal.h>
|
#include <yoga/debug/AssertFatal.h>
|
||||||
#include <yoga/debug/Log.h>
|
#include <yoga/debug/Log.h>
|
||||||
|
#include <yoga/debug/NodeToString.h>
|
||||||
#include <yoga/event/event.h>
|
#include <yoga/event/event.h>
|
||||||
#include <yoga/node/Node.h>
|
#include <yoga/node/Node.h>
|
||||||
#include <yoga/numeric/Comparison.h>
|
#include <yoga/numeric/Comparison.h>
|
||||||
@@ -38,8 +39,8 @@ bool calculateLayoutInternal(
|
|||||||
const float availableWidth,
|
const float availableWidth,
|
||||||
const float availableHeight,
|
const float availableHeight,
|
||||||
const YGDirection ownerDirection,
|
const YGDirection ownerDirection,
|
||||||
const YGMeasureMode widthMeasureMode,
|
const MeasureMode widthMeasureMode,
|
||||||
const YGMeasureMode heightMeasureMode,
|
const MeasureMode heightMeasureMode,
|
||||||
const float ownerWidth,
|
const float ownerWidth,
|
||||||
const float ownerHeight,
|
const float ownerHeight,
|
||||||
const bool performLayout,
|
const bool performLayout,
|
||||||
@@ -98,22 +99,22 @@ static void constrainMaxSizeForMode(
|
|||||||
const enum YGFlexDirection axis,
|
const enum YGFlexDirection axis,
|
||||||
const float ownerAxisSize,
|
const float ownerAxisSize,
|
||||||
const float ownerWidth,
|
const float ownerWidth,
|
||||||
YGMeasureMode* mode,
|
MeasureMode* mode,
|
||||||
float* size) {
|
float* size) {
|
||||||
const FloatOptional maxSize =
|
const FloatOptional maxSize =
|
||||||
yoga::resolveValue(
|
yoga::resolveValue(
|
||||||
node->getStyle().maxDimensions()[dimension(axis)], ownerAxisSize) +
|
node->getStyle().maxDimensions()[dimension(axis)], ownerAxisSize) +
|
||||||
FloatOptional(node->getMarginForAxis(axis, ownerWidth));
|
FloatOptional(node->getMarginForAxis(axis, ownerWidth));
|
||||||
switch (*mode) {
|
switch (*mode) {
|
||||||
case YGMeasureModeExactly:
|
case MeasureMode::Exactly:
|
||||||
case YGMeasureModeAtMost:
|
case MeasureMode::AtMost:
|
||||||
*size = (maxSize.isUndefined() || *size < maxSize.unwrap())
|
*size = (maxSize.isUndefined() || *size < maxSize.unwrap())
|
||||||
? *size
|
? *size
|
||||||
: maxSize.unwrap();
|
: maxSize.unwrap();
|
||||||
break;
|
break;
|
||||||
case YGMeasureModeUndefined:
|
case MeasureMode::Undefined:
|
||||||
if (!maxSize.isUndefined()) {
|
if (!maxSize.isUndefined()) {
|
||||||
*mode = YGMeasureModeAtMost;
|
*mode = MeasureMode::AtMost;
|
||||||
*size = maxSize.unwrap();
|
*size = maxSize.unwrap();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -124,11 +125,11 @@ static void computeFlexBasisForChild(
|
|||||||
const yoga::Node* const node,
|
const yoga::Node* const node,
|
||||||
yoga::Node* const child,
|
yoga::Node* const child,
|
||||||
const float width,
|
const float width,
|
||||||
const YGMeasureMode widthMode,
|
const MeasureMode widthMode,
|
||||||
const float height,
|
const float height,
|
||||||
const float ownerWidth,
|
const float ownerWidth,
|
||||||
const float ownerHeight,
|
const float ownerHeight,
|
||||||
const YGMeasureMode heightMode,
|
const MeasureMode heightMode,
|
||||||
const YGDirection direction,
|
const YGDirection direction,
|
||||||
LayoutData& layoutMarkerData,
|
LayoutData& layoutMarkerData,
|
||||||
const uint32_t depth,
|
const uint32_t depth,
|
||||||
@@ -141,8 +142,8 @@ static void computeFlexBasisForChild(
|
|||||||
|
|
||||||
float childWidth;
|
float childWidth;
|
||||||
float childHeight;
|
float childHeight;
|
||||||
YGMeasureMode childWidthMeasureMode;
|
MeasureMode childWidthMeasureMode;
|
||||||
YGMeasureMode childHeightMeasureMode;
|
MeasureMode childHeightMeasureMode;
|
||||||
|
|
||||||
const FloatOptional resolvedFlexBasis =
|
const FloatOptional resolvedFlexBasis =
|
||||||
yoga::resolveValue(child->resolveFlexBasisPtr(), mainAxisownerSize);
|
yoga::resolveValue(child->resolveFlexBasisPtr(), mainAxisownerSize);
|
||||||
@@ -154,7 +155,7 @@ static void computeFlexBasisForChild(
|
|||||||
if (!resolvedFlexBasis.isUndefined() && !yoga::isUndefined(mainAxisSize)) {
|
if (!resolvedFlexBasis.isUndefined() && !yoga::isUndefined(mainAxisSize)) {
|
||||||
if (child->getLayout().computedFlexBasis.isUndefined() ||
|
if (child->getLayout().computedFlexBasis.isUndefined() ||
|
||||||
(child->getConfig()->isExperimentalFeatureEnabled(
|
(child->getConfig()->isExperimentalFeatureEnabled(
|
||||||
YGExperimentalFeatureWebFlexBasis) &&
|
ExperimentalFeature::WebFlexBasis) &&
|
||||||
child->getLayout().computedFlexBasisGeneration != generationCount)) {
|
child->getLayout().computedFlexBasisGeneration != generationCount)) {
|
||||||
const FloatOptional paddingAndBorder =
|
const FloatOptional paddingAndBorder =
|
||||||
FloatOptional(paddingAndBorderForAxis(child, mainAxis, ownerWidth));
|
FloatOptional(paddingAndBorderForAxis(child, mainAxis, ownerWidth));
|
||||||
@@ -183,8 +184,8 @@ static void computeFlexBasisForChild(
|
|||||||
// basis).
|
// basis).
|
||||||
childWidth = YGUndefined;
|
childWidth = YGUndefined;
|
||||||
childHeight = YGUndefined;
|
childHeight = YGUndefined;
|
||||||
childWidthMeasureMode = YGMeasureModeUndefined;
|
childWidthMeasureMode = MeasureMode::Undefined;
|
||||||
childHeightMeasureMode = YGMeasureModeUndefined;
|
childHeightMeasureMode = MeasureMode::Undefined;
|
||||||
|
|
||||||
auto marginRow =
|
auto marginRow =
|
||||||
child->getMarginForAxis(YGFlexDirectionRow, ownerWidth).unwrap();
|
child->getMarginForAxis(YGFlexDirectionRow, ownerWidth).unwrap();
|
||||||
@@ -197,7 +198,7 @@ static void computeFlexBasisForChild(
|
|||||||
child->getResolvedDimensions()[YGDimensionWidth], ownerWidth)
|
child->getResolvedDimensions()[YGDimensionWidth], ownerWidth)
|
||||||
.unwrap() +
|
.unwrap() +
|
||||||
marginRow;
|
marginRow;
|
||||||
childWidthMeasureMode = YGMeasureModeExactly;
|
childWidthMeasureMode = MeasureMode::Exactly;
|
||||||
}
|
}
|
||||||
if (isColumnStyleDimDefined) {
|
if (isColumnStyleDimDefined) {
|
||||||
childHeight =
|
childHeight =
|
||||||
@@ -205,7 +206,7 @@ static void computeFlexBasisForChild(
|
|||||||
child->getResolvedDimensions()[YGDimensionHeight], ownerHeight)
|
child->getResolvedDimensions()[YGDimensionHeight], ownerHeight)
|
||||||
.unwrap() +
|
.unwrap() +
|
||||||
marginColumn;
|
marginColumn;
|
||||||
childHeightMeasureMode = YGMeasureModeExactly;
|
childHeightMeasureMode = MeasureMode::Exactly;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The W3C spec doesn't say anything about the 'overflow' property, but all
|
// The W3C spec doesn't say anything about the 'overflow' property, but all
|
||||||
@@ -214,7 +215,7 @@ static void computeFlexBasisForChild(
|
|||||||
node->getStyle().overflow() != YGOverflowScroll) {
|
node->getStyle().overflow() != YGOverflowScroll) {
|
||||||
if (yoga::isUndefined(childWidth) && !yoga::isUndefined(width)) {
|
if (yoga::isUndefined(childWidth) && !yoga::isUndefined(width)) {
|
||||||
childWidth = width;
|
childWidth = width;
|
||||||
childWidthMeasureMode = YGMeasureModeAtMost;
|
childWidthMeasureMode = MeasureMode::AtMost;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,21 +223,21 @@ static void computeFlexBasisForChild(
|
|||||||
node->getStyle().overflow() != YGOverflowScroll) {
|
node->getStyle().overflow() != YGOverflowScroll) {
|
||||||
if (yoga::isUndefined(childHeight) && !yoga::isUndefined(height)) {
|
if (yoga::isUndefined(childHeight) && !yoga::isUndefined(height)) {
|
||||||
childHeight = height;
|
childHeight = height;
|
||||||
childHeightMeasureMode = YGMeasureModeAtMost;
|
childHeightMeasureMode = MeasureMode::AtMost;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& childStyle = child->getStyle();
|
const auto& childStyle = child->getStyle();
|
||||||
if (!childStyle.aspectRatio().isUndefined()) {
|
if (!childStyle.aspectRatio().isUndefined()) {
|
||||||
if (!isMainAxisRow && childWidthMeasureMode == YGMeasureModeExactly) {
|
if (!isMainAxisRow && childWidthMeasureMode == MeasureMode::Exactly) {
|
||||||
childHeight = marginColumn +
|
childHeight = marginColumn +
|
||||||
(childWidth - marginRow) / childStyle.aspectRatio().unwrap();
|
(childWidth - marginRow) / childStyle.aspectRatio().unwrap();
|
||||||
childHeightMeasureMode = YGMeasureModeExactly;
|
childHeightMeasureMode = MeasureMode::Exactly;
|
||||||
} else if (
|
} else if (
|
||||||
isMainAxisRow && childHeightMeasureMode == YGMeasureModeExactly) {
|
isMainAxisRow && childHeightMeasureMode == MeasureMode::Exactly) {
|
||||||
childWidth = marginRow +
|
childWidth = marginRow +
|
||||||
(childHeight - marginColumn) * childStyle.aspectRatio().unwrap();
|
(childHeight - marginColumn) * childStyle.aspectRatio().unwrap();
|
||||||
childWidthMeasureMode = YGMeasureModeExactly;
|
childWidthMeasureMode = MeasureMode::Exactly;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,35 +245,35 @@ static void computeFlexBasisForChild(
|
|||||||
// the cross axis to be measured exactly with the available inner width
|
// the cross axis to be measured exactly with the available inner width
|
||||||
|
|
||||||
const bool hasExactWidth =
|
const bool hasExactWidth =
|
||||||
!yoga::isUndefined(width) && widthMode == YGMeasureModeExactly;
|
!yoga::isUndefined(width) && widthMode == MeasureMode::Exactly;
|
||||||
const bool childWidthStretch =
|
const bool childWidthStretch =
|
||||||
resolveChildAlignment(node, child) == YGAlignStretch &&
|
resolveChildAlignment(node, child) == YGAlignStretch &&
|
||||||
childWidthMeasureMode != YGMeasureModeExactly;
|
childWidthMeasureMode != MeasureMode::Exactly;
|
||||||
if (!isMainAxisRow && !isRowStyleDimDefined && hasExactWidth &&
|
if (!isMainAxisRow && !isRowStyleDimDefined && hasExactWidth &&
|
||||||
childWidthStretch) {
|
childWidthStretch) {
|
||||||
childWidth = width;
|
childWidth = width;
|
||||||
childWidthMeasureMode = YGMeasureModeExactly;
|
childWidthMeasureMode = MeasureMode::Exactly;
|
||||||
if (!childStyle.aspectRatio().isUndefined()) {
|
if (!childStyle.aspectRatio().isUndefined()) {
|
||||||
childHeight =
|
childHeight =
|
||||||
(childWidth - marginRow) / childStyle.aspectRatio().unwrap();
|
(childWidth - marginRow) / childStyle.aspectRatio().unwrap();
|
||||||
childHeightMeasureMode = YGMeasureModeExactly;
|
childHeightMeasureMode = MeasureMode::Exactly;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool hasExactHeight =
|
const bool hasExactHeight =
|
||||||
!yoga::isUndefined(height) && heightMode == YGMeasureModeExactly;
|
!yoga::isUndefined(height) && heightMode == MeasureMode::Exactly;
|
||||||
const bool childHeightStretch =
|
const bool childHeightStretch =
|
||||||
resolveChildAlignment(node, child) == YGAlignStretch &&
|
resolveChildAlignment(node, child) == YGAlignStretch &&
|
||||||
childHeightMeasureMode != YGMeasureModeExactly;
|
childHeightMeasureMode != MeasureMode::Exactly;
|
||||||
if (isMainAxisRow && !isColumnStyleDimDefined && hasExactHeight &&
|
if (isMainAxisRow && !isColumnStyleDimDefined && hasExactHeight &&
|
||||||
childHeightStretch) {
|
childHeightStretch) {
|
||||||
childHeight = height;
|
childHeight = height;
|
||||||
childHeightMeasureMode = YGMeasureModeExactly;
|
childHeightMeasureMode = MeasureMode::Exactly;
|
||||||
|
|
||||||
if (!childStyle.aspectRatio().isUndefined()) {
|
if (!childStyle.aspectRatio().isUndefined()) {
|
||||||
childWidth =
|
childWidth =
|
||||||
(childHeight - marginColumn) * childStyle.aspectRatio().unwrap();
|
(childHeight - marginColumn) * childStyle.aspectRatio().unwrap();
|
||||||
childWidthMeasureMode = YGMeasureModeExactly;
|
childWidthMeasureMode = MeasureMode::Exactly;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -318,7 +319,7 @@ static void layoutAbsoluteChild(
|
|||||||
const yoga::Node* const node,
|
const yoga::Node* const node,
|
||||||
yoga::Node* const child,
|
yoga::Node* const child,
|
||||||
const float width,
|
const float width,
|
||||||
const YGMeasureMode widthMode,
|
const MeasureMode widthMode,
|
||||||
const float height,
|
const float height,
|
||||||
const YGDirection direction,
|
const YGDirection direction,
|
||||||
LayoutData& layoutMarkerData,
|
LayoutData& layoutMarkerData,
|
||||||
@@ -331,8 +332,8 @@ static void layoutAbsoluteChild(
|
|||||||
|
|
||||||
float childWidth = YGUndefined;
|
float childWidth = YGUndefined;
|
||||||
float childHeight = YGUndefined;
|
float childHeight = YGUndefined;
|
||||||
YGMeasureMode childWidthMeasureMode = YGMeasureModeUndefined;
|
MeasureMode childWidthMeasureMode = MeasureMode::Undefined;
|
||||||
YGMeasureMode childHeightMeasureMode = YGMeasureModeUndefined;
|
MeasureMode childHeightMeasureMode = MeasureMode::Undefined;
|
||||||
|
|
||||||
auto marginRow = child->getMarginForAxis(YGFlexDirectionRow, width).unwrap();
|
auto marginRow = child->getMarginForAxis(YGFlexDirectionRow, width).unwrap();
|
||||||
auto marginColumn =
|
auto marginColumn =
|
||||||
@@ -399,21 +400,21 @@ static void layoutAbsoluteChild(
|
|||||||
// If we're still missing one or the other dimension, measure the content.
|
// If we're still missing one or the other dimension, measure the content.
|
||||||
if (yoga::isUndefined(childWidth) || yoga::isUndefined(childHeight)) {
|
if (yoga::isUndefined(childWidth) || yoga::isUndefined(childHeight)) {
|
||||||
childWidthMeasureMode = yoga::isUndefined(childWidth)
|
childWidthMeasureMode = yoga::isUndefined(childWidth)
|
||||||
? YGMeasureModeUndefined
|
? MeasureMode::Undefined
|
||||||
: YGMeasureModeExactly;
|
: MeasureMode::Exactly;
|
||||||
childHeightMeasureMode = yoga::isUndefined(childHeight)
|
childHeightMeasureMode = yoga::isUndefined(childHeight)
|
||||||
? YGMeasureModeUndefined
|
? MeasureMode::Undefined
|
||||||
: YGMeasureModeExactly;
|
: MeasureMode::Exactly;
|
||||||
|
|
||||||
// If the size of the owner is defined then try to constrain the absolute
|
// If the size of the owner is defined then try to constrain the absolute
|
||||||
// child to that size as well. This allows text within the absolute child to
|
// child to that size as well. This allows text within the absolute child to
|
||||||
// wrap to the size of its owner. This is the same behavior as many browsers
|
// wrap to the size of its owner. This is the same behavior as many browsers
|
||||||
// implement.
|
// implement.
|
||||||
if (!isMainAxisRow && yoga::isUndefined(childWidth) &&
|
if (!isMainAxisRow && yoga::isUndefined(childWidth) &&
|
||||||
widthMode != YGMeasureModeUndefined && !yoga::isUndefined(width) &&
|
widthMode != MeasureMode::Undefined && !yoga::isUndefined(width) &&
|
||||||
width > 0) {
|
width > 0) {
|
||||||
childWidth = width;
|
childWidth = width;
|
||||||
childWidthMeasureMode = YGMeasureModeAtMost;
|
childWidthMeasureMode = MeasureMode::AtMost;
|
||||||
}
|
}
|
||||||
|
|
||||||
calculateLayoutInternal(
|
calculateLayoutInternal(
|
||||||
@@ -441,8 +442,8 @@ static void layoutAbsoluteChild(
|
|||||||
childWidth,
|
childWidth,
|
||||||
childHeight,
|
childHeight,
|
||||||
direction,
|
direction,
|
||||||
YGMeasureModeExactly,
|
MeasureMode::Exactly,
|
||||||
YGMeasureModeExactly,
|
MeasureMode::Exactly,
|
||||||
childWidth,
|
childWidth,
|
||||||
childHeight,
|
childHeight,
|
||||||
true,
|
true,
|
||||||
@@ -479,7 +480,7 @@ static void layoutAbsoluteChild(
|
|||||||
leadingEdge(mainAxis));
|
leadingEdge(mainAxis));
|
||||||
} else if (
|
} else if (
|
||||||
node->getConfig()->isExperimentalFeatureEnabled(
|
node->getConfig()->isExperimentalFeatureEnabled(
|
||||||
YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge) &&
|
ExperimentalFeature::AbsolutePercentageAgainstPaddingEdge) &&
|
||||||
child->isLeadingPositionDefined(mainAxis)) {
|
child->isLeadingPositionDefined(mainAxis)) {
|
||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
child->getLeadingPosition(
|
child->getLeadingPosition(
|
||||||
@@ -526,7 +527,7 @@ static void layoutAbsoluteChild(
|
|||||||
leadingEdge(crossAxis));
|
leadingEdge(crossAxis));
|
||||||
} else if (
|
} else if (
|
||||||
node->getConfig()->isExperimentalFeatureEnabled(
|
node->getConfig()->isExperimentalFeatureEnabled(
|
||||||
YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge) &&
|
ExperimentalFeature::AbsolutePercentageAgainstPaddingEdge) &&
|
||||||
child->isLeadingPositionDefined(crossAxis)) {
|
child->isLeadingPositionDefined(crossAxis)) {
|
||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
child->getLeadingPosition(
|
child->getLeadingPosition(
|
||||||
@@ -547,8 +548,8 @@ static void measureNodeWithMeasureFunc(
|
|||||||
yoga::Node* const node,
|
yoga::Node* const node,
|
||||||
float availableWidth,
|
float availableWidth,
|
||||||
float availableHeight,
|
float availableHeight,
|
||||||
const YGMeasureMode widthMeasureMode,
|
const MeasureMode widthMeasureMode,
|
||||||
const YGMeasureMode heightMeasureMode,
|
const MeasureMode heightMeasureMode,
|
||||||
const float ownerWidth,
|
const float ownerWidth,
|
||||||
const float ownerHeight,
|
const float ownerHeight,
|
||||||
LayoutData& layoutMarkerData,
|
LayoutData& layoutMarkerData,
|
||||||
@@ -558,10 +559,10 @@ static void measureNodeWithMeasureFunc(
|
|||||||
node->hasMeasureFunc(),
|
node->hasMeasureFunc(),
|
||||||
"Expected node to have custom measure function");
|
"Expected node to have custom measure function");
|
||||||
|
|
||||||
if (widthMeasureMode == YGMeasureModeUndefined) {
|
if (widthMeasureMode == MeasureMode::Undefined) {
|
||||||
availableWidth = YGUndefined;
|
availableWidth = YGUndefined;
|
||||||
}
|
}
|
||||||
if (heightMeasureMode == YGMeasureModeUndefined) {
|
if (heightMeasureMode == MeasureMode::Undefined) {
|
||||||
availableHeight = YGUndefined;
|
availableHeight = YGUndefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -580,8 +581,8 @@ static void measureNodeWithMeasureFunc(
|
|||||||
? availableHeight
|
? availableHeight
|
||||||
: yoga::maxOrDefined(0, availableHeight - paddingAndBorderAxisColumn);
|
: yoga::maxOrDefined(0, availableHeight - paddingAndBorderAxisColumn);
|
||||||
|
|
||||||
if (widthMeasureMode == YGMeasureModeExactly &&
|
if (widthMeasureMode == MeasureMode::Exactly &&
|
||||||
heightMeasureMode == YGMeasureModeExactly) {
|
heightMeasureMode == MeasureMode::Exactly) {
|
||||||
// Don't bother sizing the text if both dimensions are already defined.
|
// Don't bother sizing the text if both dimensions are already defined.
|
||||||
node->setLayoutMeasuredDimension(
|
node->setLayoutMeasuredDimension(
|
||||||
boundAxis(
|
boundAxis(
|
||||||
@@ -609,9 +610,9 @@ static void measureNodeWithMeasureFunc(
|
|||||||
Event::publish<Event::MeasureCallbackEnd>(
|
Event::publish<Event::MeasureCallbackEnd>(
|
||||||
node,
|
node,
|
||||||
{innerWidth,
|
{innerWidth,
|
||||||
widthMeasureMode,
|
unscopedEnum(widthMeasureMode),
|
||||||
innerHeight,
|
innerHeight,
|
||||||
heightMeasureMode,
|
unscopedEnum(heightMeasureMode),
|
||||||
measuredSize.width,
|
measuredSize.width,
|
||||||
measuredSize.height,
|
measuredSize.height,
|
||||||
reason});
|
reason});
|
||||||
@@ -620,8 +621,8 @@ static void measureNodeWithMeasureFunc(
|
|||||||
boundAxis(
|
boundAxis(
|
||||||
node,
|
node,
|
||||||
YGFlexDirectionRow,
|
YGFlexDirectionRow,
|
||||||
(widthMeasureMode == YGMeasureModeUndefined ||
|
(widthMeasureMode == MeasureMode::Undefined ||
|
||||||
widthMeasureMode == YGMeasureModeAtMost)
|
widthMeasureMode == MeasureMode::AtMost)
|
||||||
? measuredSize.width + paddingAndBorderAxisRow
|
? measuredSize.width + paddingAndBorderAxisRow
|
||||||
: availableWidth,
|
: availableWidth,
|
||||||
ownerWidth,
|
ownerWidth,
|
||||||
@@ -632,8 +633,8 @@ static void measureNodeWithMeasureFunc(
|
|||||||
boundAxis(
|
boundAxis(
|
||||||
node,
|
node,
|
||||||
YGFlexDirectionColumn,
|
YGFlexDirectionColumn,
|
||||||
(heightMeasureMode == YGMeasureModeUndefined ||
|
(heightMeasureMode == MeasureMode::Undefined ||
|
||||||
heightMeasureMode == YGMeasureModeAtMost)
|
heightMeasureMode == MeasureMode::AtMost)
|
||||||
? measuredSize.height + paddingAndBorderAxisColumn
|
? measuredSize.height + paddingAndBorderAxisColumn
|
||||||
: availableHeight,
|
: availableHeight,
|
||||||
ownerHeight,
|
ownerHeight,
|
||||||
@@ -648,16 +649,16 @@ static void measureNodeWithoutChildren(
|
|||||||
yoga::Node* const node,
|
yoga::Node* const node,
|
||||||
const float availableWidth,
|
const float availableWidth,
|
||||||
const float availableHeight,
|
const float availableHeight,
|
||||||
const YGMeasureMode widthMeasureMode,
|
const MeasureMode widthMeasureMode,
|
||||||
const YGMeasureMode heightMeasureMode,
|
const MeasureMode heightMeasureMode,
|
||||||
const float ownerWidth,
|
const float ownerWidth,
|
||||||
const float ownerHeight) {
|
const float ownerHeight) {
|
||||||
const auto& padding = node->getLayout().padding;
|
const auto& padding = node->getLayout().padding;
|
||||||
const auto& border = node->getLayout().border;
|
const auto& border = node->getLayout().border;
|
||||||
|
|
||||||
float width = availableWidth;
|
float width = availableWidth;
|
||||||
if (widthMeasureMode == YGMeasureModeUndefined ||
|
if (widthMeasureMode == MeasureMode::Undefined ||
|
||||||
widthMeasureMode == YGMeasureModeAtMost) {
|
widthMeasureMode == MeasureMode::AtMost) {
|
||||||
width = padding[YGEdgeLeft] + padding[YGEdgeRight] + border[YGEdgeLeft] +
|
width = padding[YGEdgeLeft] + padding[YGEdgeRight] + border[YGEdgeLeft] +
|
||||||
border[YGEdgeRight];
|
border[YGEdgeRight];
|
||||||
}
|
}
|
||||||
@@ -666,8 +667,8 @@ static void measureNodeWithoutChildren(
|
|||||||
YGDimensionWidth);
|
YGDimensionWidth);
|
||||||
|
|
||||||
float height = availableHeight;
|
float height = availableHeight;
|
||||||
if (heightMeasureMode == YGMeasureModeUndefined ||
|
if (heightMeasureMode == MeasureMode::Undefined ||
|
||||||
heightMeasureMode == YGMeasureModeAtMost) {
|
heightMeasureMode == MeasureMode::AtMost) {
|
||||||
height = padding[YGEdgeTop] + padding[YGEdgeBottom] + border[YGEdgeTop] +
|
height = padding[YGEdgeTop] + padding[YGEdgeBottom] + border[YGEdgeTop] +
|
||||||
border[YGEdgeBottom];
|
border[YGEdgeBottom];
|
||||||
}
|
}
|
||||||
@@ -680,22 +681,22 @@ static bool measureNodeWithFixedSize(
|
|||||||
yoga::Node* const node,
|
yoga::Node* const node,
|
||||||
const float availableWidth,
|
const float availableWidth,
|
||||||
const float availableHeight,
|
const float availableHeight,
|
||||||
const YGMeasureMode widthMeasureMode,
|
const MeasureMode widthMeasureMode,
|
||||||
const YGMeasureMode heightMeasureMode,
|
const MeasureMode heightMeasureMode,
|
||||||
const float ownerWidth,
|
const float ownerWidth,
|
||||||
const float ownerHeight) {
|
const float ownerHeight) {
|
||||||
if ((!yoga::isUndefined(availableWidth) &&
|
if ((!yoga::isUndefined(availableWidth) &&
|
||||||
widthMeasureMode == YGMeasureModeAtMost && availableWidth <= 0.0f) ||
|
widthMeasureMode == MeasureMode::AtMost && availableWidth <= 0.0f) ||
|
||||||
(!yoga::isUndefined(availableHeight) &&
|
(!yoga::isUndefined(availableHeight) &&
|
||||||
heightMeasureMode == YGMeasureModeAtMost && availableHeight <= 0.0f) ||
|
heightMeasureMode == MeasureMode::AtMost && availableHeight <= 0.0f) ||
|
||||||
(widthMeasureMode == YGMeasureModeExactly &&
|
(widthMeasureMode == MeasureMode::Exactly &&
|
||||||
heightMeasureMode == YGMeasureModeExactly)) {
|
heightMeasureMode == MeasureMode::Exactly)) {
|
||||||
node->setLayoutMeasuredDimension(
|
node->setLayoutMeasuredDimension(
|
||||||
boundAxis(
|
boundAxis(
|
||||||
node,
|
node,
|
||||||
YGFlexDirectionRow,
|
YGFlexDirectionRow,
|
||||||
yoga::isUndefined(availableWidth) ||
|
yoga::isUndefined(availableWidth) ||
|
||||||
(widthMeasureMode == YGMeasureModeAtMost &&
|
(widthMeasureMode == MeasureMode::AtMost &&
|
||||||
availableWidth < 0.0f)
|
availableWidth < 0.0f)
|
||||||
? 0.0f
|
? 0.0f
|
||||||
: availableWidth,
|
: availableWidth,
|
||||||
@@ -708,7 +709,7 @@ static bool measureNodeWithFixedSize(
|
|||||||
node,
|
node,
|
||||||
YGFlexDirectionColumn,
|
YGFlexDirectionColumn,
|
||||||
yoga::isUndefined(availableHeight) ||
|
yoga::isUndefined(availableHeight) ||
|
||||||
(heightMeasureMode == YGMeasureModeAtMost &&
|
(heightMeasureMode == MeasureMode::AtMost &&
|
||||||
availableHeight < 0.0f)
|
availableHeight < 0.0f)
|
||||||
? 0.0f
|
? 0.0f
|
||||||
: availableHeight,
|
: availableHeight,
|
||||||
@@ -768,8 +769,8 @@ static float computeFlexBasisForChildren(
|
|||||||
yoga::Node* const node,
|
yoga::Node* const node,
|
||||||
const float availableInnerWidth,
|
const float availableInnerWidth,
|
||||||
const float availableInnerHeight,
|
const float availableInnerHeight,
|
||||||
YGMeasureMode widthMeasureMode,
|
MeasureMode widthMeasureMode,
|
||||||
YGMeasureMode heightMeasureMode,
|
MeasureMode heightMeasureMode,
|
||||||
YGDirection direction,
|
YGDirection direction,
|
||||||
YGFlexDirection mainAxis,
|
YGFlexDirection mainAxis,
|
||||||
bool performLayout,
|
bool performLayout,
|
||||||
@@ -779,12 +780,12 @@ static float computeFlexBasisForChildren(
|
|||||||
float totalOuterFlexBasis = 0.0f;
|
float totalOuterFlexBasis = 0.0f;
|
||||||
YGNodeRef singleFlexChild = nullptr;
|
YGNodeRef singleFlexChild = nullptr;
|
||||||
const auto& children = node->getChildren();
|
const auto& children = node->getChildren();
|
||||||
YGMeasureMode measureModeMainDim =
|
MeasureMode measureModeMainDim =
|
||||||
isRow(mainAxis) ? widthMeasureMode : heightMeasureMode;
|
isRow(mainAxis) ? widthMeasureMode : heightMeasureMode;
|
||||||
// If there is only one child with flexGrow + flexShrink it means we can set
|
// If there is only one child with flexGrow + flexShrink it means we can set
|
||||||
// the computedFlexBasis to 0 instead of measuring and shrinking / flexing the
|
// the computedFlexBasis to 0 instead of measuring and shrinking / flexing the
|
||||||
// child to exactly match the remaining space
|
// child to exactly match the remaining space
|
||||||
if (measureModeMainDim == YGMeasureModeExactly) {
|
if (measureModeMainDim == MeasureMode::Exactly) {
|
||||||
for (auto child : children) {
|
for (auto child : children) {
|
||||||
if (child->isNodeFlexible()) {
|
if (child->isNodeFlexible()) {
|
||||||
if (singleFlexChild != nullptr ||
|
if (singleFlexChild != nullptr ||
|
||||||
@@ -866,7 +867,7 @@ static float distributeFreeSpaceSecondPass(
|
|||||||
const float availableInnerWidth,
|
const float availableInnerWidth,
|
||||||
const float availableInnerHeight,
|
const float availableInnerHeight,
|
||||||
const bool mainAxisOverflows,
|
const bool mainAxisOverflows,
|
||||||
const YGMeasureMode measureModeCrossDim,
|
const MeasureMode measureModeCrossDim,
|
||||||
const bool performLayout,
|
const bool performLayout,
|
||||||
LayoutData& layoutMarkerData,
|
LayoutData& layoutMarkerData,
|
||||||
const uint32_t depth,
|
const uint32_t depth,
|
||||||
@@ -941,34 +942,34 @@ static float distributeFreeSpaceSecondPass(
|
|||||||
|
|
||||||
float childCrossSize;
|
float childCrossSize;
|
||||||
float childMainSize = updatedMainSize + marginMain;
|
float childMainSize = updatedMainSize + marginMain;
|
||||||
YGMeasureMode childCrossMeasureMode;
|
MeasureMode childCrossMeasureMode;
|
||||||
YGMeasureMode childMainMeasureMode = YGMeasureModeExactly;
|
MeasureMode childMainMeasureMode = MeasureMode::Exactly;
|
||||||
|
|
||||||
const auto& childStyle = currentLineChild->getStyle();
|
const auto& childStyle = currentLineChild->getStyle();
|
||||||
if (!childStyle.aspectRatio().isUndefined()) {
|
if (!childStyle.aspectRatio().isUndefined()) {
|
||||||
childCrossSize = isMainAxisRow
|
childCrossSize = isMainAxisRow
|
||||||
? (childMainSize - marginMain) / childStyle.aspectRatio().unwrap()
|
? (childMainSize - marginMain) / childStyle.aspectRatio().unwrap()
|
||||||
: (childMainSize - marginMain) * childStyle.aspectRatio().unwrap();
|
: (childMainSize - marginMain) * childStyle.aspectRatio().unwrap();
|
||||||
childCrossMeasureMode = YGMeasureModeExactly;
|
childCrossMeasureMode = MeasureMode::Exactly;
|
||||||
|
|
||||||
childCrossSize += marginCross;
|
childCrossSize += marginCross;
|
||||||
} else if (
|
} else if (
|
||||||
!std::isnan(availableInnerCrossDim) &&
|
!std::isnan(availableInnerCrossDim) &&
|
||||||
!styleDefinesDimension(
|
!styleDefinesDimension(
|
||||||
currentLineChild, crossAxis, availableInnerCrossDim) &&
|
currentLineChild, crossAxis, availableInnerCrossDim) &&
|
||||||
measureModeCrossDim == YGMeasureModeExactly &&
|
measureModeCrossDim == MeasureMode::Exactly &&
|
||||||
!(isNodeFlexWrap && mainAxisOverflows) &&
|
!(isNodeFlexWrap && mainAxisOverflows) &&
|
||||||
resolveChildAlignment(node, currentLineChild) == YGAlignStretch &&
|
resolveChildAlignment(node, currentLineChild) == YGAlignStretch &&
|
||||||
currentLineChild->marginLeadingValue(crossAxis).unit != YGUnitAuto &&
|
currentLineChild->marginLeadingValue(crossAxis).unit != YGUnitAuto &&
|
||||||
currentLineChild->marginTrailingValue(crossAxis).unit != YGUnitAuto) {
|
currentLineChild->marginTrailingValue(crossAxis).unit != YGUnitAuto) {
|
||||||
childCrossSize = availableInnerCrossDim;
|
childCrossSize = availableInnerCrossDim;
|
||||||
childCrossMeasureMode = YGMeasureModeExactly;
|
childCrossMeasureMode = MeasureMode::Exactly;
|
||||||
} else if (!styleDefinesDimension(
|
} else if (!styleDefinesDimension(
|
||||||
currentLineChild, crossAxis, availableInnerCrossDim)) {
|
currentLineChild, crossAxis, availableInnerCrossDim)) {
|
||||||
childCrossSize = availableInnerCrossDim;
|
childCrossSize = availableInnerCrossDim;
|
||||||
childCrossMeasureMode = yoga::isUndefined(childCrossSize)
|
childCrossMeasureMode = yoga::isUndefined(childCrossSize)
|
||||||
? YGMeasureModeUndefined
|
? MeasureMode::Undefined
|
||||||
: YGMeasureModeAtMost;
|
: MeasureMode::AtMost;
|
||||||
} else {
|
} else {
|
||||||
childCrossSize =
|
childCrossSize =
|
||||||
yoga::resolveValue(
|
yoga::resolveValue(
|
||||||
@@ -979,11 +980,11 @@ static float distributeFreeSpaceSecondPass(
|
|||||||
const bool isLoosePercentageMeasurement =
|
const bool isLoosePercentageMeasurement =
|
||||||
currentLineChild->getResolvedDimension(dimension(crossAxis)).unit ==
|
currentLineChild->getResolvedDimension(dimension(crossAxis)).unit ==
|
||||||
YGUnitPercent &&
|
YGUnitPercent &&
|
||||||
measureModeCrossDim != YGMeasureModeExactly;
|
measureModeCrossDim != MeasureMode::Exactly;
|
||||||
childCrossMeasureMode =
|
childCrossMeasureMode =
|
||||||
yoga::isUndefined(childCrossSize) || isLoosePercentageMeasurement
|
yoga::isUndefined(childCrossSize) || isLoosePercentageMeasurement
|
||||||
? YGMeasureModeUndefined
|
? MeasureMode::Undefined
|
||||||
: YGMeasureModeExactly;
|
: MeasureMode::Exactly;
|
||||||
}
|
}
|
||||||
|
|
||||||
constrainMaxSizeForMode(
|
constrainMaxSizeForMode(
|
||||||
@@ -1011,9 +1012,9 @@ static float distributeFreeSpaceSecondPass(
|
|||||||
const float childWidth = isMainAxisRow ? childMainSize : childCrossSize;
|
const float childWidth = isMainAxisRow ? childMainSize : childCrossSize;
|
||||||
const float childHeight = !isMainAxisRow ? childMainSize : childCrossSize;
|
const float childHeight = !isMainAxisRow ? childMainSize : childCrossSize;
|
||||||
|
|
||||||
const YGMeasureMode childWidthMeasureMode =
|
const MeasureMode childWidthMeasureMode =
|
||||||
isMainAxisRow ? childMainMeasureMode : childCrossMeasureMode;
|
isMainAxisRow ? childMainMeasureMode : childCrossMeasureMode;
|
||||||
const YGMeasureMode childHeightMeasureMode =
|
const MeasureMode childHeightMeasureMode =
|
||||||
!isMainAxisRow ? childMainMeasureMode : childCrossMeasureMode;
|
!isMainAxisRow ? childMainMeasureMode : childCrossMeasureMode;
|
||||||
|
|
||||||
const bool isLayoutPass = performLayout && !requiresStretchLayout;
|
const bool isLayoutPass = performLayout && !requiresStretchLayout;
|
||||||
@@ -1160,7 +1161,7 @@ static void resolveFlexibleLength(
|
|||||||
const float availableInnerWidth,
|
const float availableInnerWidth,
|
||||||
const float availableInnerHeight,
|
const float availableInnerHeight,
|
||||||
const bool mainAxisOverflows,
|
const bool mainAxisOverflows,
|
||||||
const YGMeasureMode measureModeCrossDim,
|
const MeasureMode measureModeCrossDim,
|
||||||
const bool performLayout,
|
const bool performLayout,
|
||||||
LayoutData& layoutMarkerData,
|
LayoutData& layoutMarkerData,
|
||||||
const uint32_t depth,
|
const uint32_t depth,
|
||||||
@@ -1201,8 +1202,8 @@ static void YGJustifyMainAxis(
|
|||||||
const size_t startOfLineIndex,
|
const size_t startOfLineIndex,
|
||||||
const YGFlexDirection mainAxis,
|
const YGFlexDirection mainAxis,
|
||||||
const YGFlexDirection crossAxis,
|
const YGFlexDirection crossAxis,
|
||||||
const YGMeasureMode measureModeMainDim,
|
const MeasureMode measureModeMainDim,
|
||||||
const YGMeasureMode measureModeCrossDim,
|
const MeasureMode measureModeCrossDim,
|
||||||
const float mainAxisownerSize,
|
const float mainAxisownerSize,
|
||||||
const float ownerWidth,
|
const float ownerWidth,
|
||||||
const float availableInnerMainDim,
|
const float availableInnerMainDim,
|
||||||
@@ -1217,7 +1218,7 @@ static void YGJustifyMainAxis(
|
|||||||
const float gap = node->getGapForAxis(mainAxis, ownerWidth).unwrap();
|
const float gap = node->getGapForAxis(mainAxis, ownerWidth).unwrap();
|
||||||
// If we are using "at most" rules in the main axis, make sure that
|
// If we are using "at most" rules in the main axis, make sure that
|
||||||
// remainingFreeSpace is 0 when min main dimension is not given
|
// remainingFreeSpace is 0 when min main dimension is not given
|
||||||
if (measureModeMainDim == YGMeasureModeAtMost &&
|
if (measureModeMainDim == MeasureMode::AtMost &&
|
||||||
flexLine.layout.remainingFreeSpace > 0) {
|
flexLine.layout.remainingFreeSpace > 0) {
|
||||||
if (!style.minDimensions()[dimension(mainAxis)].isUndefined() &&
|
if (!style.minDimensions()[dimension(mainAxis)].isUndefined() &&
|
||||||
!yoga::resolveValue(
|
!yoga::resolveValue(
|
||||||
@@ -1348,7 +1349,7 @@ static void YGJustifyMainAxis(
|
|||||||
static_cast<float>(numberOfAutoMarginsOnCurrentLine);
|
static_cast<float>(numberOfAutoMarginsOnCurrentLine);
|
||||||
}
|
}
|
||||||
bool canSkipFlex =
|
bool canSkipFlex =
|
||||||
!performLayout && measureModeCrossDim == YGMeasureModeExactly;
|
!performLayout && measureModeCrossDim == MeasureMode::Exactly;
|
||||||
if (canSkipFlex) {
|
if (canSkipFlex) {
|
||||||
// If we skipped the flex step, then we can't rely on the measuredDims
|
// If we skipped the flex step, then we can't rely on the measuredDims
|
||||||
// because they weren't computed. This means we can't call
|
// because they weren't computed. This means we can't call
|
||||||
@@ -1465,21 +1466,21 @@ static void YGJustifyMainAxis(
|
|||||||
// content" because we don't support default minimum main sizes (see above
|
// content" because we don't support default minimum main sizes (see above
|
||||||
// for details). Each of our measure modes maps to a layout mode from the
|
// for details). Each of our measure modes maps to a layout mode from the
|
||||||
// spec (https://www.w3.org/TR/CSS3-sizing/#terms):
|
// spec (https://www.w3.org/TR/CSS3-sizing/#terms):
|
||||||
// - YGMeasureModeUndefined: max content
|
// - MeasureMode::Undefined: max content
|
||||||
// - YGMeasureModeExactly: fill available
|
// - MeasureMode::Exactly: fill available
|
||||||
// - YGMeasureModeAtMost: fit content
|
// - MeasureMode::AtMost: fit content
|
||||||
//
|
//
|
||||||
// When calling calculateLayoutImpl and calculateLayoutInternal, if the
|
// When calling calculateLayoutImpl and calculateLayoutInternal, if the
|
||||||
// caller passes an available size of undefined then it must also pass a
|
// caller passes an available size of undefined then it must also pass a
|
||||||
// measure mode of YGMeasureModeUndefined in that dimension.
|
// measure mode of MeasureMode::Undefined in that dimension.
|
||||||
//
|
//
|
||||||
static void calculateLayoutImpl(
|
static void calculateLayoutImpl(
|
||||||
yoga::Node* const node,
|
yoga::Node* const node,
|
||||||
const float availableWidth,
|
const float availableWidth,
|
||||||
const float availableHeight,
|
const float availableHeight,
|
||||||
const YGDirection ownerDirection,
|
const YGDirection ownerDirection,
|
||||||
const YGMeasureMode widthMeasureMode,
|
const MeasureMode widthMeasureMode,
|
||||||
const YGMeasureMode heightMeasureMode,
|
const MeasureMode heightMeasureMode,
|
||||||
const float ownerWidth,
|
const float ownerWidth,
|
||||||
const float ownerHeight,
|
const float ownerHeight,
|
||||||
const bool performLayout,
|
const bool performLayout,
|
||||||
@@ -1490,17 +1491,17 @@ static void calculateLayoutImpl(
|
|||||||
yoga::assertFatalWithNode(
|
yoga::assertFatalWithNode(
|
||||||
node,
|
node,
|
||||||
yoga::isUndefined(availableWidth)
|
yoga::isUndefined(availableWidth)
|
||||||
? widthMeasureMode == YGMeasureModeUndefined
|
? widthMeasureMode == MeasureMode::Undefined
|
||||||
: true,
|
: true,
|
||||||
"availableWidth is indefinite so widthMeasureMode must be "
|
"availableWidth is indefinite so widthMeasureMode must be "
|
||||||
"YGMeasureModeUndefined");
|
"MeasureMode::Undefined");
|
||||||
yoga::assertFatalWithNode(
|
yoga::assertFatalWithNode(
|
||||||
node,
|
node,
|
||||||
yoga::isUndefined(availableHeight)
|
yoga::isUndefined(availableHeight)
|
||||||
? heightMeasureMode == YGMeasureModeUndefined
|
? heightMeasureMode == MeasureMode::Undefined
|
||||||
: true,
|
: true,
|
||||||
"availableHeight is indefinite so heightMeasureMode must be "
|
"availableHeight is indefinite so heightMeasureMode must be "
|
||||||
"YGMeasureModeUndefined");
|
"MeasureMode::Undefined");
|
||||||
|
|
||||||
(performLayout ? layoutMarkerData.layouts : layoutMarkerData.measures) += 1;
|
(performLayout ? layoutMarkerData.layouts : layoutMarkerData.measures) += 1;
|
||||||
|
|
||||||
@@ -1617,9 +1618,9 @@ static void calculateLayoutImpl(
|
|||||||
const float paddingAndBorderAxisCross =
|
const float paddingAndBorderAxisCross =
|
||||||
leadingPaddingAndBorderCross + trailingPaddingAndBorderCross;
|
leadingPaddingAndBorderCross + trailingPaddingAndBorderCross;
|
||||||
|
|
||||||
YGMeasureMode measureModeMainDim =
|
MeasureMode measureModeMainDim =
|
||||||
isMainAxisRow ? widthMeasureMode : heightMeasureMode;
|
isMainAxisRow ? widthMeasureMode : heightMeasureMode;
|
||||||
YGMeasureMode measureModeCrossDim =
|
MeasureMode measureModeCrossDim =
|
||||||
isMainAxisRow ? heightMeasureMode : widthMeasureMode;
|
isMainAxisRow ? heightMeasureMode : widthMeasureMode;
|
||||||
|
|
||||||
const float paddingAndBorderAxisRow =
|
const float paddingAndBorderAxisRow =
|
||||||
@@ -1671,12 +1672,12 @@ static void calculateLayoutImpl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const bool mainAxisOverflows =
|
const bool mainAxisOverflows =
|
||||||
(measureModeMainDim != YGMeasureModeUndefined) &&
|
(measureModeMainDim != MeasureMode::Undefined) &&
|
||||||
totalMainDim > availableInnerMainDim;
|
totalMainDim > availableInnerMainDim;
|
||||||
|
|
||||||
if (isNodeFlexWrap && mainAxisOverflows &&
|
if (isNodeFlexWrap && mainAxisOverflows &&
|
||||||
measureModeMainDim == YGMeasureModeAtMost) {
|
measureModeMainDim == MeasureMode::AtMost) {
|
||||||
measureModeMainDim = YGMeasureModeExactly;
|
measureModeMainDim = MeasureMode::Exactly;
|
||||||
}
|
}
|
||||||
// STEP 4: COLLECT FLEX ITEMS INTO FLEX LINES
|
// STEP 4: COLLECT FLEX ITEMS INTO FLEX LINES
|
||||||
|
|
||||||
@@ -1711,7 +1712,7 @@ static void calculateLayoutImpl(
|
|||||||
// If we don't need to measure the cross axis, we can skip the entire flex
|
// If we don't need to measure the cross axis, we can skip the entire flex
|
||||||
// step.
|
// step.
|
||||||
const bool canSkipFlex =
|
const bool canSkipFlex =
|
||||||
!performLayout && measureModeCrossDim == YGMeasureModeExactly;
|
!performLayout && measureModeCrossDim == MeasureMode::Exactly;
|
||||||
|
|
||||||
// STEP 5: RESOLVING FLEXIBLE LENGTHS ON MAIN AXIS
|
// STEP 5: RESOLVING FLEXIBLE LENGTHS ON MAIN AXIS
|
||||||
// Calculate the remaining available space that needs to be allocated. If
|
// Calculate the remaining available space that needs to be allocated. If
|
||||||
@@ -1721,7 +1722,7 @@ static void calculateLayoutImpl(
|
|||||||
bool sizeBasedOnContent = false;
|
bool sizeBasedOnContent = false;
|
||||||
// If we don't measure with exact main dimension we want to ensure we don't
|
// If we don't measure with exact main dimension we want to ensure we don't
|
||||||
// violate min and max
|
// violate min and max
|
||||||
if (measureModeMainDim != YGMeasureModeExactly) {
|
if (measureModeMainDim != MeasureMode::Exactly) {
|
||||||
const auto& minDimensions = node->getStyle().minDimensions();
|
const auto& minDimensions = node->getStyle().minDimensions();
|
||||||
const auto& maxDimensions = node->getStyle().maxDimensions();
|
const auto& maxDimensions = node->getStyle().maxDimensions();
|
||||||
const float minInnerWidth =
|
const float minInnerWidth =
|
||||||
@@ -1755,7 +1756,7 @@ static void calculateLayoutImpl(
|
|||||||
availableInnerMainDim = maxInnerMainDim;
|
availableInnerMainDim = maxInnerMainDim;
|
||||||
} else {
|
} else {
|
||||||
bool useLegacyStretchBehaviour =
|
bool useLegacyStretchBehaviour =
|
||||||
node->hasErrata(YGErrataStretchFlexBasis);
|
node->hasErrata(Errata::StretchFlexBasis);
|
||||||
|
|
||||||
if (!useLegacyStretchBehaviour &&
|
if (!useLegacyStretchBehaviour &&
|
||||||
((!yoga::isUndefined(flexLine.layout.totalFlexGrowFactors) &&
|
((!yoga::isUndefined(flexLine.layout.totalFlexGrowFactors) &&
|
||||||
@@ -1829,8 +1830,8 @@ static void calculateLayoutImpl(
|
|||||||
performLayout);
|
performLayout);
|
||||||
|
|
||||||
float containerCrossAxis = availableInnerCrossDim;
|
float containerCrossAxis = availableInnerCrossDim;
|
||||||
if (measureModeCrossDim == YGMeasureModeUndefined ||
|
if (measureModeCrossDim == MeasureMode::Undefined ||
|
||||||
measureModeCrossDim == YGMeasureModeAtMost) {
|
measureModeCrossDim == MeasureMode::AtMost) {
|
||||||
// Compute the cross axis from the max cross dimension of the children.
|
// Compute the cross axis from the max cross dimension of the children.
|
||||||
containerCrossAxis =
|
containerCrossAxis =
|
||||||
boundAxis(
|
boundAxis(
|
||||||
@@ -1843,7 +1844,7 @@ static void calculateLayoutImpl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If there's no flex wrap, the cross dimension is defined by the container.
|
// If there's no flex wrap, the cross dimension is defined by the container.
|
||||||
if (!isNodeFlexWrap && measureModeCrossDim == YGMeasureModeExactly) {
|
if (!isNodeFlexWrap && measureModeCrossDim == MeasureMode::Exactly) {
|
||||||
flexLine.layout.crossDim = availableInnerCrossDim;
|
flexLine.layout.crossDim = availableInnerCrossDim;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1924,8 +1925,8 @@ static void calculateLayoutImpl(
|
|||||||
child->getMarginForAxis(mainAxis, availableInnerWidth)
|
child->getMarginForAxis(mainAxis, availableInnerWidth)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
YGMeasureMode childMainMeasureMode = YGMeasureModeExactly;
|
MeasureMode childMainMeasureMode = MeasureMode::Exactly;
|
||||||
YGMeasureMode childCrossMeasureMode = YGMeasureModeExactly;
|
MeasureMode childCrossMeasureMode = MeasureMode::Exactly;
|
||||||
constrainMaxSizeForMode(
|
constrainMaxSizeForMode(
|
||||||
child,
|
child,
|
||||||
mainAxis,
|
mainAxis,
|
||||||
@@ -1949,16 +1950,16 @@ static void calculateLayoutImpl(
|
|||||||
auto alignContent = node->getStyle().alignContent();
|
auto alignContent = node->getStyle().alignContent();
|
||||||
auto crossAxisDoesNotGrow =
|
auto crossAxisDoesNotGrow =
|
||||||
alignContent != YGAlignStretch && isNodeFlexWrap;
|
alignContent != YGAlignStretch && isNodeFlexWrap;
|
||||||
const YGMeasureMode childWidthMeasureMode =
|
const MeasureMode childWidthMeasureMode =
|
||||||
yoga::isUndefined(childWidth) ||
|
yoga::isUndefined(childWidth) ||
|
||||||
(!isMainAxisRow && crossAxisDoesNotGrow)
|
(!isMainAxisRow && crossAxisDoesNotGrow)
|
||||||
? YGMeasureModeUndefined
|
? MeasureMode::Undefined
|
||||||
: YGMeasureModeExactly;
|
: MeasureMode::Exactly;
|
||||||
const YGMeasureMode childHeightMeasureMode =
|
const MeasureMode childHeightMeasureMode =
|
||||||
yoga::isUndefined(childHeight) ||
|
yoga::isUndefined(childHeight) ||
|
||||||
(isMainAxisRow && crossAxisDoesNotGrow)
|
(isMainAxisRow && crossAxisDoesNotGrow)
|
||||||
? YGMeasureModeUndefined
|
? MeasureMode::Undefined
|
||||||
: YGMeasureModeExactly;
|
: MeasureMode::Exactly;
|
||||||
|
|
||||||
calculateLayoutInternal(
|
calculateLayoutInternal(
|
||||||
child,
|
child,
|
||||||
@@ -2181,8 +2182,8 @@ static void calculateLayoutImpl(
|
|||||||
childWidth,
|
childWidth,
|
||||||
childHeight,
|
childHeight,
|
||||||
direction,
|
direction,
|
||||||
YGMeasureModeExactly,
|
MeasureMode::Exactly,
|
||||||
YGMeasureModeExactly,
|
MeasureMode::Exactly,
|
||||||
availableInnerWidth,
|
availableInnerWidth,
|
||||||
availableInnerHeight,
|
availableInnerHeight,
|
||||||
true,
|
true,
|
||||||
@@ -2240,9 +2241,9 @@ static void calculateLayoutImpl(
|
|||||||
|
|
||||||
// If the user didn't specify a width or height for the node, set the
|
// If the user didn't specify a width or height for the node, set the
|
||||||
// dimensions based on the children.
|
// dimensions based on the children.
|
||||||
if (measureModeMainDim == YGMeasureModeUndefined ||
|
if (measureModeMainDim == MeasureMode::Undefined ||
|
||||||
(node->getStyle().overflow() != YGOverflowScroll &&
|
(node->getStyle().overflow() != YGOverflowScroll &&
|
||||||
measureModeMainDim == YGMeasureModeAtMost)) {
|
measureModeMainDim == MeasureMode::AtMost)) {
|
||||||
// Clamp the size to the min/max size, if specified, and make sure it
|
// Clamp the size to the min/max size, if specified, and make sure it
|
||||||
// doesn't go below the padding and border amount.
|
// doesn't go below the padding and border amount.
|
||||||
node->setLayoutMeasuredDimension(
|
node->setLayoutMeasuredDimension(
|
||||||
@@ -2251,7 +2252,7 @@ static void calculateLayoutImpl(
|
|||||||
dimension(mainAxis));
|
dimension(mainAxis));
|
||||||
|
|
||||||
} else if (
|
} else if (
|
||||||
measureModeMainDim == YGMeasureModeAtMost &&
|
measureModeMainDim == MeasureMode::AtMost &&
|
||||||
node->getStyle().overflow() == YGOverflowScroll) {
|
node->getStyle().overflow() == YGOverflowScroll) {
|
||||||
node->setLayoutMeasuredDimension(
|
node->setLayoutMeasuredDimension(
|
||||||
yoga::maxOrDefined(
|
yoga::maxOrDefined(
|
||||||
@@ -2267,9 +2268,9 @@ static void calculateLayoutImpl(
|
|||||||
dimension(mainAxis));
|
dimension(mainAxis));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (measureModeCrossDim == YGMeasureModeUndefined ||
|
if (measureModeCrossDim == MeasureMode::Undefined ||
|
||||||
(node->getStyle().overflow() != YGOverflowScroll &&
|
(node->getStyle().overflow() != YGOverflowScroll &&
|
||||||
measureModeCrossDim == YGMeasureModeAtMost)) {
|
measureModeCrossDim == MeasureMode::AtMost)) {
|
||||||
// Clamp the size to the min/max size, if specified, and make sure it
|
// Clamp the size to the min/max size, if specified, and make sure it
|
||||||
// doesn't go below the padding and border amount.
|
// doesn't go below the padding and border amount.
|
||||||
node->setLayoutMeasuredDimension(
|
node->setLayoutMeasuredDimension(
|
||||||
@@ -2282,7 +2283,7 @@ static void calculateLayoutImpl(
|
|||||||
dimension(crossAxis));
|
dimension(crossAxis));
|
||||||
|
|
||||||
} else if (
|
} else if (
|
||||||
measureModeCrossDim == YGMeasureModeAtMost &&
|
measureModeCrossDim == MeasureMode::AtMost &&
|
||||||
node->getStyle().overflow() == YGOverflowScroll) {
|
node->getStyle().overflow() == YGOverflowScroll) {
|
||||||
node->setLayoutMeasuredDimension(
|
node->setLayoutMeasuredDimension(
|
||||||
yoga::maxOrDefined(
|
yoga::maxOrDefined(
|
||||||
@@ -2323,7 +2324,7 @@ static void calculateLayoutImpl(
|
|||||||
}
|
}
|
||||||
const bool absolutePercentageAgainstPaddingEdge =
|
const bool absolutePercentageAgainstPaddingEdge =
|
||||||
node->getConfig()->isExperimentalFeatureEnabled(
|
node->getConfig()->isExperimentalFeatureEnabled(
|
||||||
YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge);
|
ExperimentalFeature::AbsolutePercentageAgainstPaddingEdge);
|
||||||
|
|
||||||
layoutAbsoluteChild(
|
layoutAbsoluteChild(
|
||||||
node,
|
node,
|
||||||
@@ -2382,18 +2383,17 @@ static const char* spacerWithLength(const unsigned long level) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const char* measureModeName(
|
static const char* measureModeName(
|
||||||
const YGMeasureMode mode,
|
const MeasureMode mode,
|
||||||
const bool performLayout) {
|
const bool performLayout) {
|
||||||
constexpr auto N = enums::count<YGMeasureMode>();
|
switch (mode) {
|
||||||
const char* kMeasureModeNames[N] = {"UNDEFINED", "EXACTLY", "AT_MOST"};
|
case MeasureMode::Undefined:
|
||||||
const char* kLayoutModeNames[N] = {
|
return performLayout ? "LAY_UNDEFINED" : "UNDEFINED";
|
||||||
"LAY_UNDEFINED", "LAY_EXACTLY", "LAY_AT_MOST"};
|
case MeasureMode::Exactly:
|
||||||
|
return performLayout ? "LAY_EXACTLY" : "EXACTLY";
|
||||||
if (mode >= N) {
|
case MeasureMode::AtMost:
|
||||||
return "";
|
return performLayout ? "LAY_AT_MOST" : "AT_MOST";
|
||||||
}
|
}
|
||||||
|
return "";
|
||||||
return performLayout ? kLayoutModeNames[mode] : kMeasureModeNames[mode];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -2409,8 +2409,8 @@ bool calculateLayoutInternal(
|
|||||||
const float availableWidth,
|
const float availableWidth,
|
||||||
const float availableHeight,
|
const float availableHeight,
|
||||||
const YGDirection ownerDirection,
|
const YGDirection ownerDirection,
|
||||||
const YGMeasureMode widthMeasureMode,
|
const MeasureMode widthMeasureMode,
|
||||||
const YGMeasureMode heightMeasureMode,
|
const MeasureMode heightMeasureMode,
|
||||||
const float ownerWidth,
|
const float ownerWidth,
|
||||||
const float ownerHeight,
|
const float ownerHeight,
|
||||||
const bool performLayout,
|
const bool performLayout,
|
||||||
@@ -2431,8 +2431,8 @@ bool calculateLayoutInternal(
|
|||||||
layout->nextCachedMeasurementsIndex = 0;
|
layout->nextCachedMeasurementsIndex = 0;
|
||||||
layout->cachedLayout.availableWidth = -1;
|
layout->cachedLayout.availableWidth = -1;
|
||||||
layout->cachedLayout.availableHeight = -1;
|
layout->cachedLayout.availableHeight = -1;
|
||||||
layout->cachedLayout.widthMeasureMode = YGMeasureModeUndefined;
|
layout->cachedLayout.widthMeasureMode = MeasureMode::Undefined;
|
||||||
layout->cachedLayout.heightMeasureMode = YGMeasureModeUndefined;
|
layout->cachedLayout.heightMeasureMode = MeasureMode::Undefined;
|
||||||
layout->cachedLayout.computedWidth = -1;
|
layout->cachedLayout.computedWidth = -1;
|
||||||
layout->cachedLayout.computedHeight = -1;
|
layout->cachedLayout.computedHeight = -1;
|
||||||
}
|
}
|
||||||
@@ -2526,14 +2526,14 @@ bool calculateLayoutInternal(
|
|||||||
if (gPrintChanges && gPrintSkips) {
|
if (gPrintChanges && gPrintSkips) {
|
||||||
yoga::log(
|
yoga::log(
|
||||||
node,
|
node,
|
||||||
YGLogLevelVerbose,
|
LogLevel::Verbose,
|
||||||
"%s%d.{[skipped] ",
|
"%s%d.{[skipped] ",
|
||||||
spacerWithLength(depth),
|
spacerWithLength(depth),
|
||||||
depth);
|
depth);
|
||||||
node->print();
|
node->print();
|
||||||
yoga::log(
|
yoga::log(
|
||||||
node,
|
node,
|
||||||
YGLogLevelVerbose,
|
LogLevel::Verbose,
|
||||||
"wm: %s, hm: %s, aw: %f ah: %f => d: (%f, %f) %s\n",
|
"wm: %s, hm: %s, aw: %f ah: %f => d: (%f, %f) %s\n",
|
||||||
measureModeName(widthMeasureMode, performLayout),
|
measureModeName(widthMeasureMode, performLayout),
|
||||||
measureModeName(heightMeasureMode, performLayout),
|
measureModeName(heightMeasureMode, performLayout),
|
||||||
@@ -2547,7 +2547,7 @@ bool calculateLayoutInternal(
|
|||||||
if (gPrintChanges) {
|
if (gPrintChanges) {
|
||||||
yoga::log(
|
yoga::log(
|
||||||
node,
|
node,
|
||||||
YGLogLevelVerbose,
|
LogLevel::Verbose,
|
||||||
"%s%d.{%s",
|
"%s%d.{%s",
|
||||||
spacerWithLength(depth),
|
spacerWithLength(depth),
|
||||||
depth,
|
depth,
|
||||||
@@ -2555,7 +2555,7 @@ bool calculateLayoutInternal(
|
|||||||
node->print();
|
node->print();
|
||||||
yoga::log(
|
yoga::log(
|
||||||
node,
|
node,
|
||||||
YGLogLevelVerbose,
|
LogLevel::Verbose,
|
||||||
"wm: %s, hm: %s, aw: %f ah: %f %s\n",
|
"wm: %s, hm: %s, aw: %f ah: %f %s\n",
|
||||||
measureModeName(widthMeasureMode, performLayout),
|
measureModeName(widthMeasureMode, performLayout),
|
||||||
measureModeName(heightMeasureMode, performLayout),
|
measureModeName(heightMeasureMode, performLayout),
|
||||||
@@ -2582,7 +2582,7 @@ bool calculateLayoutInternal(
|
|||||||
if (gPrintChanges) {
|
if (gPrintChanges) {
|
||||||
yoga::log(
|
yoga::log(
|
||||||
node,
|
node,
|
||||||
YGLogLevelVerbose,
|
LogLevel::Verbose,
|
||||||
"%s%d.}%s",
|
"%s%d.}%s",
|
||||||
spacerWithLength(depth),
|
spacerWithLength(depth),
|
||||||
depth,
|
depth,
|
||||||
@@ -2590,7 +2590,7 @@ bool calculateLayoutInternal(
|
|||||||
node->print();
|
node->print();
|
||||||
yoga::log(
|
yoga::log(
|
||||||
node,
|
node,
|
||||||
YGLogLevelVerbose,
|
LogLevel::Verbose,
|
||||||
"wm: %s, hm: %s, d: (%f, %f) %s\n",
|
"wm: %s, hm: %s, d: (%f, %f) %s\n",
|
||||||
measureModeName(widthMeasureMode, performLayout),
|
measureModeName(widthMeasureMode, performLayout),
|
||||||
measureModeName(heightMeasureMode, performLayout),
|
measureModeName(heightMeasureMode, performLayout),
|
||||||
@@ -2609,7 +2609,7 @@ bool calculateLayoutInternal(
|
|||||||
if (layout->nextCachedMeasurementsIndex ==
|
if (layout->nextCachedMeasurementsIndex ==
|
||||||
LayoutResults::MaxCachedMeasurements) {
|
LayoutResults::MaxCachedMeasurements) {
|
||||||
if (gPrintChanges) {
|
if (gPrintChanges) {
|
||||||
yoga::log(node, YGLogLevelVerbose, "Out of cache entries!\n");
|
yoga::log(node, LogLevel::Verbose, "Out of cache entries!\n");
|
||||||
}
|
}
|
||||||
layout->nextCachedMeasurementsIndex = 0;
|
layout->nextCachedMeasurementsIndex = 0;
|
||||||
}
|
}
|
||||||
@@ -2678,7 +2678,7 @@ void calculateLayout(
|
|||||||
gCurrentGenerationCount.fetch_add(1, std::memory_order_relaxed);
|
gCurrentGenerationCount.fetch_add(1, std::memory_order_relaxed);
|
||||||
node->resolveDimension();
|
node->resolveDimension();
|
||||||
float width = YGUndefined;
|
float width = YGUndefined;
|
||||||
YGMeasureMode widthMeasureMode = YGMeasureModeUndefined;
|
MeasureMode widthMeasureMode = MeasureMode::Undefined;
|
||||||
const auto& maxDimensions = node->getStyle().maxDimensions();
|
const auto& maxDimensions = node->getStyle().maxDimensions();
|
||||||
if (styleDefinesDimension(node, YGFlexDirectionRow, ownerWidth)) {
|
if (styleDefinesDimension(node, YGFlexDirectionRow, ownerWidth)) {
|
||||||
width = (yoga::resolveValue(
|
width = (yoga::resolveValue(
|
||||||
@@ -2686,36 +2686,36 @@ void calculateLayout(
|
|||||||
ownerWidth) +
|
ownerWidth) +
|
||||||
node->getMarginForAxis(YGFlexDirectionRow, ownerWidth))
|
node->getMarginForAxis(YGFlexDirectionRow, ownerWidth))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
widthMeasureMode = YGMeasureModeExactly;
|
widthMeasureMode = MeasureMode::Exactly;
|
||||||
} else if (!yoga::resolveValue(maxDimensions[YGDimensionWidth], ownerWidth)
|
} else if (!yoga::resolveValue(maxDimensions[YGDimensionWidth], ownerWidth)
|
||||||
.isUndefined()) {
|
.isUndefined()) {
|
||||||
width = yoga::resolveValue(maxDimensions[YGDimensionWidth], ownerWidth)
|
width = yoga::resolveValue(maxDimensions[YGDimensionWidth], ownerWidth)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
widthMeasureMode = YGMeasureModeAtMost;
|
widthMeasureMode = MeasureMode::AtMost;
|
||||||
} else {
|
} else {
|
||||||
width = ownerWidth;
|
width = ownerWidth;
|
||||||
widthMeasureMode = yoga::isUndefined(width) ? YGMeasureModeUndefined
|
widthMeasureMode = yoga::isUndefined(width) ? MeasureMode::Undefined
|
||||||
: YGMeasureModeExactly;
|
: MeasureMode::Exactly;
|
||||||
}
|
}
|
||||||
|
|
||||||
float height = YGUndefined;
|
float height = YGUndefined;
|
||||||
YGMeasureMode heightMeasureMode = YGMeasureModeUndefined;
|
MeasureMode heightMeasureMode = MeasureMode::Undefined;
|
||||||
if (styleDefinesDimension(node, YGFlexDirectionColumn, ownerHeight)) {
|
if (styleDefinesDimension(node, YGFlexDirectionColumn, ownerHeight)) {
|
||||||
height = (yoga::resolveValue(
|
height = (yoga::resolveValue(
|
||||||
node->getResolvedDimension(dimension(YGFlexDirectionColumn)),
|
node->getResolvedDimension(dimension(YGFlexDirectionColumn)),
|
||||||
ownerHeight) +
|
ownerHeight) +
|
||||||
node->getMarginForAxis(YGFlexDirectionColumn, ownerWidth))
|
node->getMarginForAxis(YGFlexDirectionColumn, ownerWidth))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
heightMeasureMode = YGMeasureModeExactly;
|
heightMeasureMode = MeasureMode::Exactly;
|
||||||
} else if (!yoga::resolveValue(maxDimensions[YGDimensionHeight], ownerHeight)
|
} else if (!yoga::resolveValue(maxDimensions[YGDimensionHeight], ownerHeight)
|
||||||
.isUndefined()) {
|
.isUndefined()) {
|
||||||
height = yoga::resolveValue(maxDimensions[YGDimensionHeight], ownerHeight)
|
height = yoga::resolveValue(maxDimensions[YGDimensionHeight], ownerHeight)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
heightMeasureMode = YGMeasureModeAtMost;
|
heightMeasureMode = MeasureMode::AtMost;
|
||||||
} else {
|
} else {
|
||||||
height = ownerHeight;
|
height = ownerHeight;
|
||||||
heightMeasureMode = yoga::isUndefined(height) ? YGMeasureModeUndefined
|
heightMeasureMode = yoga::isUndefined(height) ? MeasureMode::Undefined
|
||||||
: YGMeasureModeExactly;
|
: MeasureMode::Exactly;
|
||||||
}
|
}
|
||||||
if (calculateLayoutInternal(
|
if (calculateLayoutInternal(
|
||||||
node,
|
node,
|
||||||
@@ -2737,9 +2737,9 @@ void calculateLayout(
|
|||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (node->getConfig()->shouldPrintTree()) {
|
if (node->getConfig()->shouldPrintTree()) {
|
||||||
YGNodePrint(
|
yoga::print(
|
||||||
node,
|
node,
|
||||||
(YGPrintOptions)(YGPrintOptionsLayout | YGPrintOptionsChildren | YGPrintOptionsStyle));
|
PrintOptions::Layout | PrintOptions::Children | PrintOptions::Style);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@@ -83,7 +83,7 @@ void roundLayoutResultsToPixelGrid(
|
|||||||
if (pointScaleFactor != 0.0f) {
|
if (pointScaleFactor != 0.0f) {
|
||||||
// If a node has a custom measure function we never want to round down its
|
// If a node has a custom measure function we never want to round down its
|
||||||
// size as this could lead to unwanted text truncation.
|
// size as this could lead to unwanted text truncation.
|
||||||
const bool textRounding = node->getNodeType() == YGNodeTypeText;
|
const bool textRounding = node->getNodeType() == NodeType::Text;
|
||||||
|
|
||||||
node->setLayoutPosition(
|
node->setLayoutPosition(
|
||||||
roundValueToPixelGrid(nodeLeft, pointScaleFactor, false, textRounding),
|
roundValueToPixelGrid(nodeLeft, pointScaleFactor, false, textRounding),
|
||||||
|
@@ -41,37 +41,37 @@ bool Config::shouldPrintTree() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Config::setExperimentalFeatureEnabled(
|
void Config::setExperimentalFeatureEnabled(
|
||||||
YGExperimentalFeature feature,
|
ExperimentalFeature feature,
|
||||||
bool enabled) {
|
bool enabled) {
|
||||||
experimentalFeatures_.set(feature, enabled);
|
experimentalFeatures_.set(static_cast<size_t>(feature), enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Config::isExperimentalFeatureEnabled(YGExperimentalFeature feature) const {
|
bool Config::isExperimentalFeatureEnabled(ExperimentalFeature feature) const {
|
||||||
return experimentalFeatures_.test(feature);
|
return experimentalFeatures_.test(static_cast<size_t>(feature));
|
||||||
}
|
}
|
||||||
|
|
||||||
EnumBitset<YGExperimentalFeature> Config::getEnabledExperiments() const {
|
ExperimentalFeatureSet Config::getEnabledExperiments() const {
|
||||||
return experimentalFeatures_;
|
return experimentalFeatures_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Config::setErrata(YGErrata errata) {
|
void Config::setErrata(Errata errata) {
|
||||||
errata_ = errata;
|
errata_ = errata;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Config::addErrata(YGErrata errata) {
|
void Config::addErrata(Errata errata) {
|
||||||
errata_ |= errata;
|
errata_ |= errata;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Config::removeErrata(YGErrata errata) {
|
void Config::removeErrata(Errata errata) {
|
||||||
errata_ &= (~errata);
|
errata_ &= (~errata);
|
||||||
}
|
}
|
||||||
|
|
||||||
YGErrata Config::getErrata() const {
|
Errata Config::getErrata() const {
|
||||||
return errata_;
|
return errata_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Config::hasErrata(YGErrata errata) const {
|
bool Config::hasErrata(Errata errata) const {
|
||||||
return (errata_ & errata) != YGErrataNone;
|
return (errata_ & errata) != Errata::None;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Config::setPointScaleFactor(float pointScaleFactor) {
|
void Config::setPointScaleFactor(float pointScaleFactor) {
|
||||||
@@ -96,10 +96,10 @@ void Config::setLogger(YGLogger logger) {
|
|||||||
|
|
||||||
void Config::log(
|
void Config::log(
|
||||||
const yoga::Node* node,
|
const yoga::Node* node,
|
||||||
YGLogLevel logLevel,
|
LogLevel logLevel,
|
||||||
const char* format,
|
const char* format,
|
||||||
va_list args) const {
|
va_list args) const {
|
||||||
logger_(this, node, logLevel, format, args);
|
logger_(this, node, unscopedEnum(logLevel), format, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Config::setCloneNodeCallback(YGCloneNodeFunc cloneNode) {
|
void Config::setCloneNodeCallback(YGCloneNodeFunc cloneNode) {
|
||||||
|
@@ -7,8 +7,12 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <bitset>
|
||||||
|
|
||||||
#include <yoga/Yoga.h>
|
#include <yoga/Yoga.h>
|
||||||
#include <yoga/bits/EnumBitset.h>
|
#include <yoga/enums/Errata.h>
|
||||||
|
#include <yoga/enums/ExperimentalFeature.h>
|
||||||
|
#include <yoga/enums/LogLevel.h>
|
||||||
|
|
||||||
// Tag struct used to form the opaque YGConfigRef for the public C API
|
// Tag struct used to form the opaque YGConfigRef for the public C API
|
||||||
struct YGConfig {};
|
struct YGConfig {};
|
||||||
@@ -18,6 +22,8 @@ namespace facebook::yoga {
|
|||||||
class Config;
|
class Config;
|
||||||
class Node;
|
class Node;
|
||||||
|
|
||||||
|
using ExperimentalFeatureSet = std::bitset<ordinalCount<ExperimentalFeature>()>;
|
||||||
|
|
||||||
// Whether moving a node from an old to new config should dirty previously
|
// Whether moving a node from an old to new config should dirty previously
|
||||||
// calculated layout results.
|
// calculated layout results.
|
||||||
bool configUpdateInvalidatesLayout(
|
bool configUpdateInvalidatesLayout(
|
||||||
@@ -43,17 +49,15 @@ class YG_EXPORT Config : public ::YGConfig {
|
|||||||
void setShouldPrintTree(bool printTree);
|
void setShouldPrintTree(bool printTree);
|
||||||
bool shouldPrintTree() const;
|
bool shouldPrintTree() const;
|
||||||
|
|
||||||
void setExperimentalFeatureEnabled(
|
void setExperimentalFeatureEnabled(ExperimentalFeature feature, bool enabled);
|
||||||
YGExperimentalFeature feature,
|
bool isExperimentalFeatureEnabled(ExperimentalFeature feature) const;
|
||||||
bool enabled);
|
ExperimentalFeatureSet getEnabledExperiments() const;
|
||||||
bool isExperimentalFeatureEnabled(YGExperimentalFeature feature) const;
|
|
||||||
EnumBitset<YGExperimentalFeature> getEnabledExperiments() const;
|
|
||||||
|
|
||||||
void setErrata(YGErrata errata);
|
void setErrata(Errata errata);
|
||||||
void addErrata(YGErrata errata);
|
void addErrata(Errata errata);
|
||||||
void removeErrata(YGErrata errata);
|
void removeErrata(Errata errata);
|
||||||
YGErrata getErrata() const;
|
Errata getErrata() const;
|
||||||
bool hasErrata(YGErrata errata) const;
|
bool hasErrata(Errata errata) const;
|
||||||
|
|
||||||
void setPointScaleFactor(float pointScaleFactor);
|
void setPointScaleFactor(float pointScaleFactor);
|
||||||
float getPointScaleFactor() const;
|
float getPointScaleFactor() const;
|
||||||
@@ -64,7 +68,7 @@ class YG_EXPORT Config : public ::YGConfig {
|
|||||||
void setLogger(YGLogger logger);
|
void setLogger(YGLogger logger);
|
||||||
void log(
|
void log(
|
||||||
const yoga::Node* node,
|
const yoga::Node* node,
|
||||||
YGLogLevel logLevel,
|
LogLevel logLevel,
|
||||||
const char* format,
|
const char* format,
|
||||||
va_list args) const;
|
va_list args) const;
|
||||||
|
|
||||||
@@ -79,8 +83,8 @@ class YG_EXPORT Config : public ::YGConfig {
|
|||||||
YGLogger logger_;
|
YGLogger logger_;
|
||||||
|
|
||||||
ConfigFlags flags_{};
|
ConfigFlags flags_{};
|
||||||
EnumBitset<YGExperimentalFeature> experimentalFeatures_{};
|
ExperimentalFeatureSet experimentalFeatures_{};
|
||||||
YGErrata errata_ = YGErrataNone;
|
Errata errata_ = Errata::None;
|
||||||
float pointScaleFactor_ = 1.0f;
|
float pointScaleFactor_ = 1.0f;
|
||||||
void* context_ = nullptr;
|
void* context_ = nullptr;
|
||||||
};
|
};
|
||||||
|
@@ -22,7 +22,7 @@ namespace facebook::yoga {
|
|||||||
|
|
||||||
void assertFatal(const bool condition, const char* message) {
|
void assertFatal(const bool condition, const char* message) {
|
||||||
if (!condition) {
|
if (!condition) {
|
||||||
yoga::log(YGLogLevelFatal, "%s\n", message);
|
yoga::log(LogLevel::Fatal, "%s\n", message);
|
||||||
fatalWithMessage(message);
|
fatalWithMessage(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -32,7 +32,7 @@ void assertFatalWithNode(
|
|||||||
const bool condition,
|
const bool condition,
|
||||||
const char* message) {
|
const char* message) {
|
||||||
if (!condition) {
|
if (!condition) {
|
||||||
yoga::log(node, YGLogLevelFatal, "%s\n", message);
|
yoga::log(node, LogLevel::Fatal, "%s\n", message);
|
||||||
fatalWithMessage(message);
|
fatalWithMessage(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -42,7 +42,7 @@ void assertFatalWithConfig(
|
|||||||
const bool condition,
|
const bool condition,
|
||||||
const char* message) {
|
const char* message) {
|
||||||
if (!condition) {
|
if (!condition) {
|
||||||
yoga::log(config, YGLogLevelFatal, "%s\n", message);
|
yoga::log(config, LogLevel::Fatal, "%s\n", message);
|
||||||
fatalWithMessage(message);
|
fatalWithMessage(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -18,18 +18,18 @@ namespace {
|
|||||||
void vlog(
|
void vlog(
|
||||||
const yoga::Config* config,
|
const yoga::Config* config,
|
||||||
const yoga::Node* node,
|
const yoga::Node* node,
|
||||||
YGLogLevel level,
|
LogLevel level,
|
||||||
const char* format,
|
const char* format,
|
||||||
va_list args) {
|
va_list args) {
|
||||||
if (config == nullptr) {
|
if (config == nullptr) {
|
||||||
getDefaultLogger()(nullptr, node, level, format, args);
|
getDefaultLogger()(nullptr, node, unscopedEnum(level), format, args);
|
||||||
} else {
|
} else {
|
||||||
config->log(node, level, format, args);
|
config->log(node, level, format, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void log(YGLogLevel level, const char* format, ...) noexcept {
|
void log(LogLevel level, const char* format, ...) noexcept {
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
vlog(nullptr, nullptr, level, format, args);
|
vlog(nullptr, nullptr, level, format, args);
|
||||||
@@ -38,7 +38,7 @@ void log(YGLogLevel level, const char* format, ...) noexcept {
|
|||||||
|
|
||||||
void log(
|
void log(
|
||||||
const yoga::Node* node,
|
const yoga::Node* node,
|
||||||
YGLogLevel level,
|
LogLevel level,
|
||||||
const char* format,
|
const char* format,
|
||||||
...) noexcept {
|
...) noexcept {
|
||||||
va_list args;
|
va_list args;
|
||||||
@@ -50,7 +50,7 @@ void log(
|
|||||||
|
|
||||||
void log(
|
void log(
|
||||||
const yoga::Config* config,
|
const yoga::Config* config,
|
||||||
YGLogLevel level,
|
LogLevel level,
|
||||||
const char* format,
|
const char* format,
|
||||||
...) noexcept {
|
...) noexcept {
|
||||||
va_list args;
|
va_list args;
|
||||||
|
@@ -9,23 +9,23 @@
|
|||||||
|
|
||||||
#include <yoga/Yoga.h>
|
#include <yoga/Yoga.h>
|
||||||
|
|
||||||
#include <yoga/YGEnums.h>
|
|
||||||
#include <yoga/config/Config.h>
|
#include <yoga/config/Config.h>
|
||||||
|
#include <yoga/enums/LogLevel.h>
|
||||||
#include <yoga/node/Node.h>
|
#include <yoga/node/Node.h>
|
||||||
|
|
||||||
namespace facebook::yoga {
|
namespace facebook::yoga {
|
||||||
|
|
||||||
void log(YGLogLevel level, const char* format, ...) noexcept;
|
void log(LogLevel level, const char* format, ...) noexcept;
|
||||||
|
|
||||||
void log(
|
void log(
|
||||||
const yoga::Node* node,
|
const yoga::Node* node,
|
||||||
YGLogLevel level,
|
LogLevel level,
|
||||||
const char* message,
|
const char* message,
|
||||||
...) noexcept;
|
...) noexcept;
|
||||||
|
|
||||||
void log(
|
void log(
|
||||||
const yoga::Config* config,
|
const yoga::Config* config,
|
||||||
YGLogLevel level,
|
LogLevel level,
|
||||||
const char* format,
|
const char* format,
|
||||||
...) noexcept;
|
...) noexcept;
|
||||||
|
|
||||||
|
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#include <yoga/YGEnums.h>
|
#include <yoga/YGEnums.h>
|
||||||
|
|
||||||
|
#include <yoga/debug/Log.h>
|
||||||
#include <yoga/debug/NodeToString.h>
|
#include <yoga/debug/NodeToString.h>
|
||||||
#include <yoga/numeric/Comparison.h>
|
#include <yoga/numeric/Comparison.h>
|
||||||
|
|
||||||
@@ -118,12 +119,12 @@ static void appendEdgeIfNotUndefined(
|
|||||||
void nodeToString(
|
void nodeToString(
|
||||||
std::string& str,
|
std::string& str,
|
||||||
const yoga::Node* node,
|
const yoga::Node* node,
|
||||||
YGPrintOptions options,
|
PrintOptions options,
|
||||||
uint32_t level) {
|
uint32_t level) {
|
||||||
indent(str, level);
|
indent(str, level);
|
||||||
appendFormattedString(str, "<div ");
|
appendFormattedString(str, "<div ");
|
||||||
|
|
||||||
if (options & YGPrintOptionsLayout) {
|
if ((options & PrintOptions::Layout) == PrintOptions::Layout) {
|
||||||
appendFormattedString(str, "layout=\"");
|
appendFormattedString(str, "layout=\"");
|
||||||
appendFormattedString(
|
appendFormattedString(
|
||||||
str, "width: %g; ", node->getLayout().dimensions[YGDimensionWidth]);
|
str, "width: %g; ", node->getLayout().dimensions[YGDimensionWidth]);
|
||||||
@@ -136,7 +137,7 @@ void nodeToString(
|
|||||||
appendFormattedString(str, "\" ");
|
appendFormattedString(str, "\" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options & YGPrintOptionsStyle) {
|
if ((options & PrintOptions::Style) == PrintOptions::Style) {
|
||||||
appendFormattedString(str, "style=\"");
|
appendFormattedString(str, "style=\"");
|
||||||
const auto& style = node->getStyle();
|
const auto& style = node->getStyle();
|
||||||
if (style.flexDirection() != yoga::Node{}.getStyle().flexDirection()) {
|
if (style.flexDirection() != yoga::Node{}.getStyle().flexDirection()) {
|
||||||
@@ -228,7 +229,8 @@ void nodeToString(
|
|||||||
appendFormattedString(str, ">");
|
appendFormattedString(str, ">");
|
||||||
|
|
||||||
const size_t childCount = node->getChildCount();
|
const size_t childCount = node->getChildCount();
|
||||||
if (options & YGPrintOptionsChildren && childCount > 0) {
|
if ((options & PrintOptions::Children) == PrintOptions::Children &&
|
||||||
|
childCount > 0) {
|
||||||
for (size_t i = 0; i < childCount; i++) {
|
for (size_t i = 0; i < childCount; i++) {
|
||||||
appendFormattedString(str, "\n");
|
appendFormattedString(str, "\n");
|
||||||
nodeToString(str, node->getChild(i), options, level + 1);
|
nodeToString(str, node->getChild(i), options, level + 1);
|
||||||
@@ -239,5 +241,11 @@ void nodeToString(
|
|||||||
appendFormattedString(str, "</div>");
|
appendFormattedString(str, "</div>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void print(const yoga::Node* node, PrintOptions options) {
|
||||||
|
std::string str;
|
||||||
|
yoga::nodeToString(str, node, options, 0);
|
||||||
|
yoga::log(node, LogLevel::Debug, str.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace facebook::yoga
|
} // namespace facebook::yoga
|
||||||
#endif
|
#endif
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <yoga/Yoga.h>
|
#include <yoga/enums/PrintOptions.h>
|
||||||
#include <yoga/node/Node.h>
|
#include <yoga/node/Node.h>
|
||||||
|
|
||||||
namespace facebook::yoga {
|
namespace facebook::yoga {
|
||||||
@@ -19,9 +19,11 @@ namespace facebook::yoga {
|
|||||||
void nodeToString(
|
void nodeToString(
|
||||||
std::string& str,
|
std::string& str,
|
||||||
const yoga::Node* node,
|
const yoga::Node* node,
|
||||||
YGPrintOptions options,
|
PrintOptions options,
|
||||||
uint32_t level);
|
uint32_t level);
|
||||||
|
|
||||||
|
void print(const yoga::Node* node, PrintOptions options);
|
||||||
|
|
||||||
} // namespace facebook::yoga
|
} // namespace facebook::yoga
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
51
yoga/enums/Align.h
Normal file
51
yoga/enums/Align.h
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// @generated by enums.py
|
||||||
|
// clang-format off
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <yoga/YGEnums.h>
|
||||||
|
#include <yoga/enums/YogaEnums.h>
|
||||||
|
|
||||||
|
namespace facebook::yoga {
|
||||||
|
|
||||||
|
enum class Align : uint8_t {
|
||||||
|
Auto = YGAlignAuto,
|
||||||
|
FlexStart = YGAlignFlexStart,
|
||||||
|
Center = YGAlignCenter,
|
||||||
|
FlexEnd = YGAlignFlexEnd,
|
||||||
|
Stretch = YGAlignStretch,
|
||||||
|
Baseline = YGAlignBaseline,
|
||||||
|
SpaceBetween = YGAlignSpaceBetween,
|
||||||
|
SpaceAround = YGAlignSpaceAround,
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
constexpr inline int32_t ordinalCount<Align>() {
|
||||||
|
return 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
constexpr inline int32_t bitCount<Align>() {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr inline Align scopedEnum(YGAlign unscoped) {
|
||||||
|
return static_cast<Align>(unscoped);
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr inline YGAlign unscopedEnum(Align scoped) {
|
||||||
|
return static_cast<YGAlign>(scoped);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const char* toString(Align e) {
|
||||||
|
return YGAlignToString(unscopedEnum(e));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace facebook::yoga
|
45
yoga/enums/Dimension.h
Normal file
45
yoga/enums/Dimension.h
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// @generated by enums.py
|
||||||
|
// clang-format off
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <yoga/YGEnums.h>
|
||||||
|
#include <yoga/enums/YogaEnums.h>
|
||||||
|
|
||||||
|
namespace facebook::yoga {
|
||||||
|
|
||||||
|
enum class Dimension : uint8_t {
|
||||||
|
Width = YGDimensionWidth,
|
||||||
|
Height = YGDimensionHeight,
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
constexpr inline int32_t ordinalCount<Dimension>() {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
constexpr inline int32_t bitCount<Dimension>() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr inline Dimension scopedEnum(YGDimension unscoped) {
|
||||||
|
return static_cast<Dimension>(unscoped);
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr inline YGDimension unscopedEnum(Dimension scoped) {
|
||||||
|
return static_cast<YGDimension>(scoped);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const char* toString(Dimension e) {
|
||||||
|
return YGDimensionToString(unscopedEnum(e));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace facebook::yoga
|
46
yoga/enums/Direction.h
Normal file
46
yoga/enums/Direction.h
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// @generated by enums.py
|
||||||
|
// clang-format off
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <yoga/YGEnums.h>
|
||||||
|
#include <yoga/enums/YogaEnums.h>
|
||||||
|
|
||||||
|
namespace facebook::yoga {
|
||||||
|
|
||||||
|
enum class Direction : uint8_t {
|
||||||
|
Inherit = YGDirectionInherit,
|
||||||
|
LTR = YGDirectionLTR,
|
||||||
|
RTL = YGDirectionRTL,
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
constexpr inline int32_t ordinalCount<Direction>() {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
constexpr inline int32_t bitCount<Direction>() {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr inline Direction scopedEnum(YGDirection unscoped) {
|
||||||
|
return static_cast<Direction>(unscoped);
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr inline YGDirection unscopedEnum(Direction scoped) {
|
||||||
|
return static_cast<YGDirection>(scoped);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const char* toString(Direction e) {
|
||||||
|
return YGDirectionToString(unscopedEnum(e));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace facebook::yoga
|
45
yoga/enums/Display.h
Normal file
45
yoga/enums/Display.h
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// @generated by enums.py
|
||||||
|
// clang-format off
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <yoga/YGEnums.h>
|
||||||
|
#include <yoga/enums/YogaEnums.h>
|
||||||
|
|
||||||
|
namespace facebook::yoga {
|
||||||
|
|
||||||
|
enum class Display : uint8_t {
|
||||||
|
Flex = YGDisplayFlex,
|
||||||
|
None = YGDisplayNone,
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
constexpr inline int32_t ordinalCount<Display>() {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
constexpr inline int32_t bitCount<Display>() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr inline Display scopedEnum(YGDisplay unscoped) {
|
||||||
|
return static_cast<Display>(unscoped);
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr inline YGDisplay unscopedEnum(Display scoped) {
|
||||||
|
return static_cast<YGDisplay>(scoped);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const char* toString(Display e) {
|
||||||
|
return YGDisplayToString(unscopedEnum(e));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace facebook::yoga
|
52
yoga/enums/Edge.h
Normal file
52
yoga/enums/Edge.h
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// @generated by enums.py
|
||||||
|
// clang-format off
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <yoga/YGEnums.h>
|
||||||
|
#include <yoga/enums/YogaEnums.h>
|
||||||
|
|
||||||
|
namespace facebook::yoga {
|
||||||
|
|
||||||
|
enum class Edge : uint8_t {
|
||||||
|
Left = YGEdgeLeft,
|
||||||
|
Top = YGEdgeTop,
|
||||||
|
Right = YGEdgeRight,
|
||||||
|
Bottom = YGEdgeBottom,
|
||||||
|
Start = YGEdgeStart,
|
||||||
|
End = YGEdgeEnd,
|
||||||
|
Horizontal = YGEdgeHorizontal,
|
||||||
|
Vertical = YGEdgeVertical,
|
||||||
|
All = YGEdgeAll,
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
constexpr inline int32_t ordinalCount<Edge>() {
|
||||||
|
return 9;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
constexpr inline int32_t bitCount<Edge>() {
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr inline Edge scopedEnum(YGEdge unscoped) {
|
||||||
|
return static_cast<Edge>(unscoped);
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr inline YGEdge unscopedEnum(Edge scoped) {
|
||||||
|
return static_cast<YGEdge>(scoped);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const char* toString(Edge e) {
|
||||||
|
return YGEdgeToString(unscopedEnum(e));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace facebook::yoga
|
49
yoga/enums/Errata.h
Normal file
49
yoga/enums/Errata.h
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// @generated by enums.py
|
||||||
|
// clang-format off
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <yoga/YGEnums.h>
|
||||||
|
#include <yoga/enums/YogaEnums.h>
|
||||||
|
|
||||||
|
namespace facebook::yoga {
|
||||||
|
|
||||||
|
enum class Errata : uint32_t {
|
||||||
|
None = YGErrataNone,
|
||||||
|
StretchFlexBasis = YGErrataStretchFlexBasis,
|
||||||
|
All = YGErrataAll,
|
||||||
|
Classic = YGErrataClassic,
|
||||||
|
};
|
||||||
|
|
||||||
|
YG_DEFINE_ENUM_FLAG_OPERATORS(Errata)
|
||||||
|
|
||||||
|
template <>
|
||||||
|
constexpr inline int32_t ordinalCount<Errata>() {
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
constexpr inline int32_t bitCount<Errata>() {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr inline Errata scopedEnum(YGErrata unscoped) {
|
||||||
|
return static_cast<Errata>(unscoped);
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr inline YGErrata unscopedEnum(Errata scoped) {
|
||||||
|
return static_cast<YGErrata>(scoped);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const char* toString(Errata e) {
|
||||||
|
return YGErrataToString(unscopedEnum(e));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace facebook::yoga
|
45
yoga/enums/ExperimentalFeature.h
Normal file
45
yoga/enums/ExperimentalFeature.h
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// @generated by enums.py
|
||||||
|
// clang-format off
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <yoga/YGEnums.h>
|
||||||
|
#include <yoga/enums/YogaEnums.h>
|
||||||
|
|
||||||
|
namespace facebook::yoga {
|
||||||
|
|
||||||
|
enum class ExperimentalFeature : uint8_t {
|
||||||
|
WebFlexBasis = YGExperimentalFeatureWebFlexBasis,
|
||||||
|
AbsolutePercentageAgainstPaddingEdge = YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge,
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
constexpr inline int32_t ordinalCount<ExperimentalFeature>() {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
constexpr inline int32_t bitCount<ExperimentalFeature>() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr inline ExperimentalFeature scopedEnum(YGExperimentalFeature unscoped) {
|
||||||
|
return static_cast<ExperimentalFeature>(unscoped);
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr inline YGExperimentalFeature unscopedEnum(ExperimentalFeature scoped) {
|
||||||
|
return static_cast<YGExperimentalFeature>(scoped);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const char* toString(ExperimentalFeature e) {
|
||||||
|
return YGExperimentalFeatureToString(unscopedEnum(e));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace facebook::yoga
|
47
yoga/enums/FlexDirection.h
Normal file
47
yoga/enums/FlexDirection.h
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// @generated by enums.py
|
||||||
|
// clang-format off
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <yoga/YGEnums.h>
|
||||||
|
#include <yoga/enums/YogaEnums.h>
|
||||||
|
|
||||||
|
namespace facebook::yoga {
|
||||||
|
|
||||||
|
enum class FlexDirection : uint8_t {
|
||||||
|
Column = YGFlexDirectionColumn,
|
||||||
|
ColumnReverse = YGFlexDirectionColumnReverse,
|
||||||
|
Row = YGFlexDirectionRow,
|
||||||
|
RowReverse = YGFlexDirectionRowReverse,
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
constexpr inline int32_t ordinalCount<FlexDirection>() {
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
constexpr inline int32_t bitCount<FlexDirection>() {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr inline FlexDirection scopedEnum(YGFlexDirection unscoped) {
|
||||||
|
return static_cast<FlexDirection>(unscoped);
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr inline YGFlexDirection unscopedEnum(FlexDirection scoped) {
|
||||||
|
return static_cast<YGFlexDirection>(scoped);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const char* toString(FlexDirection e) {
|
||||||
|
return YGFlexDirectionToString(unscopedEnum(e));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace facebook::yoga
|
46
yoga/enums/Gutter.h
Normal file
46
yoga/enums/Gutter.h
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// @generated by enums.py
|
||||||
|
// clang-format off
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <yoga/YGEnums.h>
|
||||||
|
#include <yoga/enums/YogaEnums.h>
|
||||||
|
|
||||||
|
namespace facebook::yoga {
|
||||||
|
|
||||||
|
enum class Gutter : uint8_t {
|
||||||
|
Column = YGGutterColumn,
|
||||||
|
Row = YGGutterRow,
|
||||||
|
All = YGGutterAll,
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
constexpr inline int32_t ordinalCount<Gutter>() {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
constexpr inline int32_t bitCount<Gutter>() {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr inline Gutter scopedEnum(YGGutter unscoped) {
|
||||||
|
return static_cast<Gutter>(unscoped);
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr inline YGGutter unscopedEnum(Gutter scoped) {
|
||||||
|
return static_cast<YGGutter>(scoped);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const char* toString(Gutter e) {
|
||||||
|
return YGGutterToString(unscopedEnum(e));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace facebook::yoga
|
49
yoga/enums/Justify.h
Normal file
49
yoga/enums/Justify.h
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// @generated by enums.py
|
||||||
|
// clang-format off
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <yoga/YGEnums.h>
|
||||||
|
#include <yoga/enums/YogaEnums.h>
|
||||||
|
|
||||||
|
namespace facebook::yoga {
|
||||||
|
|
||||||
|
enum class Justify : uint8_t {
|
||||||
|
FlexStart = YGJustifyFlexStart,
|
||||||
|
Center = YGJustifyCenter,
|
||||||
|
FlexEnd = YGJustifyFlexEnd,
|
||||||
|
SpaceBetween = YGJustifySpaceBetween,
|
||||||
|
SpaceAround = YGJustifySpaceAround,
|
||||||
|
SpaceEvenly = YGJustifySpaceEvenly,
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
constexpr inline int32_t ordinalCount<Justify>() {
|
||||||
|
return 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
constexpr inline int32_t bitCount<Justify>() {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr inline Justify scopedEnum(YGJustify unscoped) {
|
||||||
|
return static_cast<Justify>(unscoped);
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr inline YGJustify unscopedEnum(Justify scoped) {
|
||||||
|
return static_cast<YGJustify>(scoped);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const char* toString(Justify e) {
|
||||||
|
return YGJustifyToString(unscopedEnum(e));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace facebook::yoga
|
49
yoga/enums/LogLevel.h
Normal file
49
yoga/enums/LogLevel.h
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// @generated by enums.py
|
||||||
|
// clang-format off
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <yoga/YGEnums.h>
|
||||||
|
#include <yoga/enums/YogaEnums.h>
|
||||||
|
|
||||||
|
namespace facebook::yoga {
|
||||||
|
|
||||||
|
enum class LogLevel : uint8_t {
|
||||||
|
Error = YGLogLevelError,
|
||||||
|
Warn = YGLogLevelWarn,
|
||||||
|
Info = YGLogLevelInfo,
|
||||||
|
Debug = YGLogLevelDebug,
|
||||||
|
Verbose = YGLogLevelVerbose,
|
||||||
|
Fatal = YGLogLevelFatal,
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
constexpr inline int32_t ordinalCount<LogLevel>() {
|
||||||
|
return 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
constexpr inline int32_t bitCount<LogLevel>() {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr inline LogLevel scopedEnum(YGLogLevel unscoped) {
|
||||||
|
return static_cast<LogLevel>(unscoped);
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr inline YGLogLevel unscopedEnum(LogLevel scoped) {
|
||||||
|
return static_cast<YGLogLevel>(scoped);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const char* toString(LogLevel e) {
|
||||||
|
return YGLogLevelToString(unscopedEnum(e));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace facebook::yoga
|
46
yoga/enums/MeasureMode.h
Normal file
46
yoga/enums/MeasureMode.h
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// @generated by enums.py
|
||||||
|
// clang-format off
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <yoga/YGEnums.h>
|
||||||
|
#include <yoga/enums/YogaEnums.h>
|
||||||
|
|
||||||
|
namespace facebook::yoga {
|
||||||
|
|
||||||
|
enum class MeasureMode : uint8_t {
|
||||||
|
Undefined = YGMeasureModeUndefined,
|
||||||
|
Exactly = YGMeasureModeExactly,
|
||||||
|
AtMost = YGMeasureModeAtMost,
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
constexpr inline int32_t ordinalCount<MeasureMode>() {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
constexpr inline int32_t bitCount<MeasureMode>() {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr inline MeasureMode scopedEnum(YGMeasureMode unscoped) {
|
||||||
|
return static_cast<MeasureMode>(unscoped);
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr inline YGMeasureMode unscopedEnum(MeasureMode scoped) {
|
||||||
|
return static_cast<YGMeasureMode>(scoped);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const char* toString(MeasureMode e) {
|
||||||
|
return YGMeasureModeToString(unscopedEnum(e));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace facebook::yoga
|
45
yoga/enums/NodeType.h
Normal file
45
yoga/enums/NodeType.h
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// @generated by enums.py
|
||||||
|
// clang-format off
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <yoga/YGEnums.h>
|
||||||
|
#include <yoga/enums/YogaEnums.h>
|
||||||
|
|
||||||
|
namespace facebook::yoga {
|
||||||
|
|
||||||
|
enum class NodeType : uint8_t {
|
||||||
|
Default = YGNodeTypeDefault,
|
||||||
|
Text = YGNodeTypeText,
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
constexpr inline int32_t ordinalCount<NodeType>() {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
constexpr inline int32_t bitCount<NodeType>() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr inline NodeType scopedEnum(YGNodeType unscoped) {
|
||||||
|
return static_cast<NodeType>(unscoped);
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr inline YGNodeType unscopedEnum(NodeType scoped) {
|
||||||
|
return static_cast<YGNodeType>(scoped);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const char* toString(NodeType e) {
|
||||||
|
return YGNodeTypeToString(unscopedEnum(e));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace facebook::yoga
|
46
yoga/enums/Overflow.h
Normal file
46
yoga/enums/Overflow.h
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// @generated by enums.py
|
||||||
|
// clang-format off
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <yoga/YGEnums.h>
|
||||||
|
#include <yoga/enums/YogaEnums.h>
|
||||||
|
|
||||||
|
namespace facebook::yoga {
|
||||||
|
|
||||||
|
enum class Overflow : uint8_t {
|
||||||
|
Visible = YGOverflowVisible,
|
||||||
|
Hidden = YGOverflowHidden,
|
||||||
|
Scroll = YGOverflowScroll,
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
constexpr inline int32_t ordinalCount<Overflow>() {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
constexpr inline int32_t bitCount<Overflow>() {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr inline Overflow scopedEnum(YGOverflow unscoped) {
|
||||||
|
return static_cast<Overflow>(unscoped);
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr inline YGOverflow unscopedEnum(Overflow scoped) {
|
||||||
|
return static_cast<YGOverflow>(scoped);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const char* toString(Overflow e) {
|
||||||
|
return YGOverflowToString(unscopedEnum(e));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace facebook::yoga
|
46
yoga/enums/PositionType.h
Normal file
46
yoga/enums/PositionType.h
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// @generated by enums.py
|
||||||
|
// clang-format off
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <yoga/YGEnums.h>
|
||||||
|
#include <yoga/enums/YogaEnums.h>
|
||||||
|
|
||||||
|
namespace facebook::yoga {
|
||||||
|
|
||||||
|
enum class PositionType : uint8_t {
|
||||||
|
Static = YGPositionTypeStatic,
|
||||||
|
Relative = YGPositionTypeRelative,
|
||||||
|
Absolute = YGPositionTypeAbsolute,
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
constexpr inline int32_t ordinalCount<PositionType>() {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
constexpr inline int32_t bitCount<PositionType>() {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr inline PositionType scopedEnum(YGPositionType unscoped) {
|
||||||
|
return static_cast<PositionType>(unscoped);
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr inline YGPositionType unscopedEnum(PositionType scoped) {
|
||||||
|
return static_cast<YGPositionType>(scoped);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const char* toString(PositionType e) {
|
||||||
|
return YGPositionTypeToString(unscopedEnum(e));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace facebook::yoga
|
48
yoga/enums/PrintOptions.h
Normal file
48
yoga/enums/PrintOptions.h
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// @generated by enums.py
|
||||||
|
// clang-format off
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <yoga/YGEnums.h>
|
||||||
|
#include <yoga/enums/YogaEnums.h>
|
||||||
|
|
||||||
|
namespace facebook::yoga {
|
||||||
|
|
||||||
|
enum class PrintOptions : uint32_t {
|
||||||
|
Layout = YGPrintOptionsLayout,
|
||||||
|
Style = YGPrintOptionsStyle,
|
||||||
|
Children = YGPrintOptionsChildren,
|
||||||
|
};
|
||||||
|
|
||||||
|
YG_DEFINE_ENUM_FLAG_OPERATORS(PrintOptions)
|
||||||
|
|
||||||
|
template <>
|
||||||
|
constexpr inline int32_t ordinalCount<PrintOptions>() {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
constexpr inline int32_t bitCount<PrintOptions>() {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr inline PrintOptions scopedEnum(YGPrintOptions unscoped) {
|
||||||
|
return static_cast<PrintOptions>(unscoped);
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr inline YGPrintOptions unscopedEnum(PrintOptions scoped) {
|
||||||
|
return static_cast<YGPrintOptions>(scoped);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const char* toString(PrintOptions e) {
|
||||||
|
return YGPrintOptionsToString(unscopedEnum(e));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace facebook::yoga
|
47
yoga/enums/Unit.h
Normal file
47
yoga/enums/Unit.h
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// @generated by enums.py
|
||||||
|
// clang-format off
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <yoga/YGEnums.h>
|
||||||
|
#include <yoga/enums/YogaEnums.h>
|
||||||
|
|
||||||
|
namespace facebook::yoga {
|
||||||
|
|
||||||
|
enum class Unit : uint8_t {
|
||||||
|
Undefined = YGUnitUndefined,
|
||||||
|
Point = YGUnitPoint,
|
||||||
|
Percent = YGUnitPercent,
|
||||||
|
Auto = YGUnitAuto,
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
constexpr inline int32_t ordinalCount<Unit>() {
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
constexpr inline int32_t bitCount<Unit>() {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr inline Unit scopedEnum(YGUnit unscoped) {
|
||||||
|
return static_cast<Unit>(unscoped);
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr inline YGUnit unscopedEnum(Unit scoped) {
|
||||||
|
return static_cast<YGUnit>(scoped);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const char* toString(Unit e) {
|
||||||
|
return YGUnitToString(unscopedEnum(e));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace facebook::yoga
|
46
yoga/enums/Wrap.h
Normal file
46
yoga/enums/Wrap.h
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// @generated by enums.py
|
||||||
|
// clang-format off
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <yoga/YGEnums.h>
|
||||||
|
#include <yoga/enums/YogaEnums.h>
|
||||||
|
|
||||||
|
namespace facebook::yoga {
|
||||||
|
|
||||||
|
enum class Wrap : uint8_t {
|
||||||
|
NoWrap = YGWrapNoWrap,
|
||||||
|
Wrap = YGWrapWrap,
|
||||||
|
WrapReverse = YGWrapWrapReverse,
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
constexpr inline int32_t ordinalCount<Wrap>() {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
constexpr inline int32_t bitCount<Wrap>() {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr inline Wrap scopedEnum(YGWrap unscoped) {
|
||||||
|
return static_cast<Wrap>(unscoped);
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr inline YGWrap unscopedEnum(Wrap scoped) {
|
||||||
|
return static_cast<YGWrap>(scoped);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const char* toString(Wrap e) {
|
||||||
|
return YGWrapToString(unscopedEnum(e));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace facebook::yoga
|
@@ -7,13 +7,12 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <yoga/YGEnums.h>
|
|
||||||
#include <bitset>
|
|
||||||
|
|
||||||
namespace facebook::yoga {
|
namespace facebook::yoga {
|
||||||
|
|
||||||
// std::bitset with one bit for each option defined in YG_ENUM_SEQ_DECL
|
template <typename EnumT>
|
||||||
template <typename Enum>
|
constexpr inline int32_t ordinalCount();
|
||||||
using EnumBitset = std::bitset<enums::count<Enum>()>;
|
|
||||||
|
template <typename EnumT>
|
||||||
|
constexpr inline int32_t bitCount();
|
||||||
|
|
||||||
} // namespace facebook::yoga
|
} // namespace facebook::yoga
|
@@ -10,6 +10,8 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
#include <yoga/Yoga.h>
|
#include <yoga/Yoga.h>
|
||||||
|
|
||||||
|
#include <yoga/enums/MeasureMode.h>
|
||||||
#include <yoga/numeric/Comparison.h>
|
#include <yoga/numeric/Comparison.h>
|
||||||
|
|
||||||
namespace facebook::yoga {
|
namespace facebook::yoga {
|
||||||
@@ -17,8 +19,8 @@ namespace facebook::yoga {
|
|||||||
struct CachedMeasurement {
|
struct CachedMeasurement {
|
||||||
float availableWidth{-1};
|
float availableWidth{-1};
|
||||||
float availableHeight{-1};
|
float availableHeight{-1};
|
||||||
YGMeasureMode widthMeasureMode{YGMeasureModeUndefined};
|
MeasureMode widthMeasureMode{MeasureMode::Undefined};
|
||||||
YGMeasureMode heightMeasureMode{YGMeasureModeUndefined};
|
MeasureMode heightMeasureMode{MeasureMode::Undefined};
|
||||||
|
|
||||||
float computedWidth{-1};
|
float computedWidth{-1};
|
||||||
float computedHeight{-1};
|
float computedHeight{-1};
|
||||||
|
@@ -211,10 +211,11 @@ FloatOptional Node::getGapForAxis(
|
|||||||
|
|
||||||
YGSize Node::measure(
|
YGSize Node::measure(
|
||||||
float width,
|
float width,
|
||||||
YGMeasureMode widthMode,
|
MeasureMode widthMode,
|
||||||
float height,
|
float height,
|
||||||
YGMeasureMode heightMode) {
|
MeasureMode heightMode) {
|
||||||
return measureFunc_(this, width, widthMode, height, heightMode);
|
return measureFunc_(
|
||||||
|
this, width, unscopedEnum(widthMode), height, unscopedEnum(heightMode));
|
||||||
}
|
}
|
||||||
|
|
||||||
float Node::baseline(float width, float height) const {
|
float Node::baseline(float width, float height) const {
|
||||||
@@ -227,7 +228,7 @@ void Node::setMeasureFunc(YGMeasureFunc measureFunc) {
|
|||||||
if (measureFunc == nullptr) {
|
if (measureFunc == nullptr) {
|
||||||
// TODO: t18095186 Move nodeType to opt-in function and mark appropriate
|
// TODO: t18095186 Move nodeType to opt-in function and mark appropriate
|
||||||
// places in Litho
|
// places in Litho
|
||||||
setNodeType(YGNodeTypeDefault);
|
setNodeType(NodeType::Default);
|
||||||
} else {
|
} else {
|
||||||
yoga::assertFatalWithNode(
|
yoga::assertFatalWithNode(
|
||||||
this,
|
this,
|
||||||
@@ -236,7 +237,7 @@ void Node::setMeasureFunc(YGMeasureFunc measureFunc) {
|
|||||||
"children.");
|
"children.");
|
||||||
// TODO: t18095186 Move nodeType to opt-in function and mark appropriate
|
// TODO: t18095186 Move nodeType to opt-in function and mark appropriate
|
||||||
// places in Litho
|
// places in Litho
|
||||||
setNodeType(YGNodeTypeText);
|
setNodeType(NodeType::Text);
|
||||||
}
|
}
|
||||||
|
|
||||||
measureFunc_ = measureFunc;
|
measureFunc_ = measureFunc;
|
||||||
|
@@ -14,6 +14,9 @@
|
|||||||
#include <yoga/Yoga.h>
|
#include <yoga/Yoga.h>
|
||||||
|
|
||||||
#include <yoga/config/Config.h>
|
#include <yoga/config/Config.h>
|
||||||
|
#include <yoga/enums/Errata.h>
|
||||||
|
#include <yoga/enums/MeasureMode.h>
|
||||||
|
#include <yoga/enums/NodeType.h>
|
||||||
#include <yoga/node/LayoutResults.h>
|
#include <yoga/node/LayoutResults.h>
|
||||||
#include <yoga/style/CompactValue.h>
|
#include <yoga/style/CompactValue.h>
|
||||||
#include <yoga/style/Style.h>
|
#include <yoga/style/Style.h>
|
||||||
@@ -29,7 +32,7 @@ struct NodeFlags {
|
|||||||
bool hasNewLayout : 1;
|
bool hasNewLayout : 1;
|
||||||
bool isReferenceBaseline : 1;
|
bool isReferenceBaseline : 1;
|
||||||
bool isDirty : 1;
|
bool isDirty : 1;
|
||||||
uint32_t nodeType : 1;
|
NodeType nodeType : bitCount<NodeType>();
|
||||||
};
|
};
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
@@ -92,15 +95,15 @@ class YG_EXPORT Node : public ::YGNode {
|
|||||||
return flags_.hasNewLayout;
|
return flags_.hasNewLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
YGNodeType getNodeType() const {
|
NodeType getNodeType() const {
|
||||||
return static_cast<YGNodeType>(flags_.nodeType);
|
return flags_.nodeType;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasMeasureFunc() const noexcept {
|
bool hasMeasureFunc() const noexcept {
|
||||||
return measureFunc_ != nullptr;
|
return measureFunc_ != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
YGSize measure(float, YGMeasureMode, float, YGMeasureMode);
|
YGSize measure(float, MeasureMode, float, MeasureMode);
|
||||||
|
|
||||||
bool hasBaselineFunc() const noexcept {
|
bool hasBaselineFunc() const noexcept {
|
||||||
return baselineFunc_ != nullptr;
|
return baselineFunc_ != nullptr;
|
||||||
@@ -108,7 +111,7 @@ class YG_EXPORT Node : public ::YGNode {
|
|||||||
|
|
||||||
float baseline(float width, float height) const;
|
float baseline(float width, float height) const;
|
||||||
|
|
||||||
bool hasErrata(YGErrata errata) const {
|
bool hasErrata(Errata errata) const {
|
||||||
return config_->hasErrata(errata);
|
return config_->hasErrata(errata);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,8 +253,8 @@ class YG_EXPORT Node : public ::YGNode {
|
|||||||
flags_.hasNewLayout = hasNewLayout;
|
flags_.hasNewLayout = hasNewLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setNodeType(YGNodeType nodeType) {
|
void setNodeType(NodeType nodeType) {
|
||||||
flags_.nodeType = static_cast<uint32_t>(nodeType) & 0x01;
|
flags_.nodeType = nodeType;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMeasureFunc(YGMeasureFunc measureFunc);
|
void setMeasureFunc(YGMeasureFunc measureFunc);
|
||||||
|
Reference in New Issue
Block a user