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)
|
||||
|
||||
#ifdef DEBUG
|
||||
void YGNodePrint(const YGNodeConstRef nodeRef, const YGPrintOptions options) {
|
||||
const auto node = resolveRef(nodeRef);
|
||||
std::string str;
|
||||
yoga::nodeToString(str, node, options, 0);
|
||||
yoga::log(node, LogLevel::Debug, str.c_str());
|
||||
void YGNodePrint(const YGNodeConstRef node, const YGPrintOptions options) {
|
||||
yoga::print(resolveRef(node), scopedEnum(options));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@@ -24,6 +24,7 @@
|
||||
#include <yoga/algorithm/ResolveValue.h>
|
||||
#include <yoga/debug/AssertFatal.h>
|
||||
#include <yoga/debug/Log.h>
|
||||
#include <yoga/debug/NodeToString.h>
|
||||
#include <yoga/event/event.h>
|
||||
#include <yoga/node/Node.h>
|
||||
#include <yoga/numeric/Comparison.h>
|
||||
@@ -2737,9 +2738,9 @@ void calculateLayout(
|
||||
|
||||
#ifdef DEBUG
|
||||
if (node->getConfig()->shouldPrintTree()) {
|
||||
YGNodePrint(
|
||||
yoga::print(
|
||||
node,
|
||||
(YGPrintOptions)(YGPrintOptionsLayout | YGPrintOptionsChildren | YGPrintOptionsStyle));
|
||||
PrintOptions::Layout | PrintOptions::Children | PrintOptions::Style);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@@ -11,6 +11,7 @@
|
||||
|
||||
#include <yoga/YGEnums.h>
|
||||
|
||||
#include <yoga/debug/Log.h>
|
||||
#include <yoga/debug/NodeToString.h>
|
||||
#include <yoga/numeric/Comparison.h>
|
||||
|
||||
@@ -118,12 +119,12 @@ static void appendEdgeIfNotUndefined(
|
||||
void nodeToString(
|
||||
std::string& str,
|
||||
const yoga::Node* node,
|
||||
YGPrintOptions options,
|
||||
PrintOptions options,
|
||||
uint32_t level) {
|
||||
indent(str, level);
|
||||
appendFormattedString(str, "<div ");
|
||||
|
||||
if (options & YGPrintOptionsLayout) {
|
||||
if ((options & PrintOptions::Layout) == PrintOptions::Layout) {
|
||||
appendFormattedString(str, "layout=\"");
|
||||
appendFormattedString(
|
||||
str, "width: %g; ", node->getLayout().dimensions[YGDimensionWidth]);
|
||||
@@ -136,7 +137,7 @@ void nodeToString(
|
||||
appendFormattedString(str, "\" ");
|
||||
}
|
||||
|
||||
if (options & YGPrintOptionsStyle) {
|
||||
if ((options & PrintOptions::Style) == PrintOptions::Style) {
|
||||
appendFormattedString(str, "style=\"");
|
||||
const auto& style = node->getStyle();
|
||||
if (style.flexDirection() != yoga::Node{}.getStyle().flexDirection()) {
|
||||
@@ -228,7 +229,8 @@ void nodeToString(
|
||||
appendFormattedString(str, ">");
|
||||
|
||||
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++) {
|
||||
appendFormattedString(str, "\n");
|
||||
nodeToString(str, node->getChild(i), options, level + 1);
|
||||
@@ -239,5 +241,11 @@ void nodeToString(
|
||||
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
|
||||
#endif
|
||||
|
@@ -11,7 +11,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <yoga/Yoga.h>
|
||||
#include <yoga/enums/PrintOptions.h>
|
||||
#include <yoga/node/Node.h>
|
||||
|
||||
namespace facebook::yoga {
|
||||
@@ -19,9 +19,11 @@ namespace facebook::yoga {
|
||||
void nodeToString(
|
||||
std::string& str,
|
||||
const yoga::Node* node,
|
||||
YGPrintOptions options,
|
||||
PrintOptions options,
|
||||
uint32_t level);
|
||||
|
||||
void print(const yoga::Node* node, PrintOptions options);
|
||||
|
||||
} // namespace facebook::yoga
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user