Commit Graph

15 Commits

Author SHA1 Message Date
Nick Gerleman 5d55c8eeb5 Revert D50998164: Allow lazy resolution of edge dimension values
Differential Revision:
D50998164

Original commit changeset: 248396f9587e

Original Phabricator Diff: D50998164

fbshipit-source-id: 4f592158324d758bb9e3731ced36b8e3587c459c
2023-11-15 18:34:47 -08:00
Nick Gerleman 6c4cb02e27 Allow lazy resolution of edge dimension values (#41347)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41347

X-link: https://github.com/facebook/yoga/pull/1453

This follows the previous patterns used for `Gutters` and `Dimension`, where we hide CompactValue array implementation from `yoga::Style` callers.

This allows a single read of a style to only need access to the resolved values of a single edge, vs all edges. This is cheap now because the interface is the representation, but gets expensive if `StyleValuePool` is the actual implementation.

This prevents us from needing to resolve nine dimensions, in order to read a single value like `marginLeft`. Doing this, in the new style, also lets us remove `IdxRef` from the API.

We unroll the structure dependent parts in the props parsing code, for something more verbose, but also a bit clearer.

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D50998164

fbshipit-source-id: 248396f9587e29d62cde05ae7512d8194f60c809
2023-11-14 09:12:35 -08:00
Nick Gerleman ebcd1ab1ab C++ style enums 15/N: Display (#39541)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39541

X-link: https://github.com/facebook/yoga/pull/1397

Moves internal usages of YGDisplay to Display

bypass-github-export-checks

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D49361952

fbshipit-source-id: a961efaa35a3fed01659d23783bf90e0b47656f0
2023-09-19 16:30:02 -07:00
Nick Gerleman aa8caf0641 C++ Style enums 12/N: PositionType (#39538)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39538

X-link: https://github.com/facebook/yoga/pull/1399

Moves internal usages of YGPositionType to PositionType

bypass-github-export-checks

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D49361677

fbshipit-source-id: 526222d6cf9f3dc26eddfbfb8a04de4ba28e14a9
2023-09-19 16:30:02 -07:00
Samuel Susla 5bafef6622 Delete CoreFeatures::enableMapBuffer (#39407)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39407

changelog: [internal]

CoreFeatures::enableMapBuffer is not used and always set to false, let's delete it.

Reviewed By: christophpurrer

Differential Revision: D49144919

fbshipit-source-id: 7d6a2a96ade13f7cedc2d12f7672c9df9d247e0d
2023-09-14 07:16:26 -07:00
Nick Gerleman d2e91599c8 PointerAlignment: Left
Summary:
This changes Clang format config to enforce left pointer alignment instead of right, in accordance with https://www.internalfb.com/intern/wiki/Cpp/CppStyle/

Changelog: [Internal]

bypass-github-export-checks

Reviewed By: sammy-SC

Differential Revision: D48952040

fbshipit-source-id: 108329b2f11d2041a31dee3334c7801d69a3f1ad
2023-09-04 10:55:18 -07:00
Nick Gerleman a966291611 Consistent QualifierAlignment (for real this time I swear) (#39217)
Summary:
(reland of D48761722)

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

React Native uses an inconsistent mix of "west const" and "east const". E.g. `const auto &` in 74 files, but `auto const &` in 60. Sometimes they are mixed from one line to the next:  {F1079102436}

Clang format 14 adds a QualifierAlignment option, but fbsource is still on 12, so we cannot use it in our config until the [world is updated]()https://fb.workplace.com/groups/toolchain.fndn/posts/24006558685624673/?comment_id=24009214565359085&reply_comment_id=24009455088668366. This diff just runs a local version of Clang format locally first to fix QualifierAlignment, then reformats with the fbsource version, to fix any other output differences unrelated to that. This will not continually enforce a style, but will make the world more consistent, and hopefully encourage a consistent style until we can set it.

West const seems more popular in `//xplat` so I just picked left alignment somewhat arbitrarily, but we could also maybe take a poll on this.

Changelog: [Internal]

bypass-github-export-checks

Reviewed By: shwanton

Differential Revision: D48852450

fbshipit-source-id: 1789aa0db43948169f482188cb8b5e8f0f0246b8
2023-08-30 19:56:13 -07:00
Nick Gerleman 294a50db93 C++ Cleanup 1/N: Reorganize YGStyle (#39221)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39221

X-link: https://github.com/facebook/yoga/pull/1349

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

## This diff

This diff adds a `style` directory for code related to storing and manipulating styles. `YGStyle`, which is not a public API, is renamed to `yoga::Style` and moved into this folder, alongside `CompactValue`. We will eventually add `ValuePool` alongside this for the next generation style representation.

## This stack

The organization of the C++ internals of Yoga are in need of attention.
1. Some of the C++ internals are namespaced, but others not.
2. Some of the namespaces include `detail`, but are meant to be used outside of the translation unit (FB Clang Tidy rules warn on any usage of these)
2. Most of the files are in a flat hierarchy, except for event tracing in its own folder
3. Some files and functions begin with YG, others don’t
4. Some functions are uppercase, others are not
5. Almost all of the interesting logic is in Yoga.cpp, and the file is too large to reason about
6. There are multiple grab bag files where folks put random functions they need in (Utils, BitUtils, Yoga-Internal.h)
7. There is no clear indication from file structure or type naming what is private vs not
8. Handles like `YGNodeRef` and `YGConfigRef` can be used to access internals just by importing headers

This stack does some much needed spring cleaning:
1. All non-public headers and C++ implementation details are in separate folders from the root level `yoga`. This will give us room to split up logic and add more files without too large a flat hierarchy
3. All private C++ internals are under the `facebook::yoga` namespace. Details namespaces are only ever used within the same header, as they are intended
4. Utils files are split
5. Most C++ internals drop the YG prefix
6. Most C++ internal function names are all lower camel case
7. We start to split up Yoga.cpp
8. Every header beginning with YG or at the top-level directory is public and C only, with the exception of Yoga-Internal.h which has non-public functions for bindings
9. It is not possible to use private APIs without static casting handles to internal classes

This will give us more leeway to continue splitting monolithic files, and consistent guidelines for style in new files as well.

These changes should not be breaking to any project using only public Yoga headers. This includes every usage of Yoga in fbsource except for RN Fabric which is currently tied to internals. This refactor should make that boundary clearer.

Changelog: [Internal]

Reviewed By: shwanton

Differential Revision: D48847261

fbshipit-source-id: 0fc8c6991e19079f3f0d55d368574757e453fe93
2023-08-30 16:27:32 -07:00
Zhiyao Zhou 796cdea6fa Revert D48710084: C++ Cleanup 1/N: Reorganize YGStyle
Differential Revision:
D48710084

Original commit changeset: 20961aee30d5

Original Phabricator Diff: D48710084

fbshipit-source-id: 79cda4f13979b8d0cdf87dabbfc13cbd17abe488
2023-08-29 23:27:25 -07:00
Nick Gerleman 02b05c306d C++ Cleanup 1/N: Reorganize YGStyle (#39171)
Summary:
X-link: https://github.com/facebook/yoga/pull/1349

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

## This diff

This diff adds a `style` directory for code related to storing and manipulating styles. `YGStyle`, which is not a public API, is renamed to `yoga::Style` and moved into this folder, alongside `CompactValue`. We will eventually add `ValuePool` alongside this for the next generation style representation.

## This stack

The organization of the C++ internals of Yoga are in need of attention.
1. Some of the C++ internals are namespaced, but others not.
2. Some of the namespaces include `detail`, but are meant to be used outside of the translation unit (FB Clang Tidy rules warn on any usage of these)
2. Most of the files are in a flat hierarchy, except for event tracing in its own folder
3. Some files and functions begin with YG, others don’t
4. Some functions are uppercase, others are not
5. Almost all of the interesting logic is in Yoga.cpp, and the file is too large to reason about
6. There are multiple grab bag files where folks put random functions they need in (Utils, BitUtils, Yoga-Internal.h)
7. There is no clear indication from file structure or type naming what is private vs not
8. Handles like `YGNodeRef` and `YGConfigRef` can be used to access internals just by importing headers

This stack does some much needed spring cleaning:
1. All non-public headers and C++ implementation details are in separate folders from the root level `yoga`. This will give us room to split up logic and add more files without too large a flat hierarchy
3. All private C++ internals are under the `facebook::yoga` namespace. Details namespaces are only ever used within the same header, as they are intended
4. Utils files are split
5. Most C++ internals drop the YG prefix
6. Most C++ internal function names are all lower camel case
7. We start to split up Yoga.cpp
8. Every header beginning with YG or at the top-level directory is public and C only, with the exception of Yoga-Internal.h which has non-public functions for bindings
9. It is not possible to use private APIs without static casting handles to internal classes

This will give us more leeway to continue splitting monolithic files, and consistent guidelines for style in new files as well.

These changes should not be breaking to any project using only public Yoga headers. This includes every usage of Yoga in fbsource except for RN Fabric which is currently tied to internals. This refactor should make that boundary clearer.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D48710084

fbshipit-source-id: 20961aee30d54a6b0d8c1cc2976df09b9b6d486a
2023-08-29 21:32:56 -07:00
Eric Rozell b0a8d45e28 More consistent platform for out-of-tree platform extensions (#38703)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38703

This change consolidates the pattern for setting up out-of-tree platform options for core classes like ViewProps and ViewEventEmitter. A similar pattern was used for Touch.h. As we move towards documenting how to build an out-of-tree platform, it would be nice to specify a set of HostPlatformX classes that need to be implemented and made resolvable from specific header paths.

At this point, there is:
- HostPlatformViewProps
- HostPlatformViewEventEmitter
- HostPlatformViewTraitsInitializer
- HostPlatformTouch
- HostPlatformColor

The other benefit of this pattern is to DRY helper aliases like SharedViewEventEmitter and SharedViewProps.

## Changelog:
[General] [Added] - Use more consistent pattern for out-of-tree platform Fabric C++ class extensions

Reviewed By: christophpurrer

Differential Revision: D47917598

fbshipit-source-id: 58ee9677eefd34eb0bc2d321103314642c457cd8
2023-07-31 11:38:36 -07:00
Eric Rozell 646c75995e Create option for out-of-tree platforms to customize View traits (#38580)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38580

We already have a differential between Android and iOS View props that force view flattening (or unflattening) behaviors. Other out-of-tree platforms may have a need to customize view flattening behaviors.

This change adds a ViewTraitsInitializer header that out of tree platforms can inject to include platform-specific ViewProps fields when considering view flattening behaviors.

## Changelog:
[General] [Added] - Support customization of View traits for flattening in out of tree platform Fabric implementations

Reviewed By: christophpurrer

Differential Revision: D47721377

fbshipit-source-id: b7d6dda2f20e153a0277861d04709090756c96ce
2023-07-31 11:38:36 -07:00
Samuel Susla bb879d3ecb Move CoreFeatures to React-utils (#37599)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37599

changelog: [internal]

Moving CoreFeatures class to `utils` module from `core` module. There are other modules besides `core` that need to use CoreFeatures and moving it to `utils` will prevent circular dependency.

Reviewed By: javache, rshest

Differential Revision: D46218604

fbshipit-source-id: 6030f00ad37f55f0c95f4eafa61fb22808b880a4
2023-06-17 07:49:56 -07:00
Pieter De Baets ebf10798a5 Remove unused View foregroundColor (#36882)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36882

This property was never used as TextAttributes has its own foreground color attribute.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D44884978

fbshipit-source-id: daac06c9dfcbceedc084b6adc2cb114758533036
2023-04-14 05:00:17 -07:00
Ruslan Lesiutin 714b502b0c | RN Monorepo | Migrate to package (#36434)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36434

Changelog: [Internal]

This is a squashed stack of 18 commits, starting from D43202126

allow-large-files

Reviewed By: cortinico

Differential Revision: D43977381

fbshipit-source-id: 0da552ddb85f2f61a0be0ef071915b35f3f8555c
2023-03-17 05:03:25 -07:00