Граф коммитов

3208 Коммитов

Автор SHA1 Сообщение Дата
Valentin Shergin d3bb76b8b6 Fabric: Using RCTUIColorFromSharedColor everywhere
Summary:
Even though we have wonderful helper functions converting SharedColor to UIColor and CGColorRef, in many places we still use some hardcoded things. This diff fixes that; it will be important for the next diff.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D23753508

fbshipit-source-id: 09d280b132266252753526c2735ab3e41b96c8d5
2020-09-17 11:12:28 -07:00
Valentin Shergin f2ca6f568e Fabric: Removing `RCTCGColorRefUnretainedFromSharedColor()`
Summary:
This diff removes `RCTCGColorRefUnretainedFromSharedColor` function because it's not compatible with future changes we plan to make.
Converting SharedColor to unretained CGColorRef is actually quite dangerous because... it's an unowned pointer.

Reviewed By: JoshuaGross

Differential Revision: D23753509

fbshipit-source-id: df030ade69b63cbb872d6bdbde51575eedc6a4a6
2020-09-17 11:12:28 -07:00
Valentin Shergin 2103839525 Fabric: Optimized hit-testing
Summary:
An experiment where we use `LayoutMetrics::overflowInset` to optimize performance of hit-testing algorithm.
In my measurements enabling this feature drastically (2x) reduced amount of calls to `hitTest:withEvent:` method.

Reviewed By: sammy-SC

Differential Revision: D23669091

fbshipit-source-id: ac6dadc90b6a2fbb45e41e0d4a113bd5ae8f1218
2020-09-15 22:29:30 -07:00
Samuel Susla b705eafd22 Fix retain cycle in RCTFabricSurface
Summary:
Changelog: [internal]

Fix retain cycle caused by chain: `RCTSurfaceTouchHandler` -> `RCTSurfaceTouchHandler._rootComponentView` -> `RCTSurfaceTouchHandler`

`RCTSurfaceTouchHandler._rootComponentView` calls `addGestureRecognizer` with `RCTSurfaceTouchHandler` as a parameter which, according to documentation, strongly holds onto gesture recogniser.

https://www.internalfb.com/intern/diffusion/FBS/browsefile/master/xplat/js/react-native-github/React/Fabric/RCTSurfaceTouchHandler.mm?lines=189

For details about `addGestureRecognizer`, refer to https://developer.apple.com/documentation/appkit/nsview/1483749-addgesturerecognizer?language=objc#

Reviewed By: shergin

Differential Revision: D23704441

fbshipit-source-id: b1ab0feff552eaf10c1c71a931690c5258ce87cf
2020-09-15 17:34:35 -07:00
Ullrich Schäfer 845e9eaafb Fix for loading state of Fast Refresh from user defaults (#29880)
Summary:
Disabling Fast Refresh won't be persisted when restarting the app.

I believe this regressed with 824e171117. In this commit `HMRClient.setup` will always be called with `enabled` being set true. This PR loads the _enabled_ state from the user defaults (as it was done before).

## Changelog

[iOS] [Fixed] - Enable Fast Refresh gets persisted across app launches

Pull Request resolved: https://github.com/facebook/react-native/pull/29880

Test Plan:
Without this change Fast Refresh is enabled on every app restart.

Tested with this change:
- Disabling Fast Refresh
- Restarting App -> Fast Refresh still disabled
- Enabled Fast Refresh again
- Restarting App -> Fast Refresh still enabled again

Reviewed By: sammy-SC

Differential Revision: D23686435

Pulled By: PeteTheHeat

fbshipit-source-id: 42c31b22060d3dc4b1d4cb8f41792b303fc7fce8
2020-09-14 17:45:53 -07:00
Paige Sun acda299453 6/6 Log image-rendered for Fabric image logging
Reviewed By: fkgozali

Differential Revision: D23450649

fbshipit-source-id: 58265a2c7855a2f4371d68637f09a07921821adf
2020-09-11 15:09:12 -07:00
Paige Sun 24ba03ccae 4/6 Log view-appear and view-disappear for Fabric image logging
Reviewed By: fkgozali

Differential Revision: D23447863

fbshipit-source-id: db16d97034a8d4ba6fcd08da5068039450f3c57b
2020-09-11 15:09:12 -07:00
Paige Sun 13759f192d 3/6 Add IGviewpoint for image visibility callbacks
Summary: Changelog: [Internal] Add IGviewpoint to get image visibility callbacks for when an UIImageView is in or out of view

Reviewed By: fkgozali

Differential Revision: D23428528

fbshipit-source-id: 87e4cee8fbe3c6b7da5153f87bbb530b2f990d96
2020-09-11 15:09:12 -07:00
Valentin Shergin 661d34bb42 Fabric: Removing MainRunLoopEventBeat and RuntimeEventBeat (iOS)
Summary:
The `enable_run_loop_based_event_beat_ios` experiment was shipped a couple of months ago.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D23606061

fbshipit-source-id: e1926f46933d6603f20104f211c944c50173a627
2020-09-11 08:23:27 -07:00
Jayme Deffenbaugh cb719a16cc Fix Xcode warnings in React-Core pod (#29622)
Summary:
With the upgrade to React Native 0.63, we started running into nullability warnings that were breaking our build. This PR fixes those nullability warnings as well as a few other warnings in React-Core.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[iOS] [Fixed] - Fix xcodebuild warnings in React-Core

Pull Request resolved: https://github.com/facebook/react-native/pull/29622

Test Plan:
- Nullability annotations should only affect compilation, but even though RNTester compiles, I'm not fully convinced that this won't break projects downstream. It would be good to get another opinion on this.
- The change in `RCTAllocateRootViewTag` is the only real logic change in this PR. We throw an exception if the root view tag is not in the correct format, so this change seems safe after some basic manual testing in RNTester.

Reviewed By: shergin

Differential Revision: D23386678

Pulled By: appden

fbshipit-source-id: a74875195a4614c3248e8f968aa98602e3ee2de0
2020-09-09 12:48:09 -07:00
Ramanpreet Nara f5c246d50e Use reader/writer lock for TurboModule cache access
Summary:
Right now, when two threads require two NativeModules, both threads fight for the same `std::mutex`. Why? Because NativeModule require can read from/write to the shared `std::unordered_map<std::string, TurboModuleHolder*>`.

**A Few Thoughts:**
- All threads should be able to read from the TurboModule cache concurrently, without issue. Only writes into the cache require exclusive access. *With our current setup, both reads and writes acquire exclusive access.*
- During the lifetime of an application, there will only be tens of NativeModule create events (i.e: writes into the TurboModule cache). However, there may be hundreds, if not thousands of TurboModule cache lookups. *We don't need to serialize those hundreds/thousands of TurboModule cache reads.*

This is a potential optimization opportunity for the TurboModule infra.

## Changes
This diff introduces a `std::shared_mutex` inside `RCTTurboModuleManager`. We use either the regular `std::mutex` or the `std::shared_mutex`, depending on whether `RCTTurboModuleSharedMutexInitEnabled()` is `YES`.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D23413118

fbshipit-source-id: 0880413c691b141db98a2715648f0c3e05983307
2020-09-09 09:31:38 -07:00
Mi-ZAZ 8933724d7d Update RCTModalHostViewManager.m (#29745)
Summary:
Fix a issue that RCTModalHostView can't be dismissed while being presented

Steps To Reproduce
A native modal presented view controller is being dismissed before the first screen shows.
A RCTModalHostView is presented when the first screen shows.
The RCTModalHostView will be dismissed after an asynchronous callback.
If the callback was called before the completion of the presenting animation, the RCTModalHostView will not be dismissed.

## Changelog

[iOS] [Fixed] - Fix that RCTModalHostView can't be dismissed while being presented

Pull Request resolved: https://github.com/facebook/react-native/pull/29745

Reviewed By: shergin

Differential Revision: D23566487

Pulled By: sammy-SC

fbshipit-source-id: bd95f200b79fa75e2387e402091d58c0f538759c
2020-09-09 06:41:06 -07:00
Valentin Shergin 7e899348c7 Fabric: Better error reporting in UIView+ComponentViewProtocol
Summary:
We need this to make crash logs more actionable. For now we know that those asserts fire so we should make them actionable.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D23580103

fbshipit-source-id: 8532e33b016e738a4f128c9b547c33d204610bcc
2020-09-08 16:45:27 -07:00
Valentin Shergin 1b994f9ddd Proxing NSException stack trace to NSError object
Summary:
When we catch an Objective-C exception and convert it to NSError we need to somehow represent the call stack from NSException instance in NSError instance. For now, we just attach the stack trace to `message` field.

The next step would be to figure out how to pass the Objective-C stack trace to error reporting infra to help it to display the stack trace nicely in the web interface.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D23557600

fbshipit-source-id: a080c2e186e719e42dcfc01bb12f5811e3c5b2e6
2020-09-08 13:22:54 -07:00
Samuel Susla 67af6e54fc Fix removal for nested legacy interop layer
Summary:
Changelog: [Internal]

In https://fburl.com/diffusion/3705cj0i we assert that view which is about to be recycled, has no superview.
This is a problem in Legacy interop layer which is nested within another interop layer. This originally wasn't considered.

Removing views in `finalizeUpdates` like it has been done until now is not enough because when a component is deleted, `finaliseUpdates` isn't called.

Reviewed By: shergin

Differential Revision: D23572999

fbshipit-source-id: f007dfe293b7d27d56253656c02529163304f83c
2020-09-08 10:53:57 -07:00
Samuel Susla 4b95bb2f84 Check for nullability of [NSString UTF8String]
Summary:
Changelog: [internal]

[NSString UTF8String] is nullable. Therefore, we need to check if it isn't nil before passing it to std::string constructor which crashes if it's nil.

Reviewed By: shergin

Differential Revision: D23572652

fbshipit-source-id: 59e7f5e918b2e5c69333bfb687371f856555d8e0
2020-09-08 10:29:21 -07:00
Moti Zilberman 345baf477c Fix reorder-init-list warning in RCTViewComponentView
Summary:
Changes the order of `RCTBorderColors` field designators to match their declaration order, fixing one case of `-Wreorder-init-list` when compiling the RN codebase with Xcode 12.

Changelog: [Internal]

Reviewed By: MichaReiser

Differential Revision: D23447685

fbshipit-source-id: f04a3841187f0869d2efb60e81ce075c45f27f3c
2020-09-01 07:32:57 -07:00
Jimmy Zhang 7d44959940 Respect port information if available from RCTBundleURLProvider
Summary:
Changelog:
Sometimes a port different than kRCTBundleURLProviderDefaultPort (8081) can be specified to RCTBundleURLProvider for packager checking or requesting resources through saving them in JSLocation, this adds support for that rather than always falling back to kRCTBundleURLProviderDefaultPort

Reviewed By: PeteTheHeat

Differential Revision: D23395548

fbshipit-source-id: b7a6f0816d1f226a2e3fb82bf2dc0ab9e79ef966
2020-08-28 16:01:02 -07:00
Eloy Durán 941bc0ec19 Upstream RN macOS Hermes integration bits (#29748)
Summary:
Microsoft’s RN for macOS fork supports the Hermes engine nowadays https://github.com/microsoft/react-native-macos/pull/473. As a longer term work item, we’ve started moving bits that are not invasive for iOS but _are_ a maintenance burden on us—mostly when merging—upstream. Seeing as this one is a recent addition, it seemed like a good candidate to start with.

As to the actual changes, these include:

* Sharing Android’s Hermes executor with the objc side of the codebase.
* Adding a CocoaPods subspec to build the Hermes inspector source and its dependencies (`Folly/Futures`, `libevent`).
* Adding the bits to the Xcode build phase script that creates the JS bundle for release builds to compile Hermes bytecode and source-maps…
* …coincidentally it turns out that the Xcode build phase script did _not_ by default output source-maps for iOS, which is now fixed too.

All of the Hermes bits are automatically enabled, on macOS, when providing the `hermes-engine-darwin` [npm package](https://www.npmjs.com/package/hermes-engine-darwin) and enabling the Hermes pods.

## Changelog

[General] [Added] - Upstream RN macOS Hermes integration bits

Pull Request resolved: https://github.com/facebook/react-native/pull/29748

Test Plan:
Building RNTester for iOS and Android still works as before.

To test the actual changes themselves, you’ll have to use the macOS target in RNTester in the macOS fork, or create a new application from `master`:

<img width="812" alt="Screenshot 2020-08-18 at 16 55 06" src="https://user-images.githubusercontent.com/2320/90547606-160f6480-e18c-11ea-9a98-edbbaa755800.png">

Reviewed By: TheSavior

Differential Revision: D23304618

Pulled By: fkgozali

fbshipit-source-id: 4ef0e0f60d909f3c59f9cfc87c667189df656a3b
2020-08-27 01:18:33 -07:00
Samuel Susla 33c16689a8 Deallocate UIViewController after it was used in Modal component
Summary:
Changelog: [Internal]

# Problem
`RCTModalHostViewComponentView` reuses the same UIViewController between recycles. This can be a problem if dismissal of the modal is animated as the UIViewController is still presented while it is being dismissed. That's when "Application tried to present modally an active controller" exception can happen.

# Solution
Deallocate UIViewController when `RCTModalHostViewComponentView` is recycled.

Reviewed By: PeteTheHeat

Differential Revision: D23345711

fbshipit-source-id: da540571184afcb88b52758c4a1f0b4ec5874eb1
2020-08-26 18:49:21 -07:00
Samuel Susla 9b973f32e4 Fix TextInput value not restoring after reuse
Summary:
Changelog: [Internal]

# Problem

The problem was setting `_backedTextInputView.attributedText` to nil inside `[RCTTextInputComponentView prepareForRecycle]`.

Ordinarily this isn't a problem becase `UIManager::updateState` drops the update if the ShadowNode no longer exists. But in certain cases the ShadowNode can exist, empty string being set as its value

# Fix

Fix is trivial, invalidate state before nullifying `_backedTextInputView`. This prevents the state update from being dispatched.

# Discussion

We should go over all other components and make sure state is invalidated as first thing in `[RCTViewComponentView prepareForRecycle]`.

Reviewed By: shergin

Differential Revision: D23324929

fbshipit-source-id: 9568e920d99683ad95f965ef4b63c529f50f3283
2020-08-25 15:43:08 -07:00
Samuel Susla b7afbb1fe2 Use window size instead of screensize for maximum size
Summary:
Changelog: [Internal]

This was set to screensize in D13104172 (346c9d5f2c) to work around issues at that time.
The issues might not be around anymore.

Reviewed By: PeteTheHeat

Differential Revision: D23298723

fbshipit-source-id: 4f33a2cc65ae4fe5ba20b0b2b270b135878c339f
2020-08-25 06:50:34 -07:00
Samuel Susla 258387ddaa Use window size instead of screen size in InputAccessoryView
Summary:
Changelog: [internal]

Use window size instead of screen size to layout InputAccessoryView.

Reviewed By: PeteTheHeat

Differential Revision: D23297141

fbshipit-source-id: d6d7223342d17a2e1b9e5fca6f999b7ad365d056
2020-08-25 06:50:34 -07:00
Samuel Susla 9aabc8cdf0 Use window size instead of screen size in BottomSheet
Summary: Changelog: [internal]

Reviewed By: shergin

Differential Revision: D23294566

fbshipit-source-id: 1da67feff377a2f8c843b961ce3b381f6b16828b
2020-08-25 06:50:34 -07:00
Peter Argany 6d58490187 Fix RCTEventDispatcher Crash
Summary:
This crash was introduced in D22962320 (ffdfbbec08), which landed 8/17 and went into 8/23 cut. I plan to pick this diff into that release.

I can't repro this, but there must be a scenario (in bridged mode), where we try to flush event queue while bridge is tearing down. I plan to consider this scenario going forward.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D23306445

fbshipit-source-id: 285d4b94a17423c3b08d83e7041c4ee04b7e6d0c
2020-08-24 17:21:06 -07:00
Samuel Susla 00563575ba Fix native command dispatch from RCTLegacyViewManagerInteropComponentView
Summary:
Changelog: [Internal]

# Problem

In D22274782 (fb2b49d298) I removed integration between Paper and Fabric. However this integration was still used by `RCTLegacyViewManagerInteropComponentView` for view commands dispatch.

Fix is to use `[RCTUIManager viewForReactTag:viewTag]` instead of viewRegistry.

Reviewed By: shergin

Differential Revision: D23291567

fbshipit-source-id: 35c50716fd8b86ae25b1534e4d8aa688c8e6e129
2020-08-24 10:33:56 -07:00
Samuel Susla 1704a725c5 Use ConcreteStateTeller in RCTImageComponentView
Summary: Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D23239098

fbshipit-source-id: fa558e705e121f3d3fbded80ae99e5f51c80ae4a
2020-08-24 06:43:18 -07:00
Samuel Susla 0f7a1145ff Use ConcreteStateTeller in RCTInputAccessoryComponentView
Summary: Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D23239095

fbshipit-source-id: a3324b5df6e6bd7508d74b66de9235852d828bbd
2020-08-24 06:43:18 -07:00
Samuel Susla 0b532e1be7 Use ConcreteStateTeller in RCTLegacyViewManagerInteropComponentView
Summary: Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D23239097

fbshipit-source-id: 4c0d7b24917509d3d9660098349c226ad42e832e
2020-08-24 06:43:18 -07:00
Samuel Susla 9a5807162c Use ConcreteStateTeller in RCTParagraphComponentView
Summary: Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D23239100

fbshipit-source-id: 10d10a369cb7ec82d2f6118a21ec70c2cc20abb3
2020-08-24 06:43:18 -07:00
Samuel Susla c2dab01c62 Use ConcreteStateTeller in RCTModalHostViewComponentView
Summary: Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D23239096

fbshipit-source-id: b82301e5db48861d6d241abd681df38701e3ac44
2020-08-24 06:43:18 -07:00
Samuel Susla ca091b009a Use ConcreteStateTeller in RCTScrollViewComponentView
Summary: Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D23238812

fbshipit-source-id: 8c777ae1264cfade507bfd336eefbe86ffb94b8f
2020-08-24 06:43:18 -07:00
Samuel Susla 724952e5d6 Use ConcreteStateTeller in RCTSafeAreaViewComponentView
Summary: Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D23238703

fbshipit-source-id: 67596194b599ce8d39a6e7403bf61dce0fd61434
2020-08-24 06:43:18 -07:00
Samuel Susla e454863bca Use ConcreteStateTeller in RCTTextInputComponentView
Summary: Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D23216864

fbshipit-source-id: 2b82e2d43cc694251a1873ad9059eff4abca4e73
2020-08-24 06:43:17 -07:00
Paige Sun 6aa63272dc Create internal Fabric subclass of RCTImageComponentView
Summary: Changelog: [Internal] Create internal Fabric subclass of RCTImageComponentView

Reviewed By: sammy-SC

Differential Revision: D23211115

fbshipit-source-id: 0e756de3f3e555bf212dc88dfc8c32930ac85132
2020-08-22 01:19:10 -07:00
Peter Argany 38c3b95798 Bridgeless support for RCTKeyboardObserver
Summary:
RCTKeyboardObserver only uses the bridge to avoid sending events during a reload. See D6573855 (d9c658566a) for reference.

In bridgeless mode, the bridge is expected to always be nil, as the module uses `invokeJS` block to send events instead.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D23176990

fbshipit-source-id: 7946c9c2684d7d9ea0a606bad375309a5530a719
2020-08-21 13:21:12 -07:00
Jimmy Zhang 12543d557f Remove port from JSLocation when returning packager host
Summary:
Changelog:
Some callsites may rely on the assumption that address return by this method does not contain port information. JSLocation saved in NSUserDefault might contain port information, removing it here can prevent the issue for callsites.

Differential Revision: D23240495

fbshipit-source-id: a2edf4abb086fd951dd089331407bd659aad1729
2020-08-20 09:25:18 -07:00
Samuel Susla 7d7903cd43 Back out "Fabric: Asserting if the RuntimeExecutor callback in RCTRuntimeExecutorFromBridge is not called"
Summary:
Changelog: [internal]

Original commit changeset: f11932019ab6

Reviewed By: JoshuaGross

Differential Revision: D23212230

fbshipit-source-id: 9e35e107eca5a25ba164e4588aa1c9c3517c6056
2020-08-19 11:01:26 -07:00
Lulu Wu bdbb040382 Fix Logbox Fullscreen View
Summary:
Logbox inside bridgeless surfaces was crashing and not able to open, this diff should fix it.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D23043773

fbshipit-source-id: 6e584f97e53e626b9bfedd6dc997ba6ba8c08b8f
2020-08-18 12:29:45 -07:00
Samuel Susla e4cfbbad6d Introduce RCTFBModalComponentView
Summary: Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D23155490

fbshipit-source-id: 2c83c2ec71ca4d842275b4db6aac7169d3d77955
2020-08-17 15:44:29 -07:00
Paige Sun e1a5bd6bd6 Stop logging for Fabric from FBReactStreamingImageLoader
Summary: Changelog: [Internal]  Stop logging for Fabric from FBReactStreamingImageLoader

Reviewed By: fkgozali

Differential Revision: D23172395

fbshipit-source-id: d9fc4e82958d2f88ff91bddeb385fe3073cd8f1e
2020-08-17 15:44:29 -07:00
Samuel Susla 4c86bc6a41 Prevent RCTStringFromNSString from crashing if passed nil
Summary:
Changelog: [Internal]

[UITextField attributedText] is nullable. If it returns nil, we would crash inside `RCTStringFromNSString`.
[Source](https://developer.apple.com/documentation/uikit/uitextfield/1619602-attributedtext?language=objc)

Reviewed By: shergin

Differential Revision: D23154453

fbshipit-source-id: 33ec4950c4011461d0c4de3a4da3db760a8924b9
2020-08-16 10:28:41 -07:00
Samuel Susla c429ee9974 Implement ScrollView.contentInsetAdjustmentBehavior
Summary:
Changelog: [internal]

Fabric's ScrollView was ignoring value of `ScrollView.contentInsetAdjustmentBehavior`, this diff fixes that.

Reviewed By: shergin

Differential Revision: D23102235

fbshipit-source-id: 8cf42e730b560a21d56d7e007059109ccd01154e
2020-08-13 10:11:46 -07:00
Valentin Shergin b2570bd74d Removing `dispatch_async`-delayed TTRC reporting for Fabric TTRC tracker (gated)
Summary:
This diff introduces a new experiment touching performance measuring infra.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D23071089

fbshipit-source-id: 22e6f34754956311bd6a0140fe2accd5758d87c7
2020-08-12 12:12:47 -07:00
Samuel Susla 22c1032dbc Fix text not being restored from state in TextInput
Summary:
Changelog: [internal]

Restore text value from state when re-initialising RCTTextInputComponentView

Reviewed By: shergin

Differential Revision: D22844624

fbshipit-source-id: b47e3fe890793f8de429b637535d641262c42be2
2020-08-11 13:20:30 -07:00
Jiayan Zhuang b628d4f5d5 Fix the frame issue for truncated text
Summary:
Changelog:
[Internal] - Fix the frame issue for truncated text.

When double tapping to expand/truncate the text, the rect of the element always moves to the top and then come back to the original place.. This seems because after truncating/expanding the text, the view would re-render and the container would be destroyed. I used the API accessibilityFrameInContainerSpace to set the frame before. And the frame was not updated properly. Converting the bound to the screen coordinates and set accessibilityFrame directly fixed it.

Reviewed By: PeteTheHeat

Differential Revision: D23040295

fbshipit-source-id: 1b449c39c79007d5321ff7b565c170f6d3fab8a4
2020-08-10 17:54:33 -07:00
Samuel Susla 154ce78972 Take viewport offset into account in UIManager.measureInWindow
Summary:
Changelog: [Internal]

Fabric's UIManager.measureInWindow didn't take viewport's offset into account. This diff fixes it by including viewport's offset in `LayoutContext`.

Reviewed By: JoshuaGross

Differential Revision: D23021903

fbshipit-source-id: 9106a8789d66fe19d8cb0a9378ee5bc8f2c83005
2020-08-10 12:52:23 -07:00
Samuel Susla 3be9f3ef2c Make RCTSurface and RCTFabricSurface conform to common protocol
Summary:
Changelog: [internal]

RCTSurface and RCTFabricSurface are two distinct classes that need to have the same interface otherwise the program crashes. This diff ties their interfaces through a protocol, triggering a build time error if they diverge.

Reviewed By: PeteTheHeat, JoshuaGross

Differential Revision: D23021837

fbshipit-source-id: 09ce345298ec2b45ac5a3fd2e0d3f5fa757a174f
2020-08-10 12:52:23 -07:00
Peter Argany ffdfbbec08 Support bridgeless in RCTEventDispatcher
Summary:
This ties the stack together, utilizes new TM functionality to avoid using the bridge in `RCTEventDispatcher`.

Changelog: [Internal]

Differential Revision: D22962320

fbshipit-source-id: de4e001a4a6ce232c37d7feed1e0c0d1d70a80f8
2020-08-07 11:55:51 -07:00
Peter Argany c494d590fb Workarounds for two bridge methods: dispatchToJSThread and enqueueJSCall:
Summary:
To get `RCTNativeAnimatedModule` working bridgeless, I need to get `RCTEventDispatcher` working bridgeless.

To get `RCTEventDispatcher` working bridgeless, I need to support 2 new bridge methods:
- `- (void)enqueueJSCall:(NSString *)moduleDotMethod args:(NSArray *)args`
- `- (void)dispatchBlock:(dispatch_block_t)block queue:(dispatch_queue_t)queue;`

For (1) I copied the bridge impl exactly. For (2), the bridge only dispatches to JS thread, else uses `dispatch_async`. I only added support for dispatching to JS thread, callers can `dispatch_async` themselves if they want to.

Changelog: [Internal]

Differential Revision: D22962292

fbshipit-source-id: e34d15aee72f80dffcaa945bfda05ea415f66df7
2020-08-07 11:55:51 -07:00
Peter Argany fcb667059d Fix refresh control redbox
Summary: Changelog:[Internal]

Reviewed By: Vince0613

Differential Revision: D22989945

fbshipit-source-id: 735da1cf103b2465663ecb6abfd49e512aff9a1e
2020-08-06 17:31:47 -07:00
Jiayan Zhuang dd040a87a7 Implement localization for accessibility guide words (#29576)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/29576

Changelog:
[Internal] - Implement localization for accessibility guide words

Reviewed By: PeteTheHeat

Differential Revision: D22419882

fbshipit-source-id: 85fc4e741df3c59b64173c027a3c4e61b01bad4c
2020-08-06 16:38:56 -07:00
Devon Deonarine f319ff321c iOS: Update RCTAlertManager to use new RCTAlertController (#29295)
Summary:
This should fix https://github.com/facebook/react-native/issues/29082 and https://github.com/facebook/react-native/issues/10471

Currently when an alert is being shown while a modal is being dismissed, it causes the alert not to show and In some cases it causes the UI to become unresponsive. I think this was caused by using RCTPresentedViewController to try and display the Alert the currently presented view. The View the Alert was going to be shown on is dismissed and the modal doesn't show. I implemented a new RCTAlertController to show the alert on top of the view, the modal being dismissed should now not interfere with the alert being shown.

## Changelog

[iOS] [Fixed] - Fixed showing Alert while closing a Modal

Pull Request resolved: https://github.com/facebook/react-native/pull/29295

Test Plan:
To recreate the bug:

1. npx react-native init Test --version 0.63.0-rc.1
2. Paste the following code into App.js

```javascript
/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 *
 * format
 * flow strict-local
 */

import React from 'react';
import {
  SafeAreaView,
  StyleSheet,
  View,
  Text,
  StatusBar,
  Modal,
  Alert
} from 'react-native';

const App: () => React$Node = () => {
  const [visible, setVisible] = React.useState(false)

  const onShowModal = () => {
    setVisible(true)
  }

  onCloseBroken = () => {
    setVisible(false)
    Alert.alert('Alert', 'Alert won\'t show')
  }

  onCloseWorking = () => {
    setVisible(false)
    setTimeout(() => Alert.alert('Alert', 'Works fine'), 10)
  }

  return (
    <>
      <StatusBar barStyle="dark-content" />
      <SafeAreaView style={styles.container}>
        <Text onPress={onShowModal}>Show modal</Text>
      </SafeAreaView>
      <Modal animationType="fade" visible={visible} onRequestClose={onCloseWorking} >
        <View style={styles.container}>
          <Text onPress={onCloseBroken}>Close modal immediately</Text>
          <Text onPress={onCloseWorking}>Close modal with delay</Text>
        </View>
      </Modal>
    </>
  )
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'space-around',
  },
})

export default App

```

3. cd Test && npx react-native run-ios
4. Show the modal and click the `Close modal immediately` button

The first button doesn't show the alert, the second does because it gets rendered after the modal view is dismissed. After this commit, the alert always shows on top of every view properly. You can test by pointing the react native package to my branch by modifying the package json file like this

```
    "react-native": "https://github.com/devon94/react-native.git#fix-ios-modal"
```

I was unable to reproduce the case where it causes the UI to be responsive in the test app but was able to reproduce it in our react native app at work. I can provide a video later if needed but the code is too complex to simplify into a test case.

Reviewed By: sammy-SC

Differential Revision: D22783371

Pulled By: PeteTheHeat

fbshipit-source-id: 3e359645c610074ea855ee5686c59bdb9d6b696b
2020-08-06 16:20:47 -07:00
Jiayan Zhuang 07640dce69 Build the basic RCTLocalizationProvider
Summary:
Changelog:
[Internal][Add] - Build the basic RCTLocalizationProvider

RCTLocalizationProvider is to enable the localization in fabric. But I'd start with internal apps now.

Reviewed By: PeteTheHeat

Differential Revision: D22704051

fbshipit-source-id: 845693a131c325f3c3d92b2ff491d5421966ad3e
2020-08-06 14:35:35 -07:00
Jiayan Zhuang 3f405dcbd2 Add support for accessibilityRole = "switch"
Summary:
Changelog:
[Internal] - Add support for accessibilityRole = "switch"

Reviewed By: sammy-SC

Differential Revision: D22906500

fbshipit-source-id: 81dfbfd56a24c89ffedc0fde5a63f7bdeed0c5db
2020-08-06 13:16:48 -07:00
Jiayan Zhuang 6fa9dbabfc Update accessibilityState prop
Summary:
Changelog:
[Internal] - Add default value for accessibilityState "checked" and handle unhandled states.

It is also work for the case that accessibilityRole = "switch" and accessibilityState is set.

Reviewed By: sammy-SC

Differential Revision: D22914427

fbshipit-source-id: 4767a21f3bd109019b57bc09918758a38fbdea93
2020-08-06 12:14:38 -07:00
Nicholas Tinsley 389b0b4bd1 Mark RN method as requiring iOS 10+
Summary:
as title. The output of Buck suggested I add this, so I did and it let me build.

Changelog:
[Internal][Fixed] - Added iOS 10 method compatibility macro

Reviewed By: PeteTheHeat

Differential Revision: D22955013

fbshipit-source-id: 6aa03b164adca480e7c6f661b221c9bd3ee6c4f1
2020-08-05 14:49:07 -07:00
Yogev Ben David 1b0fb9bead iOS: Fix refreshControl layouting (#28236)
Summary:
In `react-native-navigation` we allow the usage of native iOS navigationBar **largeTitle** which cause the title to "jump" when pulling to refresh.
We found that the layout calculations of the refreshControl element mess up the system behaviour.

## Changelog

[iOS] [Fixed] - Fix refreshControl messes up navigationBar largeTitles

Pull Request resolved: https://github.com/facebook/react-native/pull/28236

Test Plan:
### Before the fix:
![before](https://user-images.githubusercontent.com/10794586/75991307-f7c7ec00-5efe-11ea-8cd9-ab8c3fbe1dc1.gif)

### And after:
![after](https://user-images.githubusercontent.com/10794586/75990618-d9152580-5efd-11ea-8c72-5deb6d83a840.gif)

### How it looks like with react-native init app after the fix:
![ezgif com-video-to-gif (4)](https://user-images.githubusercontent.com/10794586/77253369-54970680-6c62-11ea-9ad6-3265e23044e6.gif)

Reviewed By: sammy-SC

Differential Revision: D22782680

Pulled By: PeteTheHeat

fbshipit-source-id: f86ccd0a6ad492312029a69b392cd525450fe594
2020-08-05 11:51:30 -07:00
Jiayan Zhuang df66b7a4d2 Add UIContentSizeCategoryDidChangeNotification to re-render text
Summary:
Changelog:
[Internal] - Add UIContentSizeCategoryDidChangeNotification to re-render text

We don't need to restart the app to re-render text now, but we still need to swipe the screen or click on buttons to force to refresh. We may address this in the future.

Reviewed By: PeteTheHeat

Differential Revision: D22867293

fbshipit-source-id: 4747a45adc2bdc638cf7ef9c07a9484e48600583
2020-08-04 15:12:14 -07:00
Jiayan Zhuang a422592c95 Delete WEBKIT_IOS_10_APIS_AVAILABLE
Summary:
Changelog:
[Internal][Removed] - Delete WEBKIT_IOS_10_APIS_AVAILABLE because React Native doesn't support iOS 9 and WEBKIT_IOS_10_APIS_AVAILABLE would always be true.

Reviewed By: PeteTheHeat

Differential Revision: D22768504

fbshipit-source-id: 76dbf967260b26ee6c0a45d8ae099f137a3a4ec7
2020-08-04 09:10:00 -07:00
Samuel Susla 22584954cd Account for view offset in bottom sheet
Summary: Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D22887857

fbshipit-source-id: 97194737a5c7c83f0ff9b35d90608c5e7e9b6bab
2020-08-04 01:50:56 -07:00
Samuel Susla a1b6f7bd9e Fabric: Asserting if the RuntimeExecutor callback in RCTRuntimeExecutorFromBridge is not called
Summary:
The implementation of RuntimeExecutor must execute all provided callbacks. However, the implementation of RCTRuntimeExecutorFromBridge cannot guarantee it because it relies on Bridge to make the call. In this diff, we wrap the callback into a callable that asserts if it's not being called before destruction.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D22810439

fbshipit-source-id: f11932019ab6ccbab7e65db5919e0c64dcaf37ed
2020-08-03 10:45:14 -07:00
Samuel Susla f838c7e5c3 Fabric: Asserts in RCTRuntimeExecutorFromBridge
Summary:
The implementation of RuntimeExecutor must execute all provided callbacks. However, the implementation has some branches that lead to such cases. To understand if this happens and when we need to add some asserts.

Changelog: [Internal] Fabric-specific internal change.

Differential Revision: D22810440

fbshipit-source-id: 7c29b765045b644fe0ad9d56b4c253dfe9395c31
2020-08-03 10:45:14 -07:00
Samuel Susla c452b826df Implement ScrollView.snapToOffsets and associated props
Summary:
Changelog: [Internal]
Implementation is copied from Paper.

Reviewed By: shergin

Differential Revision: D22820677

fbshipit-source-id: 8eed7ecd4dc766e8579a89707849e041adb073eb
2020-08-03 07:08:29 -07:00
Samuel Susla 94d0078653 Implement ScrollView.snapToInterval and associated props
Summary:
Changelog: [Internal]

Implementation is copied from Paper.

Reviewed By: shergin

Differential Revision: D22794554

fbshipit-source-id: ccfa777356932d81aa986349fba1685acf65d7f1
2020-08-03 07:08:29 -07:00
Joshua Gross e3302eeeab LayoutAnimations: call onSuccess, onFailure callbacks
Summary:
Hook up onSuccess and onFailure callbacks to LayoutAnimations.

Note that in non-Fabric RN, onSuccess is not known to work in Android. I could not find any uses of onFailure and it's not documented, so for now, it is only called if the setup of the animation fails.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D22889352

fbshipit-source-id: 4306debb350388dd2b7a2cbfe295eb99723988e2
2020-08-02 16:37:03 -07:00
David Vacca 3093010ea5 move fabric to ReactCommon/react/renderer
Summary:
This diff moves fabric C++ code from ReactCommon/fabric to ReactCommon/react/renderer
As part of this diff I also refactored components, codegen and callsites on CatalystApp, FB4A and venice

Script: P137350694

changelog: [internal] internal refactor

Reviewed By: fkgozali

Differential Revision: D22852139

fbshipit-source-id: f85310ba858b6afd81abfd9cbe6d70b28eca7415
2020-07-31 13:34:29 -07:00
Peter Argany 00bc73f625 Fix misleading comment in RCTFabricSurface API
Summary:
Using RCTFabricSurface in bridgeless mode, this comment seems incorrect to me.

`[_surface start]`  needs to be called after initialization, or else the stage and `SurfacePresenter` registration never happen.

Maybe this comment used to be true, but it is misleading with the current implementation.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D22800934

fbshipit-source-id: c396cbd3fc1749b8e7ab571c9e7bc05cd352fc14
2020-07-28 14:41:26 -07:00
Jiayan Zhuang 3c52942506 Write tests to cover additional features in RCTParagraphComponentView
Summary:
Changelog:
[Internal] - Add additional tests to cover other features in RCTParagraphComponentView.

I mainly test the correctness of attributedString and fragments in the RCTParagraphComponentView.

Reviewed By: shergin

Differential Revision: D22668022

fbshipit-source-id: 6879eb6b6a6ace9e6e05f1486d4e4034ebfd73bc
2020-07-27 16:05:53 -07:00
Jiayan Zhuang 894b3aa389 Build the basic RCTParagraphComponentViewTests
Summary:
Changelog:
[Internal] - Build the basic RCTParagraphComponentViewTests. Add the content of tests.
I mainly test the cases of text with multiple links inside, text with link which crosses multiple lines and truncated text with link.

Reviewed By: shergin

Differential Revision: D22607097

fbshipit-source-id: c98b8d4c5424a3e51e2869f50bc5038f969e45e8
2020-07-27 15:37:31 -07:00
Jiayan Zhuang c03a6aba49 Setup the ShadowNode tree for RCTParagraphComponentViewTests (#29470)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/29470

Changelog:
[Internal] - Build the framework of the RCTParagraphComponentViewTests and do some setup.

I built a shadowNode tree here for future tests.

Reviewed By: shergin

Differential Revision: D22536626

fbshipit-source-id: c74b63b3319693b90c9d64b7f782a1a922b0d499
2020-07-27 15:37:31 -07:00
Valentin Shergin 8d613c6f32 Fabric: Implementation of BackgroundExecutor on iOS (and gating)
Summary:
This is an implementation of `BackgroundExecutor` on iOS.
In case if the experiment is successful, we will make it mandatory for all platforms.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D22743722

fbshipit-source-id: 7756d2947e962720b9970d48c74929ab407c0440
2020-07-24 23:52:48 -07:00
Peter Argany 9d3cefbbca Delete unused RCTAdditionalJavaScriptDidLoadNotification
Summary:
This notification was never used, I'd rather not have someone start relying on it, and need to figure out how to migrate them in bridgeless mode.

Changelog:[Internal]

Reviewed By: cpojer, RSNara

Differential Revision: D22513602

fbshipit-source-id: 80b179af8408abc6646a73380b4a66cade3f75f2
2020-07-23 17:11:32 -07:00
Peter Argany 448db78a88 Fix loading from Metro in Bridgeless mode (#29453)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/29453

Problem Statement: A native module needs to call a function on `ReactInstance` (in this case `loadScript`). Typically, this is handled by the bridge.
Current Bridgeless Solution: Create a new protocol (in this case `RCTJSScriptLoaderModule`) which lets a block be passed in TM init to forward the method call to `ReactInstance`. This is the best thing I could think of right now.

Changelog:[Internal]

Reviewed By: RSNara

Differential Revision: D22512748

fbshipit-source-id: e6559279b6e299e17d1199407129ad3902c41e6b
2020-07-23 17:11:32 -07:00
Peter Argany 91d16bbd9f Hardcode @available(iOS 10) to YES
Summary:
RN removed support for iOS 9 last year, therefore iOS10+ is always available.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D22655069

fbshipit-source-id: 77e85e0403ea7ea0febc8766c10bb6f94ea417ad
2020-07-22 11:00:32 -07:00
Jimmy Zhang bbb7bef539 Remove unnecessary packager running check when saved JSLocation is empty
Summary:
Changelog:
When the JSLocation is nil, checking whether the address is running is unnesarry and wasting time, adding a JSLocation length check to mitigate that.

Reviewed By: cpojer

Differential Revision: D22644574

fbshipit-source-id: c51fc1a8976ebc25cba2653581e1bfa479a1d70d
2020-07-21 09:55:11 -07:00
Valentin Shergin ec60ebe792 Introducing `YGPositionTypeStatic`
Summary:
Changelog: [Internal] Fabric-specific internal change.
This diff introduces a new value for `YGPositionType`: `YGPositionTypeStatic`.
No part of Yoga, RN, Litho or CK uses this value yet. `relative` and `static` values behave the same way for now. We also do not change any defaults. So, it should be fine.

Reviewed By: SidharthGuglani

Differential Revision: D22386732

fbshipit-source-id: 39cd9e818458ac2a91efb175f24a74c8c303ff08
2020-07-20 00:33:22 -07:00
Jiayan Zhuang 5ac524bdbc Add a condition to exclude accessibilityRole that not currently used
Summary:
Changelog:
[Internal] - Add an condition to exclude accessibilityRole that not currently used

Since I've added all the possible values in accessibilityRole enum, it is necessary to gate what needs to be an accessibilityElement. SO I add a condition to exclude accessibilityRole that not currently used.

Reviewed By: shergin

Differential Revision: D22559136

fbshipit-source-id: 910d59132984872b5a9816b8e390117b7b1e2e71
2020-07-16 08:34:31 -07:00
Valentin Shergin 9f699ae185 Fabric: Using TelemetryController in RCTMountingManager on iOS
Summary:
Here we use `TelemetryController` to instrument mounting transactions in RCTMoutingManagers and wire that with RCTMountingTransactionObserving protocol. Now, performance trackers (flags) that we use can obtain this information and report to some server-side infrastructure. (Which will be implemented in future diffs.)

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D22490581

fbshipit-source-id: 37695560437ae0e27845c3bda2030fe6fa4c6735
2020-07-15 23:30:33 -07:00
Jiayan Zhuang 4320359686 Reword the guide words
Summary:
Changelog:
[Internal] - Reword the guide words to make it more generic.

Considering the case that some languages are RTL so swiping right cannot guarantee to move to the link. iOS can handle the order of the words and accessibilityElements according to the language. But the accessibilityHint we hardcoded would be an issue. So we decided to reword it to be more generic.

Reviewed By: PeteTheHeat

Differential Revision: D22422498

fbshipit-source-id: 175711317961663d0b0b47e04d2ab600f63446fe
2020-07-14 11:24:32 -07:00
Jiayan Zhuang 8c602e271e Solve truncation attributed string case
Summary:
Changelog:
[Internal] - Add a `accessibilityHint` to the first accessibilityElement so that it will tell user double tap to expand or truncate the text after reading the whole text. Also add the `accessibilityRole` in `FBTextWithEntities` when shouldTruncated is true, which allow us to specially distinguish the shouldTruncated text.

Reviewed By: sammy-SC

Differential Revision: D22339875

fbshipit-source-id: ce22fe9d86eeba5a2750022acd2cdd2c06a1dc79
2020-07-14 09:55:32 -07:00
Ramanpreet Nara e549f6984e Gate TurboModule eager initialization
Summary:
TurboModule eager initialization is a bit dangerous if we get it wrong, which we did (twice): T69449176.

This diff gates TurboModule eager init behind a MC, so that we can control (i.e: turn off/on, and do gradually rollout of) TurobModule eager initialization in isolation from the larger TurboModules experiment.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D22460359

fbshipit-source-id: 3b8dce0529f1739bd68b8b16d6a28aa572d82c2c
2020-07-09 16:24:31 -07:00
Ramanpreet Nara a27c295f53 Rename RCTTurboModuleLookupDelegate to RCTTurboModuleRegistry
Summary:
## Why?
1. RCTTurboModuleLookupDelegate sounds a bit nebulous.
2. In JS and Java, we use a `TurboModuleRegistry` interface to require TurboModules. So, this diff will make JS, Java, and ObjC consistent.

Changelog:
[Internal]

Reviewed By: PeteTheHeat

Differential Revision: D22405754

fbshipit-source-id: 30c85c246b39d198c5b8c6ca4432a3196ca0ebfd
2020-07-07 16:25:11 -07:00
Ramanpreet Nara 103c863eaa Eagerly initialize TurboModules before executing JS bundle
Summary:
## Context
1. In FBReactModule jsExecutorForBridge, we asynchronously initialize a list of TurboModules on the main queue: https://fburl.com/diffusion/i56wi3px
2. After initializing the bridge, we start executing the JS bundle, here: e23e9328aa/React/CxxBridge/RCTCxxBridge.mm (L414-L417). Since bridge initialization knows nothing about TurboModule eager initialization, this happens concurrently with 1, and starts requiring NativeModules/TurboModules on the JS thread.

## The Race
1. Both the main thread and the JS thread race to create a TurboModule that requires main queue setup.
2. The JS thread wins, and starts creating the TurboModule. Meanwhile, the main thread blocks, waiting on a signal here, in RCTTurboModuleManager: e23e9328aa/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm (L430)
3. The JS thread tries to dispatch_sync to the main queue to setup the TurboModule because the TurboModule requires main queue setup, here: e23e9328aa/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm (L402)
4. We deadlock.

## The fix
Succinctly, NativeModule eager initialization finishes before execute the JS bundle, but TurboModule initialization doesn't. This diff corrects that mistake.

The changes in this diff:
1. The RN application via the TurboModuleManager delegate can now optionally provide the names of all eagerly initialized TurboModules by implementing two methods `getEagerInitModuleNames`, `getEagerInitMainQueueModuleNames`.
2. The TurboModuleManager grabs these two lists from the delegate, and exposes them to its owner via the `RCTTurboModuleRegistry` protocol.
3. The RCTCxxBridge, which already owns a `id<RCTTurboModuleRegistry>` object, uses it to eagerly initialize the TurboModules in these two lists with the correct timing requirements.

This is exactly how we implement eager initialization in Android.

**Note:** Right now, phase one and two of TurboModule eager initialization happen after phase one and two of NativeModule eager initialization. We could make the timing even more correct by initializing the TurboModules at the exact same time we initialize the NativeModules. However, that would require a bit more surgery on the bridge, and the bridge delegate. I think this is good enough for now.

Changelog:
[iOS][Fixed] - Fix TurboModule eager init race

Reviewed By: PeteTheHeat

Differential Revision: D22406171

fbshipit-source-id: 4715be0bceb478a8e4aa206180c0316eaaf287e8
2020-07-07 16:25:10 -07:00
Ramanpreet Nara 5c24746a48 Correct JSRequireEnding marker start in RCTModuleData gatherConstants
Summary:
`RCTModuleData gatherConstants` is [used by `RCTModuleData exportedConstants` to compute and return the constants exported to JS](https://fburl.com/diffusion/ssg4jbeu). However, `RCTModuleData gatherConstants` is also [used by `RCTCxxBridge` to pre-compute NativeModule constants during bridge startup](https://fburl.com/diffusion/nfmjc1ke). Therefore, since `RCTModuleData gatherConstants` can be used outside the context of a JS require, we cannot start the JSRequireEnding marker inside `RCTModuleData gatherConstants` directly.

This diff moves the body of `RCTModuleData gatherConstants` into `gatherConstantsAndSignalJSRequireEnding:(BOOL)startMarkers`:
 - `RCTModuleData gatherConstants` calls `RCTModuleData gatherConstantsAndSignalJSRequireEnding:NO`
 - `RCTModuleData exportedConstants` calls `RCTModuleData gatherConstantsAndSignalJSRequireEnding:YES`. **Note:** This is okay, because `RCTModuleData exportedConstants` is only called inside `RCTNativeModule::getConstants()`.

This should make sure that we don't start the JSRequireEnding marker outside of a JS require.

Reviewed By: PeteTheHeat

Differential Revision: D22371889

fbshipit-source-id: de17b857259572fb0f840a22072a16b5e465cabd
2020-07-07 15:33:49 -07:00
Valentin Shergin f2fdc1a5df Fabric: Simplifying RCTPerformMountInstructions
Summary:
This diff inlines all mount-instruction functions into a single one - RCTPerformMountInstructions.
The main purpose is to reduce the number of calls to `RCTComponentViewRegistry` for some instructions. E.g., before the change, the `Insert` (or `Update`) instruction had seven identical calls to the registry. That's not a huge deal but there is no need to pay for it either. Maybe it can save us a couple of milliseconds during TTI.

The code of those functions is quite straight-forward, so this change probably even improves readability.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D22402987

fbshipit-source-id: 043a4114ba42622e9ed226f4d5e41ed45c1b066c
2020-07-07 12:01:56 -07:00
Jiayan Zhuang ac0f4b42c5 Add additional accessibilityElements for embedded links
Summary:
Changelog:
[Internal] - Add the additional accessibilityElement for embedded links

Reviewed By: sammy-SC

Differential Revision: D22296547

fbshipit-source-id: 286cd3cb19d288d584ecd94a8201a28851ca042f
2020-07-06 15:00:58 -07:00
Jiayan Zhuang 10a800da25 Complete the basic RCTParagraphComponentAccessibilityProvider
Summary:
Changelog:
[Internal] - add the first accessibilityElement

Reviewed By: shergin

Differential Revision: D22249310

fbshipit-source-id: e0f1920377eb9d7a22737cf7437b1c5bd7195c5d
2020-07-06 15:00:58 -07:00
Jimmy Zhang 3d882495d5 Check whether packager is running in RCTBundleURLProvider for saved JSLocation
Summary:
Changelog:
Adding packager running check when RCTBundleURLProvider is returning JSLocation, this prevents an invalid address from being returned which might cause various issues.

Reviewed By: cpojer

Differential Revision: D22390156

fbshipit-source-id: a20dbf63103158a34cbf6dc0ae8349b2f9e5b0a8
2020-07-06 09:08:44 -07:00
Valentin Shergin 4716d2282e Fabric: Fixes in computing visible frame in `RCTScrollViewComponentView`
Summary:
This refined algorithm now takes a zoom/scale into account and deals with `contentInset` properly.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D22382482

fbshipit-source-id: 7e9d34d3bababf68e624c045c308957e7e5c9d84
2020-07-04 15:25:43 -07:00
Samuel Susla 42c8dead62 Restore contentOffset from state if necesarry
Summary:
Changelog: [Internal]

When JS Inspector is activated, ScrollView is unmounted and then mounted again with same state.

 ScrollView's content offset was being set to 0 inside `[RCTScrollViewComponentView prepareForRecycle]` during unmount but when it is mounted again, we ignored value inside state.

Reviewed By: shergin

Differential Revision: D22333125

fbshipit-source-id: f232dc95b695605f4819f29d8e0bf14b2f3e9150
2020-07-03 11:15:26 -07:00
Christoph Nakazawa 6d6c68c2c6 "The Metro Server" -> Metro
Summary:
Pet Peeve: Metro is a brand name. You don't say "the Metro server" just like you don't say "the iPhone phone". This is a leftover from when it used to be called "the packager server".

Note: It makes sense to refer to "the Metro server" when talking about it in the context of Metro's features, like if you are discussing "Metro's bundling" and "Metro's server". However, when talking about the tool itself, just Metro is enough.

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D22330966

fbshipit-source-id: 667618363c641884df543d88cac65d1e44956ad3
2020-07-02 14:51:18 -07:00
Jiayan Zhuang ffa07254de Build the framework for RCTParagraphComponentAccessibilityProvider
Summary:
Changelog:
[iOS][Added] - This is the first step to build RCTParagraphComponentAccessibilityProvider.  The main idea of RCTParagraphComponentAccessibilityProvider is to provide an array of accessible elements for the AttributedString in PCTParagraphComponentView.

Reviewed By: sammy-SC

Differential Revision: D22214855

fbshipit-source-id: 69d47555e86452620f89a4b2e21ed6065c8e669c
2020-07-02 08:55:39 -07:00
Valentin Shergin 26d8d41735 Fabric: More asserts in iOS mounting infra
Summary:
The change contains a bunch of additional asserts that verify some assumptions on which mounting relies on. Working on the previous diffs I realized that it's very easy to broke those and then spend hours trying to understand what exactly went wrong.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D22324087

fbshipit-source-id: 1152c40248885d02bde62a493a574868c3732273
2020-07-01 20:37:49 -07:00
Valentin Shergin 8320ad37f2 Fabric: Using `overflowInset` in on-demain view mounting in <ScrollView>
Summary:
Now we can use `overflowInset` to check if the view's descendants overflow.

```
  ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐
   A cell w/o overflow content
  │                           │

  └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘
  ┌───────────────────────────┐                 ┌───────────────────────────┐
  │A cell w/ overflow content │                 │A cell w/ overflow content │
  │             ┌───────────┐ │   <━━━━━━━━━>   │             ┌───────────┐ │
  │             │A thing    │ │                 │             │A thing    │ │
  └─────────────┤that       ├─┘                 └─────────────┤that       ├─┘
  ┌ ─ ─ ─ ─ ─ ─ ┤overflows  ├ ┐                 Inset ********│overflows  │**
                │ended up   │                   Overflow******│ended up   │**
  │             │being      │ │                 **************│being      │**
                │visible.   │                   **************│visible.   │**
  └ ─ ─ ─ ─ ─ ─ ┤           ├ ┘                 **************│           │**
  ┌─────────────┤           ├─┐                 **************│           │**
  │             │           │ │                 **************│           │**
  │             │           │ │                 **************│           │**
╔═│             │           │ │═╗             ╔═**************│           │**═╗
║ └─────────────┤           ├─┘ ║             ║ **************│           │** ║
║ ┌─────────────┤           ├─┐ ║             ║ **************│           │** ║
║ │             │           │ │ ║             ║ **************│           │** ║
║ │             │           │ │ ║             ║ **************│           │** ║
║ │             └───────────┘ │ ║             ║ **************└───────────┘** ║
║ └───────────────────────────┘ ║             ║                               ║
║ ┌───────────────────────────┐ ║             ║                               ║
║ │                           │ ║             ║                               ║
║ │                           │ ║             ║                               ║
║ │                           │ ║             ║                               ║
║ └───────────────────────────┘ ║             ║                               ║
║ ┌───────────────────────────┐ ║             ║                               ║
║ │                           │ ║             ║                               ║
║ │                           │ ║             ║                               ║
║ │                           │ ║             ║                               ║
║ └───────────────────────────┘ ║             ║                               ║
║ ┌───────────────────────────┐ ║             ║                               ║
║ │                           │ ║             ║                               ║
║ │                           │ ║             ║                               ║
║ │                           │ ║             ║                               ║
║ └───────────────────────────┘ ║             ║                               ║
║ ┌───────────────────────────┐ ║             ║                               ║
║ │                           │ ║             ║                               ║
║ │                           │ ║             ║                               ║
╚═│                           │═╝             ╚═══════════════════════════════╝
  └───────────────────────────┘
  ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐

  │                           │

  └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘
  ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐

  │                           │

  └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘
```

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D22325808

fbshipit-source-id: e80ae196fc9158358a67c6706b0a2ddec6d47ee9
2020-07-01 18:25:14 -07:00
Valentin Shergin e223f2c2bf Fabric: Gating for on-demand view mounting in ScrollView
Summary:
Just gating.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D22325692

fbshipit-source-id: 14cdfb4bf10ad00e090a91659138639360020fca
2020-07-01 18:25:14 -07:00
Valentin Shergin 9a72702b44 Fabric: On-demand view mounting for <ScrollView>
Summary:
This is the first implementation stage of on-demand child views mounting for <ScrollView> feature.

It works this way. When mounting layer requests mounting of a subview of <ScrollView>, the component does not mount it immediately. Instead, it stores it in an internal collection, and then after the transaction finishes use that to mount views that are in a visible area.
Then we re-evaluate which child views are should be mounted and unmounted on every significant onScroll event. We use some leeway to do it not so often to save CPU cycles on scrolling.

This feature already works fine but to make it shippable we need to integrate it with an `overflow inset` feature to make it 100% reliable in complex cases when some views have overflow content.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D22304012

fbshipit-source-id: be4ae21378d9d1c457cad2826da7d8c8d6395be5
2020-07-01 18:25:14 -07:00
Samuel Susla ab1f54c61c Do not log warning if JS responder isn't set in Fabric
Summary:
Changelog: [Internal]

Do not log warning for "Invalid view set to be the JS responder".
{F242140509}

Fabric doesn't store views in view registry, therefore this warning would be shown to the developer everytime `[RCTUIManager setJSResponder]` is called.

Reviewed By: shergin

Differential Revision: D22309447

fbshipit-source-id: cac8985cdc79ab2d03a246cc2d9377472a64a683
2020-06-30 15:56:47 -07:00
Valentin Shergin 188a66daab Fabric: Empty (no-op) `layoutSubviews` method was removed from RCTComponentView.
Summary:
The method does not do anything besides calling a super method. Even if this method does nothing special, overriding it can have negative performance implications.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D22309895

fbshipit-source-id: bd8237d15df20017629223f278b1b6ac628b0cc7
2020-06-30 10:35:10 -07:00
Samuel Susla 3d4535a2bb Introduce InputAccessoryView
Summary:
Changelog: [Internal]

Introducing InputAccessoryView.

There is one big difference between Fabric's implementation and Paper's implementation.

Fabric searches for text input from InputAccessoryView, unlike Paper where it is the other way around.

Reviewed By: shergin

Differential Revision: D22160445

fbshipit-source-id: 55313fe50afeced7aead5b57137d711dd1cfd3ae
2020-06-30 01:36:04 -07:00