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

2208 Коммитов

Автор SHA1 Сообщение Дата
Kevin Gozali 21785eea67 Replace fbsource// with // in xplat/js/ files [4]
Summary:
`fbsource//xplat` and `//xplat` are equivalent for FB BUCK targets. Removing extra prefix for consistency.

Changelog: [Internal]

Reviewed By: JoshuaGross, shergin

Differential Revision: D20656696

fbshipit-source-id: 10f02decb1dc969fd3491ac90d97f09e2bda59e7
2020-03-26 01:12:50 -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
Michael Bolin 0b9ea60b4f Back out "Upgrade Prettier from 1.17 to 2.0.2."
Differential Revision: D20639755

fbshipit-source-id: 5028563f9cf0527a30b4259daac50cdc03934bfd
2020-03-24 21:47:35 -07:00
Michael Bolin cf44650b3f Upgrade Prettier from 1.17 to 2.0.2.
Summary:
This gets us on the latest Prettier 2.x:
https://prettier.io/blog/2020/03/21/2.0.0.html

Notably, this adds support for TypeScript 3.8,
which introduces new syntax, such as `import type`.

Reviewed By: zertosh

Differential Revision: D20636268

fbshipit-source-id: fca5833d003804333a05ba16325bbbe0e06d6c8a
2020-03-24 20:24:47 -07:00
Oleg Bogdanov 79c69bea02 hermes | inspector | Don't include posix headers on non-posix systems
Summary:
Changelog: [Internal]

Hermes inspector includes pthreads, arpa and sys headers on all OSes that would break vanilla Windows builds. This diff adds a check for posix-compliance before inclusion

(Note: this ignores all push blocking failures!)

Reviewed By: dulinriley

Differential Revision: D20564449

fbshipit-source-id: 8e264bc3104065dc4315bb291e8560609fe65184
2020-03-24 18:53:43 -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
Ramanpreet Nara 39aae1038b Perflogger codemod manual changes
Summary:
Just includes the manual changes to get the perf logger moved to the ObjCTurboModule constructor.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D20498443

fbshipit-source-id: e607588f47ccc8ae199cd97043b09dfaff7a72dd
2020-03-18 11:01:15 -07:00
Ramanpreet Nara 9c4eb14213 Pass PerfLogger to ObjCTurboModule constructor
Summary:
Previously, I had logic inside `RCTTurboModuleManager` to attach the `id<RCTTurboModulePerformanceLogger>` to the `ObjCTurboModule` object

```
/**
 * By default, all TurboModules are long-lived.
 * Additionally, if a TurboModule with the name `name` isn't found, then we
 * trigger an assertion failure.
 */
auto turboModule = [strongSelf provideTurboModule:moduleName];

/**
 * TODO(T63718299): Move this setter into the ObjCTurboModule constructor
 */
if (performanceLogger) {
  if (auto objCTurboModule = std::dynamic_pointer_cast<facebook::react::ObjCTurboModule>(turboModule)) {
    objCTurboModule->setRCTTurboModulePerformanceLogger(performanceLogger);
  };
}
```

This diff removes that logic in `RCTTurboModuleManager`, and it also removes `ObjCTurboModule::setRCTTurboModulePerformanceLogger`. Henceforth, we'll instead pass the `id<RCTTurboModulePerformanceLogger>` into `ObjCTurboModule`'s constructor. I've made all the necessary changes to the codegen scripts in this diff as well.

This should also resolve T63903079 by simply eliminating the code that's crashing production FB apps.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D20480971

fbshipit-source-id: c3899981f880aa5d1354b5c3f4018c8fd57c3bae
2020-03-18 11:01:15 -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 44618c80ed Revert D20464278: Make Lambda function called in NativeModule mutable to improve performance
Differential Revision:
D20464278

Original commit changeset: 846a8bc6c61c

fbshipit-source-id: 71b69687ab3c279ec4e14f633700355af2291705
2020-03-16 16:21:28 -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
maschad 5290047d09 Make Lambda function called in NativeModule mutable to improve performance (#28297)
Summary:
Fixes https://github.com/facebook/react-native/issues/28271
As explained by mmallet-youilabs , if the parameters passed to the `move` function are too expensive, this can have an impact on performance. Thus making these parameters captured by value mutable, the parameters are not movable.

## Changelog

[iOS] [Fixed] - Message
Pull Request resolved: https://github.com/facebook/react-native/pull/28297

Test Plan: Steps to reproduce (and expected results) are not applicable (unless running with a profiler).

Differential Revision: D20464278

Pulled By: shergin

fbshipit-source-id: 846a8bc6c61cb4aa21fbd96b419c3775190a2c84
2020-03-15 22:54:10 -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
Valentin Shergin ca35bfe597 Fabric: `traitCast` now return `nullptr` if the argument is `nullptr`
Summary:
This behavior matches the behavior of `dynamic_cast` (on which some callsites rely on).

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D20456792

fbshipit-source-id: 9604da0f9f78cc7357e60ed11012756e753e4b45
2020-03-14 10:17:20 -07:00
Samuel Susla 2394108e15 Fix FindNodeAtPoint newPoint calculation
Summary:
Changelog: [Internal]

Fix newPoint calculation. This bug was revealed when testing with JS inspector.

Reviewed By: JoshuaGross, shergin, mdvacca

Differential Revision: D20369654

fbshipit-source-id: d05aac5bbd408ef5bb0e8e92f0446e287d2854a0
2020-03-14 07:35:13 -07:00
Marc Horowitz 05c17c76da Add a little headroom to the stack when converting an exception JS -> C++
Summary:
This was causing an exception cascade leading to production
errors.  Added a test which repros the problem and passes with the
fix.

Changelog: [Internal]

Reviewed By: tmikov

Differential Revision: D20408858

fbshipit-source-id: 3fa9b8669bf3bf7617bfc05ef8f23d52bc969b4e
2020-03-14 00:13:29 -07:00
David Vacca 6a6590fbdf Fix bug in TextInlineViews when using a deep nested hierarchy of Text and Images
Summary:
This fixes a bug in Android TextInlineViews that was reproducible in ActivityLog screen, see T63438920

Since Text are virtual nodes it is not necessary for these kind of views to stack views during diffing.

changelog: [internal]

Reviewed By: shergin

Differential Revision: D20448085

fbshipit-source-id: 2d852975493bf6bcc7840c80c5de5cb5f7890303
2020-03-13 22:13:57 -07:00
Valentin Shergin ee88e72c02 Fabric: Removed unused leftovers from ViewShadowNode
Summary:
This method does not have implementation and we don't use it.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D20423392

fbshipit-source-id: cfb5e4a60dbeca26a968c29d20e74dd6af0bf660
2020-03-13 22:06:04 -07:00
Héctor Ramos 07def55396 fbshipit-source-id: da15f69185e724eaf7d4bc78dbc61fcdcb3074d5 2020-03-13 21:46:45 -07:00
Valentin Shergin 147f0f2eec Fabric: Unsetting `FormsStackingContext` trait for `ParagraphShadowNode` on Android
Summary:
Unsetting `FormsStackingContext` trait is essential on Android where we can't mount views inside `TextView`.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D20268038

fbshipit-source-id: e754bf1631a0c3147694fb6b34bb1d9e78148894
2020-03-11 22:45:28 -07:00
Valentin Shergin 4bfe94ac9d Fabric: Specifying the max possible order index value to TextShadowNode on Android
Summary:
We need that to move all `TextShadowNode`s to the end of the list of nodes to make view indexes work for nodes that actually have views.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D20396717

fbshipit-source-id: efbef47ef89ab37e83e020c029c39e1a62727fda
2020-03-11 22:45:27 -07:00
Valentin Shergin 8e3e0bd6a7 Fabric: Introducting `ShadowNode::getOrderIndex()`
Summary:
The diff introduces a new field in `ShadowNode` which defines in which order ShadowViews created from the node and its siblings will appear ShadowView tree. The feature will be used to overcome some platform limitations (e.g. on Android) on the mounting layer (it will be able to move some nodes of some time to the end (or beginning) of the list) and build features like zIndex ordering in C++ core.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D20396718

fbshipit-source-id: 16aef7c2b5511c874341ab7554e5585b2cdc356f
2020-03-11 22:45:27 -07:00
Valentin Shergin 8fb0eefb78 Fabric: Using move semantic in Differentiator
Summary:
This diff changes how we pass lists of nodes to `calculateShadowViewMutations`: previously we passed that as `const &` and now we pass them as rvalue references because we will need to mute them in the future diffs.

This diff also adds a `static_assert` to ensure that the lists are movable.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D20353754

fbshipit-source-id: 0c3383bff6ded8a49d1ac003fce8919d3906b5bb
2020-03-11 22:45:27 -07:00
generatedunixname89002005287564 1dc82a89d7 Daily `arc lint --take CLANGFORMAT`
Reviewed By: zertosh

Differential Revision: D20383094

fbshipit-source-id: 1dc497a98fd3b5962542735c5243d7ac9cd40da3
2020-03-11 21:41:04 -07:00
Marc Horowitz 409c276474 Remove remaining external references to JSC
Summary: Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D20319757

fbshipit-source-id: 4ac3952175fd1b78957b01de279135af122d5bf1
2020-03-11 21:13:01 -07:00
Ramanpreet Nara 99ceb6afba Introduce RCTTurboModulePerformanceLogger
Summary:
In production, we'd like to be able to track the performance metrics of TurboModules. So, I'm introducing a new protocol called `RCTTurboModulePerformanceLogger`. It allows the application to be notified at points during stages of TurboModule creation, and TurboModule method invocation.

**Why can't we use `RCTPerformanceLogger`?**

`RCTPerformanceLogger` is meant to be used to profile RN initialization. It supports a fixed list of markers. Each marker has a type, and there can only be one instance of it. This isn't suitable for logging events in the TurboModule system.

Reviewed By: mdvacca

Differential Revision: D20310976

fbshipit-source-id: a49251b325c94f912cd35ab1cd8fc010f2cfc08f
2020-03-10 19:59:34 -07:00
Ramanpreet Nara 1c1fa5b909 Make main queue setup synchronous
Summary:
This can cause a deadlock if the main thread synchronously calls into some JS that creates a TurboModule. However, this is also the behaviour of legacy NativeModules. Furthermore, this also greatly simplifies how we'll fix async method invocation in TurboModules: T55255146.

Changelog:
[Internal]

Reviewed By: fkgozali

Differential Revision: D20364251

fbshipit-source-id: d0db85665506f08c51c2f33a123e69960923e7f3
2020-03-10 19:59:33 -07:00
Valentin Shergin 0d6d58656a Fabric: EmptyLayoutMetrics does not contain invalid values anymore
Summary:
Before this change, fields of EmptyLayoutMetrics have some "invalid" values to allow us to compare equal them individually and get `false`. Turned out that having invalid values there might break some serialization layers, which is no good.
This change fixes that and adds explicit check for EmptyLayoutMetrics before running a comparison of individual fields.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D20324881

fbshipit-source-id: ab8e2a402f6bdfb393fc9b6789decb526fa94dfa
2020-03-10 17:00:41 -07:00
Valentin Shergin 507379f6fa Fabric: Support for Inline Views in Paragraph component
Summary:
Final diff that implements Inline Views in `Paragraph` component.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D20268045

fbshipit-source-id: 9a0093eacb9ae34890f6137b308550547a3bcb38
2020-03-10 08:16:40 -07:00
David Detlefs 07c4980267 Add unit test for multiple levels of DecoratedHostObject.
Summary:
I was unsure how, or if, DecoratedHostObjects worked.  Marc had created the linked task to make sure that things worked right with multiple levels of decorated host objects.  I decided to do that, thinking it would show a bug; instead it showed me that the pattern did work, and let me figure out how.

Changelog: [Internal]

Reviewed By: mhorowitz

Differential Revision: D20263797

fbshipit-source-id: 8bbe71cba1b6ef5b2673566759112320dd1894b8
2020-03-09 22:08:00 -07:00
Adam Ernst 0c7bd388f0 Rename get_debug_preprocessor_flags
Summary:
The new name is get_preprocessor_flags_for_build_mode.

Changelog: [Internal]

Reviewed By: d16r

Differential Revision: D20351718

fbshipit-source-id: 67628ce81e7244f0f72af2d00d92842a649ff619
2020-03-09 18:28:27 -07:00
Valentin Shergin 02f2c81240 Fabric: Proper way to specity layout constraints for root Yoga node
Summary:
This diff changes how we apply layout constraints to a root node before layout. We previously used two arguments of `YGNodeCalculateLayout` but that's not expressive enough in cases we have min & max sizes.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross, sammy-SC

Differential Revision: D20268051

fbshipit-source-id: 85aaae65326432993296c3cbc9f7fb8919b07386
2020-03-09 16:36:47 -07:00
Valentin Shergin 0d33cdf146 Fabric: New `LayoutableShadowNode::measure(...)` which measures the node "outside"
Summary:
This diff introduces a new method of `LayoutableShadowNode` called `measure`. The purpose of the method is to measure the node from an "outside" perspective (including paddings and so on). The existing method with the same name (but with slightly different signature) will be renamed to `measureContent` in future diffs.
Hense we will have two `measure*` methods:
 * `measureContent` measures nested content of the node;
 * `measure` measures the node (outside).

This diff also introduces a default implementation of a new measure that uses `layoutTree` under the hood.

Measures the node with given layoutConstraints and layoutContext.
The size of nested content and the padding should be included, the margin should *not* be included.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross, sammy-SC

Differential Revision: D20268047

fbshipit-source-id: 29c28cf16c5afe24f1bfb6e76c42816d4583a8fa
2020-03-09 16:36:47 -07:00
Valentin Shergin 90ada5abb1 Fabric: Calculating positions of attachments as part of text measurement
Summary:
This diff changes API we use to measure text. Previously, a platform-specific measure infra returned just the size of the text, now it returns the size and an array of frames that describe where attachments are placed.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D20268041

fbshipit-source-id: 7c065607b6af18a36318db0aab24dad0f171d33a
2020-03-09 16:36:46 -07:00
Valentin Shergin d1ad29b7db Fabric: Introducing `ParagraphShadowNode::Content`
Summary:
`ParagraphShadowNode::Content` describes all nested content of a `Paragraph` component as a single entity allowing to reason about that as a thing that holds an invariant. Now we can store that as a single thing, copy, pass to functions, build on top of that and etc.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC, mdvacca

Differential Revision: D20268043

fbshipit-source-id: e976588ad76615259c72bc21f9ad8d923f2f3b9f
2020-03-09 16:36:46 -07:00
Valentin Shergin 2508c46a75 Fabric: More `assert`s in YogaLayoutableShadowNode
Summary:
These `assert`s must be satisfied. Having them allows us to fail early in case of bugs.
I spent a log of time debugging an issue and finally found that after adding those `assert`s.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D20268046

fbshipit-source-id: 1d8ddd6de00069bd2a79e74af5e4278aa6c9131b
2020-03-09 16:36:45 -07:00
Valentin Shergin b5aaa25b9e Fabric: De-virtualizing `LayoutableShadowNode::setLayoutMetrics()`
Summary:
Removing `virtual` qualifier for `LayoutableShadowNode::setLayoutMetrics()`. Original design implied that some subclass might override that method to provide additional functionality but we never used that and seems not it does not much the overall design: we store `layoutMetrics` *inside* `LayoutableShadowNode`.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D20268042

fbshipit-source-id: 2aa9b3da316b97f26493fb04d19ca8290bd5d2a6
2020-03-09 16:36:45 -07:00
Valentin Shergin 2a61c4ec53 Fabric: `roundToPixel<>()` convenience functions
Summary:
A bunch of convenience functions for rounding float values to be aligned to the device pixel grid. We had something like this on iOS, now we need to have that in xplat C++ code.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D20268044

fbshipit-source-id: 980b61c793eaeafb160e2b3c1d9742402800cd47
2020-03-09 16:36:45 -07:00
Valentin Shergin e1b8841c7a Fabric: non-const `AttributedString::getFragments()`
Summary:
This diff adds a non-const method to AttributedString that allows accessing a list of fragments by reference.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D20268040

fbshipit-source-id: cd0c8be126607b99686f7f596106b38fbe3da230
2020-03-09 16:36:44 -07:00
Valentin Shergin f18358dda6 Fabric: Introducing `BaseTextShadowNode::getAttributedString()`
Summary:
`BaseTextShadowNode::getAttributedString()` was replaced with simular method `BaseTextShadowNode::buildAttributedString()` which does same work with following differences:
* Besides returning `AttributedString`, it retures an array of `Attachment`s elements of which points to `ShadowNode`s that form attachments;
* Now we use single `AttributedString` to construct result instead of concatenation objects recurvily walking the tree.

We will use the array of attachments later.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D20268048

fbshipit-source-id: 371c548826bdfd5c4f4b18915d68977724885ce6
2020-03-09 16:36:44 -07:00
Jesse Katsumata 42c1957aff chore: fix typo in comments (#28269)
Summary:
Fixed some typos in the comment.

## Changelog

[Internal] [Fixed] - Fixed typo in the comments
Pull Request resolved: https://github.com/facebook/react-native/pull/28269

Test Plan: Changes are only made in the comments, so test is not necessary.

Reviewed By: cpojer

Differential Revision: D20342637

Pulled By: shergin

fbshipit-source-id: f6e7dd538ee54c43e1570c35e1f8c4502054e328
2020-03-09 15:37:33 -07:00
Samuel Susla f96dc274d1 FindNodeAtPoint now accounts for scrollView offset
Summary:
Changelog: [internal]
FindNodeAtPoint was not taking transform into account.

Reviewed By: JoshuaGross

Differential Revision: D20288026

fbshipit-source-id: a8ff09bc265de983e42610c5d23837a2000f9dd2
2020-03-09 05:57:20 -07:00
Samuel Susla d6484fa180 Add TextKind trait to ParagraphShadowNode and TextInputShadowNode
Summary:
Adds `TextKind` trait to Paragraph and TextInput shadow nodes.

Later on it could cause confusion why they do not have this trait.

Changelog: [Internal]

Reviewed By: shergin, mdvacca

Differential Revision: D20254008

fbshipit-source-id: 56fb264fa4fe38a5f00f080558cdc7992fd51fea
2020-03-09 05:51:27 -07:00
Samuel Susla 138ade0117 Add transform*rect and transform*size operators
Summary:
Adding 2 `transform*rect` and `transform*size` operations.
Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D20304247

fbshipit-source-id: 7bde67c96a21ce15e9da0464bcfccc61ab8fe13d
2020-03-09 04:56:39 -07:00
Valentin Shergin a426c8dc77 Fabric: Using `(un)wrapManagedObject` in TextLayoutManager
Summary:
Investigating a crash, I spend half of an hour staring at `__bridge`, `__bridge_retained`, `CFRelease` and etc trying to understand is there a bug or not. Even if I think there was no bug there, it should not be this way. We have a nice abstraction around that madness we should use to make the code obvious.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D20260917

fbshipit-source-id: 2b511ebf46a78950c4720e749099134aed1dd890
2020-03-08 21:31:54 -07:00
Jon Thysell (JAUNTY) 460c698e5f Fix MSVC build break in VS 2019 (#28253)
Summary:
Updating react-native-windows to build with Visual Studio 2019 and the v142 toolset.

## Changelog

[Internal] [Fixed] - Fix MSVC build break in VS 2019
Pull Request resolved: https://github.com/facebook/react-native/pull/28253

Test Plan: No real change, only adding a missing include for `stdexcept`.

Reviewed By: cpojer

Differential Revision: D20321273

Pulled By: shergin

fbshipit-source-id: ffe8b4d3a96ce4ed1db303020d77a806637e88bc
2020-03-08 21:18:48 -07:00
Joshua Gross c18cc76e58 Comparison of AttributedString false more often than true in TextInput, resulting in janky editing behavior
Summary:
Instead of comparing the entire AttributedString, compare just the strings and the TextAttributes of Fragments.

Concretely what I'm seeing is that the Frame of the associated parent ShadowViews are changing very frequently, making it impossible to actually modify the TextInput in some cases. However, we shouldn't forcibly reset the content of the TextInput if the frame of the parent is changing and not the actual child contents.

Changelog: [Internal] Fabric TextInput bug fix

Reviewed By: shergin

Differential Revision: D20319359

fbshipit-source-id: 2f51f521ad76fff9da6f6c8b5e795f03c33e496f
2020-03-06 19:37:27 -08:00
Joshua Gross 83c76c257c Fix T61647031 - color comparison causing TextAttribute color to not update ParagraphState
Summary:
As documented in T61647031, Text colors were sometimes not being updated because the ParagraphState was not always updating with a new AttributedString.

Turns out, it's because the equality comparator for Color had not been implemented, and so State was not being set in some cases.

The confusing part is that now color comparisons return true **more often** than before (if you're comparing two smart pointers of opaque data without a custom comparator, in theory I assume they're comparing pointer values and returning false way more often... but maybe my understanding is off). This distracted us for a while in finding an other ~fairly simple solution.

We should keep this in mind if we experience other, similar issues with text attributes not updating.

Changelog: [Internal] Fabric

Reviewed By: mdvacca

Differential Revision: D20300307

fbshipit-source-id: 13d86495f4c4ef8a0219fec66d39a49b4f7e6c2a
2020-03-06 12:39:34 -08:00
Riley Dulin 48001c597e Add call to collectGarbage for JSIExecutor::handleMemoryPressure
Summary:
Someone pointed out in this Github issue: https://github.com/facebook/react-native/issues/27532
that the memory pressure warning from Android was being ignored, when it can easily
be used to start a garbage collection on the JS runtime.

Changelog: [Internal] Add a memory pressure handler for jsi::Runtime

Reviewed By: mhorowitz

Differential Revision: D20072943

fbshipit-source-id: 869a14068aa02bd378e8b26d8c18b76a5d0f7bc0
2020-03-05 18:15:38 -08:00
Valentin Shergin 22fdb8bb05 Fabric: Fixed UI jankiness caused by changes in flattening
Summary:
It's not clear why exactly but seems in some cases, for some views the hierarchical relationship between views is required (when it should not be conceptually). Turning this feature off for Android for now.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D20292833

fbshipit-source-id: 1aab8468cedeb5c1440a95944be7eca3216e0db0
2020-03-05 17:29:08 -08:00
generatedunixname89002005287564 d1018e0414 Daily `arc lint --take CLANGFORMAT`
Reviewed By: zertosh

Differential Revision: D20278397

fbshipit-source-id: 2188283cd01d0d9d9d5b3995bd8d3f1fd687ad55
2020-03-05 08:27:36 -08:00
Joshua Gross 43e6d9acd7 TextInput should respect previous props, paddingHorizontal, and paddingVertical
Summary:
Of course if props aren't changing, rawProps won't have paddings anymore and so padding gets reset.

Also, make sure we pay attention to paddingVertical and paddingHorizontal styles.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D20269583

fbshipit-source-id: 2903fd0f7e6178f506109467d9a8f67b6d013a25
2020-03-04 20:01:24 -08:00
Will Holen f1a9ca04f6 Support CDP returnByValue in Hermes Inspector
Summary:
This adds support for 'returnByValue' in Runtime.evaluate invocations.
If the result of the evaluation can't be serialized to JSON, the results
are undefined.

ChangeLog: [Internal] - Hermes Inspector now supports 'returnByValue' in CDP Runtime.evaluate calls

[Facebook]
This is change was made to support debug completion in VSCode for ReactVR.

Reviewed By: ArchDev

Differential Revision: D19961115

fbshipit-source-id: d20af82b35d6bde88ab74b5c5a4c07415122c142
2020-03-04 16:28:45 -08:00
Valentin Shergin 4f3e3f8cc1 Fabric: Tweaking view flattening algorithm to rely on new traits instead of `LayoutableShadowNode::isLayoutOnly()`
Summary: Now, following the previous diff, we remove `LayoutableShadowNode::isLayoutOnly()` and change the view flattening algorithm to rely on two new traits. See the previous diff to learn more about how it works.

Reviewed By: sammy-SC

Differential Revision: D20212252

fbshipit-source-id: 87a07e8bb17b2e66e5703f107dc35ca7a8e49634
2020-03-04 12:33:03 -08:00
Valentin Shergin b5117bf6ea Fabric: New two ShadowNode Traits: FormsStackingContext & FormsView
Summary:
This diff introduces two new `ShadowNodeTrait`s that we will use in the future in the new (slightly tweaked) view-flattening algorithm. (Note: this diff does not enable the new flattening, it's just preparation.)
The idea is that we split the notion of `isLayoutOnlyView` into two traits:
* `FormsView`: `ShadowNode`s with this trait must be represented as `ShadowView`s. Normal "visible" ShadowNodes will have this trait, but "layout only views" in old nomenclature will not.
* `FormsStackingContext`: `ShadowNode`s with this thread not only must be represented as `ShadowView`s but also have to form a "stacking context" which means that their children must be mounted as `ShadowView`'s children.

Our implementation does not exactly follow W3C spec in terms of sets of props that create the stacking context (because of historical reasons and mobile specifics) but ideologically it's the same. We start from the very conservative implementation where only views with background-color and borders do not form stacking context and then we probably extend that to more props.

Most importantly for us now, we will enforce the absence of ``FormsStackingContext` for `ParagraphShadowNode` and the presence of `FormsView` for `TextShadowNode` on Android where it's essential for mounting layer.

Read more about stacking context here: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D20212253

fbshipit-source-id: 0fbaee214ce2c5886cb0232843a2a3c7bb20655d
2020-03-04 12:33:03 -08: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 899b314ca2 Back out "Pass layoutContext to Yoga's MeasureCallback"
Summary:
Passing `layoutContext` to yoga crashes fb4a-64. Until I have a solution let's back this out.

Original commit changeset: 9df7da4bef8c

Changelog: [Internal]

Reviewed By: makovkastar

Differential Revision: D20246917

fbshipit-source-id: 220744fde9f74e8157fc0714c63639b01152e4ab
2020-03-04 05:01:54 -08:00
Samuel Susla 3ee1e5312a Back out "Rename measure to measureContent and pass it LayoutContext"
Summary:
Original commit changeset: 8928b59d5194

Changelog: [Internal]

Reviewed By: makovkastar

Differential Revision: D20246918

fbshipit-source-id: 0b9142d9bc4774a07304769126411a34cc8c33c5
2020-03-04 05:01:53 -08:00
Samuel Susla 74034ba23a Back out "Font size in Text now respects preferredContentSizeCategory"
Summary:
Original commit changeset: 3965a127069a

Changelog: [Internal]

Reviewed By: makovkastar

Differential Revision: D20246919

fbshipit-source-id: d2238f279f44ac4394557949c8f148f08a60647e
2020-03-04 05:01:53 -08:00
Valentin Shergin 0baac1ccfc Fabric: Improvements in Diffing test (`messWithLayotableOnlyFlag`)
Summary:
Now we tweak more props in order to prepare for new flattening algorithm.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D20212254

fbshipit-source-id: 7391155072f93046e78fbecf4bb4b42cb1caacdc
2020-03-03 23:35:25 -08:00
Valentin Shergin 903bf2de21 Fabric: Removing `const` qualifier from AccessibilityProps fields
Summary:
This is a part of migration staterted in D19390813.
There is no need to have those as const. The whole *Props object is usually const (and when it's not, props should not be too).
Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D20212255

fbshipit-source-id: 87f3d8e7a94c6626bd9b0fc304f75e915dd73d4c
2020-03-03 23:35:25 -08:00
Valentin Shergin b8c17dd7c0 Revert D19965405: Fabric: Small improvements in Differentiator/TinyMap
Differential Revision:
D19965405

Original commit changeset: 92eedf38d55b

fbshipit-source-id: 92073ca877899e2a607f283275f0d7c894dd4720
2020-03-03 16:39:31 -08:00
Samuel Susla 58347677f9 Back out "UIManager.findNodeAtPoint now returns shadowNode instead of instanceHandle"
Summary:
Original commit changeset: bd2a1bcd26ab

changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D20196869

fbshipit-source-id: 53235dc3475d79f9e3545c9aa42171f23137be5a
2020-03-03 04:22:00 -08:00
Samuel Susla 08dda02347 Font size in Text now respects preferredContentSizeCategory
Summary:
Changelog: [Internal]

Use LayoutContext to pass `fontSizeMultiplier` down to ParagrapShadowNode.

Reviewed By: shergin

Differential Revision: D20184596

fbshipit-source-id: 3965a127069a21328ed19cb3f9732f0a2d1c4d58
2020-03-03 04:14:04 -08:00
Samuel Susla b40f0562f5 Rename measure to measureContent and pass it LayoutContext
Summary:
In order to build dynamic text sizing, `LayoutableShadowNode::measure` needs to accept `LayoutContext`

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D20184598

fbshipit-source-id: 8928b59d51948caf3654f40049212a89a91dceb6
2020-03-03 04:14:04 -08:00
Samuel Susla d98a229202 Pass layoutContext to Yoga's MeasureCallback
Summary:
In order to build dynamic text sizing, we need to pass layoutContext to `yogaNodeMeasureCallbackConnector`

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D20184597

fbshipit-source-id: 9df7da4bef8cbad3bc87d63ed0c5aa5f420dbc11
2020-03-03 04:14:04 -08:00
Valentin Shergin b41307af77 Fabric: Small improvements in Differentiator/TinyMap
Summary:
What's changed:
 * `end()` now returns the pointer to the imaginary element after the very last one (which is aligned with STL);
 * `erase()` now swaps the removing and the last elements and shrinks the size of an array.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D19965405

fbshipit-source-id: 92eedf38d55be35a0d9ab6120634b51c8d6e4674
2020-03-02 23:03:01 -08:00
Valentin Shergin 11948bb4b6 Fabric: Removing `TimeUtils.h`
Summary:
We don't use it anymore (we switched to `std::chrono`).

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D20201214

fbshipit-source-id: 0c464223822b78c99ed7ff60d926e84a675f2612
2020-03-02 20:11:29 -08:00
David Vacca bf0019e433 Do not flatten views with PointerEvents props
Summary:
Some of the values of pointer events should be propagated across the hierarchy of views, e.g. the pointerEvent value NONE: https://reactnative.dev/docs/view#pointerevents
That mean that we can't flatten these views (or we should propagate these values across alll the hierarchy of a view that is being flatten)
For now I'm going to prevent these views to be flatten, this behavior is consistent with the Adroid view flattening algorithm:
https://our.intern.facebook.com/intern/diffusion/FBS/browse/master/xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewProps.java?commit=1144adb5b45bf9a8c8cedf4ac86a2e9ccb429815&lines=249

changelog: [internal]

Reviewed By: shergin

Differential Revision: D20180804

fbshipit-source-id: 1fe7fc99c873a28c077b3859f8a7884d38b6d4d8
2020-03-01 14:11:56 -08:00
Valentin Shergin 490e33dd88 Fabric: Fixed memory leak caused by retain cycle in BaseTextShadowNode
Summary:
Clearing `props` and `state` (which we don't use) allows avoiding retain cycles.

The memory leak was caused by a retain cycle:
AttributedString -> Fragment -> ShadowView -> PharagraphState -> TextLayoutManager -> Cache -> AttributedString.

We don't use `props` and `state` parts of `ShadowView` inside `AttributedString`.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D20182791

fbshipit-source-id: 2ddc5d53a1cb594e3d1cc39933e8958eb6425389
2020-03-01 12:32:00 -08:00
David Vacca 17a62b72b7 Serialize and de-serialize text attachments for Android
Summary:
This diff implements serialization and deserialization of text attachments as part of the calculation of layout of text components
changelog: [internal]

Reviewed By: JoshuaGross

Differential Revision: D20087251

fbshipit-source-id: dbcbd22f856aadace14343205548154ea80c8464
2020-02-28 22:43:14 -08:00
Kevin Gozali 30822e3923 make RN infra labels public
Summary:
Internal build target labeling.

Changelog: [Internal]

Reviewed By: zlern2k

Differential Revision: D20152676

fbshipit-source-id: 89615a0b3a6f3994b18f2c07b86d0ae93e052327
2020-02-28 12:46:49 -08:00
Samuel Susla 85696298bf Fix yoga node owner getting out of sync with children
Summary:
Changelog: [internal]

# Problem
We have node A with N children.

Calling cloning constructor on `YogaLayoutableShadowNode` causes new `yogaNode_` to be created.
However if `fragment.children` is nil in cloning constructor, which basically says children were not changed, then the existing children's `owner` becomes invalid.

# Solution
In the clone constructor, always call `updateYogaChildren`. This updates yoga children with the new `owner`.

Reviewed By: JoshuaGross

Differential Revision: D20139582

fbshipit-source-id: 3932694d4381b601df07dd8a57887ce7c09f1582
2020-02-28 06:17:55 -08:00
Valentin Shergin 061f54e890 Fabric: `AttributedString::operator==()` now checks `layoutMetrics` for being equal
Summary:
The sizes of attachments are legit parts of `AttributedString`s identity, so we need to incorporate it into the equality test.
We need that to make measurement cache work correctly with inline views.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D20151505

fbshipit-source-id: ae47c24a753eab1e497fcfaa93de557ffb30d874
2020-02-27 21:47:49 -08:00
Valentin Shergin 6f4d362887 Fabric: Providing correct `pointScaleFactor` in `YogaLayoutableShadowNode::layoutTree`
Summary:
The previous implementation didn't do it, which was incorrect.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D20151493

fbshipit-source-id: ce4b916dbf8f6469b37dfa8ec3bab8cafcf87940
2020-02-27 21:47:49 -08:00
Valentin Shergin dbc35267a0 Fabric: Removing unnecessary code fragments
Summary:
Those `true &&` code fragments don't look intentional.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D20135541

fbshipit-source-id: a7f2a99b2cbcd82023ec40c6b6211ad4f91d65a4
2020-02-27 09:46:29 -08:00
Héctor Ramos 8ae3174873 Run clang-format and apply patches
Summary:
Run clang-format and add .clang-tidy with `clang-diagnostic-*` to several more directories in order to catch any problems.

Changelog:
[Internal]

Reviewed By: shergin

Differential Revision: D19860169

fbshipit-source-id: 7785aab010c8e6945cc6b5c9b68cb8ee0cdbb7fa
2020-02-27 08:29:30 -08:00
Nick Gerleman 427ba359e0 Stamp React Native Version Into C++ Code (#28036)
Summary:
The PlatformConstants native module exposes the ability to query the React
Native version used to build native code. This is managed on iOS and Android by
a version bumping script, which replaces module code based on a template.

It is currently difficult to accurately determine this version for out-of-tree C++
platforms (I.e. React Native Windows). The version of upstream react-native we resolve to is ultimately
dependent on the version of react-native chosen a peer dependency, which is not
neccesarily constant given a build of react-native-windows.

We could try to hack around this, and make our native build try to reason about
the resolved pacakge for react-native using a lockfile, but a much cleaner
solution is to embed version into C++ code, similar to what is done for Android
and iOS. This change does that, adding a header with React Native version and
updating the build stamping script to write to it.

Usage sample:

```c++
  constants["reactNativeVersion"] = folly::dynamic::object();
  constants["reactNativeVersion"]["major"] = ReactNativeVersion.Major;
  constants["reactNativeVersion"]["minor"] = ReactNativeVersion.Minor;
  constants["reactNativeVersion"]["patch"] = ReactNativeVersion.Patch;
```
## Changelog

[General] [Added] - Stamp React Native Version Into C++ Code
Pull Request resolved: https://github.com/facebook/react-native/pull/28036

Test Plan: Validated that the bumping script will accurately update the header, can compile under both MSVC and Clang.

Differential Revision: D19865992

Pulled By: hramos

fbshipit-source-id: 9e0b8e9519015bb62c60b9935a234cd367a1926a
2020-02-27 06:42:14 -08:00
Valentin Shergin 1aab70d0e2 Fabric: `RootShadowNode::clone` was renamed/moved to `ShadowNode::cloneTree`
Summary:
Cloning subtrees is not something specific to a RootNode, so it makes sense to have it in ShadowNode. Soon we will use that to clone subtrees inside Paragraph component to implement Inline Views.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D20090666

fbshipit-source-id: 0a64ef9bda438cd55d5fd21d3ad83b36221fa89e
2020-02-26 22:08:22 -08:00
Valentin Shergin 011b470961 Fabric: Introducing `LayoutableShadowNode::layoutTree`
Summary:
All logic that is performed on the root node only was moved from `layout` to a separate methods `layoutTree`. That makes the code simpler and allows reusing `layoutTree` in InlineViews feature.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D20052025

fbshipit-source-id: 3070a1cca4e322c6d077ede751ea80359c96a600
2020-02-26 22:08:22 -08:00
Valentin Shergin 1801d63de2 Fabric: Deleting `YogaLayoutableShadowNode::getYogaLayoutableChildren`
Summary:
We don't use it anymore.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D20052019

fbshipit-source-id: b829e7bbf0768588c2f0f28c59bf8f85054408b7
2020-02-26 22:08:22 -08:00
Valentin Shergin 6a88e94326 Fabric: `YogaLayoutableShadowNode::updateYogaChildren`
Summary:
Similar to a previous diff but for `setChildren`.
`YogaLayoutableShadowNode::setChildren()` was renamed to `YogaLayoutableShadowNode::updateYogaChildren()`. Now we don't need to pass an argument to this function because the object is already initialized. The new name also disambiguates this method with `getChildren()` from `ShadowNode` (which does something completely different). The rest of the changes is just type adjustments.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D20052031

fbshipit-source-id: 6157cad9b55d4cdd97ce04e1278ac1369bfb96bc
2020-02-26 22:08:21 -08:00
Valentin Shergin 191d65ec4e Fabric: `YogaLayoutableShadowNode::setProps()` was replaced with `updateYogaProps()`
Summary:
`YogaLayoutableShadowNode::setProps()` was renamed to `YogaLayoutableShadowNode::updateYogaProps()`. Now we don't need to pass an argument to this function because the object is already initialized. The new name also disambiguates this method with `getProp()` from `ShadowNode` (which does something completely different).

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D20052018

fbshipit-source-id: 4d9651bb4452408708fa1b36bb5c5c8639f7d1bb
2020-02-26 22:08:21 -08:00
Valentin Shergin 124c20b2b1 Fabric: Removing `ConcreteShadowNode::getChildrenSlice`
Summary:
We don't use it anymore.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC, mdvacca

Differential Revision: D20052028

fbshipit-source-id: 22c46b90d87b55465d3549c6de24393c33375833
2020-02-26 22:08:21 -08:00
Valentin Shergin 33bf310920 Fabric: YogaStylableProps now inherits Props
Summary:
How we can finally make `ViewProps` inherit `YogaStylableProps` and remove `dynamic_cast`. This overall change is aligned with D19963353.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D20052026

fbshipit-source-id: 1066f9a259b50d4672111c9c03a71c2590d59aca
2020-02-26 22:08:20 -08:00
Valentin Shergin 6d10310733 Fabric: Removing a couple of (ViewProps and YogaStylableProps) constructors
Summary:
Here we delete several constructors that were needed only because `YogaLayoutableShadowNode::yogaStyle` was private (which is not true anymore).

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC, mdvacca

Differential Revision: D20052033

fbshipit-source-id: c2afcaf2fdebb65cdcde6c214c8b78aa35d45e91
2020-02-26 22:08:20 -08:00
Valentin Shergin cdbc21132b Fabric: Refinement of `BaseTraits` chain
Summary:
Here we refine the `ShadowNode::BaseTraits` static method. Before this change, ConcreteViewShadowNode<> enforces Layoutable and YogaLayoutable traits. This change moves that responsibility to LayoutableShadowNode and YogaLayoutableShadowNode which makes overall logic more coherent.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D20052027

fbshipit-source-id: fd25264204b0232b1dbbff6f9dfefd9fbcb146c4
2020-02-26 22:08:20 -08:00
Valentin Shergin 0c50ba5376 Fabric: Moving logic from `ConcreteViewShadowNode` constructors to `YogaLayoutableShadowNode` constructors
Summary:
Now we can move custom to `YogaLayoutableShadowNode` code from `ConcreteViewShadowNode<>` template to `YogaLayoutableShadowNode` itself reducing the amount of templated code and reduce overall complexity.

Note, here we have to do `dynamic_cast` for now, we will address that in coming diffs.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D20052021

fbshipit-source-id: dac5969a97b75e54c7728a1ca8161922bd2245ca
2020-02-26 22:08:19 -08:00
Valentin Shergin 6f08c37633 Fabric: `getLayoutableChildNodes` was de-virtualized and moved to `LayoutableShadowNode`
Summary:
The fact that `LayoutableShadowNode` now inherits `ShadowNode` allows us to de-virtualize `getLayoutableChildNodes` and move that to `LayoutableShadowNode`. Less code, less virtual dispatch, less complexity.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D20052032

fbshipit-source-id: 580e86b5a746028e470788e00027f247bf77126c
2020-02-26 22:08:19 -08:00
Valentin Shergin 5bf6726bae Fabric: Stop using `getChildrenSlice` in ConcreteViewShadowNode
Summary:
D19963353 mentioned the infrastructure that re-routes methods calls related to adding and cloning children between YogaLayoutableShadowNode and ShadowNode. `cloneAndReplaceChild` is exactly this. It was implemented as a virtual method that is called from `ConcreteViewShadowNode`. The whole process requires building a list of children of some class and passing that as a list of pointers. Now we don't need it all that because we can call directly and statically. That change will allow us to simplify that infra even more in the future diffs.

With all previous changes, now we can implement `getYogaLayoutableChildren` inside `YogaLayoutableShadowNode` and call that statically. Eventually, that will allow us to remove templated `getChildrenSlice`. Previously the call for that method must be in `ConcreteViewShadowNode`, now it's not true anymore which we will use later to even better goodness.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D20052020

fbshipit-source-id: e5c819a4d21b2dbcd08f3439e1783e3a9cba5ef4
2020-02-26 22:08:18 -08:00