mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fabric: Fixed incorrect early-return in UIView+ComponentViewProtocol::updateLayoutMetrics
Summary: Before the change, an incorrect (NaN or Inf) values in LayoutMetrics might force an early return in the `updateLayoutMetrics:oldMetrics:` method implementation. This was not correct because the rest of the method also didn't run in this case, so it might force some value to stale. E.g., imagine we have an instruction that contains NaN size and `display: none`. Previously, the function might just return right before applying sizes and progress the stored "already applied" value of LayoutMetrics which will cause the view being visible even if it should not. Changelog: [Internal] Fabric-specific internal change. Reviewed By: JoshuaGross Differential Revision: D21110644 fbshipit-source-id: 501319d7b1dcd5c18f27e0ceca3c8d207485c49b
This commit is contained in:
committed by
Facebook GitHub Bot
parent
b0006648e2
commit
6694ce00bb
@@ -79,13 +79,12 @@ using namespace facebook::react;
|
||||
@"-[UIView(ComponentViewProtocol) updateLayoutMetrics:oldLayoutMetrics:]: Received invalid layout metrics (%@) for a view (%@).",
|
||||
NSStringFromCGRect(frame),
|
||||
self);
|
||||
return;
|
||||
} else {
|
||||
// Note: Changing `frame` when `layer.transform` is not the `identity transform` is undefined behavior.
|
||||
// Therefore, we must use `center` and `bounds`.
|
||||
self.center = CGPoint{CGRectGetMidX(frame), CGRectGetMidY(frame)};
|
||||
self.bounds = CGRect{CGPointZero, frame.size};
|
||||
}
|
||||
|
||||
// Note: Changing `frame` when `layer.transform` is not the `identity transform` is undefined behavior.
|
||||
// Therefore, we must use `center` and `bounds`.
|
||||
self.center = CGPoint{CGRectGetMidX(frame), CGRectGetMidY(frame)};
|
||||
self.bounds = CGRect{CGPointZero, frame.size};
|
||||
}
|
||||
|
||||
if (forceUpdate || (layoutMetrics.layoutDirection != oldLayoutMetrics.layoutDirection)) {
|
||||
|
||||
Reference in New Issue
Block a user