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

1122 Коммитов

Автор SHA1 Сообщение Дата
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
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
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
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
David Aurelio c37826a933 Move out `YGValue`
Summary:
@public

Creates a single header file for `YGValue`. This is in preparation of a more compact representation of `YGValue` within `YGStyle`.

Also fixes the incorrect definition of NAN.

Reviewed By: SidharthGuglani

Differential Revision: D13172444

fbshipit-source-id: 4250dbcf8fe15ec3ecdee3913360a73bab633ce3
2018-12-06 07:38:43 -08:00
David Aurelio 57a38263bf Roll back `-ffast-math`
Summary:
@public

`-ffast-math` does not have measurable performance benefits.

By using `NaN` for *undefined* values again, we can squeeze `YGFloatOptional` into 32 bits.
This will also enable us to store `YGValue` (or a variant of it) in 32 bits.

Reviewed By: SidharthGuglani

Differential Revision: D13119110

fbshipit-source-id: 4e6964240bf74ebc22d8783107b89d536a1a0842
2018-12-06 07:38:43 -08:00
Marc Horowitz 3f0f25f73c Back out "Check for thread consistency in JSCRuntime"
Summary:
This check is too aggressive.  We will consider putting it back once we are
more certain nothing will trigger it.

Differential Revision: D13350907

fbshipit-source-id: 6033bdbfe7adb2a18bdf889c090cf271497605e5
2018-12-05 16:59:31 -08:00
Kevin Gozali 01d7aad548 Guard calls to debug features in fabric test
Summary:
In some setup, buck cxx test for android runs with `NDEBUG` set, hence we can't call debug symbols in the test cases. So guard those callsites with `#ifndef NDEBUG`.

Also, some dependencies for this test target depend on Android specific symbols, so we have to mark it as instrumentation test for now (FB-specific).

Reviewed By: sahrens

Differential Revision: D13337637

fbshipit-source-id: 02ff152df9937f2b0b8596f53789cdee8ee8a539
2018-12-05 15:03:27 -08:00
Kevin Gozali 4f9a3bc8f6 xplat: pass through config object to fabric UIManager layer
Summary: For configuration purpose, pass down config object from the hosting app and use it in UITemplateProcessor.

Reviewed By: sahrens

Differential Revision: D13290322

fbshipit-source-id: 8bb6d7f5a3f977b873e548e15603259876b46dc8
2018-12-05 15:03:27 -08:00
Kevin Gozali 3b6f229eb9 xplat: added ReactNativeConfig to access runtime specific config values
Summary: Each app may provide different impl for its runtime specific behaviors, then Fabric and other new infra can share the same config instance to configure stuffs.

Reviewed By: sahrens

Differential Revision: D13290319

fbshipit-source-id: 30e3eeedc6ff6ef250ed233b27e38cb7c1062b55
2018-12-05 15:03:27 -08:00
Marc Horowitz 424d4458d7 Delete dead code
Summary: It was made dead by the previous revisions

Reviewed By: amnn

Differential Revision: D13313263

fbshipit-source-id: b8c8402b5427dc5d3efbbd2ee871aebf1e14ee0d
2018-12-04 12:01:59 -08:00
Marc Horowitz bdb084e8a8 Check for thread consistency in JSCRuntime
Summary:
In the version of JSC on iOS 11, creating a JSContext on one
thread and using it on another can trigger subtle and nearly
impossible to debug reentrancy-related crashes in the VM (see
https://bugs.webkit.org/show_bug.cgi?id=186827).  In !NDEBUG builds,
check for this case and throw an exception, so it can be detected
early.

Reviewed By: amnn

Differential Revision: D13313264

fbshipit-source-id: ee85435c20e23c8520495ce743d2f91f2eeada5c
2018-12-04 12:01:59 -08:00
Valentin Shergin 757518edba Fabric: `ShadowTreeRegistry::get` was renamed to `ShadowTreeRegistry::visit`
Summary: Trivial. The name `visit` expresss intent more clearly and fits C++17 `std::visit` pattern.

Reviewed By: mdvacca

Differential Revision: D13269744

fbshipit-source-id: 6aa6569c58aa66673e3f3a1662390a74290b8e01
2018-11-30 17:29:31 -08:00
Valentin Shergin d150cbc298 Fabric: Using RW-like shared lock in ShadowTreeRegistry
Summary:
`ShadowTree` class is already thread-safe, so we don't need to (we should not) guard concurent access to it.
We should guard concurrent write-access to the collection of them though.
Note that unordered_map is "thread-compatible" collection, so concurrent reading access is okay.

Reviewed By: mdvacca

Differential Revision: D13269745

fbshipit-source-id: 4779626018da0e42b81a835e538f6c1d1a8e25f7
2018-11-30 17:29:31 -08:00
David Vacca 3c50d04cf2 Cleanup measure function
Summary: Trivial diff that cleans up measure function in C++ and Android

Reviewed By: shergin

Differential Revision: D13200340

fbshipit-source-id: 6c0888439640241cdedf514898a1ba3dac231d6a
2018-11-30 17:19:11 -08:00
David Aurelio ea734dcfbf Adjust yearless format for MIT license
Summary:
@public

Adjust license headers throughout the project

Reviewed By: SidharthGuglani

Differential Revision: D13255691

fbshipit-source-id: 98be2aa372a94e7a54a65e3d64e5c6a436b18083
2018-11-29 11:37:51 -08:00
empyrical d6d31a4b66 JSBigString: Explicitly include unistd.h (#22330)
Summary:
`JSBigString` is using functions from `unistd.h`, like `getpagesize`, `dup`, `open`, etc. but was not directly including it.

It was being included from inside the glog `logging.h` header, which in turn was getting included by the Folly headers `JSBigString` was using.

This was discovered while building CxxReact with a custom shimmed Glog.
Pull Request resolved: https://github.com/facebook/react-native/pull/22330

Differential Revision: D13115346

Pulled By: shergin

fbshipit-source-id: 9fe4e3b28f74c0ca351ac6308484e375eace4db4
2018-11-28 16:42:42 -08:00
Alexandre Kirszenberg e81adb99f3 DeltaClient: split DeltaBundle's modules into added and modified
Summary:
The reasoning behind this change is that right now, having both added and modified modules inside of a single `modules` field doesn't allow for basic operations like combining two deltas.

For instance, say I have three different bundle revisions: A, B and C.

Module 42 was added in B, and then removed in C.

A->B = `{modules: [42, "..."], deleted: []}`
B->C = `{modules: [], deleted: [42]}`
A->C = `{modules: [], deleted: []}`

However, were we to compute A->C as the combination of A->B and B->C, it would result in `{modules: [], deleted: [42]}` because we have no way of knowing that module 42 was only just added in B.

This means that the `deleted` field of delta X->Y might eventually contain module ids that were never present in revision X, because they were added and then removed between revisions X and Y.

The last time I changed the delta format, we had a few bug reports pop out from people who had desync issues between their version of React Native and their version of Metro. As such, I've tried to make this change backwards compatible in at least one direction (new RN, old Metro). However, this will still break if someone is using a newer version of Metro and an older version of RN. I created T37123645 to follow up on this.

Reviewed By: rafeca, fromcelticpark

Differential Revision: D13156514

fbshipit-source-id: 4a4ee3b6cc0cdff5dca7368a46d7bf663769e281
2018-11-28 02:50:56 -08:00
Valentin Shergin c30c803b89 Fabric: Migrating TouchEventEmitter to JSI-based payload
Summary: Pretty straight-forward migration to using `JSI` instead of `folly::dynamic` in `TouchEventEmitter`.

Reviewed By: sahrens

Differential Revision: D13123042

fbshipit-source-id: 594b89b6e3986d6a04846194701e3a727b152cec
2018-11-27 21:00:56 -08:00
Valentin Shergin 847e6fdd99 Fabric: Migrating ScrollViewEventEmitter to JSI-based payload
Summary: Pretty straight-forward migration to using `JSI` instead of `folly::dynamic` in `ScrollViewEventEmitter`.

Reviewed By: sahrens

Differential Revision: D13123049

fbshipit-source-id: 2839976d0119c48fa2538dbaa53afbc24982c598
2018-11-27 21:00:56 -08:00
Valentin Shergin 610dac4461 Fabric: Migrating ViewEventEmitter to JSI-based payload
Summary: Pretty straight-forward migration to using `JSI` instead of `folly::dynamic` in ViewEventEmitter.

Reviewed By: sahrens

Differential Revision: D13123048

fbshipit-source-id: 3c323912d3e65b684f99df6cda99c785876164af
2018-11-27 21:00:56 -08:00
Valentin Shergin eeaf0096b1 Fabric: Migrating SwitchEventEmitter to JSI-based payload
Summary: Pretty straight-forward migration to using `JSI` instead of `folly::dynamic` in SwitchEventEmitter.

Reviewed By: sahrens

Differential Revision: D13123046

fbshipit-source-id: f2e4905a96191540ceec633bae1871c93be724db
2018-11-27 21:00:56 -08:00
Valentin Shergin dea8773c19 Fabric: `ValueFactory` and `EventEmitter::dispatchEvent` based on that
Summary:
Now the event delive pipeline supports `JSI::Value`-based payload. Instead of passing `folly::dynamic`, now we are passing `std::function<jsi::Value(jsi::Runtime &runtime)>` as factory that can build a `JSI::Value` with given `jsi::Runtime` and any captured data.
The old (now legacy) way of calling `EventEmitter::dispatchEvent(..., const folly::dynamic &payload, ...)` is also supported.

Reviewed By: sahrens

Differential Revision: D13123043

fbshipit-source-id: d65348bb215013042abb2fcfe5083a8c697333d0
2018-11-27 21:00:55 -08:00
Valentin Shergin f4da8769a3 Fabric: Coupling `Tag` inside `TargetEventEmitter`
Summary: Now instead of passing `reactTag` through the whole event pipeline, we store it inside `EventTargetWrapper` (and it does not leave `UIManagerBinding`). It helps with reducing the complexity of `EventEmitter` and will help us in migrating to JSI.

Reviewed By: sahrens

Differential Revision: D13123045

fbshipit-source-id: aa9ee94d5660ff3090369c1e55cf748d2e72b987
2018-11-27 21:00:55 -08:00
Valentin Shergin 106de1201b Fabric: Fixed incorrect systrace marker in UIManagerBinding::dispatchEvent
Summary: `SystraceSection` relies on RAII, so previously it measured only `if (eventTarget) {`'s body.

Reviewed By: mdvacca

Differential Revision: D13123047

fbshipit-source-id: 463fba783763f694b51325f98314d36b7da2f887
2018-11-27 21:00:55 -08:00
Valentin Shergin 7197aa026b Fabric: Using ShadowView instad of ShadowNode inside AttributedString
Summary:
That's generally better because:
 * Avoids exposing ShadowNode to mounting layer;
 * Enables hashing and comparing the AttributedString based on actual meaningful data (not on just a pointer to ShadowNode).

Reviewed By: mdvacca

Differential Revision: D13205230

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

Reviewed By: mdvacca

Differential Revision: D13205231

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

Reviewed By: mdvacca

Differential Revision: D13205229

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

Reviewed By: sahrens

Differential Revision: D13114836

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

Reviewed By: sahrens

Differential Revision: D13114788

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

Reviewed By: sahrens

Differential Revision: D13114789

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

Reviewed By: mdvacca

Differential Revision: D13036552

fbshipit-source-id: de825dfde8e64163168510aea1eda77370753b29
2018-11-27 18:03:27 -08:00
Tomas Reimers b5571cd5fd Create a recursive free with cleanup function
Reviewed By: davidaurelio

Differential Revision: D13119307

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

Reviewed By: sahrens

Differential Revision: D13196886

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

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

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

Reviewed By: sahrens

Differential Revision: D13196885

fbshipit-source-id: d386ce0a067df0a72e6619d62d56038aaf80eccb
2018-11-26 13:51:19 -08:00
Sidharth Guglani f000cf07c5 calling markDirtyAndPropogate when setting isReferenceBaseline value
Summary:
@public
Marking the node as dirty when isReferenceBaseline property is changed

Reviewed By: davidaurelio

Differential Revision: D13147742

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

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

Reviewed By: mdvacca

Differential Revision: D13176277

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

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

Reviewed By: shergin

Differential Revision: D13189110

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

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

Reviewed By: shergin

Differential Revision: D13188600

fbshipit-source-id: e8412497a80300cfbc3770b829e9633206aaf427
2018-11-25 17:21:00 -08:00