Commit Graph

1147 Commits

Author SHA1 Message Date
Valentin Shergin c03bf5d2b0 Fabric: Fixed crash caused by preluminary deallocation of RCTImageLoader
Summary:
The spec says that `bridge_transfer` indicates that we "transfer ownership of the pointer" to ARC which implies that as soon this part of the code does not need the object, it will be deallocated. However, that's not what we want here. This object is actually already owned by another ARC-powered code somewhere else and the pointer to it was transferred as a raw pointer through the C++ world.
So, we want to keep the ownership of the object on the other side but still imply the lifetime of the object. So how can we do that? Simple, we have to use `bridge`.
Why? ARC is not magical, it's just automatic ref counting. And I think the only difference between `bridge` and `bridge_transfer` is how many refcounter's bumps will be added to the generated code. In the case of `bridge_transfer` it is zero, in the case of `bridge` it is one. So, initializing a new Objective-C variable that points to the shared resource we have to bump the counter once, so we have to use `bridge`.

Reviewed By: mdvacca

Differential Revision: D9819405

fbshipit-source-id: 9e7af343917ec4407a64d884402b10ee2a8097f9
2018-09-14 15:21:12 -07:00
Valentin Shergin 9b863d4da3 Fabric: std::hash specification for AttributedString and all derivatives
Summary: We will need that to manage collections of attributed strings.

Reviewed By: mdvacca

Differential Revision: D9803351

fbshipit-source-id: 0ea9719f97ed30ff6dfe17b6dbebf448afe228b3
2018-09-14 15:21:12 -07:00
Valentin Shergin e663b1ed59 Fabric: Equality operators for AttributedString and derivatives
Summary: We will need this eventually.

Reviewed By: mdvacca

Differential Revision: D9799852

fbshipit-source-id: 0411e2f41540273c80f425e04c877fe51b9b2374
2018-09-14 15:21:11 -07:00
Valentin Shergin e05acf1930 Fabric: Managing an EventHandler as a unique_pointer
Summary:
I realized that instead of using shared_ptr's type-erasure feature, we can make the EventHandler's destructor virtual and this itself will allow safe deallocation by a pointer to a base class.
We cannot use the same technic for EventTarget thought because having a weak_ptr to this is another feature of shared_ptr that we need.

Reviewed By: mdvacca

Differential Revision: D9775742

fbshipit-source-id: 3c23a163827e8aa9ec731c89ce87051a93afe4ca
2018-09-13 23:02:37 -07:00
Valentin Shergin 93dd790cad Fabric: Simplified relationship between RawEvent and EventEmitter
Summary: Instead of relying on explicit `RawEventDispatchable` function, we simply check the existence of the `weak_ptr` to `EventTarget`. This is efficient and sufficient because only an EventEmitter retains an associated EventTarget.

Reviewed By: mdvacca

Differential Revision: D9764858

fbshipit-source-id: 4ac25d925f189d0f8b9002e52388fd51629934a8
2018-09-13 23:02:37 -07:00
Valentin Shergin b6e42517e5 Fabric: Now `EventEmitter::setEnabled()` relies on stored `eventTarget` is not being nullptr
Summary:
This diff implements a new model of managing `enabled` flag in EventEmitter.
Now we simply rely on `eventTarget_` is not being `nullptr` (and we reset the pointer to "disable" the event emitter).

Reviewed By: mdvacca

Differential Revision: D9764857

fbshipit-source-id: 1dd3ce0c8589048babbf2dbac9f8359358b31a34
2018-09-13 23:02:37 -07:00
Valentin Shergin c25d5948a5 Fabric: Exposing EventEmitter's ownership model as a shared_ptr
Summary:
As we did in the previous diff, here we implemented `EventEmitter`'s ownership model as a `shared_ptr`. This change fixes problem with leaking `WeakObject`s which happens on hot-reload.

So, in short:
 * `EventTargetWrapper` object owns `jsi::WeakObject` that can be converted to actual `jsi::Object` that represent event target in JavaScript realm;
 * `EventTargetWrapper` and `jsi::WeakObject` objects must be deallocated as soon as native part does not need them anymore;
 * `EventEmitter` objects retain `EventTarget` objects;
 * `EventEmitter` can loose event target object in case if assosiated `ShadowNode` got unmounted (not deallocated); in this case `EventEmitter` is loosing possibility to dispatch event even if some mounting-layer code is still retaining it.

Reviewed By: mdvacca

Differential Revision: D9762755

fbshipit-source-id: 96e989767a32914db9f4627fce51b044c71f257a
2018-09-13 23:02:37 -07:00
Valentin Shergin a089df3f8b Fabric: JSIReleaseFabricEventHandler was replaced with shared_ptr approach
Summary:
Previously, we used special JSI bindings method to release an event handler (`JSIReleaseFabricEventHandler`). Now we expose this ownership model as a regular `std::shared_ptr`, so when the owner got deallocated, the event handler will be released automatically.

Why not use `unique_ptr`? `unique_ptr` is faster (and simpler) indeed, but it does not provide `type erasure` functionality that we need; to use `unique_ptr` we would have to make JSI an explicit Fabric dependency (we will probably end up with it eventually, but I this particular case is not a good reason for that).
All interactions with `eventHandler_` are done in a non-owning manner, so it's as performant as unique_ptr anyway.

(Please ignore all changes in JSCFabricUIManager.h/cpp files, we will delete them soon.)

Reviewed By: mdvacca

Differential Revision: D9756732

fbshipit-source-id: bffdee0c724dc95855ced7c35e7c13cf1554796e
2018-09-13 23:02:36 -07:00
Scott Rice 686ff70d96 Fixup references to old flag_defs.bzl in xplat/
Summary:
The source of truth has already moved, so now we just need to fix references

This diff is mostly the result of running:

```
$ tools/mobile-unification/loadmod --fixup xplat/configurations/buck/apple/flag_defs.bzl tools/build_defs/apple/
```

Then I committed with `hg commit -I xplat/`

The controller you requested could not be found.

Differential Revision: D9772194

fbshipit-source-id: 93d23ae8e1c62440c7876cad965d963bde960db9
2018-09-11 18:47:30 -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
Michael Lee c5daf3fed9 Reformat BUCK files to follow new buildifier format
Summary: buildifier was updated and now we sort loads!

Reviewed By: zertosh

Differential Revision: D9771824

fbshipit-source-id: 0001aa5f656d4aa40b3498d5bfd792a3d14e56e1
2018-09-11 15:20:48 -07:00
Valentin Shergin 9570d7d490 Fabric: Unifying usage of `auto`s
Summary:
I was watching a classic magnificent talk about modern C++ by Herb Sutter and I was totally sold on double down on using `auto` in our codebase. Surprisingly, 95% of the code base already follows Herb's guidence; I just changed the last 5% to make it consistent.
All those changes must work *exactly* like it was before.
The talk: https://youtu.be/xnqTKD8uD64?t=28m25s

Reviewed By: mdvacca

Differential Revision: D9753301

fbshipit-source-id: 9629aa485a5d6e51806cc96306c297284d4f90b8
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 4c7cf13678 Setup event emitters for `TextShdowNode` and `ParagraphShadowNode`
Summary:
This diff includes two changes:
1. `TextShadowNode` represents virtual texts. For the time being, virtual text nodes only need touch capabilities so that they can handle `onPress` events for their children. Therefore, we should set the `TextShadowNode`'s `EventEmitterT` to `TouchEventEmitter`.
2. Since `ParagraphShadowNode` extends an instance of the `ConcreteViewShadowNode` template, it automatically uses the `ViewEventEmitter` if no event emitter is specified. I think it's better to make the event emitter explicitly specified. So, I've included that change in this diff.

Reviewed By: shergin

Differential Revision: D9696906

fbshipit-source-id: ac053ffdde4c2fbc6351f177c07a2ada4445cbb8
2018-09-10 11:41:34 -07:00
Ramanpreet Nara 7c0b707754 Extract TouchEventEmitter from ViewEventEmitter
Summary: In the future, we may want some components (like Virtual Text) to handle only touch events. Therefore, I've extracted `TouchEventEmitter` from `ViewEventEmitter`.

Reviewed By: shergin

Differential Revision: D9696903

fbshipit-source-id: f6acc90d8ff53b5e6badaa472a5e099fb7cf03ff
2018-09-10 11:41:32 -07:00
Ramanpreet Nara 4e841f2114 Remember ShadowNode of RawText's parent in attribute string
Summary:
When a user clicks on some text, `RCTSurfaceTouchHandler` will call into a method on `RCTParagraphComponentView`. That method (i.e: `touchEventEmitter`) would be responsible for identifying the closest ancestral `<Text/>` component to which we should dispatch the `onPress` event, given the point where the user clicked. To answer this query, we'll use a data structure called `UIAttributedString`.

This data structure represents a string, and a corresponding mapping from sequences of its characters to some arbitrary data. In this attributed string, we'll map sequences of characters to their closest ancestral `ParagraphShadowNode` or `TextShadowNode`. That way, when we get a click event on `RCTParagraphComponentView`, we can just look at the character that was clicked, and use that information to do a lookup in the attributed string to find the shadow node who's EventEmitter is responsible for processing the click event.

Reviewed By: shergin

Differential Revision: D9696904

fbshipit-source-id: a199649981ad271afa85414ce4c3f056851348be
2018-09-10 11:41:31 -07:00
Ramanpreet Nara 4a4e083e2a Refactor BaseTextShadowNode::getAttributedString to recurse on SharedShadowNode
Summary: Previously, `BaseTextShadowNode::getAttributedString` used to recurse on a list of `SharedShadowNode`s (i.e: the children). In the `RawText` base case of this recursion, we'll need to record the parent of the current `RawText` (so that we can dispatch the `onPress` event to it). Therefore, we need to start recursing using the `SharedShadowNode` itself, and not its children.

Reviewed By: shergin

Differential Revision: D9696908

fbshipit-source-id: dbf3f9c21a7ae4de421d0355c4e5900b3947dc2a
2018-09-10 11:41:30 -07:00
Valentin Shergin 1e3e2387d3 Fabric: Stripping the word `fabric` from some function names
Summary:
@public
Trivial.
We should not use the name of the effort in the API interfaces where it's not neccecery.

Reviewed By: sahrens

Differential Revision: D9652991

fbshipit-source-id: 52b99e39f92926f9fc99626690eb4385195558f6
2018-09-07 23:48:02 -07:00
Valentin Shergin 10181f31bd Fabric: Fixed possible crash due race condition during Surface unmounting
Summary:
@public
Now we simply skip `uiManagerDidFinishTransaction` calls if they refer to unregister surfaces. In the future, after we have proper asynchronous scheduling and sync unmounting (and if we chose to have sync unmounting), we can avoid this situation (and assert in this cases).

Reviewed By: sahrens

Differential Revision: D9652731

fbshipit-source-id: e376ea1ae4f93960a903e6397d843bd7c4b72400
2018-09-07 23:48:02 -07:00
Valentin Shergin f341541899 Fabric: Simplified `RootShadowNode` instantiation
Summary:
@public
Trivial.
`children = ShadowNode::emptySharedShadowNodeSharedList()` is already a default.

Reviewed By: rsnara

Differential Revision: D9650218

fbshipit-source-id: ad5c17776866b1dc800f68b0a54b9ac3f70de3f6
2018-09-07 21:46:59 -07:00
Valentin Shergin 1183d82884 Fabric: Removing `ShadowNode::operator==`
Summary:
@public
We don't need this anymore.
The same functionality is now implemented as `ShadowView::operator==` in much more reasonable way.

Reviewed By: sahrens

Differential Revision: D9649821

fbshipit-source-id: 8cd5f3cb4f583fd10d2d1e060aba914541341b5b
2018-09-07 21:46:59 -07:00
Joe Peplowski 8ac6ba81ea Clean up import/include statements
Summary: Make import/include more pedantically correct for platform-specific compilation

Reviewed By: hramos

Differential Revision: D9691962

fbshipit-source-id: a5fd373a7b3db22535116c597255cafb7a940c58
2018-09-07 16:02:18 -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 44fb60938a Fabric: Fixed `colorComponentsFromColor` to able to accept empty color object
Summary:
@public
Empty (nullptr) color should be treated as `Clear` color ({0, 0, 0, 0} - black, fully tranparent), so `colorComponentsFromColor()` was changed to accomodate this (previously it crashed).

Reviewed By: rsnara

Differential Revision: D9631865

fbshipit-source-id: e211f34a89e9f5f86d9fca2789c7163db4feaab1
2018-09-07 11:17:53 -07:00
Valentin Shergin a3954ed5cb Fabric: Virtual destructors for all abstract interface-like classes
Summary:
@public
Apparently, it's how it should be.

Reviewed By: rsnara

Differential Revision: D9631870

fbshipit-source-id: 46f58270104d699fbc9abe21062c12f791460536
2018-09-07 11:17:52 -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 917800c686 Fabric: RectangleEdges & RectangleCorners generics
Summary:
@public

EdgeInsets and CornerInsets are now just qualifications of those generics:

	using EdgeInsets = RectangleEdges<Float>;
	using CornerInsets = RectangleCorners<Float>;

We will need more concrete types like that in the future diffs.

Reviewed By: mdvacca

Differential Revision: D9614428

fbshipit-source-id: e4d48a11d9083958c3ada68e6368afb150c64f6b
2018-09-03 23:04:20 -07:00
Valentin Shergin 6186c61476 Fabric: Fixed `border*Width` style prop parsing
Summary:
@public
The code previously assumed that the border size prop is called simply `border*` whereas it's actually `border*Width`.

Reviewed By: mdvacca

Differential Revision: D9626468

fbshipit-source-id: 75226cfdfb286f861b0961076857bd697d4a740b
2018-09-03 23:04:20 -07:00
Valentin Shergin c49f0eff6f Fabric: Using proper defaults in Yoga style props parsing
Summary:
@public
Previously, we amitted `default` argument in  `convertRawProp` functions assuming that all default values are equal to results of their default constructors (which was something between "wrong" and "lucky coincidence"). Now we use a `YGStyle` default value as a source of all semantic default values of all layout props/styles.

Reviewed By: mdvacca

Differential Revision: D9626469

fbshipit-source-id: 5cfc9c518772556f59da46f608181145cc744928
2018-09-03 23:04:20 -07:00
Valentin Shergin 294d91b30a Fabric: ShadowTree is now stored as unique_ptr instead of shared_ptr
Summary:
@public
Now it's clear that we don't need to store/handle ShadowTree objects as `shared_ptr`s; Scheduler should own it. This diff changes that to using unique_ptr and removes a base class of ShadowTree.

Reviewed By: mdvacca

Differential Revision: D9403567

fbshipit-source-id: 6e411714b632a04233fd5b25c8ab7cdd260105fd
2018-09-03 23:04:20 -07:00
Valentin Shergin 1068da2ec7 Introducing `LayoutableShadowNode::isLayoutOnly` and (theoretical) view-flattening
Summary:
@public
Voalá, this small change actually implements view flattening. Obviously, it does not work right now because there are no `ShadowNode` classes which implement `isLayoutOnly`.
Surprisingly, correct implementing of `isLayoutOnly` is quite tricky, we will work on this in coming diffs.

Reviewed By: mdvacca

Differential Revision: D9403565

fbshipit-source-id: 1f16f912cb5c6841405a1fc3cf36aec28698c11f
2018-09-03 23:04:20 -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 5c83855c75 Fabric: Introducting `ShadowView` and `ShadowViewMutation`
Summary:
@public
We need some another object like ShadowNode (but not ShadowNode) to represent an instance of the component in the mutation instructions. This is
the main motivation for introducing ShadowView.

Why not use ShadowNode? ShadowNode is designed to represent a node in ShadowTree, not be a part of a mutation instruction.
 * ShadowNode exposes some APIs that should not be exposed to the mounting layer;
 * ShadowNode is an immutable data structure, so we cannot mutate it in some way which can be meaningful for mounting;
 * We should not add to ShadowNode any functionality which is needed only for mounting;
 * ShadowNode is a bit more heavy object to share that it needs to be; it's exposed (embedded into Mutation) as a `shared_ptr` which is not optimal from the performance perspective;
 * Retaining ShadowNode from mounting code can unnecessarily extend its lifetime which can negatively affect memory usage.

Reviewed By: mdvacca

Differential Revision: D9403562

fbshipit-source-id: 72ad81ed918157a62cd3d1a03261f14447649d0b
2018-09-03 23:04:20 -07:00
Valentin Shergin 2a942b7ae8 Fabric: Defined `+` and `*` operators for Point and Size geometric types
Summary:
@public
Trivial. Those operations are very useful in layout algorithms.

Reviewed By: mdvacca

Differential Revision: D9403566

fbshipit-source-id: e76967aaaac3a36bf6d3e7a468b5ae7769a4dcac
2018-09-03 23:04:20 -07:00
Taras Tsugrii a8a63b1560 Remove unused loads from build files.
Summary: Unused loads hurt readability and take time to process.

Reviewed By: hramos

Differential Revision: D9494120

fbshipit-source-id: 455b56efadab1cb976344cffcb427772bfda2f71
2018-08-31 18:03:07 -07:00
Jonathan Kim 087e2a89fc Clean up xplat relative loads
Reviewed By: scottrice

Differential Revision: D9584163

fbshipit-source-id: 4793b7fa6151c2ec2f8c7fae6271635c9844a50a
2018-08-30 13:04:50 -07:00
Pritesh Nandgaonkar abc95a9113 Expose logging capablities in Yoga header
Summary: Exposes a bool in the config which will help log the yoga hierarchy. Also added a test case

Reviewed By: IanChilds

Differential Revision: D9560577

fbshipit-source-id: ef4998107ed51ea374853bab7cbe09e3232caa0c
2018-08-30 04:47:15 -07:00
Jonathan Kim f9e823fb5a Update loads for glob_defs.bzl
Reviewed By: mzlee

Differential Revision: D9565702

fbshipit-source-id: df38928394a90367492a25ed52ec552b89c1f903
2018-08-30 01:46:51 -07:00
Jonathan Kim 2515e4861a Move RN's DEFS.bzl to tools and rename to rn_defs.bzl
Reviewed By: mzlee

Differential Revision: D9553765

fbshipit-source-id: cb65081668ea2726f24d2c9c02661e859cc7a994
2018-08-29 13:21:52 -07:00
David Vacca 575f7d478d Implement HorizontalScrollView component
Summary: This diff implements the HorizontalScrollView component for Android Fabric C++, as part of this diff I also re-named the components AndroidHorizontalScrollContentView for RCTAndroidHorizontalScrollContentView and AndroidHorizontalScrollView for RCTAndroidHorizontalScrollView. This might sound against our plan of removing the RCT preffix, but it is to make it simpler to map components between current implementation of RN and Fabric (otherwise we don't know when to add the RCT preffix in Android side to find the right View Manager), later we can just remove the preffix from C++, Android, iOS and JS.

Reviewed By: shergin, achen1

Differential Revision: D9122729

fbshipit-source-id: e9299552857c6dd0c18abfa5fa49a3d50e221729
2018-08-28 23:03:33 -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 b49c8add15 Fabric: Rethinking of EventEmitter's role
Summary:
@public
Now, one of the main purposes of `EventEmitter`s is to create RawEvent instances for all specific event invocations.

Reviewed By: mdvacca

Differential Revision: D8886226

fbshipit-source-id: 82a489174efcda097887e70650a2038dc986d149
2018-08-27 07:32:37 -07:00
Valentin Shergin 0dae893eec Fabric: Rethinking of `EventDispatcher`
Summary:
@public
Now, it's not just an abstract class, it's a regular class which unifies event delivery priorities using specific event beats and event pipe.

Reviewed By: mdvacca

Differential Revision: D8886232

fbshipit-source-id: c4360511e5fd477ca7407fc3ebbd99ca578e79cc
2018-08-27 07:32:37 -07:00
Valentin Shergin 5f8d5e0665 Fabric: Proper events priorities for touch events
Summary:
@public
The existing code does not use that at all but we need that for testing things and we will need this in the future.

Reviewed By: mdvacca

Differential Revision: D8886236

fbshipit-source-id: 5ca33e4f4d4ca13a6be0f55cc04b59d5f9b27fa9
2018-08-27 07:32:36 -07:00
Valentin Shergin 71295bcdac Fabric: Enabling and disabling EventEmitter at post commit phase
Summary:
@public
We need that to ensure that we will not deliver events to nodes with invalid state.

Reviewed By: mdvacca

Differential Revision: D8886234

fbshipit-source-id: 1d6ca129c97a5dca0411e85909aea48185f46c54
2018-08-27 07:32:36 -07:00
Valentin Shergin b784adc7ae Fabric: `FabricUIManager::dispatchEventToEmptyTarget` got coupled with `dispatchEventToTarget`
Summary:
@public
Instead of having two methods it's easier to have just one which can be abstracted as `EventPipe`.

Reviewed By: mdvacca

Differential Revision: D8886231

fbshipit-source-id: af9fd92dc4afa1219a11acce0aa021a85c94d232
2018-08-27 07:32:35 -07:00
Valentin Shergin 5965ba283f Fabric: Introducting EventQueue (+ Batched and Unbatched versions)
Summary:
@public
EventQueue is a queue of events that synchronizing event dispatching with given Event Beat.
The only difference between UnbatchedEventQueue and BatchedEventQueue is that UnbatchedEventQueue `induce` an Event Beat right after enqueing an event.

Reviewed By: mdvacca

Differential Revision: D8886225

fbshipit-source-id: fedba6fdff2ecb6f3c615cea09b5fdaa58890479
2018-08-27 07:32:35 -07:00
Valentin Shergin 504c7694c4 Fabric: Introducing `RawEvent`
Summary:
@public
RawEvent represents ready-to-dispatch event data, an event that can be processed uniformly.

Reviewed By: mdvacca

Differential Revision: D8886235

fbshipit-source-id: 1c905517814330c5ecbf39f0ebc95ff2b576d1f2
2018-08-27 07:32:35 -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
Pritesh Nandgaonkar d85226f539 Solve the bug related to baseline height
Summary:
This diff fixes the height calculation logic for the nodes with baseline. Before height calculation for baseline was done at wrong place.

The task was created due to the regression caused by D9219678.

Reviewed By: IanChilds

Differential Revision: D9421551

fbshipit-source-id: 3fbb738314130b346c4186ec45d00c9ea63bc9f4
2018-08-22 12:31:19 -07:00
Pritesh Nandgaonkar 5be1726d28 Solve width bug when the size is less than min
Summary:
This diff updates the logic which reassigns `remainingFreeSpace` when the node's calculated dimension falls below min width of the node.

So we will have to update the `remainingFreeSpace` as there is more available space since the calculated nodes width is less than the min width.

I have also added comments at relevant places in the code so that it is clearer.

This diff solves the issue raised in litho support grp. The details can be found here T32199608. This diff also makes sure that it doesn't break fblite, as the earlier version broke it, details of which can be found here T32881750.

Reviewed By: IanChilds

Differential Revision: D9359026

fbshipit-source-id: 4168e385e962c168a9de9370220c75f14a6726a7
2018-08-20 06:20:52 -07:00
David Aurelio 625c54d406 Inline `YG_NODE_STYLE_PROPERTY_UNIT_IMPL` macro
Reviewed By: astreet

Differential Revision: D8874733

fbshipit-source-id: 75c24b508f287f405fad09605f64d2bfb3ffa0a5
2018-08-17 04:02:30 -07:00
David Aurelio e4dc34ddba Replace percent setter in `YG_NODE_STYLE_PROPERTY_UNIT_IMPL` macro with template code
Reviewed By: astreet

Differential Revision: D8874732

fbshipit-source-id: 46fdf851f19f16def0c7e2ab4c5f17a349dc7aee
2018-08-17 04:02:30 -07:00
David Aurelio 03377ac322 Replace point setter in `YG_NODE_STYLE_PROPERTY_UNIT_IMPL` macro with template code
Reviewed By: astreet

Differential Revision: D8874735

fbshipit-source-id: 77fa1ceb2eaff6a0e415ef939e55aa22bc3d6099
2018-08-17 04:02:30 -07:00
David Aurelio edc15ebceb Replace getter in `YG_NODE_STYLE_PROPERTY_UNIT_IMPL` macro with template code
Reviewed By: astreet

Differential Revision: D8874734

fbshipit-source-id: ba94b4d0fd31e8344c7836b66a269d5f1f69e225
2018-08-17 04:02:30 -07:00
David Aurelio b7c079f96f Type alias for dimensions
Summary:
Aliases `std::array<YGValue, 2>` as `YGStyle::Dimensions` for increased readability.

This prepares a follow up, where the alias is used in `Yoga.cpp`.

Reviewed By: astreet

Differential Revision: D8874566

fbshipit-source-id: a7a7a1b02bff547d7d6b800c522c4785a62ad611
2018-08-17 04:02:30 -07:00
Pritesh Nandgaonkar 3770165f72 Fix parent height calculation in case of baseline alignment
Summary:
Prior to this diff, if parents height was not set then the height of parent was deduced as max of childrens height(considering  line ht, padding, margin etc. ), but it didn't consider the baseline scenario where the previous logic will fail as then the parents height will be determined by the space taken by children above and below the reference baseline. I added a test case for the same.

Look at the diff D9088051 which shows the screenshot of the bug.
It is solved to https://pxl.cl/gvVk

Reviewed By: dsyang

Differential Revision: D9219678

fbshipit-source-id: f4a0b9f1452c33e78bd8c6cf39f6fcf538a04074
2018-08-16 16:52:42 -07:00
Roman Kushnarenko f0631b11f5 Revert D9286928: [yoga] Solve width bug when the size is less than min
Differential Revision:
D9286928

Original commit changeset: 915269602cda

fbshipit-source-id: a4c23bf335b82fbbf3928a524a61374a6cf6ffb1
2018-08-16 16:52:42 -07:00
David Vacca af49568482 Implement the update of props in the MountingManager layer
Summary: This diff implements the update of props in Fabric C++. The props values are passed to java in a ReadableMap and they are integrated into the current implementation of ViewManagers. In the fututre we will replace the ReadableMap for typed objects.

Reviewed By: shergin

Differential Revision: D9093560

fbshipit-source-id: da58326cfadb0665dac3349a8cf24cde2d401aaa
2018-08-16 16:52:42 -07:00
David Vacca 3418d01703 Expose rawProps as part of the Props class
Summary: this diff exposes the rawProps folly::dynamic map received by JS as part of the Props class

Reviewed By: shergin

Differential Revision: D9093559

fbshipit-source-id: 5f5bc4924aebb6bcc24c7a82ce1a59593d44450e
2018-08-16 16:52:42 -07:00
David Vacca 8a8ee33f48 Fix color conversions for android
Summary: This diff fixes the color conversions for Android

Reviewed By: shergin

Differential Revision: D9093561

fbshipit-source-id: a17e61c58be511bd463dc0b21b632dc24066b8b6
2018-08-16 16:52:42 -07:00
David Vacca b8a50c7614 Improve error message when a component descriptor is not implemented
Summary: This diff improves the error message that is displayed when a component descriptor is not implemented in C++

Reviewed By: shergin

Differential Revision: D9093562

fbshipit-source-id: 930b381bc66c20af6fa160b09e7484bad4666e28
2018-08-16 16:52:42 -07:00
Pritesh Nandgaonkar 3072d599c9 Solve width bug when the size is less than min
Summary:
Removed the faulty calculation of `remainingFreeSpace` from the code. `remainingFreeSpace` already had the correct value that special condition was not required.

Also added a test case for this issue

Reviewed By: IanChilds

Differential Revision: D9286928

fbshipit-source-id: 915269602cda2cc4515e6eab8184b2ea98d3e6d4
2018-08-16 16:52:41 -07:00
David Aurelio 0926373c9f Eliminate remaining `YGStyle&` locals
Summary:
@public

Replaces local references to `YGStyle` objects, and assignment to `YGValue` members with direct assignment from temporaries.

This should increase readability, and eliminate duplicated checks for *undefined* values.

Reviewed By: astreet

Differential Revision: D9083531

fbshipit-source-id: 11386be465352f5cb167b8195b7da432d0055d6f
2018-08-15 06:17:15 -07:00
David Aurelio acd8820154 Eliminate unnecessary copies of node style objects
Summary:
@public

`YGNode.getStyle()` returns a reference to the enclosed `YGStyle` member. Assigning to a local copies unnecessarily.

Having eliminated the copy, we can also safely remove calls to `YGNode.setStyle()`, eliminating another copy.

Reviewed By: astreet

Differential Revision: D9083336

fbshipit-source-id: df8b603b5cc0b974cf5dd434c71956be4548e583
2018-08-15 06:17:15 -07:00
Alex Dvornikov 1cd9aa2dea Add REGISTER_JS_SEGMENT perf markers
Reviewed By: cwdick

Differential Revision: D9244289

fbshipit-source-id: 9004a0405f9622cbd0bbb837b99df32454f35bb8
2018-08-10 09:37:42 -07:00
Valentin Shergin 1d93d70af4 Fabric: `ShadowNodeCloneFunction` signature was unified with ShadowNode copy constructor
Summary:
@public
Now it accepts `const ShadowNode &` instead of `std::shared_ptr<const ShadowNode>` which is more reasonable (and more performant) becasue the function must not retain ownershipt.

Reviewed By: mdvacca

Differential Revision: D9073921

fbshipit-source-id: c24c475615e0f81b3e004e118dea7565d8e757b4
2018-08-04 09:47:31 -07:00
Valentin Shergin 6230147e73 Fabric: Removed unnecessary `YGValue::operator==`
Summary:
@public
We backported that into Yoga recently, so we don't need it here anymore.

Reviewed By: mdvacca

Differential Revision: D8988439

fbshipit-source-id: 01a538ff291e25d92eeb01b1fdee3a6868b2448b
2018-08-04 09:47:31 -07:00
Valentin Shergin 3770d4df45 Fabric: Using `const &` type for `ShadowNodeFragment`'s fields
Summary:
@public
To avoid unnecessary copying of `shared_ptr`s inside ShadowNodeFragment, now we store them as `const &` references.

Reviewed By: mdvacca

Differential Revision: D8988388

fbshipit-source-id: 0b3582e57ce7577b8fa819392bf33f34e1a60b59
2018-08-04 09:47:31 -07:00
Valentin Shergin 06e62440d3 Fabric: Using `ShadowNodeFragment` in `ComponentDescriptor`
Summary:
@public
Now we use same data structure to specify a shape of shadow node as we use in ShadowNode (sub)clases.

Reviewed By: mdvacca

Differential Revision: D8988387

fbshipit-source-id: 475298b2c71ee7ee2b197db009f7b8313b54f5df
2018-08-04 09:47:30 -07:00
Valentin Shergin 52ed882332 Fabric: Using `const ShadowNode &` as a parameter in ShadowNode copy constructor
Summary:
@public
When we copy-construct ShadowNode, we don't need to retain a source shadow node, so there is no need to pass it as a `shared_ptr`. Passing an argument to constructor as `const &` is also more idiomatic in C++.

Reviewed By: mdvacca

Differential Revision: D8988384

fbshipit-source-id: 1279d9185fa1b4b82fd26e3040bd62fa9495b4d3
2018-08-04 09:47:30 -07:00
Valentin Shergin 938e1d51c4 Fabric: ShadowNode::children_ is now managed in copy-on-write manner
Summary:
@public
ShadowNode class is designed to share `props` and `children` objects between instances. Given that all *Props classes are immutable, it's very easy to share them and we do this from the day one. The `children_` collection is more tricky though because ShadowNode class has a couple of mutation methods. Previously, we dealt with it very simply by copying the whole vector in constructors, and that was far from optimal. Now we store a special flag that indicates that the children list is shared among nodes, and we clone this before the first mutation.
Sharing a `shared_ptr` should be much more efficient (cost of atomic refcount increment) than instantiating whole new collection (an allocation).

Reviewed By: mdvacca

Differential Revision: D8988386

fbshipit-source-id: cb2f6b2fccac70a35e070a1aa108d135f77cd041
2018-08-04 09:47:30 -07:00
Valentin Shergin d74346b616 Fabric: `ShadowNode::getChildren()` now returns `vector`, not `shared_ptr`
Summary: TBD

Reviewed By: mdvacca

Differential Revision: D8988385

fbshipit-source-id: 1d1c7e0b87b32b242c69bbce44cf70fb0899cf93
2018-08-04 09:47:30 -07:00
Valentin Shergin ca6d263d6d Fabric: ConcreteViewShadowNode::BaseShadowNode type alias
Summary:
@public
Just a type alias to make the code prettier, nothing more.

Reviewed By: mdvacca

Differential Revision: D8988383

fbshipit-source-id: 3f21de0ec0cb9a2270eccfc4a67a3d1108535e42
2018-08-04 09:47:30 -07:00
Valentin Shergin 95074e6c12 Fabric: ShadowNode::Fragment
Summary:
@public
This diff changes a way how we specify a shape of newly created and/or cloned of ShadowNode. Previously we pass those values as a list of arguments, now those values are coupled into a new data structure called ShadowNodeFragment. All that makes suppose to make code much more easy to read and maintain, this is especially important because we want to add a couple of new entities in this set.

Reviewed By: mdvacca

Differential Revision: D8988389

fbshipit-source-id: 1835f646e1ecc6a1f413feaf1900f3d3ad0ebc05
2018-08-04 09:47:30 -07:00
Valentin Shergin 682fd43f3b Fabric: Removed ConcreteShadowNode specialized constructors
Summary:
@public
Apparently we don't need them.

Reviewed By: mdvacca

Differential Revision: D8944766

fbshipit-source-id: e3b78f98d3d805ab0aaf5a167efeb7e058c0394e
2018-08-04 09:47:30 -07:00
Valentin Shergin 67a79010ca Fabric: Simplified way to specialize ComponentName in ConcreteShadowNode class template
Summary:
@public
Previously, all ConcreteShadowNode subclasses had to override `getComponentName()` function to specialize a name of the component. And often it was all that those subclasses do. Now, it's a template argument; and many ShadowNode classes can be created as oneliners via *just* specializing  ConcreteShadowNode template.

Unfortunately, C++ does not allow to use `std::string`s or string literals as template arguments, but it allows to use pointers. Moreover, those pointers must point to some linked data, hence, those values must be declared in .cpp (not .h) files. For simplicity, we put those constants in Props classes, (but this is not a strong requirement).

Reviewed By: mdvacca

Differential Revision: D8942826

fbshipit-source-id: 4fd517e2485eb8f8c20a51df9b3496941856d8a5
2018-08-04 09:47:30 -07:00
Valentin Shergin 5d0b51b107 Fabric: Making Sealable debug-only thing
Summary:
@public
Now, Sealable is already error-preventing-only mechanism, no business logic relies on that.
So, it makes sense to make it debug-only to illuminate possible performance impact.

Reviewed By: mdvacca

Differential Revision: D8923597

fbshipit-source-id: 80aa9097c4b719e91de73ac59f38d3a4751f0b06
2018-08-04 09:47:29 -07:00
Valentin Shergin 50b80a9ef8 Fabric: Fixed image URLs parsing
Summary:
@public
It's a basically reimplementation of `+[RCTConvert NSURL:]`.

Reviewed By: mdvacca

Differential Revision: D9146850

fbshipit-source-id: 57ecac1eb35b57b0d417b599371bd0c4a3988116
2018-08-03 08:32:56 -07:00
Dulmandakh 6117a6c720 Bump Android NDK to r17b (#20357)
Summary:
This PR bumps Android NDK version to r17b (latest). Cleaned up redundant **LOCAL_EXPORT_CPPFLAGS** rules in .mk files
Pull Request resolved: https://github.com/facebook/react-native/pull/20357

Differential Revision: D9068424

Pulled By: hramos

fbshipit-source-id: 8578637e38e807288b819a36cb75ea9feefcc09f
2018-07-30 14:02:11 -07:00
Amir Shalem 374fd7c0cd Deallocate the YogaConfig memory with correct method
Summary: We've mistakenly used `free()` to free the memory, where `delete` should have been used

Reviewed By: davidaurelio

Differential Revision: D9042347

fbshipit-source-id: e15cec0f498409066521a6de1e3fe4b7404ec46c
2018-07-29 14:16:35 -07:00
Ram N c7fdd2701f Added more info to Module Registry systraces
Summary:
Added module names to systraces for getConstants and getMethods.

Also added systrace for moduleNames.

We are starting to look at ways to optimize native modules, and having these traces helps

Reviewed By: javache

Differential Revision: D9012702

fbshipit-source-id: c79222f36988bef3a108ed91d1ea1318d3576b40
2018-07-26 15:35:54 -07:00
Kevin Gozali 201ba8c69d Catch JS bundle load failure and prevent calls to JS after that
Summary: There are cases where JS bundle fails to be evaluated, which throws an exception already, but then there were pending calls into JS which would fail in a weird way. This prevents those calls (because it's mostly meaningless at that point). For now, those extra calls will still throw an exception, but with a specific message so that it doesn't confuse people.

Reviewed By: yungsters

Differential Revision: D8961622

fbshipit-source-id: 3f67fb63fdfa9fc5b249de0096e893b07956776a
2018-07-24 19:48:32 -07:00
Valentin Shergin 6bf9024107 Implementation of `operator==` for YGValue
Summary:
@public
It's very useful sometimes for product code to compare `YGValue`s (e.g. in Fabric).

Reviewed By: priteshrnandgaonkar

Differential Revision: D8937594

fbshipit-source-id: b93e1ab4a6419ada6746f233b587e8c9cb32c6d4
2018-07-23 13:33:28 -07:00
David Aurelio 709e3bc1fe Replace `YG_NODE_STYLE_PROPERTY_IMPL` macro with template
Summary:
@public

Replacing the `YG_NODE_STYLE_PROPERTY_IMPL` macro with template code, in order to make code easier to edit and grep.

Reviewed By: astreet

Differential Revision: D8868184

fbshipit-source-id: f52537376fa8d4dd53aa98bb43e93279699dbdd5
2018-07-19 10:02:27 -07:00
David Aurelio 95b7fd9de6 Yoga.h: inline function declaring macros
Summary:
@public

Inlines macros used for declarations of `YGNodeStyle*` and `YGNodeLayout*` functions.
Benefits easier grepping and code base navigation.

Reviewed By: astreet

Differential Revision: D8868168

fbshipit-source-id: d6b1b70981a59a2214dc7d166435a1d1a844e1b7
2018-07-19 10:02:27 -07:00
David Aurelio ce4c2de3a3 Run lint on `Yoga.cpp`/`Yoga.h`
Summary:
@public

auto-fixes formatting for `Yoga.cpp`/`Yoga.h`.
Submitted separately to keep other diffs cleaner.

Reviewed By: astreet

Differential Revision: D8868179

fbshipit-source-id: d0667f8bb909bb5ada1263aac6e22b0a8f8875ad
2018-07-19 10:02:27 -07:00
David Aurelio 1d7a24ff0c inline trivial constructors / methods
Summary:
@public

inlines some trivial constructors, destructors, and methods.

Reviewed By: astreet

Differential Revision: D8912691

fbshipit-source-id: 79840ef3322676deebed99391390d6c1796963b5
2018-07-19 10:02:27 -07:00
David Aurelio dfc7b2fd03 auto-lint YGLayout.h YGNode.h YGStyle.cpp YGStyle.h
Summary:
@public

automatically applies lint fixes to  YGLayout.h YGNode.h YGStyle.cpp YGStyle.h

Reviewed By: astreet

Differential Revision: D8913432

fbshipit-source-id: 488bf25db041ddb527565c26c1762c6ee4cae736
2018-07-19 10:02:27 -07:00
Scott Wolchok 165dd40bea Explicitly default YGNode copy ctor
Summary: No need to type out the old version. This is exactly equivalent (unless I've misread and the old version did something other than memberwise copy).

Reviewed By: davidaurelio

Differential Revision: D8842326

fbshipit-source-id: c575ea4cee6caef9ea15aaf5967597385ed26ec3
2018-07-18 15:47:55 -07:00
Scott Wolchok 46fb04e746 Delete YGNode ctor w/arg per member
Summary: It doesn't seem to be used internally, it hurts greppability, and there are setters for these properties as needed anyway.

Reviewed By: davidaurelio

Differential Revision: D8842084

fbshipit-source-id: f0275b490e585ea94df341c97c34b441ed91c4fb
2018-07-18 15:47:55 -07:00
David Aurelio 04aaa01991 Make `YGFloatIsUndefined` inlineable
Summary:
@public

Makes `YGFloatIsUndefined` inlineable

Reviewed By: swolchok

Differential Revision: D8875520

fbshipit-source-id: 7ac653e002512b1a8d5f9c04e0a21381aeb02e67
2018-07-18 02:39:20 -07:00
David Aurelio b330579204 Lint Utils.cpp YGLayout.cpp YGNode.cpp Yoga-internal.h
Summary:
@public

Auto-fixes formatting of YGLayout.cpp YGNode.cpp Yoga-internal.h

Reviewed By: astreet

Differential Revision: D8875514

fbshipit-source-id: 38d709831349c4ad015f20451421aea89fc6f007
2018-07-18 01:01:56 -07:00
Valentin Shergin 9395485822 Fabric: ContextContainer is now able to store any copyable values
Summary:
@public
Previously, ContextContainer could store only `shared_ptr`s, but now it wraps all values in own `shared_ptr` container.
I wish we can use `unique_ptr` here, but apparently we cannot because `unique_ptr` does not support type-erasure (`std::unique_ptr<void>` is illigal).
Becasue ContextContainer is not supposed to be used in hot paths, the performance aspect of that does not actually matter.

Reviewed By: mdvacca

Differential Revision: D8853446

fbshipit-source-id: e5d0a5595fe44c59f1395d6ffccf9d3fed923c83
2018-07-17 22:53:57 -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 88b8616437 Fabric: Using `unordered_map` instead of `map` for RawProps
Summary:
@public
We don't need to maintain an order of this collection, so using `unordered_map` is more appropriate.

Reviewed By: mdvacca

Differential Revision: D8826946

fbshipit-source-id: f6890097cc5d6a1e06f6b2cfd1b7d68a388da461
2018-07-17 22:53:56 -07:00
Valentin Shergin 58da98149d Fabric: Support for optional `key` parameter to register/retrieve in ContextContainer
Summary:
@public
We need this in case when we want to store several intances of the same class in the container.

Reviewed By: mdvacca

Differential Revision: D8814808

fbshipit-source-id: 78ab15d78cf3878d03bf0a45bc42b968d87435e7
2018-07-17 22:53:56 -07:00
Valentin Shergin ec5b1fd259 Fabric: Optimized ShadowNode::replaceChild() with `suggestedIndex` argument
Summary:
@public
In most cases callsite knows probable index of replacing child node, hence it makes sense to provide this info to `replaceChild` to illuminate O(n) search in most cases.

Reviewed By: mdvacca

Differential Revision: D8814809

fbshipit-source-id: 0edf82878a72260365e2757beb3886ad07c7464d
2018-07-17 22:53:56 -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 2d1fabbab2 Fabric: `SharedColor` for Android
Summary:
@public
On Android, a color can be represented as 32 bits integer, so there is no need to instantiate complex color objects and then pass them as shared pointers.  Hense instead of using shared_ptr, we use a simple wrapper class which provides a pointer-like interface.

Reviewed By: mdvacca

Differential Revision: D8742014

fbshipit-source-id: 14109b61fd84a34989538a15bc6fe4e2a8ce83a6
2018-07-17 18:17:27 -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
Taras Tsugrii c68c3a53d4 Fix invalid build file syntax.
Summary: https://buckbuild.com/concept/skylark.html

Reviewed By: shergin

Differential Revision: D8878696

fbshipit-source-id: 33db539701fa84e7391be643f3eabb7e0224aa0b
2018-07-17 17:33:12 -07:00
David Vacca 46164324cd Exclude ios dependencies from Android build in fabric C++
Summary: This diff updates the buck dependencies from fabric to allow cross platform usage

Reviewed By: shergin

Differential Revision: D8755155

fbshipit-source-id: 8501463bb22e5b86e6ad8b6c9f621251c6b6d55a
2018-07-17 01:46:45 -07:00
Valentin Shergin e9e20e6c83 Fabric: <Root> component was decoupled from <View>
Summary:
@public
There is no reason to have it inside View; it deserves that.

Reviewed By: mdvacca

Differential Revision: D8757012

fbshipit-source-id: 881b54008b51614cd203ab97811494fa7c30e4ef
2018-07-15 16:52:26 -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 2c28310267 Fabric: Computed attributed string caching inside <Paragraph>
Summary:
@public
Quite trivial. We had to have this from the day one.
We don't need cache invalidation policy because all subtree is immutable.

Reviewed By: mdvacca

Differential Revision: D8709973

fbshipit-source-id: bd7fcf0ae1dcb23894321cb5d16da18cb1ab788f
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 7a7f9601bc Fabric: ShadowNode::getSourceNode() was finally removed
Summary:
@public
Trivial.

Reviewed By: mdvacca

Differential Revision: D8753905

fbshipit-source-id: 0a0e351dc0f8ff52e685c7d7dc79d0185cfac711
2018-07-15 16:52:26 -07:00
Valentin Shergin e78bf723bf Fabric: Removed last two plactical usages of `ShadowNode::sourceNode_`
Summary:
@public
 * In case of `ShadowTree` we just pass original old node as a `commit` method argument;
 * In case of `ConcreteViewShadowNode` we just don't need that because diffing algorithm does not use that information anymore.

Reviewed By: mdvacca

Differential Revision: D8753906

fbshipit-source-id: b8555083c7e72e9b3c0f9a8065745946d4cf44c7
2018-07-15 16:52:25 -07:00
Valentin Shergin fcd72bf34a Fabric: Generalizing cloning of YogaLayoutable approach
Summary:
@public
Non-null owner pointer in Yoga node indicates that this node is already being used by some other subtree, so it must be cloned in case of possible (re)layout.
Theoretically, this node must/can be cloned by Yoga right before applying a new layout to this node, but Yoga has a special optimization that uses that fact that Yoga always cloning *all* children of a particular node altogether. This is not true for React; to meet React and Yoga worlds we double check the owner pointer in `addChild` and clone node preliminary if needed.
See also the previous diff for more context.

Reviewed By: mdvacca

Differential Revision: D8709952

fbshipit-source-id: 84ef0faa0f1d9cc9a8136b550cf325bc20508d53
2018-07-15 16:52:25 -07:00
Taras Tsugrii 12d98db901 Fix conditional load usage.
Summary:
Conditional `load` statements are not allowed in new Buck build file parser - Skylark.
https://buckbuild.com/concept/skylark.html

Reviewed By: mzlee

Differential Revision: D8842756

fbshipit-source-id: f22dff00f594978e4cab5736268ad3225182c39b
2018-07-14 18:32:20 -07:00
Taras Tsugrii 6b1d99686d Skylarkify jni_instrumentation_test.
Summary: https://our.intern.facebook.com/intern/wiki/Buck/python-to-skylark/

Reviewed By: mzlee

Differential Revision: D8842575

fbshipit-source-id: 2de5efa8b00397e751f6c213b8c8630deea21f00
2018-07-13 15:03:15 -07:00
Scott Wolchok 6ab52ff90d Remove some unnecessary `const float &` uses
Summary: Holding floats by reference is unnecessary at best and may be detrimental to performance.

Reviewed By: davidaurelio

Differential Revision: D8826496

fbshipit-source-id: 2391f8aa26ebfbb440f6e4b7d57975be688f791c
2018-07-13 12:48:02 -07:00
Scott Wolchok 727ee92de5 Tidy up YGFloatOptional further
Summary: I missed these two things: inline default ctor, getValue() should return a float.

Reviewed By: priteshrnandgaonkar

Differential Revision: D8826640

fbshipit-source-id: e6324dea0268ef276e6fa1722e72dffb5241e676
2018-07-13 12:48:02 -07:00
Scott Wolchok e589595bc9 YGNode::getChildren() should return const ref
Summary:
It's wasteful to do it by value. I'm fairly sure this is
safe, especially because
fbd332dee8 (diff-ade2a4bbd6582e2898cbd9e0fa142ab5R215)
shows that we did access by reference before.

Reviewed By: priteshrnandgaonkar, davidaurelio

Differential Revision: D8822697

fbshipit-source-id: 791bcf0fa37453f67795af727c85c8adce3b0f69
2018-07-13 12:48:02 -07:00
Scott Wolchok 7eb419d4bf Tidy up YGFloatOptional
Summary: Just some convention/weird style things. `float` should be passed by value, weird use of ?: operator instead of ||.

Reviewed By: priteshrnandgaonkar

Differential Revision: D8804407

fbshipit-source-id: e0d67363ccde36ec5bccec7497ed0ffd364b3fcf
2018-07-12 08:46:36 -07:00
Scott Wolchok 40cdda3166 Inline simple YGNode getters/setters
Summary: Simple getters/setters are usually inlined like this.

Reviewed By: priteshrnandgaonkar, davidaurelio

Differential Revision: D8793588

fbshipit-source-id: 436bd54880e41a5e403e3f4ae0d9dd4a413df79c
2018-07-11 09:02:21 -07:00
Scott Wolchok 4858454718 Remove unused YGNode::*nextChild
Summary: This linked list was never used, and YGNodeDeepClone was doing scary things to maintain it.

Reviewed By: davidaurelio

Differential Revision: D8792864

fbshipit-source-id: c578fabe65c837f0791aa9ac3e18f31d93691abd
2018-07-11 09:02:21 -07:00
Pritesh Nandgaonkar 90a408ea6f Fix SingleFlex Child condition
Summary:
Fixes the improper `singleFlexChild` optimization. In the case when all the childs have `flex-grow:0 flex-grow:0` except one child with `flex-grow:1 flex-shrink:1`, then one can simply measure all the non-flexing children and then give the flexing child all the remaining space.

Also added a test case which reproduced the bug

Reviewed By: IanChilds

Differential Revision: D8782684

fbshipit-source-id: ffd4d35b6122f82111b987540efb23bd2a8da5a2
2018-07-11 06:02:16 -07:00
Valentin Shergin e8ec1cb16a Fabric: The diffing algorithm does not use source nodes anymore
Summary:
@public
... and it's as efficient as it was before.

The previous version of the algorithm used `sourceNode` reference to know the previous state of the node to call the algorithm recursively.
That wasn't so good because of several reasons:
 - It was fragile because we had two different sources of the truth of the "previous state of the tree": committed tree and source node pointer;
 - We had to store weak pointers to source nodes inside cloned nodes. That is not free in terms of performance;
 - The old approach introduced a constraint that all previously used and now reinserted nodes must be cloned to update source node (otherwise, the algorithm would regenerate instructions recreating already existing subtrees);
 - That cloning required access to `isSealed` flag which is supposed to be a debug-only thing (that actually affects performance and must be compile-out for release builds).

The new approach compares nodes with same react tag and naturally cloning-artifacts resilient.

Yes, the new approach uses a map of inserted nodes, but the previous one already had it (otherwise there is no way to tell which nodes should be "deleted"). And anyway, this is a very little map that exists for a very little period of time.

Reviewed By: mdvacca

Differential Revision: D8709953

fbshipit-source-id: 027abb326cf45f00f7bb0bbd7c4e612578268c66
2018-07-06 14:49:07 -07:00
Valentin Shergin e0e9c1549e Fabric: Improved prettyprinting of TreeMutationInstruction
Summary:
@public
Quite trivial... and nice.

Reviewed By: mdvacca

Differential Revision: D8709951

fbshipit-source-id: 63e53eb85361fe3a0a0ecd7f21bf4c7db049d5bf
2018-07-06 14:49:06 -07:00
David Vacca 6292e2707a Revert order of Remove Mount Item operations
Summary: Revert the order of "remove mount items", to ensure views are removed from high index to low index.

Reviewed By: shergin

Differential Revision: D8742796

fbshipit-source-id: 6e04c39386d290bf3958ee83256d4fbe23e2c4ca
2018-07-06 09:17:34 -07:00
Kevin Gozali a09c464585 iOS: avoid crash because of null eventTarget
Summary: We were supposed to pass in proper eventEmitter, but passed in one with null eventTarget instead, causing assertion failures when dispatching event.

Reviewed By: sebmarkbage, shergin

Differential Revision: D8720793

fbshipit-source-id: 891f3b2a2c76a6dd3e40039623c6e86991aad50b
2018-07-02 18:02:35 -07:00
Valentin Shergin ee535fafe3 Fabric: Making `fabric/textlayoutmanager` compilable on Android
Summary:
@public
This compiles, but it works only on iOS for now.

Reviewed By: mdvacca

Differential Revision: D8655540

fbshipit-source-id: 7e9a73fadb317dd62298af6f347344ac4229a8a5
2018-07-01 21:37:00 -07:00
Valentin Shergin 5786db3a26 Fabric: Making `fabric/graphics` compilable on Android
Summary:
@public
This compiles but this does not work.
To make it actually work we have to implement all missing functions in `Color.cpp` and co.

Reviewed By: fkgozali

Differential Revision: D8655537

fbshipit-source-id: 564fb7131445af81cf05407239dc6ba870cf6b83
2018-07-01 21:36:59 -07:00
Sebastian Markbage 5d9326be29 Remove instanceHandle, pass event target instead + add dispatchToEmptyTarget
Summary:
Removes the concept of instance handle. Instead we pass the event target
to createNode and don't pass it to subsequent clones.

The life time of the event target is managed by native (the event emitter).
It has to be released manually.

Reviewed By: shergin

Differential Revision: D8688330

fbshipit-source-id: e11b61f147ea9ca4dfb453fe07063ed06f24b7ac
2018-06-29 15:32:27 -07:00
Valentin Shergin 62f9ced099 Fabric: Subtle changes that make GCC compiler happy
Summary:
@public
Most of them are legit issues which should not be compilable anyways (but Clang tolerates thems).

Reviewed By: mdvacca

Differential Revision: D8655539

fbshipit-source-id: 645729fb9d6a120ce1ab2b07542abcdacd72320d
2018-06-29 12:18:27 -07:00
Valentin Shergin 712c2ed5d2 Fabric: Getting rid of `std::to_string()`
Summary:
@public
Suddenly, it is not supported on Android.
Luckelly `folly:to<std::string>()` is as good as `std::to_string()`.

Reviewed By: mdvacca

Differential Revision: D8655538

fbshipit-source-id: 2b3b970f6a261253aaa6b22dba8338dc66b7195d
2018-06-29 12:18:27 -07:00
David Vacca 2f3f1b02cd Avoid cleaning up Owner of YGNode during clonning
Summary:
This diff refactors the cloning mechanism for YogaNode used from Fabric UI renderer and RN iOS graphs.
Previously, we were cleaning the owner of the child's cloned node inside the C++ implementation of YogaNode. This was a mistake because this modified the last commited YogaTree, causing side effect in RN iOS graphs.

Reviewed By: shergin

Differential Revision: D8672627

fbshipit-source-id: c9902d00690e0361fd58aed84b506c42258bd995
2018-06-28 22:48:35 -07:00
Valentin Shergin 80f7891287 Fabric: Embracing non-trivial default values of some Props
Summary:
@public
This is follow up for D8601600 and D8247652 (the last one has detailed explanation of the problem).
From this commit I propose that we have to follow simple rule:
If some prop has a default value which differs from the default value of its type, we have to specify it as {<value>} in .h file and explicitly in .m file, for all other props the default value must not be specified explicitly (in .h files it must be specified as {}).
The reason is that we have to embrase those cases and establish behaviour: if we change the default value in .h file, it always means that we have to change the value in .cpp file too.

Reviewed By: fkgozali

Differential Revision: D8601776

fbshipit-source-id: 3379aace4e2d72febb2b942a3da1cb24decf54be
2018-06-26 11:48:13 -07:00
Valentin Shergin 97bc0c03ba Fabric: `fromDynamic` for float numbers was moved to `core` module
Summary:
@public
Otherwise, it can mess with implementation for `int`s and causes some errors where `float` implementation was requested but `int` was applied.

Reviewed By: mdvacca

Differential Revision: D8601752

fbshipit-source-id: cfe51b7785ff29ee4ad88f0f1cbfed335557d5ef
2018-06-26 11:48:12 -07:00
Taras Tsugrii 71cd2d79ec Move conditional logic into corresponding build defs.
Summary:
Conditional `load`s are not allowed in Skylark. The logic
that belongs to different environments has to be part of environment
specific build defs and include as part of cell resolution or CI
configuration.
More context: https://buckbuild.com/concept/skylark.html

Differential Revision: D8604673

fbshipit-source-id: 385f2e155c4d80219e6ed3a2e0a82c909ebabb13
2018-06-24 14:46:38 -07:00
Kevin Gozali 1dced3448a iOS: implement <PerformanceLoggerFlag> component
Summary: This is basic impl of <PerformanceLoggerFlag> component without any layout/mounting computation, just TTI.

Reviewed By: shergin, mdvacca

Differential Revision: D8598983

fbshipit-source-id: b938753d6396088735cbbeab26d69c9aaa45608e
2018-06-24 14:17:37 -07:00
Valentin Shergin 802a371c92 Fabric: Fixed missed default value in parsing constructor of ViewProps
Summary:
@public
It fixes a problem when some Views got disaper after they have non-zero opacity.

Reviewed By: mdvacca

Differential Revision: D8601600

fbshipit-source-id: 3da3ee591d4a685a8d7a56b15519d4d5cae4a031
2018-06-23 19:16:09 -07:00
Taras Tsugrii 346ac75ed6 Fix deprecated glob usage.
Summary: https://our.intern.facebook.com/intern/wiki/Buck/python-to-skylark/

Differential Revision: D8595731

fbshipit-source-id: 0e3046a7fd2a25e9b13462713ae9a008ad546770
2018-06-23 18:33:48 -07:00
Valentin Shergin 6942408a47 Fabric: Dispatching `onLayout` events to only nodes which requested it
Summary:
@public
The current Fabric architecture, in general, does not support "subscribing" for events, so all kinds of events are always delivered no matter have JavaScript components `on`-handlers for them or not.
At this point, we are not sure should it be this way or not. But we are sure that for some extremely noisy events (like onLayout) we have to make an exception right now (otherwise overall performance will suffer).
So, this diff implements that for `onLayout`.

Reviewed By: fkgozali

Differential Revision: D8597408

fbshipit-source-id: 6933b7cb96e24f0660bd7850b625ff27e3146a2b
2018-06-22 18:46:39 -07:00
Valentin Shergin 250cc3c594 Fabric: Fixed order of instructions in Differentiator
Summary:
@public
Previously Differentiator might generate some `remove` instruction that refers to already `deleted` node. That diffs fixes that.

Reviewed By: fkgozali

Differential Revision: D8596536

fbshipit-source-id: 88117962f93e52167dbcb6525f2cc36758a367e7
2018-06-22 15:34:47 -07:00
Valentin Shergin 483c45cff0 Fabric: Shadow node shallowing was removed from preventive cloning in UIManager
Summary:
@public
We do preventing cloning in UIManager especially to add a layer to Shadow Node source chain,
so apparently there is no point illuminate that by calling `shallowSourceNode`.

Reviewed By: fkgozali

Differential Revision: D8585163

fbshipit-source-id: 3743edc30bf2183c420fd79ce1e59d68ceaa278b
2018-06-22 11:57:41 -07:00
Valentin Shergin af75d93dad Fabric: Bunch of unimplemented yet component was aliased to <View>
Summary:
@public
We need this temporary for testing until we support them all.

Reviewed By: mdvacca

Differential Revision: D8552361

fbshipit-source-id: 25f48cebcf5a665a24b92803dd7738f947ca74b2
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
David Vacca f19c36116c Clean-up parent / owner reference of children during clonning
Summary: This diff cleans up the parent / owner references for children of ReactShadowNode / YogaNode during cloning. The reason of this behavior is to avoid retaining every generation of trees during cloning. This fixes a memory leak detected when running the ProgressBarExample.android.js in catalyst app

Reviewed By: fkgozali

Differential Revision: D8019894

fbshipit-source-id: b0d38f0c836ffec534f64fa1adbd7511ecf3473d
2018-06-22 11:36:04 -07:00
Valentin Shergin 8ef539e0c2 Fabric: `fromDynamic`: Parsing vector type when source has no array
Summary:
@public
If some prop has `std::vector` type, it possible that on JS side we want to pass just one element of the array.
And in this case we sometimes drop array initialization (`[]`) part, so instead of passing `[{x:1, y:1}]` we pass `{x:1, y:1}`.
This diff adds support for that.

Reviewed By: mdvacca

Differential Revision: D8526572

fbshipit-source-id: 33d4369ac48cac3eb1c534f477d8259e76e0c547
2018-06-22 07:32:50 -07:00
Valentin Shergin b09457b4d2 Fabric: <Image> component, xplat part
Summary:
@public
This diff implements basics of cross-platform part of <Image> component.
Known issues:
- Events does not work yet.
- Some quite specific image source parameters (like custom http headers) are not supported yet.

Reviewed By: fkgozali

Differential Revision: D8526575

fbshipit-source-id: ecc97d9fda2b2e65bb1b079af057f8e176a161e5
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 0a20f47021 Fabric: Proxying `pointScaleFactor` to Yoga Config
Summary:
@public
This diff changes how we store and manage Yoga Config in layoutable shadow nodes.
Previously we have `shared_ptr` to single shared yoga config (one to many relationships); now we initiate and store yoga config with yoga node (one to one relationship).
Cons:
 - Less memory efficient.
Pros:
 - Much more flexible model. Configuration can be tweaked on a per-node basis.
 - More performant. Dealing with `shared_ptr` is expensive because of atomic ref-counter. (This is not really applicable for the previous approach but would be applicable for any alternate approach where we want to have more granular control of the configuration.) Data locality is also great in the new model which should positively impact performance.
 - Simplicity. Any alternate approach where we manage sets of nodes which share the same configuration is going to be quite complex.

Reviewed By: fkgozali

Differential Revision: D8475638

fbshipit-source-id: 5d73116718ced8e4b2d31d857bb9aac69eb69f2b
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 eff76d237b Fabric: Using proper encoding for converting user-facing strings to NSString
Summary:
@public
Trivial.

Reviewed By: fkgozali

Differential Revision: D8473507

fbshipit-source-id: 49c9e66dc6b32b0a5208aeb4c2fb68fbe1f71738
2018-06-22 07:32:49 -07:00
Kevin Gozali 20a8673b48 iOS: create EventTarget when creating EventEmitter and keep it until the emitter is deallocated.
Summary:
@public
There are some race conditions between VM objects getting deallocated and the instanceHandle held by the eventEmitter can point to deallocated memory space, causing undefined behavior like a crash.
For now, keep a strong ref to the eventTarget inside EventEmitter to avoid that scenario. This is a temporary workaround.

Reviewed By: shergin

Differential Revision: D8576785

fbshipit-source-id: 87ef36f716270ceca906b32bb86e0046ceaca19e
2018-06-21 14:35:39 -07:00
Valentin Shergin 9a59428468 Fabric: Fixed `Identity Transform` matrix literal
Summary:
@public
As Janic janicduplessis mentioned on GH the literal should be slightly different.
8df7d51600 (r29390543)

And here is prooflink: https://developer.apple.com/documentation/quartzcore/calayer/identity_transform?language=objc

Thanks Janic!

Created from Diffusion's 'Open in Editor' feature.

Reviewed By: fkgozali

Differential Revision: D8508559

fbshipit-source-id: 7427be36e041bf500bee1e06d2293f7b5ea8cf21
2018-06-18 23:02:41 -07:00
Valentin Shergin 310a2850c5 Fabric: Universal `fromDynamic` for `std::vector<...>`
Summary:
Now, if `fromDynamic` is defined for some type, `fromDynamic` for `std::vector` of this type is also will be defined.
We need this for parsing `ImageSources` (a vector of `ImageSource`) type.

Reviewed By: fkgozali

Differential Revision: D8473508

fbshipit-source-id: d8dc8e3a3273f35b76c7132c553130762f768394
2018-06-17 21:46:22 -07:00
Valentin Shergin d92601be05 Fabric: Improved parsing EdgeInsets and CornerInsets styles
Summary: In case if it's just a number, it is treated as unified insets now.

Reviewed By: mdvacca

Differential Revision: D8473510

fbshipit-source-id: 1034377bc3e4abe55778c2f182360345419f00d5
2018-06-17 21:46:22 -07:00
Valentin Shergin c1e0ea9d38 Fabric: Fixed erratum in "borderRadius" prop name
Summary: Trivial.

Reviewed By: mdvacca

Differential Revision: D8473506

fbshipit-source-id: ce2888edc1052f39a042904c02b3ac347feedbba
2018-06-17 21:46:22 -07:00
Valentin Shergin dca2067b71 Fabric: Fixed error in parsing translateX/translateY prop
Summary: Quite trivial.

Reviewed By: mdvacca

Differential Revision: D8473513

fbshipit-source-id: 5d20244cbaae5ea69c79379e9894adb05cef2eb5
2018-06-17 21:46:22 -07:00
Valentin Shergin 3b20a16703 Fabric: Fixed error in parsing `position` style
Summary: This style/prop is called `position` (not `positionType`) in RN/JS API.

Reviewed By: mdvacca

Differential Revision: D8473509

fbshipit-source-id: f381189e05e6b618f3c74f1bc4610e737981b388
2018-06-17 21:46:22 -07:00
Valentin Shergin 8df7d51600 Fabric: Transform type and <View transform/> prop
Summary: The matrix magic and parsing approach are mixins between current iOS and Android implementation.

Reviewed By: fkgozali

Differential Revision: D8344054

fbshipit-source-id: 524b48c5ab61959ce740373534d0d435eb37b647
2018-06-15 11:47:39 -07:00
Valentin Shergin da55ef1367 Fabric: Definition of the rest <View> props on C++ side
Summary:
Just definition; we don't have an implementation on the native view layer yet.
And we don't have `transform` prop yet (because it's quite complex).

Reviewed By: fkgozali

Differential Revision: D8344058

fbshipit-source-id: 3b7b41480be8295cbc90b95ebe8562e52c6f81d7
2018-06-15 11:47:39 -07:00
Valentin Shergin f65e4e0174 Fabric: Implemetation of <Switch> component
Summary:
This is pretty straightforward implementation uses native `UISwitch`.
Suddenly we need Switch to test a bunch of other things.

Reviewed By: fkgozali

Differential Revision: D8344055

fbshipit-source-id: cfc51b8bc11198eb9d4d5e4745b96fb3a7f14de1
2018-06-15 11:47:39 -07:00
Valentin Shergin e311fbb797 Fabric: CornerInsets: Graphical primitive for rect-corner-specific values
Summary: CornerInsets is something like EdgeInsets but about corners instead of edges.

Reviewed By: fkgozali

Differential Revision: D8344062

fbshipit-source-id: 9bf7a8696fba96e3124cb15e8e84093c1f4f8747
2018-06-15 11:47:39 -07:00
Kevin Gozali cb19621dfe Implementation of JS reload without crashing
Summary:
On JS reload the FabricUIManager and EventDispatcher didn't get release due to a retain cycle. This breaks the cycle.

In addition, force release the Scheduler on reload so that the stale classes get cleaned up properly, avoiding crashes. Also the surface now remounts the content correctly

Reviewed By: shergin

Differential Revision: D8414916

fbshipit-source-id: 4b14031f29b3bc9987d7aa765dc0d930a7de2b1e
2018-06-15 11:02:17 -07:00
Kevin Gozali 2ca4770011 fabric: send events via JS thread
Summary: Calling the event emitters on the main thread seems to be problematic, so let's dispatch it via the JS thread. This requires some changes to make "eventTarget" single-use because otherwise the binding would need to synchronize the actual JS call with the act of releasing the target.

Reviewed By: shergin

Differential Revision: D8375291

fbshipit-source-id: bd2b42731176ae209f4a19c232309c163fb1c01b
2018-06-15 11:02:17 -07:00
Kevin Gozali 119fd1efe7 iOS: Fixed some props conversion errors
Summary:
* numbers in JS are doubles in native land, since there's no notion of int or int64 in JS - so simply convert numbers to int instead of assuming it's int
* the parsing of Yoga props with `'...%'` string value has a bug: it should be copying the number instead of the `%`

Reviewed By: shergin

Differential Revision: D8370873

fbshipit-source-id: 44e9e3f0530c000c963e8e9ca66e8b0a48d80bcd
2018-06-11 20:01:42 -07:00
Vince Mi c3c5c3cbce Add back deprecated getParent methods for non-breaking API change (#775)
Summary:
I'm not totally sure what I'm doing so if this needs changes let me know.
Closes https://github.com/facebook/yoga/pull/775

Reviewed By: emilsjolander

Differential Revision: D8331892

Pulled By: passy

fbshipit-source-id: eb1023e666322d2472e4081fd4a4e72a7b43d049
2018-06-11 04:24:34 -07:00
Kevin Gozali f573ea8a66 iOS: fix fabric core test
Reviewed By: shergin

Differential Revision: D8344613

fbshipit-source-id: 10c604e7fbe2ff3b8c47babedea12a197c0c56b2
2018-06-09 21:52:13 -07:00
Valentin Shergin d49ebbcf62 Fabric: All *EventHandlers were renamed to *EventEmitter
Summary:
Using `EventHandlers` name was a bad idea, and I cannot tolerate it anymore.
The worst part of it is that when you have a collection of `EventHandlers` objects you cannot use plural word to describe it because `EventHandlers` is an already plural word.

And, this object is actually an event emitter, the thing on which we call events.

Reviewed By: fkgozali

Differential Revision: D8247723

fbshipit-source-id: b3303a4b9529bd6d32bb8ca0378287ebefaedda8
2018-06-09 13:16:45 -07:00
Valentin Shergin 7f1ed6848f Fabric: `convertRawProp` was extended to accept an optional default value
Summary:
During transforming raw prop (`rawProps[<prop>]`) to typed props (`MyProps.<prop>`) we can face three different cases:
 * `rawProps` collection has proper serialized value for the key. In this case, we have to set a new value of the typed prop converting value using `fromDynamic`.
 * `rawProps` collection does not have value for the key. In this case, we have to copy a value from source prop (`sourceValue`).
 * `rawProps` collection has `null` value for the key. This is the special case which means that the prop was removed from the particular component instance and we have to reset it to some *default* value (which is *not* the same as `sourceValue`). Now the default value of the `defaultValue` (sic!) argument is a default value of the type of the value (which may be different from logical default value).

We didn't handle the last case previously and this caused crashes (and unexpected behavior) because `fromDynamic` often cannot handle `null` value.

And yes, all this mean that we also have to update all `convertRawProp` call sites where logical default values are not equal to type-specific default values. This is a potential error-prone place, especially because now we have to specify logical default values in two places (in a prop declaration and in a parameterized constructor). And seems there is no way to avoid that without performance loss (because both of those places are basically constructors).

My hope is that codegen (where default values are also defined in JavaScript) will help with it eventually.

Reviewed By: fkgozali

Differential Revision: D8247652

fbshipit-source-id: 2cbe65f5f5cccd7a0d34aaa19e385aacebfe8cb1
2018-06-08 20:31:41 -07:00
Valentin Shergin d01290dd34 Fabric: Data model of Touch Events
Summary: The data model of Touch events and payload serialization. The implementation mimics W3C standard and current React Native implementation.

Reviewed By: fkgozali

Differential Revision: D8246711

fbshipit-source-id: 955b2068674f290d8bdb82da1ebfb796dd32971b
2018-06-08 20:31:40 -07:00
Valentin Shergin bb9bf26169 Fabric: Using exact UIFontWeight* constants instead of CGFloat
Summary: SUDDENLY, `-[UIFont systemFontOfSize:weight:]` returns incorrect result if `weight` is not exactly equal to any of built-in constants.

Reviewed By: fkgozali

Differential Revision: D8246712

fbshipit-source-id: 13d59cc8d66a4494437f28d791fd93fa83ebe6fb
2018-06-08 20:31:40 -07:00
Valentin Shergin 8b62e7a550 Fabric: Using Size instead of Point as textShadowOffset's type
Summary:
The current implementation of React Native uses `Size` as the underlying type of `textShadowOffset` which is clearly terribly wrong (especially because negative size values makes no sense). This mistake was borrowed from `NSShadow`, I believe.
I don't have time to fix this in every implementation of RN now, so let's use `Size` in Fabric as well.

Reviewed By: fkgozali

Differential Revision: D8246714

fbshipit-source-id: 1f0bf9b9dfa83802ef3faef2971fed5510494bfd
2018-06-08 20:31:40 -07:00
Robert Sayre 79c5b8eb97 Remove unused include. (#19548)
Summary:
`LayoutableShadowNode.cpp` includes `"LayoutableShadowNode.h"` as well as `<fabric/core/LayoutContext.h>`. In turn, `LayoutContext.h` then includes `<fabric/core/LayoutableShadowNode.h>`. `LayoutContext.h` doesn't actually require `LayoutableShadowNode.h`, but this unnecessary inclusion can cause duplicate definition errors if the two include paths don't map to exactly the same file. This patch removes the unnecessary include.

The CI's build system should cover the testing needed.

[INTERNAL] [MINOR] [fabric] - Remove an unnecessary include in fabric/core/layout.
Closes https://github.com/facebook/react-native/pull/19548

Differential Revision: D8313337

Pulled By: shergin

fbshipit-source-id: 2e01e29ff25131543d9a8601483c2e716c7437be
2018-06-07 08:36:37 -07:00
Marc Horowitz 83c990b25c make logMarker visible for consistency with logTaggedMarker
Differential Revision: D8240294

fbshipit-source-id: 8d056dc89adff41ff43c0df2f752b01ac1fb189f
2018-06-01 15:20:01 -07:00
Valentin Shergin ec265df1d2 Fabric: Removed unused type aliases
Summary: Trivial.

Reviewed By: fkgozali

Differential Revision: D8212287

fbshipit-source-id: 228951742568d28a064ee03b6314a4c01532b9c9
2018-06-01 09:37:46 -07:00
Valentin Shergin beb3fcda34 Fabric: The first version of event dispatching pipeline
Summary:
This is the first attempt to implement some base part of event dispatching pipeline from end-to-end.
Even when it is working, all this is still incomplete and generally up in the air. We are still messing proper implementation of event queue, priority, and synchronization of react reconciliation process with event scheduling.

Reviewed By: fkgozali

Differential Revision: D8212271

fbshipit-source-id: 92f9427d14726441c70ffff294ac95eeb004152a
2018-06-01 09:37:46 -07:00
Valentin Shergin 0fc5a91889 Fabric: Integrating `tag` into `EventHandlers`
Summary:
In order to dispatch event, `EventHandlers` must also know react tag. So we have to store it inside.
We plan to illuminate this requirement (and `tag` from `EventHandlers`) eventually.

Reviewed By: fkgozali

Differential Revision: D8211685

fbshipit-source-id: 2064c0f4a7869cbf4d2c92d0349f4ee3998cb8f5
2018-06-01 09:37:46 -07:00
Héctor Ramos da7873563b Migrate Android sources to MIT license header
Reviewed By: fkgozali

Differential Revision: D8065619

fbshipit-source-id: 719c303b40c96950bab8e5dde9a75f449b2956c6
2018-05-31 15:37:30 -07:00
Valentin Shergin b3b72bbdcf Fabric: Using types `EventTarget`, `EventHandler` & co. instead of `void *` everywhere
Summary:
Nothing actually changed besides type names... which actually helps me found an issue in FabricUIManager!
Now there is no a single `void *` in Fabric/C++ and JavaScript bindings. Yay!

Reviewed By: fkgozali

Differential Revision: D8191420

fbshipit-source-id: b1eb60b6bc34dd25ab200aab854ffbd7ccf5b15d
2018-05-29 15:03:57 -07:00
Dan Zimmerman 2bf47559b5 Export JSExecutor
Reviewed By: rzito

Differential Revision: D8187754

fbshipit-source-id: e0da3781e2b3e24cef04086d15e3f5394e059d30
2018-05-29 12:19:12 -07:00
Valentin Shergin 957ef606b9 Adding `Wrapper` suffix to `EventHandler` and `EventHandler` type names
Summary:
It's maybe not so important/crucial, but this thing bothers me a lot.
We use raw opaque `EventTarget`, `InstanceHandle` and `EventHandler` pointers in application layer quite a lot and we don't have any kind of type-safety here. I believe all those opaque types should be represented as named scalar types which compiler at least can differentiate at compile time.
So I propose introducing named aliases for them which will point to particular empty `struct`s. This will allow us to tag types properly in all functions and methods and ensure that we pass right values as right arguments.
Again, they are *just aliases*, which are effectively still `void *`, no any additional logic or names are involved.

Unfortunately, those nice type names are already taken by `JSIFabricUIManager` local anonymous namespace (even if they are inside anonymous namespace we cannot use them https://stackoverflow.com/questions/3673353/anonymous-namespace-ambiguity).  I think it's fair to rename them because... it's local. And we already use `Wrapper` suffix for them anyways.

Reviewed By: fkgozali

Differential Revision: D8181151

fbshipit-source-id: 9b55b43fb671a56b32a862ac54f78d528e1188ce
2018-05-29 11:41:49 -07:00
Andres Suarez d42697bcf3 Run buildifier over BUCK and TARGETS files
Reviewed By: scottrice

Differential Revision: D8163151

fbshipit-source-id: 700a77c09c6ab1bef8fd24a2a3133a4b50e3b3a3
2018-05-25 11:15:59 -07:00
Valentin Shergin 9b7f6abd87 Fabric: Support for `onLayout` event
Summary: `onLayout` event is fired when some layoutable node got inserted or updated (with changed layout) during commit phase.

Reviewed By: fkgozali

Differential Revision: D8119826

fbshipit-source-id: 831003c88fe5c4358a80328aa715be80e484b52e
2018-05-24 18:27:59 -07:00
Valentin Shergin 0be26092a5 Fabric: Wiring FabricUIManager with JS*FabricUIManager bindings
Summary: Now FabricUIManager is all you (or I) need to deliver an event.

Reviewed By: fkgozali

Differential Revision: D8086627

fbshipit-source-id: 70d783bee291f4c5d19650ac0768a5d2bd778961
2018-05-24 18:27:59 -07:00
Valentin Shergin b13add753b Fabric: Optimizing yogaNodeCloneCallbackConnector in case of correct childIndex
Summary:
YogaLayoutableShadowNode::yogaNodeCloneCallbackConnector is a hot path.
Previous implementation did not use provided `childIndex` which is correct for most cases.
See comments in code for more details.

Reviewed By: fkgozali

Differential Revision: D8070120

fbshipit-source-id: d1a6abe82688387752b66a57b13dc356abb22c96
2018-05-24 18:01:46 -07:00
Kevin Gozali 8bfe78c723 iOS: Support <ActivityIndicator> component
Summary: Setup for using <ActivityIndicator> component in Fabric.

Reviewed By: shergin

Differential Revision: D8107528

fbshipit-source-id: e3ba46d1538f5d5a2fa6f75639caaaa51156c452
2018-05-23 10:22:47 -07:00
Kevin Gozali 092103e752 iOS OSS: update podspec's to target iOS 9.0
Summary: A few more places to update to target iOS 9.0 (upgraded from 8.0)

Reviewed By: shergin

Differential Revision: D8108719

fbshipit-source-id: f17aa5e5aa34fdad57196202bf67a842735d4cdc
2018-05-23 06:16:00 -07:00
Valentin Shergin 21189be7cb Fabric: ScrollView events
Summary: Note: Some features are not suported yet, e.g. event throttling.

Reviewed By: fkgozali

Differential Revision: D8082771

fbshipit-source-id: d60f6e9011283aeee7aff77dc9178e99f06deb5c
2018-05-22 16:31:59 -07:00
Valentin Shergin 20645681d1 Fabric: Support of accessibility events for <View> component
Summary: This also illustrates how we should use EventHandlers objects.

Reviewed By: fkgozali

Differential Revision: D8053357

fbshipit-source-id: cba084c8a871e40c7536720fce290c3467d33061
2018-05-22 16:31:58 -07:00
Valentin Shergin 2a3025da97 Fabric: Application layer of events infrastructure
Summary: This implements `EventHandlers` abstract class (aka "Events Guy") which encapsulates `eventDispatcher` and `instanceHandle` (and ownership of future `eventTarget`), all of this as part of existing {ShadowNode + Props + LayoutMetrics + LocalData + Descriptor + (and now) EventHandlers} infra. (We don't plan to add anything else to this model. Ever.)

Reviewed By: fkgozali

Differential Revision: D8053351

fbshipit-source-id: 1dd9ccbcbe5a2eb284b59ea351dc8beca645e8bf
2018-05-22 16:31:58 -07:00
Valentin Shergin d94a9e2640 Fabric: Composing YGNode object inside ShadowNode to avoid memory allocation overhead
Summary:
Given that fact that life-time of YGNode and ShadowNode objects must be idential and that we always allocate ShadowNode on heap,
we can embed YGNode object right inside ShadowNode object and use pointer to it safely.
That allows us to save additional memory allocation for every single layoutable shadow node! Whoo-hoo!

Reviewed By: fkgozali

Differential Revision: D8070121

fbshipit-source-id: 6eefbca1b7ac0a8aad235513b4c4899d414835f2
2018-05-22 15:48:17 -07:00
Sebastian Markbage 91f2ffed37 Back out "[JSC] Expose new methods to Custom/System JSC"
Reviewed By: fkgozali

Differential Revision: D8003558

fbshipit-source-id: 0b90153518f849f66d7c713f99cb44c79b27ca19
2018-05-22 09:53:54 -07:00
Kevin Gozali 55724bcc62 make <Image> fallback to <View> temporarily
Summary: <Image> support isn't there, so fallback to <View> instead of crashing.

Reviewed By: shergin

Differential Revision: D8086403

fbshipit-source-id: 16d7fd8023f93cbe25f2bc0f7d0a03e32cd402ce
2018-05-22 01:31:57 -07:00
Kevin Gozali 54489b91ab Fabric: Implementation of ShimmeringView aka <Shimmer>
Reviewed By: shergin

Differential Revision: D8016962

fbshipit-source-id: 5ec598e606f8e4bbf9e5c1db082d6a0b29bed3ee
2018-05-22 01:31:57 -07:00
Valentin Shergin f180300606 Fabric: Support for object notation in dynamic-to-Point/Size/Edges converstions
Summary: Trivial.

Reviewed By: fkgozali

Differential Revision: D8086650

fbshipit-source-id: 0850c799811f7cda2dd6786aada6222dcc28a3e4
2018-05-21 20:03:59 -07:00
Sebastian Markbage 18b8dbb9bb Wire up event handler bindings
Reviewed By: shergin

Differential Revision: D8068507

fbshipit-source-id: 26326416c0b04cd52dc53af5d91010a1b27e0ec7
2018-05-21 12:21:56 -07:00
Dmitry Zakharov 7c5845a5a2 Remove Native Extensions
Reviewed By: michalgr

Differential Revision: D8057885

fbshipit-source-id: 6af7f7729201d26a704adaadb15813979cd035f8
2018-05-21 12:21:56 -07:00
Taras Tsugrii 1a7682b2a1 Re-format BUCK to use recommended style.
Reviewed By: yfeldblum

Differential Revision: D8073585

fbshipit-source-id: 12322aebc09b89d5af9cc257b16c1bc0fbb066c1
2018-05-20 23:24:51 -07:00
Valentin Shergin 06b0dabaa7 Fabric: Deletion of unused files
Summary: We don't use them anymore.

Reviewed By: fkgozali

Differential Revision: D8048545

fbshipit-source-id: c92aa9ca13ac31eaead87a0982ed613710b7af57
2018-05-18 22:00:52 -07:00
Valentin Shergin caaea38ad9 Fabric: Using unique_ptr for storing YGNode inside YogaLayoutableShadowNode
Summary:
I recently realized (Thanks David!) that we should not use `shared_ptr` for storing YGNode*
because ShadowNode does not share ownership of the Yoga node with anybody.
So the lifecycle of shadow node and yoga node must be synchronized (this is already the case but changing to unique_ptr makes this explicit and a bit more performant).

Reviewed By: fkgozali

Differential Revision: D8030417

fbshipit-source-id: c7f85ea309598d2a5ebfed55b1d182d3fe1336ae
2018-05-18 20:34:18 -07:00
Sebastian Markbage 6cc597e6e4 Alternative Instance Handle Approach without JSWeakRef
Reviewed By: fkgozali

Differential Revision: D8003736

fbshipit-source-id: 597378555cc3f9c0ae95e8927460a3c813ebfb45
2018-05-18 20:22:45 -07:00
Kevin Gozali 0afc70b24a iOS: Introduced ComponentDescriptorFactory to provide app specific component registry
Summary: Each app has its own set of components to support, so this mechanism allows each of them to customize the set. Core library only provides the signature (.h file) without any impl.

Reviewed By: shergin

Differential Revision: D8065360

fbshipit-source-id: c123397afda678e84f1d1fa41a6393f25b2c15e1
2018-05-18 19:46:32 -07:00
Valentin Shergin cc09d21e60 Fabric: Simplifying usage of `ConcreteComponentDescriptor`
Summary:
Now ConcreteComponentDescriptor can infer `ComponentName` from `ShadowNodeT` automatically,
so in the most cases we even don't need to create a subclass of that.

Reviewed By: fkgozali

Differential Revision: D8016965

fbshipit-source-id: d910597093c9f4c9f32ca06cb3ef1b12538b9543
2018-05-17 20:28:50 -07:00
Valentin Shergin 8f507280ac Fabric: Removing default arguments from ShadowNode's constructors
Summary: We don't use them at all; moreover they complicate adding/changing signatures of those methods (because arguments with defaults must be grouped at the end and some arguments cannot have defaults).

Reviewed By: fkgozali

Differential Revision: D7981456

fbshipit-source-id: d7dd098e83630d1ab3342d2ca52ade9c4e27b2c3
2018-05-17 20:28:50 -07:00
Valentin Shergin 15cb6540c1 Fabric: ScrollView, the native part
Summary: Note: not all scrollview props and features (especially event listeners and imperative calls) are supported yet.

Reviewed By: fkgozali

Differential Revision: D7961868

fbshipit-source-id: 5277674fe976e089fd963066f78e705ad846d78d
2018-05-17 20:28:50 -07:00
Valentin Shergin bd99d3a6f4 Fabric: ScrollView: xplat part (shadow node, props, localdata, descriptor)
Summary:
All the props of a scrollview, and local data.
LocalData part is probably the most interesting: with it we precompute content size which we use inside native scrollview. Previously we rely on some assumptions like "ScrollView must have only one subview" instead, and that was not so efficient and straight-forward.

Reviewed By: fkgozali

Differential Revision: D7961869

fbshipit-source-id: fa070b8423a3e7739aeb62220e51213683e1a223
2018-05-17 20:28:50 -07:00
Valentin Shergin e3a3999b75 Fabric: ScrollView: primitives and buck target
Summary: Trivial.

Reviewed By: fkgozali

Differential Revision: D7961870

fbshipit-source-id: 3cfd92bd441dbf516ade777e6428924e9634257a
2018-05-17 20:28:50 -07:00
Kevin Gozali 128c9343c4 iOS: fix up RNTesterPods
Summary:
A few fixes:
* missing include: folly/Optional.h
* switch folly::Optional's `has_value()` to `hasValue()` for now until folly is upgraded to newer version
* fix up import for RCTTextAttributes.h
* fix up includes for "conversions.h" to use namespaced includes

Reviewed By: mmmulani

Differential Revision: D8021149

fbshipit-source-id: d3955986d3ab6b1d9b61ac1e385767893ce57e5e
2018-05-16 14:14:41 -07:00
Valentin Shergin 48dccf18b8 Fabric: Making logging in FabricUIManager optional
Summary: Trivial.

Reviewed By: fkgozali

Differential Revision: D7961186

fbshipit-source-id: 703fa3b336e093c430d32ab08eafc42b1f590f32
2018-05-15 23:58:59 -07:00
Valentin Shergin 30d08ea8a4 Fabric: `EdgeInsets` from `dynamic` conversion
Summary: We will need this for several components, first of all for ScrollView.

Reviewed By: fkgozali

Differential Revision: D7958246

fbshipit-source-id: 364b939abe8f0734376448149bbdc735abd00189
2018-05-15 23:58:59 -07:00
Valentin Shergin 545f087b46 Fabric: Several helper functions for `react::Rect`
Summary: Trivial. We will need them soon at least for ScrollView.

Reviewed By: fkgozali

Differential Revision: D7958244

fbshipit-source-id: ce92c6e6181181ac17d817292af18ffa46a4d975
2018-05-15 23:58:59 -07:00
Valentin Shergin 57d69772b7 Fabric: Improved signature of `calculateMutationInstructions`
Summary: Apparently, `calculateMutationInstructions` must also produce mutation instructions for root node as well. To make it possible we have to change the signature of the function and weak some restrictions in TreeMutationInstruction.

Reviewed By: fkgozali

Differential Revision: D7958248

fbshipit-source-id: 4109a6bce3a77f7eb89157201fd0e80f98487dbd
2018-05-15 23:58:59 -07:00
Valentin Shergin 10c5368c37 Fabric: Fixed issue where root shadow node does not layout itself
Summary: Conceptually, it always must be node owner's responsibility, but for the root node, we have to make an exception because there is no another parent node and there is no another component which has access to YogaNode.

Reviewed By: fkgozali

Differential Revision: D7958251

fbshipit-source-id: 0bdaea87adbd323c758bc3c28f325be615aa90f3
2018-05-15 23:58:59 -07:00
Kevin Gozali 4a0243fcd3 iOS: whitelist a few components for testing purpose
Reviewed By: mmmulani

Differential Revision: D7999459

fbshipit-source-id: e56946931997cb51ee66020a97c60f3c85d1d348
2018-05-15 09:28:41 -07:00
Kevin Gozali 42fc87eb8d remove unnecessary ExceptionManager abstraction
Reviewed By: sebmarkbage

Differential Revision: D8002124

fbshipit-source-id: 4e0bce9686549d0dd7b59b1323efd11ea168855b
2018-05-14 20:45:21 -07:00
Sebastian Markbage 4ef099679d Expose new methods to Custom/System JSC
Reviewed By: fkgozali

Differential Revision: D7998298

fbshipit-source-id: f20d5b961db1cc31880d383a67d8bba40dd8008f
2018-05-14 18:58:05 -07:00
Valentin Shergin 858f7f8331 Fabric: Improved printing of Yoga's `Edges` data structure
Summary:
Yoga represents concepts like `margin`, `padding` and `position` as `edges` (aka std::array<YGValue, YGEdgeCount>).
This diff improves conversion of this data structure to string (primarily for debugging purposes).

Reviewed By: fkgozali

Differential Revision: D7958241

fbshipit-source-id: 6931c7b5d2395c28821c8daef62f609b13f112c6
2018-05-14 16:03:49 -07:00
Valentin Shergin 1f9676a1cb Fabric: Final cleanup of define-based props treatment
Summary: Oh, my! No more `#define`s related to props conversions and debug-printing.

Reviewed By: fkgozali

Differential Revision: D7958250

fbshipit-source-id: 86950070c55f134aa3a575b9fd68fc90d865cf44
2018-05-14 16:03:49 -07:00
Valentin Shergin 120dcec621 Fabric: New props treatment in `core` module
Summary:
Same as previous one.
Adopting template-generated `convertRawProp` and `debugStringConvertibleItem` functions in `core` module.
Note, to do so we have to change signatures of some conversions functions to make them more overloading-friendly.

Reviewed By: fkgozali

Differential Revision: D7958243

fbshipit-source-id: 500ee420d9aa562ee3c5810ef625e06541eda8fb
2018-05-14 16:03:49 -07:00
Valentin Shergin c19649cc16 Fabric: New props treatment in `view` module
Summary:
Same as previous one.
Adopting template-generated `convertRawProp` and `debugStringConvertibleItem` functions in `view` module.
Note, to do so we have to change signatures of some conversions functions to make them more overloading-friendly.

Reviewed By: fkgozali

Differential Revision: D7958242

fbshipit-source-id: 10199d1fbb43329de93604aa383c884f5cc64dc5
2018-05-14 16:03:49 -07:00
Valentin Shergin 9f85873c9f Fabric: New props treatment in `graphics` module
Summary:
Same as previous one.
Adopting template-generated `convertRawProp` and `debugStringConvertibleItem` functions in `graphics` module.
Note, to do so we have to change signatures of some conversions functions to make them more overloading-friendly.

Reviewed By: fkgozali

Differential Revision: D7958252

fbshipit-source-id: 0f33a2e6aad60befacee31486acdb9b6114d3e07
2018-05-14 16:03:49 -07:00
Valentin Shergin 9d21e6661a Fabric: New props treatment in `attributedstring` module
Summary:
Adopting template-generated `convertRawProp` and `debugStringConvertibleItem` functions in `attributedstring` module.
Note, to do so we have to change signatures of some conversions functions to make them more overloading-friendly.

Reviewed By: fkgozali

Differential Revision: D7958245

fbshipit-source-id: 275a58bd3955a6ceb4881bffff86bf1d4501b3d2
2018-05-14 16:03:49 -07:00
Valentin Shergin 7048c9134a Fabric: Support for optionals in `convertRawProp` and `debugStringConvertibleItem` templates
Summary:
We have to have automatic treatment for `optional` types. So, if we can process type `T` we can also automatically process `optional<T>.`
Support for optional allows us to not introduce new types (with embedded special "undefined" value) or pollute existing pure types (with special "undefined" value). (A lot of examples of those types can be found in AttributedString module.)

Reviewed By: fkgozali

Differential Revision: D7958249

fbshipit-source-id: 21af526a17dd0329e1262020cab8ecb902316654
2018-05-14 16:03:49 -07:00
Valentin Shergin 03fb77cc95 Fabric: Using templates to generate convertRawProp and debugStringConvertibleItem functions
Summary:
This diff opens a diffstack where we migrate the generation of all prop conversions (convertRawProp) and pretty-printing (debugStringConvertibleItem) functions to C++ templates (instead of using `#define`s).
So, this diff implements base versions of those functions as templated functions.
For now we still need #define-based version, but eventually, we will get rid of it.

Reviewed By: fkgozali

Differential Revision: D7958247

fbshipit-source-id: 24346297c1bd17e8054758f0eb84698eebfa21e2
2018-05-14 16:03:49 -07:00
Valentin Shergin 2b827c9f13 Fabric: Modernizing debug printing in View module
Summary: This is continue of the work started in D7797561.

Reviewed By: fkgozali

Differential Revision: D7901244

fbshipit-source-id: 2f7a5cd9fa8c0079787e26e19c7c6c4255e54b42
2018-05-14 16:03:49 -07:00
Valentin Shergin f3f378ad3d Fabric: Using modern props-conversion appraoch for YogaStylableProps
Summary:
This a natiral continue of previous/ongoing work towards modernizing props pipeline.
Less defines, less code, more obvious code.

Reviewed By: fkgozali

Differential Revision: D7901246

fbshipit-source-id: 3387b6d13e21e6ec48a38c9e3708762dfe536105
2018-05-14 16:03:49 -07:00
Valentin Shergin dd3a6eda70 Fabric: Devirtualizing of props parsing infra
Summary:
This diff contains several tight to each other changes (which can/should not be split into several diffs):
 * The props parsing/conversion process was de-virtualized: we don't use virtual `apply` method to parse props anymore. Instead, we use old-fashioned constructors.
 * All fields of Props classes which represent props values were marked as `const` which make impossible to modify them after the objects were created (even if we have non-const value-of/pointer-to the whole Props object). Those fields are also `public` now.
 * All custom handwritten getters were removed (because we don't need them anymore).

So, now we don't need all those custom getters which makes code much more compact, performant and codegen-friendly.

Reviewed By: fkgozali

Differential Revision: D7901245

fbshipit-source-id: 9f4b1fd2da64bf963b63215ed3bd74b9d3c58dd5
2018-05-14 16:03:49 -07:00
Valentin Shergin 582e1bded3 Fabric: Text types conversions & better debug printing
Summary: Trivial.

Reviewed By: fkgozali

Differential Revision: D7863489

fbshipit-source-id: c7b9852e104ca12eea144473ed8e1f2973a36df7
2018-05-14 16:03:48 -07:00
Kevin Gozali 266016c521 iOS: Mark Scheduler class as final
Summary:
This fixes some build flavor:

```
error: destructor called on non-final 'facebook::react::Scheduler' that has virtual functions but non-virtual destructor [-Werror,-Wdelete-non-virtual-dtor]
```

Reviewed By: shergin

Differential Revision: D7958022

fbshipit-source-id: 6ff64bdaa221b5c6430a98244d40d6d3789ba937
2018-05-10 15:17:53 -07:00
Marc Horowitz 9d0b7d8f31 Fix BUCK bugs which were breaking tests after refactoring
Reviewed By: johnislarry

Differential Revision: D7874275

fbshipit-source-id: 7f9c8648571bc7f41649ec4ef547e7c34b479221
2018-05-09 22:12:03 -07:00
Marc Horowitz a363a7b501 Refactor ReactMarker out of Platform
Reviewed By: fromcelticpark

Differential Revision: D7803908

fbshipit-source-id: 957e80519c209732b163ece2bccb7c8c36ff8107
2018-05-09 22:12:03 -07:00
Marc Horowitz 042449f24a simplify handleMemoryPressure conditionalization, delete some dead code
Reviewed By: javache

Differential Revision: D7803912

fbshipit-source-id: 0bab4be07fc006a208caa75f94b5716c99b5d265
2018-05-09 22:12:03 -07:00
Marc Horowitz 09f3d7ab49 reformat JSCExecutor.cpp
Reviewed By: fromcelticpark

Differential Revision: D7803913

fbshipit-source-id: fc4637d0f9ab8c01f2f257e34e435c9573ecf948
2018-05-09 22:12:03 -07:00
Marc Horowitz ef258b0106 Remove unnecessary #includes to reduce dependencies
Reviewed By: davidaurelio

Differential Revision: D7803909

fbshipit-source-id: 2ccafdbfcb786c4c5f703714fb0c92cda1026cef
2018-05-09 22:12:02 -07:00
Valentin Shergin e052685ffc Fabric: Resonable default values for LayoutConstraints members
Summary: Trivial.

Reviewed By: mdvacca

Differential Revision: D7857046

fbshipit-source-id: 88400f1831bf66ccd3d880ddf1de3df27287b5be
2018-05-08 23:03:36 -07:00
Valentin Shergin a879842033 Fabric: Introducing `ShadowTree`
Summary: ShadowTree is an abstraction around (commited) root shadow node and managing its lifecycle.

Reviewed By: mdvacca

Differential Revision: D7857049

fbshipit-source-id: 8d530e0366fc703e4aef4ec88dd8ea990dafaaf1
2018-05-08 23:03:36 -07:00
Valentin Shergin 2bb41031ba Fabric: Introducing `RootShadowNode`
Summary: `RootShadowNode` is a dedicated class for managing the root node.

Reviewed By: mdvacca

Differential Revision: D7857050

fbshipit-source-id: f15f4b177f03cea4c0fd5a60d761ee2745319d77
2018-05-08 23:03:36 -07:00
Valentin Shergin cb48fa4d49 Fabric: `LayoutContext::affectedShadowNodes` was removed
Summary:
Apparently, we don't need this functionality in Fabric because we compute mutation instactions during diffing anyways.
But we still need (will need) `LayoutContext` for sure.

Reviewed By: mdvacca

Differential Revision: D7857045

fbshipit-source-id: 4be2744d9abea473ead847f35f698104f94af33d
2018-05-08 23:03:35 -07:00
Valentin Shergin e028631513 Fabric: Implementation of `yogaStyleValueFromFloat`
Summary: Quite obvious.

Reviewed By: mdvacca

Differential Revision: D7857047

fbshipit-source-id: 876664b3ab5c19b7c66a38579664f18a38a1a371
2018-05-08 23:03:35 -07:00
Valentin Shergin 6e537b000b Fabric: New nice way to deal with DebugStringConvertible items
Summary:
No macros in product code.
(Not all callsites are converted yet.)

Reviewed By: mdvacca

Differential Revision: D7797561

fbshipit-source-id: da899421bf99669a0e0a2b83df6004daf14355c2
2018-05-08 23:03:35 -07:00
Valentin Shergin d9ff1769aa Fabric/Text: <Paragraph> is now supporting text attributes
Summary:
I was shamed by Sebastian's sebmarkbage concerns (totally unrelated to this topic) about introducing another level of indirection into the system and decided to change my original plan not to support text attributes for the <Paragraph> component.

So, now <Paragraph> shares <View>, <Text> and <Paragraph> itself capabilities. That reduces the minimum amount of required components for trivial text fragment from three (Paragraph, Text, RawText) to two (Paragraph and RawText).

Special thanks for C++ for supporting multiple inheritance.

Reviewed By: mdvacca

Differential Revision: D7785889

fbshipit-source-id: dd9f2e2650bfbfd76d7d4b538adaf409f9429df3
2018-05-08 19:24:10 -07:00
Valentin Shergin f3893aab3b Fabric/Text: Connecting the dots
Summary: This change registers the Text module.

Reviewed By: mdvacca

Differential Revision: D7784509

fbshipit-source-id: 0de3e432b8f975927547ba990586f99655e8322d
2018-05-08 19:24:10 -07:00
Valentin Shergin 81bdd36204 Fabric/Text: RCTParagraphComponentView
Summary: RCTParagraphComponentView is a UIView which can render text using TextLayoutManager.

Reviewed By: mdvacca

Differential Revision: D7751853

fbshipit-source-id: e6ee9a0f989cdf6e878390d37dbcf8a11ef90bf4
2018-05-08 19:24:10 -07:00
Valentin Shergin b5a780608e Fabric/Text: text module, paragraph part
Summary: <Paragraph> component represents <View>-like component containing and displaying text.

Reviewed By: mdvacca

Differential Revision: D7751854

fbshipit-source-id: 1acdfebf6f96a5da068ce985e15288e958266855
2018-05-07 22:08:54 -07:00
Valentin Shergin dc7a87e737 Fabric/Text: text module, text part
Summary: <Text> component is used to describe text attributes in React.

Reviewed By: mdvacca

Differential Revision: D7751851

fbshipit-source-id: f90a4367cad64283ee64828b0d5e24470ee3d9f7
2018-05-07 22:08:53 -07:00
Valentin Shergin 02c3cd4c4e Fabric/Text: text module, rawtext part
Summary: <RawText> component represents a purely regular string object in React.

Reviewed By: mdvacca

Differential Revision: D7751850

fbshipit-source-id: 54afe43e0c1ac063862f109ea07f0e7de3593573
2018-05-07 22:08:53 -07:00
Valentin Shergin 05890a5942 Fabric/Text: textlayoutmanager
Summary:
TextLayoutManager measures and renders text using iOS specific APIs (CoreText & TextKit).
By desing, only this module should contain platfrom-specific text functionality.

Reviewed By: mdvacca

Differential Revision: D7751852

fbshipit-source-id: fd6e1907df617fe5a4479ea08f207946765b3a45
2018-05-07 19:05:53 -07:00