Commit Graph

1824 Commits

Author SHA1 Message Date
Pieter De Baets 81c2f3b189 Cleanup Platform
Reviewed By: dcaspi

Differential Revision: D5185504

fbshipit-source-id: 4f7e9f9068598418b346a7370f6be241a0784b60
2017-06-07 10:19:01 -07:00
Jean Regisser 5114b61b5e Add support for flashScrollIndicators on iOS
Summary:
Flashing scroll indicators is a standard behavior on iOS to show the user there's more content.

Launch RNTester on iOS, go to the ScrollView section, tap the "Flash scroll indicators" button.
You'll see this:

![Flash scroll indicators](https://cloud.githubusercontent.com/assets/57791/26250919/ebea607a-3cab-11e7-96c6-27579cc809ab.gif)

I've exposed the method `flashScrollIndicators` on all scrolling components that were already exposing a `scrollToXXX` method so it's usable from those components using a ref.

Let me know what you think.
Closes https://github.com/facebook/react-native/pull/14058

Differential Revision: D5103239

Pulled By: shergin

fbshipit-source-id: caad8474fbe475065418d771b17e4ea9766ffcdc
2017-06-06 13:06:48 -07:00
Dan Caspi e284a9db8c Create JS executor and context on main thread w/ custom JSC
Reviewed By: javache

Differential Revision: D5165405

fbshipit-source-id: 35e5cfdf0518968c095ba54ec980d2fe376fa20e
2017-06-06 04:45:51 -07:00
Valentin Shergin 072d2709df Introducing `-[RCTView reactAccessibleView]`
Summary:
Sometimes, when we implement some custom RN view, we have to proxy all accessible atributes directly to some subview which actually has accesible content. So, in other words, this allows bypass some axillary views in terms of accessibility.
Concreate example which this approach supposed to fix:
https://github.com/facebook/react-native/pull/14200/files#diff-e5f6b1386b7ba07fd887bca11ec828a4R208

Reviewed By: mmmulani

Differential Revision: D5143860

fbshipit-source-id: 6d7ce747f28e5a31d32c925b8ad8fd4b98ce1de1
2017-06-02 14:19:57 -07:00
adamjmcgrath 23a34d4c65 Ignore "Frame load interrupted" errors in UIWebView
Summary:
Am writing an OAuth flow using `WebView`, when the OAuth provider redirects back to the [redirect_uri](https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow#logindialog) I intercept the request using `onShouldStartLoadWithRequest`, get the access token from the url and close the `WebView`.

The problem I see is that when the OAuth provider redirects to the `redirect_uri` and I intercept it by returning false from `onShouldStartLoadWithRequest`, I get a WebKitErrorDomain error code 102 ("Frame load interrupted").

Looking at some other iOS libraries that implement OAuth with a WebView - it seems that the error can be ignored. eg.

https://github.com/facebook/facebook-ios-sdk/blob/master/FBSDKCoreKit/FBSDKCoreKit/Internal/WebDialog/FBSDKWebDialogView.m#L146

https://github.com/evernote/evernote-sdk-ios/blob/master/evernote-sdk-ios/internal/ENOAuthViewController.m#L147

You can recreate the error using a url that automatically redirects, eg http://www.facebook.com -> https://www.facebook.com

```js
<WebView
  source={{ uri: 'http://www.facebook.com' }}
  onShouldStartLoadWithRequest={(event) => {
    if (event.url.startsWith('https://www.facebook.com')) {
      return false;
    }
    return true;
  }}
/>
```
Closes https://github.com/facebook/react-native/pull/12482

Differential Revision: D5154115

Pulled By: shergin

fbshipit-source-id: 25151d00a1f97e17760617ee5aac6a0140c733c8
2017-05-31 00:16:13 -07:00
Stephen Bird f1284b8231 Add message to remind user to enable wifi
Summary:
Our iOS devs frequently turn off wifi and forget to turn it back on. This message should remind them that they need wifi to connect. Often they waste several minutes due to this problem.

I'm not sure if there's a test plan to apply here. Any suggestions?
Closes https://github.com/facebook/react-native/pull/13551

Differential Revision: D5149231

Pulled By: hramos

fbshipit-source-id: 0afc71024f10f802ac1a50435fb57fc10a02c819
2017-05-30 20:49:48 -07:00
Pieter De Baets 33e22486e9 Fix some issues with the React podspec for the Cxx bridge
Summary:
Trying to fix the RN Travis CI tests

Splitting off from https://github.com/facebook/react-native/pull/14100
Closes https://github.com/facebook/react-native/pull/14132

Reviewed By: ericvicenti

Differential Revision: D5112077

Pulled By: javache

fbshipit-source-id: cf030b927b0f28f2b494471498f1ddb2c0a5c1df
2017-05-30 11:15:19 -07:00
Adam Comella cfe003238a iOS: Introduce API for making screen reader announcements
Summary:
This change introduces some APIs that are useful for making announcements through the screen reader on iOS:
  - `announceForAccessibility`: The screen reader announces the string that is passed in.
  - `announcementFinished`: An event that fires when the screen reader has finished making an announcement.

You can already solve similar problems with RN Android using the `accessibilityLiveRegion` prop. Live regions are a different feature but they can be used to solve the same problem. This commit does not attempt to add live region support in RN iOS because Apple did not build live region support into iOS.

Verified that `announceForAccessibility` causes VoiceOver to announce the string when VoiceOver is enabled. Verified that `announcementFinished` fires with the appropriate data in the event object. Additionally, my team has been using this change in our app.

Adam Comella
Microsoft Corp.
Closes https://github.com/facebook/react-native/pull/14168

Differential Revision: D5137004

Pulled By: javache

fbshipit-source-id: b3c10f3dfc716430a16fcc98e1bb6fe52cabd6a5
2017-05-30 04:46:08 -07:00
Valentin Shergin e13b9c6e49 RCTTextField was spliited into two classes
Summary:
Motivation:
 * We maintain two different implementation of <TextInput> (multilined and singlelined), this change makes the implementations much similar which will help us to support and improve both of them in the (near) future;
 * We have to have separated RCTView-based container view for (TextField) to support sofisticated bordering and so on;
 * It opens to us possibility to unify UITextView and UITextField subclasses and remove code duplication across RCTTextView and RCTTextField;
 * Making things decoupled in general will allow us to fix existing bugs with events.

Reviewed By: mmmulani

Differential Revision: D5083010

fbshipit-source-id: 2f2d42c2244d2b39256c51480c1f16f4e3947c01
2017-05-29 16:01:11 -07:00
Valentin Shergin 44af4d19d3 Fixed <TextInput>'s padding and border size computation and layout
Summary: Previosly `borderWidth` did not affect actual content inset (which was a problem).

Reviewed By: mmmulani

Differential Revision: D5072483

fbshipit-source-id: d43cba7414a9335b9f9fd4d1565d7aee403cce0e
2017-05-29 16:01:04 -07:00
Janic Duplessis 1658f36630 Improve z-index implementation on iOS
Summary:
This avoids reordering views because it created some bugs when the native hierarchy is different from the shadow views. This leverages `layer.zPosition` and takes z-index in consideration when we check what view should be the target of a touch.

**Test plan**
Tested that this fixes some layout issues that occurred when using sticky headers in the Expo home screen.
Closes https://github.com/facebook/react-native/pull/14011

Differential Revision: D5108437

Pulled By: shergin

fbshipit-source-id: 0abfe85666e9d236a190e6f54cdd5453cacfbcac
2017-05-28 21:45:32 -07:00
Pieter De Baets a2e589eb23 Cleanup initialization of native modules in FBReactModule
Reviewed By: shergin

Differential Revision: D5111768

fbshipit-source-id: 9ad682b51ad34516576b6403220bb7d2870e0192
2017-05-26 04:17:19 -07:00
Pieter De Baets 03e1f40c1e Cleanup and document Value wrapper (retry)
Reviewed By: mhorowitz

Differential Revision: D5120975

fbshipit-source-id: 6e9c80a57fdcf7f3dad21d5521fb928b52c924c7
2017-05-26 04:17:19 -07:00
Adam Comella e40d1a1065 iOS: Introduce API for moving screen reader's focus
Summary:
This change introduces an API, `setAccessibilityFocus`, which moves the screen reader's focus to the passed in element. This causes VoiceOver to announce the element and draw a focus rectangle around it.

Similar functionality is already available in RN Android through the `sendAccessibilityEvent` method. Here's an example of what exists today in RN Android:

```
RCTUIManager.sendAccessibilityEvent(
  node,
  8 /* TYPE_VIEW_FOCUSED */);
```

Called `setAccessibilityFocus` on a couple of elements to verify that focus does indeed move when VoiceOver is enabled. Additionally, my team is using this change in our app.

Adam Comella
Microsoft Corp.
Closes https://github.com/facebook/react-native/pull/14169

Differential Revision: D5137002

Pulled By: javache

fbshipit-source-id: 466e8b187e625de7c0f0d36e0400327dcd8d192a
2017-05-26 03:19:21 -07:00
Adam Comella 35338e9008 iOS: Avoid adding extra spaces to accessibility label
Summary:
In some cases, `RCTRecursiveAccessibilityLabel` could return an accessibility label that had leading space, trailing space, or multiple spaces between words. This is because it always added a space before adding a label even if the label turned out to be empty.

This is fixed by being stricter about adding spaces.

Found test cases that used to introduce leading space, trailing space, or multiple spaces between words and verified that there aren't any extra spaces after the fix.

```
{/* Used to have leading space */}
<View accessible={true}>
  <View />
  <View accessibilityLabel='Two' />
  <View accessibilityLabel='Three' />
</View>

{/* Used to have 2 spaces between "One" and "Three" */}
<View accessible={true}>
  <View accessibilityLabel='One' />
  <View />
  <View accessibilityLabel='Three' />
</View>

{/* Used to have trailing space */}
<View accessible={true}>
  <View accessibilityLabel='One' />
  <View accessibilityLabel='Two' />
  <View />
</View>
```

Additionally, my team is using this fix in our app.

Adam Comella
Microsoft Corp.
Closes https://github.com/facebook/react-native/pull/14177

Differential Revision: D5127891

Pulled By: shergin

fbshipit-source-id: 42c3022895d844959e0037eaf381b326af3cd6d1
2017-05-24 23:15:41 -07:00
makadaw 5e97be8b1c Fix data race on read/write _instance variable in ModuleData class
Summary:
Thanks for submitting a PR! Please read these instructions carefully:

- [ ] Explain the **motivation** for making this change.
- [ ] Provide a **test plan** demonstrating that the code is solid.
- [ ] Match the **code formatting** of the rest of the codebase.
- [ ] Target the `master` branch, NOT a "stable" branch.

What existing problem does the pull request solve?
XCode  [Thread Sanitizer](https://clang.llvm.org/docs/ThreadSanitizer.html) find race condition while read/write `_instance` variable in RCTModuleData class. A bridge can check `hasInstance` method while instance writes.

All tests passed on my device.
These changes remove data race, you can turn it in scheme configuration ![](https://www.shinobicontrols.com/wp-content/uploads/2016/08/Enable_Sanitizer.png)
Closes https://github.com/facebook/react-native/pull/13757

Differential Revision: D4994041

Pulled By: javache

fbshipit-source-id: 631cd59bbcbde193937d8baf8358ff6868717a2e
2017-05-24 13:01:00 -07:00
Feng999 a3d58ba570 Update RCTScrollView.m
Summary:
fix problem of function scrollToEnd: There are some strange thing happened when contentSize.height(width)  is smaller than bounds.size.height(width).  In fact, there is no need to scroll in this case.

Thanks for submitting a PR! Please read these instructions carefully:

- [x] Explain the **motivation** for making this change.
- [x] Provide a **test plan** demonstrating that the code is solid.
- [x] Match the **code formatting** of the rest of the codebase.
- [x] Target the `master` branch, NOT a "stable" branch.

What existing problem does the pull request solve?

A good test plan has the exact commands you ran and their output, provides screenshots or videos if the pull request changes UI or updates the website. See [What is a Test Plan?][1] to learn more.

If you have added code that should be tested, add tests.

Sign the [CLA][2], if you haven't already.

Small pull requests are much easier to review and more likely to get merged. Make sure the PR does only one thing, otherwise please split it.

Make sure all **tests pass** on both [Travis][3] and [Circle CI][4]. PRs that break tests are unlikely to be merged.

For more info, see the ["Pull Requests"][5] section of our "Contributing" guidelines.

[1]: https://medium.com/martinkonicek/what-is-a-test-plan-8bfc840ec171#.y9lcuqqi9
[2]: https://code.facebook.com/cla
[3]: https://travis-ci.org/facebook/react-native
[4]: http://circleci.com/gh/facebook/react-native
[5]: https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md#pull-requests
Closes https://github.com/facebook/react-native/pull/13180

Differential Revision: D4928778

Pulled By: javache

fbshipit-source-id: 8b74833593ee317df726a4035ec71bbc77d13afe
2017-05-24 11:45:46 -07:00
Kathy Gray f46eaa30cf Provide sync vs async interface for bundle loading via parameter
Reviewed By: javache

Differential Revision: D5104317

fbshipit-source-id: ffacb57d85c24795a3acc2faba2ff5824cc739b2
2017-05-24 07:31:36 -07:00
Pieter De Baets d59fd9e419 Revert D5087565: Cleanup and document Value wrapper
Differential Revision: D5087565

fbshipit-source-id: 8168bda39fac9384264e9d849b205a2c1d37dcfa
2017-05-24 07:31:36 -07:00
Pieter De Baets 374d08b8e4 Cleanup and document Value wrapper
Reviewed By: mhorowitz

Differential Revision: D5087565

fbshipit-source-id: 21b15dc4c476d6ecd7c42f9334c6995fa43810c2
2017-05-24 06:30:51 -07:00
David Aurelio a710f9a81e Move packager launcher scripts outside of `packager/`
Summary: in order to prepare open sourcing React Native Packager, we have to move scripts specific to React Native to a directory that will continue to exist.

Reviewed By: javache

Differential Revision: D5112193

fbshipit-source-id: eac77d0d981aecef7ee52365a6856340420a5638
2017-05-23 16:17:09 -07:00
Pieter De Baets 0357303f5b Schedule initializeBridge on the JS thread
Reviewed By: shergin

Differential Revision: D5044230

fbshipit-source-id: 87030e210af662bc12cfb57bc83e73a128303fb0
2017-05-17 09:02:43 -07:00
Pieter De Baets 8525aac769 Ensure enqueueJSCall's completion block is always dispatched after the actual JS call
Reviewed By: mhorowitz

Differential Revision: D4985694

fbshipit-source-id: 50ab14e7088a53e03d5ee70c8ea1e245f531dac1
2017-05-16 09:46:54 -07:00
Valentin Shergin ff42878a5c Introducing `-[RCTUIManager shadowViewForReactTag:]`
Reviewed By: javache

Differential Revision: D5042093

fbshipit-source-id: 7c154b660f51de6d575f3c4a70321415512e92a2
2017-05-16 09:46:53 -07:00
Pieter De Baets 49c4c0c942 Fix packager reload command not working
Reviewed By: yungsters, mmmulani

Differential Revision: D5061001

fbshipit-source-id: 8b75c95525f90955a8dc2054861ad3b6e25eab1d
2017-05-15 10:30:36 -07:00
Pieter De Baets 65aaa9c045 Fix memory leak in RN fbsystrace support
Reviewed By: alexeylang

Differential Revision: D5060485

fbshipit-source-id: f2ab38023f1870992c16bea08ee887261d0ca34b
2017-05-15 03:47:15 -07:00
Pieter De Baets 6221053179 Improve systrace markers
Reviewed By: mhorowitz

Differential Revision: D4860135

fbshipit-source-id: ce963010883e6b9cc8e34f7ff01b4018cd195eba
2017-05-12 18:07:49 -07:00
Pieter De Baets 885856c6a1 More attempts to fix Travis CI runs
Summary:
* Add RCTBridge+Private to exported headers for unit tests
* Fix tvOS build
Closes https://github.com/facebook/react-native/pull/13840

Reviewed By: ericvicenti

Differential Revision: D5027887

Pulled By: javache

fbshipit-source-id: 7a17ee2f84eb1cb87e71373444ef25559959c24a
2017-05-10 04:32:54 -07:00
Ben Nham 65f22a5190 log script name with bundle loading perf event
Reviewed By: javache

Differential Revision: D5010638

fbshipit-source-id: 2e139201a8374245fa1dedc4f11a716dcf700fd7
2017-05-10 04:09:19 -07:00
Valentin Shergin 712b1dd20a RCTUIManagerObserverCoordinator: new way to subscribe for granular notifications from UI Manager
Reviewed By: majak

Differential Revision: D4868591

fbshipit-source-id: 24a09ffa3e69dec5ce1f0a8715c7e4701d781996
2017-05-08 12:52:09 -07:00
Valentin Shergin 2a984326b0 Introducing `RCTAssertUIManagerQueue()`
Reviewed By: javache

Differential Revision: D4868564

fbshipit-source-id: b9b9f6cf8f31495bb0e82fb60b2402dde460ddb8
2017-05-08 12:52:09 -07:00
Valentin Shergin 5058e7eb05 Several layout related helper methods of RCTShadowView was moved to new (+Layout) category.
Reviewed By: javache

Differential Revision: D4865327

fbshipit-source-id: 4df71b57433370ee09c3f1288c4d6241a33f440a
2017-05-08 11:31:20 -07:00
Pieter De Baets 1dd7bc1515 Remove RCTPackagerClientResponder references from Xcode projects
Reviewed By: ericnakagawa

Differential Revision: D5012951

fbshipit-source-id: c31732829790a46c5ff5134a6b8421ce934f41b6
2017-05-05 13:20:57 -07:00
Pieter De Baets e7680131d7 Merge RCTPackagerClient into RCTPackagerConnection
Reviewed By: mmmulani

Differential Revision: D4988204

fbshipit-source-id: 78e0df5268bfc11e4e0edf8e60494e55022cd9f2
2017-05-05 08:49:28 -07:00
Marc Horowitz b2f3a65eab Rename xcodeproj's so Cxx is the default
Reviewed By: javache

Differential Revision: D4981939

fbshipit-source-id: d2935aa04f30f025c6d5499604aaddf359b8eb14
2017-05-03 14:52:56 -07:00
Marc Horowitz dd45e7e1c4 Switch default bridge to CxxBridge
Reviewed By: javache

Differential Revision: D4981911

fbshipit-source-id: 49900a0e86d13045aa8930a865b073e1dec35e93
2017-05-03 14:52:56 -07:00
Valentin Shergin 18e0f84349 Use just `_bridge` instead of `batchedBridge` when actual bridge is already batched one
Reviewed By: javache

Differential Revision: D4989251

fbshipit-source-id: 939b54459d14e9bddd60be82787c2ca4d116200c
2017-05-03 11:16:31 -07:00
Alexey Lang 1c07658a1e Log RCTPLTTI for Warm Start
Reviewed By: javache

Differential Revision: D4962773

fbshipit-source-id: d01f8fe0d4e2f1e7453df03f9a15482f2f065a13
2017-05-03 09:30:54 -07:00
Alex Dvornikov 366c15d2b2 Use RCTDevLoadingView in a sample app
Reviewed By: javache

Differential Revision: D4985384

fbshipit-source-id: 1d5a33a6746010d3cf4ac524468af21bb9599f3e
2017-05-02 10:01:14 -07:00
Valentin Shergin 18fd18e792 Assertion on attempt to get layout metrics from dirtied Yoga node
Reviewed By: javache

Differential Revision: D4865294

fbshipit-source-id: e1bd2f297af87ffa817003f9e4dae94ad2c96644
2017-05-01 12:16:42 -07:00
Lukas Wöhrl 992e37c8bc Fix sizing of non strech items
Summary:
Fixes the sizing of items so that under most scenarios it calcultes its height by it's content for non exact measurings. This introduces a new useLegacyStretchBehaviour flag on the config to opt out of this change as it is breaking.

See facebook/yoga#505
Closes https://github.com/facebook/yoga/pull/506

Reviewed By: astreet

Differential Revision: D4954016

Pulled By: emilsjolander

fbshipit-source-id: d28bd5d174cd76951fb94df85e3b0cfab7f81ff7
2017-04-28 06:18:30 -07:00
Alex Dvornikov d1fb892715 Clean up after recent RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD changes
Reviewed By: javache

Differential Revision: D4969636

fbshipit-source-id: 49785dcf02e6544a313d82ccb26839ac2302c7d9
2017-04-28 05:35:41 -07:00
Pieter De Baets 96d13b663b Avoid presenting on view controller that's being dismissed
Summary:
Mitigates the issue in https://github.com/facebook/react-native/issues/10471, by not trying to present
a modal or alert view if the presenting view controller is already being dismissed.

Reviewed By: shergin

Differential Revision: D4962169

fbshipit-source-id: 593e3f21096458651d16677a3e030552f809bf02
2017-04-28 03:30:38 -07:00
Valentin Shergin ca07a5fd5f Adopting Yoga's YGConfig in RCTShadowView
Reviewed By: javache

Differential Revision: D4932540

fbshipit-source-id: 4a5ff3b34fc635b3291dff9a7c1a603179c90fa7
2017-04-27 13:05:55 -07:00
Alex Dvornikov db0c22192c Added support for synchronous methods in native modules on iOS
Reviewed By: javache

Differential Revision: D4947556

fbshipit-source-id: 0ef73dc5d741201e59fef1fc048809afc65c75b5
2017-04-27 12:03:30 -07:00
Valentin Shergin 91be5bfc86 Do not warn if `touch.force` is NaN
Reviewed By: jingc

Differential Revision: D4956972

fbshipit-source-id: e0d4d55e4e7ee352a8fc88a4cfd43dc3cabc9c48
2017-04-26 15:16:16 -07:00
Pieter De Baets 34bc6bd2ae Drop support for webworkers
Reviewed By: AaaChiuuu

Differential Revision: D4916449

fbshipit-source-id: a447233d3b7cfee98db2ce00f1c0505d513e2429
2017-04-25 05:37:54 -07:00
Alexey Lang 1bc9d448f5 Port perf metrics used in RCTBatchedBridge
Reviewed By: javache

Differential Revision: D4938279

fbshipit-source-id: c927261ff96c2eb07b7303ae96aae7600f2947f1
2017-04-25 02:32:25 -07:00
Valentin Shergin e7c6a4c038 Fixed crash caused by NaN values in RCTTouchEvent
Summary:
React Native uses JSON to marshal the data across the bridge.
And because of this we have to avoid using NaN and INF values in events and other pieces of data that suppose to be transfered to/from JS side.
(We also don't want to introduce additional wrapping/escaping semantics for perfomance reasons.)
So, we have to gate all particular cases where there is a possibility of NaN or INF values, and replace these value with something meaningful for each particular case.
We are using `0` as NaN substitution here because:
 * NaN in touch event is super rare case;
 * Conversion to `0` is fast;
 * `0` is okay value for product code in most cases;
 * In all cases `0` is decent analog to "undefined position on screen" for touch event;
 * Nobody will explicitly handle NaN case in product code, just because it is super rare case and actually indicates that something else went wrong.

Reviewed By: javache

Differential Revision: D4918669

fbshipit-source-id: e95fa29e59dcdc40b57519e307b74c1f293da188
2017-04-21 11:30:57 -07:00
Pieter De Baets 59378f71db Immediately trigger renderApplication from RCTRootView init
Reviewed By: fkgozali

Differential Revision: D4849610

fbshipit-source-id: 291a9bcdf0efe47d83130fe2675f3ef04a3f085b
2017-04-21 07:04:57 -07:00
William Schurman 39d19740d2 Expose shake-to-show dev menu setting via the bridge
Summary:
Apps commonly provide their own rage-shake menus or behaviors, including in dev builds where the dev menu is enabled on shake. Rather than try to override these settings via native code, it can be helpful to let the app define when to show the menu via the bridge.

See recent discussion in https://github.com/facebook/react-native/issues/1054
Closes https://github.com/facebook/react-native/pull/13563

Differential Revision: D4928745

Pulled By: javache

fbshipit-source-id: a5b30e1b198780bb560e1a6d528f727b3b7d4cb7
2017-04-21 03:02:52 -07:00
Pieter De Baets db8efd9c4b Split off websocket related items to RCTPackagerConnection
Reviewed By: cwdick

Differential Revision: D4588557

fbshipit-source-id: 3f4176b9bab2b06cacbb06f1ff514a5f99a76d73
2017-04-20 08:32:10 -07:00
wenzhao.yin 47f834a76d fix RCTMultipartDataTask Memory leaks
Summary:
In the Docs of `NSURLSession` ,

>IMPORTANT

>The session object keeps a strong reference to the delegate until your app exits or explicitly >invalidates the session. If you do not invalidate the session, your app leaks memory until it exits.

The RCTMultipartDataTask will cause memory leaks, it will make `RCTBatchedBridge` and ` RCTMultipartDataTask` will not release.

So call `[session finishTasksAndInvalidate];` at the end of `startTask` function.
Closes https://github.com/facebook/react-native/pull/12673

Reviewed By: shergin

Differential Revision: D4896497

Pulled By: javache

fbshipit-source-id: eb5f8761f67ad33a7de081a68a9a7e1d4329bfc0
2017-04-20 03:45:25 -07:00
Marc Horowitz 325228d6cf Remove RCTBatchedBridge rule and all uses from the tree
Reviewed By: AaaChiuuu, javache

Differential Revision: D4889438

fbshipit-source-id: ba103ace8802f0976e09af6b491442e9aa723f49
2017-04-19 17:00:43 -07:00
Connor McEwen 3122328023 Enable dev menu in tvOS simulator
Summary:
There was no easy way to pull up the dev menu in the tvOS simulator

Run the UIExplorer demo and press cmd+d to bring up the menu
Closes https://github.com/facebook/react-native/pull/13584

Differential Revision: D4916967

Pulled By: javache

fbshipit-source-id: 27f50031f65f35dad46ad5ade7b52c7d350b31a2
2017-04-19 15:29:56 -07:00
Emily Janzer bd0f9fbacb Only start observing in requestPermissions() if not already observing
Reviewed By: javache

Differential Revision: D4903744

fbshipit-source-id: d2700f59bae521de6c76f8a3d11d6d48f1c0e7d9
2017-04-19 11:30:36 -07:00
Andrew Tokarev 460e77d47d Fixing Race condition that happens with _wasBatchActive
Summary:
Issue Fix: #13485

Yet another race condition that was found by XCode's Thread Sanitizer.
Happens because wasBatchActive is read/write from multiple threads at the same time

- opened UIExplorer and see it works
- npm run test pass
- tested on own project as well

Signed CLA
Closes https://github.com/facebook/react-native/pull/13505

Differential Revision: D4906096

Pulled By: javache

fbshipit-source-id: 5d4329aafcfe9491ce0188fa1e2dd71e09b31031
2017-04-19 03:00:53 -07:00
Marc Horowitz e7fe3b165b Explicitly cast to (bool) where needed on objc with folly::dynamic
Reviewed By: yfeldblum

Differential Revision: D4711054

fbshipit-source-id: 00897ca703f0f3a8cddaf170fef53f9851b631af
2017-04-18 15:36:20 -07:00
Kevin Cooper e443b7379e More verbose error messages for iOS
Summary:
Output the reason for the error when failing to load source code. This was a big help when trying to diagnose https://github.com/facebook/react-native/issues/13299.

~~Unfortunately there still seems to be no way to get the offending line number (because `loadError.userInfo[RCTJSStackTraceKey]` is empty), but this is good enough.~~

Before:

```
[warn][tid:com.facebook.react.JavaScript][RCTBatchedBridge.m:510] Failed to execute source code. Unhandled JS Exception: SyntaxError
```

After:

```
[warn][tid:com.facebook.react.JavaScript][RCTJSCErrorHandling.mm:30] Couldn't get stack trace for http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:81886
[warn][tid:com.facebook.react.JavaScript][RCTBatchedBridge.m:510] Failed to execute source code. Unhandled JS Exception: SyntaxError Unexpected keyword 'var'
```
Closes https://github.com/facebook/react-native/pull/13561

Differential Revision: D4908501

Pulled By: javache

fbshipit-source-id: a316dc70739b917b3cc690309d0ff37a8bb5d412
2017-04-18 14:19:13 -07:00
Marc Horowitz 5e09242e26 Rename JSCSamplingProfiler to RCTJSCSamplingProfiler
Reviewed By: javache

Differential Revision: D4889427

fbshipit-source-id: 1f74416b858134ec3682b1302021131114763881
2017-04-18 13:22:01 -07:00
Douglas Lowder a97f494bf1 Add missing header to tvOS build
Summary:
**Motivation**

Without this change, unit tests and integration tests won't build and run for Apple TV.

**Test plan**

Run `scripts/objc-test-tvos.sh` after uncommenting the TEST line.
Closes https://github.com/facebook/react-native/pull/13456

Differential Revision: D4875309

Pulled By: javache

fbshipit-source-id: 9b6fa3b7107924ba0346bf8be63bba5fe45acb53
2017-04-12 16:15:15 -07:00
Pieter De Baets 9d1c62669b Add extra guards to DispatchMessageQueueThread
Reviewed By: bnham

Differential Revision: D4868432

fbshipit-source-id: 23d6c996aa97db82ea5e0e166e1988f4ce378b6f
2017-04-11 12:25:39 -07:00
Alex Dvornikov abd148fa21 Show redbox window on JS errors for debug builds
Reviewed By: javache

Differential Revision: D4860613

fbshipit-source-id: 255202df9401ffd1dfb48224dd89255eac76874e
2017-04-11 06:00:42 -07:00
Valentin Shergin ca6e0b37cf `reactRespondsToTouch:` was removed
Summary:
* It complicates Touch Handling mechanism.
* The same functionality can be (and should be) implemented via overriding standard `hitTest:` method.
* It was marked as deprecated a while ago.

Reviewed By: mmmulani

Differential Revision: D4667776

fbshipit-source-id: 2e047c3308563a2849ea351a242270f0800fead2
2017-04-10 12:32:31 -07:00
Pieter De Baets 2336ac299c Improve constant extraction from RCTNativeModule
Reviewed By: dcaspi

Differential Revision: D4829671

fbshipit-source-id: 6b1cef1d31c7d8981c6f1e304d3742e885f8a83b
2017-04-08 15:18:08 -07:00
Pieter De Baets f3dfd616f4 Allow lazy Cxx modules to not initialize
Reviewed By: mhorowitz

Differential Revision: D4851596

fbshipit-source-id: cf5f5c51b9aaa0da96f7ab6fba1277b72c988400
2017-04-08 15:18:08 -07:00
Pieter De Baets 5767b98f4d Add JSC utility header to RCTBridge
Reviewed By: shergin

Differential Revision: D4823509

fbshipit-source-id: 79c96d3bc183d89a5dec7da06b0a0a710d8c7dea
2017-04-07 11:16:59 -07:00
Pieter De Baets 76b93e1253 Add block-based initializer for RCTModuleData
Reviewed By: shergin

Differential Revision: D4821772

fbshipit-source-id: 2cd35ec6726b6fe1494a92966ade5aa0b86e769b
2017-04-07 11:16:59 -07:00
Ben Roth 540f4c9638 Fix crash in `RCTRedBox::formatFrameSource:`
Summary:
Motivation: Similar to https://github.com/facebook/react-native/pull/13242 - the application will crash with `[NSNull lastPathComponent]: unrecognized selector sent to instance` if a stack frame with no filename makes it to RCTRedBox.
Closes https://github.com/facebook/react-native/pull/13360

Differential Revision: D4848980

Pulled By: javache

fbshipit-source-id: dc506f2ba39c2d4d68982b56a6e765a19dc048b0
2017-04-07 11:03:56 -07:00
Pieter De Baets ceac54ebe9 Use forward declaration in RCTCxxModule
Reviewed By: mhorowitz

Differential Revision: D4821449

fbshipit-source-id: 8e75a7b17e0986bc9416a0afde0d7dfa179d4fed
2017-04-07 09:30:33 -07:00
Pieter De Baets b2647ea335 Allow ModuleRegistry initialization to complete lazily
Reviewed By: mhorowitz

Differential Revision: D4794794

fbshipit-source-id: f3b7a5d02587b4cd4e214aa6b0368a0d214fb63f
2017-04-07 09:30:33 -07:00
Shruti Malugu 39eb090906 Fixing another iOS app extension unsafe API usage in react native
Summary:
Thanks for submitting a PR! Please read these instructions carefully:

- [yes] Explain the **motivation** for making this change.
    Using react-native library inside iOS app extension causes a compile error inside react native stating that usage of UIAlertView is not allowed inside iOS app extension and should use UIAlertController instead. I have updated the code to use UIAlertController based on the other instances of the UIAlertController usage in the react-native library

- [ partial ] Provide a **test plan** demonstrating that the code is solid.
This code should be launched when developers start the profiler from the React native debug menu. I am currently in process of upgrading my app from 0.34 to the latest react native ( aka app not in working state). Would appreciate if there is an alternative way for me to test this functionality out.

Just tried to create a new react-native project using "react-native init testproject" and upon running "react-native run-ios", I  hit the following error a
Closes https://github.com/facebook/react-native/pull/13328

Differential Revision: D4844559

Pulled By: javache

fbshipit-source-id: e516ca57cb2abf2b09aa53abecb0fe60a40190b4
2017-04-06 12:30:55 -07:00
Alex Dvornikov b3872e807d Check that RCTDidInitializeModuleNotification is being called with the correct bridge
Reviewed By: javache

Differential Revision: D4800110

fbshipit-source-id: acc8bc512ed17a84abeac74afb91db51ab4c5043
2017-04-06 00:46:05 -07:00
Alex Dvornikov 37c1678421 Report JS errors in debug console
Reviewed By: javache

Differential Revision: D4835405

fbshipit-source-id: d10658d1b885048ea3495388450208bb0e29ee5b
2017-04-05 19:51:03 -07:00
Pieter De Baets ff95805657 Fix YGEnums references in ReactCxx.xcodeproj
Summary:
cc ericvicenti
Closes https://github.com/facebook/react-native/pull/13301

Differential Revision: D4830381

Pulled By: ericvicenti

fbshipit-source-id: 866864ac34f6c873c1646e59cd0245b3f6634d7e
2017-04-04 15:40:04 -07:00
Douglas Lowder 6a81de37d4 Add YGEnums to tvOS build
Summary:
**Motivation** Fix the Apple TV build, which is broken after a recent commit.

**Test plan** Travis tvOS test script should succeed.
Closes https://github.com/facebook/react-native/pull/13284

Differential Revision: D4827053

Pulled By: ericvicenti

fbshipit-source-id: 380e8f1b32adfeea844bedc11326e5a6a755066a
2017-04-04 10:00:36 -07:00
Pieter De Baets e0bd35f76f Fix order of timers called in the same frame
Reviewed By: mmmulani

Differential Revision: D4802858

fbshipit-source-id: 8d8400c20b7e487aea5a0943f91ac7adc2d23108
2017-04-03 18:48:48 -07:00
Valentin Shergin bc1ea548d0 Better TextInput: Simplified focus/first-responder management on iOS
Summary:
Pair `reactWillMakeFirstResponder` and `reactDidMakeFirstResponder` was replaced with just `reactFocus` method
which is supposed to incapsulate all "focus" and "focus-later-if-needed" functionality.

Reviewed By: mmmulani

Differential Revision: D4664626

fbshipit-source-id: 8d3b7935ca26d32ba1d1826a585cce0396fcc885
2017-04-03 15:16:16 -07:00
Emil Sjolander beb559d9cf Fix xcode project file
Reviewed By: ericvicenti

Differential Revision: D4821749

fbshipit-source-id: 19730209557c58457e6cc67916e9a8cb944fb963
2017-04-03 14:33:52 -07:00
Shruti Malugu edbb48c67a Replacing all instances of [UIApplication sharedApplication] wi…
Summary:
…th RCTSharedApplication()

Thanks for submitting a PR! Please read these instructions carefully:

- [ ] Explain the **motivation** for making this change.
          Using React Native latest version with Cocoapods 1.2.0 causes the following error inside iOS app extensions

> /react-native/React/Modules/RCTAccessibilityManager.m:67:70: ‘sharedApplication’ is unavailable: not available on iOS (App Extension) — Use view controller based solutions where appropriate instead.

Moving the use of [UIApplication sharedApplication] to RCTSharedApplication() which is safe on app extension

- [ ] Provide a **test plan** demonstrating that the code is solid.
        I am not sure how to test such that all the features which touch the modified code are tested.

- [ ] Match the **code formatting** of the rest of the codebase.
- [ ] Target the `master` branch, NOT a "stable" branch.

What existing problem does the pull request solve?
    Using React Native latest v
Closes https://github.com/facebook/react-native/pull/13227

Differential Revision: D4816338

Pulled By: javache

fbshipit-source-id: e3e3c77882990ad1817b0b633521cff52571ecd0
2017-04-01 03:34:41 -07:00
Ben Roth 9075fe0618 Fix crash in `RCTJSStackFrame::stackFrameWithDictionary:`
Summary:
Motivation: When logging to RCTRedBox, if any of the stack frames lacks a line number or a column, the application will crash with `[NSNull integerValue]: unrecognized selector sent to instance`.
Closes https://github.com/facebook/react-native/pull/13242

Differential Revision: D4812185

Pulled By: hramos

fbshipit-source-id: 4b1c3c38f67cf59034a383c95d4280d1b6380300
2017-03-31 13:32:47 -07:00
Pieter De Baets e12e57eb77 Move bindKeys to RCTBridge setUp
Reviewed By: shergin

Differential Revision: D4794788

fbshipit-source-id: 0839829f4ed010bf2fb2574092a8f68f4c95341a
2017-03-31 05:31:26 -07:00
Pieter De Baets f6754348be Merge RCTPlatform.isTesting and RCTRunningInTestEnvironment
Reviewed By: fkgozali

Differential Revision: D4802834

fbshipit-source-id: 76bb98877f2fc427c01806b192d8dc71489a1c4a
2017-03-30 10:02:35 -07:00
Pieter De Baets 5af30382d5 Improve fbsystrace support
Reviewed By: mhorowitz

Differential Revision: D4756318

fbshipit-source-id: 7811f680a7ad044b5ae028ee9b2fed5f46ce2a63
2017-03-30 06:53:16 -07:00
Ben Alpert 1d367004e9 Improve feel of scroll snapping behavior on iOS
Reviewed By: sahrens, shergin

Differential Revision: D4768384

fbshipit-source-id: 6319d058292be6ba38c059d8d1a1bf70bac603e2
2017-03-29 07:16:01 -07:00
Janic Duplessis ec5baf02bd Fix cxx bridge headers when archiving
Summary:
There were some headers that were in the `public` or `private` section instead of `project` this causes headers to be included in archives and prevent it from being able to be uploaded to the app store. This fixes it by using only `project` headers and copy files like we use in other places.

Also fixes a file that was moved and not updated in ReactCxx.xcodeproj.

**Test plan**
Tested that I am now able to upload an archive on the app store.
Closes https://github.com/facebook/react-native/pull/13008

Differential Revision: D4779894

Pulled By: javache

fbshipit-source-id: 6e36e925cc3fc03c095c9f1872eb5a45b7f0d78c
2017-03-28 06:45:56 -07:00
Janic Duplessis c9fae2fb93 Native Animated - Restore default values when removing props on iOS
Summary:
This fixes a bug that causes properties to keep stale values because they were not restored to their default after being removed when their value was controlled by native animated.

To fix this we restore default values in `disconnectFromView` by updating views with null values for all props that we modified previously. However this causes another issue where we lose any props that were set by the normal process because NativeAnimated operations are always executed after UIManager operatations. To fix this I added a way to hook into UIManager view updating process to be able to execute NativeAnimated operations either before or after updating native views.

In the case of disconnecting we want to do it before updating views so that it does: Value changed by native animated -> value restored to default -> (optional) value updated by normal prop.

This PR also depends on #10658.

**Test plan**
Tested that this fixed a particular bug in an app that uses ex-navigation + native animations where a navbar w
Closes https://github.com/facebook/react-native/pull/11819

Differential Revision: D4752566

Pulled By: javache

fbshipit-source-id: 68ee28200ffeba859ae1b98ac753bd7dcb8910f0
2017-03-28 05:33:02 -07:00
Sokovikov c87c4d052f Fixed previously broken support for negative `scale` (`transform` style property)
Summary:
closes #13081

UIExplorer, TransformExample
Closes https://github.com/facebook/react-native/pull/13083

Reviewed By: mmmulani

Differential Revision: D4758237

Pulled By: shergin

fbshipit-source-id: 58385a4cde7a739b6657c293c381644a92918265
2017-03-24 18:15:42 -07:00
Pieter De Baets 7c9173bc9e Enable -Wimplicit-retain-self en sync warning config for all projects
Summary:
This is enforced for all of our internal iOS code and a common cause of import failures.

cc janicduplessis
Closes https://github.com/facebook/react-native/pull/13124

Differential Revision: D4765016

fbshipit-source-id: 7c8248c98bca0fa6bad24d5a52b666243375e0db
2017-03-23 15:01:34 -07:00
Pieter De Baets 9d377e98a0 Fix warnings in React.xcodeproj
Summary:
Various fixes of xcode projects and cleaning up some warnings
Closes https://github.com/facebook/react-native/pull/13109

Differential Revision: D4762652

Pulled By: lacker

fbshipit-source-id: b452976a58962439de4adecc8e703264af40cb38
2017-03-23 11:36:17 -07:00
Pieter De Baets 0ea1ea5fb7 Remove unused websocket-executor-name and websocket-executor-port options
Reviewed By: davidaurelio

Differential Revision: D4745529

fbshipit-source-id: 2c69aca33c999ccf2af8dbf8d9af2c1d123b59cd
2017-03-22 05:38:04 -07:00
Marc Horowitz ba149d7277 Tease apart React and RCTBatchedBridge targets
Reviewed By: javache

Differential Revision: D4679655

fbshipit-source-id: 8123488c2d50dd7cc2329b5131e99998fe1f1e2f
2017-03-21 18:31:23 -07:00
Marc Horowitz d9ac00735c Make the choice of bridge based on an optional delegate method
Reviewed By: javache

Differential Revision: D4679644

fbshipit-source-id: f53e554e283fdb0b59c41623e690fd1a21e03a57
2017-03-21 18:31:23 -07:00
Pieter De Baets 314ec87269 Remove unused CxxMessageQueue
Differential Revision: D4713064

fbshipit-source-id: 511b782279b89076228f00290e78ed155e2e723e
2017-03-21 12:46:27 -07:00
Ben Roth b3be5743e9 Fix property accessor warning in RCTDevSettings::websocketExecutorName
Summary:
Motivation: Fixes Xcode warning `Ivar '_websocketExecutorName' which backs the property is not referenced in this property's accessor` which shows up because this property has no setter (and is never set anywhere).
Closes https://github.com/facebook/react-native/pull/12639

Differential Revision: D4745437

Pulled By: javache

fbshipit-source-id: 3ab4b0df62f90adc2b62d891197dc783e07da4e3
2017-03-21 04:20:02 -07:00
Daniele Conti 08c404d293 Eagerly change the listeners count
Summary:
While working with `RCTEventEmitter` I noticed that if an event is emitted before `_listenerCount` is updated, it will not go through because the listeners count hasn't been updated. Moving the count update before the invokation of `startObserving` and `stopObserving` fixes the issue. Same way if you remove the last listener and an event is fired before the count is updated (while it shouldn't be fired).

**Test plan (required)**

An easy test to demonstrate it is to implement `startObserving` to synchronously fire an event. Without the change, a warning is thrown, with the change, the event is fired. Not very strong on Obj-C here and I didn't know how to mock out the native stuff. Would be glad to write a failing unit test tho :)
Closes https://github.com/facebook/react-native/pull/11907

Differential Revision: D4738965

Pulled By: javache

fbshipit-source-id: cf175051be5b9c5de761d3dcd290560e1639b05e
2017-03-20 12:49:00 -07:00
Jhen f352aa129a Add missing `toggleElementInspector` event send when `jsLoaded`
Summary:
- [x] Explain the **motivation** for making this change.
- [x] Provide a **test plan** demonstrating that the code is solid.
- [x] Match the **code formatting** of the rest of the codebase.
- [x] Target the `master` branch, NOT a "stable" branch.

The PR #11613 (0.43) removed this missing `toggleElementInspector` event send when `jsLoaded` in DevMenu (Now is DevSettings), it should open the inspector if `isElementInspectorShown` is true when we reload JS.

The dev menu text `Show / Hide Inspector` is dependent on `isElementInspectorShown` bool value.

([This behavior in 0.42](https://github.com/facebook/react-native/blob/0.42-stable/React/Modules/RCTDevMenu.mm#L436-L442))

Manual testing in UIExplorer:

* Open the dev menu and click `Show Inspector`
* Open the dev menu and click `Reload JS`
* The built-in inspector should keep open (dev menu text: `Hide Inspector`)
Closes https://github.com/facebook/react-native/pull/12999

Differential Revision: D4738959

Pulled By: javache

fbshipit-source-id: b3f584db51aa0e1b463c52003967b00bcd81bc99
2017-03-20 12:49:00 -07:00
Jeff Thomas 439889262c RCTLocalAssetImageLoader: Add searching shipped frameworks beyond mainBundle
Reviewed By: javache

Differential Revision: D4715608

fbshipit-source-id: 5cb2febf543e2ff6e30d0c6d8737de9a2cce2383
2017-03-20 12:00:44 -07:00
Valentin Shergin b53d76efb7 Better TextInput: RCTUITextView was decoupled in separate file and now handles placeholder feature
Reviewed By: mmmulani

Differential Revision: D4663151

fbshipit-source-id: ce57ca4bebf4676df2ae5e586a1b175ec2aac760
2017-03-20 00:02:58 -07:00
Valentin Shergin 1b013cd30c Better TextInput: Fixing multiline <TextInput> insets and prepare for auto-expanding feature
Summary:
Several things:
 * The mess with insets was fixed. Previously we tried to compensate the insets difference with `UITextField` by adjusting `textContainerInset` property, moreover we delegated negative part of this compensation to the view inset. That was terrible because it breaks `contentSize` computation, complicates whole insets consept, complicates everything; it just was not right. Now we are fixing the top and left inset differences in different places. We disable left and right 5pt margin by setting `_textView.textContainer.lineFragmentPadding = 0` and we introduce top 5px inset as a DEFAULT value for top inset for common multiline <TextInput> (this value can be easilly overwritten in Javascript).
 * Internal layout and contentSize computations were unified and simplified.
 * Now we report `intrinsicContentSize` value to Yoga, one step before auto-expandable TextInput.

Depends on D4640207.

Reviewed By: mmmulani

Differential Revision: D4645921

fbshipit-source-id: da5988ebac50be967caecd71e780c014f6eb257a
2017-03-20 00:02:55 -07:00
Valentin Shergin d272334186 RCTRootView is now has empty autoresizing mask by default
Summary: `autoresizingMask` is supposed to be set outside self class, this is UIKit convention.

Reviewed By: mmmulani

Differential Revision: D4697098

fbshipit-source-id: 7e0aa5d3032184de980b3cecafebbc4ce8ef9ada
2017-03-19 22:01:56 -07:00
Valentin Shergin 64c327ae68 Fixed issue where setting `zero scale` transfrom matrix to UIView brokes `hitTest` mechanism
Summary:
The Math Strikes Back

Several related things:
 * When we specify `scale: 0;` style for some view it ends up with calling `CATransform3DScale` with zero scale parameter.
 * In this case `CATransform3DScale` returns transform matrix full of zeros. It actually depends on representation and matrix-type (2d or 3d) but in UIView debugger it appears as [0, 0, 0, 0, ...]. And probably it is correct result.
 * By default, for hit-testing, UIKit uses specially optimized logic based on GPU/CALayer infrastructure under the hood. And the transform matrix full of zeros breaks this algorithm. I guess, it happens because zero-matrix doesn't quite make sense.

So, `scale: 0;` is a weird edge case, and in this diff, we are trying to illuminate it by replacing with epsilon value.

Related SO issues:
http://stackoverflow.com/questions/25964224/cgaffinetransformscale-not-working-with-zero-scale
http://stackoverflow.com/questions/7937369/animate-uiview-scale-to-zero

Reviewed By: blairvanderhoof

Differential Revision: D4734475

fbshipit-source-id: 7241cdffa86c05a6552860a25789e2281588ba23
2017-03-19 22:01:55 -07:00
Ashwin Bharambe f48b54bf62 Expose RCTImageLocalAssetURL as a utility
Reviewed By: javache

Differential Revision: D4696627

fbshipit-source-id: 56d3e59983f524dfd5021835734b9b34203e20f2
2017-03-17 17:02:06 -07:00
Ashwin Bharambe 95c1926193 Introduce `DeviceInfo` as a new native module
Summary:
The `UIManager` already has a lot of responsibilities and is deeply
tied with React Native's view architecture. This diff separates out a
`DeviceInfo` native module to provide information about screen dimensions and
font scale, etc.

Reviewed By: fkgozali

Differential Revision: D4713834

fbshipit-source-id: f2ee93acf876a4221c29a8c731f5abeffbb97974
2017-03-17 17:01:57 -07:00
Pieter De Baets ce270220e4 Extract module registry creation to helper
Reviewed By: mhorowitz

Differential Revision: D4721817

fbshipit-source-id: 2fa17ca5317a57d429aa75d6c1865932af27e02f
2017-03-17 07:08:14 -07:00
Pieter De Baets ea069b69de Make Cxx modules lazy on iOS
Reviewed By: mhorowitz

Differential Revision: D4716040

fbshipit-source-id: 08cc1317e15f0b3bd1df6d76c483a560f5c43d53
2017-03-17 07:08:14 -07:00
Pieter De Baets 73e81b87d3 Remove unused onNativeException delegate method
Reviewed By: mhorowitz

Differential Revision: D4597914

fbshipit-source-id: 82a109d1e6d8b0c93380840c22ec74dc75ab1a45
2017-03-17 07:08:14 -07:00
Pieter De Baets d7b37c4050 Remove JsToNativeBridge's nativeQueue
Reviewed By: mhorowitz

Differential Revision: D4589737

fbshipit-source-id: 3b2730417d99c4f98cfaad386bc50328f2551592
2017-03-17 07:08:14 -07:00
Jakub Woyke b8cc75c613 Don't call libc malloc and free directly from assembly
Reviewed By: strager, javache

Differential Revision: D4484300

fbshipit-source-id: 97b9c2e9525f38c9158cfb499ba93d1af7d84b69
2017-03-16 12:34:06 -07:00
Ashok Menon d5dda1b136 Adding in missing wrapper invocation.
Reviewed By: javache

Differential Revision: D4714260

fbshipit-source-id: 641dfd07e8161bedf31cfd4cf94b1dc64beec0f9
2017-03-15 18:30:20 -07:00
ShiHui 1195a8f3e6 Fix RCTPicker crash
Summary:
If user slide picker when picker item is zero, `UIPickerViewDelegate` will call `pickerView:didSelectRow:inComponent` row=0, `_items[row][@"value"]` will crash.
Closes https://github.com/facebook/react-native/pull/12187

Differential Revision: D4709882

Pulled By: mkonicek

fbshipit-source-id: 772c819d4eaef41ac983287877bda2918f40b1a7
2017-03-14 17:46:24 -07:00
Janic Duplessis 22151d28d4 Fix ReactCxx xcodeproj
Summary:
The ReactCxx project was not updated when RCTMap was removed in 48f30eca7e, this fixes it. It was also missing the systemJSCWrapper.cpp file.

**Test plan**
Tested that UIExplorerCxx now builds

cc mkonicek
Closes https://github.com/facebook/react-native/pull/12919

Differential Revision: D4709498

Pulled By: mkonicek

fbshipit-source-id: 995a1a914ab0a3227b1219c575a84d136800ff19
2017-03-14 16:46:00 -07:00
Marc Horowitz e622d51e20 Support ModuleHolder-based lazy init of C++ modules with C++ bridge on android
Reviewed By: AaaChiuuu

Differential Revision: D4614479

fbshipit-source-id: 109ac34b8688f0113675e4a4479d1ddcc6169ed4
2017-03-14 15:35:01 -07:00
Valentin Shergin 98798a06ae More accurate implementation of `RCTRootView`'s `sizeThatFits:`
Reviewed By: mmmulani

Differential Revision: D4672788

fbshipit-source-id: 780487f2264916349e32785808a93ed6f957e471
2017-03-13 13:30:31 -07:00
Pieter De Baets 41f3d0cf2d Expose getter for 'flex' property
Summary: Helps mitigate part of https://github.com/facebook/react-native/pull/12245 while we wait for a more comprehensive solution.

Reviewed By: emilsjolander

Differential Revision: D4571776

fbshipit-source-id: 185cd1b0d3af37724136a37471df412c2000dfe4
2017-03-13 06:00:19 -07:00
Douglas Lowder 02a6621e23 Add systemJSCWrapper.cpp to React-tvOS target
Summary:
**Motivation**: Fix Apple TV build breakage

**Test plan**: This fixes Travis test that builds tvOS targets.
Closes https://github.com/facebook/react-native/pull/12869

Differential Revision: D4692883

fbshipit-source-id: 3babfe4ab6d80143e15410bff7cae41ada3bf09f
2017-03-10 16:30:33 -08:00
Martin Konicek a8bd4621af Try to fix tvOS and podspec builds
Summary: Closes https://github.com/facebook/react-native/pull/12866

Differential Revision: D4691348

Pulled By: ericvicenti

fbshipit-source-id: df7d611aa4ed3fed6158d2210a0403c90875b7c3
2017-03-10 13:17:18 -08:00
Theo Yaung acb9fa8f66 Refactor dependencies
Reviewed By: mkonicek

Differential Revision: D4689351

fbshipit-source-id: 35e6939379dcb6723e7749883ad9613459f9787b
2017-03-10 09:15:50 -08:00
Martin Konicek 5c24a9110a Update Boost dependency to 1.63 on iOS
Summary:
We use this version internally.
Closes https://github.com/facebook/react-native/pull/12838

Differential Revision: D4688982

Pulled By: mkonicek

fbshipit-source-id: d8a6f8168b9e71ff4f53a8c18d55dc5a759a9183
2017-03-10 05:45:28 -08:00
Valentin Shergin 264d60b979 Setting `availableSize` for `RCTRootShadowView` on earlier stage
Summary:
Moving setting `availableSize` for `RCTRootShadowView` on earlier stage allows to prevent situations where `availableSize` is not specified yet, but Yoga layout is already happening.
Because `availableSize` equals {infinity, infinity} by default (in this case), Yoga returns a lot of nodes with infinit metrics, which confises UIKit.

Reviewed By: mmmulani

Differential Revision: D4672170

fbshipit-source-id: f9d8c84799dcbdb6b9230ddef6284d84df268833
2017-03-08 19:00:14 -08:00
Adam Comella 22b3faf1ad iOS: Expose fontScale to JavaScript
Summary:
A related Android PR is #11008.

Font scale was exposed through:
  - The `getContentSizeMultiplier` method
  - The `didUpdateContentSizeMultiplier` event

These are now deprecated. The reason is that there was already an API that exposed font scale. However, it was Android only. We now expose font scale through that API on iOS as well. Specifically:
  - Font scale is now available as `PixelRatio.getFontScale()`.
  - The `change` event on the `Dimensions` object now fires when font scale changes.

This change also adds support for `Dimensions.get('screen')` on iOS. Previously, only `Dimensions.get('window')` was available on iOS. The motivation is that, [according to this comment](https://github.com/facebook/react-native/pull/11008#issuecomment-275123609), we'd like to deprecate `window` dimensions in favor of `screen` dimensions in the future.

**Test plan (required)**

Verified that `PixelRatio.getFontScale()` and the `change` event work properly in a test app.

Adam Comella
Microsoft Corp.
Closes https://github.com/facebook/react-native/pull/12268

Differential Revision: D4673642

Pulled By: mkonicek

fbshipit-source-id: 2602204da6998a96216e06f5321f28f6603e4972
2017-03-08 05:59:41 -08:00
Martin Konicek 48f30eca7e Move iOS Maps out of the GitHub repo to internal fb codebase
Summary:
MapView has been deprecated in open source for a while: http://facebook.github.io/react-native/docs/mapview.html
We still want to use it internally. Moving it away from the GitHub folder.

Reviewed By: mmmulani

Differential Revision: D4646199

fbshipit-source-id: f469971e448dbca12afe141b43fa8a2518c7d467
2017-03-08 05:01:36 -08:00
Marc Horowitz cb3a439d17 Upgrade double-conversion to 1.1.5
Reviewed By: ericvicenti

Differential Revision: D4662924

fbshipit-source-id: ecf4a3d8aee8a3def1d8308456ca2551b4669f63
2017-03-07 12:08:40 -08:00
Mehdi Mulani 0a06250d24 Add build-time check that module methods are exported correctly
Summary:
This prevents someone from only putting `RCT_EXPORT_METHOD(...)` around some of the arguments to a method and generally causing confusion. Yes, before this diff it would still compile correctly if you did something like:

```
RCT_EXPORT_METHOD(lol:(NSNumber *)lol)
blah:(id)blah
{
  NSLog(@"%@ %@", lol, blah);
}
```

Reviewed By: fkgozali

Differential Revision: D4660019

fbshipit-source-id: 1829a47e5c8d5e8ce93edca2ac7efd7e2bfdf840
2017-03-07 10:45:36 -08:00
Marc Horowitz d1411f11d3 Drop calls to [RCTCxxBridge enqueueCallback:args:] on an invalid instance
Reviewed By: mmmulani

Differential Revision: D4655339

fbshipit-source-id: a6cb026325a030fa15a25638ebfb17ac9ea53767
2017-03-06 12:03:30 -08:00
Janic Duplessis 7d06c35d1c Run install third party script as part of the xcode build
Summary:
Runs the `./ios-install-third-party.sh` script as part of the build process to avoid having to do it manually when building the cxx bridge with xcode. Also added the third-party dir to gitignore.

**Test plan**
Tested that just building works when the third-party dir is missing.
Closes https://github.com/facebook/react-native/pull/12694

Differential Revision: D4658165

Pulled By: ericvicenti

fbshipit-source-id: 9b51b88eb26637b19266bf85deafa41e3a77a645
2017-03-06 00:00:55 -08:00
Janic Duplessis 5353d39172 Remove unused native iOS sticky headers implementation
Summary:
Remove the native iOS sticky headers implementation that has been replaced by the js Animated one. Also remove a line in JS that made sure we passed null to native so it did not use the native implementation.

**Test plan**
Made sure there were no more mentions of sticky / header in native ScrollView related code.
Tested that sticky headers still work :o
Closes https://github.com/facebook/react-native/pull/12696

Differential Revision: D4657391

Pulled By: ericvicenti

fbshipit-source-id: 16324a45ca4ce5cd143293c61394a0fa7ad0c4a1
2017-03-05 14:21:40 -08:00
Kevin Gozali c04e79e85a iOS: fixed RCTDevSettings executor-override handling
Summary: RCTDevSettings incorrectly assigned "bad" executor-override class to the executor instead of checking if the class exists before assigning it. It should really check if the class exists, and fallback to defaults otherwise.

Reviewed By: mmmulani, yungsters

Differential Revision: D4655926

fbshipit-source-id: 48c8fe28f22aaa8430752411ce5e6e858dbd4b32
2017-03-04 16:47:11 -08:00
Marc Horowitz 218e37dbab Fix missing/renamed files so OSS builds again
Reviewed By: ericvicenti

Differential Revision: D4652383

fbshipit-source-id: 04f816c333aba81d936135d7e5fc29a8f9de3af7
2017-03-03 14:17:14 -08:00
Emil Sjolander 4d69f4b2d1 Add display:none support to react native
Summary:
This diff adds display:none support to React Native. This enables hiding components which still calling their render method and keeping them within the state of your application. This enables preserving state in a component even though the component is not visible. Previously this was often implemented by rendering a component off screen as a work around. See below playground for usage.

```
class Playground extends React.Component {
  render() {
    return (
      <View style={{width: '100%', height: '100%', flexDirection: 'row', backgroundColor: 'white'}}>
        <View style={{width: 100, height: 100, display: 'none', backgroundColor: 'red'}}/>
        <View style={{width: 100, height: 100, backgroundColor: 'blue'}}/>
      </View>
    );
  }
}
```

Reviewed By: astreet

Differential Revision: D4611771

fbshipit-source-id: 0dbe0494d989df42994ab9ad5125d47f3233cc5a
2017-03-01 09:16:05 -08:00
Emil Sjolander 31f848a5fa Expose alignContent to react native
Summary:
This diff adds alignContent (https://developer.mozilla.org/en-US/docs/Web/CSS/align-content) support to React Native. This enables aligning the lines of multi-line content. See below playground for example usage.

```
class Playground extends React.Component {
  render() {
    return (
      <View style={{width: '100%', height: '100%', flexDirection: 'row', backgroundColor: 'white', flexWrap: 'wrap', alignContent: 'space-between'}}>
        <View style={{width: 100, height: 100, marginLeft: 10, marginTop: 10, backgroundColor: 'red'}}/>
        <View style={{width: 100, height: 100, marginLeft: 10, marginTop: 10, backgroundColor: 'red'}}/>
        <View style={{width: 100, height: 100, marginLeft: 10, marginTop: 10, backgroundColor: 'red'}}/>
        <View style={{width: 100, height: 100, marginLeft: 10, marginTop: 10, backgroundColor: 'red'}}/>
        <View style={{width: 100, height: 100, marginLeft: 10, marginTop: 10, backgroundColor: 'red'}}/>
        <View style={{width: 100, height: 100, marginLeft: 10, marginTop: 10, backgroundColor: 'red'}}/>
        <View style={{width: 100, height: 100, marginLeft: 10, marginTop: 10, backgroundColor: 'red'}}/>
      </View>
    );
  }
}
```

Reviewed By: astreet

Differential Revision: D4611803

fbshipit-source-id: ae7f6b4b7e9f4bc78d2502da948214294aad4dd2
2017-03-01 09:16:05 -08:00
Emil Sjolander cc275557be Add margin auto support to react native
Summary:
This diff adds margin:auto (https://drafts.csswg.org/css-flexbox-1/#auto-margins) support to React Native. This enables layout not previously supported without inserting empty 'spacer' views. See below Playground for usage.

```
class Playground extends React.Component {
  render() {
    return (
      <View style={{width: '100%', height: '100%', flexDirection: 'row', backgroundColor: 'white'}}>
        <View style={{width: 100, height: 100, backgroundColor: 'red'}}/>
        <View style={{width: 100, height: 100, marginLeft: 'auto', backgroundColor: 'blue'}}/>
      </View>
    );
  }
}
```

Reviewed By: astreet

Differential Revision: D4611753

fbshipit-source-id: e78335565c193f7fb263129a638b444715ba5ab0
2017-03-01 09:16:05 -08:00
Emil Sjolander 23f2f5f239 default root node to size of parent contraints
Reviewed By: dshahidehpour

Differential Revision: D4634616

fbshipit-source-id: 089eb4313c5bb810a6ff56f158cd19cec71808ec
2017-03-01 07:15:23 -08:00
Marc Horowitz 611661e5fe TODO is done
Reviewed By: AaaChiuuu

Differential Revision: D4614454

fbshipit-source-id: 48d66b26371834e35c43731a22abc015fc234650
2017-02-28 14:15:57 -08:00
Emil Sjolander 702564fb60 Pass the parent size to YGNodeCalculateLayout instead of the node size
Reviewed By: astreet

Differential Revision: D4611417

fbshipit-source-id: 2fb0eedffa17f0ec89b601722a1717a72e216b9e
2017-02-28 08:14:51 -08:00
Valentin Shergin b00c1fa3b6 `accessibilityViewIsModal` property was exposed for any view (iOS only)
Reviewed By: mmmulani

Differential Revision: D4582786

fbshipit-source-id: 0902b8cc762042e772798ea7eaa350bc9d737cfb
2017-02-27 23:46:14 -08:00
Eloy Durán 19caaba1d5 Fixes current CI failures and allows tree shaking of native dev support code.
Summary:
* The dev support code moved into a `DevSupport` subspec, meaning that only if the subspec is specified in the user’s Podfile will the packager client, dev menu, etc be included. This is mainly done through checks for header availability.

  It also improves the weird situation where you had to specify the `RCTWebSocket` subspec if you wanted to be able to use the packager client during development.

* I removed hardcoding the release version in the podspec on release, because the podspec still relies on `package.json` when evaluating, so there’s no real point in not also getting the version number from there. This should remove any requirement to perform maintenance of the OSS release script regarding the podspec.
Closes https://github.com/facebook/react-native/pull/12602

Differential Revision: D4621021

Pulled By: ericvicenti

fbshipit-source-id: 6c208371fc40ea607809a6ab05dd3714ed9980cf
2017-02-27 14:04:58 -08:00
Valentin Shergin e7cc1bcbba RCTRootView's `intrinsicSize` property was deprecated in favour of `intrinsicContentSize`
Summary:
Nothing actually changed except the deprecation.
Existed `intrinsicSize` was already implemented as `intrinsicContentSize` and this change only removes redundancy.
Moreover, we do not need `rootViewDidChangeIntrinsicSize` delegate method anymore; this is now mentioned in its description.

Depends on D4577890

Reviewed By: mmmulani

Differential Revision: D4589344

fbshipit-source-id: 16ed62cbf6bf72678bd7f7c11d4812c5aa36c743
2017-02-27 14:04:58 -08:00
Valentin Shergin 9dccff0eda Better support of UIKit layout stuff for RCTRootView an co.
Summary:
Now RCTRootView is much more reliable citizen of UIKit, it got:
 * Implemented `sizeThatFits:`;
 * Implemented `instrinsicContentSize`;
 * Notifying superview via `setNeedsLayout` about changed size.

All it make possible painless integration of ReactNative-powered widgets inside existing native apps.

Reviewed By: javache

Differential Revision: D4577890

fbshipit-source-id: 9897cb002c9d658a97fd436240c2ac947ba2084b
2017-02-27 14:04:58 -08:00
dlowder-salesforce 7f6f964e18 Add missing websocket headers to React-tvOS target
Summary:
Fix Apple TV breakage.  This should allow scripts/objc-test-tvos.sh to run normally.
Closes https://github.com/facebook/react-native/pull/12565

Differential Revision: D4612182

Pulled By: hramos

fbshipit-source-id: 77fd3eeabc6757b23e4f5efbd46e9948b61b1ab6
2017-02-24 09:45:38 -08:00
Lukas Piatkowski 0707361b00 Add a RCTPackagerClientMethod handler for pokeSamplingProfiler in DevMenu
Reviewed By: javache

Differential Revision: D4579600

fbshipit-source-id: dfdf2b6ca0690988015873add58c43faa96ab0a6
2017-02-24 08:30:50 -08:00
Ben Roth 6a14f0b449 Add RCTDevSettings module
Summary:
This decouples non-UI logic from RCTDevMenu into a new module RCTDevSettings.

**Motivation**: This allows developers to change dev settings without depending on the built-in dev menu, e.g. if they want to introduce their own UI, or have other devtools logic that doesn't depend on an action sheet.

It also introduces the RCTDevSettingsDataSource protocol for storing dev tools preferences. This could allow a developer to implement alternative behaviors, e.g. loading the settings from some other config, changing settings based on the user, deciding not to persist some settings, or something else.

The included data source implementation, RCTDevSettingsUserDefaultsDataSource, uses NSUserDefaults and is backwards compatible with the older implementation, so **no workflows or dependent code will break, and old saved settings will persist.**

The RCTDevMenu interface has not changed and is therefore also backwards-compatible, though
some methods are now deprecated.

In order to ensure that RCTDevSettings
Closes https://github.com/facebook/react-native/pull/11613

Reviewed By: mmmulani

Differential Revision: D4571773

Pulled By: javache

fbshipit-source-id: 25555d0a6eaa81f694343e079ed02439e5845fbc
2017-02-24 07:00:16 -08:00
Lukas Piatkowski ccc525c5ca Refactor iOS packager webSocket handling to resemble Android's packagerconnection
Reviewed By: javache

Differential Revision: D4572607

fbshipit-source-id: b588d6216f7b84aef5a63454d2d8978783412c7b
2017-02-23 10:03:54 -08:00
Pieter De Baets dba133a291 Merge AndroidConstants and IOSConstants into PlatformConstants
Reviewed By: AaaChiuuu

Differential Revision: D4597790

fbshipit-source-id: 0a54598d6e9cadb75efff4ac17c13899d6785f9b
2017-02-22 15:01:11 -08:00
Benoit VALLON ca2741609a Fix badgeColor for previous iOS 10 versions
Summary:
The actual badgeColor prop causes the following error when run on device with a version inferior to iOS 10 like iPad 2 and iPad mini 1.

`*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITabBarItem setBadgeColor:]: unrecognized selector sent to instance 0x7968be80'`

This PR fixes it by checking at runtime if the selector is available for the current running version.

It also makes the color available at start by using the variable `self.barItem`. Currently, the color appears only after a reload.
Closes https://github.com/facebook/react-native/pull/12354

Differential Revision: D4598036

Pulled By: shergin

fbshipit-source-id: 9f104fc27db51213a54273e33c5a22f1b350c55e
2017-02-22 12:04:10 -08:00
Adam Comella 6fbc2c9972 iOS: Remove leading space from accessibilityLabel
Summary:
In some cases, the accessibilityLabel contains a leading space. This is because `RCTRecursiveAccessibilityLabel` adds a space before every iteration of the loop including the first.

After this change, the contract is that:
  - `RCTRecursiveAccessibilityLabel` always returns a string with a leading space.
  - `accessibilityLabel` never returns a string with a leading space.

**Test plan**

I created a test app with the following code:

```
<View style={{height: 100, width: 100, backgroundColor: 'steelblue'}} accessible={true}>
  <View style={{height: 20, width: 20, backgroundColor: 'red'}} accessibilityLabel='One' />
  <View style={{height: 20, width: 20, backgroundColor: 'yellow'}} accessibilityLabel='Two' />
  <View style={{height: 20, width: 20, backgroundColor: 'green'}} accessibilityLabel='Three' />
</View>
```

Before this change, the accessibilityLabel of the outermost View was " One Two Three" (notice the leading space).

After this change, it is "One Two Three" as desired.

Adam
Closes https://github.com/facebook/react-native/pull/12269

Reviewed By: javache

Differential Revision: D4596761

Pulled By: shergin

fbshipit-source-id: 7d5ff704e858d9f277d1547339a2831ffa90f592
2017-02-22 11:16:13 -08:00
Valentin Shergin e361ce8673 `RCTShadowViews`'s `cssNode` property was renamed to `yogaNode`
Reviewed By: javache

Differential Revision: D4590104

fbshipit-source-id: 7767aaa62bcbdce2746c3a26543052dd46be63e0
2017-02-21 08:45:05 -08:00
Pieter De Baets bdd27f4696 Break apart -[RCTComponentData propBlockForKey:inDictionary:]
Reviewed By: shergin

Differential Revision: D4578549

fbshipit-source-id: 726773fdf8c97cdcc3b0540b32278e36c00b19b5
2017-02-20 05:15:25 -08:00
Pieter De Baets ebe3355de7 Create NSDataBigString
Reviewed By: bnham

Differential Revision: D4559734

fbshipit-source-id: 6766093524ae79ed2a41285d33eb2207993a7d0e
2017-02-20 05:00:58 -08:00
Ashok Menon 1635c02e92 Simplifying Struct definition.
Summary:
Since we are reading from a file, we should make sure this struct is packed, just in case we change it down the line and the compiler decides it might want to introduce padding, we're now protected against that.

There was also a discussion about the fact that people might use `ptr += sizeof(BundleHeader)` as an idiom in their code, which would currently be incorrect, if padding was introduced at the end of the file. Actually, it remains incorrect to do that now, because a RAM bundle header is a different size to a BC Bundle header. If people are properly testing their code, they should spot this pretty quickly, because it will always be an incorrect thing to do with a RAM bundle, so this isn't as bad as previously thought: where the code only succeeds when the compiler deigns to not pad the struct at the end.

This diff also cleans up how headers are initialised. `BundleHeader` has a constructor that explicitly zero-initialises it so we can rely on the default initializer to do the right thing now.

Reviewed By: mhorowitz

Differential Revision: D4572032

fbshipit-source-id: 7dc50cfa9438dfdfb9f842dc39d8f15334813c63
2017-02-20 04:30:19 -08:00
Valentin Shergin c02c78a681 Splitting `RCTRootView.m`, decoupling RCTRootContentView
Reviewed By: javache

Differential Revision: D4570067

fbshipit-source-id: 91305d0c175af135ce2f22d7992bee68c13da80e
2017-02-19 23:19:47 -08:00
Valentin Shergin ba170ec78c Simplifying mess with RCTRootViewSizeFlexibility
Summary:
Now things look much more clear, I hope.
This diff:
 * Introduces new property of `RCTRootShadowView` `availableSize` which represents exactly what we transmit to layout engine;
 * Illuminates conflict between logical `availableSize` and explicitly specified size of DOM node (current `size`);
 * Splits overcomplicated `setSize:forView:` method into two unrelated ones;
 * Changes actual values of `RCTRootViewSizeFlexibility` enum constants for simpler usage;
 * Completely removes `sizeFlexibility` concept from `RCTRootShadowView` (in favor of special values of `availableSize`);
 * Makes the code clearer finally.

This is beginning of big effort to improve `RCTRootView` and co.

Reviewed By: mmmulani

Differential Revision: D4562834

fbshipit-source-id: f5baaf2859ea430d44645a6b5d35f222f15a668e
2017-02-19 23:19:47 -08:00
Mathieu Baudet 4a893ee071 remove unused includes in fbobjc/Libraries
Reviewed By: swolchok

Differential Revision: D4507573

fbshipit-source-id: 7fc6df52bc37c39698c7897be567758469417218
2017-02-19 18:33:49 -08:00
Mehdi Mulani 93a263d874 Make RCTRefreshControl not dependent on order of setting properties
Summary: With the Cxx bridge, properties are not guaranteed to be set it any order (and furthermore, they should not be). RCTRefreshControl previously had its title set first, and would crash otherwise. This fixes that.

Reviewed By: mhorowitz

Differential Revision: D4580253

fbshipit-source-id: 39baecceb8b67c6a851c08ba9cabbf4dc99359cb
2017-02-17 15:16:01 -08:00
Ashok Menon 3148cc09ae Fix CI runs
Summary: I broke Circle CI builds by moving a file, so I am updating the OSS build setup with details of the move. Whilst I was testing the change, I noticed that the UI Explorer build was also already broken, so this diff also changes some of its configuration to make it build again.

Reviewed By: javache

Differential Revision: D4579137

fbshipit-source-id: 4cbb1ef148075280b991cbc5bb47bf96ec3d543a
2017-02-17 09:17:19 -08:00
Pieter De Baets 591de3e278 Move tryBytecode to bundle specifier
Reviewed By: amnn

Differential Revision: D4559898

fbshipit-source-id: 917bef5a1d753b52e9e967f3029eb158935feee6
2017-02-17 06:00:55 -08:00
Alexey Lang ba029becbe Support QuickPerformanceLogger.js in CxxBridge
Reviewed By: javache

Differential Revision: D4573567

fbshipit-source-id: 3ef9da38fb178cf4c1400b4a991a9e85f3ec3755
2017-02-17 06:00:54 -08:00
Pieter De Baets 0c8e925a18 Move initializedExecutorWithContextProvider API
Reviewed By: dcaspi

Differential Revision: D4558591

fbshipit-source-id: 821d6a6d4e42d1c67559fde102a0558eb623733b
2017-02-17 02:30:45 -08:00
Pieter De Baets c529a06cb8 Remove unused RCTMessageQueue
Reviewed By: mhorowitz

Differential Revision: D4564975

fbshipit-source-id: 62cb686fe5fefb4ec4a8f5db44898a95496420be
2017-02-16 15:18:43 -08:00
Pieter De Baets 11e59e3ff4 Move some utilities to RCTCxxUtils
Reviewed By: mhorowitz

Differential Revision: D4551173

fbshipit-source-id: db01d3205ec1feb54c815c0f0fc688fc7a4823d0
2017-02-16 14:02:03 -08:00
Alexey Lang 7c97008fa8 Support QuickPerformanceLogger.js in the old bridge
Reviewed By: javache

Differential Revision: D4566647

fbshipit-source-id: 1a6448b89b14f4ce9f2192e9f7b4e28b8dcb52b7
2017-02-16 11:33:48 -08:00
Emil Sjolander 1b5eb36e2f Fix up some small issues with YGUnitAuto
Reviewed By: wwjholmes

Differential Revision: D4567045

fbshipit-source-id: ace5fd89bd534a6bb5ec7dba0c3afbf13d62d7c9
2017-02-16 06:59:33 -08:00
Pieter De Baets 53b387638e Move JSBigString to its own header
Reviewed By: mhorowitz

Differential Revision: D4551162

fbshipit-source-id: 2374e05e60942211e50af86ed42eb194e5e82bbe
2017-02-16 06:59:30 -08:00
Pieter De Baets 5d4ff693b4 Move RCTFollyConvert to the correct namespace
Reviewed By: mhorowitz

Differential Revision: D4551124

fbshipit-source-id: 40a0a8ca818710a7529798b8244d9c133eb5c22d
2017-02-16 06:59:27 -08:00
Lukas Piatkowski a2addbd932 BREAKING: Change the js1 - packager - RN App protocol to version 2
Reviewed By: cwdick

Differential Revision: D4551991

fbshipit-source-id: 395c38ee5c71ddc24d8743e7ec90cc89de087503
2017-02-16 04:30:00 -08:00
Pieter De Baets 8987d86718 Fix error handling for nested exceptions
Reviewed By: mhorowitz

Differential Revision: D4551110

fbshipit-source-id: e593c1ef0dea27e95a387bcde6250aeb22d2e9cc
2017-02-15 06:15:11 -08:00
Pieter De Baets bbe0c45c19 Prevent deadlock after bridge reload
Reviewed By: dcaspi

Differential Revision: D4551097

fbshipit-source-id: 33b43b2691d4e595d3c09c9a5b101ce458c4d6d7
2017-02-15 06:15:11 -08:00
Pieter De Baets a2000d1200 Replace valueForKey with subscript access in RCTJavascriptLoader
Reviewed By: shergin

Differential Revision: D4559391

fbshipit-source-id: 44cb4900f93f2ac60dae3a461ed5344e1af08f3b
2017-02-15 03:45:55 -08:00
Kevin Gozali a512f6dcf6 ios: exposed 'RCTConvert UITabBarSystemItem:' in the header file
Summary: This method was defined in the .m file already, so we can just expose it to the header for other usages.

Reviewed By: mmmulani, shergin

Differential Revision: D4557942

fbshipit-source-id: a1be8af8e31b88a152cabfab6d4cf82316088572
2017-02-15 02:17:17 -08:00
Valentin Shergin 5263699f90 Introducing RCTRootShadowView.baseDirection property
Reviewed By: dshahidehpour

Differential Revision: D4555904

fbshipit-source-id: 8f0a2a9a38af42334188bc1cc5e0f6dded8592ae
2017-02-14 15:33:15 -08:00
David Hart 67f6b32409 Rename YGUnitPixel to YGPoint...
Summary:
...to reflect the modern world we live in with dynamic DPI platforms :)
Closes https://github.com/facebook/yoga/pull/375

Reviewed By: dshahidehpour

Differential Revision: D4528518

Pulled By: emilsjolander

fbshipit-source-id: e422bd4ae148e02c598a7b484a6adfa8c0e1e0c9
2017-02-14 14:31:31 -08:00
Lukas Wöhrl dbaa687518 Feature auto margin
Summary:
Even so I know there are some opinions against ```margin: 0 auto``` it's still part of the spec: https://www.w3.org/TR/css-flexbox-1/#auto-margins and pretty usefull if you have to position via ```justify-content```.

This PR adds an implementation for that.

It adds an additonal ```YGUnitAuto``` and margins got ```YGNodeStyleSetMarginAuto``` functions as well.
Closes https://github.com/facebook/yoga/pull/357

Reviewed By: astreet

Differential Revision: D4501142

Pulled By: emilsjolander

fbshipit-source-id: 86519f8632496f46e78a7c9dbc5b21e212e3e0c7
2017-02-14 14:31:31 -08:00
Pieter De Baets 4695508826 Remove iOS7 API check
Reviewed By: shergin

Differential Revision: D4551186

fbshipit-source-id: ab5ec3c01bbfe0faca833960431a9739cbc1ea44
2017-02-13 12:17:01 -08:00
Valentin Shergin 7686274e13 Removed RTL workaround in RCTShadowText
Reviewed By: fkgozali

Differential Revision: D4511274

fbshipit-source-id: f658afb4e1c943cc9ecab2dd2a91f251edd3fa36
2017-02-13 12:00:57 -08:00
Ciprian Pãtru dcf7f631f4 Enable perf monitor for CxxBridge
Reviewed By: javache

Differential Revision: D4510939

fbshipit-source-id: f90dc5c97b98ce68cb2c21e5f283790880b032a4
2017-02-09 12:47:04 -08:00
Valentin Shergin d8748233ca Removing `transformMatrix` and `decomposedMatrix` properties
Summary: We deprecated `transformMatrix` and `decomposedMatrix` in D3239960 10 months ago. This revision finally removes remains of this functionality from native code.

Reviewed By: mmmulani

Differential Revision: D4515760

fbshipit-source-id: b4d5b7e834ac4a775f4992b28270b4ff961889a6
2017-02-07 14:02:20 -08:00
Valentin Shergin ec673d0771 Added support of `direction` style property
Summary: Now layout direction (LTR or LTR) can be specified not only for whole app but also for view subtree via `direction` style property.

Reviewed By: mmmulani

Differential Revision: D4510206

fbshipit-source-id: 4e56c5886b6e42f2343165eb76be897e681c5ba4
2017-02-06 21:00:16 -08:00
Valentin Shergin 233015c93e `[-RCTUIManager setFrame:forView:]` was replaced with `[-RCTUIManager setSize:forView:]`
Reviewed By: fkgozali

Differential Revision: D4511712

fbshipit-source-id: 5c51d573bf638cb9b55d5f03b9f1882dc6129510
2017-02-06 11:01:11 -08:00
Valentin Shergin e38679fbc7 Added missing files to React.xcodeproj
Reviewed By: mmmulani

Differential Revision: D4513525

fbshipit-source-id: 40700db4cc8fd8eae1f7b98855a461489adaf86a
2017-02-05 11:43:32 -08:00
Valentin Shergin 54d3e83bbf Fixed crash in RCTScrollView on iOS 8
Reviewed By: javache

Differential Revision: D4508906

fbshipit-source-id: 08955f338879f708d35f4784e858a92b542e8661
2017-02-03 15:28:34 -08:00
Valentin Shergin 91910d87de Better RTL support especially for ScrollView's
Reviewed By: fkgozali

Differential Revision: D4478913

fbshipit-source-id: 525c17fa109ad3c35161b10940776f1426ba2535
2017-02-02 09:58:30 -08:00
Pieter De Baets 4d2512aef9 Replace MethodCallResult with folly::Optional
Reviewed By: AaaChiuuu

Differential Revision: D4481987

fbshipit-source-id: 945dd671eb2482f3c6b626192aa2181c5bfd906f
2017-02-02 05:13:33 -08:00
Marc Horowitz 81b2d69575 Fork UIExplorer.xcodeproj into UIExplorerCxx.xcodeproj
Reviewed By: javache

Differential Revision: D4434102

fbshipit-source-id: 45e128e7d985b58c04dda14f8e692051a552a491
2017-02-01 14:14:33 -08:00
Marc Horowitz aeab15d0aa Fork React.xcodeproj to build the C++ bridge
Reviewed By: javache

Differential Revision: D4434074

fbshipit-source-id: b096b887cdcd5ef900e540bcd6697b5980200add
2017-02-01 14:14:32 -08:00
Marc Horowitz b774820dc2 move C++ bridge into oss directory
Reviewed By: javache

Differential Revision: D4434052

fbshipit-source-id: ff2743eb7fe5d9cabb860752ca3d92d631a2f02b
2017-02-01 14:14:32 -08:00
Valentin Shergin f33f84e75f Deprecating/removing `setFrame`, `setLeftTop`, and co.
Summary:
Motivation:
 * `RCTShadowView`'s `frame` property actually represents computed layout of the view. We must not use it as a setter for yoga node styles;
 * Using `frame` and `setLeftTop` in existing way actually works only for view with absolute positioning, so it is super rare and special case;
 * Internally, setting `frame` only make sense to `RootView`, and in that case there we always must not change `origin` we are introducing `setSize` method.

Changes:
 * `[-RCTShadowView setFrame:]` was removed, `frame` property is readonly now;
 * `[-RCTShadowView setLeftTop:]` was removed; no replacement provided;
 * `[-RCTShadowView size]` read-write property was added;
 * `[-RCTUIManager setFrame:forView:]` was deprecated, use (just introduced) `setSize:forView:` instead;
 * `[-RCTUIManager setSize:forView:]` was added.

If you are still need some of removed methods, you are probably doing something wrong. Consider using `setIntrinsicContentSize`-family methods,
`setSize`-family methods, or (in the worst case) accessing `yogaNode` directly.

Reviewed By: javache

Differential Revision: D4491384

fbshipit-source-id: 56dd84567324c5a86e4c870a41c38322dc1224d2
2017-02-01 13:13:27 -08:00
Valentin Shergin d1990f8fc4 Better (right) implementation of `intrinsicContentSize`
Reviewed By: emilsjolander

Differential Revision: D4486767

fbshipit-source-id: d37ea11f9f48425d4d99c29e8bfb6c8ed2353f04
2017-01-31 16:58:32 -08:00
Max Graey c68195929b Fix skew transform on native side (iOS & Android)
Summary:
According to #11992 fix skew transform in native code as well

janicduplessis vjeux
Closes https://github.com/facebook/react-native/pull/12106

Differential Revision: D4479880

fbshipit-source-id: d84780842b555f6352d84d229b5b6c5c3c6a0647
2017-01-28 12:43:30 -08:00
Rob Hogan 2a5cb9a773 Typo: bagde -> badge
Summary:
Simple typo fix for an Obj-C local variable.
Closes https://github.com/facebook/react-native/pull/12099

Differential Revision: D4477106

fbshipit-source-id: 7626a22981e24946398d5f6299fd7dab664a1419
2017-01-27 14:58:27 -08:00
rh389 9d6d8a24eb RCTConvert: Deprecated NSStringArray typedef
Summary:
Eliminates a build warning related to the use of the deprecated `NSStringArray` typedef.

This fix was more complex than I'd anticipated because `NSStringArray` was also being used as part of a macro-generated selector name, and in two different ways for debug/release. I've added a macro which allows the selector name to be specified explicitly, thus generally allowing for converters which return arrays of templated types.

There's an argument for ditching `RCT_JSON_ARRAY_CONVERTER` in favour of `RCT_JSON_ARRAY_CONVERTER_NAMED` as they're both private, but `RCT_ARRAY_CONVERTER` is in the public API so we'd at least need to retain that. There are also arguments for ditching the use of the macro for the nested array case(s) - since afaik this is the only one at the moment. Feedback appreciated :)

Tested with the `UIExplorer` unit tests and by diffing the preprocessor output of `RCTConvert.m` in both release and debug configs, verifying that they're identical apart from that `NSStringArray` is replaced by
Closes https://github.com/facebook/react-native/pull/11799

Differential Revision: D4441197

fbshipit-source-id: 7535ebe6f8ad4566df742e805b0a64530d1b269f
2017-01-27 13:43:27 -08:00
Martin Konicek 9dee696ed8 Add scrollToEnd to ScrollView and ListView
Summary:
**Motivation**

A basic task of making a React Native ScrollView or ListView scroll to the bottom is currently very hard to accomplish:
- https://github.com/facebook/react-native/issues/8003
- https://github.com/facebook/react-native/issues/913
- http://stackoverflow.com/questions/29829375/how-to-scroll-to-bottom-in-react-native-listview

**NOTE:** If you're building something like a chat app where you want a ListView to keep scrolling to the bottom at all times, it's easiest to use the [react-native-invertible-scrollview](https://github.com/exponent/react-native-invertible-scroll-view) component rather calling `scrollToEnd` manually when layout changes. The invertible-scrollview uses a clever trick to invert the direction of the ScrollView.

This pull request adds a `scrollToEnd` method which scrolls to the bottom if the ScrollView is vertical, to the right if the ScrollView is horizontal.

The implementation is based on this SO answer:
http://stackoverflow.com/questions/952412/uiscrollview-scrol
Closes https://github.com/facebook/react-native/pull/12088

Differential Revision: D4474974

Pulled By: mkonicek

fbshipit-source-id: 6ecf8b3435f47dd3a31e2fd5be6859062711c233
2017-01-27 10:13:29 -08:00
Ryan Gomba 7e869b9d0a Drive any numerical prop via NativeAnimated
Summary:
In theory, we should be able to animate any non-layout property, including custom ones. While there is still work to be done on the native side to fully enable this, we should start by dropping the prop whitelist.
Closes https://github.com/facebook/react-native/pull/10658

Differential Revision: D4379031

Pulled By: ericvicenti

fbshipit-source-id: fe9c30ea101e93a8b260d7d09a909fafbb82fee6
2017-01-26 18:28:53 -08:00
Eric Vicenti 65513e501a Bug fix for nil TVView on pop
Summary:
Explain the **motivation** for making this change. What existing problem does the pull request solve?

This change is required when you try to set a focus on a view that doesn't exist and thus cannot be focused. In my specific use case, this occurred when trying to set a focus on a list item in a setInterval when the View (with the specific list item) had been popped. The while loop ran infinitely (eventually freezing the app) since the rootView doesn't exist. This adds that check and breaks out if so.

All obj-c tests ran successfully.

dlowder-salesforce
Closes https://github.com/facebook/react-native/pull/12073

Differential Revision: D4468989

Pulled By: ericvicenti

fbshipit-source-id: 7926c887035722c983c41cb6b6d9df567010c2ee
2017-01-26 09:43:32 -08:00
Pieter De Baets 0fc62eebc3 Revert D4450924: Expose StatusBar height on iOS
Differential Revision: D4450924

fbshipit-source-id: a883a7417e85f0a923d5fcc4d5efff75b99c2272
2017-01-25 17:59:30 -08:00
Pieter De Baets a407ff94ee Add option to start sampling profiler on app launch
Reviewed By: mhorowitz

Differential Revision: D4415989

fbshipit-source-id: 30704c2b618656cb7cc0ccdf87dec315b30b62f3
2017-01-25 14:43:30 -08:00
Valentin Shergin 64041669ee The warning 'cannot calculate shadow efficiently' is not a warning anymore
Reviewed By: fkgozali, yungsters

Differential Revision: D4445304

fbshipit-source-id: 3a37150ae2beaf44b505dc36b575b7d44619e071
2017-01-25 12:28:50 -08:00
Mathieu Acthernoene eebfd33b70 Expose StatusBar height on iOS
Summary:
Following the PR https://github.com/facebook/react-native/pull/6195, this adds a `HEIGHT` constant on `StatusBar` for iOS.

Combined with `statusBarFrameDidChange` and `statusBarFrameWillChange` StatusBar native events, it solves various problems with In-Call cellar bar / Location bar / others 40pt status bars, and offers a correct `keyboardVerticalOffset` value for the KeyboardAvoidingView component.
Closes https://github.com/facebook/react-native/pull/12041

Differential Revision: D4450924

Pulled By: hramos

fbshipit-source-id: 664798260f4226140f3fa3f9222a415a305d0d78
2017-01-23 12:58:34 -08:00
Pieter De Baets 7412340175 Fix passThroughTouches
Reviewed By: mmmulani

Differential Revision: D4438390

fbshipit-source-id: 4e1ec4eaf80ffb48ac7b65ed092402c51d9227d3
2017-01-23 11:28:51 -08:00
Pieter De Baets 9681583cf3 Disable RCTPerfMonitor on new bridge
Reviewed By: mhorowitz

Differential Revision: D4446988

fbshipit-source-id: f36360b1ea049e64e2a6a9bffce0af8d0ab6839a
2017-01-23 10:13:31 -08:00
yueshuaijie 94f71a3884 Add one more parameter(keyboardType) to AlertIOS.promot().
Summary:
Add one more parameter which can specify the keyboard type of first text input(if exists) to AlertIOS.prompt().

Example usage:
`AlertIOS.prompt('Type a phone number', null, null, 'plain-text', undefined, 'phone-pad')`
Closes https://github.com/facebook/react-native/pull/8781

Differential Revision: D4437900

Pulled By: hramos

fbshipit-source-id: 8141cc0d7c70d13603cd5a1d5ea3f1ab1ce437a6
2017-01-19 14:43:37 -08:00
Mehdi Mulani 81c33b542d Switch out DISABLE_YELLOW_BOX for IS_TESTING
Summary: Switch to using IS_TESTING on the Platform module. While IS_TESTING has to be explicitly set in the test harness, this makes it more usable and stops people from relying on brittle variables in the (larger) environment.

Reviewed By: fkgozali

Differential Revision: D4423661

fbshipit-source-id: 27a80867778b9374bcba67b69f9c93d32c0a74b0
2017-01-18 12:28:42 -08:00
Peter Salanki 52d8851fc8 Cache policy control for image source
Summary:
In the context of an app an image exists in three resolutions on the server: `thumb` (30px) `feed` (300px) `full` (900px). When looking at an individual item a user can come either from the feed, via a permalink or from other parts of the app. This allows a situation where the `feed` image might or might not already be loaded somewhere in the app. In the detail view I want to render `thumb` with a blur (to quickly display something), then the `feed` image if it exists to have something decent to display until `full` loads. However it is quite a waste to load the `feed` image if it isn't already in cache, and will slow down the time until `full` is loaded. It is possible to track the navigation from feed->detail and that the `feed` image has actually completed loading by the feed component however as component hierarchies grow this turns into quite a lot of prop passing and bad separation of concerns.

NSURLRequests accepts a [Cache Policy](https://developer.apple.com/reference/fo
Closes https://github.com/facebook/react-native/pull/10844

Differential Revision: D4425959

Pulled By: lacker

fbshipit-source-id: 679835439c761a2fc894f56eb6d744c036cf0b49
2017-01-17 17:13:31 -08:00
Neil Sarkar 302d42da7f Remove deprecated method 'RCTExecuteOnMainThread'
Summary:
**Motivation**

This finishes the job of #11817, removing the previously deprecated method. See https://github.com/facebook/react-native/issues/11736 for more context.

**Test plan**

There were no tests for this method, and I searched the whole project to make sure we weren't relying on it anywhere.
Closes https://github.com/facebook/react-native/pull/11854

Differential Revision: D4421671

Pulled By: javache

fbshipit-source-id: 67e0db8d3c594ad3ccd6ccdae08f8ce49ddb8a34
2017-01-16 15:13:36 -08:00
Valentin Shergin 930010ec91 RCTTouchHandler doesn't delay any touches anymore
Reviewed By: mmmulani

Differential Revision: D4418211

fbshipit-source-id: 07fdd81d975c6b65477e599e2dcb604b64556e9e
2017-01-13 17:43:35 -08:00
Rob Hogan 9e1e52f312 Mark __unused completion block args
Summary:
Catching a couple more build warnings introduced by b50f55026a since https://github.com/facebook/react-native/pull/11797.

Edit: and one more introduced by c68a708621

Tested the build with UIExplorer.
Closes https://github.com/facebook/react-native/pull/11865

Differential Revision: D4415630

fbshipit-source-id: 1384d56770eea8665ede8bd9abe06cf34cd14b33
2017-01-13 12:43:31 -08:00
Mehdi Mulani 91b7499cf6 Expose environment and arguments to JS
Summary:
Right now from JS there's no way to see the environment variables or arguments that the application was started with.
The main use case for this is to help enable/disable features when being run in a testing environment (as environment variables are the easiest way to communicate).

javache is it okay to reference these constants from JS at startup time? I am planning to disable yellow boxes via an environment variable.

achen1 how easy is it expose these two things for Android as well?

Reviewed By: achen1

Differential Revision: D4395091

fbshipit-source-id: fc318e6a60b8829f7eb4491ea8f3258f68f59c8c
2017-01-13 12:28:31 -08:00
Pieter De Baets 8e4f33e669 Dismiss redbox upon pressing reload
Reviewed By: shergin

Differential Revision: D4405376

fbshipit-source-id: 63d624457c6afde3dbe71a66c57b410cf71cbbd3
2017-01-13 03:58:47 -08:00
Pieter De Baets a94418fdd3 Show redbox when no bundle is present
Reviewed By: shergin

Differential Revision: D4405409

fbshipit-source-id: 847fc559121dcde844f1ee3c6d02206e9e27803b
2017-01-13 03:43:35 -08:00
Valentin Shergin c68a708621 New way to handle simultaneously active gesture recognizers in RCTTouchHandler
Reviewed By: majak

Differential Revision: D4385209

fbshipit-source-id: 22746dd93e378a4d9e5feca66bc84c357afb6f36
2017-01-12 12:13:28 -08:00
rh389 4844225eed JavaScriptLoader BCBundle version check
Summary:
Currently a build warning is thrown by `if (header.BCVersion != runtimeBCVersion) ...` because `runtimeBCVersion` is signed, apparently because `-1` is used to mean that the runtime has no support for bytecode bundles.

This PR splits out the error case of the runtime not supporting BC bundles from the case of a version mismatch.

Tested as much as I could by building and running `UIExplorer` - I haven't attempted to use real bytecode bundles.
Closes https://github.com/facebook/react-native/pull/11806

Differential Revision: D4408608

fbshipit-source-id: a1d868bb2064588e6a20827692629a46b6ba1e74
2017-01-11 22:28:43 -08:00
Valentin Shergin f839b58c20 `UIManager.measure()` now respects any `zoom` affected view hierarchy
Reviewed By: mmmulani

Differential Revision: D4396422

fbshipit-source-id: 100c7050bdf9e66b8af27df335343f028a2d4148
2017-01-11 13:43:40 -08:00
Dan Caspi ad0493c6c2 Fixing a crash caused by D4393955
Reviewed By: javache

Differential Revision: D4403858

fbshipit-source-id: c930aa108d27c1bd1b36364530d2953bcd4664ad
2017-01-11 09:43:34 -08:00
Emil Sjolander 3f49e743be Add percentage support to react native
Summary:
Adds support for percentage value in react native.

syntax: property: 100 | property | '100%'

supported properties:
padding
margin
width
height
minWidth
minHeight
maxWidth
maxHeight
flexBasis

```
class Playground extends React.Component {
  render() {
    return (
      <View style={{backgroundColor: 'white', padding: 10, paddingTop: 30, height: '100%'}}>
        <Text>
          If you want to quickly test out something,
          open the Playground.js file and start coding.
        </Text>
        <View style={{backgroundColor: 'red', height: 50, width: 50}}/>
        <View style={{backgroundColor: 'blue', height: '50%', width: '50%'}}/>
      </View>
    );
  }
}
```

Reviewed By: astreet

Differential Revision: D4376549

fbshipit-source-id: c41d68a7555396f95d063a7527ee081773ac56dc
2017-01-11 03:58:37 -08:00
Neil Sarkar 00d5674474 Remove deprecation warning for RCTExecuteOnMainThread
Summary:
As per janicduplessis recommendation, provide a new synchronous method to replace the necessary synchronous calls and use a warning in the comments (and method name).

**Motivation**

There are currently a number of XCode warnings that show up in a fresh 0.40 install of a react native project. While the project can still be run, this contributes negatively to the development experience -- valid warnings may be ignored and new ones may be added as per https://en.wikipedia.org/wiki/Broken_windows_theory

This addresses one of the warnings, by providing the functionality of a deprecated method in two specific cases where we can't avoid doing synchronous work on the main queue. See https://github.com/facebook/react-native/issues/11736 for more context.

**Test plan (required)**

I ran a project that relied on screen size and it didn't crash...happy to do more involved testing if someone can share better methodology.
Closes https://github.com/facebook/react-native/pull/11817

Differential Revision: D4402911

fbshipit-source-id: 9fd8b3f50d34984b765fe22b1f4512e103ba55a9
2017-01-10 23:13:33 -08:00
rh389 40f2b1bbb7 Prevent compiler inferring incorrect type
Summary:
Fixes the build warning:

```react-native/React/Modules/RCTRedBox.m:406:58: Conversion from value of type 'NSArray<RCTJSStackFrame *> *' to incompatible type 'NSArray<NSDictionary *> *```

This appears because the compiler is left to infer the type of `stack`, and it does so as `NSArray<RCTJSStackFrame *>` based on [RCTRedBox.m#L390](https://github.com/facebook/react-native/blob/master/React/Modules/RCTRedBox.m#L390). In reality `stack` may be either of two types and the function body deals with normalisation.

Mark the stack as explicitly `NSArray<id>` to prevent inference so we're free to make the decision to cast to more specific types.
Closes https://github.com/facebook/react-native/pull/11807

Differential Revision: D4402916

fbshipit-source-id: 356343f244af7638b9b9e91c2c5b7e68de0cbd33
2017-01-10 22:58:33 -08:00
Dan Caspi b50f55026a Adding support in the new RN bridge on iOS
Differential Revision: D4393955

fbshipit-source-id: e5f3fb6773908678773a5dd4fdea568bcc200336
2017-01-10 11:28:44 -08:00
rh389 453e70d19c Replace deprecated completion block
Summary:
`UIActivityViewConroller.completionHandler` has been [deprecated](https://developer.apple.com/reference/uikit/uiactivityviewcontroller/1622010-completionhandler) since iOS 8, when it was replaced by `completionWithItemsHandler`.

Tested the build using `UIExplorer` and XCode 8.2 but I've never seen and can't work out how to activate the `UIActivityViewController` this method relates to, so I haven't tested a real run.
Closes https://github.com/facebook/react-native/pull/11798

Differential Revision: D4396618

fbshipit-source-id: 92a993c434637ede2d5779f4154feb00d2c78d06
2017-01-09 19:28:28 -08:00
rh389 2d8a287f9c Mark params __unused or #pragma unused
Summary:
Motivation: reduce build noise that might worry new users or hide real problems.

This deals with four of the warnings currently in the iOS build. The `__unused` additions are standard and self-explanatory, following the style used elsewhere in RN. I've used `#pragma unused` to deal with parameters named by macros.

Tested by building and running the `UIExplorer` example app in XCode 8.2
Closes https://github.com/facebook/react-native/pull/11797

Differential Revision: D4396611

fbshipit-source-id: 728e9ebb94d147f7a2cbc674a25fe67e66e2e8b2
2017-01-09 19:28:27 -08:00
Valentin Shergin 47f18bdb17 Nobody outside RCTTouchHandler should treat it as UIGestureRecognizer subclass
Reviewed By: mmmulani

Differential Revision: D4387821

fbshipit-source-id: 8060772a5de669eeaca159ceac13b995d7518a1b
2017-01-09 00:13:33 -08:00
Emil Sjolander 976abf87f2 Add baseline alignment support
Summary:
Add baseline alignment support to react native.

{F65372439}

```
class Playground extends React.Component {
  render() {
    return (
      <View style={{padding: 30, flexDirection: 'row', alignItems: 'baseline'}}>
        <View style={{width: 30, height: 10, backgroundColor: 'red'}}/>
        <View style={{width: 30, height: 20, backgroundColor: 'green'}}/>
        <View style={{width: 30, height: 30, backgroundColor: 'blue'}}/>
      </View>
    );
  }
}
```

Reviewed By: javache

Differential Revision: D4385099

fbshipit-source-id: d7caa6e4c086c4a62e24ef1d5db9c805c470ef2a
2017-01-08 04:43:31 -08:00
Luke Miles da9a712a9e Add a injectJavaScript method to the WebView component
Summary:
Currently, < WebView > allows you to pass JS to execute within the view. This works great, but there currently is not a way to execute JS after the page is loaded. We needed this for our app.

We noticed that the WebView had messaging support added (see #9762) . Initially, this seemed like more than enough functionality for our use case - just write a function that's injected on initial load that accepts a message with JS, and `eval()` it. However, this broke once we realized that Content Security Policy can block the use of eval on pages. The native methods iOS provide to inject JS allow you to inject JS without CSP interfering. So, we just wrapped the native methods on iOS (and later Android) and it worked for our use case. The method injectJavaScript was born.

Now, after I wrote this code, I realized that #8798 exists and hadn't been merged because of a lack of tests. I commend what was done in #8798 as it sorely solves a problem (injecting JS after the initial load) and has more features than what I'
Closes https://github.com/facebook/react-native/pull/11358

Differential Revision: D4390425

fbshipit-source-id: 02813127f8cf60fd84229cb26eeea7f8922d03b3
2017-01-06 20:29:02 -08:00
Emil Sjolander 5d6ce0e4ae Rely on yoga to enforces precedence rules
Reviewed By: javache

Differential Revision: D4376526

fbshipit-source-id: b37e541f74674ce0c918cc4993943a972bc4dc87
2017-01-06 06:43:45 -08:00
Emil Sjolander 828addcf55 Use layout padding instead of style padding
Reviewed By: javache

Differential Revision: D4377071

fbshipit-source-id: c4a534a07f335c39ec50214e33a41aeff0389bf1
2017-01-06 06:43:45 -08:00
Valentin Shergin 482c73de86 More accurate touch bookkeeping in RCTTouchHandler
Reviewed By: javache

Differential Revision: D4381374

fbshipit-source-id: d959381617eda93658d519e7a3c565093eb9fae8
2017-01-04 14:43:40 -08:00
Dave Lee 7123618aa8 Fix comparison between NSNumber* and int
Summary:
Strangely comparing a pointer with zero will only be a clang warning when compiling with `-Wpedantic`, so this incorrect comparison is silently allowed.

**Test plan**

Compiles with `-Wpedantic`.
Closes https://github.com/facebook/react-native/pull/11709

Differential Revision: D4377512

Pulled By: ericvicenti

fbshipit-source-id: 483cf1f41d3f539c452d542ad2155c4c4b41616d
2017-01-03 10:28:29 -08:00
Lukas Woehrl 16359ec8ee Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.

You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.

I did some benchmarks:

```
Without Percentage Feature - Release x86:

Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms

Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms

With Percentage Feature - Release x86:

Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258

Reviewed By: dshahidehpour

Differential Revision: D4361945

Pulled By: emilsjolander

fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:28:30 -08:00
David Hart c1aff605ed Transform the Count enum values into private constants
Summary:
Hides implementation details for the C, Objective-C and Swift APIs.
Closes https://github.com/facebook/yoga/pull/292

Differential Revision: D4351523

Pulled By: emilsjolander

fbshipit-source-id: 18a1149d169f0d52bd078714295000b5d07434dd
2016-12-22 02:58:59 -08:00
dlowder-salesforce fd5af61e5c Apple TV support 5: adjustments after manual import of #10427
Summary:
**Motivation**

After reviewing changes between my PR https://github.com/facebook/react-native/pull/10427 and what was eventually manually imported to master, found two minor adjustments needed.

**Test plan**

Existing tests should still pass.
Closes https://github.com/facebook/react-native/pull/11548

Differential Revision: D4357216

Pulled By: javache

fbshipit-source-id: 571794cda104210bf5236462c0700e07a2a51d29
2016-12-21 03:28:28 -08:00
Mani Ghasemlou a19c6991c0 Fix for dimensions not updating correctly on iPad due to screen rotation
Summary:
On certain devices (in my case, any iPad Pro model), listening to `DeviceEventEmitter.didUpdateDimensions` would call back *before* the interface change takes places (i.e. calling `Dimensions.get()` in this callback would return wrong values). Turns out that we were listening for the wrong native event.

Edit to add: now using `[RCTSharedApplication() statusBarOrientation]` to get the current orientation. Not yet sure why, but the `userInfo` provided by the notification was returning the wrong orientation *only* on the first time you rotate the device.

This fixes the open issue: https://github.com/facebook/react-native/issues/7340
Closes https://github.com/facebook/react-native/pull/11350

Differential Revision: D4348186

Pulled By: javache

fbshipit-source-id: cb2cfb9cccfc459ad4b46a5af2bec4c973132ae8
2016-12-19 14:58:54 -08:00
Pieter De Baets c92ad5f6ae Apple TV support 4: support for input (tvOS focus engine)
Reviewed By: shergin

Differential Revision: D4333546

fbshipit-source-id: 8655070e81dbb62a80ab1f00a43ef6c2d9654618
2016-12-19 06:28:40 -08:00
Pieter De Baets 88da9e658c Remove duplicate Yoga copy
Reviewed By: foghina

Differential Revision: D4346088

fbshipit-source-id: 3decfe16fe13d70a1862fc8bb8dfca30689023f8
2016-12-19 03:43:29 -08:00
Emil Sjolander 45fdcdc93a YGNodeChildCount -> YGNodeGetChildCount for consistency
Reviewed By: gkassabli

Differential Revision: D4333480

fbshipit-source-id: 17058f18fa9e26b3e02f7a1651f7295cae59acad
2016-12-16 04:44:18 -08:00
Janic Duplessis 46f3ff68b6 Move headers to project section to fix archive
Summary:
Follow up to fix some issues with 59407f3660. Headers needed to be in the `project` section instead of `private` in xcode so they don't get included in the archive.

cc javache
Closes https://github.com/facebook/react-native/pull/11395

Differential Revision: D4313048

Pulled By: javache

fbshipit-source-id: 805dbbe9f149acfe780be76e99c949c450272358
2016-12-12 08:58:29 -08:00
Alexey Lang 66c5305fa8 Fix JSGlobalContext leak
Reviewed By: javache

Differential Revision: D4299616

fbshipit-source-id: f30e88fbdd08422f1d0ae3c10b8a9af13d637135
2016-12-12 05:43:34 -08:00
Stepan Hruda 1642b38abe Make React Profiler asm position independent
Reviewed By: compnerd

Differential Revision: D4297098

fbshipit-source-id: 567f640f2d1ed4187e53356e7ca2d066f1412f9d
2016-12-08 14:58:26 -08:00
Theo Yaung 4a6f2ec44a Fail-Fast on Redundant Callback Invokes
Reviewed By: javache

Differential Revision: D4295268

fbshipit-source-id: 1258ffbc02bcf7d7199348c7df8fcd744bb9963f
2016-12-08 13:43:38 -08:00
Adam Ernst cfb8b19126 Expose more of RCTWebSocketObserver
Reviewed By: javache

Differential Revision: D4297162

fbshipit-source-id: 97032ccf3dc6bd259ca0fa2883eff45c0c49347f
2016-12-08 07:44:38 -08:00
Adam Ernst 587606987f Rename and merge files for RCTWebSocketObserver protocol
Summary: No need to have two files; merge it into one and give it an appropriate name.

Reviewed By: javache

Differential Revision: D4296716

fbshipit-source-id: 904d13c23bb8d403b8efcb60f9a4aa5df5b08972
2016-12-08 07:44:37 -08:00
Adam Ernst 2b0c4591e2 Rename RCTWebSocketManager file to reflect its new contents
Reviewed By: javache

Differential Revision: D4296615

fbshipit-source-id: a48da3f0550398cb59478c7405fe971f9246910f
2016-12-08 07:44:37 -08:00
Adam Ernst d0c3e98d1d Eliminate RCTWebSocketManager
Summary: This singleton was unnecessary and can be implemented with a single `static` in `RCTDevMenu`. In another diff, I will rename `RCTWebSocketManager.{h,m}` to reflect the only class that remains.

Reviewed By: javache

Differential Revision: D4296551

fbshipit-source-id: 653971dfb31de5b0a161b531eed82a067f536ce3
2016-12-08 07:44:37 -08:00
Adam Ernst 2ca6138852 Start exposing RCTWebSocketObserver using a protocol
Reviewed By: javache

Differential Revision: D4296387

fbshipit-source-id: 33f92c36168dcb18356d0ccdaf902a84634d94b7
2016-12-08 07:44:37 -08:00
Adam Ernst ac489858f8 Clean up RCTWebSocketProxyDelegate a bit
Reviewed By: javache

Differential Revision: D4296294

fbshipit-source-id: b31e522c21ec490fdf98711655e5e8df22b32a12
2016-12-08 07:44:37 -08:00
Pieter De Baets 286095292f Fix RN tvOS build
Reviewed By: mkonicek

Differential Revision: D4298869

fbshipit-source-id: fd132b2c1b656707b2dc750888c09e262b503111
2016-12-08 04:13:36 -08:00
Adam Ernst 617eb309a1 Refactor reload command in React Native
Summary: Introduces an API to register a weakly-held listener for the reload (Cmd+R) command. This allows external infrastructure to hook into the reload command before the `RCTBridge` object is even created.

Reviewed By: javache

Differential Revision: D4286980

fbshipit-source-id: 51012fb8cbeb433dc880d9d98d847b07fdbb4c4f
2016-12-07 20:13:22 -08:00
Pieter De Baets 286a1b2e5e Remove deprecated RCTReloadNotification
Reviewed By: adamjernst

Differential Revision: D4294180

fbshipit-source-id: 6837597df2a798661c993c6f63ec430989954de6
2016-12-07 16:28:33 -08:00
Pieter De Baets 59407f3660 Redo exported headers and include paths for opensource
Summary:
Xcode really sucks, per some discussion on e1577df1fd and https://developer.apple.com/library/content/technotes/tn2215/_index.html, if you use the headers phase, and mark headers in your static library as public, they will actually end up in the final package that's built and you can't submit to the app store! This changes our xcode setup to use a copy files phase instead.

I've also changed the header include path to be $(BUILT_PRODUCTS_DIR)/include, which is added to the include path by Xcode by default, so 3rd party libraries should not be impacted by these changes anymore.

Reviewed By: mkonicek

Differential Revision: D4291607

fbshipit-source-id: 969b9ebcbeb8161f85427f8c429e198d9d0fae30
2016-12-07 15:28:29 -08:00
Emil Sjolander 7f8c2985a8 Rename directories
Reviewed By: gkassabli

Differential Revision: D4284681

fbshipit-source-id: f0c6855c2c6e4389b7867f48f72cbb697830fc5a
2016-12-07 05:14:12 -08:00
Pieter De Baets 27acb71353 Fix target configuration in React.xcodeproj
Summary: The target config inside React.xcodeproj was messed up, with source files being included in multiple or wrong targets. I went over the files in React.xcodeproj and verified that each .m file was included only once and was in the right target and .h were in the right projects.

Reviewed By: majak

Differential Revision: D4284673

fbshipit-source-id: 99af61083c6ca81311e30f0ea0045d4e7bffc20c
2016-12-06 06:28:33 -08:00
Jake Dawkins 6234a5dfa2 Fix iOS Picker Item Colors
Summary:
I want to resolve #11170 by passing the `color` prop from `PickerIOS.Item` to its implementation.

In `RCTPicker.m`, the label.textColor was already being set and used, but there was nothing referencing the past prop. I passed the prop to the implementation, checked if it exists, and if not, set the default color, like before.

I visually tested the **Colorful Pickers** example in UIExplorer. Those picker `Item`s pass in a `color` prop.

![dec-01-2016 22-07-46](https://cloud.githubusercontent.com/assets/9259509/20821696/ae45d704-b812-11e6-9720-0045d6c0bcd4.gif)

The basic picker does not pass the color prop to the picker `Item`, and there are no errors. Basic functionality is still in tact:

![dec-01-2016 22-09-35](https://cloud.githubusercontent.com/assets/9259509/20821730/ee544f74-b812-11e6-9294-a1b45e78d9f7.gif)
Closes https://github.com/facebook/react-native/pull/11260

Differential Revision: D4272370

fbshipit-source-id: 5fa33c40526dda59ca2ab527c31351bcd27e5cf3
2016-12-03 18:58:29 -08:00
Emil Sjolander 85ac5fc354 Rename C api
Differential Revision: D4259190

fbshipit-source-id: 26c8b356ca464d4304f5f9dc4192bff10cea2dc9
2016-12-03 04:44:10 -08:00