Make node printing private

Summary:
@public

Removes `YGNodeGetPrintFunc`, and encapsulates node printing within `YGNode`.
This is necessary for allowing for context-aware callback functions, which will ultimately allow for removal of weak global JNI references.

On a side node, the printing logic does not seem to be well thought through: print functions print as a side effect to whatever output they choose. Printing that uses callbacks is printing to different output streams or strings, though.

We need to consolidate Yoga debugging, and make it all more stringent.

Reviewed By: SidharthGuglani

Differential Revision: D14131024

fbshipit-source-id: 68704682dab3e7dfba61930bb03003d7d4723b80
This commit is contained in:
David Aurelio
2019-02-19 09:54:48 -08:00
committed by Facebook Github Bot
parent bd90192df9
commit 59bcac3289
5 changed files with 12 additions and 21 deletions

View File

@@ -12,6 +12,12 @@
using namespace facebook;
using facebook::yoga::detail::CompactValue;
void YGNode::print() {
if (print_ != nullptr) {
print_(this);
}
}
YGFloatOptional YGNode::getLeadingPosition(
const YGFlexDirection axis,
const float axisSize) const {
@@ -298,7 +304,7 @@ YGNode& YGNode::operator=(const YGNode& node) {
}
context_ = node.getContext();
print_ = node.getPrintFunc();
print_ = node.print_;
hasNewLayout_ = node.getHasNewLayout();
nodeType_ = node.getNodeType();
measureUsesContext_ = node.measureUsesContext_;

View File

@@ -68,9 +68,7 @@ public:
return context_;
}
YGPrintFunc getPrintFunc() const {
return print_;
}
void print();
bool getHasNewLayout() const {
return hasNewLayout_;

View File

@@ -114,9 +114,7 @@ void YGNodeToString(
uint32_t level) {
indent(str, level);
appendFormatedString(str, "<div ");
if (node->getPrintFunc() != nullptr) {
node->getPrintFunc()(node);
}
node->print();
if (options & YGPrintOptionsLayout) {
appendFormatedString(str, "layout=\"");

View File

@@ -169,10 +169,6 @@ void YGNodeSetDirtiedFunc(YGNodeRef node, YGDirtiedFunc dirtiedFunc) {
node->setDirtiedFunc(dirtiedFunc);
}
YGPrintFunc YGNodeGetPrintFunc(YGNodeRef node) {
return node->getPrintFunc();
}
void YGNodeSetPrintFunc(YGNodeRef node, YGPrintFunc printFunc) {
node->setPrintFunc(printFunc);
}
@@ -3847,9 +3843,7 @@ bool YGLayoutNodeInternal(
"%s%d.{[skipped] ",
YGSpacer(gDepth),
gDepth);
if (node->getPrintFunc() != nullptr) {
node->getPrintFunc()(node);
}
node->print();
Log::log(
node,
YGLogLevelVerbose,
@@ -3873,9 +3867,7 @@ bool YGLayoutNodeInternal(
YGSpacer(gDepth),
gDepth,
needToVisitNode ? "*" : "");
if (node->getPrintFunc() != nullptr) {
node->getPrintFunc()(node);
}
node->print();
Log::log(
node,
YGLogLevelVerbose,
@@ -3911,9 +3903,7 @@ bool YGLayoutNodeInternal(
YGSpacer(gDepth),
gDepth,
needToVisitNode ? "*" : "");
if (node->getPrintFunc() != nullptr) {
node->getPrintFunc()(node);
}
node->print();
Log::log(
node,
YGLogLevelVerbose,

View File

@@ -138,7 +138,6 @@ bool YGNodeHasBaselineFunc(YGNodeRef node);
void YGNodeSetBaselineFunc(YGNodeRef node, YGBaselineFunc baselineFunc);
YGDirtiedFunc YGNodeGetDirtiedFunc(YGNodeRef node);
void YGNodeSetDirtiedFunc(YGNodeRef node, YGDirtiedFunc dirtiedFunc);
YGPrintFunc YGNodeGetPrintFunc(YGNodeRef node);
void YGNodeSetPrintFunc(YGNodeRef node, YGPrintFunc printFunc);
WIN_EXPORT bool YGNodeGetHasNewLayout(YGNodeRef node);
WIN_EXPORT void YGNodeSetHasNewLayout(YGNodeRef node, bool hasNewLayout);