C++ style enums 6/N: PrintOptions
Summary: This converts usages of YGPrintOptions to PrintOptions Differential Revision: D49270929 fbshipit-source-id: 10c8dd6e711581a62f234658016afe697e2e44ce
This commit is contained in:
committed by
Facebook GitHub Bot
parent
9a73336ba3
commit
c4d0b6ae7c
@@ -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, LogLevel::Debug, str.c_str());
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -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>
|
||||||
@@ -2737,9 +2738,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
|
||||||
}
|
}
|
||||||
|
@@ -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
|
||||||
|
Reference in New Issue
Block a user