Dirty nodes when dynamically setting config (#37207)
Summary: X-link: https://github.com/facebook/react-native/pull/37207 Pull Request resolved: https://github.com/facebook/yoga/pull/1274 Yoga exposes public APIs for dirtying Nodes, but will itself perform dirty marking when changing bits which invalidate layout. E.g. changing the style of a Node will invalidate it along with every parent Node. Because config setting is newly public to the C ABI, this makes a similar change so that replacing a Node's config will dirty the tree above the node if there is a layout impacting config change (I don't think children need to be invalidated since child output shouldn't change given the same owner dimensions). One quirk of this is that configs may be changed independently of the node. So someone could attach a config to a Node, then change the live config after the fact. The config does not currently have a back pointer to the Node, so we do not invalidate in that case of live config edits. The future work to rectify this would be to make configs immutable once created. There are also currently some experimental features here which should maybe be compared, but these should be moved to YGErrata anyway. Reviewed By: javache Differential Revision: D45505089 fbshipit-source-id: 72b2b84ba758679af081d92e7403750c9cc53cb5
This commit is contained in:
committed by
Facebook GitHub Bot
parent
54d78926ce
commit
b8126cdc6c
@@ -7,7 +7,18 @@
|
||||
|
||||
#include "YGConfig.h"
|
||||
|
||||
using namespace facebook::yoga::detail;
|
||||
using namespace facebook::yoga;
|
||||
|
||||
namespace facebook {
|
||||
namespace yoga {
|
||||
bool configUpdateInvalidatesLayout(YGConfigRef a, YGConfigRef b) {
|
||||
return a->getErrata() != b->getErrata() ||
|
||||
a->getEnabledExperiments() != b->getEnabledExperiments() ||
|
||||
a->getPointScaleFactor() != b->getPointScaleFactor() ||
|
||||
a->useWebDefaults() != b->useWebDefaults();
|
||||
}
|
||||
} // namespace yoga
|
||||
} // namespace facebook
|
||||
|
||||
YGConfig::YGConfig(YGLogger logger) : cloneNodeCallback_{nullptr} {
|
||||
setLogger(logger);
|
||||
@@ -40,6 +51,10 @@ bool YGConfig::isExperimentalFeatureEnabled(
|
||||
return experimentalFeatures_.test(feature);
|
||||
}
|
||||
|
||||
ExperimentalFeatureSet YGConfig::getEnabledExperiments() const {
|
||||
return experimentalFeatures_;
|
||||
}
|
||||
|
||||
void YGConfig::setErrata(YGErrata errata) {
|
||||
errata_ = errata;
|
||||
}
|
||||
|
Reference in New Issue
Block a user