mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fabric: Checking for HasNewLayout before applying layout metrics to ShadowNode
Summary: If the `HasNewLayout` flag is `false`, we should not copy the data from YGStyle/YGLayout to ShadowNode because the node can be already sealed and because it's unnecessary. Previously we workaround this case with a special check in `setLayoutMetrics` method, but that can be unreliable because of some side-effects related to pixel rounding and comparing floats. The new approach is much more robust and explicit. Reviewed By: JoshuaGross Differential Revision: D14496939 fbshipit-source-id: deddb14d2206c5bd3f22154d0ea682e3c5888901
This commit is contained in:
committed by
Facebook Github Bot
parent
be6fa25d16
commit
55eaf30740
@@ -170,6 +170,10 @@ void YogaLayoutableShadowNode::layout(LayoutContext layoutContext) {
|
||||
|
||||
void YogaLayoutableShadowNode::layoutChildren(LayoutContext layoutContext) {
|
||||
for (const auto &childYogaNode : yogaNode_.getChildren()) {
|
||||
if (!childYogaNode->getHasNewLayout()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto childNode =
|
||||
static_cast<YogaLayoutableShadowNode *>(childYogaNode->getContext());
|
||||
|
||||
|
||||
@@ -22,12 +22,12 @@ LayoutMetrics LayoutableShadowNode::getLayoutMetrics() const {
|
||||
}
|
||||
|
||||
bool LayoutableShadowNode::setLayoutMetrics(LayoutMetrics layoutMetrics) {
|
||||
ensureUnsealed();
|
||||
|
||||
if (layoutMetrics_ == layoutMetrics) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ensureUnsealed();
|
||||
|
||||
layoutMetrics_ = layoutMetrics;
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user