Avoid dirtying layout when frame doesn't change
Reviewed By: nicklockwood Differential Revision: D2939782 fb-gh-sync-id: e2346f053e9594e5d24d1e73d493a34446fb228c shipit-source-id: e2346f053e9594e5d24d1e73d493a34446fb228c
This commit is contained in:
parent
b8e7fe4959
commit
f51c16b270
|
@ -375,19 +375,27 @@ extern NSString *RCTBridgeModuleNameForClass(Class cls);
|
||||||
|
|
||||||
NSNumber *reactTag = view.reactTag;
|
NSNumber *reactTag = view.reactTag;
|
||||||
dispatch_async(_shadowQueue, ^{
|
dispatch_async(_shadowQueue, ^{
|
||||||
RCTShadowView *rootShadowView = _shadowViewRegistry[reactTag];
|
RCTShadowView *shadowView = _shadowViewRegistry[reactTag];
|
||||||
RCTAssert(rootShadowView != nil, @"Could not locate root view with tag #%@", reactTag);
|
RCTAssert(shadowView != nil, @"Could not locate shadow view with tag #%@", reactTag);
|
||||||
|
|
||||||
if (RCTIsReactRootView(reactTag)) {
|
BOOL dirtyLayout = NO;
|
||||||
rootShadowView.frame = frame;
|
|
||||||
rootShadowView.sizeFlexibility = sizeFlexibility;
|
if (!CGRectEqualToRect(frame, shadowView.frame)) {
|
||||||
} else {
|
shadowView.frame = frame;
|
||||||
rootShadowView.frame = frame;
|
dirtyLayout = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
[rootShadowView dirtyLayout];
|
// Trigger re-layout when size flexibility changes, as the root view might grow or
|
||||||
|
// shrink in the flexible dimensions.
|
||||||
|
if (RCTIsReactRootView(reactTag) && shadowView.sizeFlexibility != sizeFlexibility) {
|
||||||
|
shadowView.sizeFlexibility = sizeFlexibility;
|
||||||
|
dirtyLayout = YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dirtyLayout) {
|
||||||
|
[shadowView dirtyLayout];
|
||||||
[self batchDidComplete];
|
[self batchDidComplete];
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1045,18 +1053,16 @@ RCT_EXPORT_METHOD(measure:(nonnull NSNumber *)reactTag
|
||||||
callback(@[]);
|
callback(@[]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CGRect frame = view.frame;
|
|
||||||
|
|
||||||
|
// If in a <Modal>, rootView will be the root of the modal container.
|
||||||
UIView *rootView = view;
|
UIView *rootView = view;
|
||||||
while (rootView && ![rootView isReactRootView]) {
|
while (rootView.superview && ![rootView isReactRootView]) {
|
||||||
rootView = rootView.superview;
|
rootView = rootView.superview;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: this doesn't work because sometimes view is inside a modal window
|
|
||||||
// RCTAssert([rootView isReactRootView], @"React view is not inside a React root view");
|
|
||||||
|
|
||||||
// By convention, all coordinates, whether they be touch coordinates, or
|
// By convention, all coordinates, whether they be touch coordinates, or
|
||||||
// measurement coordinates are with respect to the root view.
|
// measurement coordinates are with respect to the root view.
|
||||||
|
CGRect frame = view.frame;
|
||||||
CGPoint pagePoint = [view.superview convertPoint:frame.origin toView:rootView];
|
CGPoint pagePoint = [view.superview convertPoint:frame.origin toView:rootView];
|
||||||
|
|
||||||
callback(@[
|
callback(@[
|
||||||
|
|
Loading…
Reference in New Issue