Commit Graph

56 Commits

Author SHA1 Message Date
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 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
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 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 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 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 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
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 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 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 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
Jonathan Kim 255b97ddd1 Load and use fb_xplat_cxx_test
Reviewed By: mzlee

Differential Revision: D7854278

fbshipit-source-id: 2a4c4fc27fc665a192fc04a8c8fae19f7f221566
2018-05-03 16:04:29 -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 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 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 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 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
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 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
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 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 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 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 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 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 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
Valentin Shergin 99e9c6e798 Fabric: Collecting and printing ShadowNode's revision/generation
Summary: It drastically simplifies reading logs.

Reviewed By: fkgozali

Differential Revision: D7388963

fbshipit-source-id: 7849c803f295719918c20ddf8c082e5a5780116f
2018-03-25 22:48:19 -07:00
Valentin Shergin cb7a7f3b93 Fabric: Deleted virtual default destructor from Props
Summary: Trivial. We don't need this because we already have another virtual method.

Reviewed By: fkgozali

Differential Revision: D7388964

fbshipit-source-id: 5ea6eb33ece72796d8cde2cc4b12c1240447d22a
2018-03-25 22:48:18 -07:00
Valentin Shergin ee0cc6bbe7 Fabric: Implementing cloneAndReplaceChild() for ViewShadowNode
Summary:
First, LayoutableShadowNode::cloneAndReplaceChild() is now pure virtual. The default implementation was useless and confusing.
Second, cloneAndReplaceChild() is now fully implemented for ViewShadowNode, so fancy Yoga Concurrent layout *should* work now.

Reviewed By: mdvacca

Differential Revision: D7376352

fbshipit-source-id: 1199a37e64535c8592a2a5480e60139f61d02006
2018-03-25 22:48:18 -07:00
Valentin Shergin 53782eafc9 Fabric: Source shadow node is now stored as a weak pointer
Summary:
We use shource nodes only in the diffing alogorithm. It implies that we have strong pointers to those nodes in trees we compare against.
Using weak_ptr's allows to avoid memory leaks.

Reviewed By: mdvacca

Differential Revision: D7376348

fbshipit-source-id: 34e5f58f18a00475f6bcdfbea3996b41c84dff62
2018-03-25 22:48:18 -07:00
Kevin Gozali 408a5f264b iOS: added fabric/core ComponentDescriptor tests
Summary: Basic test for ComponentDescriptor mechanism.

Reviewed By: shergin

Differential Revision: D7388297

fbshipit-source-id: 3b0c625656e31df03d71a2e036388621a5e2e21d
2018-03-23 17:32:52 -07:00
Kevin Gozali e254474d4c iOS: added fabric/core ShadowNode tests
Summary: basic tests for shadow nodes and props for fabric

Reviewed By: shergin

Differential Revision: D7377867

fbshipit-source-id: dc8e5bb369aeb32b4790fd8b56f333376bc1578c
2018-03-23 17:32:52 -07:00
Kevin Gozali 8c0070c706 iOS: added fabric/core primitives tests
Summary: basic tests for fabric core primitives

Reviewed By: shergin

Differential Revision: D7373952

fbshipit-source-id: e2d9b3c15716c16b1aab698883817e670dcb7a57
2018-03-23 17:32:52 -07:00
Valentin Shergin b808bfdce2 Fabric: Introducting `ShadowNode.sourceNode`, the node used in copy-constructor
Summary: We will need this later in the diffing alogrithm.

Reviewed By: fkgozali

Differential Revision: D7330337

fbshipit-source-id: 3da44a62e4d5f30deed28b18a5779544153244f3
2018-03-19 17:08:31 -07:00
Valentin Shergin a5a34565e0 Fabric: Proper return value of `LayoutableShadowNode::setLayoutMetrics()`
Summary: `LayoutableShadowNode::setLayoutMetrics()` must return `false` is nothing was changes.

Reviewed By: fkgozali

Differential Revision: D7330334

fbshipit-source-id: 700d50b0047919fa2b919acfa72825f100cd496f
2018-03-19 17:08:31 -07:00
Naris Siamwalla 12535ae69d Fix clang-6 strictness surrounding virtual destructors
Reviewed By: smeenai

Differential Revision: D7326765

fbshipit-source-id: 9df477dfa89812e05e79b5e6d510bcbbc793381c
2018-03-19 15:00:09 -07:00
Valentin Shergin 965e60b05a `fabric/view` module
Summary: Defines `<View>`: Yoga-powered, Accessible and styleable component.

Reviewed By: fkgozali

Differential Revision: D7230673

fbshipit-source-id: 08a1d8626c0b41260fafdca938d4fe9489b1b793
2018-03-18 19:17:39 -07:00
Valentin Shergin 6b0960cbdb Introducing `ConcreteShadowNode`
Summary: ConcreteShadowNode defines a template which connects typed Props and typed ShadowNode.

Reviewed By: fkgozali

Differential Revision: D7230667

fbshipit-source-id: be28314d6846d69960e921da852f01232951f965
2018-03-18 19:17:39 -07:00