Commit Graph

1011 Commits

Author SHA1 Message Date
Alexey Kozhevnikov d9792b3e59 Exclude cpp equality operators from `extern "C"`
Summary:
`extern "C"` disables name mangling, hence input parameter types does not influence the name. That makes it impossible to have several equality operators with `extern "C"` linkage (for different types).

One such operator is defined in Windows SDK, in `guiddef.h`. It in turn is included in `winnt.h` inside `extern "C" { ... }` block. Trying to compile file which both is dependent both on `winnt.h` and `Yoga.h` results in:
```
Yoga.h(50): error C2733: 'operator ==': second C linkage of overloaded function not allowed
guiddef.h(192): note: see declaration of 'operator =='
```

In general it doesn't make much sense to have cpp specific operator to have `extern "C"` linkage, so the change doesn't introduce any controlling flag (mangling on/off).

Note that it's breaking binary compatibility and yoga library should be rebuilt if those operators are used.

Reviewed By: milend

Differential Revision: D10418395

fbshipit-source-id: 2f1cccff26165e638b9a07eece07d94fccfa5e5a
2018-10-18 08:44:45 -07:00
Marc Horowitz 6370b86c1f Get RNTester to compile and run
Summary:
This diff includes a few changes:
1. Move the headers inside `jsiexecutor` into `jsiexecutor/jsireact`. As far as I'm aware, the Android ndk build system isn't flexible enough to support header namespaces, so we can't just expose the headers inside the `jsiexecutor` directory under the `jsireact` namespace. Therefore, I moved the headers to `jsiexecutor/jsireact`, and added `jsiexecutor` to the header search path.  This was the easiest way to simulate `jsireact` namespace.
2. Setup the Android.mk files to get RNTester compiling and running.
3. Introduce a `jscexecutor` module to make `JSCExecutor.java` execute without throwing.

**Note:** Moving the header files inside `jsiexecutor` probably breaks the iOS builds and internal builds. I'll fix those in subsequent diffs on this stack.

Reviewed By: shergin

Differential Revision: D9995429

fbshipit-source-id: 418a4ee91f585842c5e317af2f300227a51e9ba8
2018-10-18 01:06:24 -07:00
Marc Horowitz 7ffb406517 Remove RN files which use JSC
Summary:
JSI+JSCRuntime replaces direct use of JSC
@public

Reviewed By: danzimm

Differential Revision: D9328235

fbshipit-source-id: a4d0cad8250ef2da058ffffbdedbffa19f96bb12
2018-10-18 01:06:24 -07:00
Marc Horowitz 00381920c6 Remove jschelpers and privatedata
Summary: JSI doesn't use any of this.

Reviewed By: RSNara

Differential Revision: D10229167

fbshipit-source-id: 9eaa288a1d62bafb3ff0626f9f8430e699fdad4a
2018-10-18 01:06:24 -07:00
Marc Horowitz c49d3653ef iOS changes to switch to JSI
Summary:
change RCTCxxBridge to use JSIExecutorFactory+JSCRuntime
instead of JSCExecutorFactory.  Also remove JSC usage from RN in other
files.  This allows deleting files, too, which is done further down
the stack.

Reviewed By: RSNara

Differential Revision: D9369111

fbshipit-source-id: 67ef3146e3abe5244b6cf3249a0268598f91b277
2018-10-18 01:06:24 -07:00
Marc Horowitz 6796e62bb3 Remove JSC references
Summary:
Removing entire files will be the next diff
@public

Reviewed By: fkgozali

Differential Revision: D9328239

fbshipit-source-id: 083847d3b841a3c7bfa751a82e8cc16bd112bace
2018-10-18 01:06:24 -07:00
Marc Horowitz 749b18dbc9 Add JSI-based JSExecutor for the bridge
Summary:
This is similar in function to the old JSCExecutor, but uses the more abstract JSI API to interact with the JSVM.
@public

Reviewed By: axe-fb

Differential Revision: D9328241

fbshipit-source-id: 3212ff4f43d0589a70d7bebc4d463d4433590f1d
2018-10-18 01:06:24 -07:00
Marc Horowitz a23fb1a22c Add JSI implementation for JSC
Summary:
This diff is an implementation of jsi::Runtime which uses JSC as the virtual machine.  All of the JSC-specific details are encapsulated here.
@public

Reviewed By: RSNara

Differential Revision: D9328242

fbshipit-source-id: be3c7bed161916c1cb9a48182600b558f054eadc
2018-10-18 01:06:24 -07:00
Marc Horowitz e337bcafb0 Add JSI API and JSIDynamic glue to OSS React Native
Summary: This will help abstract the JS engine from React Native

Reviewed By: hramos

Differential Revision: D9328237

fbshipit-source-id: 7b34f55f28e43d83ba24d22e83e836c92ca737a9
2018-10-18 01:06:23 -07:00
Valentin Shergin 764dd511d2 Fabric: Making EventEmitter reenableable
Summary:
The first implementation of EventEmitter's enable/disable feature didn't not provide a way to enable an object after it was disabled.
Apparently, we need this functionality due that fact that all nodes of the same family share same event emitter.

Reviewed By: mdvacca

Differential Revision: D10395849

fbshipit-source-id: 0eba54f0bb7ded35d64afb6559e6e27208c2b577
2018-10-16 12:29:33 -07:00
Valentin Shergin f2da2d1963 Fabric: Proxying `LayoutConstraints::direction` down to RootNode's styles
Summary:
Trivial.
We have to proxy layout directions as well as min and max sizes to RootNode's Props to properly communicate the constrains to Yoga.

Reviewed By: sahrens

Differential Revision: D10387798

fbshipit-source-id: a02ec0a20b3ef28f6230738e5b3a4a2b0b8e0961
2018-10-15 23:25:47 -07:00
Valentin Shergin 07d8b06d41 Fabric: TextAttributes::defaultTextAttributes()
Summary: An `AttributedString` object generated by a cross-platform layer of React Native must have already resolved text styles to make the actual resulting text identical across platforms. To do so we have to have a unified default.

Reviewed By: sahrens

Differential Revision: D10287725

fbshipit-source-id: e8c62b33496be34146182baccd0009d3624a7fe5
2018-10-15 23:25:47 -07:00
Valentin Shergin 057438a103 Fabric: Defined constants for white, black and clear colors
Summary: This might be useful to specify some default props.

Reviewed By: sahrens

Differential Revision: D10284657

fbshipit-source-id: b6fbdc6bab75697af67bdbb5d06eb3309500ab8c
2018-10-15 23:25:47 -07:00
Valentin Shergin c4c90fdc2e Fabric: Support for a bunch of accessiblity props in View
Summary: We didn't have support for them... and now we have it.

Reviewed By: sahrens

Differential Revision: D10280430

fbshipit-source-id: 7275d4617ed3994366f673a17c24b823293d7092
2018-10-15 23:25:47 -07:00
David Vacca 5d414665ea Fix reload for Image views in Android
Summary: This diff fixes the release of ImageRequest object. The responseFutureSplitter_ can be destroyed by the time ~ImageRequest is executed. See P60163877 for original crash (this crash was reproducible when reloading or closing a Fabric screen that contains several images.

Reviewed By: shergin

Differential Revision: D10282207

fbshipit-source-id: 4f0894959e54f6d15b98e216df102e764866e387
2018-10-12 18:41:51 -07:00
Adam Comella f90c9b5292 When paddingStart is 0, it should override paddingHorizontal (#816)
Summary:
Fixes #815

Imagine a node with this style: `{ paddingHorizontal: 10, paddingStart: 0 }`.

After running layout on this node, we expect its computed `paddingStart` to be `0`. However, it is actually `10`.

Consider the expression `paddingEdgeStart.getValue() > 0.0f` in [`getLeadingPadding`](328ec7dc4d/yoga/YGNode.cpp (L461)). Why is `0` handled like a negative number rather than a positive number? I suspect this should be `>=` so `0` is handled like the positive numbers (this is how `getTrailingPadding` works).

It looks like 3a82d2b1a8?diff=unified&w=1#diff-07b4949bf42749fde386e769ff08a124 changed the operator from `>=` to `>` in `getLeadingPadding`. I suspect it was a mistake. `getTrailingPadding` still uses `>=`.

I manually verified this using the code in #815 and added some unit tests to catch this bug and other similar issues.

Adam Comella
Microsoft Corp.
Pull Request resolved: https://github.com/facebook/yoga/pull/816

Reviewed By: priteshrnandgaonkar

Differential Revision: D10282617

Pulled By: shergin

fbshipit-source-id: 2ab2874ae39d9454308a020a960ace85573fe777
2018-10-12 15:08:45 -07:00
David Vacca 88ccb33b7d rename test of AttributedStringTest
Summary: trivial change to rename tests of AttributedStringTest class

Reviewed By: shergin

Differential Revision: D10349177

fbshipit-source-id: 8bcc29e03037636e3038ec046ca628cf29c34b6d
2018-10-11 23:03:51 -07:00
David Vacca ee4e2ae489 Fix AttributeStrings tests
Summary: This diff fixes AttributeStrings tests

Reviewed By: shergin

Differential Revision: D10349107

fbshipit-source-id: c03407bf057535ebbb75ccf02d03f76fbc3cd360
2018-10-11 23:03:51 -07:00
Spencer Ahrens d8a5da5153 Fix some test stuff
Summary: missing header and platform. attributedstring builds now, but still fails because of T34990592

Reviewed By: mdvacca

Differential Revision: D10349210

fbshipit-source-id: dcd163df9ac9a4fcb36399cb9f93dbf1b33c062d
2018-10-11 19:37:48 -07:00
Adam Comella af8c69ecf7 Fix rounding of negative numbers (#825)
Summary:
`YGRoundValueToPixelGrid` currently rounds negative numbers incorrectly. For example:

```
YGRoundValueToPixelGrid(-2.2, 1.0, /* ceil */ false, /* floor */ true) = -2.0
```

However, that operation is supposed to take the floor of the number so the result should acutally be `-3.0`.

There's a detailed comment in `YGRoundValueToPixelGrid` about the fix and why it works.

A symptom that manifested because of this bug is that text nodes could get smaller and smaller on each layout pass. For details see https://github.com/facebook/yoga/issues/824.

Fixes #824

Adam Comella
Microsoft Corp.
Pull Request resolved: https://github.com/facebook/yoga/pull/825

Reviewed By: priteshrnandgaonkar

Differential Revision: D10282064

Pulled By: shergin

fbshipit-source-id: 16ca966e6cb0cfc88b1dbf4ba31e7b1dbe1f2049
2018-10-11 18:19:11 -07:00
Spencer Ahrens 83da74b556 Refactor uimanager stuff a bit
Summary: Simplies UIManager a bit and some other tweaks

Reviewed By: shergin

Differential Revision: D10211883

fbshipit-source-id: 93ab23dd2baab2fdc6d9c54e976b001a19efab7f
2018-10-10 20:01:04 -07:00
Adam Comella 780ced4d07 Fix C# unit tests (#818)
Summary:
This consists of several fixes:
  - Some of the C++ functions called by the tests were missing `WIN_EXPORT`
  - It looks like Yoga was changed to round up after `TestMeasureFuncWithFloat` was written. Here's the function call that results in the rounding: 357ca78f9f/yoga/Yoga.cpp (L4019-L4026)
  - The format of the result of the `Print` method was changed after `TestPrint` was written.
Pull Request resolved: https://github.com/facebook/yoga/pull/818

Differential Revision: D10282902

Pulled By: shergin

fbshipit-source-id: a5fd732a7dbff1a704cbafbfc95ae3e0c0a0cdd8
2018-10-09 18:16:21 -07:00
David Vacca 28d80e4717 Avoid serializing UndefinedColor when rendering texts
Summary: This diff avoids the serialization of color that are set as: "UndefinedColor". This allows the text rendering system to set the default color in the native side

Reviewed By: shergin

Differential Revision: D10275834

fbshipit-source-id: b81c7a5995bef65e04a246d99f44ff10cb20f548
2018-10-09 16:47:29 -07:00
David Vacca 397573ffed Fix onPress for TextView containing just RawText
Summary: This diff enables the onPress event for TextViews that render RawText

Reviewed By: shergin

Differential Revision: D10222183

fbshipit-source-id: 4b6a6ad548286453f7dd3a14a5e4ee453a55b923
2018-10-09 16:47:28 -07:00
David Vacca 74a00beeb7 Enabled View falttening for Android builds
Summary: This diff enables view flattening for Android when using Fabric.

Reviewed By: shergin

Differential Revision: D10254678

fbshipit-source-id: cc7acaa38a6d01e112ba0e8a92db61cdeefbffee
2018-10-09 16:47:28 -07:00
David Vacca 95afdd8bb3 Introducing "collapsable" prop as part of ViewProps
Summary: This diff introduces the collapsable props in the viewProps. This prop is used in product code to prevent specific Views to be removed from the view hierarchy

Reviewed By: shergin

Differential Revision: D10254679

fbshipit-source-id: 637665b8998a86e29e839eb6d405a0fac354c8d3
2018-10-09 16:47:27 -07:00
Valentin Shergin 04fbdd347b Fabric: Proper parsing of Accessibility Props
Summary: Previsouly, we basically didn't support Accessibility at all.

Reviewed By: mdvacca

Differential Revision: D10250635

fbshipit-source-id: d33eed8f56374f57310654653f41c312cb5942e6
2018-10-09 16:31:48 -07:00
Valentin Shergin 8f51243957 Fabric: Enabling clang-format for the rest of Fabric
Summary: This is the second and the final part of adopting clang-format.

Reviewed By: mdvacca

Differential Revision: D10229624

fbshipit-source-id: d97670b716800ea2488b84bd0aacaf54d8bd2e31
2018-10-09 16:31:48 -07:00
Valentin Shergin 01af828d16 Fabric: Fixed possible race condition in `ShadowTree::complete`
Summary: Quite obviously, having a `complete` method which accepts only `newRootShadowNode` was a baaad idea. When we `complete` or `commit` we always have to have two nodes (before and after). And only after layout and right before swapping (and acquiring the mutex) we have to verify that *current* root node is still the same as it was when we initialized the transaction (if not, we have to abort).

Reviewed By: mdvacca

Differential Revision: D10201902

fbshipit-source-id: 15adc78c5d31d6fd39fd7fc6e53203a5539717a8
2018-10-09 16:31:48 -07:00
Valentin Shergin 4ce57cb7c7 Fabric: Passing size constraints as part of starting Surface
Summary:
Size constraints are essential part of the running Surface, decoupling them from starting process means that we will have to perform additional commit later.
This and previous couple diffs fix a problem with initial zero size of the surface and following visible "jumpy" relayout.

Reviewed By: sahrens

Differential Revision: D10174280

fbshipit-source-id: 0ec48692cb814fd46cc3a1d044c5eb8ab9ecb031
2018-10-09 16:31:48 -07:00
Valentin Shergin b8947c459f Fabric: `ShadowTree::synchronize` and reliable `constraintLayout`
Summary:
New `ShadowTree::synchronize` method allows to perform operations on ShadowTree without a risk of an unsuccessful commit. To make it happen, the `commitMutex_` is now recursive and `synchronize` acquires it before calling the callback.
Using that we finally can implement reliable `constraintLayout`.

Reviewed By: mdvacca

Differential Revision: D10174281

fbshipit-source-id: 9864ebb5343d40e2da205272a834710f0ab730db
2018-10-09 16:31:48 -07:00
Valentin Shergin b9850844a5 Fabric: `constraintLayout` is now return boolean
Summary:
Setting the right expectations: setting layout constraints might fail. Nothing really changed.
Implementing a reliable `constraintLayout` which locks instead of returning immediately requires some additional work and new/additional API.

Reviewed By: mdvacca

Differential Revision: D10159457

fbshipit-source-id: bb23c7de105629ef086ae0b04667ff32c6ffb81d
2018-10-09 16:31:48 -07:00
Valentin Shergin d38dffc8a0 Fabric: Proper defaults for ScrollView's alwaysBounce*
Summary: That's actually proper defaults. That fixes problems with horizontally bouncing ScrollView.

Reviewed By: mdvacca

Differential Revision: D10159458

fbshipit-source-id: b2b6df911b0a23f5e13539caeb48e51cdbc56528
2018-10-09 16:31:47 -07:00
Valentin Shergin 4876928f9e Fabric: Improved thread-safety in ShadowTree
Summary: With new `ShadowTree::getRootShadowNode()` method all access to rootShadowNode_ is protected by commit mutex.

Reviewed By: mdvacca

Differential Revision: D10159456

fbshipit-source-id: 0bc8676ca2564a8ef95d60e912356e99d9f172c1
2018-10-09 16:31:47 -07:00
Valentin Shergin 0f683bb5c1 Fabric: Calling `UIManager`'s `uninstall` function asynchonously
Summary:
Calling `uninstall` synchnously was a bad idea. Unfortunatelly, even if it illuminate possible race condition during uninstallation, sometimes it deadlock.
It's not clear for now how to solve both problems without introducting another layer of indirection between UIManager and JSI.

Reviewed By: mdvacca

Differential Revision: D10081500

fbshipit-source-id: 90d8120603929a8219a3e606d8b3527e297b13ce
2018-10-08 14:46:48 -07:00
Valentin Shergin 5f4aa6ae42 Fabric: Proper failCallback handling in EventBeatBasedExecutor
Summary: That's why we need the previous three diffs. Synchonous executor deadlocks if the beat is missing.

Reviewed By: sahrens

Differential Revision: D10081501

fbshipit-source-id: 9986d0a1844e642048b6f37a1fcb5f623a267663
2018-10-08 14:46:48 -07:00
Valentin Shergin fa3525dc83 Fabric: Introducting EventBeat::setFailCallback
Summary: In some cases we have to have a way to notify a EventBeat consumer that the beat cannot be (and will not be) delivered, so we introducing special API for that.

Reviewed By: mdvacca

Differential Revision: D10081503

fbshipit-source-id: 4c5a392d32572f426e3744bdba797efcd29b8cb4
2018-10-08 14:46:48 -07:00
Valentin Shergin 3ad5c9e016 Fabric: Enabling clang-format for half of Fabric modules
Summary:
All code styles are terribly ugly. We have the only choise - choise something and embrace it.
This particular code style was borrowed from a neibour Fabric-friendly project because it follows established Facebook guides and respects client-side traditions.

Reviewed By: mdvacca

Differential Revision: D10218598

fbshipit-source-id: 8c4cf6713c07768566dadef479191661c79988f0
2018-10-05 11:03:23 -07:00
David Vacca 98a6f19d7c Move 'top' prefix from UIManager to EventEmitter
Summary: This diff unifies the 'handling' of the top prefix in the EventEmitter.cpp class

Reviewed By: shergin

Differential Revision: D10149497

fbshipit-source-id: d0ddbbbeefe3790b414b101da47582161354c971
2018-10-02 15:09:05 -07:00
David Vacca cf66923831 Refactor UIManager -> FabricUIManager
Summary: This diff renames com.facebook.fbreact.fabric.UIManager to FabricUIManager, this is done in order to avoid confusion with com.facebook.react.bridge.UIManager

Reviewed By: shergin

Differential Revision: D10128635

fbshipit-source-id: 0cb874ec1ba698077d750214f1d25004065c2f59
2018-10-02 15:09:05 -07:00
David Vacca 637d74f2a6 Expose EventEmitter.dispatchEvent as public
Summary: This diff exposes the method EventEmitter.dispatchEvent as public in order to be able to access it from the android side.

Reviewed By: shergin

Differential Revision: D10127509

fbshipit-source-id: d6ddf59c654a91fdeed5fba867ca31d6de96d607
2018-10-01 18:03:35 -07:00
Valentin Shergin c70abb393f Fabric: Enabling view hierarchy flattening (for <View> component only for now)
Summary: This change implements `onLayoutOnly` for regular bare <View> component (*not* for its descendants!) After this view flattening is actually starting working for all platforms.

Reviewed By: mdvacca

Differential Revision: D9511001

fbshipit-source-id: 3562dd1b7570a064150f100cc2e1bc4220b81290
2018-09-30 22:23:02 -07:00
Valentin Shergin 5ce2c0144b Fabric: Fixed a bug in LayoutMetrics::operator==
Summary: Trivial. We missed `pointScaleFactor`.

Reviewed By: mdvacca

Differential Revision: D10112051

fbshipit-source-id: 980b8c310fbb3701008765509dce5b6e61852c0e
2018-09-28 14:47:38 -07:00
Valentin Shergin 9edf63534e Fabric: Using YGNodeLayoutGet* family functions to access Yoga layout
Summary:
... instead of using direction access to `ygNode.getLayout()` object.
Suddenly, YGLayout object that YGNode exposes contains unresolved/directional-unaware styles. To get resolved directional-aware styles we have to use functions from Yoga.h.
I am not happy with this solution, I will try to implement something like `ygNode.getResolvedLayout()` and use that instead.

This change fixes strange missing horizontal padding around some views.

Reviewed By: mdvacca

Differential Revision: D10112049

fbshipit-source-id: 4b6ef39d8dd34e78a4592962e8af4eeaa5028768
2018-09-28 14:47:38 -07:00
Valentin Shergin e3b61f53bd Fabric: Debug Pretty-printing is now debug only feature
Summary: That should save us some app size kilobytes.

Reviewed By: mdvacca

Differential Revision: D10081499

fbshipit-source-id: 2b950768c609b412f9be332c22b6b1e96657e5ea
2018-09-28 10:32:06 -07:00
Valentin Shergin 84fbad6215 Fabric: Safer UIManager deallocation and uninstallation
Summary: We have to uninstall UIManager synchronously to avoid a race condition when JS is capable to call already deallocated UIManager.

Reviewed By: mdvacca

Differential Revision: D10033406

fbshipit-source-id: 194d1ae2dd5ab09b036b1c165de289ada8e66014
2018-09-26 10:18:39 -07:00
Valentin Shergin c69313fc52 Fabric: Start/stop Surface calls were moved down to C++ layer
Summary:
There is no need to make JS calls to start or stop React Native apps; Scheduler does it automatically. Yay!

With this change (because we have to change Scheduler API) we are starting slow process migrating away from using term `reactRootTag` when we refer to running a ReactNative app (aka Surface). We will use `surfaceId` instead. We plan to slowly and gracefully retire `reactTag` term entity replacing it with several appropriate entities specific for particular usage, e.g. `viewId` (some id which makes sense for mounting), `surfaceId`, `nodeId` (unique id representing nodes which were cloned from the original one), or `eventTarget`.

Reviewed By: mdvacca

Differential Revision: D9999336

fbshipit-source-id: bbc7303c195b070b8c235c9ca35546d1dc693e98
2018-09-26 10:18:39 -07:00
Valentin Shergin b91f6d1e93 Fabric: Using EventBeatBasedExecutor to ensure threading during installing UIManager
Summary: This is the last step before making JSIUIManagerInstaller a direct dependency of UIManager (and making UIManager installation process completely seamless/platform-agnostic).

Reviewed By: mdvacca

Differential Revision: D9995781

fbshipit-source-id: 6f8c7177495b01ebaac1dbe330f49dce2e2a552c
2018-09-26 10:18:38 -07:00
Valentin Shergin 78746afd92 Fabric: Introducing EventBeatBasedExecutor
Summary:
EventBeatBasedExecutor is an executor derived from EventBeat and using EventBeat to ensure proper threading.
Why do we need yet another executor? Because otherwise, we have to make it platform specific-dependency that each platform-specific implementation has to implement and provide. We already have all that we need in already provided EventBeat, so we can just convert that into simple executor in a platform-agnostic way.

Reviewed By: mdvacca

Differential Revision: D9995783

fbshipit-source-id: f8aa72a9744e50ebecbea9ad0e2546f41f5358f2
2018-09-26 10:18:38 -07:00
Valentin Shergin 4a8613f40f Fabric: UIManager's API for installing and uninstalling itself
Summary: UIManager now can install and uninstall itself calling a functions that are provided as constructor arguments.

Reviewed By: mdvacca

Differential Revision: D9931329

fbshipit-source-id: b8d2d9925b0e2db0fed44bdf2e185d198fabd5ee
2018-09-26 10:18:38 -07:00