Call measure and baseline fns within YGNode
Summary: @public Stricter encapsulation of baseline and measure callbacks withing `YGNode`. Instead of invoking these callbacks directly (`node->getBaseline()(...)`), they are invoked via methods on `YGNode` (`node->baseline(...)`). This change will allow us to add the concept of a *Layout Context,* where measure and baseline functions will be able to receive an additional `void *` argument if configured accordingly. This API will be used internally for Yoga’s JNI bindings, to avoid storing a weak JNI reference for each node, and avoid reference table overflows. Changed API: - `YGNodeGetMeasureFunc()` -> `YGNodeHasMeasureFunc()` - `YGNodeGetBaselineFunc()` -> `YGNodeHasBaselineFunc()` - `YGNode::getMeasure()` -> `YGNode::hasMeasureFunc()` + `YGNode::measure()` - `YGNpde::getBaseline()` -> `YGNode::hasBaselineFunc()` + `YGNode::baseline()` Reviewed By: SidharthGuglani Differential Revision: D14099550 fbshipit-source-id: 2653ab36acc252a9747986bc88d21dac22d8c91b
This commit is contained in:
committed by
Facebook Github Bot
parent
d5ad51bccc
commit
f86c74ce7e
@@ -63,12 +63,24 @@ public:
|
||||
return nodeType_;
|
||||
}
|
||||
|
||||
YGMeasureFunc getMeasure() const {
|
||||
return measure_;
|
||||
bool hasMeasureFunc() const noexcept {
|
||||
return measure_ != nullptr;
|
||||
}
|
||||
|
||||
YGBaselineFunc getBaseline() const {
|
||||
return baseline_;
|
||||
YGSize measure(
|
||||
float width,
|
||||
YGMeasureMode widthMode,
|
||||
float height,
|
||||
YGMeasureMode heightMode) {
|
||||
return measure_(this, width, widthMode, height, heightMode);
|
||||
}
|
||||
|
||||
bool hasBaselineFunc() const noexcept {
|
||||
return baseline_ != nullptr;
|
||||
}
|
||||
|
||||
float baseline(float width, float height) {
|
||||
return baseline_(this, width, height);
|
||||
}
|
||||
|
||||
YGDirtiedFunc getDirtied() const {
|
||||
|
Reference in New Issue
Block a user