forked from microsoft/react-native-macos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create option for out-of-tree platforms to customize View traits (fac…
…ebook#38580) Summary: Pull Request resolved: facebook#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: 1eeab5f847fb1813172d0ff0fad4182fcdd2cf21
- Loading branch information
1 parent
2e9cc3c
commit d694e71
Showing
3 changed files
with
63 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...r/components/view/platform/android/react/renderer/components/view/ViewTraitsInitializer.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <react/renderer/components/view/ViewProps.h> | ||
#include <react/renderer/core/ShadowNodeTraits.h> | ||
|
||
namespace facebook::react::ViewTraitsInitializer { | ||
|
||
static bool formsStackingContext(ViewProps const &viewProps) { | ||
return viewProps.elevation != 0; | ||
} | ||
|
||
static bool formsView(ViewProps const &viewProps) { | ||
return viewProps.nativeBackground.has_value() || | ||
viewProps.nativeForeground.has_value() || viewProps.focusable || | ||
viewProps.hasTVPreferredFocus || | ||
viewProps.needsOffscreenAlphaCompositing || | ||
viewProps.renderToHardwareTextureAndroid; | ||
} | ||
|
||
static ShadowNodeTraits::Trait extraTraits() { | ||
return ShadowNodeTraits::Trait::AndroidMapBufferPropsSupported; | ||
} | ||
|
||
} // namespace facebook::react::ViewTraitsInitializer |
27 changes: 27 additions & 0 deletions
27
...er/components/view/platform/common/react/renderer/components/view/ViewTraitsInitializer.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <react/renderer/components/view/ViewProps.h> | ||
#include <react/renderer/core/ShadowNodeTraits.h> | ||
|
||
namespace facebook::react::ViewTraitsInitializer { | ||
|
||
static bool formsStackingContext(ViewProps const &props) { | ||
return false; | ||
} | ||
|
||
static bool formsView(ViewProps const &props) { | ||
return false; | ||
} | ||
|
||
static ShadowNodeTraits::Trait extraTraits() { | ||
return ShadowNodeTraits::Trait::None; | ||
} | ||
|
||
} // namespace facebook::react::ViewTraitsInitializer |