Simplify bitfields (#1393)
Summary: X-link: https://github.com/facebook/react-native/pull/39485 Pull Request resolved: https://github.com/facebook/yoga/pull/1393 These were previously packed into structs to allow zero initializing all the flags at once without needing a ctor. C++ 20 has in-class member initializer support for bitfields, which makes these look more like normal member variables. Setting enum values is a bit jank right now, due to relying on C enums which are effectively int32_t, along with GCC `-Wconversion` being a bit aggressive in needing to explicitly mask. I have some ideas to fix this later (e.g. using scoped enums internally). bypass-github-export-checks Changelog: [General][Breaking] - Require C++ 20 when including renderer headers Reviewed By: sammy-SC Differential Revision: D49265967 fbshipit-source-id: 6ab935a866196df06e742c821f3af88eb4d18e1a
This commit is contained in:
committed by
Facebook GitHub Bot
parent
557d2a76fe
commit
ea3869fe9f
@@ -23,15 +23,17 @@ Node::Node(const yoga::Config* config) : config_{config} {
|
||||
yoga::assertFatal(
|
||||
config != nullptr, "Attempting to construct Node with null config");
|
||||
|
||||
flags_.hasNewLayout = true;
|
||||
if (config->useWebDefaults()) {
|
||||
useWebDefaults();
|
||||
}
|
||||
}
|
||||
|
||||
Node::Node(Node&& node) {
|
||||
hasNewLayout_ = node.hasNewLayout_;
|
||||
isReferenceBaseline_ = node.isReferenceBaseline_;
|
||||
isDirty_ = node.isDirty_;
|
||||
nodeType_ = node.nodeType_;
|
||||
context_ = node.context_;
|
||||
flags_ = node.flags_;
|
||||
measureFunc_ = node.measureFunc_;
|
||||
baselineFunc_ = node.baselineFunc_;
|
||||
printFunc_ = node.printFunc_;
|
||||
@@ -271,10 +273,10 @@ void Node::setConfig(yoga::Config* config) {
|
||||
}
|
||||
|
||||
void Node::setDirty(bool isDirty) {
|
||||
if (isDirty == flags_.isDirty) {
|
||||
if (isDirty == isDirty_) {
|
||||
return;
|
||||
}
|
||||
flags_.isDirty = isDirty;
|
||||
isDirty_ = isDirty;
|
||||
if (isDirty && dirtiedFunc_) {
|
||||
dirtiedFunc_(this);
|
||||
}
|
||||
@@ -473,7 +475,7 @@ void Node::cloneChildrenIfNeeded() {
|
||||
}
|
||||
|
||||
void Node::markDirtyAndPropagate() {
|
||||
if (!flags_.isDirty) {
|
||||
if (!isDirty_) {
|
||||
setDirty(true);
|
||||
setLayoutComputedFlexBasis(FloatOptional());
|
||||
if (owner_) {
|
||||
@@ -483,7 +485,7 @@ void Node::markDirtyAndPropagate() {
|
||||
}
|
||||
|
||||
void Node::markDirtyAndPropagateDownwards() {
|
||||
flags_.isDirty = true;
|
||||
isDirty_ = true;
|
||||
for_each(children_.begin(), children_.end(), [](Node* childNode) {
|
||||
childNode->markDirtyAndPropagateDownwards();
|
||||
});
|
||||
|
Reference in New Issue
Block a user