Commit Graph

1938 Commits

Author SHA1 Message Date
Will Holen 58f3673099 yarn upgrade msggen
Summary:
This upgrades the yarn.lock for msggen

Changelog: [Internal]

Reviewed By: avp

Differential Revision: D19199162

fbshipit-source-id: 8064a14032948fa81e3c7e637cfca1e02f5bfcd6
2019-12-20 11:40:40 -08:00
Samuel Susla f871bbada2 Cosmetic adjustments to ShadowNode::getAncestors
Summary:
Changelog: [internal]

Just cosmetic changes to code, shouldn't affect behaviour at all.

Reviewed By: shergin

Differential Revision: D19177494

fbshipit-source-id: b2e4d3d2cf0d30f40f2e2d950dd7a10dc7a5b5ea
2019-12-20 01:01:55 -08:00
Marc Horowitz a195447539 Handle errors building JSErrors better
Summary:
If building a JSError causes a JSError, this would lead to infinite recursion.  This changes the error handling path so the problem is visible to JS.  There's also a few related cleanups included, and a new test case.

Changelog: [General] [Fixed] - If Error global is not callable when building an error, jsi will throw a JS exception back to JS code. #158

Reviewed By: tmikov, dulinriley

Differential Revision: D18796269

fbshipit-source-id: 57a45d144fa2ea5e78d18c27d3130611737dda96
2019-12-19 21:33:18 -08:00
Will Holen 35dd2e0c37 Upgrade more msggen dependencies
Summary:
GitHub still marks some dependencies as vulnerable. Updating them.

Changelog: [Internal]

Reviewed By: avp

Differential Revision: D19183702

fbshipit-source-id: 9c9c815816c4fc591c77d811058234a63aeda727
2019-12-19 14:02:57 -08:00
Samuel Susla 61f7639d38 Fabric: Remove eventEmitter from ShadowNodeFragment
Summary:
As part of the plan is splitting ShadowNodeFragment into two parts. ShadowNodeFamilyFragment is already in place. This diff removes use of `ShadowNodeFragment::eventEmitter` and goes over all call sites to change it to `ShadowNodeFamilyFragment::surfaceId`.
Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D19146697

fbshipit-source-id: 22cae5404b0f3098feb86c0437a4aa256d5b773e
2019-12-19 13:48:22 -08:00
Samuel Susla 97f1c053b3 Fabric: Remove surfaceId from ShadowNodeFragment
Summary:
As part of the plan is splitting `ShadowNodeFragment` into two parts. `ShadowNodeFamilyFragment` is already in place. This diff removes use of `ShadowNodeFragment::surfaceId` and goes over all call sites to change it to `ShadowNodeFamilyFragment::surfaceId`.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D19115785

fbshipit-source-id: 5972332c3360b88ca935581ed36070f26e678b22
2019-12-19 13:48:22 -08:00
Samuel Susla f9c5bf8bee Fabric: Remove tag from ShadowNodeFragment
Summary:
As part of the plan is splitting `ShadowNodeFragment` into two parts. `ShadowNodeFamilyFragment` is already in place. This diff removes use of `ShadowNodeFragment::tag` and goes over all call sites to change it to `ShadowNodeFamilyFragment::tag`.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D19115781

fbshipit-source-id: 6ab3464a063c220d0924bf5a69b75449ca178650
2019-12-19 13:48:22 -08:00
Samuel Susla 90874d974f Fabric: ShadowNode now takes family as its constructor parameter
Summary: Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D19115780

fbshipit-source-id: 7a693b5eea7599dca3e4b737126fcbb26078894d
2019-12-19 13:48:21 -08:00
Samuel Susla bc9d50991a ShadowNodeFamily now accepts fragment in constructor
Summary:
`ShadowNodeFamily` now accepts ShadowNodeFamilyfragment as its constructor parameter.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D19115794

fbshipit-source-id: 95605398a8f6b54b5c6f196a22b8b6cadb18baad
2019-12-19 13:48:21 -08:00
Samuel Susla bd359ce257 Introduce new class ShadowNodeFamilyFragment
Summary: Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D19115782

fbshipit-source-id: 9c3b069dbbf2c3d7321dfc9fbd0e54ae4e485a32
2019-12-19 13:48:21 -08:00
Will Holen 389a91c9d9 Update msggen dependencies
Summary:
`msggen` has dependencies on some npm packages with vulnerabilities.
This diff updates the dependency list.

Changelog: [Internal]

Reviewed By: avp

Differential Revision: D19107926

fbshipit-source-id: 0526f6fe430c162322ec9ecb84f3d78604cd76bc
2019-12-18 15:06:53 -08:00
Joshua Gross bb5622dd89 Prop parsing: always require explicit default argument to convertRawProp
Summary:
Having automatic defaults/an optional arg for `convertRawProp` has caused way more problems than it is worth. Remove the default argument.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D19151594

fbshipit-source-id: 839ec8d138b2c3c083f221a2871582454004648c
2019-12-18 15:02:09 -08:00
Valentin Shergin b2f267ac3b Fabric: Propagation of ScrollView's contentOffset value down to ShadowNode layer on Android
Summary:
This implements propagation of ScrollView's contentOffset value on Android. That allows `LayoutableShadowNode::getRelativeLayoutMetrics` (and some measure functions) return values that take that info into  account.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D19027433

fbshipit-source-id: 023ff9642d023971b3d24d5cc5f7c2f4b443031e
2019-12-18 10:48:41 -08:00
Valentin Shergin c89ead313c Fabric: Proper implementation of ScrollView::contentOffset-aware measure functions (iOS only for now)
Summary:
This diff re-enables propagation of ScrollView's content-offset value down to the ShadowTree layer and enables measure fucntions opt-in incorporating this info to result.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: zackargyle

Differential Revision: D18981891

fbshipit-source-id: a6c0f4e690703b0ee07d45efab161750cfcc4b60
2019-12-18 10:48:40 -08:00
Samuel Susla 38af48d5fd Fix argument passed to method in TemplateViewComponentDescriptor
Summary:
Incorrect argument was being passed to `createShadowTreeFromTemplateProps`

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D19114167

fbshipit-source-id: c0d7d96e5cbf43cbdcf653ff19b4565fd44e9994
2019-12-18 07:49:20 -08:00
Valentin Shergin 2c30b5dde9 Fabic: Fixed typo in LegacyViewManagerInterop
Summary:
Just typo.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D19137124

fbshipit-source-id: f1d751a4ddf785453575a9beeb7e0152d33f9071
2019-12-17 18:26:49 -08:00
Valentin Shergin 44ff3f46a5 Fabric: Re-enabling RN_SHADOW_TREE_INTROSPECTION in DEBUG mode
Summary:
This diff reverts D15908765 where we disabled the introspection feature because we were afraid that it leaks into prod because of some sort of misconfiguration. Seems that wasn't the case.
We need to re-enable this to get some signals if it's broken.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D19104526

fbshipit-source-id: 696c0e68bb858da270dbbb5da11032e664d75659
2019-12-17 18:26:49 -08:00
Valentin Shergin 9e2e754555 Fabric: Removing a workaround from ComponentDescriptorRegistry
Summary:
We used that on iOS only before we had `ComponentDescriptorProviderRequest`. Now iOS does not use `_fallbackComponentDescriptor`.
On Android we still use `_fallbackComponentDescriptor` but set that explicitly via `ComponentDescriptorRegistry::setFallbackComponentDescriptor`.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D19103296

fbshipit-source-id: fb2a2142afb183145fd3c8e48f620cb3f316c0bb
2019-12-17 18:26:49 -08:00
Samuel Susla b02d516d7c Fabric: fix order of arguments for ShadowNodeFragment
Summary: Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D19109689

fbshipit-source-id: 6c7b477324376e95dac1c381e339a23f261a0d60
2019-12-17 03:43:35 -08:00
Kevin Gozali eb95b2f855 iOS Fabric: added support for image instrumentation [2]
Summary:
Passing thru image instrumentation activities to the image loader class, which now supports Fabric instrumentation.

Changelog: [Internal]

Reviewed By: mdvacca, voznesenskym

Differential Revision: D19047898

fbshipit-source-id: d12cb5a06a83e85347629a25e593d30cb9020fe6
2019-12-16 22:50:45 -08:00
Kevin Gozali 55142efd3a iOS Fabric: added support for image instrumentation [1]
Summary:
Added basic hook to enable image instrumentation. The hook passes information to the existing image loader, where instrumentation is done, specific for each app, if any.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D19047899

fbshipit-source-id: 6c013806cce98bcf1ea240d696a7ede9697e5cd9
2019-12-16 22:50:44 -08:00
Kevin Gozali 743074d09c iOS image: introduced RCTImageURLLoaderRequest for instrumentation/tracking purpose
Summary:
The `RCTImageURLLoaderWithAttribution` protocol historically only returns a cancellation block to cancel the url request. But for more complex instrumentation, we may need to associate a requestId for the specific URL request. To do this, the protocol now returns an object that has both the unique ID and the cancellation block, so that instrumentation logic can refer to the ID in the future.

Note that the `RCTImageURLLoader` protocol is unchanged, because the request ID is only relevant for instrumentation purpose.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D19047900

fbshipit-source-id: cd029f2470c32fc7bffd674b09a5353fe1dbc80b
2019-12-16 22:50:44 -08:00
Joshua Gross 5bc7f0441d Ensure that TextAttribute prop parsing in BaseTextProps uses proper defaults
Summary:
Motivation: in Marketplace, there's a TextInput in JS that sends { lineHeight: null } to C++. In Paper this was correctly handled as a default value, which just causes that property to not be set. In C++ in Fabric, it was being parsed incorrectly as 0 (because of incorrect defaults being passed into `convertRawProp`), causing the text to not be visible at all. The solution is to make sure that its default value is NaN, which is handled correctly, and causes the Text to render again.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D19128049

fbshipit-source-id: fe985428f3ed8b90d56cfa387fbc2d1476d19d36
2019-12-16 18:14:14 -08:00
Valentin Shergin 5e50d3141d Fabric: Fixed View::transform::scaleX/Y/Z property
Summary:
The coefficients in the code were incorrect: the default value of the scale should be 1, not 0.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sahrens

Differential Revision: D19101221

fbshipit-source-id: 3b4c3afc692ddb6bf32bf2344a77ec5ca34a06e4
2019-12-16 14:35:24 -08:00
Valentin Shergin ebdce9b3b0 Fabric: SafeAreaView does always not dirty Yoga node during cloning anymore
Summary:
Setting `padding` for Yoga node dirties it.
In the previous implementation, we did it for all newly cloned nodes. Now we do it only if State actually changes.

This is important because usually, SafeAreaView is a container node; that means that if some descendant of SafeAreaView changes its state,  the recloning of all nodes down to root node will cause dirtying  SafeAreaView and cause relayout if the whole subtree.

E.g., if we put ScrollView inside SafeAreaView without the fix, onScroll events will cause Yoga relayout (because ScrollView updates own state on debounced onScroll event).

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D18987158

fbshipit-source-id: a3130c607c37e54ce813113222cd4a3872c58b6a
2019-12-15 18:51:22 -08:00
Igor Sugak 399cabd1bb move chrome-devtools-protocol from xplat/third-party to third-party
Reviewed By: pixelb

Differential Revision: D16871230

fbshipit-source-id: e97710cf33a4ecee045595f1eb70021f275339e1
2019-12-13 17:30:18 -08:00
Valentin Shergin 294cf84469 Fabric: Debouncing insets value in SafeAreaView
Summary:
iOS/UIKit prop `safeAreaInsets` sometimes produces values (and calls `safeAreaInsetsDidChange`) that practically the same but differ just enough to make operator `==` return `false`. That causes an indefinite state update loop and dizzying of the interface.

We do the same in Paper component as well.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D18964089

fbshipit-source-id: 4c714d2554fdee0f6e999921f69b95676080b8fa
2019-12-12 12:53:13 -08:00
Valentin Shergin 5755129c19 Fabric: Conversion function between NSAttributedString and AttributedStringBox
Summary:
It's nice to have those conversions between NSAttributedString and AttributedTextBox in some utils module because:
An empty string must be stored as an empty C++ string, not like an empty NSAttributedString. That allows deferring this property from the object without accessing Objective-C runtime;
It's nice to hide some tedious Objective-C object wrapping/unwrapping boilerplate.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18950430

fbshipit-source-id: 842c202f243da17c47bc5cca9df6722cdcec07c5
2019-12-12 12:53:12 -08:00
Valentin Shergin 909b0fe0e7 Fabric: operator== and std::hash for AttributedStringBox
Summary:
That will allow building a custom caching table for boxed stings to cache text measurements for them in TextLayoutManager.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18950428

fbshipit-source-id: 8ceef29543dc6ed540043e32d65f3295030ae90f
2019-12-12 12:53:12 -08:00
Valentin Shergin 3b92d3187c Fabric: Exposing RCTNSTextAttributesFromTextAttributes as public function
Summary:
We need to use that outside of this file, in Fabric's TextInputComponentView to build `defaultTextAttributes` from C++ text attributes.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18950433

fbshipit-source-id: c48155f4340b7e9780c35f86ba5155e54f160be1
2019-12-12 12:53:12 -08:00
Valentin Shergin eb10d3e1d6 Fabric: Removing REACT_FABRIC_SYNC_EVENT_DISPATCHING_DISABLED macro
Summary:
When we designed the Fabric's event priorities we followed the model "let's assign all priorities to all events as they should theoretically be and create a flag that disables sync execution (because we were unsure that it's stable enough". After some experiments, it's clear that this model is not feasible. We realized that we were often not sure about the exact event priority that should be assigned to a particular event. We also realized that the priorities in web work differently compare to RN. And we are not sure how we should ensure ordering among events in different queues with different priorities.

At the same time, we want to use (or experiment with) sync events for in some cases when we sure about desired behavior and/or where async events make no sense.

This diff deletes the macro that disables sync priorities and explicitly assigns async priorities to events that previously had sync ones.

The actual behavior should not change.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18950431

fbshipit-source-id: 4033ef63d4e736075b525a693cd514d7b92d5bb0
2019-12-12 12:53:11 -08:00
Valentin Shergin 7cf43afa8d Fabric: Fixing an incorrect empty image placeholder for NSAttributedString attachment
Summary:
Same as D18048277 but for Fabric text infra.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: PeteTheHeat

Differential Revision: D18950415

fbshipit-source-id: 09701e261ecb871b3624260a36dd607fdb70e717
2019-12-12 12:00:47 -08:00
Eli White 39234e862e Fix order of arguments in Fabric measure
Summary:
These arguments were in the wrong order. It should be x,y,width,height,pageX,pageY. It was x,y,pageX,pageY,width,height.

Changelog:
[Internal]

Reviewed By: yungsters

Differential Revision: D18940318

fbshipit-source-id: ebd757648169b1ffbf33b35dded1d505a1c80974
2019-12-11 14:56:28 -08:00
Valentin Shergin 0cdc3b7016 Fabric: Making DebugStringConvertibleOptions a required parameter for all methods of static debug-printing infra
Summary:
Having those arguments optional does not really make anything easier to use; on another side that makes it hard finding problems caused by missing that parameter.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18797337

fbshipit-source-id: c119b8f6a03994072edb45e39337e33b0f8b602f
2019-12-09 15:37:59 -08:00
Joshua Gross 254ebab1d2 AndroidTextInput: don't set TextInput value to placeholder; use eventCounter prop to send tree updates via state
Summary:
Fix (1) placeholder (2) modifying TextInput in Fabric on Android.

Changelog: [internal]

Reviewed By: mdvacca

Differential Revision: D18894538

fbshipit-source-id: 21103f56e6f6e108fcf6359a23c9dd9a0323250e
2019-12-09 14:44:36 -08:00
Samuel Susla 5ee8202b26 Add missing accessibilityTraits in Fabric
Summary:
`accessibilityTraits` was missing, this diff adds it.

Also there is a name mis match, in javascript it is called `accessibilityRole`.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D18857668

fbshipit-source-id: 10656e8fb4e8c1d771a72c7f354b845e41cfc313
2019-12-09 06:41:27 -08:00
Valentin Shergin b1f2c1e2c5 Fabric: Disabling an assert in ComponentDescriptorProviderRegistry
Summary:
This temporarily disables an `assert` in `ComponentDescriptorProviderRegistry`. The `assert` only suggests that the call to the class is redundant, so it's safe to just remove it for now.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross, sammy-SC

Differential Revision: D18878273

fbshipit-source-id: 007a2c6f62f858126912b7e54a1098e6f4c25a16
2019-12-08 09:54:37 -08:00
Valentin Shergin 36d895ce21 Fabric: Enabling new TextMeasureCache thing for Android
Summary:
Read more about this in D18848583 (where it's implemented for iOS). This diff enables that for Android.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D18869823

fbshipit-source-id: ebdc863ec07268119d1cbbb911760532bb28ee04
2019-12-07 22:47:49 -08:00
Valentin Shergin 3aba90b58a Fabric: Workaround for mysterious crash in synchronouslyUpdateViewOnUIThread:props:.
Summary:
We are seeing some non-trivial amount of crashes happened because `[RCTSurfacePresenter synchronouslyUpdateViewOnUIThread:props:]` requests a Component Descriptor which does not register in the registry.
And the problem here is that ComponentDescriptors are not being designed to be used outside of C++ UIManager, and we only use that in RCTSurfacePresenter only because it's an old workaround that makes Native Animation Driver works with Fabric.

Messing with ComponentDescriptors are in general dangerous. Accessing them outside of UIManager means that they might be deallocated at any time, extending their lifetime will cause other crashes on the other side. So, that's why this is "BROKEN".

This diff does not make the code worse, it just designates the problem that was there for a long time, so it kinda makes it better.

We don't know for sure why some ComponentDescriptors are not registered but this diff at least makes it not crash in such case.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D18869651

fbshipit-source-id: 9d945ac7a2bd24a69a9bbb83b4fdd3cd19808f87
2019-12-06 17:58:35 -08:00
Valentin Shergin e08412d9a1 Fabric: Text Measuring: TextMeasureCache the new, improved text measure cache
Summary:
Special thanks for Joshua Gross for flagging this problem!

This diff implements a custom evicting hash map designed specially to hold text measurement information. The key feature of this is custom equality checks and hashing functions.

They are designed around the following principals:
* Decorative text attributes (such as color, shadows, etc) has no effect on layout, therefore they should not be taking into account;
* `minimum height`, `minimum width`, and `maximum height` don't affect the measurement;
* the value of `layout metrics` are important only for `attachment` fragments.

After I redo all tests, I will enable this for Android-specific TextLayoutManager in separate diff.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18848583

fbshipit-source-id: 46c2fc445fbd1823afc5e7498e37de75381258b1
2019-12-06 10:54:13 -08:00
Valentin Shergin 1a12919dea Fabric: Text Measuring: Using unlimited height during text measuring
Summary:
In the previous diff, we noted that the maximum height is not really important for text measurement. That diff make is in code.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18848585

fbshipit-source-id: 5fe0ea8f76487a50baa8a2e024663a85afcd9861
2019-12-06 10:54:13 -08:00
Valentin Shergin c9b9c93c90 Fabric: Text Measuring: Doing clamping outside of caching
Summary:
Here the deal with the clamp thing:
A layout engine asks nodes to measure their content providing layout constraints (min and max size) and that would be kind from nodes to return a result that in space of those constraints. Sometimes, satisfying that is an additional separate step of that operation, e.g. if we know that the intrinsic size of some node is `{100, 100}`, we need to clamp that to satisfy constraint `[min: {200, 200}, max: {inf, inf}]`.

In case when we need to cache measure information, it becomes tricky enough when we need to make the cache work most efficiently. For the case of measuring Text, we have an insight: the available maximum width is important, the rest three metrics (maximum height and minimum size) are not.

That means that any changes in those three metrics don't affect the actual measurement result but will affect the final value because the actual value will be clamped by constraints that didn't influence measuring in the first place.
That's why moving clamping outside of a cache is the first step into making it more efficient.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18848584

fbshipit-source-id: 8feeb3f1a9d0e9691abac8be43639487a626fec3
2019-12-06 10:54:12 -08:00
Eli White e362470305 Convert easy files to flow strict-local
Summary:
This diff was generated by this script used by WWW
https://our.intern.facebook.com/intern/diffusion/WWW/browse/master/scripts/flow/upgrade_to_flow_strict_local.sh?lines=0

Changelog:
[Internal] Upgrade flow to flow strict-local

Reviewed By: zackargyle, rickhanlonii

Differential Revision: D18833630

fbshipit-source-id: e64d4e9a49a0db5e6bf70a0c489567862b578d7f
2019-12-05 16:06:46 -08:00
Joshua Gross b9491b7c51 TextInput: support editing completely empty TextInputs
Summary:
Before this change, C++ couldn't propagate changes that updated TextInputs that were completely empty. In C++ the AttributedString cannot contain Fragments with empty text, so a completely empty TextInput would have no Fragments; this breaks the C++ state value updating infra since it relies on copying over existing fragments.

Instead, now we propagate default TextAttributes and ShadowView through State, so that State updates can use them to construct new Fragments.

Changelog: [Internal]

Reviewed By: shergin, mdvacca

Differential Revision: D18835048

fbshipit-source-id: 58ac94c5454c8610c6287b096b62199045e5879b
2019-12-05 13:20:30 -08:00
Joshua Gross 0556e86d09 TextInput: support modifying TextInputs with multiple Fragments (Cxx side)
Summary:
Support for modifying AndroidTextInputs with multiple Fragments was added on the Java side in a previous diff.

This diff adds support on the C++ side for the following scenario:

A <TextInput> is initially given contents via children <Text> notes, which represents multiple Fragments (that could have different TextAttributes like color, font size, backgroundcolor, etc). The Android EditText view must get this initial data, and then all updates after that on the Android side must flow to C++ so that the C++ ShadowNode can perform layout and measurement with up-to-date data.

At the same time, the <TextInput> node could be updated from the JS side. All else equal, this would cause the native Android EditText to be replaced with the old, original contents of the <TextInput> that may not have been updated at all from the JS side.

To mitigate this, we keep track of two AttributedStrings with Fragments on the C++ side: the AttributedString representing the values coming from <TextInput> children, from JS (`treeAttributedString`); and the AttributedString representing the current value the user is interacting with (`attributedString`). If the children from JS don't change, we don't update Android/Java with that AttributedString. If the children from JS do change, we overwrite any user input with the tree from JS.

Changelog: [Internal]

Reviewed By: shergin, mdvacca

Differential Revision: D18785976

fbshipit-source-id: a1f3a935e02379cabca8ab62a39cb3c0cf3fbca5
2019-12-05 13:20:30 -08:00
Joshua Gross 2a46980535 AttributedString equality: only check tags of parentShadowView; ShadowViews are never equal otherwise
Summary:
For future diffs, we need to check AttributedStrings for equality.
It turns out that any time props or state change, two `parentShadowView`s will never be equal to each other, even if we'd consider them equal for our use-cases here for AttributedStrings. Just compare the tags instead of the whole object.

NOTE: I don't have any strong opinions about how we should be comparing them. It just isn't working currently for AndroidTextInput. Comparing tags seems convenient and reasonably correct for now.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D18786004

fbshipit-source-id: 13c0e881cd8d2c2a207e8891309b3c9b880b827f
2019-12-05 13:20:29 -08:00
Joshua Gross 25ce622683 Fix TextInput example with text attribute and child Text node: text background shouldn't be same as TextInput background
Summary:
Currently the TextInput background is same as the background of the `text` value's attributes, because of the way we're parsing props and using the TextInput's props both for the background of the TextInput, and for the AttributedString/background color of the `text` prop node's attributes. If the background color has opacity, the `text` prop node will not have the correct background because it will be applied twice. Fix it.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D18760384

fbshipit-source-id: 0cdcc8dd8839dd47e8fe0f593b4696bc16a62333
2019-12-05 13:20:29 -08:00
Joshua Gross a09346f129 TextInput: support text value+child Text nodes
Summary:
Fix and simplify `AndroidTextInputShadowNode::getAttributedString` so that it (1) works, and (2) is aligned with the equivalents in the old Java code.

The issue is that we weren't picking up `text` attributes since we're only traversing children and not the TextInput node itself. If a `text` attribute is present it needs to be treated as its own Text node.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D18739830

fbshipit-source-id: 4b3bc81dbe8c241c2e06fe5be1f9b50e49132890
2019-12-05 13:20:29 -08:00
Joshua Gross 7590d9f8f4 Support creating AndroidTextInputState from previous state + folly::dynamic
Summary:
This is necessary for allowing TextInput updates from Java.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D18739831

fbshipit-source-id: 0ba2d7eac96cac7471c5e46cc1e03a4d065229f5
2019-12-05 13:20:28 -08:00
Valentin Shergin 42f2ded900 Fabric: Returning zero size on attempt to measure an empty string in RCTTextLayoutManager
Summary:
Sometimes, very irregularly, measuring an empty string crashes/freezes iOS internal text infrastructure. This is our last line of defense.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC, mdvacca

Differential Revision: D18802308

fbshipit-source-id: addf523b31b78b0777be7eeaeee140ac8416393b
2019-12-04 18:36:49 -08:00