Move reset logic to YGNode::reset()

Summary:
@public

Moving logic from free C functions to the C++ layer.

This will allow us to get rid of the dangerous copy / move assignment operators of `YGNode`.

Reviewed By: SidharthGuglani

Differential Revision: D14241564

fbshipit-source-id: aae9f2a7ffd23bb839f1747e4a0694578bae86ae
This commit is contained in:
David Aurelio
2019-02-28 06:22:17 -08:00
committed by Facebook Github Bot
parent e25fe994b3
commit 15668aceb6
3 changed files with 22 additions and 19 deletions

View File

@@ -571,3 +571,22 @@ bool YGNode::isLayoutTreeEqualToNode(const YGNode& node) const {
}
return isLayoutTreeEqual;
}
void YGNode::reset() {
YGAssertWithNode(
this,
children_.size() == 0,
"Cannot reset a node which still has children attached");
YGAssertWithNode(
this, owner_ == nullptr, "Cannot reset a node still attached to a owner");
clearChildren();
auto config = getConfig();
*this = YGNode{};
if (config->useWebDefaults) {
setStyleFlexDirection(YGFlexDirectionRow);
setStyleAlignContent(YGAlignStretch);
}
setConfig(config);
}