mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Revert D48710084: C++ Cleanup 1/N: Reorganize YGStyle
Differential Revision: D48710084 Original commit changeset: 20961aee30d5 Original Phabricator Diff: D48710084 fbshipit-source-id: 79cda4f13979b8d0cdf87dabbfc13cbd17abe488
This commit is contained in:
committed by
Facebook GitHub Bot
parent
53df1d3fa8
commit
796cdea6fa
@@ -142,7 +142,7 @@ MapBuffer convertBorderRadii(CascadedBorderRadii const &radii) {
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
MapBuffer convertBorderWidths(yoga::Style::Edges const &border) {
|
||||
MapBuffer convertBorderWidths(YGStyle::Edges const &border) {
|
||||
MapBufferBuilder builder(7);
|
||||
putOptionalFloat(
|
||||
builder, EDGE_TOP, optionalFloatFromYogaValue(border[YGEdgeTop]));
|
||||
|
||||
+5
-5
@@ -11,9 +11,9 @@
|
||||
|
||||
#include <fbjni/fbjni.h>
|
||||
|
||||
#include <yoga/CompactValue.h>
|
||||
#include <yoga/YGEnums.h>
|
||||
#include <yoga/YGValue.h>
|
||||
#include <yoga/style/CompactValue.h>
|
||||
|
||||
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
||||
|
||||
@@ -38,7 +38,7 @@ class AndroidTextInputComponentDescriptor final
|
||||
ShadowNodeFamily::Shared const &family) const override {
|
||||
int surfaceId = family->getSurfaceId();
|
||||
|
||||
yoga::Style::Edges theme;
|
||||
YGStyle::Edges theme;
|
||||
// TODO: figure out RTL/start/end/left/right stuff here
|
||||
if (surfaceIdToThemePaddingMap_.find(surfaceId) !=
|
||||
surfaceIdToThemePaddingMap_.end()) {
|
||||
@@ -97,7 +97,7 @@ class AndroidTextInputComponentDescriptor final
|
||||
int surfaceId = textInputShadowNode.getSurfaceId();
|
||||
if (surfaceIdToThemePaddingMap_.find(surfaceId) !=
|
||||
surfaceIdToThemePaddingMap_.end()) {
|
||||
yoga::Style::Edges theme = surfaceIdToThemePaddingMap_[surfaceId];
|
||||
YGStyle::Edges theme = surfaceIdToThemePaddingMap_[surfaceId];
|
||||
|
||||
auto &textInputProps = textInputShadowNode.getConcreteProps();
|
||||
|
||||
@@ -106,7 +106,7 @@ class AndroidTextInputComponentDescriptor final
|
||||
// TODO: T62959168 account for RTL and paddingLeft when setting default
|
||||
// paddingStart, and vice-versa with paddingRight/paddingEnd.
|
||||
// For now this assumes no RTL.
|
||||
yoga::Style::Edges result = textInputProps.yogaStyle.padding();
|
||||
YGStyle::Edges result = textInputProps.yogaStyle.padding();
|
||||
bool changedPadding = false;
|
||||
if (!textInputProps.hasPadding && !textInputProps.hasPaddingStart &&
|
||||
!textInputProps.hasPaddingLeft &&
|
||||
@@ -171,7 +171,7 @@ class AndroidTextInputComponentDescriptor final
|
||||
"com/facebook/react/fabric/FabricUIManager";
|
||||
|
||||
SharedTextLayoutManager textLayoutManager_;
|
||||
mutable butter::map<int, yoga::Style::Edges> surfaceIdToThemePaddingMap_;
|
||||
mutable butter::map<int, YGStyle::Edges> surfaceIdToThemePaddingMap_;
|
||||
};
|
||||
|
||||
} // namespace facebook::react
|
||||
|
||||
@@ -60,7 +60,7 @@ void ViewShadowNode::initialize() noexcept {
|
||||
|
||||
bool formsView = formsStackingContext ||
|
||||
isColorMeaningful(viewProps.backgroundColor) ||
|
||||
!(viewProps.yogaStyle.border() == yoga::Style::Edges{}) ||
|
||||
!(viewProps.yogaStyle.border() == YGStyle::Edges{}) ||
|
||||
!viewProps.testId.empty() ||
|
||||
HostPlatformViewTraitsInitializer::formsView(viewProps);
|
||||
|
||||
|
||||
+7
-7
@@ -378,10 +378,10 @@ void YogaLayoutableShadowNode::updateYogaProps() {
|
||||
yogaNode_.setStyle(styleResult);
|
||||
}
|
||||
|
||||
/*static*/ yoga::Style YogaLayoutableShadowNode::applyAliasedProps(
|
||||
const yoga::Style &baseStyle,
|
||||
/*static*/ YGStyle YogaLayoutableShadowNode::applyAliasedProps(
|
||||
const YGStyle &baseStyle,
|
||||
const YogaStylableProps &props) {
|
||||
yoga::Style result{baseStyle};
|
||||
YGStyle result{baseStyle};
|
||||
|
||||
// Aliases with precedence
|
||||
if (!props.inset.isUndefined()) {
|
||||
@@ -864,9 +864,9 @@ void YogaLayoutableShadowNode::swapLeftAndRightInYogaStyleProps(
|
||||
YogaLayoutableShadowNode const &shadowNode) {
|
||||
auto yogaStyle = shadowNode.yogaNode_.getStyle();
|
||||
|
||||
yoga::Style::Edges const &position = yogaStyle.position();
|
||||
yoga::Style::Edges const &padding = yogaStyle.padding();
|
||||
yoga::Style::Edges const &margin = yogaStyle.margin();
|
||||
YGStyle::Edges const &position = yogaStyle.position();
|
||||
YGStyle::Edges const &padding = yogaStyle.padding();
|
||||
YGStyle::Edges const &margin = yogaStyle.margin();
|
||||
|
||||
// Swap Yoga node values, position, padding and margin.
|
||||
|
||||
@@ -950,7 +950,7 @@ void YogaLayoutableShadowNode::swapLeftAndRightInViewProps(
|
||||
props.borderStyles.right.reset();
|
||||
}
|
||||
|
||||
yoga::Style::Edges const &border = props.yogaStyle.border();
|
||||
YGStyle::Edges const &border = props.yogaStyle.border();
|
||||
|
||||
if (props.yogaStyle.border()[YGEdgeLeft] != YGValueUndefined) {
|
||||
props.yogaStyle.border()[YGEdgeStart] = border[YGEdgeLeft];
|
||||
|
||||
+5
-5
@@ -22,7 +22,7 @@
|
||||
namespace facebook::react {
|
||||
|
||||
class YogaLayoutableShadowNode : public LayoutableShadowNode {
|
||||
using CompactValue = facebook::yoga::CompactValue;
|
||||
using CompactValue = facebook::yoga::detail::CompactValue;
|
||||
|
||||
public:
|
||||
using Shared = std::shared_ptr<YogaLayoutableShadowNode const>;
|
||||
@@ -202,11 +202,11 @@ class YogaLayoutableShadowNode : public LayoutableShadowNode {
|
||||
YogaLayoutableShadowNode const &shadowNode);
|
||||
|
||||
/*
|
||||
* Combine a base yoga::Style with aliased properties which should be
|
||||
* flattened into it. E.g. reconciling "marginInlineStart" and "marginStart".
|
||||
* Combine a base YGStyle with aliased properties which should be flattened
|
||||
* into it. E.g. reconciling "marginInlineStart" and "marginStart".
|
||||
*/
|
||||
static yoga::Style applyAliasedProps(
|
||||
const yoga::Style &baseStyle,
|
||||
static YGStyle applyAliasedProps(
|
||||
const YGStyle &baseStyle,
|
||||
const YogaStylableProps &props);
|
||||
|
||||
#pragma mark - Consistency Ensuring Helpers
|
||||
|
||||
+2
-2
@@ -104,7 +104,7 @@ void YogaStylableProps::setProp(
|
||||
RawPropsPropNameHash hash,
|
||||
const char *propName,
|
||||
RawValue const &value) {
|
||||
static const auto ygDefaults = yoga::Style{};
|
||||
static const auto ygDefaults = YGStyle{};
|
||||
static const auto defaults = YogaStylableProps{};
|
||||
|
||||
Props::setProp(context, hash, propName, value);
|
||||
@@ -161,7 +161,7 @@ void YogaStylableProps::setProp(
|
||||
|
||||
#if RN_DEBUG_STRING_CONVERTIBLE
|
||||
SharedDebugStringConvertibleList YogaStylableProps::getDebugProps() const {
|
||||
auto const defaultYogaStyle = yoga::Style{};
|
||||
auto const defaultYogaStyle = YGStyle{};
|
||||
return {
|
||||
debugStringConvertibleItem(
|
||||
"direction", yogaStyle.direction(), defaultYogaStyle.direction()),
|
||||
|
||||
+3
-3
@@ -7,7 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <yoga/style/Style.h>
|
||||
#include <yoga/YGStyle.h>
|
||||
|
||||
#include <react/renderer/core/Props.h>
|
||||
#include <react/renderer/core/PropsParserContext.h>
|
||||
@@ -16,7 +16,7 @@
|
||||
namespace facebook::react {
|
||||
|
||||
class YogaStylableProps : public Props {
|
||||
using CompactValue = facebook::yoga::CompactValue;
|
||||
using CompactValue = facebook::yoga::detail::CompactValue;
|
||||
|
||||
public:
|
||||
YogaStylableProps() = default;
|
||||
@@ -38,7 +38,7 @@ class YogaStylableProps : public Props {
|
||||
#endif
|
||||
|
||||
#pragma mark - Props
|
||||
yoga::Style yogaStyle{};
|
||||
YGStyle yogaStyle{};
|
||||
|
||||
// Duplicates of existing properties with different names, taking
|
||||
// precedence. E.g. "marginBlock" instead of "marginVertical"
|
||||
|
||||
@@ -406,7 +406,7 @@ inline void fromRawValue(
|
||||
inline void fromRawValue(
|
||||
const PropsParserContext &context,
|
||||
const RawValue &value,
|
||||
yoga::Style::ValueRepr &result) {
|
||||
YGStyle::ValueRepr &result) {
|
||||
if (value.hasType<Float>()) {
|
||||
result = yogaStyleValueFromFloat((Float)value);
|
||||
return;
|
||||
@@ -440,7 +440,7 @@ inline void fromRawValue(
|
||||
const PropsParserContext &context,
|
||||
const RawValue &value,
|
||||
YGValue &result) {
|
||||
yoga::Style::ValueRepr ygValue{};
|
||||
YGStyle::ValueRepr ygValue{};
|
||||
fromRawValue(context, value, ygValue);
|
||||
result = ygValue;
|
||||
}
|
||||
@@ -826,11 +826,11 @@ inline std::string toString(const YGFloatOptional &value) {
|
||||
return folly::to<std::string>(floatFromYogaFloat(value.unwrap()));
|
||||
}
|
||||
|
||||
inline std::string toString(const yoga::Style::Dimensions &value) {
|
||||
inline std::string toString(const YGStyle::Dimensions &value) {
|
||||
return "{" + toString(value[0]) + ", " + toString(value[1]) + "}";
|
||||
}
|
||||
|
||||
inline std::string toString(const yoga::Style::Edges &value) {
|
||||
inline std::string toString(const YGStyle::Edges &value) {
|
||||
static std::array<std::string, yoga::enums::count<YGEdge>()> names = {
|
||||
{"left",
|
||||
"top",
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
|
||||
namespace facebook::react {
|
||||
|
||||
MapBuffer convertBorderWidths(yoga::Style::Edges const &border) {
|
||||
MapBuffer convertBorderWidths(YGStyle::Edges const &border) {
|
||||
MapBufferBuilder builder(7);
|
||||
putOptionalFloat(
|
||||
builder, EDGE_TOP, optionalFloatFromYogaValue(border[YGEdgeTop]));
|
||||
|
||||
+12
-12
@@ -17,13 +17,13 @@ namespace facebook::react {
|
||||
|
||||
// Nearly this entire file can be deleted when iterator-style Prop parsing
|
||||
// ships fully for View
|
||||
static inline yoga::Style::Dimensions convertRawProp(
|
||||
static inline YGStyle::Dimensions convertRawProp(
|
||||
const PropsParserContext &context,
|
||||
RawProps const &rawProps,
|
||||
char const *widthName,
|
||||
char const *heightName,
|
||||
yoga::Style::Dimensions const &sourceValue,
|
||||
yoga::Style::Dimensions const &defaultValue) {
|
||||
YGStyle::Dimensions const &sourceValue,
|
||||
YGStyle::Dimensions const &defaultValue) {
|
||||
auto dimensions = defaultValue;
|
||||
dimensions[YGDimensionWidth] = convertRawProp(
|
||||
context,
|
||||
@@ -40,13 +40,13 @@ static inline yoga::Style::Dimensions convertRawProp(
|
||||
return dimensions;
|
||||
}
|
||||
|
||||
static inline yoga::Style::Edges convertRawProp(
|
||||
static inline YGStyle::Edges convertRawProp(
|
||||
const PropsParserContext &context,
|
||||
RawProps const &rawProps,
|
||||
char const *prefix,
|
||||
char const *suffix,
|
||||
yoga::Style::Edges const &sourceValue,
|
||||
yoga::Style::Edges const &defaultValue) {
|
||||
YGStyle::Edges const &sourceValue,
|
||||
YGStyle::Edges const &defaultValue) {
|
||||
auto result = defaultValue;
|
||||
result[YGEdgeLeft] = convertRawProp(
|
||||
context,
|
||||
@@ -123,11 +123,11 @@ static inline yoga::Style::Edges convertRawProp(
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline yoga::Style::Edges convertRawProp(
|
||||
static inline YGStyle::Edges convertRawProp(
|
||||
const PropsParserContext &context,
|
||||
RawProps const &rawProps,
|
||||
yoga::Style::Edges const &sourceValue,
|
||||
yoga::Style::Edges const &defaultValue) {
|
||||
YGStyle::Edges const &sourceValue,
|
||||
YGStyle::Edges const &defaultValue) {
|
||||
auto result = defaultValue;
|
||||
result[YGEdgeLeft] = convertRawProp(
|
||||
context,
|
||||
@@ -168,11 +168,11 @@ static inline yoga::Style::Edges convertRawProp(
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline yoga::Style convertRawProp(
|
||||
static inline YGStyle convertRawProp(
|
||||
const PropsParserContext &context,
|
||||
RawProps const &rawProps,
|
||||
yoga::Style const &sourceValue) {
|
||||
auto yogaStyle = yoga::Style{};
|
||||
YGStyle const &sourceValue) {
|
||||
auto yogaStyle = YGStyle{};
|
||||
yogaStyle.direction() = convertRawProp(
|
||||
context,
|
||||
rawProps,
|
||||
|
||||
@@ -50,7 +50,6 @@ Pod::Spec.new do |spec|
|
||||
source_files = 'yoga/**/*.{cpp,h}'
|
||||
source_files = File.join('ReactCommon/yoga', source_files) if ENV['INSTALL_YOGA_WITHOUT_PATH_OPTION']
|
||||
spec.source_files = source_files
|
||||
spec.header_mappings_dir = 'yoga'
|
||||
|
||||
public_header_files = 'yoga/{Yoga,YGEnums,YGMacros,YGValue}.h'
|
||||
public_header_files = File.join('ReactCommon/yoga', public_header_files) if ENV['INSTALL_YOGA_WITHOUT_PATH_OPTION']
|
||||
|
||||
+2
-2
@@ -38,7 +38,7 @@ static_assert(
|
||||
#define VISIBLE_FOR_TESTING private:
|
||||
#endif
|
||||
|
||||
namespace facebook::yoga {
|
||||
namespace facebook::yoga::detail {
|
||||
|
||||
// This class stores YGValue in 32 bits.
|
||||
// - The value does not matter for Undefined and Auto. NaNs are used for their
|
||||
@@ -207,4 +207,4 @@ constexpr bool operator!=(CompactValue a, CompactValue b) noexcept {
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
} // namespace facebook::yoga
|
||||
} // namespace facebook::yoga::detail
|
||||
@@ -8,8 +8,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "YGNode.h"
|
||||
#include <yoga/Yoga-internal.h>
|
||||
#include <yoga/style/CompactValue.h>
|
||||
#include "Yoga-internal.h"
|
||||
#include "CompactValue.h"
|
||||
|
||||
// This struct is an helper model to hold the data for step 4 of flexbox algo,
|
||||
// which is collecting the flex items in a line.
|
||||
@@ -56,8 +56,8 @@ struct YGCollectFlexItemsRowValues {
|
||||
|
||||
bool YGValueEqual(const YGValue& a, const YGValue& b);
|
||||
inline bool YGValueEqual(
|
||||
facebook::yoga::CompactValue a,
|
||||
facebook::yoga::CompactValue b) {
|
||||
facebook::yoga::detail::CompactValue a,
|
||||
facebook::yoga::detail::CompactValue b) {
|
||||
return YGValueEqual((YGValue) a, (YGValue) b);
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ inline YGFloatOptional YGResolveValue(
|
||||
}
|
||||
|
||||
inline YGFloatOptional YGResolveValue(
|
||||
facebook::yoga::CompactValue value,
|
||||
facebook::yoga::detail::CompactValue value,
|
||||
float ownerSize) {
|
||||
return YGResolveValue((YGValue) value, ownerSize);
|
||||
}
|
||||
@@ -140,7 +140,7 @@ inline YGFlexDirection YGResolveFlexDirection(
|
||||
}
|
||||
|
||||
inline YGFloatOptional YGResolveValueMargin(
|
||||
facebook::yoga::CompactValue value,
|
||||
facebook::yoga::detail::CompactValue value,
|
||||
const float ownerSize) {
|
||||
return value.isAuto() ? YGFloatOptional{0} : YGResolveValue(value, ownerSize);
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
|
||||
#include <yoga/Yoga.h>
|
||||
|
||||
#include <yoga/BitUtils.h>
|
||||
#include <yoga/Yoga-internal.h>
|
||||
#include "BitUtils.h"
|
||||
#include "Yoga-internal.h"
|
||||
|
||||
namespace facebook::yoga {
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
#include <yoga/Yoga-internal.h>
|
||||
#include "Yoga-internal.h"
|
||||
|
||||
struct YGFloatOptional {
|
||||
private:
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <yoga/BitUtils.h>
|
||||
#include <yoga/YGFloatOptional.h>
|
||||
#include <yoga/Yoga-internal.h>
|
||||
#include "BitUtils.h"
|
||||
#include "YGFloatOptional.h"
|
||||
#include "Yoga-internal.h"
|
||||
|
||||
struct YGLayout {
|
||||
std::array<float, 4> position = {};
|
||||
|
||||
@@ -11,8 +11,7 @@
|
||||
#include "Utils.h"
|
||||
|
||||
using namespace facebook;
|
||||
using namespace facebook::yoga;
|
||||
using facebook::yoga::CompactValue;
|
||||
using facebook::yoga::detail::CompactValue;
|
||||
|
||||
YGNode::YGNode(const YGConfigRef config) : config_{config} {
|
||||
YGAssert(
|
||||
@@ -54,7 +53,7 @@ void YGNode::print(void* printContext) {
|
||||
}
|
||||
|
||||
CompactValue YGNode::computeEdgeValueForRow(
|
||||
const Style::Edges& edges,
|
||||
const YGStyle::Edges& edges,
|
||||
YGEdge rowEdge,
|
||||
YGEdge edge,
|
||||
CompactValue defaultValue) {
|
||||
@@ -72,7 +71,7 @@ CompactValue YGNode::computeEdgeValueForRow(
|
||||
}
|
||||
|
||||
CompactValue YGNode::computeEdgeValueForColumn(
|
||||
const Style::Edges& edges,
|
||||
const YGStyle::Edges& edges,
|
||||
YGEdge edge,
|
||||
CompactValue defaultValue) {
|
||||
if (!edges[edge].isUndefined()) {
|
||||
@@ -87,7 +86,7 @@ CompactValue YGNode::computeEdgeValueForColumn(
|
||||
}
|
||||
|
||||
CompactValue YGNode::computeRowGap(
|
||||
const Style::Gutters& gutters,
|
||||
const YGStyle::Gutters& gutters,
|
||||
CompactValue defaultValue) {
|
||||
if (!gutters[YGGutterRow].isUndefined()) {
|
||||
return gutters[YGGutterRow];
|
||||
@@ -99,7 +98,7 @@ CompactValue YGNode::computeRowGap(
|
||||
}
|
||||
|
||||
CompactValue YGNode::computeColumnGap(
|
||||
const Style::Gutters& gutters,
|
||||
const YGStyle::Gutters& gutters,
|
||||
CompactValue defaultValue) {
|
||||
if (!gutters[YGGutterColumn].isUndefined()) {
|
||||
return gutters[YGGutterColumn];
|
||||
@@ -432,7 +431,7 @@ YGValue YGNode::resolveFlexBasisPtr() const {
|
||||
|
||||
void YGNode::resolveDimension() {
|
||||
using namespace yoga;
|
||||
const Style& style = getStyle();
|
||||
const YGStyle& style = getStyle();
|
||||
for (auto dim : {YGDimensionWidth, YGDimensionHeight}) {
|
||||
if (!style.maxDimensions()[dim].isUndefined() &&
|
||||
YGValueEqual(style.maxDimensions()[dim], style.minDimensions()[dim])) {
|
||||
|
||||
@@ -9,12 +9,11 @@
|
||||
|
||||
#include <cstdint>
|
||||
#include <stdio.h>
|
||||
#include "CompactValue.h"
|
||||
#include "YGConfig.h"
|
||||
#include "YGLayout.h"
|
||||
#include <yoga/Yoga-internal.h>
|
||||
|
||||
#include <yoga/style/CompactValue.h>
|
||||
#include <yoga/style/Style.h>
|
||||
#include "YGStyle.h"
|
||||
#include "Yoga-internal.h"
|
||||
|
||||
YGConfigRef YGConfigGetDefault();
|
||||
|
||||
@@ -53,7 +52,7 @@ private:
|
||||
PrintWithContextFn withContext;
|
||||
} print_ = {nullptr};
|
||||
YGDirtiedFunc dirtied_ = nullptr;
|
||||
facebook::yoga::Style style_ = {};
|
||||
YGStyle style_ = {};
|
||||
YGLayout layout_ = {};
|
||||
uint32_t lineIndex_ = 0;
|
||||
YGNodeRef owner_ = nullptr;
|
||||
@@ -81,7 +80,7 @@ private:
|
||||
// DO NOT CHANGE THE VISIBILITY OF THIS METHOD!
|
||||
YGNode& operator=(YGNode&&) = default;
|
||||
|
||||
using CompactValue = facebook::yoga::CompactValue;
|
||||
using CompactValue = facebook::yoga::detail::CompactValue;
|
||||
|
||||
public:
|
||||
YGNode() : YGNode{YGConfigGetDefault()} { flags_.hasNewLayout = true; }
|
||||
@@ -124,9 +123,9 @@ public:
|
||||
YGDirtiedFunc getDirtied() const { return dirtied_; }
|
||||
|
||||
// For Performance reasons passing as reference.
|
||||
facebook::yoga::Style& getStyle() { return style_; }
|
||||
YGStyle& getStyle() { return style_; }
|
||||
|
||||
const facebook::yoga::Style& getStyle() const { return style_; }
|
||||
const YGStyle& getStyle() const { return style_; }
|
||||
|
||||
// For Performance reasons passing as reference.
|
||||
YGLayout& getLayout() { return layout_; }
|
||||
@@ -179,22 +178,22 @@ public:
|
||||
}
|
||||
|
||||
static CompactValue computeEdgeValueForColumn(
|
||||
const facebook::yoga::Style::Edges& edges,
|
||||
const YGStyle::Edges& edges,
|
||||
YGEdge edge,
|
||||
CompactValue defaultValue);
|
||||
|
||||
static CompactValue computeEdgeValueForRow(
|
||||
const facebook::yoga::Style::Edges& edges,
|
||||
const YGStyle::Edges& edges,
|
||||
YGEdge rowEdge,
|
||||
YGEdge edge,
|
||||
CompactValue defaultValue);
|
||||
|
||||
static CompactValue computeRowGap(
|
||||
const facebook::yoga::Style::Gutters& gutters,
|
||||
const YGStyle::Gutters& gutters,
|
||||
CompactValue defaultValue);
|
||||
|
||||
static CompactValue computeColumnGap(
|
||||
const facebook::yoga::Style::Gutters& gutters,
|
||||
const YGStyle::Gutters& gutters,
|
||||
CompactValue defaultValue);
|
||||
|
||||
// Methods related to positions, margin, padding and border
|
||||
@@ -274,7 +273,7 @@ public:
|
||||
|
||||
void setDirtiedFunc(YGDirtiedFunc dirtiedFunc) { dirtied_ = dirtiedFunc; }
|
||||
|
||||
void setStyle(const facebook::yoga::Style& style) { style_ = style; }
|
||||
void setStyle(const YGStyle& style) { style_ = style; }
|
||||
|
||||
void setLayout(const YGLayout& layout) { layout_ = layout; }
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
#include "YGNodePrint.h"
|
||||
#include "YGNode.h"
|
||||
#include <yoga/Yoga-internal.h>
|
||||
#include "Yoga-internal.h"
|
||||
#include "Utils.h"
|
||||
|
||||
namespace facebook::yoga {
|
||||
@@ -25,7 +25,7 @@ static void indent(string& base, uint32_t level) {
|
||||
}
|
||||
}
|
||||
|
||||
static bool areFourValuesEqual(const Style::Edges& four) {
|
||||
static bool areFourValuesEqual(const YGStyle::Edges& four) {
|
||||
return YGValueEqual(four[0], four[1]) && YGValueEqual(four[0], four[2]) &&
|
||||
YGValueEqual(four[0], four[3]);
|
||||
}
|
||||
@@ -90,10 +90,10 @@ static void appendNumberIfNotZero(
|
||||
static void appendEdges(
|
||||
string& base,
|
||||
const string& key,
|
||||
const Style::Edges& edges) {
|
||||
const YGStyle::Edges& edges) {
|
||||
if (areFourValuesEqual(edges)) {
|
||||
auto edgeValue = YGNode::computeEdgeValueForColumn(
|
||||
edges, YGEdgeLeft, CompactValue::ofZero());
|
||||
edges, YGEdgeLeft, detail::CompactValue::ofZero());
|
||||
appendNumberIfNotZero(base, key, edgeValue);
|
||||
} else {
|
||||
for (int edge = YGEdgeLeft; edge != YGEdgeAll; ++edge) {
|
||||
@@ -106,14 +106,14 @@ static void appendEdges(
|
||||
static void appendEdgeIfNotUndefined(
|
||||
string& base,
|
||||
const string& str,
|
||||
const Style::Edges& edges,
|
||||
const YGStyle::Edges& edges,
|
||||
const YGEdge edge) {
|
||||
// TODO: this doesn't take RTL / YGEdgeStart / YGEdgeEnd into account
|
||||
auto value = (edge == YGEdgeLeft || edge == YGEdgeRight)
|
||||
? YGNode::computeEdgeValueForRow(
|
||||
edges, edge, edge, CompactValue::ofUndefined())
|
||||
edges, edge, edge, detail::CompactValue::ofUndefined())
|
||||
: YGNode::computeEdgeValueForColumn(
|
||||
edges, edge, CompactValue::ofUndefined());
|
||||
edges, edge, detail::CompactValue::ofUndefined());
|
||||
appendNumberIfNotUndefined(base, str, value);
|
||||
}
|
||||
|
||||
@@ -188,15 +188,17 @@ void YGNodeToString(
|
||||
appendEdges(str, "padding", style.padding());
|
||||
appendEdges(str, "border", style.border());
|
||||
|
||||
if (YGNode::computeColumnGap(style.gap(), CompactValue::ofUndefined()) !=
|
||||
if (YGNode::computeColumnGap(
|
||||
style.gap(), detail::CompactValue::ofUndefined()) !=
|
||||
YGNode::computeColumnGap(
|
||||
YGNode().getStyle().gap(), CompactValue::ofUndefined())) {
|
||||
YGNode().getStyle().gap(), detail::CompactValue::ofUndefined())) {
|
||||
appendNumberIfNotUndefined(
|
||||
str, "column-gap", style.gap()[YGGutterColumn]);
|
||||
}
|
||||
if (YGNode::computeRowGap(style.gap(), CompactValue::ofUndefined()) !=
|
||||
if (YGNode::computeRowGap(
|
||||
style.gap(), detail::CompactValue::ofUndefined()) !=
|
||||
YGNode::computeRowGap(
|
||||
YGNode().getStyle().gap(), CompactValue::ofUndefined())) {
|
||||
YGNode().getStyle().gap(), detail::CompactValue::ofUndefined())) {
|
||||
appendNumberIfNotUndefined(str, "row-gap", style.gap()[YGGutterRow]);
|
||||
}
|
||||
|
||||
|
||||
+3
-7
@@ -5,13 +5,11 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include <yoga/style/Style.h>
|
||||
#include <yoga/Utils.h>
|
||||
|
||||
namespace facebook::yoga {
|
||||
#include "YGStyle.h"
|
||||
#include "Utils.h"
|
||||
|
||||
// Yoga specific properties, not compatible with flexbox specification
|
||||
bool operator==(const Style& lhs, const Style& rhs) {
|
||||
bool operator==(const YGStyle& lhs, const YGStyle& rhs) {
|
||||
bool areNonFloatValuesEqual = lhs.direction() == rhs.direction() &&
|
||||
lhs.flexDirection() == rhs.flexDirection() &&
|
||||
lhs.justifyContent() == rhs.justifyContent() &&
|
||||
@@ -56,5 +54,3 @@ bool operator==(const Style& lhs, const Style& rhs) {
|
||||
|
||||
return areNonFloatValuesEqual;
|
||||
}
|
||||
|
||||
} // namespace facebook::yoga
|
||||
+31
-32
@@ -13,17 +13,17 @@
|
||||
#include <type_traits>
|
||||
|
||||
#include <yoga/Yoga.h>
|
||||
#include <yoga/YGFloatOptional.h>
|
||||
#include <yoga/Yoga-internal.h>
|
||||
#include <yoga/BitUtils.h>
|
||||
|
||||
#include <yoga/style/CompactValue.h>
|
||||
#include "CompactValue.h"
|
||||
#include "YGFloatOptional.h"
|
||||
#include "Yoga-internal.h"
|
||||
#include "BitUtils.h"
|
||||
|
||||
namespace facebook::yoga {
|
||||
|
||||
class YOGA_EXPORT Style {
|
||||
class YOGA_EXPORT YGStyle {
|
||||
template <typename Enum>
|
||||
using Values = detail::Values<enums::count<Enum>()>;
|
||||
using Values =
|
||||
facebook::yoga::detail::Values<facebook::yoga::enums::count<Enum>()>;
|
||||
using CompactValue = facebook::yoga::detail::CompactValue;
|
||||
|
||||
public:
|
||||
using Dimensions = Values<YGDimension>;
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
|
||||
template <typename T>
|
||||
struct BitfieldRef {
|
||||
Style& style;
|
||||
YGStyle& style;
|
||||
size_t offset;
|
||||
operator T() const {
|
||||
return facebook::yoga::detail::getEnumData<T>(style.flags, offset);
|
||||
@@ -43,9 +43,9 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, T Style::*Prop>
|
||||
template <typename T, T YGStyle::*Prop>
|
||||
struct Ref {
|
||||
Style& style;
|
||||
YGStyle& style;
|
||||
operator T() const { return style.*Prop; }
|
||||
Ref<T, Prop>& operator=(T value) {
|
||||
style.*Prop = value;
|
||||
@@ -53,10 +53,10 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Idx, Values<Idx> Style::*Prop>
|
||||
template <typename Idx, Values<Idx> YGStyle::*Prop>
|
||||
struct IdxRef {
|
||||
struct Ref {
|
||||
Style& style;
|
||||
YGStyle& style;
|
||||
Idx idx;
|
||||
operator CompactValue() const { return (style.*Prop)[idx]; }
|
||||
operator YGValue() const { return (style.*Prop)[idx]; }
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
Style& style;
|
||||
YGStyle& style;
|
||||
IdxRef<Idx, Prop>& operator=(const Values<Idx>& values) {
|
||||
style.*Prop = values;
|
||||
return *this;
|
||||
@@ -76,11 +76,11 @@ public:
|
||||
CompactValue operator[](Idx idx) const { return (style.*Prop)[idx]; }
|
||||
};
|
||||
|
||||
Style() {
|
||||
YGStyle() {
|
||||
alignContent() = YGAlignFlexStart;
|
||||
alignItems() = YGAlignStretch;
|
||||
}
|
||||
~Style() = default;
|
||||
~YGStyle() = default;
|
||||
|
||||
private:
|
||||
static constexpr size_t directionOffset = 0;
|
||||
@@ -188,52 +188,51 @@ public:
|
||||
BitfieldRef<YGDisplay> display() { return {*this, displayOffset}; }
|
||||
|
||||
YGFloatOptional flex() const { return flex_; }
|
||||
Ref<YGFloatOptional, &Style::flex_> flex() { return {*this}; }
|
||||
Ref<YGFloatOptional, &YGStyle::flex_> flex() { return {*this}; }
|
||||
|
||||
YGFloatOptional flexGrow() const { return flexGrow_; }
|
||||
Ref<YGFloatOptional, &Style::flexGrow_> flexGrow() { return {*this}; }
|
||||
Ref<YGFloatOptional, &YGStyle::flexGrow_> flexGrow() { return {*this}; }
|
||||
|
||||
YGFloatOptional flexShrink() const { return flexShrink_; }
|
||||
Ref<YGFloatOptional, &Style::flexShrink_> flexShrink() { return {*this}; }
|
||||
Ref<YGFloatOptional, &YGStyle::flexShrink_> flexShrink() { return {*this}; }
|
||||
|
||||
CompactValue flexBasis() const { return flexBasis_; }
|
||||
Ref<CompactValue, &Style::flexBasis_> flexBasis() { return {*this}; }
|
||||
Ref<CompactValue, &YGStyle::flexBasis_> flexBasis() { return {*this}; }
|
||||
|
||||
const Edges& margin() const { return margin_; }
|
||||
IdxRef<YGEdge, &Style::margin_> margin() { return {*this}; }
|
||||
IdxRef<YGEdge, &YGStyle::margin_> margin() { return {*this}; }
|
||||
|
||||
const Edges& position() const { return position_; }
|
||||
IdxRef<YGEdge, &Style::position_> position() { return {*this}; }
|
||||
IdxRef<YGEdge, &YGStyle::position_> position() { return {*this}; }
|
||||
|
||||
const Edges& padding() const { return padding_; }
|
||||
IdxRef<YGEdge, &Style::padding_> padding() { return {*this}; }
|
||||
IdxRef<YGEdge, &YGStyle::padding_> padding() { return {*this}; }
|
||||
|
||||
const Edges& border() const { return border_; }
|
||||
IdxRef<YGEdge, &Style::border_> border() { return {*this}; }
|
||||
IdxRef<YGEdge, &YGStyle::border_> border() { return {*this}; }
|
||||
|
||||
const Gutters& gap() const { return gap_; }
|
||||
IdxRef<YGGutter, &Style::gap_> gap() { return {*this}; }
|
||||
IdxRef<YGGutter, &YGStyle::gap_> gap() { return {*this}; }
|
||||
|
||||
const Dimensions& dimensions() const { return dimensions_; }
|
||||
IdxRef<YGDimension, &Style::dimensions_> dimensions() { return {*this}; }
|
||||
IdxRef<YGDimension, &YGStyle::dimensions_> dimensions() { return {*this}; }
|
||||
|
||||
const Dimensions& minDimensions() const { return minDimensions_; }
|
||||
IdxRef<YGDimension, &Style::minDimensions_> minDimensions() {
|
||||
IdxRef<YGDimension, &YGStyle::minDimensions_> minDimensions() {
|
||||
return {*this};
|
||||
}
|
||||
|
||||
const Dimensions& maxDimensions() const { return maxDimensions_; }
|
||||
IdxRef<YGDimension, &Style::maxDimensions_> maxDimensions() {
|
||||
IdxRef<YGDimension, &YGStyle::maxDimensions_> maxDimensions() {
|
||||
return {*this};
|
||||
}
|
||||
|
||||
// Yoga specific properties, not compatible with flexbox specification
|
||||
YGFloatOptional aspectRatio() const { return aspectRatio_; }
|
||||
Ref<YGFloatOptional, &Style::aspectRatio_> aspectRatio() { return {*this}; }
|
||||
Ref<YGFloatOptional, &YGStyle::aspectRatio_> aspectRatio() { return {*this}; }
|
||||
};
|
||||
|
||||
YOGA_EXPORT bool operator==(const Style& lhs, const Style& rhs);
|
||||
YOGA_EXPORT inline bool operator!=(const Style& lhs, const Style& rhs) {
|
||||
YOGA_EXPORT bool operator==(const YGStyle& lhs, const YGStyle& rhs);
|
||||
YOGA_EXPORT inline bool operator!=(const YGStyle& lhs, const YGStyle& rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
} // namespace facebook::yoga
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
#include <yoga/Yoga.h>
|
||||
|
||||
#include <yoga/style/CompactValue.h>
|
||||
#include "CompactValue.h"
|
||||
|
||||
using YGVector = std::vector<YGNodeRef>;
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "Utils.h"
|
||||
#include "YGNode.h"
|
||||
#include "YGNodePrint.h"
|
||||
#include <yoga/Yoga-internal.h>
|
||||
#include "Yoga-internal.h"
|
||||
#include "event/event.h"
|
||||
|
||||
using namespace facebook::yoga;
|
||||
@@ -480,25 +480,26 @@ void updateStyle(
|
||||
}
|
||||
|
||||
template <typename Ref, typename T>
|
||||
void updateStyle(YGNode* node, Ref (Style::*prop)(), T value) {
|
||||
void updateStyle(YGNode* node, Ref (YGStyle::*prop)(), T value) {
|
||||
updateStyle(
|
||||
node,
|
||||
value,
|
||||
[prop](Style& s, T x) { return (s.*prop)() != x; },
|
||||
[prop](Style& s, T x) { (s.*prop)() = x; });
|
||||
[prop](YGStyle& s, T x) { return (s.*prop)() != x; },
|
||||
[prop](YGStyle& s, T x) { (s.*prop)() = x; });
|
||||
}
|
||||
|
||||
template <typename Ref, typename Idx>
|
||||
void updateIndexedStyleProp(
|
||||
YGNode* node,
|
||||
Ref (Style::*prop)(),
|
||||
Ref (YGStyle::*prop)(),
|
||||
Idx idx,
|
||||
CompactValue value) {
|
||||
detail::CompactValue value) {
|
||||
using detail::CompactValue;
|
||||
updateStyle(
|
||||
node,
|
||||
value,
|
||||
[idx, prop](Style& s, CompactValue x) { return (s.*prop)()[idx] != x; },
|
||||
[idx, prop](Style& s, CompactValue x) { (s.*prop)()[idx] = x; });
|
||||
[idx, prop](YGStyle& s, CompactValue x) { return (s.*prop)()[idx] != x; },
|
||||
[idx, prop](YGStyle& s, CompactValue x) { (s.*prop)()[idx] = x; });
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -508,12 +509,12 @@ void updateIndexedStyleProp(
|
||||
// overload like clang and GCC. For the purposes of updateStyle(), we can help
|
||||
// MSVC by specifying that return type explicitly. In combination with
|
||||
// decltype, MSVC will prefer the non-const version.
|
||||
#define MSVC_HINT(PROP) decltype(Style{}.PROP())
|
||||
#define MSVC_HINT(PROP) decltype(YGStyle{}.PROP())
|
||||
|
||||
YOGA_EXPORT void YGNodeStyleSetDirection(
|
||||
const YGNodeRef node,
|
||||
const YGDirection value) {
|
||||
updateStyle<MSVC_HINT(direction)>(node, &Style::direction, value);
|
||||
updateStyle<MSVC_HINT(direction)>(node, &YGStyle::direction, value);
|
||||
}
|
||||
YOGA_EXPORT YGDirection YGNodeStyleGetDirection(const YGNodeConstRef node) {
|
||||
return node->getStyle().direction();
|
||||
@@ -523,7 +524,7 @@ YOGA_EXPORT void YGNodeStyleSetFlexDirection(
|
||||
const YGNodeRef node,
|
||||
const YGFlexDirection flexDirection) {
|
||||
updateStyle<MSVC_HINT(flexDirection)>(
|
||||
node, &Style::flexDirection, flexDirection);
|
||||
node, &YGStyle::flexDirection, flexDirection);
|
||||
}
|
||||
YOGA_EXPORT YGFlexDirection
|
||||
YGNodeStyleGetFlexDirection(const YGNodeConstRef node) {
|
||||
@@ -534,7 +535,7 @@ YOGA_EXPORT void YGNodeStyleSetJustifyContent(
|
||||
const YGNodeRef node,
|
||||
const YGJustify justifyContent) {
|
||||
updateStyle<MSVC_HINT(justifyContent)>(
|
||||
node, &Style::justifyContent, justifyContent);
|
||||
node, &YGStyle::justifyContent, justifyContent);
|
||||
}
|
||||
YOGA_EXPORT YGJustify YGNodeStyleGetJustifyContent(const YGNodeConstRef node) {
|
||||
return node->getStyle().justifyContent();
|
||||
@@ -544,7 +545,7 @@ YOGA_EXPORT void YGNodeStyleSetAlignContent(
|
||||
const YGNodeRef node,
|
||||
const YGAlign alignContent) {
|
||||
updateStyle<MSVC_HINT(alignContent)>(
|
||||
node, &Style::alignContent, alignContent);
|
||||
node, &YGStyle::alignContent, alignContent);
|
||||
}
|
||||
YOGA_EXPORT YGAlign YGNodeStyleGetAlignContent(const YGNodeConstRef node) {
|
||||
return node->getStyle().alignContent();
|
||||
@@ -553,7 +554,7 @@ YOGA_EXPORT YGAlign YGNodeStyleGetAlignContent(const YGNodeConstRef node) {
|
||||
YOGA_EXPORT void YGNodeStyleSetAlignItems(
|
||||
const YGNodeRef node,
|
||||
const YGAlign alignItems) {
|
||||
updateStyle<MSVC_HINT(alignItems)>(node, &Style::alignItems, alignItems);
|
||||
updateStyle<MSVC_HINT(alignItems)>(node, &YGStyle::alignItems, alignItems);
|
||||
}
|
||||
YOGA_EXPORT YGAlign YGNodeStyleGetAlignItems(const YGNodeConstRef node) {
|
||||
return node->getStyle().alignItems();
|
||||
@@ -562,7 +563,7 @@ YOGA_EXPORT YGAlign YGNodeStyleGetAlignItems(const YGNodeConstRef node) {
|
||||
YOGA_EXPORT void YGNodeStyleSetAlignSelf(
|
||||
const YGNodeRef node,
|
||||
const YGAlign alignSelf) {
|
||||
updateStyle<MSVC_HINT(alignSelf)>(node, &Style::alignSelf, alignSelf);
|
||||
updateStyle<MSVC_HINT(alignSelf)>(node, &YGStyle::alignSelf, alignSelf);
|
||||
}
|
||||
YOGA_EXPORT YGAlign YGNodeStyleGetAlignSelf(const YGNodeConstRef node) {
|
||||
return node->getStyle().alignSelf();
|
||||
@@ -572,7 +573,7 @@ YOGA_EXPORT void YGNodeStyleSetPositionType(
|
||||
const YGNodeRef node,
|
||||
const YGPositionType positionType) {
|
||||
updateStyle<MSVC_HINT(positionType)>(
|
||||
node, &Style::positionType, positionType);
|
||||
node, &YGStyle::positionType, positionType);
|
||||
}
|
||||
YOGA_EXPORT YGPositionType
|
||||
YGNodeStyleGetPositionType(const YGNodeConstRef node) {
|
||||
@@ -582,7 +583,7 @@ YGNodeStyleGetPositionType(const YGNodeConstRef node) {
|
||||
YOGA_EXPORT void YGNodeStyleSetFlexWrap(
|
||||
const YGNodeRef node,
|
||||
const YGWrap flexWrap) {
|
||||
updateStyle<MSVC_HINT(flexWrap)>(node, &Style::flexWrap, flexWrap);
|
||||
updateStyle<MSVC_HINT(flexWrap)>(node, &YGStyle::flexWrap, flexWrap);
|
||||
}
|
||||
YOGA_EXPORT YGWrap YGNodeStyleGetFlexWrap(const YGNodeConstRef node) {
|
||||
return node->getStyle().flexWrap();
|
||||
@@ -591,7 +592,7 @@ YOGA_EXPORT YGWrap YGNodeStyleGetFlexWrap(const YGNodeConstRef node) {
|
||||
YOGA_EXPORT void YGNodeStyleSetOverflow(
|
||||
const YGNodeRef node,
|
||||
const YGOverflow overflow) {
|
||||
updateStyle<MSVC_HINT(overflow)>(node, &Style::overflow, overflow);
|
||||
updateStyle<MSVC_HINT(overflow)>(node, &YGStyle::overflow, overflow);
|
||||
}
|
||||
YOGA_EXPORT YGOverflow YGNodeStyleGetOverflow(const YGNodeConstRef node) {
|
||||
return node->getStyle().overflow();
|
||||
@@ -600,7 +601,7 @@ YOGA_EXPORT YGOverflow YGNodeStyleGetOverflow(const YGNodeConstRef node) {
|
||||
YOGA_EXPORT void YGNodeStyleSetDisplay(
|
||||
const YGNodeRef node,
|
||||
const YGDisplay display) {
|
||||
updateStyle<MSVC_HINT(display)>(node, &Style::display, display);
|
||||
updateStyle<MSVC_HINT(display)>(node, &YGStyle::display, display);
|
||||
}
|
||||
YOGA_EXPORT YGDisplay YGNodeStyleGetDisplay(const YGNodeConstRef node) {
|
||||
return node->getStyle().display();
|
||||
@@ -608,7 +609,7 @@ YOGA_EXPORT YGDisplay YGNodeStyleGetDisplay(const YGNodeConstRef node) {
|
||||
|
||||
// TODO(T26792433): Change the API to accept YGFloatOptional.
|
||||
YOGA_EXPORT void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) {
|
||||
updateStyle<MSVC_HINT(flex)>(node, &Style::flex, YGFloatOptional{flex});
|
||||
updateStyle<MSVC_HINT(flex)>(node, &YGStyle::flex, YGFloatOptional{flex});
|
||||
}
|
||||
|
||||
// TODO(T26792433): Change the API to accept YGFloatOptional.
|
||||
@@ -623,7 +624,7 @@ YOGA_EXPORT void YGNodeStyleSetFlexGrow(
|
||||
const YGNodeRef node,
|
||||
const float flexGrow) {
|
||||
updateStyle<MSVC_HINT(flexGrow)>(
|
||||
node, &Style::flexGrow, YGFloatOptional{flexGrow});
|
||||
node, &YGStyle::flexGrow, YGFloatOptional{flexGrow});
|
||||
}
|
||||
|
||||
// TODO(T26792433): Change the API to accept YGFloatOptional.
|
||||
@@ -631,7 +632,7 @@ YOGA_EXPORT void YGNodeStyleSetFlexShrink(
|
||||
const YGNodeRef node,
|
||||
const float flexShrink) {
|
||||
updateStyle<MSVC_HINT(flexShrink)>(
|
||||
node, &Style::flexShrink, YGFloatOptional{flexShrink});
|
||||
node, &YGStyle::flexShrink, YGFloatOptional{flexShrink});
|
||||
}
|
||||
|
||||
YOGA_EXPORT YGValue YGNodeStyleGetFlexBasis(const YGNodeConstRef node) {
|
||||
@@ -646,37 +647,37 @@ YOGA_EXPORT YGValue YGNodeStyleGetFlexBasis(const YGNodeConstRef node) {
|
||||
YOGA_EXPORT void YGNodeStyleSetFlexBasis(
|
||||
const YGNodeRef node,
|
||||
const float flexBasis) {
|
||||
auto value = CompactValue::ofMaybe<YGUnitPoint>(flexBasis);
|
||||
updateStyle<MSVC_HINT(flexBasis)>(node, &Style::flexBasis, value);
|
||||
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(flexBasis);
|
||||
updateStyle<MSVC_HINT(flexBasis)>(node, &YGStyle::flexBasis, value);
|
||||
}
|
||||
|
||||
YOGA_EXPORT void YGNodeStyleSetFlexBasisPercent(
|
||||
const YGNodeRef node,
|
||||
const float flexBasisPercent) {
|
||||
auto value = CompactValue::ofMaybe<YGUnitPercent>(flexBasisPercent);
|
||||
updateStyle<MSVC_HINT(flexBasis)>(node, &Style::flexBasis, value);
|
||||
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(flexBasisPercent);
|
||||
updateStyle<MSVC_HINT(flexBasis)>(node, &YGStyle::flexBasis, value);
|
||||
}
|
||||
|
||||
YOGA_EXPORT void YGNodeStyleSetFlexBasisAuto(const YGNodeRef node) {
|
||||
updateStyle<MSVC_HINT(flexBasis)>(
|
||||
node, &Style::flexBasis, CompactValue::ofAuto());
|
||||
node, &YGStyle::flexBasis, detail::CompactValue::ofAuto());
|
||||
}
|
||||
|
||||
YOGA_EXPORT void YGNodeStyleSetPosition(
|
||||
YGNodeRef node,
|
||||
YGEdge edge,
|
||||
float points) {
|
||||
auto value = CompactValue::ofMaybe<YGUnitPoint>(points);
|
||||
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(points);
|
||||
updateIndexedStyleProp<MSVC_HINT(position)>(
|
||||
node, &Style::position, edge, value);
|
||||
node, &YGStyle::position, edge, value);
|
||||
}
|
||||
YOGA_EXPORT void YGNodeStyleSetPositionPercent(
|
||||
YGNodeRef node,
|
||||
YGEdge edge,
|
||||
float percent) {
|
||||
auto value = CompactValue::ofMaybe<YGUnitPercent>(percent);
|
||||
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(percent);
|
||||
updateIndexedStyleProp<MSVC_HINT(position)>(
|
||||
node, &Style::position, edge, value);
|
||||
node, &YGStyle::position, edge, value);
|
||||
}
|
||||
YOGA_EXPORT YGValue YGNodeStyleGetPosition(YGNodeConstRef node, YGEdge edge) {
|
||||
return node->getStyle().position()[edge];
|
||||
@@ -686,19 +687,21 @@ YOGA_EXPORT void YGNodeStyleSetMargin(
|
||||
YGNodeRef node,
|
||||
YGEdge edge,
|
||||
float points) {
|
||||
auto value = CompactValue::ofMaybe<YGUnitPoint>(points);
|
||||
updateIndexedStyleProp<MSVC_HINT(margin)>(node, &Style::margin, edge, value);
|
||||
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(points);
|
||||
updateIndexedStyleProp<MSVC_HINT(margin)>(
|
||||
node, &YGStyle::margin, edge, value);
|
||||
}
|
||||
YOGA_EXPORT void YGNodeStyleSetMarginPercent(
|
||||
YGNodeRef node,
|
||||
YGEdge edge,
|
||||
float percent) {
|
||||
auto value = CompactValue::ofMaybe<YGUnitPercent>(percent);
|
||||
updateIndexedStyleProp<MSVC_HINT(margin)>(node, &Style::margin, edge, value);
|
||||
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(percent);
|
||||
updateIndexedStyleProp<MSVC_HINT(margin)>(
|
||||
node, &YGStyle::margin, edge, value);
|
||||
}
|
||||
YOGA_EXPORT void YGNodeStyleSetMarginAuto(YGNodeRef node, YGEdge edge) {
|
||||
updateIndexedStyleProp<MSVC_HINT(margin)>(
|
||||
node, &Style::margin, edge, CompactValue::ofAuto());
|
||||
node, &YGStyle::margin, edge, detail::CompactValue::ofAuto());
|
||||
}
|
||||
YOGA_EXPORT YGValue YGNodeStyleGetMargin(YGNodeConstRef node, YGEdge edge) {
|
||||
return node->getStyle().margin()[edge];
|
||||
@@ -708,17 +711,17 @@ YOGA_EXPORT void YGNodeStyleSetPadding(
|
||||
YGNodeRef node,
|
||||
YGEdge edge,
|
||||
float points) {
|
||||
auto value = CompactValue::ofMaybe<YGUnitPoint>(points);
|
||||
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(points);
|
||||
updateIndexedStyleProp<MSVC_HINT(padding)>(
|
||||
node, &Style::padding, edge, value);
|
||||
node, &YGStyle::padding, edge, value);
|
||||
}
|
||||
YOGA_EXPORT void YGNodeStyleSetPaddingPercent(
|
||||
YGNodeRef node,
|
||||
YGEdge edge,
|
||||
float percent) {
|
||||
auto value = CompactValue::ofMaybe<YGUnitPercent>(percent);
|
||||
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(percent);
|
||||
updateIndexedStyleProp<MSVC_HINT(padding)>(
|
||||
node, &Style::padding, edge, value);
|
||||
node, &YGStyle::padding, edge, value);
|
||||
}
|
||||
YOGA_EXPORT YGValue YGNodeStyleGetPadding(YGNodeConstRef node, YGEdge edge) {
|
||||
return node->getStyle().padding()[edge];
|
||||
@@ -729,8 +732,9 @@ YOGA_EXPORT void YGNodeStyleSetBorder(
|
||||
const YGNodeRef node,
|
||||
const YGEdge edge,
|
||||
const float border) {
|
||||
auto value = CompactValue::ofMaybe<YGUnitPoint>(border);
|
||||
updateIndexedStyleProp<MSVC_HINT(border)>(node, &Style::border, edge, value);
|
||||
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(border);
|
||||
updateIndexedStyleProp<MSVC_HINT(border)>(
|
||||
node, &YGStyle::border, edge, value);
|
||||
}
|
||||
|
||||
YOGA_EXPORT float YGNodeStyleGetBorder(
|
||||
@@ -750,8 +754,8 @@ YOGA_EXPORT void YGNodeStyleSetGap(
|
||||
const YGNodeRef node,
|
||||
const YGGutter gutter,
|
||||
const float gapLength) {
|
||||
auto length = CompactValue::ofMaybe<YGUnitPoint>(gapLength);
|
||||
updateIndexedStyleProp<MSVC_HINT(gap)>(node, &Style::gap, gutter, length);
|
||||
auto length = detail::CompactValue::ofMaybe<YGUnitPoint>(gapLength);
|
||||
updateIndexedStyleProp<MSVC_HINT(gap)>(node, &YGStyle::gap, gutter, length);
|
||||
}
|
||||
|
||||
YOGA_EXPORT float YGNodeStyleGetGap(
|
||||
@@ -780,40 +784,46 @@ YOGA_EXPORT void YGNodeStyleSetAspectRatio(
|
||||
const YGNodeRef node,
|
||||
const float aspectRatio) {
|
||||
updateStyle<MSVC_HINT(aspectRatio)>(
|
||||
node, &Style::aspectRatio, YGFloatOptional{aspectRatio});
|
||||
node, &YGStyle::aspectRatio, YGFloatOptional{aspectRatio});
|
||||
}
|
||||
|
||||
YOGA_EXPORT void YGNodeStyleSetWidth(YGNodeRef node, float points) {
|
||||
auto value = CompactValue::ofMaybe<YGUnitPoint>(points);
|
||||
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(points);
|
||||
updateIndexedStyleProp<MSVC_HINT(dimensions)>(
|
||||
node, &Style::dimensions, YGDimensionWidth, value);
|
||||
node, &YGStyle::dimensions, YGDimensionWidth, value);
|
||||
}
|
||||
YOGA_EXPORT void YGNodeStyleSetWidthPercent(YGNodeRef node, float percent) {
|
||||
auto value = CompactValue::ofMaybe<YGUnitPercent>(percent);
|
||||
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(percent);
|
||||
updateIndexedStyleProp<MSVC_HINT(dimensions)>(
|
||||
node, &Style::dimensions, YGDimensionWidth, value);
|
||||
node, &YGStyle::dimensions, YGDimensionWidth, value);
|
||||
}
|
||||
YOGA_EXPORT void YGNodeStyleSetWidthAuto(YGNodeRef node) {
|
||||
updateIndexedStyleProp<MSVC_HINT(dimensions)>(
|
||||
node, &Style::dimensions, YGDimensionWidth, CompactValue::ofAuto());
|
||||
node,
|
||||
&YGStyle::dimensions,
|
||||
YGDimensionWidth,
|
||||
detail::CompactValue::ofAuto());
|
||||
}
|
||||
YOGA_EXPORT YGValue YGNodeStyleGetWidth(YGNodeConstRef node) {
|
||||
return node->getStyle().dimensions()[YGDimensionWidth];
|
||||
}
|
||||
|
||||
YOGA_EXPORT void YGNodeStyleSetHeight(YGNodeRef node, float points) {
|
||||
auto value = CompactValue::ofMaybe<YGUnitPoint>(points);
|
||||
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(points);
|
||||
updateIndexedStyleProp<MSVC_HINT(dimensions)>(
|
||||
node, &Style::dimensions, YGDimensionHeight, value);
|
||||
node, &YGStyle::dimensions, YGDimensionHeight, value);
|
||||
}
|
||||
YOGA_EXPORT void YGNodeStyleSetHeightPercent(YGNodeRef node, float percent) {
|
||||
auto value = CompactValue::ofMaybe<YGUnitPercent>(percent);
|
||||
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(percent);
|
||||
updateIndexedStyleProp<MSVC_HINT(dimensions)>(
|
||||
node, &Style::dimensions, YGDimensionHeight, value);
|
||||
node, &YGStyle::dimensions, YGDimensionHeight, value);
|
||||
}
|
||||
YOGA_EXPORT void YGNodeStyleSetHeightAuto(YGNodeRef node) {
|
||||
updateIndexedStyleProp<MSVC_HINT(dimensions)>(
|
||||
node, &Style::dimensions, YGDimensionHeight, CompactValue::ofAuto());
|
||||
node,
|
||||
&YGStyle::dimensions,
|
||||
YGDimensionHeight,
|
||||
detail::CompactValue::ofAuto());
|
||||
}
|
||||
YOGA_EXPORT YGValue YGNodeStyleGetHeight(YGNodeConstRef node) {
|
||||
return node->getStyle().dimensions()[YGDimensionHeight];
|
||||
@@ -822,16 +832,16 @@ YOGA_EXPORT YGValue YGNodeStyleGetHeight(YGNodeConstRef node) {
|
||||
YOGA_EXPORT void YGNodeStyleSetMinWidth(
|
||||
const YGNodeRef node,
|
||||
const float minWidth) {
|
||||
auto value = CompactValue::ofMaybe<YGUnitPoint>(minWidth);
|
||||
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(minWidth);
|
||||
updateIndexedStyleProp<MSVC_HINT(minDimensions)>(
|
||||
node, &Style::minDimensions, YGDimensionWidth, value);
|
||||
node, &YGStyle::minDimensions, YGDimensionWidth, value);
|
||||
}
|
||||
YOGA_EXPORT void YGNodeStyleSetMinWidthPercent(
|
||||
const YGNodeRef node,
|
||||
const float minWidth) {
|
||||
auto value = CompactValue::ofMaybe<YGUnitPercent>(minWidth);
|
||||
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(minWidth);
|
||||
updateIndexedStyleProp<MSVC_HINT(minDimensions)>(
|
||||
node, &Style::minDimensions, YGDimensionWidth, value);
|
||||
node, &YGStyle::minDimensions, YGDimensionWidth, value);
|
||||
}
|
||||
YOGA_EXPORT YGValue YGNodeStyleGetMinWidth(const YGNodeConstRef node) {
|
||||
return node->getStyle().minDimensions()[YGDimensionWidth];
|
||||
@@ -840,16 +850,16 @@ YOGA_EXPORT YGValue YGNodeStyleGetMinWidth(const YGNodeConstRef node) {
|
||||
YOGA_EXPORT void YGNodeStyleSetMinHeight(
|
||||
const YGNodeRef node,
|
||||
const float minHeight) {
|
||||
auto value = CompactValue::ofMaybe<YGUnitPoint>(minHeight);
|
||||
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(minHeight);
|
||||
updateIndexedStyleProp<MSVC_HINT(minDimensions)>(
|
||||
node, &Style::minDimensions, YGDimensionHeight, value);
|
||||
node, &YGStyle::minDimensions, YGDimensionHeight, value);
|
||||
}
|
||||
YOGA_EXPORT void YGNodeStyleSetMinHeightPercent(
|
||||
const YGNodeRef node,
|
||||
const float minHeight) {
|
||||
auto value = CompactValue::ofMaybe<YGUnitPercent>(minHeight);
|
||||
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(minHeight);
|
||||
updateIndexedStyleProp<MSVC_HINT(minDimensions)>(
|
||||
node, &Style::minDimensions, YGDimensionHeight, value);
|
||||
node, &YGStyle::minDimensions, YGDimensionHeight, value);
|
||||
}
|
||||
YOGA_EXPORT YGValue YGNodeStyleGetMinHeight(const YGNodeConstRef node) {
|
||||
return node->getStyle().minDimensions()[YGDimensionHeight];
|
||||
@@ -858,16 +868,16 @@ YOGA_EXPORT YGValue YGNodeStyleGetMinHeight(const YGNodeConstRef node) {
|
||||
YOGA_EXPORT void YGNodeStyleSetMaxWidth(
|
||||
const YGNodeRef node,
|
||||
const float maxWidth) {
|
||||
auto value = CompactValue::ofMaybe<YGUnitPoint>(maxWidth);
|
||||
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(maxWidth);
|
||||
updateIndexedStyleProp<MSVC_HINT(maxDimensions)>(
|
||||
node, &Style::maxDimensions, YGDimensionWidth, value);
|
||||
node, &YGStyle::maxDimensions, YGDimensionWidth, value);
|
||||
}
|
||||
YOGA_EXPORT void YGNodeStyleSetMaxWidthPercent(
|
||||
const YGNodeRef node,
|
||||
const float maxWidth) {
|
||||
auto value = CompactValue::ofMaybe<YGUnitPercent>(maxWidth);
|
||||
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(maxWidth);
|
||||
updateIndexedStyleProp<MSVC_HINT(maxDimensions)>(
|
||||
node, &Style::maxDimensions, YGDimensionWidth, value);
|
||||
node, &YGStyle::maxDimensions, YGDimensionWidth, value);
|
||||
}
|
||||
YOGA_EXPORT YGValue YGNodeStyleGetMaxWidth(const YGNodeConstRef node) {
|
||||
return node->getStyle().maxDimensions()[YGDimensionWidth];
|
||||
@@ -876,16 +886,16 @@ YOGA_EXPORT YGValue YGNodeStyleGetMaxWidth(const YGNodeConstRef node) {
|
||||
YOGA_EXPORT void YGNodeStyleSetMaxHeight(
|
||||
const YGNodeRef node,
|
||||
const float maxHeight) {
|
||||
auto value = CompactValue::ofMaybe<YGUnitPoint>(maxHeight);
|
||||
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(maxHeight);
|
||||
updateIndexedStyleProp<MSVC_HINT(maxDimensions)>(
|
||||
node, &Style::maxDimensions, YGDimensionHeight, value);
|
||||
node, &YGStyle::maxDimensions, YGDimensionHeight, value);
|
||||
}
|
||||
YOGA_EXPORT void YGNodeStyleSetMaxHeightPercent(
|
||||
const YGNodeRef node,
|
||||
const float maxHeight) {
|
||||
auto value = CompactValue::ofMaybe<YGUnitPercent>(maxHeight);
|
||||
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(maxHeight);
|
||||
updateIndexedStyleProp<MSVC_HINT(maxDimensions)>(
|
||||
node, &Style::maxDimensions, YGDimensionHeight, value);
|
||||
node, &YGStyle::maxDimensions, YGDimensionHeight, value);
|
||||
}
|
||||
YOGA_EXPORT YGValue YGNodeStyleGetMaxHeight(const YGNodeConstRef node) {
|
||||
return node->getStyle().maxDimensions()[YGDimensionHeight];
|
||||
@@ -2509,7 +2519,7 @@ static void YGJustifyMainAxis(
|
||||
i < collectedFlexItemsValues.endOfLineIndex;
|
||||
i++) {
|
||||
const YGNodeRef child = node->getChild(i);
|
||||
const Style& childStyle = child->getStyle();
|
||||
const YGStyle& childStyle = child->getStyle();
|
||||
const YGLayout childLayout = child->getLayout();
|
||||
const bool isLastChild = i == collectedFlexItemsValues.endOfLineIndex - 1;
|
||||
// remove the gap if it is the last element of the line
|
||||
|
||||
Reference in New Issue
Block a user