A couple of checks for corner cases in RCTGetDimensions and RCTExportedDimensions

Summary: We need this checks to make the results of those function more reliable.

Reviewed By: sammy-SC

Differential Revision: D24038911

fbshipit-source-id: 3b54fe3056c9508cde84ea157beebea57e7e49b6
This commit is contained in:
Valentin Shergin 2020-10-01 13:17:50 -07:00 коммит произвёл Facebook GitHub Bot
Родитель 9a2a4ba579
Коммит e853722981
2 изменённых файлов: 4 добавлений и 2 удалений

Просмотреть файл

@ -93,7 +93,8 @@ static BOOL RCTIsIPhoneX()
static NSDictionary *RCTExportedDimensions(RCTBridge *bridge)
{
RCTAssertMainQueue();
RCTDimensions dimensions = RCTGetDimensions(bridge.accessibilityManager.multiplier);
RCTAssert(bridge, @"Bridge must not be `nil`.");
RCTDimensions dimensions = RCTGetDimensions(bridge.accessibilityManager.multiplier ?: 1.0);
__typeof(dimensions.window) window = dimensions.window;
NSDictionary<NSString *, NSNumber *> *dimsWindow = @{
@"width" : @(window.width),

Просмотреть файл

@ -16,7 +16,8 @@ RCTDimensions RCTGetDimensions(CGFloat fontScale)
UIView *mainWindow;
mainWindow = RCTKeyWindow();
CGSize windowSize = mainWindow.bounds.size;
// We fallback to screen size if a key window is not found.
CGSize windowSize = mainWindow ? mainWindow.bounds.size : screenSize;
RCTDimensions result;
typeof(result.screen) dimsScreen = {