mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
C++ style enums 15/N: Display (#39541)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/39541 X-link: https://github.com/facebook/yoga/pull/1397 Moves internal usages of YGDisplay to Display bypass-github-export-checks Changelog: [Internal] Reviewed By: sammy-SC Differential Revision: D49361952 fbshipit-source-id: a961efaa35a3fed01659d23783bf90e0b47656f0
This commit is contained in:
committed by
Facebook GitHub Bot
parent
e2e6895ea0
commit
ebcd1ab1ab
+1
-1
@@ -88,7 +88,7 @@ class ConcreteViewShadowNode : public ConcreteShadowNode<
|
||||
void initialize() noexcept {
|
||||
auto& props = BaseShadowNode::getConcreteProps();
|
||||
|
||||
if (props.yogaStyle.display() == YGDisplayNone) {
|
||||
if (props.yogaStyle.display() == yoga::Display::None) {
|
||||
BaseShadowNode::traits_.set(ShadowNodeTraits::Trait::Hidden);
|
||||
} else {
|
||||
BaseShadowNode::traits_.unset(ShadowNodeTraits::Trait::Hidden);
|
||||
|
||||
@@ -45,7 +45,7 @@ void ViewShadowNode::initialize() noexcept {
|
||||
viewProps.opacity != 1.0 || viewProps.transform != Transform{} ||
|
||||
(viewProps.zIndex.has_value() &&
|
||||
viewProps.yogaStyle.positionType() != yoga::PositionType::Static) ||
|
||||
viewProps.yogaStyle.display() == YGDisplayNone ||
|
||||
viewProps.yogaStyle.display() == yoga::Display::None ||
|
||||
viewProps.getClipsContentToBounds() || viewProps.events.bits.any() ||
|
||||
isColorMeaningful(viewProps.shadowColor) ||
|
||||
viewProps.accessibilityElementsHidden ||
|
||||
|
||||
@@ -141,9 +141,9 @@ inline LayoutMetrics layoutMetricsFromYogaNode(yoga::Node& yogaNode) {
|
||||
layoutMetrics.borderWidth.bottom +
|
||||
floatFromYogaFloat(YGNodeLayoutGetPadding(&yogaNode, YGEdgeBottom))};
|
||||
|
||||
layoutMetrics.displayType = yogaNode.getStyle().display() == YGDisplayNone
|
||||
? DisplayType::None
|
||||
: DisplayType::Flex;
|
||||
layoutMetrics.displayType =
|
||||
yogaNode.getStyle().display() == yoga::Display::None ? DisplayType::None
|
||||
: DisplayType::Flex;
|
||||
|
||||
layoutMetrics.layoutDirection =
|
||||
YGNodeLayoutGetDirection(&yogaNode) == YGDirectionRTL
|
||||
@@ -385,22 +385,22 @@ inline void fromRawValue(
|
||||
inline void fromRawValue(
|
||||
const PropsParserContext& context,
|
||||
const RawValue& value,
|
||||
YGDisplay& result) {
|
||||
result = YGDisplayFlex;
|
||||
yoga::Display& result) {
|
||||
result = yoga::Display::Flex;
|
||||
react_native_expect(value.hasType<std::string>());
|
||||
if (!value.hasType<std::string>()) {
|
||||
return;
|
||||
}
|
||||
auto stringValue = (std::string)value;
|
||||
if (stringValue == "flex") {
|
||||
result = YGDisplayFlex;
|
||||
result = yoga::Display::Flex;
|
||||
return;
|
||||
}
|
||||
if (stringValue == "none") {
|
||||
result = YGDisplayNone;
|
||||
result = yoga::Display::None;
|
||||
return;
|
||||
}
|
||||
LOG(ERROR) << "Could not parse YGDisplay:" << stringValue;
|
||||
LOG(ERROR) << "Could not parse yoga::Display:" << stringValue;
|
||||
react_native_expect(false);
|
||||
}
|
||||
|
||||
@@ -833,11 +833,11 @@ inline std::string toString(const yoga::Overflow& value) {
|
||||
}
|
||||
}
|
||||
|
||||
inline std::string toString(const YGDisplay& value) {
|
||||
inline std::string toString(const yoga::Display& value) {
|
||||
switch (value) {
|
||||
case YGDisplayFlex:
|
||||
case yoga::Display::Flex:
|
||||
return "flex";
|
||||
case YGDisplayNone:
|
||||
case yoga::Display::None:
|
||||
return "none";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ TEST_F(YogaDirtyFlagTest, changingLayoutSubPropsMustDirtyYogaNode) {
|
||||
auto& props = *viewProps;
|
||||
|
||||
props.yogaStyle.alignContent() = yoga::Align::Baseline;
|
||||
props.yogaStyle.display() = YGDisplayNone;
|
||||
props.yogaStyle.display() = yoga::Display::None;
|
||||
|
||||
return oldShadowNode.clone(ShadowNodeFragment{viewProps});
|
||||
});
|
||||
|
||||
+1
-1
@@ -764,7 +764,7 @@ TEST_F(StackingContextTest, zIndexAndFlattenedNodes) {
|
||||
|
||||
mutateViewShadowNodeProps_(nodeBB_, [](ViewProps& props) {
|
||||
auto& yogaStyle = props.yogaStyle;
|
||||
yogaStyle.display() = YGDisplayNone;
|
||||
yogaStyle.display() = yoga::Display::None;
|
||||
});
|
||||
|
||||
testViewTree_([](const StubViewTree& viewTree) {
|
||||
|
||||
@@ -508,10 +508,10 @@ YGOverflow YGNodeStyleGetOverflow(const YGNodeConstRef node) {
|
||||
}
|
||||
|
||||
void YGNodeStyleSetDisplay(const YGNodeRef node, const YGDisplay display) {
|
||||
updateStyle<MSVC_HINT(display)>(node, &Style::display, display);
|
||||
updateStyle<MSVC_HINT(display)>(node, &Style::display, scopedEnum(display));
|
||||
}
|
||||
YGDisplay YGNodeStyleGetDisplay(const YGNodeConstRef node) {
|
||||
return resolveRef(node)->getStyle().display();
|
||||
return unscopedEnum(resolveRef(node)->getStyle().display());
|
||||
}
|
||||
|
||||
// TODO(T26792433): Change the API to accept FloatOptional.
|
||||
|
||||
@@ -804,7 +804,7 @@ static float computeFlexBasisForChildren(
|
||||
|
||||
for (auto child : children) {
|
||||
child->resolveDimension();
|
||||
if (child->getStyle().display() == YGDisplayNone) {
|
||||
if (child->getStyle().display() == Display::None) {
|
||||
zeroOutLayoutRecursively(child);
|
||||
child->setHasNewLayout(true);
|
||||
child->setDirty(false);
|
||||
@@ -1307,7 +1307,7 @@ static void justifyMainAxis(
|
||||
const auto child = node->getChild(i);
|
||||
const Style& childStyle = child->getStyle();
|
||||
const LayoutResults& childLayout = child->getLayout();
|
||||
if (childStyle.display() == YGDisplayNone) {
|
||||
if (childStyle.display() == Display::None) {
|
||||
continue;
|
||||
}
|
||||
if (childStyle.positionType() == PositionType::Absolute &&
|
||||
@@ -1863,7 +1863,7 @@ static void calculateLayoutImpl(
|
||||
if (performLayout) {
|
||||
for (size_t i = startOfLineIndex; i < endOfLineIndex; i++) {
|
||||
const auto child = node->getChild(i);
|
||||
if (child->getStyle().display() == YGDisplayNone) {
|
||||
if (child->getStyle().display() == Display::None) {
|
||||
continue;
|
||||
}
|
||||
if (child->getStyle().positionType() == PositionType::Absolute) {
|
||||
@@ -2069,7 +2069,7 @@ static void calculateLayoutImpl(
|
||||
float maxDescentForCurrentLine = 0;
|
||||
for (ii = startIndex; ii < childCount; ii++) {
|
||||
const auto child = node->getChild(ii);
|
||||
if (child->getStyle().display() == YGDisplayNone) {
|
||||
if (child->getStyle().display() == Display::None) {
|
||||
continue;
|
||||
}
|
||||
if (child->getStyle().positionType() != PositionType::Absolute) {
|
||||
@@ -2112,7 +2112,7 @@ static void calculateLayoutImpl(
|
||||
if (performLayout) {
|
||||
for (ii = startIndex; ii < endIndex; ii++) {
|
||||
const auto child = node->getChild(ii);
|
||||
if (child->getStyle().display() == YGDisplayNone) {
|
||||
if (child->getStyle().display() == Display::None) {
|
||||
continue;
|
||||
}
|
||||
if (child->getStyle().positionType() != PositionType::Absolute) {
|
||||
@@ -2318,7 +2318,7 @@ static void calculateLayoutImpl(
|
||||
if (performLayout) {
|
||||
// STEP 10: SIZING AND POSITIONING ABSOLUTE CHILDREN
|
||||
for (auto child : node->getChildren()) {
|
||||
if (child->getStyle().display() == YGDisplayNone ||
|
||||
if (child->getStyle().display() == Display::None ||
|
||||
child->getStyle().positionType() != PositionType::Absolute) {
|
||||
continue;
|
||||
}
|
||||
@@ -2352,7 +2352,7 @@ static void calculateLayoutImpl(
|
||||
if (needsMainTrailingPos || needsCrossTrailingPos) {
|
||||
for (size_t i = 0; i < childCount; i++) {
|
||||
const auto child = node->getChild(i);
|
||||
if (child->getStyle().display() == YGDisplayNone) {
|
||||
if (child->getStyle().display() == Display::None) {
|
||||
continue;
|
||||
}
|
||||
if (needsMainTrailingPos) {
|
||||
|
||||
@@ -38,7 +38,7 @@ FlexLine calculateFlexLine(
|
||||
// Add items to the current line until it's full or we run out of items.
|
||||
for (; endOfLineIndex < node->getChildren().size(); endOfLineIndex++) {
|
||||
auto child = node->getChild(endOfLineIndex);
|
||||
if (child->getStyle().display() == YGDisplayNone ||
|
||||
if (child->getStyle().display() == Display::None ||
|
||||
child->getStyle().positionType() == PositionType::Absolute) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -174,8 +174,7 @@ void nodeToString(
|
||||
}
|
||||
|
||||
if (style.display() != yoga::Node{}.getStyle().display()) {
|
||||
appendFormattedString(
|
||||
str, "display: %s; ", YGDisplayToString(style.display()));
|
||||
appendFormattedString(str, "display: %s; ", toString(style.display()));
|
||||
}
|
||||
appendEdges(str, "margin", style.margin());
|
||||
appendEdges(str, "padding", style.padding());
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <yoga/bits/NumericBitfield.h>
|
||||
#include <yoga/enums/Align.h>
|
||||
#include <yoga/enums/Direction.h>
|
||||
#include <yoga/enums/Display.h>
|
||||
#include <yoga/enums/FlexDirection.h>
|
||||
#include <yoga/enums/Justify.h>
|
||||
#include <yoga/enums/Overflow.h>
|
||||
@@ -209,10 +210,10 @@ class YG_EXPORT Style {
|
||||
return {*this, overflowOffset};
|
||||
}
|
||||
|
||||
YGDisplay display() const {
|
||||
return getEnumData<YGDisplay>(flags, displayOffset);
|
||||
Display display() const {
|
||||
return getEnumData<Display>(flags, displayOffset);
|
||||
}
|
||||
BitfieldRef<YGDisplay> display() {
|
||||
BitfieldRef<Display> display() {
|
||||
return {*this, displayOffset};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user