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

15637 Коммитов

Автор SHA1 Сообщение Дата
Valentin Shergin 7197aa026b Fabric: Using ShadowView instad of ShadowNode inside AttributedString
Summary:
That's generally better because:
 * Avoids exposing ShadowNode to mounting layer;
 * Enables hashing and comparing the AttributedString based on actual meaningful data (not on just a pointer to ShadowNode).

Reviewed By: mdvacca

Differential Revision: D13205230

fbshipit-source-id: 7b79c1aad97b10d81e3faa10408be61b74f815cf
2018-11-27 18:34:15 -08:00
Valentin Shergin 6c3b05f343 Fabric: std::hash for ShadowView
Summary: Trivial. We need this for future use as part of AttributedString's hash.

Reviewed By: mdvacca

Differential Revision: D13205231

fbshipit-source-id: 14a3decae72741030284a30abdb936616bafb3fe
2018-11-27 18:34:14 -08:00
Valentin Shergin 62173a1569 Introducing `fabric/mounting` module
Summary:
ShadowView, ShadowViewMutation, and Differentiator were decoupled to separate module.
That enables us to use ShadowView more widely without facing a circular dependency problem.

Reviewed By: mdvacca

Differential Revision: D13205229

fbshipit-source-id: 7373864bf153a7813c2f97edb263a41454ce0b88
2018-11-27 18:34:14 -08:00
Valentin Shergin 28c3981f73 Fabric: UIManagerBinding::setNativeProps
Summary: Pretty straightforward.

Reviewed By: sahrens

Differential Revision: D13114836

fbshipit-source-id: ff86b28d8764955383d4b46a369faf978825f6eb
2018-11-27 18:03:27 -08:00
Valentin Shergin 142dd7673e Fabric: UIManager::setNativeProps
Summary: Pretty straightforward wiring UIManager and the new feature in ShadowTree: we get the node, clone with the new props and then replace this.

Reviewed By: sahrens

Differential Revision: D13114788

fbshipit-source-id: 3a34fb879f3ec564c26278034a19b88518302de8
2018-11-27 18:03:27 -08:00
Valentin Shergin f42d2b9e32 Fabric: `ShadowTree::completeByReplacingShadowNode`
Summary: This method is the core of the future features: `setNativeProps` and `LocalState`.

Reviewed By: sahrens

Differential Revision: D13114789

fbshipit-source-id: 2138496c43c171fe27784b1959d86d6eec4638ee
2018-11-27 18:03:27 -08:00
Valentin Shergin d594d5a4e5 Fabric: `UIManagerBinding::getRelativeLayoutMetrics`
Summary: Exposing the getRelativeLayoutMetrics method to JS.

Reviewed By: mdvacca

Differential Revision: D13036552

fbshipit-source-id: de825dfde8e64163168510aea1eda77370753b29
2018-11-27 18:03:27 -08:00
Spencer Ahrens 7b2e3f8159 Small cleanup of TextInputExample
Summary: Use array+map like other examples for DRY.

Reviewed By: TheSavior

Differential Revision: D13222132

fbshipit-source-id: 15171e496eaef8794c02e853950f666d77372923
2018-11-27 17:33:13 -08:00
nd-02110114 23845fb15c Flow strict in Picker.js, PickerIOS.ios.js, PickerAndroid.android.js (#22128)
Summary:
Related to #22100

Turn Flow strict mode on for Picker

- [x] npm run prettier
- [x] npm run flow-check-ios
- [x] npm run flow-check-android
Pull Request resolved: https://github.com/facebook/react-native/pull/22128

Differential Revision: D12946781

Pulled By: mmmulani

fbshipit-source-id: 4d3cb884dd8bf57a43ef8aec4491359e9874d182
2018-11-27 17:11:31 -08:00
Ramanpreet Nara db43aa8fc3 Implement getConstants()
Summary:
Instead of assigning all the constants exported by a NativeModule to the native module JavaScript object itself, we want to instead export a `getConstants()` method that can be used to access native module constants. This change simplifies the API of native modules. Eventually, we'll remove the ability to access constants as native module object properties alltogether, but that's comes later.

**Note**: I didn't need to make any cpp changes because `JSIExecutor::NativeModuleProxy::get` calls `JSINativeModules::getModule` (here: https://goo.gl/QwPDWF), which eventually calls `JSINativeModules::createModule`, which uses `global.__fbGenNativeModule` (here: https://goo.gl/pSxMgE), which is just an alias to `genModule` in `NativeModules` (here: https://goo.gl/u2wjCs).

Reviewed By: fkgozali

Differential Revision: D13207152

fbshipit-source-id: 375aab1346232819187a5d5b272b33c55992346a
2018-11-27 16:28:20 -08:00
Ramanpreet Nara ada7089066 Revert D13105396
Summary: D13105396 broke a few things, so I'm reverting it. See: https://fburl.com/toehyir8

Reviewed By: sahrens, mmmulani

Differential Revision: D13220491

fbshipit-source-id: 35594099eea7f40d2fb948ae2010db4babb7093d
2018-11-27 14:03:14 -08:00
Adam Ernst 7030d95988 Fix unmangled visibility in rn_defs
Summary: The wrappers exposed by `rn_defs.bzl` should mangle visibility to include the cell.

Reviewed By: scottrice

Differential Revision: D13219109

fbshipit-source-id: ded17e79a1d388d6b76fbdf2ab0d75e586092fcd
2018-11-27 13:46:24 -08:00
Radek Czemerys 706888df35 Use Changelog instead of Release Notes for danger bot (#22395)
Summary:
In #22117 we changed the PR template to use `Changelog` instead of `Release notes` and now danger bot is complaining as it wasn't updated there.

cc turnrye
Pull Request resolved: https://github.com/facebook/react-native/pull/22395

Differential Revision: D13195006

Pulled By: TheSavior

fbshipit-source-id: 36b9675c1e30c86fb8d002b121cc29239d6f78dd
2018-11-27 12:38:22 -08:00
David Vacca 00681c3660 Fix TouchEvents on text after state changes
Summary:
This diff fixes a bug that produces TouchEvents on text to stop working after a react state has happened.
An easy way to reproduce this is opening a YellowBox, minimizing it and trying to open it again

Reviewed By: shergin

Differential Revision: D13198663

fbshipit-source-id: 19b08818bbff8014ab8227b3db1119edc4193389
2018-11-27 11:51:12 -08:00
Krzysztof Sroka d3f3bfa2a5 Added `persistentScrollbar` prop in ScrollView component (#22300)
Summary:
This PR is a follow-up from the closed [discussions-and-proposals PR](https://github.com/react-native-community/discussions-and-proposals/pull/39), that explains in more detail the rationale for adding this feature.
Pull Request resolved: https://github.com/facebook/react-native/pull/22300

Reviewed By: fkgozali

Differential Revision: D13121748

Pulled By: mdvacca

fbshipit-source-id: 899641be79bdb41fa6649df0772c602a5e09b3b9
2018-11-27 11:21:54 -08:00
Tim Yung 0c8db08f51 Switch: Improve Accessibility
Summary: On Android, `Switch` does not currently read its role as a "button". This fixes that and makes it consistent with iOS.

Reviewed By: sahrens

Differential Revision: D13136253

fbshipit-source-id: 0de5d54772d204168138cb2af7815cc458f72682
2018-11-27 09:46:21 -08:00
Rubén Norte 2ae559a2a4 eslint: Disable jasmine env and only enable jest env for test files
Summary:
Modified the ESLint configuration to only enable the Jest environment for files we consider now tests, which are files with the `-test.js` suffix under `__tests__`. Also enabled some globals for test helpers (any file under `__tests__`).

This will allow us to catch misspelled tests, while allowing test helpers to use most Jest APIs.

Also disabled the Jasmine environment so people stop using Jasmine APIs and we can rollout Circus soon.

Reviewed By: aaronabramov

Differential Revision: D13199591

fbshipit-source-id: 12a32cf5835630b9987452b0c33d3f8085001689
2018-11-27 03:51:02 -08:00
Peter Argany 18f3de9dce Allow init of Native Module before bridge is initialized [2/N]
Summary:
This may be controversial.

Right now, RelayPrefetcher is initialized [here](https://fburl.com/p01iunr1), after bridge is initialized. I want to create a FBRelayPrefetcherModule instance eagerly (diff 3 in stack), and then pass that into the bridge module registry. This way, native side gets to use RelayPrefetcher before bridge is init, and JS still accesses the same instance of FBRelayPrefetcherModule.

The only other option is drastically change bridge init, to allow passing in some eagerly initialized instances.

Reviewed By: shergin

Differential Revision: D13164277

fbshipit-source-id: b45111cd68d78820e61e4fca7e54a7e8df32a3f0
2018-11-26 17:28:11 -08:00
Nicolas Gallagher fd78eee11b Fix text alpha bug
Summary: Set the default text radius to 0 so that text shadows aren't applied to every text node

Reviewed By: mdvacca

Differential Revision: D13027589

fbshipit-source-id: 4f7386059ac1654b8f77dddf9eb1b772f6049e23
2018-11-26 17:24:43 -08:00
Michael Blanchard 53da585832 Fix: Add displayName to ActivityIndicator (#22417)
Summary:
Similar to #21950, this adds displayName to `ActivityIndicator`, so it displays the correct component name in snapshots instead of `Component`.

Fixes #21937 (a little bit more than it was already fixed).
Pull Request resolved: https://github.com/facebook/react-native/pull/22417

Differential Revision: D13205376

Pulled By: TheSavior

fbshipit-source-id: 21e71d4980d159a1f33d32d83346b48257ec21d4
2018-11-26 16:49:58 -08:00
Tomas Reimers b5571cd5fd Create a recursive free with cleanup function
Reviewed By: davidaurelio

Differential Revision: D13119307

fbshipit-source-id: 162bb4fd6d7620f61cbac010d0dc236d81738b71
2018-11-26 16:02:51 -08:00
Valentin Shergin e61a14e71d Fabric: RCTWeakEventEmitterWrapper, NSAttributedString and co.
Summary:
Previously, we stored a pointer to ShadowNode inside NSAttributedString's attributes to make possible retrieving an EventEmitter associated with some text fragment.
That worked fine besides only one caveat: the internal implementation of NSAttributedString is quite strange and that causes a memory leak. Because of some reason, NSAttributedString does not release stored attributes after own destruction (maybe OS uses some kind of caching).
So, now, instead of storing a strong pointer to ShadowNode inside NSAttributedString, we store a weak pointer to EventEmitter. Storing a weak pointer is okay because a desired lifetime of EventEmitter is guaranteed by LocalData stored inside a View. Storing a weak EventEmitter instead of weak ShadowNode will also help us with migration to ShadowView (we cannot store ShadowView weakly because it's a stack allocated object).

Reviewed By: sahrens

Differential Revision: D13196886

fbshipit-source-id: f8714e4b3709765629d6456edf0c635bf5f7c53b
2018-11-26 13:51:19 -08:00
Valentin Shergin 0ec1d21c2f Fabric: Fixed a retain cycle between ParagraphShadowNode, LocalData and AttributedString
Summary:
Consider this:
 * ParagraphShadowNode retains LocalData,
 * LocalData contains AttributedString,
 * AttributedString contains Fragments,
 * Fragment can contain a pointer to parent shadow node, so it can be the ParagraphShadowNode.

In this case it's a retain cycle.
We actually don't need to store pointers to not TextShadowNodes, so we don't now.

Later, after we fully migrate to ShadowView, we can remove this condition because it will become harmless.

Reviewed By: sahrens

Differential Revision: D13196885

fbshipit-source-id: d386ce0a067df0a72e6619d62d56038aaf80eccb
2018-11-26 13:51:19 -08:00
Valentin Shergin 215a0f0f21 Fabric: Proper implementation -[RCTParagraphComponentView prepareForRecycle]`
Summary: Over-retaining a LocalData object inside the View can cause a crash during tearing down JS VM because LocalData can indirectly retain EventEmitter objects which were not properly "disabled".

Reviewed By: sahrens

Differential Revision: D13196887

fbshipit-source-id: 001d9fadf775c89f750c84fe8da9b84d4636631c
2018-11-26 13:51:19 -08:00
Valentin Shergin ffd2409172 Fabric: Proper implementation of -[RCTViewComponentView prepareForRecycle]
Summary: RCTViewComponentView retains an EventEmitter, so we have to clear this up after we recyled the view.

Reviewed By: sahrens

Differential Revision: D13196884

fbshipit-source-id: e9f2e2400be864c5c6177227255012101ed8c4d1
2018-11-26 13:51:19 -08:00
Jonathan Lee 7fe3f90156 Back out "Add bounce method to TouchableBounce"
Summary: Reverting D13085800

Reviewed By: TheSavior

Differential Revision: D13110727

fbshipit-source-id: d5a6e7ff962a350b7cb7d7459abaf861a1387754
2018-11-26 10:51:58 -08:00
Rubén Norte 922e196ed1 jest: make regex for tests stricter
Summary:
Updated the configuration for all projects on xplat/js to only consider tests that end with `-test.js`.

All tests were migrated in the previous diff of the stack.

Reviewed By: mjesun

Differential Revision: D13185676

fbshipit-source-id: baaba94fabc403acb30b0b5a0462788813d7a870
2018-11-26 10:30:12 -08:00
Rubén Norte ffa9036252 jest: rename tests to follow the new convention
Summary:
Renamed test files to match `-test.js`, so people can add test helpers without blacklisting.

Codemod code: P60365841

Script executed:

```
cd xplat/js
./scripts/node/node rename-script.js > result.txt
```

Reviewed By: mjesun

Differential Revision: D13185673

fbshipit-source-id: 87451635aa538c2c1d1886e75574d0e5c889596e
2018-11-26 10:30:12 -08:00
Taras Tsugrii fed8b39c3f Sort build file loads.
Reviewed By: yungsters

Differential Revision: D13176340

fbshipit-source-id: 0942970770866c2f2280f746b2c4c592ff0c383c
2018-11-26 09:05:39 -08:00
Sidharth Guglani f000cf07c5 calling markDirtyAndPropogate when setting isReferenceBaseline value
Summary:
@public
Marking the node as dirty when isReferenceBaseline property is changed

Reviewed By: davidaurelio

Differential Revision: D13147742

fbshipit-source-id: 3bbff1cfceeadfbf77380519e4638f2984fc2009
2018-11-26 07:28:48 -08:00
Christoph Nakazawa 1f8b46a2fc Clean up EventEmitter
Summary: As suggested by yungsters in D13138187

Reviewed By: mjesun

Differential Revision: D13192765

fbshipit-source-id: 8ab3dc74b3a9aaebf043bc3b5ed4f2590f480d10
2018-11-26 06:28:25 -08:00
Christoph Nakazawa cfef04e760 Remove fbjs/lib/emptyFunction from react-native
Summary: This removes `emptyFunction` usage from react-native.

Reviewed By: yungsters

Differential Revision: D13138187

fbshipit-source-id: eaa327884aac2cabb99024077e3407cb99c946d2
2018-11-26 06:28:25 -08:00
Christoph Nakazawa 2de01cb54d Inline `extractSingleTouch` from fbjs
Summary: There is only a single use of this function across RN, and one more use in a test file. I inlined this function in both places to reduce the dependency on fbjs.

Reviewed By: yungsters

Differential Revision: D13138137

fbshipit-source-id: 32660c965a975d17e236bdd13ff0b2a8d64751ee
2018-11-26 06:28:25 -08:00
Christoph Nakazawa f377926677 Remove isNode call from Map polyfill
Summary: There are no DOM Nodes in React Native so our Map polyfill does not need to consider that use case. I deleted the references to `isNode` and `IE. In case this is important for react-native-web, I suggest to shim the Map polyfill with an IE compatible one outside of react-native.

Reviewed By: yungsters

Differential Revision: D13138030

fbshipit-source-id: 661511ea03b4477bd55d0fdf5e485178fe59d96b
2018-11-26 06:28:24 -08:00
Christoph Nakazawa dc8246d56e Stop using Promise from fbjs
Summary: This module simply forwards to the `promise` module. I inlined the code to remove the dependency.

Reviewed By: yungsters

Differential Revision: D13137980

fbshipit-source-id: e3d6208068911711fc5f5378f2d5bb6ac38f2eb2
2018-11-26 06:28:24 -08:00
Radek Czemerys 287934dba9 Fix Xcode 10 builds (broken by folly upgrade) (#22394)
Summary:
[Folly upgrade](a70625abd7) introduced changes that have to be applied to `Install Third Party` script in order to use `New build system` from Xcode 10. Unfortunately, this might happen again if someone changes folly. Also removes non-existent files from folly podspec.
Pull Request resolved: https://github.com/facebook/react-native/pull/22394

Differential Revision: D13192463

Pulled By: hramos

fbshipit-source-id: ea0eeb6e1e7f6d7dfcdb6d1dee28b1a640ee7097
2018-11-26 01:41:15 -08:00
Olivier Corradi a686048794 Fix cookies not being sent after a redirected response (#22178)
Summary:
Fixes https://github.com/facebook/react-native/issues/19376

On iOS, the `HTTPShouldHandleCookies` boolean has no effect when custom cookies are set (see https://developer.apple.com/documentation/foundation/nsmutableurlrequest/1415485-httpshouldhandlecookies?preferredLanguage=occ). Setting custom cookies prevents the cookies of a redirect response from being re-used in the subsequent request.
This is why issue https://github.com/facebook/react-native/issues/19376 is opened.
The fix is to intercept the redirect request, and to manually set the cookies. This effectively makes the Android and iOS behaviours converge.

Changelog:
----------
  [iOS] [Fixed] - Fix cookies not being sent on iOS after redirect
Pull Request resolved: https://github.com/facebook/react-native/pull/22178

Differential Revision: D13191961

Pulled By: shergin

fbshipit-source-id: 4445a2499034a9846c6d7c37c1f1b72c9fd30129
2018-11-25 23:00:01 -08:00
Valentin Shergin c68e69cb67 Fabric: Proper handling of memory pressure event in RCTComponentViewRegistry
Summary: View recycling can be pretty aggressive and memory intensive, so we can properly react on system memory-pressure notification.

Reviewed By: mdvacca

Differential Revision: D13176278

fbshipit-source-id: 38ea1b27da988aeaaa5db6ac0b94389a0bd2799e
2018-11-25 22:17:30 -08:00
Valentin Shergin cd5f0bd95c Fabric: Stopping creating ShadowView instances for non-View ShadowNodes
Summary:
Apparently, the previous behavior brings more problems than some *possible-in-the-future* features and flexibility.
The new model allows us to easily implement "nested text" feature.

(We temporary hope the old behavious for Android only for compatibility reasons.)

Reviewed By: mdvacca

Differential Revision: D13176277

fbshipit-source-id: 01f7bfb3c2e70cc89d76ecb78add016ee91cbd63
2018-11-25 22:17:30 -08:00
Valentin Shergin e581977b51 Introducing RCTComponentViewFactory
Summary:
The whole mounting iOS infra now uses `ComponentHandle` instead of `std::string` as a reference to particular `ComponentView` implementation. All changes are pretty straightforward, we use a different thing/type to refer to the particular class; no changes in the logic besides a new `RCTComponentViewFactory` that serves the same role of classes registry as Objective-C runtime served previously.
That has several benefits:
* It should be slightly faster, mostly because we don't need to convert `char *` strings to `std::string` and then to `NSString *`.
* We don't need string-based component-name maps anymore (at least on this layer). We can call classes as we want and it will work because of classes are now explicit about which ShadowNodes they are compatible with.
* Most importantly, it's explicit now! That means that no runtime magic is involved anymore and we can rely on static linting tool now and not be afraid of improper code stripping/overoptimization.

Reviewed By: mdvacca

Differential Revision: D13130760

fbshipit-source-id: aadf70525a1335b96992443abae4da359efdc829
2018-11-25 22:17:30 -08:00
Valentin Shergin eef3df86fb Fabric: Introducing `-[RCTComponentViewProtocol componentHandle]`
Summary: The new method in the protocol enforces view component classes to expose a component handle of the component that the view component represents. That will allow us to wire up those classes with shadow views in runtime explicitly and in a much more performant way than it is now.

Reviewed By: mdvacca

Differential Revision: D13114663

fbshipit-source-id: 853187d978aab200f85719d9c1d9fea2e3ad4e55
2018-11-25 22:17:30 -08:00
David Vacca 89f647d521 Redefine hashcode for AttributedString
Summary:
This diff changes the method to calculate the hash of an AttributedString (removing shadowNode and parentShadowNode from it).
This is necessary becuase otherwise hashcode of clonned parent keep changing in every state change, when the text doesnt change

With this change we are able to cache spannables in android properly

Reviewed By: shergin

Differential Revision: D13189110

fbshipit-source-id: c1f7372809ce98a5b4d091485cc15281a4ab5e1e
2018-11-25 17:21:00 -08:00
David Vacca f341795824 Add caching of spannable text objects
Summary: This diff adds support to cache the Spannable objects that are created during measure() and updateLocalData() for text

Reviewed By: shergin

Differential Revision: D13188599

fbshipit-source-id: 6547d8ce2bb8b1dfb3c91e64facff3ba0cd97472
2018-11-25 17:21:00 -08:00
David Vacca 3be2816aec Remove max and min font size from serialization of text attribute
Summary:
Removing two props that are not currently used

They are being set as quiet_NaN  in C++ and this brings problems in the Android side

Reviewed By: shergin

Differential Revision: D13188600

fbshipit-source-id: e8412497a80300cfbc3770b829e9633206aaf427
2018-11-25 17:21:00 -08:00
David Vacca 5be17c01a1 Fix re-measure of text
Summary: This diff fixes re-measures of a text component result of a change of state. For details of the bug see: T36838266

Reviewed By: shergin

Differential Revision: D13188601

fbshipit-source-id: ea9a889540f600d4e4e788105d5fa22e6cd5448c
2018-11-25 17:20:59 -08:00
David Vacca eec9e4a2f9 Expose hash as part of text localdata
Summary: In this diff we expose the text local data hash to android, this will be used in the future to cache metadata when rendering text in android

Reviewed By: shergin

Differential Revision: D13161873

fbshipit-source-id: cd13a4beba75a3fe62ac9ff3def26f88e874834b
2018-11-25 17:20:59 -08:00
David Vacca 3b4d6d5ef5 Add systrace to calculation of Yoga layout() in Fabric
Summary: Simple diff that adds a systrace to start measuring the calculation of Yoga layout() in Fabric

Reviewed By: shergin

Differential Revision: D13124641

fbshipit-source-id: 6bd03e9f56524221f5d91606ffde50253673c1bb
2018-11-25 17:20:59 -08:00
David Vacca 10ce6c3e11 Refactor types used during yoga meassure calls
Summary: This diff refactors the types used when Yoga requires to measure the size of a View in C++

Reviewed By: shergin

Differential Revision: D13124086

fbshipit-source-id: 89dfe80bb41b4fb2eaba84af630d52ef2509b1e1
2018-11-25 17:20:59 -08:00
David Vacca 0357d0de64 Ensure thread safety in the exeuction of RuntimeExecutor
Summary: This diff ensures thread safety for operations invoked by the runtime executor

Reviewed By: shergin

Differential Revision: D13136340

fbshipit-source-id: 119092dff29b37f39d4bcdcc34f1c34d638b7e07
2018-11-25 17:20:59 -08:00
David Aurelio f2894e58cf Data types for marker API
Summary:
@public

Adds types for a marker API in Yoga.

This will allow us to register callbacks that Yoga can use to log performance data without hard-coding the backend system for that.

Reviewed By: SidharthGuglani

Differential Revision: D13118830

fbshipit-source-id: b42a42c609f0cf66212186f7f20ee572522d59e3
2018-11-24 16:26:30 -08:00