Generalize/refactor `-[RCTUIManager rootViewForReactTag:withCompletion:]`

Reviewed By: shergin

Differential Revision: D5419037

fbshipit-source-id: c5a6afc826fd7ae805601c0c7940b4294bd34ef8
This commit is contained in:
Yu Wang 2017-07-14 18:14:50 -07:00 committed by Facebook Github Bot
parent 5701ae2145
commit fac6207277
1 changed files with 2 additions and 27 deletions

View File

@ -33,6 +33,7 @@
#import "RCTRootShadowView.h" #import "RCTRootShadowView.h"
#import "RCTRootViewInternal.h" #import "RCTRootViewInternal.h"
#import "RCTScrollableProtocol.h" #import "RCTScrollableProtocol.h"
#import "RCTShadowView+Hierarchy.h"
#import "RCTShadowView.h" #import "RCTShadowView.h"
#import "RCTUIManagerObserverCoordinator.h" #import "RCTUIManagerObserverCoordinator.h"
#import "RCTUtils.h" #import "RCTUtils.h"
@ -1462,7 +1463,7 @@ RCT_EXPORT_METHOD(configureNextLayoutAnimation:(NSDictionary *)config
} }
dispatch_async(RCTGetUIManagerQueue(), ^{ dispatch_async(RCTGetUIManagerQueue(), ^{
NSNumber *rootTag = [self _rootTagForReactTag:reactTag]; NSNumber *rootTag = [self shadowViewForReactTag:reactTag].rootView.reactTag;
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
UIView *rootView = nil; UIView *rootView = nil;
if (rootTag != nil) { if (rootTag != nil) {
@ -1473,32 +1474,6 @@ RCT_EXPORT_METHOD(configureNextLayoutAnimation:(NSDictionary *)config
}); });
} }
- (NSNumber *)_rootTagForReactTag:(NSNumber *)reactTag
{
RCTAssert(!RCTIsMainQueue(), @"Should be called on shadow queue");
if (reactTag == nil) {
return nil;
}
if (RCTIsReactRootView(reactTag)) {
return reactTag;
}
NSNumber *rootTag = nil;
RCTShadowView *shadowView = _shadowViewRegistry[reactTag];
while (shadowView) {
RCTShadowView *parent = [shadowView reactSuperview];
if (!parent && RCTIsReactRootView(shadowView.reactTag)) {
rootTag = shadowView.reactTag;
break;
}
shadowView = parent;
}
return rootTag;
}
static UIView *_jsResponder; static UIView *_jsResponder;
+ (UIView *)JSResponder + (UIView *)JSResponder