Skip to content

Commit

Permalink
Fixes regression of prop parsing for elevation (facebook#38959)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#38959

When refactoring ViewProps in D47492635, `elevation` prop parsing was dropped. This restores it.

## Changelog:
[General] [Fixed] - Fabric regression for elevation prop in Android

Reviewed By: sammy-SC, mdvacca

Differential Revision: D48269510

fbshipit-source-id: 240057665bd006b249ac7f95d231ec8d9fe42d5f
  • Loading branch information
rozele authored and facebook-github-bot committed Aug 11, 2023
1 parent d655d44 commit cf936d1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ class BaseViewProps : public YogaStylableProps, public AccessibilityProps {

LayoutConformance experimental_layoutConformance{};

Float elevation{}; /* Android-only */

#pragma mark - Convenience Methods

BorderMetrics resolveBorderMetrics(LayoutMetrics const &layoutMetrics) const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ HostPlatformViewProps::HostPlatformViewProps(
RawProps const &rawProps,
bool shouldSetRawProps)
: BaseViewProps(context, sourceProps, rawProps, shouldSetRawProps),
elevation(
CoreFeatures::enablePropIteratorSetter ? sourceProps.elevation
: convertRawProp(
context,
rawProps,
"elevation",
sourceProps.elevation,
{})),
nativeBackground(
CoreFeatures::enablePropIteratorSetter
? sourceProps.nativeBackground
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class HostPlatformViewProps : public BaseViewProps {

#pragma mark - Props

Float elevation{};

std::optional<NativeDrawable> nativeBackground{};
std::optional<NativeDrawable> nativeForeground{};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,11 @@ static inline ShadowNode::Unshared messWithLayoutableOnlyFlag(
: Transform::Perspective(42);
}

#ifdef ANDROID
if (entropy.random<bool>(0.1)) {
viewProps.elevation = entropy.random<bool>() ? 1 : 0;
}
#endif

return shadowNode.clone({newProps});
}
Expand Down Expand Up @@ -195,7 +197,9 @@ static inline ShadowNode::Unshared messWithNodeFlattenednessFlags(
viewProps.zIndex = {};
viewProps.pointerEvents = PointerEventsMode::Auto;
viewProps.transform = Transform::Identity();
#ifdef ANDROID
viewProps.elevation = 0;
#endif
} else {
viewProps.nativeId = "42";
viewProps.backgroundColor = whiteColor();
Expand All @@ -204,7 +208,9 @@ static inline ShadowNode::Unshared messWithNodeFlattenednessFlags(
viewProps.zIndex = {entropy.random<int>()};
viewProps.pointerEvents = PointerEventsMode::None;
viewProps.transform = Transform::Perspective(entropy.random<int>());
#ifdef ANDROID
viewProps.elevation = entropy.random<int>();
#endif
}

return shadowNode.clone({newProps});
Expand Down

0 comments on commit cf936d1

Please sign in to comment.