Commit Graph

89 Commits

Author SHA1 Message Date
Jonathan Kim be379efc9b Minimize included defs by adding a level of indirection
Reviewed By: zertosh

Differential Revision: D7851714

fbshipit-source-id: aa14e003a612173c6f316cb76a26f7e78e7f15d4
2018-05-02 22:24:42 -07:00
Valentin Shergin 6ce2823afe Fabric: Proper types and default arguments in ConcreteViewShadowNode
Summary: Trivial. Those are artefacts from copy-pasting from `ViewShadowNode`.

Reviewed By: mdvacca

Differential Revision: D7738576

fbshipit-source-id: 2d362cd0ff56420d54cdd0e339458ebe57049ddc
2018-04-26 18:03:07 -07:00
Valentin Shergin edc6cb5711 Fabric: New, much fancier, approach to parse dynamic props
Summary:
The new approach uses C++ overloading feature instead of specifying exact types in macros manually.
*Almost* macro-free!

Reviewed By: mdvacca

Differential Revision: D7738584

fbshipit-source-id: 85f8e4c1037b452df5e73b093dced9392cb2f73e
2018-04-26 18:03:07 -07:00
Valentin Shergin f8ab0e0b08 Fabric: YogaLayoutableShadowNode::enableMeasurement() enables custom measuring for Yoga based shadow nodes
Summary:
YogaLayoutableShadowNode::enableMeasurement() connects Yoga's measuring API and Fabric measuring API.
`enableMeasurement` should be called for leaf Yoga nodes with custom content which should be measured manually during layout.

Reviewed By: mdvacca

Differential Revision: D7738574

fbshipit-source-id: ffe883905c4809290d4d973ad29dc5f0e1ec7573
2018-04-26 18:03:07 -07:00
Valentin Shergin 6bbc2ec921 Fabric: Introcucing `ConcreteComponentDescriptor::adopt()`
Summary: Overriding `adopt` method allows subclasses to configure just created or cloned shadow nodes without overriding `create` and `clone` methods.

Reviewed By: mdvacca

Differential Revision: D7738581

fbshipit-source-id: bfe4e4e2d3d448591a3267b5ea7ca4e0800f5ba0
2018-04-26 18:03:07 -07:00
Valentin Shergin 368388bfc8 Fabric: Introducing `LocalData` concept
Summary:
LocalData might be used to communicate some infomation between `ShadowNode`s
and native component views.

We will use it soon to store (and transmit to mounting layer) prepared for rendering attributed text in Text component.

Reviewed By: mdvacca

Differential Revision: D7738582

fbshipit-source-id: 1ead23ffd105cce0b3d9aeb9fc1d0df47673be50
2018-04-26 18:03:07 -07:00
Valentin Shergin 9d08e2afae Fabric: Using `ColorComponents` in `colorFromComponents` function
Summary: Trivial. We have a special data structure for it, why do not use it here?

Reviewed By: mdvacca

Differential Revision: D7738577

fbshipit-source-id: 750aa649b06f17d27906d44df07172a907cde2e5
2018-04-26 18:03:07 -07:00
Valentin Shergin 139db66a3e Fabric: More graphic values conversions from dynamic type
Summary: Trivial.

Reviewed By: mdvacca

Differential Revision: D7738578

fbshipit-source-id: 3112e523dd1cdceff90a8596033f9516aa2c8156
2018-04-26 18:03:07 -07:00
Valentin Shergin 6aa52f2684 Fabric: Using a proper Component Descriptor for node cloning
Summary: To clone a ShadowNode we must use node's ComponentDescriptot, not parent node's one.

Reviewed By: mdvacca

Differential Revision: D7738583

fbshipit-source-id: 83656f9a761530cdaedf65663ae28b3119af75f5
2018-04-26 18:03:07 -07:00
Valentin Shergin 3428808b97 Fabric: Using view name argument in `FabricUIManager.createNode()`
Summary: We are going to have not only <View> component soon!

Reviewed By: mdvacca

Differential Revision: D7738579

fbshipit-source-id: 5165762b98d94f74d40d016722be36a04d45f264
2018-04-26 18:03:07 -07:00
Valentin Shergin 98b4747041 Fabric/View: Debug printing logic in YogaLayoutableShadowNode was moved to superclass
Summary:
It's more useful and consistent now because:
 - We print compound layout metrics from the correct storage (not from Yoga nodes);
 - It works fro any kind of layout now (but we still have just one);
 - It's much clear and straight-forward.

Reviewed By: fkgozali

Differential Revision: D7607422

fbshipit-source-id: 4c3cd2848e785a7f77c7f591e376d00c7c09ade9
2018-04-26 18:03:07 -07:00
Valentin Shergin 88c368b488 Fabric/Graphics: New graphic values conversion functions and type refinments
Summary: Quite trivial. We need this to debug print LayoutMetrics.

Reviewed By: fkgozali

Differential Revision: D7607417

fbshipit-source-id: f4fa52ad04be9757545a8ac627db184f171288e5
2018-04-26 18:03:06 -07:00
Valentin Shergin f72df7a6e7 Fabric/Text: ConcreteViewShadowNode - base class for all `View`-like shadow nodes
Summary: Quite trivial split ViewShadowNode into concrete class and templace class.

Reviewed By: fkgozali

Differential Revision: D7595017

fbshipit-source-id: b1ac1dfa187e5cfd0a34fbf84b3e1ae308bb0c99
2018-04-26 18:03:06 -07:00
Valentin Shergin bd91eaf664 Fabric/Text: ShadowNode::clone() - dynamic self-cloning mechanism
Summary:
The previous approach simply didn't work. :(
As you might notice, in previous implementation of ViewShadowNode::cloneAndReplaceChild we used `ViewShadowNode` class for cloning `childNode`, and this is incorrect becasue `childNode` might be instance of any class.

Reviewed By: fkgozali

Differential Revision: D7595016

fbshipit-source-id: 2215414926f2f7a2e2fd05ca2d065f10d6d32b74
2018-04-26 18:03:06 -07:00
Naris Siamwalla e512a4ae30 Fix dtor declaration for clang-6
Reviewed By: smeenai

Differential Revision: D7690428

fbshipit-source-id: 4b02a6f6cbccda3446f0a19b1b35c266a33560bd
2018-04-20 10:04:39 -07:00
Taras Tsugrii 1433d15557 Avoid top-level read_config invocations.
Reviewed By: danzimm

Differential Revision: D7651745

fbshipit-source-id: 5cbc82b3c9da3ab514278d438f97f98e19946dc7
2018-04-17 09:41:20 -07:00
Valentin Shergin 82bd4337c9 Fabric: Fixed ComponentDescriptorTest
Summary: Trivial.

Reviewed By: mdvacca

Differential Revision: D7591712

fbshipit-source-id: fbcaaa30004f096749a6bcd47dcc56c060d7524a
2018-04-16 08:15:09 -07:00
Valentin Shergin c399d69716 Fabric: More restrictive types (const &) for ShadowNode constuctors' arguments
Summary: Should be more performant theoretically.

Reviewed By: mdvacca

Differential Revision: D7591713

fbshipit-source-id: 74141053f2b91cb621cc0d573f89f3454512c585
2018-04-16 08:15:09 -07:00
Valentin Shergin 3fd2e2da4f Fabric/Text/Prep: Refined ComponentDescriptor interface
Summary:
The new interface of ComponentDescriptor makes ShadowNode creation/cloning process a bit more explicit:
Now customers (UIManager) must prepare Props object explicitly before creation or cloning.
Besides general clarity, we need this to prepare for a new virtual `ShadowNode::clone()` method which will serve "virtual constructor" role,
redirecting execution to concrete ComponentDescriptor instance.

Actually, the whole purpose of concrete ComponentDescriptor instance is serve "virtual constructor" role (and all this code should be "templated").

Reviewed By: mdvacca

Differential Revision: D7591714

fbshipit-source-id: 8793b3ef70ed7ae113efb36ad1eee20573360dc8
2018-04-16 08:15:09 -07:00
Jakub Grzmiel c866ef243e Clean up BUCK files for missing dependencies and tests
Differential Revision: D7625433

fbshipit-source-id: 332b7ff7eaed82cb52f459921f1ae67b702a1636
2018-04-14 15:32:22 -07:00
Jakub Grzmiel a42b2988ae Clean up BUCK files for missing dependencies and tests
Differential Revision: D7618360

fbshipit-source-id: 421834892519998ad088a138b3fc3d96afe34d79
2018-04-14 13:18:08 -07:00
Kevin Gozali 2299d4cd7c iOS OSS: updated Podfile to have fabric related targets
Summary: Initial attempt to make fabric stuffs built properly with CocoaPods + RNTesterPods project. This simply includes fabric libs to the build, it doesn't change any behavior or enable fabric runtime.

Reviewed By: shergin

Differential Revision: D7626038

fbshipit-source-id: 4a80e0066cffa4478bb442fa8aefeaee6ff56ddd
2018-04-13 17:33:23 -07:00
Valentin Shergin 6924d44b20 Fabric: Fixed ConcreteShadowNode::getProps()
Summary:
Apparently, there is no point to return a reference from this method because the struct (std::shared_ptr) is allocated on stack.
The test is also updated.

allow-large-files

Reviewed By: fkgozali

Differential Revision: D7557749

fbshipit-source-id: aa74146322c6d340256752586f05fc672024038e
2018-04-10 17:15:08 -07:00
Valentin Shergin b13d5beb11 Fabric: `LayoutableShadowNodeList::getChildren` renamed to `getLayoutableChildNodes`
Summary:
The previous name conflicts with the method with same (but with different semantic) name in `ShadowNode` class.
That was bad idea to use same name especially because the different semantic.

Reviewed By: fkgozali

Differential Revision: D7554549

fbshipit-source-id: 0bccbaacd0812f8a26592b2008f15ddb5bc34ebc
2018-04-10 17:15:08 -07:00
Valentin Shergin 711abeda79 Fabric: Using `enum class` for some graphics types
Summary:
`enum class` types do not provide default conversion to integers and reguire use typename before value names.
This must prevent bugs like the previous one where we used `Undefined` as a number value.

Reviewed By: fkgozali

Differential Revision: D7554548

fbshipit-source-id: b19379aae48c9aebe03043e08cf3acc712da3cb8
2018-04-10 17:15:08 -07:00
Valentin Shergin dd49f9e0bc Fabric: Fixed incorrect usage of `Undefined` (instead of `kFloatUndefined`) in `yogaValuesConversions`
Summary: `Undefined` is actually equal `0` (becasuse it is `LayoutDirection::Undefined`), whereas `kFloatUndefined` is a magic huge number.

Reviewed By: fkgozali

Differential Revision: D7554550

fbshipit-source-id: 3ea37f0b8b6a59b4b0e00d205b75cd7252247d03
2018-04-10 17:15:08 -07:00
Valentin Shergin db92b16e04 Fabric: Proper invocation of `ensureunsealed` in `LayoutableShadowNode::layout`
Summary: Quite obvious. We have to check `sealable` flag of the child (not a parent) before mutating it.

Reviewed By: mdvacca

Differential Revision: D7526407

fbshipit-source-id: ce8e0d6446ff7eb23baee9c92f246d5e198fe377
2018-04-10 17:15:08 -07:00
Valentin Shergin 05f41931e2 Fabric: Fixed YogaLayoutableShadowNode::yogaNodeCloneCallbackConnector
Summary:
YogaLayoutableShadowNode::yogaNodeCloneCallbackConnector recently was disabled because of change in Yoga (D7339832).
This diff brings is back.

Reviewed By: mdvacca

Differential Revision: D7526417

fbshipit-source-id: 5369d641bf1e118132cf742d2d243bf426c0ffdb
2018-04-10 17:15:08 -07:00
Valentin Shergin ba45895a3f Fabric: Introducing Scheduler
Summary: Scheduler coordinates Shadow Tree updates and event flows (not yet).

Reviewed By: mdvacca

Differential Revision: D7503387

fbshipit-source-id: 4cb8bc574c25a0fd2ace6319c26c644a1e4757a9
2018-04-10 12:59:51 -07:00
Valentin Shergin 534abeca04 Fabric: Introducing UIManagerDelegate
Summary: UIManager uses UIManagerDelegate to communicate about shadow tree changes to another parts of the system.

Reviewed By: fkgozali

Differential Revision: D7503484

fbshipit-source-id: 0afe0f0d6cad31fe2ee9d61235d02b379cfe8217
2018-04-10 12:59:51 -07:00
Valentin Shergin 47c0ab91a5 Fabric: Using `shallowSourceNode()` inside `ViewShadowNode::cloneAndReplaceChild()`
Summary:
We have to call shallowSourceNode() in all cases of cloning which were not caused by UIManager instructions,
otherwise the diffing alogorith might produce incorrect mutation instructions.

Reviewed By: mdvacca

Differential Revision: D7503383

fbshipit-source-id: b33e5c39b7ba8cbd0f925fd29b3af379441a40a4
2018-04-10 12:59:51 -07:00
Valentin Shergin 53837c4a4f Fabric: Refined usage of `ensureunSealed` in `YogaLayoutableShadowNode::layout()`
Summary: We have to call `ensureunSealed()` only if the node was changed.

Reviewed By: mdvacca

Differential Revision: D7503388

fbshipit-source-id: a3d07d50fa983ef93c14fa771711fa783fdf4c12
2018-04-10 12:59:51 -07:00
Valentin Shergin c4bd7cef69 Fabric: Fixed issue in the diffing algorithm
Summary:
Previously we generated `removed` *or* `delete` instruction, but sometimes we have to generate both.
So, basically we did it wrong. :(

Reviewed By: mdvacca

Differential Revision: D7503386

fbshipit-source-id: 8ee476abd29f088f31dc776f6e6a68d5293fbb35
2018-04-10 12:59:51 -07:00
Valentin Shergin db7f98b789 Fabric: Introducing ShadowNode::shallowSourceNode()
Summary:
The method replaces the current source node with its source node.
It's useful when we have to clone some node but don't want to change a source node pointer.

Reviewed By: fkgozali

Differential Revision: D7503384

fbshipit-source-id: 81ec64079c7e99cb9abdda2af10d85281a94e1b1
2018-04-10 12:59:51 -07:00
Valentin Shergin 5463fc260b Fabric: ComponentDescriptorRegistry::operator[] marked as const
Summary:
Quite trivial.
Note that std::unordered_map's `operator[]` is not `const`, so we have to use `at` instead.

Reviewed By: mdvacca

Differential Revision: D7467799

fbshipit-source-id: df38b21dccee4b347f7c070600af0d52f38d6570
2018-04-10 12:59:51 -07:00
Valentin Shergin b2af59a0f0 Fabric: Diffing Algorithm (computing shadow node tree mutation instructions)
Summary:
The first and quite naive implementation of The Diffing algorithm.
The exact set of instructions, their semantic, order, amount, and excessiveness are still unclear.
The concept should be verified by comprehensive testing with working native views rendering layer.

Reviewed By: mdvacca

Differential Revision: D7467790

fbshipit-source-id: 08f2f646e058cac8a4b73bf7b148e2748633348d
2018-04-10 12:59:51 -07:00
Valentin Shergin 0332d475cc Fabric: Refined Yoga's `isDirty` flag management in YogaLayoutableShadowNode
Summary:
Motivation:
 * We never should call `markDirtyAndPropogate()` during tree construction/mutation because it might affect trees in different thread/dimentions;
 * In Fabric we basically always have to dirty nodes ourselves manually duting tree construction;
 * In Fabric we don't have "scoped/limited" tree mutations which require recursive dirtying; any mutation is creation of the new tree instance;
 * Default value of the `isDirty` flag is "false", so we have to change this right after creation of Yoga node (and after cloning).

Reviewed By: mdvacca

Differential Revision: D7467797

fbshipit-source-id: 2c9144271dceea6ba2b95173209b99b5d86fbd87
2018-04-10 12:59:51 -07:00
Valentin Shergin ef6b916e48 Fabric: New approach to manage Yoga's parent/owner references
Summary:
The modern Concurent Yoga's concept is:
We have to set parent/owner reference as part of `appendChild` process only if the current reference to parent/owner is `null`.
The motivation:
 * Null-parent indicates that this node was not attached to anything yet;
 * So, in this case there is no any concurrent memory access because we always create and (first time) attach the node on same thread;
 * Simmetrical parent-child relationship indicates that we don't need to (re)clone assosiated ShadowNode (nor Yoga node).

Reviewed By: mdvacca

Differential Revision: D7467791

fbshipit-source-id: 9a7f517380fde3bb00272de18fd5dc13edb52071
2018-04-10 12:59:51 -07:00
Valentin Shergin 5dca3e7c74 Fabric: New approach of mutating ShadowNode's children collection
Summary: Previously we recreate a vector with pointers to child nodes every single time we modify the collection. That was okay but recently I realized that the we can  simply make a copy of the vector one time during object construction and then mutate it freely.

Reviewed By: mdvacca

Differential Revision: D7467796

fbshipit-source-id: 660f1706a19ae5f07c34c509f411ce9d67b93b35
2018-04-10 12:59:51 -07:00
Valentin Shergin 1a4b6f0b3d Fabric: Overriden equality operator for ViewShadowNode
Summary:
Computed `layoutMetrics` are also considered as part of ViewShadowNode's value.
In the future we probably have to add something like `localData` and `imperativeCommands`.
We need all this for diffing algorithm and mointing phase.

Reviewed By: mdvacca

Differential Revision: D7467800

fbshipit-source-id: 8a0dcf1fd2f97dc501d6969cb0b0f6a2c6a648b4
2018-04-10 12:59:51 -07:00
Valentin Shergin fec0a51e85 Fabric: Simplified `ViewShadowNode::cloneAndReplaceChild`
Summary: Using methods of the base class instead of custom implementation.

Reviewed By: fkgozali

Differential Revision: D7467795

fbshipit-source-id: 4d168b72880f6900bf8b747e1d655c10140e0c79
2018-04-10 12:59:51 -07:00
Valentin Shergin a38f32a5a6 Fabric: Couple of ViewProps fields were exposed as getters
Summary: We have to have getters for all props/fields.

Reviewed By: mdvacca

Differential Revision: D7467792

fbshipit-source-id: 1492aad2d3398e6c14e0e354047730cf91201175
2018-04-10 12:59:51 -07:00
Valentin Shergin dc1a9680de Fabric: Refined TreeMutationInstruction class
Summary: Two additional types of instructions were added and now all of them have explicitly clear semantic.

Reviewed By: fkgozali

Differential Revision: D7467798

fbshipit-source-id: 83c0e774d56975be504aa3fe892035f5f724f809
2018-04-10 12:59:50 -07:00
Valentin Shergin 7e84cadc9c Fabric: Refined conception and usage of Sealable
Summary: Slightly new approach: Some non-const methods might not always mutate objects, so sometimes we should call `ensureUnsealed()` only inside conditional branches where we actually mutate an instance.

Reviewed By: fkgozali

Differential Revision: D7467793

fbshipit-source-id: 1b9f229cf6816e54e0df36699a571fdb612d3c3c
2018-04-10 12:59:50 -07:00
Valentin Shergin c83aeaaf82 Fabric: Forgotten compiler directive and include
Summary: Trivial. Those nits prevent cause compilation errors in some configurations.

Reviewed By: fkgozali

Differential Revision: D7467794

fbshipit-source-id: cbda285748374fd941a0b1ca6718d702ca2d6d82
2018-04-10 12:59:50 -07:00
Valentin Shergin 1f969d3440 Fabric: Equality operators for ShadowNode
Summary: Test for equality will be used in ShadowNode Tree Diffing algorithm.

Reviewed By: fkgozali

Differential Revision: D7467802

fbshipit-source-id: 5383add9fc7d7e4a772ca16e70a54f7e0c36823a
2018-04-10 12:59:50 -07:00
Valentin Shergin 4ebb57b0ba Fabric: `ShadowNode.revision_` field is now private
Summary: It prevents accidental access to the variable.

Reviewed By: fkgozali

Differential Revision: D7467789

fbshipit-source-id: fa026734f58f0039e9b6d401751e022a9ae2431d
2018-04-10 12:59:50 -07:00
Pritesh Nandgaonkar bcd12f1e87 Change the type of aspect Ratio to YGFloatOptional
Reviewed By: emilsjolander

Differential Revision: D7302651

fbshipit-source-id: 53e3b4c9627207a379f927b1f3485e36a9c70601
2018-04-03 15:02:57 -07:00
David Vacca 29ff30c539 Rename YogaNode.parent -> YogaNode.owner
Reviewed By: priteshrnandgaonkar

Differential Revision: D7352778

fbshipit-source-id: dcf1af5e72bfc3063b5c4bda197d7952a9194768
2018-04-01 18:32:12 -07:00
David Vacca aff5a75d8e Refactor cloning of YogaNode
Reviewed By: priteshrnandgaonkar

Differential Revision: D7339832

fbshipit-source-id: 2de6f47ae7601ac083d3b9fbe10ffaf6307ae760
2018-04-01 18:32:12 -07:00