Commit Graph

96 Commits

Author SHA1 Message Date
Valentin Shergin 4eb9b40979 Fabric: Proper thread synchronization in MainRunLoopEventBeat
Summary:
To dispatch events synchonously on the main thread we still have to block the Message Queue.
We actually dispatch events on the Message Queue while the main thread is waiting.

Reviewed By: mdvacca

Differential Revision: D9799853

fbshipit-source-id: 8033be36f27371ad2f1dc7210d564fbca1174910
2018-09-14 15:21:10 -07:00
Valentin Shergin a3752c6c63 Fabric: Removed leftovers from RCTScheduler
Summary: Trivial. We use `EventBeatFactory`s instead.

Reviewed By: mdvacca

Differential Revision: D9799856

fbshipit-source-id: 67a130161026565ecc948427ffa658837d9bbfc2
2018-09-13 23:02:37 -07:00
Héctor Ramos 1151c096da Update copyright headers to yearless format
Summary: This change drops the year from the copyright headers and the LICENSE file.

Reviewed By: yungsters

Differential Revision: D9727774

fbshipit-source-id: df4fc1e4390733fe774b1a160dd41b4a3d83302a
2018-09-11 15:33:07 -07:00
Valentin Shergin 37d19aaae3 Fabric: Unification of props management in RCTViewComponentView and subclasses
Summary:
* Now all `RCTViewComponentView` subclasses are required to set `_props` instance variable in the constructor with a default value;
* `RCTViewComponentView`'s `_props` instance variable now has `ShadredViewProps` type (that enforced by `static_assert` in `ConcreteViewShadowNode` template);
* New we use `static_pointer_cast` instead of `dynamic_pointer_cast` for casting props.

Reviewed By: mdvacca

Differential Revision: D9734199

fbshipit-source-id: b0a0939c936f8b5b540fa5fa1e4a2f1037346fc5
2018-09-10 16:50:02 -07:00
Ramanpreet Nara 7eb82f32a2 Implement onPress for Virtual Text nodes
Summary:
When text nodes are nested, as below, `onPress` handlers need to be correctly invoked:
```
render() {
  return (
    <Text onPress={() => console.warn('hi')}>
      hi
      <Text onPress={() => console.warn('ramanpreet')}>ramanpreet</Text>
    </Text>
  );
}
```

In the above example, clicking on "hi" should warn "hi", and clicking on "ramanpreet" should warn "ramanpreet". This diff implements that behaviour.

Reviewed By: shergin

Differential Revision: D9696905

fbshipit-source-id: 2daf24e76c3b3c37aa36cd1540e54876a367faf7
2018-09-10 11:41:36 -07:00
Ramanpreet Nara 74c24147e2 Modify `RCTTouchableComponentViewProtocol` to get touch event emitter at point
Summary:
This diff includes two changes:
1. Even though `RCTViewComponentView` conforms to `RCTTouchableComponentViewProtocol`, it never implemented this protocol. This diff makes the correction.
2. Make the necessary changes to `RCTSurfaceTouchHandler` required by the changes in `RCTTouchableComponentViewProtocol`. This means modifying the `ActiveTouch` struct to hold `SharedTouchEventEmitter`s. It also means passing in the touch point to the `componentView`'s `touchEventEmitterAtPoint` method.

Reviewed By: shergin

Differential Revision: D9696909

fbshipit-source-id: 3d4a833f7dbae6d0238a0807eb2220250ccbae3d
2018-09-10 11:41:33 -07:00
Valentin Shergin db9b468dd1 Fabric: `[RCTViewComponentView betterHitTest:]` proper support for `clipToBounds` and `zIndex`
Summary:
@public
Besides `pointerEvents` there are other two props that affect hit-testing mechanism: `zIndex` and `clipToBounds`.
The default UIKit implementation does not take this into an account (it always assume that `clipToBounds` is true and `zIndex` is same). `betterHitTest` does it right.

Reviewed By: sahrens

Differential Revision: D9688876

fbshipit-source-id: dadfd5e5541ddd1a744fbd8c6b10949c0e266069
2018-09-07 23:48:03 -07:00
Valentin Shergin dbf5bea3c1 Fabric: Custom `[RCTViewComponentView hitTest:]` that takes `pointerEvents` into an account
Summary:
@public
In RN we have special `pointerEvents` prop that controls whether the View can be the target of touch events.
This is a pretty straight-forward implementation of that.

Reviewed By: sahrens

Differential Revision: D9688877

fbshipit-source-id: 1524647b0a33e4dd14563f531d636469bf3bdef7
2018-09-07 23:48:02 -07:00
Valentin Shergin ff1b950e29 Fabric: Proper way to stop Fabric Surfaces
Summary:
@public
Apparently, we have to call `ReactFabric.unmountComponentAtNode(tag)` instead of `AppRegistry.unmountApplicationComponentAtRootTag(tag)`.

Reviewed By: sahrens

Differential Revision: D9652730

fbshipit-source-id: f56dba7dbe5421a7d939b91178db5104476fe550
2018-09-07 23:48:02 -07:00
Valentin Shergin d2186081b3 Fabric: RCTSurfaceRegistry now stores Surfaces as weak references
Summary:
@public
RCTSurfaceRegistry always promised this in the documentation but never actually did.

Reviewed By: sahrens

Differential Revision: D9652732

fbshipit-source-id: f3d06b95192e024273dc0e3a1c2753ca92370338
2018-09-07 23:48:02 -07:00
Valentin Shergin 2c3e4ec06b Fabric: `borderWidths` field was removed from ViewProps
Summary:
@public
Apperently, we don't need to store and parse this because we are already doing this for `yogaStyle` field.

Reviewed By: sahrens

Differential Revision: D9649549

fbshipit-source-id: a84a5518674f4c2d574a060cdbebb9562121f5f4
2018-09-07 11:17:53 -07:00
Valentin Shergin b960512a5e Fabric: Complete border drawing implementation in RCTViewComponentView
Summary:
@public
Now all configurations or border styles are supported by RCTViewComponentView (and all subclasses).

Reviewed By: sahrens

Differential Revision: D9631868

fbshipit-source-id: 3a5b141ac5ffa9c28f4ebb0718f2fc935b8f1a75
2018-09-07 11:17:53 -07:00
Valentin Shergin ca1e9032a4 Fabric: Proper way to represent (and parse) borders in ViewProps
Summary:
@public
Previously, ViewProps class coundn't represent whole spectre of possible values of border metrics (e.g. the border color was unified).
Now it's complete and direction-specific.

Reviewed By: sahrens

Differential Revision: D9628361

fbshipit-source-id: 6d3b3d4d7e3008e2168cbca732ff99fe5ea595e8
2018-09-07 11:17:52 -07:00
Valentin Shergin 0792fba63f Fabric: Using ShadowView instead of ShadowNode in Mutations
Summary:
@public
This is quite a big diff but the actual meaningful change is simple: now we use ShadowView class instead of ShadowNode in mutation instructions.
Note:
 * In some places (especially during diffing) we have to operate with ShadowNodeViewPair objects (which represents a pair of ShadowNode and ShadowView). The reason for that is that we cannot construct child ShadowViews from parent ShadowViews because they don't have any information about children.
 * `ShadowTree::emitLayoutEvents` is now much simpler because ShadowView better represents the specifics of this kind of object.
 * The code in RCTMountingManager also became simpler.

This change will allow us to implement more cool tricks soon.

Reviewed By: mdvacca

Differential Revision: D9403564

fbshipit-source-id: dbc7c61af250144d6c7335a01dc30df0005559a2
2018-09-03 23:04:20 -07:00
Valentin Shergin 961b6aceca Fabric: Unified event pipeline: connecting the dots
Summary:
@public
This diff basically wires everything up.

Reviewed By: mdvacca

Differential Revision: D8886227

fbshipit-source-id: fb1a1e3222b3d693a8c28ed780b14f7315b7c019
2018-08-27 07:32:38 -07:00
Valentin Shergin 26d0b05c80 Fabric: MessageQueueEventBeat
Summary:
@public
MessageQueueEventBeat implements particular Event Beat synchronized with Message Queue and calling a callback on the JS thread (aka Message Queue thread). The actual beat is synchronized with the main run loop.

Reviewed By: mdvacca

Differential Revision: D8886230

fbshipit-source-id: 97ef7d10f705789b4b0cd3a12389db960159f289
2018-08-27 07:32:34 -07:00
Valentin Shergin 57bbce9bd9 Fabric: Introducing EventBeat concept (and MainRunLoopEventBeat)
Summary:
@public
EventBeat is an abstraction around proper event scheduling combining proper timing and proper threading. Event Queues use Event Beat to ensure that events are delivered on proper threads and in proper timing (probably batched). Consumers can `request` the next beat and `induce` immediatly beat.
MainRunLoopEventBeat implements particular Event Beat synchronized with the main event loop and calling a callback on the main thread.

Reviewed By: mdvacca

Differential Revision: D8886229

fbshipit-source-id: 1a42fcbf4cd61c6cb4c502890566c98b00226f31
2018-08-27 07:32:34 -07:00
Valentin Shergin 88293d391a Fabric: Using `const &` pattern everywhere in RCTConversions
Summary:
@public
Trivial.

Reviewed By: mdvacca

Differential Revision: D8923599

fbshipit-source-id: 06f760ad7940af247ca81396fd48b08fbcd562c6
2018-08-04 09:47:30 -07:00
Valentin Shergin 96238e03b6 Fabric: Support for Yoga's `overflow` property on iOS
Summary:
@public
Quite trivial.

Reviewed By: mdvacca

Differential Revision: D9146963

fbshipit-source-id: 3cdace99c172a3aea3c0af07ecb82488437d0311
2018-08-03 08:32:56 -07:00
Valentin Shergin 9042438975 Fabric: `bridge` prop was removed from RCTSurface interface
Summary:
@public
We are moving away from using `RCTBridge` instance in public APIs to enable us using more performance solutions in the future.
This change also fixes "SwipeBack issue" caused by RCTSurfaceHostingProxyRootView returning nil bridge.

Reviewed By: mdvacca

Differential Revision: D9094625

fbshipit-source-id: 6bde3c54773e75ca4c0b6fd908da9d7235b5c3be
2018-08-01 15:32:01 -07:00
Aaron Brager ca7eb14682 Fix minor typo in RCTEnhancedScrollView.h
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/20456

Differential Revision: D9061113

Pulled By: hramos

fbshipit-source-id: 4a8afa63dd00be60cb8d622a6929c5f3bef4c20c
2018-07-30 11:01:28 -07:00
Valentin Shergin 07a4a959a7 Fabric: Events related classes were moved to separate buck target
Summary:
@public
We need that because gonna add much more event-related stuff, so it deserves separate buck target.

Reviewed By: mdvacca

Differential Revision: D8831547

fbshipit-source-id: 616581b39b425a49302d5f7f86267e62b0d58389
2018-07-17 22:53:57 -07:00
Valentin Shergin e906d4cdc9 Simplifying child nodes management in YogaLayoutableShadowNode
Summary:
@public

This diff consists of many interdependent changes which support one simple idea: YogaLayoutableShadowNode is now using YGNode children to iterate on them (it previously relied on `ShadowNode::getChildren()`). All other changes are just an unavoidable consequence of that. Hence we don't need to filter child nodes every single time when we do layout anymore! The logic around `clone callback` is also drastically simpler now.
The new approach also implies that `LayoutableShadowNode` and `YogaLayoutableShadowNode` don't use `shared_ptr`s to refer to ShadowNode objects because new relationship does not imply ownership. No more `SharedShadowNode` objects in those two classes.

Reviewed By: mdvacca

Differential Revision: D8796159

fbshipit-source-id: 6f52f92d1826f3eb13b2f8a132c3ea77de155d82
2018-07-17 22:53:56 -07:00
Valentin Shergin 732c3a4f4e Fabric: Propper support for `accessibilityLabel` in RCTParagraphComponentView
Summary:
@public
This approach is basically copying exising implementation that we have in RCTTextView (D5806097).
Changes in `AttributedString` is quite trivial.

Reviewed By: mdvacca

Differential Revision: D8740000

fbshipit-source-id: 276afdf93d777f7ccb99ca8ee5a18a880de2acbf
2018-07-17 17:54:49 -07:00
Valentin Shergin 95bd4a0a9e Fabric: `activityindicator` module was moved to `components` subdirectory
Summary:
@public
Trivial. We move all components into `/components/` subdirectory.

Reviewed By: mdvacca

Differential Revision: D8757015

fbshipit-source-id: 9b676728bf1aa4aa14345fa11a5b4a1f9f7ed472
2018-07-15 16:52:26 -07:00
Valentin Shergin 57b0e68a2c Fabric: `view` module was moved to `components` subdirectory
Summary:
@public
Trivial. We move all components into `/components/` subdirectory.

Reviewed By: mdvacca

Differential Revision: D8757011

fbshipit-source-id: 6a7da09e01184d41d37a1e1782c20d3c79371ae3
2018-07-15 16:52:26 -07:00
Valentin Shergin b42e674c2f Fabric: `scrollview` module was moved to `components` subdirectory
Summary:
@public
Trivial. We move all components into `/components/` subdirectory.

Reviewed By: mdvacca

Differential Revision: D8757013

fbshipit-source-id: fe3021862b3a4f8f0799b0dfaf6d3039f8582a7f
2018-07-15 16:52:26 -07:00
Valentin Shergin ecbe9acbaa Fabric: `text` module was moved to `components` subdirectory
Summary:
@public
Trivial. We move all components into `/components/` subdirectory.

Reviewed By: mdvacca

Differential Revision: D8757014

fbshipit-source-id: 9db94d38fe027e9125d017a17cbd4cf79f0bcf88
2018-07-15 16:52:26 -07:00
Valentin Shergin 0532e01d69 Fabric: Enhancements in ContextContainer
Summary:
@public
Everything is better with C++ templates.
In this cases templates allow us to remove additional parameters and casts on the callsite.

Reviewed By: mdvacca

Differential Revision: D8754523

fbshipit-source-id: 2340b2cd96ab0a60d54d9aa30dea3c072b951a8a
2018-07-15 16:52:26 -07:00
Valentin Shergin 2166d2bb79 Fabric: Trivial implementation of prelumiary view allocation on iOS
Summary:
@public
We have this feature in the current version of RN, so it would be nice to support that in Fabric as well. This should save us tens of ms of views creation during mounting.
And that's quite easy to do!

Reviewed By: fkgozali

Differential Revision: D8701992

fbshipit-source-id: 4e3049df009ffd65bb43043de388e81795e5e559
2018-06-29 20:02:38 -07:00
Valentin Shergin d629e4b0e5 Fabric: Releasing image bitmap as part of `prepareForRecycle`
Summary:
@public
When some `RCTImageComponentView` is going to be recycled, it makes sense to free an associated bitmap because it will not be reused anyways.

Reviewed By: mdvacca

Differential Revision: D8601751

fbshipit-source-id: 1318622b66460b8e5588a4420c91c516fe2b1106
2018-06-26 11:48:12 -07:00
Valentin Shergin b1c4fee6af Fabric: Consistency assurance asserts in RCTComponentViewRegistry
Summary:
@public
We have found that because of some bugs Mounting Manager can request creation of views with same tag several times (which should not happen).
Now, we can fail earlier in such cases.

Reviewed By: fkgozali

Differential Revision: D8585164

fbshipit-source-id: 63c6391de5adfe711552918a20a18396f54ec201
2018-06-22 11:57:42 -07:00
Valentin Shergin 48b9a6f887 Fabric: Temporary experimental integration between old and new UIManagers
Summary:
@public
We need this to enable measuring, responder-chain management and another features powered by UIManager commands.
As soon we have Fabric specifc command-delivery pipeline this must be reverted.

Reviewed By: fkgozali

Differential Revision: D8552360

fbshipit-source-id: d56e12d38c32d8ad98cb230671bac1f35e87e647
2018-06-22 11:57:41 -07:00
Valentin Shergin 36c052ad96 Fabric: Default support of `displayType` and `layoutDirection` layout metrics
Summary:
@public
Quite trivial.

Reviewed By: mdvacca

Differential Revision: D8528922

fbshipit-source-id: 1e21f988317eecc7aa659fd9b51600b9e2b7d69f
2018-06-22 11:57:40 -07:00
Valentin Shergin 803c14bd98 Fabric: Support for uniformed borders of <View>
Summary:
@public
For now we only support trivial uniformed (all sides are equal) border rendering (which can be direclty mapped to CALayer features).
Support of the more complex and fancy borders is comming soon.

Reviewed By: mdvacca

Differential Revision: D8528923

fbshipit-source-id: 0883cdc2b855fc63d399e1a93010f259f0628f48
2018-06-22 11:57:40 -07:00
Valentin Shergin ad78971569 Fabric: Added support of `accessibilityCustomActions` for <View>
Summary:
@public
Another small but important piece of Accessibility Support.

Reviewed By: mdvacca

Differential Revision: D8528921

fbshipit-source-id: d4ba87bab702d76a90e9ddb751999193243cdc74
2018-06-22 11:57:40 -07:00
Valentin Shergin 3ea4a3309f Fabric: Conversion functions between NSString and std::string
Summary:
@public
Trivial. It's also nice this we have a default encoding now.

Reviewed By: fkgozali

Differential Revision: D8528919

fbshipit-source-id: 0853eca828f22ead1a337fea3d7a2fc9a48e84c8
2018-06-22 11:57:39 -07:00
Valentin Shergin f6aa5db0e4 Fabric: RCTImageComponentView
Summary:
@public
This is iOS-specific implementation of <Image> view.
Not all props and features are supported yet.
Known issues:
 - Animated GIFs;
 - CA transitions during image appearance.

Reviewed By: mdvacca

Differential Revision: D8526570

fbshipit-source-id: a4b1dca583b139b8a09431565a79f051fae67a36
2018-06-22 07:32:50 -07:00
Valentin Shergin 979ea2094e Fabric: Introducing ImageManager
Summary:
@public
ImageManager coordinates all work related to loading image bitmaps for <Image> component.
The particular iOS implementation uses RCTImageLoader from RCTImage module under the hood.

Reviewed By: fkgozali

Differential Revision: D8526571

fbshipit-source-id: a0d927972d30113eed6e0cd169fceee17610181d
2018-06-22 07:32:49 -07:00
Valentin Shergin eabf29e320 Fabric: Getting rid of many `auto &&`
Summary:
@public
After reading about move-semantic and rvalue refs I realized that we (I) definitely overuse  `auto &&` (aka universal reference) construction. Even if this is harmless, does not look good and idiomatic.
Whenever I used that from a semantical point of view I always meant  "I need an alias for this" which is actually "read-only reference" which is `const auto &`.
This is also fit good to our policy where "everything is const (immutable) by default".
Hence I change that to how it should be.

Reviewed By: fkgozali

Differential Revision: D8475637

fbshipit-source-id: 0a691ededa0e798db8ffa053bff0f400913ab7b8
2018-06-22 07:32:49 -07:00
Valentin Shergin c674303dfd Fabric: Introducing `ContextContainer`
Summary:
@public
`ContextContainer` is general purpose DI container for Fabric.
We need this to communicate some enviroment-specific and/or platform-specific modules down to cross-platform C++ code.
The first one will be ImageManager. Soon.

Reviewed By: fkgozali

Differential Revision: D8475636

fbshipit-source-id: 0afc65063f818d0bab736cd2c55c6fdd21b629ac
2018-06-22 07:32:49 -07:00
Valentin Shergin a3f9ff4f93 Fabric: `pointScaleFactor` is now part of LayoutContext and LayoutMetrics
Summary:
@public
... and we initalize this in Surface.
We need this for requesting images with proper size/pixel-density, setup proper parameters for rasterizing CALayer's and rounding layout metric values.
Then we have to figure out how to wire this up with YGConfig.

Reviewed By: fkgozali

Differential Revision: D8475639

fbshipit-source-id: cec7af581b94efb4595dcf3f232252ce87a1fde3
2018-06-22 07:32:49 -07:00
Valentin Shergin 62a458bcea Fabric: Using `rootTag` instead of deprecated `rootViewTag` in SurfacePresenter
Summary:
@public
Trivial.

Reviewed By: mdvacca

Differential Revision: D8473512

fbshipit-source-id: 7b6c160a2a1a1abcd571b0522760d49644632922
2018-06-22 07:32:49 -07:00
Kevin Gozali e7256a777e fix up double surface registration on JS load
Summary:
@public
When JS first starts up, Fabric surface end up double registering itself, causing events to not work. So let's guard it so that registration happens only on reload case.

Reviewed By: shergin

Differential Revision: D8521002

fbshipit-source-id: 441f121786e860dc10e959e940b411c2afaf96dc
2018-06-19 18:47:41 -07:00
Kevin Gozali 7b9b1559a7 iOS: Avoid double reload event when reloading JS
Summary:
@public
The bridge may send the reload event twice when reloading JS in some rare condition. The 2nd one was actually when the "new" bridge wasn't valid yet, so log an error if that happens. This may happen if the connection to Metro server gets into a weird state. Restarting Metro would solve the problem.

The issue was that `RCTBridgeWillReloadNotification` fired twice for each reload with metro connected.

Reviewed By: mmmulani

Differential Revision: D8509448

fbshipit-source-id: 647fb98c0a97503409a10451b8f152145947ae20
2018-06-19 18:47:41 -07:00
Valentin Shergin dc0ebf7cb0 Fabric: Implementation of <View transform={...}/> property
Summary: After moving all matrix math to C++, the actual client native code is quite trivial.

Reviewed By: fkgozali

Differential Revision: D8344059

fbshipit-source-id: 6910c6af5de64d5f901e82075d30edbde177af40
2018-06-15 11:47:40 -07:00
Valentin Shergin 55f8cfe693 Fabric: Implementation of shadow related props of <View> component
Summary: Quite trivial.

Reviewed By: fkgozali

Differential Revision: D8344060

fbshipit-source-id: 1e44a2ad78e98699dd0ae7ca2816f8c8349bf6d6
2018-06-15 11:47:40 -07:00
Valentin Shergin 5bb538ab5c Fabric: Color conversions function in RCTConversions
Summary:
This is quite interesting.
In Fabric, on C++ layer we store `color` values as `SharedColor` objects which (on iOS) are `shared_ptr`s with custom deallocater (which calls CoreFramework's `CFRelease` function). All this means that we cannot directly transfer ovenership of this managed pointer to ARC (honestly, I am not 100% sure about that, but at least this "shared ownershipt between ARC and non-ARC worlds" concept is as dangerous as any "relying on implementation details" approach). To to so, we have to create a copy and transfer ownership of the copy to ARC (which we do in 1RCTCGColorRefFromSharedColor`).

Reviewed By: fkgozali

Differential Revision: D8344061

fbshipit-source-id: 8b6764e1539b1982b41f502bbd3307c7b6900fd9
2018-06-15 11:47:40 -07:00
Valentin Shergin 3c8c01791f Fabric: Implementation of bunch of trivial <View> props
Summary: Pretty straightforward.

Reviewed By: fkgozali

Differential Revision: D8344063

fbshipit-source-id: e6d35353cb3f3e374d2f2b723a612eda2d19c8b7
2018-06-15 11:47:39 -07:00
Valentin Shergin 8bdc1ff10b Fabric: Implementatiton of <View hitSlop={}/> on the native side
Summary: The implementation was basically ported from existing one.

Reviewed By: fkgozali

Differential Revision: D8344057

fbshipit-source-id: c0ec3b7b986080eab62532244da73859b445fcbb
2018-06-15 11:47:39 -07:00