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

1085 Коммитов

Автор SHA1 Сообщение Дата
Valentin Shergin 78b1c85747 Fabric: Simplifying Yoga and Fabric integration
Summary:
The integration with Yoga was pretty complex from day one. The first attempt to make it simpler was in D19963353 when we removed a bunch of layers of indirection. This is the second iteration that aimed to simplify the structure of methods and their responsibilities.

The only conceptual change (that I am aware of) in this diff is that now we don't support (imaginary) case where a non-leaf YogaLayoutableShadowNode can have a non-YogaLayoutableShadowNode child. In the previous version, it was a no-op, now it's not supported and an assert will fire.

Alongside with refactoring, this diff implements several helper functions that verify the invariants important for the Concurrent Layout in debug mode.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D21198222

fbshipit-source-id: cc085904948056f861562af5bd2571de45a743b9
2020-04-23 15:00:46 -07:00
Valentin Shergin f64b39ea6c Fabric: Introducting `ShadowNodeFamilyFragment::Value`
Summary:
`ShadowNodeFamilyFragment::Value` is a value couter-part type for `ShadowNodeFamilyFragment`.
We need that to be able safely copy data stored inside a `ShadowNodeFamilyFragment` object.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: kacieb

Differential Revision: D21169580

fbshipit-source-id: 1a485e1b2ae47bc7da9476a60466934ac9d61366
2020-04-22 15:41:56 -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
David Vacca 05c76be176 Easy diff to document in code how to enable logging of Shadow Tree instrospection
Summary:
Easy diff to document in code how to enable logging of Shadow Tree instrospection

changeLog: [Internal] Internal change used on Fabric

Reviewed By: JoshuaGross

Differential Revision: D21150196

fbshipit-source-id: 8eb23ec3ea1d574b79b09333428ab52c851065dd
2020-04-20 23:31:21 -07:00
David Vacca 8c4efc94e1 Enable Yoga logging in Fabric Debug
Summary:
This diff extends Fabric to support Yoga logging

changeLog: [Internal] Internal changes in Fabric to enable yoga logging

Reviewed By: JoshuaGross

Differential Revision: D21150195

fbshipit-source-id: a2e8308a79a7b422bf9ecc3a65f822b305f02c5d
2020-04-20 23:31:21 -07:00
Joshua Gross 1fdb9ac69c Update Differ test
Summary:
Update differ test so it passes again. Previously to D21111423 (I think) nodes were being incorrectly detected as updated even if they weren't different, so now there are fewer unnecessary Update mutations generated.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D21148647

fbshipit-source-id: cab6e3ecd0a457e1ac3155b3468bcc56663dab0b
2020-04-20 23:19:29 -07:00
Valentin Shergin d639063499 Fabric: More strict policies to dirty Yoga nodes in YogaLayoutableShadowNode
Summary:
Yoga uses a dirty flag to re-layout nodes. In normal, single-threaded approach the policy for dirtying is simple: if a node was changed, we need to dirty it. In the Concurrent Yoga approach, those rules are not so simple, and it seems we haven't formalized those rules yet.

Investigating some layout issues that we have in Fabric, I tend to believe that we don't dirty as much we should. Hense this change adds mode dirtying.

Reviewed By: JoshuaGross

Differential Revision: D21092815

fbshipit-source-id: 4603c97ccb79efcdf5e6a4cc450ebe61b63effb3
2020-04-20 19:21:08 -07:00
Valentin Shergin 4afb8362ec Fabric: Fixed `getDirtied` vs `isDirty` in `YogaLayoutableShadowNode`
Summary:
This is quite a fateful mistake. `getDirtied()` returns the pointer to a function which is obviously a mistake here; we should use `isDirty()` instead.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D21028569

fbshipit-source-id: 95212b31f4e32d51c594d5209f295397af3f1252
2020-04-20 19:21:08 -07:00
Samuel Susla e7ef35c133 Fix mistake in swapping left/right layout properties
Summary:
Changelog: [Internal]

We were assigned `undefined` value to incorrect edge, instead of `YGEdgeLeft` it should have been `YGEdgeRight`.
If node has `YGEdgeRight` value, it needs to be reassigned to `YGEdgeEnd` and its original value set to undefined.

Reviewed By: mdvacca

Differential Revision: D21095234

fbshipit-source-id: fbecd9b7e6670742ad4a4bb097760aa10eec8685
2020-04-20 11:44:15 -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 5dc6eded1b Fabric: Using proper clock in MountingTelemetryTest
Summary:
Apparently, `std::this_thread::sleep_for` uses a different clock to measure time which causes ofter misalignment with the clock which Telemery uses which makes the test flaky. Using the same clock should fix it.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D21116058

fbshipit-source-id: 52dde2e325776d365431a2a957dcc12dfe53f890
2020-04-19 22:55:09 -07:00
empyrical b0006648e2 Fabric: Add Unicode prefix to AttachmentCharacter (#28617)
Summary:
This pull request adds a Unicode `u8` prefix to the string literal returned in `AttributedString.cpp`'s `Fragment::AttachmentCharacter()`.

This fixes the following error when building on MSVC:

```
react\attributedstring\AttributedString.cpp(21): error C4566: character represented by universal-character-name '\uFFFC' cannot be represented in the current code page (1252)
```

## Changelog

[Internal] [Fixed] - Fabric: Add Unicode prefix to AttachmentCharacter
Pull Request resolved: https://github.com/facebook/react-native/pull/28617

Test Plan: The Fabric test suite has been ran on a Clang-based build of Fabric on macOS, and no regressions in it have been noted.

Differential Revision: D21118078

Pulled By: shergin

fbshipit-source-id: c105de5e4edb67fed97ce44153a75d9d380bf588
2020-04-19 13:00:17 -07:00
empyrical de188a2c97 Fabric: Fix case of Glog include in MountingTest.cpp (#28616)
Summary:
This pull request changes the include of Glog from `<Glog/logging.h>` to `<glog/logging.h>` in `MountingTest.cpp`. This fixes building on a case-sensitive filesystem.

## Changelog

[Internal] [Fixed] - Fabric: Fix case of Glog include in MountingTest.cpp
Pull Request resolved: https://github.com/facebook/react-native/pull/28616

Test Plan: The `include` of Glog no longer causes issues with building `MountingTest.cpp` on a case-sensitive filesystem.

Differential Revision: D21118085

Pulled By: shergin

fbshipit-source-id: c958c54bf88333fd5001127779c855ce8c2666c3
2020-04-19 12:06:41 -07:00
Valentin Shergin 7a2c685ac1 Fabric: `templateprocessor` module was decoupled from `uimanager`
Summary:
We need to break up the `uimanager` module in order to solve circular dependencies problem (which future diff would have otherwise).

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D20885646

fbshipit-source-id: b8e3199c0eacc57a5be1481595cf97c84f972293
2020-04-18 15:00:22 -07:00
Valentin Shergin 599f1edd9a Fabric: `scheduler` module was decoupled from `uimanager`
Summary:
We need to break up the `uimanager` module in order to solve circular dependencies problem (which future diff would have otherwise).

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D20885645

fbshipit-source-id: 8148bd934879802b076261ed86fa78acf0a07ed3
2020-04-18 15:00:21 -07:00
Valentin Shergin e56950dc65 Fabric: `componentregistry` module was decoupled from `uimanager`
Summary:
We need to break up the `uimanager` module in order to solve circular dependencies problem (which future diff would have otherwise).

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D20885163

fbshipit-source-id: 08eb1ba1d408fc0948e8d0da62380786a40973af
2020-04-18 15:00:21 -07:00
Valentin Shergin e1eef24321 Fabric: Implementation of `getDebugDescription` for `std::array`
Summary:
Yoga uses `std::array` a lot (and `std::array` is not a `std::vector`), so it's useful for printing Yoga values.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D21028570

fbshipit-source-id: c6bf114d5362f085ea201ecdc5b7d59646b33ebd
2020-04-17 21:20:05 -07:00
Valentin Shergin cc07baa87e Fabric: "Attempt to mutate a sealed object." is now an assert (not exception)
Summary:
This is a debug-only feature that simply should be an assert. When it triggers in debugger and bubbles to some random exception catch block which makes it impossible to understand was exactly it happens. Making it an assert will stop debugger exactly where it happens.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D21028571

fbshipit-source-id: 3df4ec0da922026bb9df61081cb71113577e06e9
2020-04-17 21:20:04 -07:00
Valentin Shergin 62544c0830 Fabric: Proper traits for `ImageShadowNode` and `ViewShadowNode`
Summary:
* <Image> must be a leaf node; having a proper trait will fail earlier in case of misuse (mounting something inside).
* <View> must have a `View` trait because it's for what that trait is.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D21028573

fbshipit-source-id: 457716d4661333eb2357f34316f3e495ab4fda24
2020-04-17 21:20:04 -07:00
Valentin Shergin 4c538fc8d0 Fabric: `LayoutableShadowNode:getLayoutMetrics` is not a virtual method anymore
Summary:
We don't use it as vitrual anymore (setLayoutMetrics is a non-virtual method already), so it does not need to be marker virtual.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D21028572

fbshipit-source-id: 99f86fdd4cf2f5972034d9058d7b82bdc8680187
2020-04-17 21:20:04 -07:00
Samuel Susla 00c4d950cf Implement event count for TextInput
Summary:
Changelog: [Internal]

Implementation of event count for Fabric's Text input.

Reviewed By: JoshuaGross

Differential Revision: D20800185

fbshipit-source-id: 988692cb2fc786649821cccb06e629b40b9b0479
2020-04-09 03:44:55 -07:00
Samuel Susla 3d61dc9f36 Back out "Fix controlled TextInput with child nodes"
Summary:
Changelog: [Internal]

Original commit changeset: 1b8a2efabbfa

Original diff D20587681 breaks non-controlled text input.

Reviewed By: motiz88

Differential Revision: D20815935

fbshipit-source-id: 70577ed1e5701850ff0e30a6592945a31c2a8bec
2020-04-02 08:26:04 -07:00
Samuel Susla 3591b7a956 Promote shadowColor to formsStackingContext property
Summary:
Changelog: [Internal]

View with `ShadowColor` was getting flattened and therefore views didn't have shadow property set.
This is fixed by promoting ShadowColor so in case it is set, it forms stacking context.

Reviewed By: shergin

Differential Revision: D20792201

fbshipit-source-id: 1033ac00e32047ffbb14e61b7c26348c578d132d
2020-04-01 10:42:51 -07:00
Samuel Susla 46722dcfc2 Swap left and right yoga position with start and end in RTL context
Summary:
Changelog: [Internal]

Paper swaps right and left in RTL setting, this logic is in [RCTShadowView.m](https://our.intern.facebook.com/intern/diffusion/FBS/browse/master/xplat/js/react-native-github/React/Views/RCTShadowView.m?commit=cdd504cfbee66ae0659495604c4ff7b5764a1d9e&lines=529-549).

For Fabric instead of doing it during yoga props assignment, I swap the left/right with start/end just before we pass yoga nodes to layout calculation.

Reviewed By: shergin

Differential Revision: D20420040

fbshipit-source-id: b777f2658f56c173743b2034b8b5059e3e0c9840
2020-04-01 05:42:20 -07:00
Joshua Gross 2b062eadc8 Fix bug in optimized differ
Summary:
The differ was still producing correct, but not minimal, instruction sets in some cases due to an optimization that was buggy.

This affected cases where 2+ nodes were inserted at the beginning of a list. It would trigger the old behavior where all nodes after the first would be removed, deleted, then reinserted.

See the test case (which was failing and now passed) and P128190998 (the 3->4 transition) for samples.

Changelog: [Internal] Fabric differ

Reviewed By: mdvacca

Differential Revision: D20785729

fbshipit-source-id: 2fea6a816753066abb358ed7bb51003140cd5fc4
2020-03-31 19:36:45 -07:00
Samuel Susla 367a573ccc Assign orderIndex_ in ConcreteViewShadowNode constructor instead of ViewShadowNode's constructor
Summary:
Changelog: [Internal]

`orderIndex_` was only being assigned for `ViewShadowNode`, not for other `ShadowNodes` that are later represented on the screen.

Reviewed By: shergin

Differential Revision: D20746477

fbshipit-source-id: c04c2cfea14b9141d22bc3d9e9bb4c0c59925754
2020-03-31 09:50:17 -07:00
Samuel Susla c381518a68 Set RootNodeKind trait in ModalHostViewShadowNode
Summary:
Changelog: [internal]

`ModalHostViewShadowNode` didn't have `RootNodeKit` trait, therefore `getRelativeLayoutMetrics`  was including nodes in ancestors that it shouldn't have.

Reviewed By: shergin

Differential Revision: D20735801

fbshipit-source-id: 6b81e3b174c2f82e530abc2bca2da8bebc2270b0
2020-03-31 02:59:59 -07:00
Samuel Susla bbd91446dd Include transform property when calling getRelativeLayoutMetrics
Summary:
Changelog: [Internal]

Current implementation of `measure` doesn't take transform into account..

So if you had a view which has width and height 100 and had `Scale(0.5, 0.5, 1)` (this will shrink view by half). Calling `getRelativeLayoutMetrics` would report its size being `{100, 100}`.
This applies if view's parent has transformation as well, because transformation is applied to all subviews of the view as well.

Reviewed By: mdvacca

Differential Revision: D20621590

fbshipit-source-id: 2cf902a0494291c821ecada56f810c5e6620db5a
2020-03-30 04:03:57 -07:00
Samuel Susla 26b209431b Add support for translation and rotation to operator * between Rect and Transform
Summary:
Changelog: [Internal]

Until now `Rect operator*(Rect const &rect, Transform const &transform)` supported only scaling. Now it supports translation and rotation as well.

Reviewed By: shergin

Differential Revision: D20622876

fbshipit-source-id: 1b65393bd3fd6fd9a8941903e0f2681a10097e4a
2020-03-30 04:03:57 -07:00
Samuel Susla 7a01afe03b Remove LayoutInspectingPolicy.includeScrollViewContentOffset
Summary:
`LayoutInspectingPolicy` has two flags, `includeTransform` and `includeScrollViewContentOffset`.

`includeScrollViewContentOffset` seems to be redundant for two reasons.

# 1st
From looking at callers, they have always the same value.
I looked at all call sites, and they are either always both set to true or both set to false.

# 2nd
The way we include scroll view content offset, is through transformation, so setting `includeTransform` to true and `includeScrollViewContentOffset` to false will include content offset anyway. In order to make both flags work, we would need to introduce further changes to `getRelativeLayoutMetrics`. But since the flag isn't used anyway, I think it is better to get rid of it for now. If we need it in the future, we could re-introduce it.

Reviewed By: shergin

Differential Revision: D20622256

fbshipit-source-id: fb6156c66b752319ea928239fa723ff90688b0a0
2020-03-30 04:03:57 -07:00
Joshua Gross d770d78032 Reimplement D19965405: Small improvements in Differentiator/TinyMap
Summary:
Two things:
1) I reimplement Valentin's idea in D19965405, so that TinyMaps can be iterated over, with a couple of bugfixes (calling front() or back() on an empty vector will crash).
2) I now use TinyMap instead of better::map in the "optimized" diffing algorithm.
3) `erase` now actually removes elements from the vector, but only when more than half of elements have been erased.
4) If you repeatedly erase elements at the beginning of the vector, they will no longer be iterated over. This is a specific optimization for our heaviest TinyMap use-cases.

These amount to some small but hopefully somewhat meaningful perf improvements.

Changelog: [Internal] Fabric perf

Reviewed By: shergin

Differential Revision: D20718719

fbshipit-source-id: 91f4b2e2e0f6387ae484e43d5b0095103087baa6
2020-03-28 14:49:54 -07:00
Joshua Gross 1281be69f2 Unit test for V2 "minimal instruction" diffing algorithm
Summary:
This unit test is to verify that the new diffing algorithm generates a "minimal" instruction set, with regards to removes and inserts ("moves").

These unit tests are here to verify the expected behavior in this new algorithm, but these tests may be modified or deleted in the future if we decide we want to change this behavior.

Changelog: [Internal] fabric unit test

Reviewed By: mdvacca

Differential Revision: D20706592

fbshipit-source-id: 5f9991498e0d788ecbf88d938bfe6d3f0f27af40
2020-03-27 19:07:54 -07:00
Joshua Gross 50a34bcd7f Optimize diff algorithm to produce fewer remove+insert ("move") paired instructions
Summary:
An evolution of D20633188 but more performant.

There are three optimized paths before the slow path.

The first optimized path tries to pair identical nodes from old/new tree, and generate Update mutations, until we hit nodes that are different (indicating either a remove or an insert). This already existed.

The next two optimizations, introduced by Tim in his JS pseudocode, were inspired by ReactJS's diffing algorithm. They work in cases where the rest of the nodes are (1) all removals/deletes or (2) all creates+inserts.

Finally, if those final two optimized paths can't run, it's because there is a mix of delete+remove, create+insert, and "move" operations, mixed at the beginning, middle, and/or end of the list.

This has slightly better average/best-case complexity as the previous implementation.
In particularly pathological cases where all nodes are arbitrarily reordered, or reversed, for instance (ABCDE->EDCBA) the algorithm has the same complexity as the previous algorithm (quadratic).

For now iOS is pinned to the older differ

Changelog: [Internal] Experiment to optimize diffing algorithm in Fabric

Reviewed By: shergin

Differential Revision: D20684094

fbshipit-source-id: d29fba95a0328156c023e1c87804f23770ee1d91
2020-03-27 19:07:53 -07:00
Joshua Gross 24b79c1182 Core telemetry tests: update so they pass on my machine
Summary:
`std::this_thread::sleep_for` is not really precise and will attempt to sleep for "at least" that much time, but may sleep much longer depending on what CPUs are doing and scheduling policies.

To get this to pass on my machine, I had to substantially increase the thresholds.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D20689571

fbshipit-source-id: f159420d24a95da2b5d95d49ed7882e783291e98
2020-03-27 19:07:53 -07:00
Joshua Gross c3d0f3b2de Ship State Reconciliation 100% on all platforms
Summary:
State Reconciliation has been running 50/50 for a while and all metrics look stable. This is necessary for providing a good experience so we should ship to everyone unconditionally.

Changelog: [Internal] Fabric diffing reconciliation process improvement

Reviewed By: mdvacca

Differential Revision: D20715694

fbshipit-source-id: 25b2635ecc29b67e2911679c9db66bc84d37dec1
2020-03-27 18:44:02 -07:00
Kevin Gozali 25f7aea86c Replace fbsource// with // in xplat/js/ files [1]
Summary:
`fbsource//xplat` and `//xplat` are equivalent for FB BUCK targets. Removing extra prefix for consistency.

Changelog: [Internal]

Reviewed By: scottrice

Differential Revision: D20495655

fbshipit-source-id: a57b72f694c533e2e16dffe74eccb8fdec1f55f5
2020-03-25 21:55:47 -07:00
Valentin Shergin fb0232883b Fabric: Additional temporary checks in prop parsing infra
Summary:
While ViewConfig infra isn't perfect we need to check some value for correctness during prop-parsing.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D20639055

fbshipit-source-id: 193dcd0769bc7777bc8d60c964ede72ebdaa83e4
2020-03-24 21:55:54 -07:00
generatedunixname89002005287564 9a75d50d46 xplat/js/react-native-github/ReactCommon/fabric/components/textinput/
Summary: Changelog: [Internal]

Reviewed By: scottrice

Differential Revision: D20619227

fbshipit-source-id: 674337e6ce585a4e96d020f9624b874ba86e2d80
2020-03-24 09:33:50 -07:00
Max Ovtsin 8721ee0a6b Get ReactiveNative compiled with Clang 10 (#28362)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/28362

Fixed a few compilation errors emitted by Clang 10.

Changelog:
[iOS] [Fixed] - Get ready for Clang 10

Differential Revision: D20549970

fbshipit-source-id: dc36a85d90d3e43a05f045feb57c6ab6ded67da7
2020-03-23 13:46:37 -07:00
Valentin Shergin 0952e4bb03 Fabric: View Test: Changing state should not dirty Yoga tree (in some most cases)
Summary: Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D20578789

fbshipit-source-id: 4336165217bd39fc8065cfaeb96ef7753433d48a
2020-03-23 13:33:23 -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
Valentin Shergin 3679929830 Fabric: Modernizing Yoga Dirty flag test.
Summary:
Now we using TEST_F thing that allows consilidating initialization.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D20578788

fbshipit-source-id: 103bcb8fdeb3dbf297385cfe56415bd646e16791
2020-03-23 13:33:20 -07:00
Samuel Susla a40cfc05b8 Fix controlled TextInput with child nodes
Summary:
Changelog: [Internal]

# There are three changes in this diff

## _stateRevision is replaced with a BOOL
`_stateRevision` was protecting against setting attributed string that is already visible to the user. Previously this was ok because the change was only coming from native, any changes from JS were ignored.

Imagine following scenario:

1. User taps key.
2. Update state is called on component initiated by native.
3. New state is created with incremented revision by one.
4. `_stateRevision` gets set to new state's revision + 1.
5. Now JS wants to change something because it just learnt that user tapped the key.
6. New state is created again with incremented revision by one.
7. Update state is called on the component, but the change isn't applied to the text view because `_state->getRevision()` will equal `_stateRevision`.

By having a BOOL instead of number, we very explicitly mark the region in which we don't want state changes to be applied to text view.

## Calling [_backedTextInputView setAttributedText] move cursor to the end of text input
This is prevented by storing what the current selection is and applying it after `[_backedTextInputView setAttributedText]` is called.
This was previously invisible because JS wasn't changing contents of `_backedTextInputView`.

## Storing of previously applied JS attributed string in state

This is the mechanism used to detect when value of text input changes come from JavaScript. JavaScript sends text input value changes through props and as children of TextInput.
We compare what previously was set from JavaScript to what is currently being send from JavaScript and if they differ, this change is communicated to the component.
Previously only first attributed string send from JavaScript was send to the component.

# Problem

If children are used to set text input's value, then there is a case in which we can't tell what source of truth should be.

Let's take following example
We have a text field that allows only 4 characters, again this is only a problem if those 4 characters come as children, not as value.
This is a controller text input.

1. User types 1234.
2. User types 5th character.
3. JavaScript updates TextInput, saying that the content should stay 1234.
4. In `TextInputShadowNode` `hasJSUpdatedAttributedString` will be set to false, because previous JS value is the same as current JS value.

Reviewed By: shergin

Differential Revision: D20587681

fbshipit-source-id: 1b8a2efabbfa0fc87cba210570142d162efe61e6
2020-03-23 04:42:09 -07:00
Joshua Gross fb9a7be2bd Fix TextInput left/right padding
Summary:
This fixes two things:

1) Currently it only respects Start and End padding, and if there's a Theme default, it will override Left/Right padding. Whoops.
2) Currently it doesn't respect when a TextInput starts with padding, but then is removed.

This resolves both.

It still does not account for RTL support.

Changelog: [Internal] Fix AndroidTextInput padding

Reviewed By: mdvacca

Differential Revision: D20573151

fbshipit-source-id: e89791641b6699e728cde9dbd661a8c21485fbc8
2020-03-20 18:47:31 -07:00
Samuel Susla 48fe460ed9 When resolving borders, respect leading/trailing semantics before left/right
Summary:
Changelog: [Internal]

When resolving borders, leading/trailing semantics should take priority over left/right.

Reviewed By: shergin

Differential Revision: D20422951

fbshipit-source-id: 7a464c88f881a77732929a155aaa9b2e150bba74
2020-03-17 14:09:28 -07:00
Samuel Susla 71c7e80bfd Add RTL support
Summary:
Changelog: [internal]

layoutDirectionPass down layoutDirection from `RCTSurfacePresenter` down to `YogaLayutableShadowNode`.

In `ParagraphShadowNode`, we propagate layoutDirection from yoga node to `TextAttributes.layoutDirection`.

Reviewed By: shergin

Differential Revision: D20420041

fbshipit-source-id: 86e01d31ea9415acb8579c44c470cac870ec1b8f
2020-03-17 14:09:28 -07:00
Samuel Susla 678f1c4490 Fix crash in slider with custom image
Summary:
Changelog: [Internal]

# Why was it crashing?
Crash was caused by `data.getTrackImageRequest()` returning NULL. The crash happened inside `getCoordinator` method. If you look at the implementation of the method below

```
if (request) {
    return &request->getObserverCoordinator();
} else {
    return nullptr;
}
```

you might notice that we check for NULL, why is it crashing then? And why is it only crashing in production?

The reason is compiler's optimiser, which looks at `data.getTrackImageRequest()`, this method returns `ImageRequest const &` and sees that this method will always return a value, never NULL. Compiler then looks at our `getCoordinator` function, sees that we check there for nullity but since it can never be null, removes that branch.

# Solution
Create new SliderState with non null image observer.

Reviewed By: shergin

Differential Revision: D20491367

fbshipit-source-id: 17b7cf31feabbe6f8ece324a3d329902b2ef6a2d
2020-03-17 13:56:46 -07:00
Valentin Shergin e602b22bfb Fabric: Tests for `traitCast<>`
Summary:
Subject.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D20462834

fbshipit-source-id: 13e3c3b45537e22002b948f967a2576bc52145e8
2020-03-16 10:21:41 -07:00
Valentin Shergin c6e224ee90 Fabric: Removing `yogaStyleFromLayoutConstraints` from RootShadowNode
Summary:
We don't need it anymore because the same logic is already implemented in `YogaLayoutableShadowNode::layoutTree()`.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D20464175

fbshipit-source-id: 3dd2293ee102a9b67a856104720d3a7dc4103d7f
2020-03-16 10:11:11 -07:00
Valentin Shergin 14a174c237 Fabric: Implementation of `ViewProps::zIndex` feature in C++ core
Summary:
Now, having `orderIndex` feature in the core, we can use it for implementing `zIndex` feature. All we need to do is just to assign this `zIndex` value to `orderIndex`.
Then we will use this to remove some platform-specific code that implements `zIndex` on the mounting layer.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D20432155

fbshipit-source-id: b4d62b63006f45899de38e1f40b1dfbe69550ada
2020-03-15 20:52:11 -07:00