Commit Graph

921 Commits

Author SHA1 Message Date
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