Skip to content

Commit 9fc3fc8

Browse files
philIipfacebook-github-bot
authored andcommitted
introduce RCTViewUtils
Summary: Changelog: [Internal] in this diff, i convert the following method to a C function. https://www.internalfb.com/code/fbsource/[c58818169205f1e0fa816968efdb4c3fac8333e9]/xplat/js/react-native-github/React/Views/RCTView.h?lines=43 besides for testing demonstration purposes later in the stack, C functions are a superior choice to static class methods because they incur less binary size cost (see section 4.3 of https://swolchok.github.io/objcperf/ if you're curious, and https://fb.workplace.com/groups/aexpixfn/posts/1909150855887748 for the impact of a conversion) Reviewed By: RSNara Differential Revision: D31949241 fbshipit-source-id: dd40871d48f1de168d360168c4dd60015145d7e3
1 parent ecfb637 commit 9fc3fc8

File tree

4 files changed

+44
-3
lines changed

4 files changed

+44
-3
lines changed

BUCK

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ REACT_PUBLIC_HEADERS = {
307307
"React/RCTVersion.h": RCTBASE_PATH + "RCTVersion.h",
308308
"React/RCTView.h": RCTVIEWS_PATH + "RCTView.h",
309309
"React/RCTViewManager.h": RCTVIEWS_PATH + "RCTViewManager.h",
310+
"React/RCTViewUtils.h": RCTVIEWS_PATH + "RCTViewUtils.h",
310311
"React/RCTWeakProxy.h": RCTBASE_PATH + "RCTWeakProxy.h",
311312
"React/RCTWeakViewHolder.h": RCTVIEWS_PATH + "RCTWeakViewHolder.h",
312313
"React/RCTWrapperViewController.h": RCTVIEWS_PATH + "RCTWrapperViewController.h",

React/Views/RCTViewUtils.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
#import <React/RCTDefines.h>
9+
10+
NS_ASSUME_NONNULL_BEGIN
11+
12+
RCT_EXTERN_C_BEGIN
13+
14+
UIEdgeInsets RCTContentInsets(UIView *view);
15+
16+
RCT_EXTERN_C_END
17+
18+
NS_ASSUME_NONNULL_END

React/Views/RCTViewUtils.m

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
#import "RCTViewUtils.h"
9+
10+
#import "UIView+React.h"
11+
12+
UIEdgeInsets RCTContentInsets(UIView *view)
13+
{
14+
while (view) {
15+
UIViewController *controller = view.reactViewController;
16+
if (controller) {
17+
return controller.view.safeAreaInsets;
18+
}
19+
view = view.superview;
20+
}
21+
return UIEdgeInsetsZero;
22+
}

packages/rn-tester/Podfile.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ SPEC CHECKSUMS:
881881
CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99
882882
DoubleConversion: 831926d9b8bf8166fd87886c4abab286c2422662
883883
FBLazyVector: b81a2b70c72d8b0aefb652cea22c11e9ffd02949
884-
FBReactNativeSpec: c41af89a2aca37e9fe937133ffe6758301ded893
884+
FBReactNativeSpec: cd36c48651d54982428c1b0afd5557993b45e92c
885885
Flipper: 30e8eeeed6abdc98edaf32af0cda2f198be4b733
886886
Flipper-Boost-iOSX: fd1e2b8cbef7e662a122412d7ac5f5bea715403c
887887
Flipper-DoubleConversion: 57ffbe81ef95306cc9e69c4aa3aeeeeb58a6a28c
@@ -923,10 +923,10 @@ SPEC CHECKSUMS:
923923
React-RCTTest: 12bbd7fc2e72bd9920dc7286c5b8ef96639582b6
924924
React-RCTText: e9146b2c0550a83d1335bfe2553760070a2d75c7
925925
React-RCTVibration: 50be9c390f2da76045ef0dfdefa18b9cf9f35cfa
926-
React-rncore: a1249129f80f05d7e3bcba35239ceb394c1052cc
926+
React-rncore: fb776508453c32c72c6325f421468eb8a1f3e2c4
927927
React-runtimeexecutor: 4b0c6eb341c7d3ceb5e2385cb0fdb9bf701024f3
928928
ReactCommon: 7a2714d1128f965392b6f99a8b390e3aa38c9569
929-
ScreenshotManager: ec701affd6d2a5dabf8739b0cdcc937f7dbd2ac6
929+
ScreenshotManager: b6b23f4913712a245102024854656634fee33265
930930
Yoga: c0d06f5380d34e939f55420669a60fe08b79bd75
931931
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a
932932

0 commit comments

Comments
 (0)