Add support for context-aware print functions

Summary:
@public

Context-aware print functions are an internal Yoga feature that will be used for Yoga’s JNI code.

It will be possible to specify a context when calculating layout, which will be passed on to baseline and measure functions. This will be a private feature.

Reviewed By: SidharthGuglani

Differential Revision: D14131098

fbshipit-source-id: 7a9da307274ceccba9f7debba581b70c1ebf2c98
This commit is contained in:
David Aurelio
2019-02-19 09:54:48 -08:00
committed by Facebook Github Bot
parent 59bcac3289
commit cbcf07f08a
4 changed files with 30 additions and 12 deletions

View File

@@ -12,9 +12,13 @@
using namespace facebook;
using facebook::yoga::detail::CompactValue;
void YGNode::print() {
if (print_ != nullptr) {
print_(this);
void YGNode::print(void* printContext) {
if (print_.noContext != nullptr) {
if (printUsesContext_) {
print_.withContext(this, printContext);
} else {
print_.noContext(this);
}
}
}
@@ -304,13 +308,14 @@ YGNode& YGNode::operator=(const YGNode& node) {
}
context_ = node.getContext();
print_ = node.print_;
hasNewLayout_ = node.getHasNewLayout();
nodeType_ = node.getNodeType();
measureUsesContext_ = node.measureUsesContext_;
baselineUsesContext_ = node.baselineUsesContext_;
printUsesContext_ = node.printUsesContext_;
measure_ = node.measure_;
baseline_ = node.baseline_;
print_ = node.print_;
dirtied_ = node.getDirtied();
style_ = node.style_;
layout_ = node.layout_;