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

58 Коммитов

Автор SHA1 Сообщение Дата
Joshua Gross d269844cc1 LayoutAnimations: have each Props struct do its own interpolation
Summary:
Each ComponentDescriptor becomes capable of doing its own interpolation over props for animation purposes.

This new custom interpolator is called by default by the ConcreteComponentDescriptor, but `ComponentDescriptor::interpolateProps` is a virtual function and each ComponentDescriptor can provide custom interpolation if necessary.

For now, only View does any actual interpolation, to support LayoutAnimations.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D20965310

fbshipit-source-id: e1c1588107848e94c155efecb0da1cc1619ae544
2020-05-13 15:40:34 -07:00
Valentin Shergin 3246eaec44 Fabric: `ConcreteShadowNode::initialStateData()` now accepts a `ShadowNodeFamilyFragment` instead of just a `SurfaceId`
Summary:
We need it to be able pass an `EventEmitter` object to constructed concrete State objects.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D21169581

fbshipit-source-id: 3eef0310de7e2f061108aa85c1a39678a43fe85e
2020-04-22 15:41:55 -07:00
Valentin Shergin 7cc791b978 Fabric: `ComponentDescriptor::cloneProps()` now never returns the base props objects
Summary:
The diff changes how the `empty raw props` optimization works in `ComponentDescriptor::cloneProps()`. Now it only fires only when the base `props` object is null, which is practically all production cases we have (and care about). (I tried, in a normal run there were no cases where the empty raw props were passed with non-null props.) From the other side, the old behavior that may return the same props objects previously several times created bugs and practically unexpected results and practically disallowed to clone props objects easily.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D21110608

fbshipit-source-id: 884807cd8e9c5c3e6cc1c9e4c1f0227259cc21fb
2020-04-20 00:19:56 -07:00
Valentin Shergin 100bf9076a Fabric: Changing signature of `ComponentDescriptor::createState`
Summary:
This is pure syntactic change. Often we don't have a shared pointer to ShadowNodeFamily and only have just a reference. At the same time, `ComponentDescriptor::createState` does not have to accept a shared pointer. So, it's better to accept just a reference.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D20578787

fbshipit-source-id: 905277001e096d41e75007575b59ea2ea15fbf4b
2020-03-23 13:33:21 -07:00
generatedunixname89002005287564 6aa7030ce8 Daily `arc lint --take CLANGFORMAT`
Reviewed By: zertosh

Differential Revision: D20245569

fbshipit-source-id: 2fede4cfd7e0291aa6718d510bfe14ee175134df
2020-03-04 06:08:57 -08:00
Samuel Susla f936b65883 Creating new state should now correctly increment state revision
Summary:
Changelog: [Internal]

# Problem

Calling `UIManager::updateState` does not increment state revision because it calls `ConcreteComponentDescriptor::createState` which creates new state with state revision 1.

# How did this propagate?

This error propagated itself in TextInput when trying to input a value, you would be only allowed to type in 1 character.

Reviewed By: JoshuaGross

Differential Revision: D20072844

fbshipit-source-id: 37b8173307e1d91d6e9c41b5ff2e185dde31cc38
2020-02-26 03:32:19 -08:00
Valentin Shergin 085c6d2675 Fabric: Storing data as a shared pointer inside State object
Summary:
Before this change, the concrete component-specific data/payload object associated with a State was stored inside a templated subclass as a normal instance variable; after the change, it's stored as a shared pointer inside the base class. The original motivation was that storing that inside subclass saves us one shared pointer and one heap allocation.

This approach overcomplicated a lot of things and all possible savings are probably compensated with additional complexity (we have to have templated state-update lamdas in subclasses and so on). And to update the data in the previous approach we need to create a shared pointer to data anyway.

This change will allow future improvements in the coming diff.

 Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D19799014

fbshipit-source-id: 287ed939353ba58d9e434d1502ecfbb208c6daa5
2020-02-09 22:28:39 -08:00
Samuel Susla 595e954b13 Use ShadowNodeFamily in state updates
Summary:
Changelog: [internal]

`ShadowNodeFamily` can be used as target in state updates instead of `ShadowNode`.

Reviewed By: shergin

Differential Revision: D19517428

fbshipit-source-id: 6831357e749239d5afec1dfd2d44a26ca6553e51
2020-02-03 06:25:26 -08:00
Samuel Susla 1041ad5651 Delete StateCoordinator
Summary:
StateCoordinator isn't used anymore.

Changelog: [internal]

Reviewed By: shergin

Differential Revision: D19500103

fbshipit-source-id: 6beb94b03ed04d17d58a8939626458c76eaa7e7e
2020-02-03 06:25:25 -08:00
Samuel Susla d418750359 Merge StateCoordinator into ShadowNodeFamily
Summary:
Changelog: [internal]

Merges all of responsibilities of `StateCoordinator` into `ShadowNodeFamily`.

Reviewed By: shergin

Differential Revision: D19500104

fbshipit-source-id: f31ffded5a840e722fd898eef6a9f52cd2186df7
2020-02-03 06:25:25 -08:00
David Vacca 4bfe8937b6 Replace usage of SharedShadowNode for ShadowNode::Shared
Summary:
ShadowNode::Shared and SharedShadowNode represent the exact same type. Nowadays we use ShadowNode::Shared instead of SharedShadowNode.
This diff replaces usages of SharedShadowNode for ShadowNode::Shared in the fabric folder.

Changelog: [internal]

Reviewed By: shergin

Differential Revision: D19217717

fbshipit-source-id: 112331b22251aa3a3d5e183395c54f2ca0f56e47
2020-01-29 21:06:55 -08:00
Samuel Susla 142c66f341 Create ShadowNodeFamily inside ComponentDescriptor
Summary:
Changelog: [internal]

1. Creates `ShadowNodeFamily` inside `ComponentDescriptor`.
2. As a side effect of this, we no longer need `ComponentDescriptor::createEventEmitter` so it is removed.

This is a step in order to merge `StateCoordinator` into `ShadowNodeFamily` and use it as target for state updates.

Reviewed By: shergin

Differential Revision: D19514906

fbshipit-source-id: 04ad3c621886be56925acd76f9b35a09d8c5e15a
2020-01-28 09:32:53 -08:00
Samuel Susla 7f79b46bad Initialise ShadowNodeFamily before ShadowNode is created
Summary:
Changelog: [internal]

1. Use `ShadowNode::Shared` instead of `SharedShadowNode`.
2. Initialise `ShadowNodeFamily` before `ShadowNode`.

Why?
This is a step in order to merge `StateCoordinator` into `ShadowNodeFamily` and use it as target for state updates.

Reviewed By: shergin

Differential Revision: D19471399

fbshipit-source-id: 2f67901c901349d238c711f9eeaadb19fe7c1110
2020-01-28 09:32:53 -08:00
Samuel Susla 01805636b9 Move ShadowNode::getAncestors to ShadowNodeFamily
Summary:
Changelog: [internal]

1. Moves `ShadowNode::getAncestors` to `ShadowNodeFamily`.
2. Exposes shadowNode's family through `ShadowNode::getFamily()`.

# Why?
This is a first step in order to merge `StateCoordinator` into `ShadowNodeFamily` and use it as target for state updates.

Reviewed By: shergin

Differential Revision: D19465188

fbshipit-source-id: b5a3625aa21c040301259de02beedbf97e11f20e
2020-01-28 09:32:52 -08:00
Valentin Shergin a09ab53692 Fabric: Use ComponentDescriptorParameters as an actual parameter of ComponentDescriptor constructor
Summary:
This diff changes the signature of ComponentDescriptor constructor to make it simpler and easier to support: now all arguments are passed via struct that contains all these arguments as fields.

Now the ComponentDescriptor constructor accepts three arguments one of which is optional. This causes some confusion and the possibility of bugs in all subclasses that needs to implement a custom constructor. Mostly because in every case we need to ensure that the constructor:
 * Accepts and pass down all parameters/arguments;
 * Accepts the right types of those parameters (shared vs weak pointers, references vs values).
 * Accepts all thee arguments and pass them (including flavor!). We failed this point several times.

Overal that makes the code simpler and allows changing the set of parameters relatively easy. (There is no plan for it!)
Look at the LOC balance: less code!

Changelog: [INTERNAL]

Reviewed By: sammy-SC

Differential Revision: D18548173

fbshipit-source-id: 5d038b135e004f6c054026b3235ed57db99c086d
2019-12-22 22:22:00 -08:00
Samuel Susla 61f7639d38 Fabric: Remove eventEmitter from ShadowNodeFragment
Summary:
As part of the plan is splitting ShadowNodeFragment into two parts. ShadowNodeFamilyFragment is already in place. This diff removes use of `ShadowNodeFragment::eventEmitter` and goes over all call sites to change it to `ShadowNodeFamilyFragment::surfaceId`.
Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D19146697

fbshipit-source-id: 22cae5404b0f3098feb86c0437a4aa256d5b773e
2019-12-19 13:48:22 -08:00
Samuel Susla 97f1c053b3 Fabric: Remove surfaceId from ShadowNodeFragment
Summary:
As part of the plan is splitting `ShadowNodeFragment` into two parts. `ShadowNodeFamilyFragment` is already in place. This diff removes use of `ShadowNodeFragment::surfaceId` and goes over all call sites to change it to `ShadowNodeFamilyFragment::surfaceId`.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D19115785

fbshipit-source-id: 5972332c3360b88ca935581ed36070f26e678b22
2019-12-19 13:48:22 -08:00
Samuel Susla f9c5bf8bee Fabric: Remove tag from ShadowNodeFragment
Summary:
As part of the plan is splitting `ShadowNodeFragment` into two parts. `ShadowNodeFamilyFragment` is already in place. This diff removes use of `ShadowNodeFragment::tag` and goes over all call sites to change it to `ShadowNodeFamilyFragment::tag`.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D19115781

fbshipit-source-id: 6ab3464a063c220d0924bf5a69b75449ca178650
2019-12-19 13:48:22 -08:00
Samuel Susla 90874d974f Fabric: ShadowNode now takes family as its constructor parameter
Summary: Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D19115780

fbshipit-source-id: 7a693b5eea7599dca3e4b737126fcbb26078894d
2019-12-19 13:48:21 -08:00
Valentin Shergin 059142935a Fabric: Introducing ShadowNodeTraits
Summary:
Quite often in the Fabric codebase, we need to iterate on a list of shadow nodes and perform some work depending on the exact type (or kind) of shadow node we have. Today, we exclusively use RTTI to test for exact type. The problem here is that RTTI is not only expensive in terms of code size (we are moving towards removing RTTI), it's expensive in terms of CPU cycles. (Don't mistake RTTI/dynamic_cast overhead with dynamic dispatch overhead!)

`dynamic_cast` has it's own advantages, of cource: it's simple and straight-forward and does not require additional configuration. On the other side, it requires knowledge about exact class relationship configuration and knowing the exact name of the class.

ShadowNodeTraits is the generalized solution for storing predefined traits right inside ShadowNode object and check/set/unset them efficiently and in a particular-class-independent manner.

This diff only implements it in general and switching storing an internal flag of ShadowNode inside the trait collection to save some space (and for illustration purposes as well).

In the coming diff, we will see how this approach allows tackling the real, non-trivial problem.

In addition to the concept, this diff implements some convenience infra, such as `ConcreteShadowNode::BaseTraits()` static method that allows designating intrinsic-to-a-class traits declaratively.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18525348

fbshipit-source-id: 083bb85e0a9dc9d6c69bf395bd338d3c18def688
2019-11-15 19:51:21 -08:00
Valentin Shergin dbc7e4e527 Fabric: More type asserts in ConcreteComponentDescriptor
Summary:
`ConcreteComponentDescriptor` is a major place where dynamic dispatch calls end up. We see some amount of crashes that can be caused by an invalid pointer to a ComponentDescriptor, those checks can help verify this theory. Anyway, it's a good practice to fail earlier.

Changelog: [Internal] - Stability improvements (Fabric)

Reviewed By: sammy-SC

Differential Revision: D17991515

fbshipit-source-id: 1cac372a12b49430a3d1db66c8fc673e6adc32e9
2019-10-18 09:27:48 -07:00
Andres Suarez 3b31e69e28 Tidy up license headers [2/n]
Summary: Changelog: [General] [Fixed] - License header cleanup

Reviewed By: yungsters

Differential Revision: D17952694

fbshipit-source-id: 17c87de7ebb271fa2ac8d00af72a4d1addef8bd0
2019-10-16 10:06:34 -07:00
Valentin Shergin c5cc27f1e9 Fabric: Introducing ComponentDescriptor::Flavor
Summary:
Currently, the same ComponentDescriptor class cannot be registered as a responder for components with different names. However, we have marginal cases where we really need it. The examples are `UnimplementedView` or possible universal interop with the classic RN or any other UI framework.

This change adds a special optional argument to ComponentDescript constructor that allows implementing this functionality.

Reviewed By: fkgozali

Differential Revision: D17211915

fbshipit-source-id: 18f59e09fe06b875a8e8975b7b2ab423489238bb
2019-09-29 20:06:37 -07:00
Valentin Shergin 6a10feacda Fabric: Passing EventDispatcher as a weak pointer everywhere
Summary: Storing a strong shared pointer to `ComponentDescriptor` can cause a memory leak. Therefore we enforce all call sides and params to be weak pointers. The only Scheduler preserves a retaining pointer to it (to prevent preliminary deallocation).

Reviewed By: sammy-SC

Differential Revision: D17115540

fbshipit-source-id: fdea7d19f742ff04d5ba5470dd9748a5b226aa7c
2019-08-30 18:24:26 -07:00
Valentin Shergin 874f656435 Fabric: Rethinking of prop parsing infra
Summary:
This diff reimplements the prop parsing infrastructure in a part where it interacts with RawProps value.

Local synthetic tests show that the new way is 3x faster but the actual production result is quite unpredictable. MobileLab tests show some improvements about 10-20 ms on iPhone 6.

In short, the new way is faster because it inverts the lookup order and heavily relies on actual data types (and their properties) that we use. The old approach required about 130 hash-map lookups (where the key is `std::string`) to parse a single *Props object.
The new approach prepares concrete-props-specific tables with indexes of coming values ahead of time,  iterates over raw data and puts it into those tables, and then performs a lookup in a very efficient manner.

Reviewed By: JoshuaGross

Differential Revision: D15752968

fbshipit-source-id: 847106e652eb7fc7ef7b99884a6f819ea3b9fd06
2019-06-12 21:35:21 -07:00
Valentin Shergin 69e8816bbe Fabric: Prop parsing tweek: `RawProps::isEmpty()`
Summary: This is a small perf tweak that alone does not give much improvement but the coming diffs will rely on the possibility to construct empty RawProps object.

Reviewed By: mdvacca

Differential Revision: D15511494

fbshipit-source-id: 39dec9336e6b5cf6ad33b1f3a06ca1c096ece628
2019-06-12 21:35:20 -07:00
Valentin Shergin 6d9f0a7d2a Fabric: Using full `ShadowNodeFragment` (not just `Props`) during construction of initial state
Summary: It turns out that just only props is not enought to build an initial state value in some cases for some component. Seems we need at least `surfaceId` and `eventEmitter` in some cases (which seems totally reasonable). So, seems using the whole `ShadowNodeFragment` for that purpose is a good choise.

Reviewed By: mdvacca

Differential Revision: D15039135

fbshipit-source-id: d9a5f47f971ccf6cdb2f888bd31f7948b37b67ef
2019-04-29 21:21:11 -07:00
Joshua Gross c31602acdc `getContextContainer` should be marked as const
Summary: `getContextContainer` should be marked as const so that const instances can call it.

Reviewed By: shergin

Differential Revision: D14969981

fbshipit-source-id: 8812f24ecf0642a38496580689943fbd43cddad1
2019-04-19 02:27:50 -07:00
Valentin Shergin 832164169d Fabric: Unification of registration process of `ComponentView`s and `ComponentDescriptor`s
Summary:
Registries, providers, providers of registries, registres of providers. All that can be really confusing, but that represents best the constraints and desires that we have:
* We need to be able to register components on-the-fly (so we need a mechanism that will propagate changes);
* We don't want to register ComponentDescriptors separately from ComponentView classes;
* C++ not always gives us abstractions that we want (e.g. pointers to constructors).

After the change, we can remove the whole Buck target that has a bunch of handwritten boilerplate code.

There is a still room for polish and removing some concepts, types or classes but this diff is already huge.

Reviewed By: JoshuaGross

Differential Revision: D14983906

fbshipit-source-id: ce536ebea0c905059c7a4d644dc25233e2809761
2019-04-17 22:44:20 -07:00
Valentin Shergin 00eab3d6fb Fabric: Introducing ComponentDescriptorProvider
Summary:
ComponentDescriptorProvider represents unified way to create a particular descriptor.
Now all ComponentViews (which support RCTComponentViewProtocol) expose a `ComponentDescriptorProvider` which will allow creating and registering ComponentDescriptor instances for all visual components automatically as a part of ComponentView registration process.
Don't panic, everything is still being as explicit as it always was, no magic involved; we just will have only one registration step instead of two parallel.

That also opens a way to register components on the fly.

Reviewed By: JoshuaGross

Differential Revision: D14963488

fbshipit-source-id: 9e9d9166fabaf7b30b35b8647faa6e3a19cd2435
2019-04-17 22:44:20 -07:00
Valentin Shergin 1f5af2a6f1 Fabric: ComponentDescriptor now contains ContextContainer and EventDispatcher refs
Summary:
Turns out that storing and using ContextContainer in custom subclasses is a huge pain. At the same time seems that a lot of custom components need some DI instrument, so we need this instrument anyway.

Moving stuff from the template to the base class should also help with codesize a bit.

Reviewed By: JoshuaGross

Differential Revision: D14921356

fbshipit-source-id: 4dbb961fe32bd66c73513d7e053bbed229860a31
2019-04-16 07:35:07 -07:00
Valentin Shergin 90e49d759c Fabric: Using a ref to ComponentDescriptor instead of clone function inside ShadowNode
Summary: That should reduce the size of `ShadowNode`, make an instantiation of shadowNode a bit faster, and make `clone` operation a bit faster because simple dynamic dispatch is faster than std::function invocation. It also should help a bit with code size.

Reviewed By: mdvacca

Differential Revision: D14249200

fbshipit-source-id: c1332b139d27becebf15cd894475507b5fd0eb9f
2019-03-03 13:50:35 -08:00
Valentin Shergin 802534e611 Fabric: Introducting State, an escape path from unidirectional data flow
Summary:
In React Native there are several use cases where React State is not the only input that affects the component tree. E.g., in case of a <Modal> component, the screen size directly affects the layout of components inside modal; in the case of uncontrolled <TextInput> component, the text inside the input affects the layout of the surrounding components. `State` is a special (legit!) workaround for all those similar cases. Native part of React Native maintains a special shared object between all nodes of the same family and use that during cloning and commits.

See coming commits to know how to use that.

In the near future State will fully replace LocalData concept but for simplicity they both exist for now.

Reviewed By: mdvacca

Differential Revision: D14217184

fbshipit-source-id: 6e018c5b68208d662462013bce0f4e2733d2f673
2019-02-27 00:32:25 -08:00
Valentin Shergin 9a64755a18 Fabric: `events` module was merged into `core` module
Summary: That's bummer that we have to do it, but it's actually reasonable. Files in `core` and `events` depend on each other creating circular dependencies and other similar hard problem.

Reviewed By: mdvacca

Differential Revision: D14195022

fbshipit-source-id: 96a44ae28631cc9ccd7d7de72a94526f9e0dd12a
2019-02-25 19:12:08 -08:00
Valentin Shergin 94d49e544d Fabric: Codemod: All `<fabric/...` includes were renamed to `<react/...`
Summary: We are moving to more stable APIs removing all mentiones of the effort name from the codebase.

Reviewed By: mdvacca

Differential Revision: D12912894

fbshipit-source-id: 4a0c6b9e7454b8b14e62d419e9e9311dc0c56e7a
2018-11-10 14:22:15 -08:00
Valentin Shergin 8f51243957 Fabric: Enabling clang-format for the rest of Fabric
Summary: This is the second and the final part of adopting clang-format.

Reviewed By: mdvacca

Differential Revision: D10229624

fbshipit-source-id: d97670b716800ea2488b84bd0aacaf54d8bd2e31
2018-10-09 16:31:48 -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
Héctor Ramos 1151c096da Update copyright headers to yearless format
Summary: This change drops the year from the copyright headers and the LICENSE file.

Reviewed By: yungsters

Differential Revision: D9727774

fbshipit-source-id: df4fc1e4390733fe774b1a160dd41b4a3d83302a
2018-09-11 15:33:07 -07:00
Valentin Shergin 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 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 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 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 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
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 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 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 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
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