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

15550 Коммитов

Автор SHA1 Сообщение Дата
Josh Justice 9cd6ae2f4b Updated Button e2e tests to look up elements via testID (#22593)
Summary:
Previously the e2e test for Butto looked up elements by label. This can be fragile, and based on my understanding from TheSavior we would prefer to use testIDs. This also sets a consistent pattern we can point future contributors to, to follow.

Note that we are still looking up elements in the alerts shown by label. I haven't yet looked into whether it would be possible to add testIDs to alerts; it might be too complex to be worth it.
Pull Request resolved: https://github.com/facebook/react-native/pull/22593

Differential Revision: D13410799

Pulled By: TheSavior

fbshipit-source-id: 4bda80f4b8e7fe3ef17cd33209ec86d9183fd5e9
2018-12-10 17:54:23 -08:00
Luis Flores f14edd8a0c Fix ListViewMock unique key error (#14894)
Summary:
Add key prop to renderHeader and renderFooter in ListViewMock.
Fix unique key error when using jest snapshots.

It closes #12762
Pull Request resolved: https://github.com/facebook/react-native/pull/14894

Reviewed By: TheSavior

Differential Revision: D13396721

Pulled By: cpojer

fbshipit-source-id: 5bbcb8157e3cd98fe07f2a037e1dbc06ab599c87
2018-12-10 17:13:54 -08:00
byronluk 6a483495c8 added utfsequence to react-native exports (#20955)
Summary:
Fixes #20935

Added UTFSequence module to React-Native exports. Put it under // APIs but I'm not certain if it belongs there.
Pull Request resolved: https://github.com/facebook/react-native/pull/20955

Differential Revision: D13396903

Pulled By: cpojer

fbshipit-source-id: 29cb2ee1431132bd7ca4973fecb0025cd6303a14
2018-12-10 17:10:23 -08:00
Marius Reimer ddc3471f88 set blob as default XMLHttpRequest header response type if supported (#22063)
Summary:
This is a problem that is discussed in issue #21092

Related issues: #21851 #19717

Found the code to eventually fix this issue [here](899b155746/fetch.js (L486))

- [x] Fetching an image locally and check if the blob is there, as well as its size > 0.

___
Help reviewers and the release process by writing your own release notes. See below for an example.

[GENERAL] [ENHANCEMENT] [whatwg-fetch] - set blob as default XMLHttpRequest header response type if supported
Pull Request resolved: https://github.com/facebook/react-native/pull/22063

Differential Revision: D13408797

Pulled By: cpojer

fbshipit-source-id: 9822d5a7e24bacd72838f3fc9a61b1a97b44484b
2018-12-10 16:59:20 -08:00
Ben Holcomb 6cc6f8f488 Revert D13402177: [react-native][PR] Map textContentType strings to Objective-C constants
Differential Revision:
D13402177

Original commit changeset: 55f4a2029cd3

fbshipit-source-id: b4871d10a9622f3312845a6682c482760e7e79e0
2018-12-10 13:05:12 -08:00
Levi Buzolic 077386a233 Map textContentType strings to Objective-C constants (#22579)
Summary:
Fixes #22578

Currently the only `textContentType` values that work are: `username`, `password`, `location`, `name` and `nickname`. This is due to the strings provided by React Native not matching up with the underlying string constants used in iOS (with the exception of the aforementioned types). Issue #22578 has more detail examples/explanation.
Pull Request resolved: https://github.com/facebook/react-native/pull/22579

Differential Revision: D13402177

Pulled By: shergin

fbshipit-source-id: 55f4a2029cd3ea1fb4834e9f56d2df5a05b31b4e
2018-12-10 12:11:51 -08:00
Josh Justice 1bc704d4c7 Add Touchable E2E tests (#22570)
Summary:
Adds some initial tests for Touchable*. It only tests the first screen worth of examples; in a separate PR I'll work on an alternate way to "scroll" to individual examples in tests, before I add tests for the rest of the Touchable examples.

On the live stream where I began writing these tests, I reorganized the "Touchable feedback examples" to the top of the list so it would be on-screen for testing. I didn't include this reorganization or test in this PR; that can be added in once the "alternative to scrolling" is added in, to avoid having to reorganize.

Changelog:
----------
[General] [Added] - Add E2E tests for Touchable
Pull Request resolved: https://github.com/facebook/react-native/pull/22570

Differential Revision: D13400348

Pulled By: TheSavior

fbshipit-source-id: 821af135296049090427a16472cc14dabeb10ab4
2018-12-10 10:58:15 -08:00
Emil Sjölander ee6b0d6658 Fix aspect ratio when stretching with main axis margin (#834)
Summary:
I've noticed that when a child's size is determined by `align-items: stretch` in combination with `aspect-ratio` its size is wrongly calculated to account for margin in the main axis when there is more than enough space.

See playground: https://goo.gl/tgW6cD

I've yet to figure out exactly how to solve this but i've started by writing a failing test when can be seen in the first commit here.

I assumed I had found the bug here https://github.com/facebook/yoga/blob/master/yoga/Yoga.cpp#L1838 where margin is being subtracted from the desired width even though the measure mode tells it to measure to exactly that size. However, if we don't remove this margin from the available width then 15 tests fail (including the one I just added) not quite figured out why yet. I'm also a bit confused at to why this would only happen for nodes with `aspect-ratio` and not for nodes where an explicit height and width is set.
Pull Request resolved: https://github.com/facebook/yoga/pull/834

Reviewed By: astreet

Differential Revision: D13223579

Pulled By: davidaurelio

fbshipit-source-id: 6970e6072e79f3bb6f9097355ab6e441441bfd88
2018-12-10 09:23:01 -08:00
Rafael Oleza c8047bfe66 Fix flow types
Summary:
This diff ignores the `react-native-local-cli` from being used internally.

Unfortunately, since `react-native-local-cli` has its own dependency on Metro, and using `yarn` selective resolutions causes some issues with `flow` rechecks that have not been resolved (https://fb.facebook.com/groups/flow/permalink/2220467474668522/), the easiest way to move forward is to just not install the `react-native-local-cli` package internally (we don't need it since we have our own cli).

Reviewed By: pvdz

Differential Revision: D13377495

fbshipit-source-id: 6d6edbd947104e050ad1c31a657fc21fe6848692
2018-12-10 08:36:29 -08:00
Elliott Sprehn 167d7861cb Don't crash on second resolve or reject in PromiseImpl. (#20303)
Summary:
Promise semantics per JS should allow calling resolve or reject repeatedly without crashing. Only the first one should do anything, but others should be allowed. This change fixes the Java bridge for Android. A separate change is needed for iOS.

Issue #20262
Pull Request resolved: https://github.com/facebook/react-native/pull/20303

Differential Revision: D13396975

Pulled By: cpojer

fbshipit-source-id: 81f14f73654fa7c44e043f574a39fda481ace44b
2018-12-10 05:56:22 -08:00
luckyzeng 3592122af3 Delete unused code in console.js (#20860)
Summary:
The isPrimitive method in [console.js](5c2720b089/Libraries/polyfills/console.js (L364)) is unused. It should be deleted.
Pull Request resolved: https://github.com/facebook/react-native/pull/20860

Differential Revision: D13396715

Pulled By: cpojer

fbshipit-source-id: ddfd828086106c997dcc77f5eae67adb6a0c1dfa
2018-12-10 05:48:32 -08:00
Josh Justice fb16af7944 Detox debug build (#22572)
Summary:
Adds a Detox configuration and instructions for running the app in development mode in Detox. This speeds up developing tests, because changes to production code don't require a full rebuild.
Pull Request resolved: https://github.com/facebook/react-native/pull/22572

Differential Revision: D13396883

Pulled By: cpojer

fbshipit-source-id: 186cc8d75eccae411b602cb0f68f0e11856e0743
2018-12-10 02:33:31 -08:00
Christoph Nakazawa 78132a0ab8 Fix weird `createAnimatedComponent` babel/flow bug
Summary: There are some versions of babel 7's flow support that cause problems with property initializers. I changed this code to use class properties to fix the issue. See https://github.com/facebook/react-native/issues/20588

Reviewed By: TheSavior

Differential Revision: D13396959

fbshipit-source-id: a76266ac0c8a6a19a1c45f7136de4aba9c72581d
2018-12-10 00:39:06 -08:00
Pankaj Singh b0c43717a6 Update README.md (#20867)
Summary:
Thank you for sending the PR! We appreciate you spending the time to work on these changes.
Help us understand your motivation by explaining why you decided to make this change.

If this PR fixes an issue, type "Fixes #issueNumber" to automatically close the issue when the PR is merged.
Pull Request resolved: https://github.com/facebook/react-native/pull/20867

Differential Revision: D13396488

Pulled By: cpojer

fbshipit-source-id: 971ac7b5f2e795280b94be78dce0fe44a065b942
2018-12-09 22:27:11 -08:00
dalcib af3570c637 Make jest react-native preset to use typescript files (#22217)
Summary:
Metro and react-native now have first-class support to Typescript with Babel 7, but react-native Jest preset needs specific settings to work with .ts and .tsx files.
This PR updates react-native Jest preset to use Typescript out of the box.
Pull Request resolved: https://github.com/facebook/react-native/pull/22217

Differential Revision: D13396206

Pulled By: cpojer

fbshipit-source-id: aa4e4163e555c6b213457755bc13432fa1cddf5e
2018-12-09 20:07:09 -08:00
Taras Tsugrii 7fb02889d7 Buildify xplat build files.
Summary: drop-conflicts

Differential Revision: D13378356

fbshipit-source-id: 555bcfb30139b165e32e2045b291249c6b6b8650
2018-12-08 13:18:23 -08:00
Rick Hanlon 9fdbf6029e Add e2e tests, bug fixes for testIDs (#22537)
Summary:
This PR adds e2e tests for the Picker and DatePicker components.

While writing these tests, I also found and fixed two bugs where we wern't passing the `testID` down to the native components, so detox couldn't look them up. This confirms what was mentioned by rotemmiz [here](https://github.com/wix/Detox/issues/798#issuecomment-401412276)
Pull Request resolved: https://github.com/facebook/react-native/pull/22537

Reviewed By: cpojer

Differential Revision: D13371307

Pulled By: rickhanlonii

fbshipit-source-id: a4dfcdb5913645bceca0c7353328eeb9ad0f6558
2018-12-07 14:54:42 -08:00
Héctor Ramos cf0dd8ba78 Templates: Use default title, labels (#22560)
Summary:
Trivial.
Pull Request resolved: https://github.com/facebook/react-native/pull/22560

Differential Revision: D13383489

Pulled By: hramos

fbshipit-source-id: a4ffca69e102a438e576a3b06b8ef29567271f94
2018-12-07 14:32:23 -08:00
gengjiawen fe10dfc72c fix windows ci
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/22557

Differential Revision: D13381568

Pulled By: hramos

fbshipit-source-id: db2ca0615c4cde5b0a4ae8ae824a005bcc1e2a1c
2018-12-07 14:16:45 -08:00
David Aurelio 90f582ffb9 Back out Stack D13119110..D13236159
Summary: backout, causes failures

Reviewed By: adityasharat

Differential Revision: D13376210

fbshipit-source-id: 1fa8823f2dce601c47738f34ddb2674288197e79
2018-12-07 13:01:28 -08:00
David Vacca 69c8aa64e5 Fix NPE when opening Google Search Assist when a RN Dialog is displayed
Summary:
This fixes app crashes on opening android search assistant when a RN modal is visible. The root cause is that ViewGroup.dispatchProvideStructure() method uses the private variable 'mChildren' to access the children of a view group instead of the publicApi.

This fixes the top crash for the react_MarketplaceProductDetailsNonIPadRoute route.

This also fixes github issues:
https://github.com/facebook/react-native/issues/15932
https://github.com/facebook/react-native/issues/13201
https://github.com/facebook/react-native/issues/15440

that were closed without a fix

Reviewed By: PeteTheHeat

Differential Revision: D13375993

fbshipit-source-id: d603cb4ef65a423c63a6ef2b51235702c7dbffcb
2018-12-07 09:55:40 -08:00
Christoph Nakazawa 896bb8a21e Move react-native template
Summary: This diff moves the React Native template from `local-cli/templates/HelloWorld` to `template`. Keeping it in the react-native repo will allow us to make changes to the template and version it together with react-native, instead of moving it out into a separate repo and trying to keep the template in sync with RN.

Reviewed By: TheSavior

Differential Revision: D13372949

fbshipit-source-id: e68e267b4dcf6384535d7b48fc11e297a12e9676
2018-12-07 07:49:19 -08:00
Christoph Nakazawa 9d3f598c2c Remove references to `local-cli`
Summary: This cleans up various configurations after the removal of this folder.

Reviewed By: hramos

Differential Revision: D13338515

fbshipit-source-id: 9d6877921e15a183e46861626af831231333f42a
2018-12-07 07:49:18 -08:00
Christoph Nakazawa cd43fb8005 Remove local-cli
Summary:
This diff removes all files from the local-cli from react-native-github. The only leftover is the `cli.js` which redirects to `react-native-local-cli` and the templates folder which I'll move in a follow-up.

This diff simply removes all files, it makes no code changes. There will be a cleanup diff on top of this one.

Reviewed By: TheSavior

Differential Revision: D13338367

fbshipit-source-id: 1afabdb34202596fb13186d728df74482c9bc609
2018-12-07 07:49:18 -08:00
Tnarita0000 d2318c403f Remove var from Network/__tests__/XMLHttpRequest-test.js (#22195)
Summary:
Remove var from Network/__tests__/XMLHttpRequest-test.js

- [x] Check npm run flow
- [x] Check npm run flow-check-ios
- [x] Check npm run flow-check-android

[GENERAL] [ENHANCEMENT] [Libraries/emitter] - remove var
Pull Request resolved: https://github.com/facebook/react-native/pull/22195

Differential Revision: D13374893

Pulled By: cpojer

fbshipit-source-id: 0d07599406c1195f2f98e17df98be7d42efdf664
2018-12-07 02:50:05 -08:00
Taylor123 f6d3a61677 default hitSlop values to 0 (#22281)
Summary:
Experienced a `TouchableOpacity` releasing the `PanResponder` without invoking `onPress` due to a missing a direction key in the `hitSlop` prop; The missing key caused the corresponding pressExpand to become NaN which causes `isTouchWithinActive` to become falsey, when it should be truthy.

If defaulting to 0 is undesired behavior, I'm happy to take a different approach.
Pull Request resolved: https://github.com/facebook/react-native/pull/22281

Differential Revision: D13374335

Pulled By: cpojer

fbshipit-source-id: f9d28e51b9d9c45aed42bea2df3d844a799fa827
2018-12-06 21:44:36 -08:00
Lea Bärtschi cbe7d41f3f Remove trailing slash from origin header if no port is specified (#22290)
Summary:
Fixes #16304

The standard format for origin HTTP headers does not allow a trailing slash. In order to not get warnings when connecting a websocket, I removed the trailing slash when generating the default origin HTTP header for the websocket connect request.

Release Notes:
----------
[Android] [Fixed] - Fixed default origin header for websocket connections to match the standard format (https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Origin) in WebSocketModule
Pull Request resolved: https://github.com/facebook/react-native/pull/22290

Differential Revision: D13374345

Pulled By: cpojer

fbshipit-source-id: 1173241f2b6912fd6df5e196053a950bb42ff01b
2018-12-06 21:36:19 -08:00
Karan Thakkar de6cdc442d Rename RCTImageCacheDelegate -> RCTImageCache in code comment (#22406)
Summary:
Update reference to property in code comment in `RCTImageLoader`. There is no protocol named `RCTImageCacheDelegate` in the codebase. Its just `RCTImageCache` and it exists [here](f2894e58cf/Libraries/Image/RCTImageLoader.h (L22)).
Pull Request resolved: https://github.com/facebook/react-native/pull/22406

Differential Revision: D13373793

Pulled By: cpojer

fbshipit-source-id: b5edf18ebad626bf09648c079299e5acd14ba48a
2018-12-06 21:13:58 -08:00
ferrannp e8a6cb5e18 Android: Adding sendIntent on Linking module (#22302)
Summary:
This PR implements "Add a standardized way to send intents on Android" discussed in https://github.com/react-native-community/discussions-and-proposals/issues/34.
Pull Request resolved: https://github.com/facebook/react-native/pull/22302

Differential Revision: D13374186

Pulled By: cpojer

fbshipit-source-id: 2f0b9b9f46e99f382b6c35b1914e75df23a7fd74
2018-12-06 21:13:58 -08:00
gtebbutt cc4211c72f Restore TouchableHighlight and TouchableOpacity behaviour on TV platforms (#21478)
Summary:
Since #18470, the default focus behaviour of `TouchableHighlight` and `TouchableOpacity` has been missing on tvOS. This uses the new `touchableHandleFocus` and `touchableHandleBlur` functions to restore the behaviour. Fixes #21295.
Pull Request resolved: https://github.com/facebook/react-native/pull/21478

Differential Revision: D13372959

Pulled By: cpojer

fbshipit-source-id: a5fa9d45214ac48a14a6573ccf014bba1ee0a103
2018-12-06 21:09:25 -08:00
James Treanor c090758c12 Fix build error for Android projects that use `apply plugin: "com.android.library"` (#22312)
Summary:
This PR allows Android projects that use `apply plugin: "com.android.library"` to build successfully. A recent regression caused by https://github.com/facebook/react-native/pull/20526 means that building one of these projects always fails with this error:

```
FAILURE: Build failed with an exception.

* Where:
Script '/Users/james/src/SampleLibrary/node_modules/react-native/react.gradle' line: 15

* What went wrong:
A problem occurred configuring project ':app'.
> Could not get unknown property 'applicationVariants' for object of type com.android.build.gradle.LibraryExtension.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 0s
```

This change updates `react.gradle` to cater to both application and library projects by selectively using `android.applicationVariants` or `android.libraryVariants`.

Fixes https://github.com/facebook/react-native/issues/22310.
Pull Request resolved: https://github.com/facebook/react-native/pull/22312

Differential Revision: D13373742

Pulled By: cpojer

fbshipit-source-id: 64c35ab7a6d5d0d840a43729123e70dd8e0d36e0
2018-12-06 20:33:11 -08:00
Zack Sheppard 2831d9ef61 Extend reason message for `RCTFatalException` (#22532)
Summary:
Fixes #22530

As described in the issue, the previous behavior for the `RCTFatal` macro was to truncate the `reason` on the resulting `NSException` to 75 characters. This would ensure the reason would fit on a single line, but resulted in issues debugging errors that occurred in the wild, as many crash logging tools (like Sentry) discard the `name` value of the exception and use the `reason` as their primary identifier. At 75 characters, useful information like the location of the error would usually be truncated.

- [x] This extends the truncation threshold to 175 characters, which should be short enough to prevent full-screen-takeover length errors, but long enough to provide useful context to the error.
- [x] This adds a `userInfo` value to the resulting `NSException`. It copies over the `userInfo` from the `NSError` passed to the macro, and adds an "untruncated message" value that contains the untruncated version of the `NSException`'s reason.

[iOS] [Changed] - RCTFatalExceptions now include more information in their reason and a userInfo.

<!--

  CATEGORY may be:

  - [General]
  - [iOS]
  - [Android]

  TYPE may be:

  - [Added] for new features.
  - [Changed] for changes in existing functionality.
  - [Deprecated] for soon-to-be removed features.
  - [Removed] for now removed features.
  - [Fixed] for any bug fixes.
  - [Security] in case of vulnerabilities.

  For more detail, see https://keepachangelog.com/en/1.0.0/#how

  MESSAGE may answer "what and why" on a feature level. Use this to briefly tell React Native users about notable changes.

  EXAMPLES:

  [General] [Added] - Add snapToOffsets prop to ScrollView component
  [General] [Fixed] - Fix various issues in snapToInterval on ScrollView component
  [iOS] [Fixed] - Fix crash in RCTImagePicker

-->
Pull Request resolved: https://github.com/facebook/react-native/pull/22532

Differential Revision: D13373469

Pulled By: cpojer

fbshipit-source-id: ac140d14ce76e1664869437c2c178bdd65ab6e0e
2018-12-06 20:22:25 -08:00
Christoph Nakazawa 983ddc78d0 Move middleware files into react-native-internal-cli
Summary: These files are used by `js1 run`. By copying them close to `runServer.js` we can soon remove `local-cli`.

Reviewed By: TheSavior

Differential Revision: D13337487

fbshipit-source-id: ef80317580d5a9b3e560ad1f27b681887cf50b6b
2018-12-06 20:15:46 -08:00
Christoph Nakazawa 168ac8d83d Use `findPlugins` from `react-native-local-cli`
Summary: This module now lives outside of the React Native repo.

Reviewed By: TheSavior

Differential Revision: D13337412

fbshipit-source-id: 548868e5f1f3812574fda3d235eb9d47c81d6522
2018-12-06 20:15:46 -08:00
Christoph Nakazawa 2e5e9fa88a Move asset related modules into `metro-buck`
Summary:
These files are some of the few standalone files from the `local-cli` that are used internally. This diff copies them into the one place where they are used. Note that I am leaving the old files in `local-cli`. Even if they are unused, moving them would break flow (require module verification).

This diff also moves the `assetPathUtils` file into `Libraries/Image`, which is where it is used. This was previously part of D13337412 but I had to squash them to make buck happy.

Reviewed By: TheSavior

Differential Revision: D13337304

fbshipit-source-id: 2d501109ba7d4ba94ca7e8f2953258221947b90e
2018-12-06 20:15:46 -08:00
Doug Russell ee7c702308 Accessibility Escape
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/22047

Differential Revision: D13146179

Pulled By: cpojer

fbshipit-source-id: b8a089114a5deafee47dd482e484d413c8c39137
2018-12-06 19:44:21 -08:00
Jamon Holmgren 900f2df351 Adds links to the README for roadmap, releases, RFCs. Fixes the help link (#22548)
Summary:
This PR only contains README updates.

1. Adds roadmap link
2. Adds releases repo link
3. Adds discussions and proposals repo link
4. Fixes the help link (pointed to abandoned forum)
Pull Request resolved: https://github.com/facebook/react-native/pull/22548

Differential Revision: D13372704

Pulled By: cpojer

fbshipit-source-id: 3c04d00ae08281298a851ddd6ec38ff67c6add30
2018-12-06 19:35:14 -08:00
Radovan Šmitala a2ef5b85d8 Use main.jsbundle in iOS template for production build (#22531)
Summary:
Default HelloWorld template for iOS doesn't make production main.jsbundle. This is little bit confusing in compare with Android building app when everything works one first run.

Make it seamless, reduce confuse.
Based on docs https://facebook.github.io/react-native/docs/running-on-device#3-configure-app-to-use-static-bundle

Fixes #22335
Fixes #18562
Pull Request resolved: https://github.com/facebook/react-native/pull/22531

Differential Revision: D13372773

Pulled By: cpojer

fbshipit-source-id: 888c675b7d11b1a323445e092ec9ff83924c42f4
2018-12-06 19:29:52 -08:00
David Aurelio 8f6521aacf Don't pass `std::string` by pointer
Summary:
@public

Pass strings by mutable ref rather than pointer.

Reviewed By: SidharthGuglani

Differential Revision: D13236159

fbshipit-source-id: 04fd35e8a9e106ba8cdd71cfab31e8d90edaac9e
2018-12-06 07:38:44 -08:00
David Aurelio 32d5da2eb8 Use bitfields for enum members of `YGStyle`
Summary:
@public

Puts all enum fields of `YGStyle` into bitfields. This saves 36 bytes (> 3%) per node.

Reviewed By: SidharthGuglani

Differential Revision: D13233686

fbshipit-source-id: 3ef7e0d6913f0254806acb942d9a9f5b78a5af9c
2018-12-06 07:38:44 -08:00
David Aurelio 32bc724fb0 Remove templates for setting/getting style properties
Summary:
@public

Replaces the `StyleProp` template with a simple setter macro / inlined getter code.

The template was introduced to replace more extensive macros that would generate function signatures, too.
Here, we keep the spirit of that change by only generating function bodies.

Reviewed By: SidharthGuglani

Differential Revision: D13233687

fbshipit-source-id: 218a7d5edb489b43a66c8c9d6156f74feefd2227
2018-12-06 07:38:44 -08:00
David Aurelio f9c575e352 `YGNodeBoundAxisWithinMinAndMax` accepts `YGFloatOptional`
Summary:
@public

Saves some calls to `.unwrap()`

Reviewed By: SidharthGuglani

Differential Revision: D13209153

fbshipit-source-id: 5658586e91496085f39b3522db6364aaeafcfe2f
2018-12-06 07:38:44 -08:00
David Aurelio 94ab9b429c inline `YGUnwrapFloatOptional`
Summary:
@public
Replaces C-style function call with C++ method invokation.

Reviewed By: SidharthGuglani

Differential Revision: D13209154

fbshipit-source-id: 14e650af4655efb3a659f3cd949a11df773aabcf
2018-12-06 07:38:44 -08:00
David Aurelio 517d07ddcf Remove unnecessary `static` keyword
Summary:
@public

Header-declared inline functions shouldn’t be decleared `static`

Reviewed By: SidharthGuglani

Differential Revision: D13209156

fbshipit-source-id: e2d643a67e6f6c33c96dc71b0a90d00bd9b6f36f
2018-12-06 07:38:44 -08:00
David Aurelio fa171b4fe7 Get rid of `static_cast` in `YGResolveValue`
Summary:
@public

Removes `static_cast` from `YGResolveValue`

Reviewed By: SidharthGuglani

Differential Revision: D13209155

fbshipit-source-id: 76c27c89f6217af9dfef9e2620d639c9f3e212f5
2018-12-06 07:38:43 -08:00
David Aurelio ceb6602422 Inline `YGFloatOptional` completely
Summary:
@public
`YGFLoatOptional` only contains trivial functionality. Make it header-only.

Reviewed By: SidharthGuglani

Differential Revision: D13209151

fbshipit-source-id: 3ecca015fa0ac6644ae694b44bc53d840fbc5635
2018-12-06 07:38:43 -08:00
David Aurelio a7757f6e5d Pass `YGFloatOptional` by value, not reference
Summary:
@public

`YGFloatOptional` is a 32bit type now, and can be passed by value efficiently.

Reviewed By: SidharthGuglani

Differential Revision: D13209150

fbshipit-source-id: c7b937a640258256c97e082ba2f832754e191b9a
2018-12-06 07:38:43 -08:00
David Aurelio 4157a49d8d Eliminate `YGFloatOptional::getValue()`
Summary:
@public

`YGFloatOptional::getValue()` has the unfortunate property of calling `std::exit` if the wrapped value is undefined.
That forces `x.isUndefined() ? fallback : x.getValue()` as access pattern.

Here, we replace that by introducing `YGFloatOptional::orElse(float)` which encapsulates that pattern. Other additions are `orElseGet([] { … })` and some extra operators.

Reviewed By: SidharthGuglani

Differential Revision: D13209152

fbshipit-source-id: 4e5deceaaaaf8eaed44846a8c152cc8b235e815c
2018-12-06 07:38:43 -08:00
David Aurelio cb7a9b2057 Store `YGFloatOptional` in 32 bits
Summary:
@public

After removing `-ffast-math`, `NaN` can again be used to represent `undefined`. That allows us to remove the additional flag from `YGFloatOptional`, and reduce memory usage.

Reviewed By: SidharthGuglani

Differential Revision: D13209157

fbshipit-source-id: 21b83c837a78f924a4ec23a9236ca2440b3c8606
2018-12-06 07:38:43 -08:00
David Aurelio e1c651340b Make equality operator for `YGValue` inlineable
Summary:
@public

Makes `operator==` for `YGValue` an inline function.

Reviewed By: SidharthGuglani

Differential Revision: D13189356

fbshipit-source-id: 7fe61035acf635e22ebb1a1071925d6b3dad0616
2018-12-06 07:38:43 -08:00