From 14a174c237f29a679a0bdfffa5ab91e552a351f7 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Sun, 15 Mar 2020 20:49:06 -0700 Subject: [PATCH] Fabric: Implementation of `ViewProps::zIndex` feature in C++ core Summary: Now, having `orderIndex` feature in the core, we can use it for implementing `zIndex` feature. All we need to do is just to assign this `zIndex` value to `orderIndex`. Then we will use this to remove some platform-specific code that implements `zIndex` on the mounting layer. Changelog: [Internal] Fabric-specific internal change. Reviewed By: sammy-SC Differential Revision: D20432155 fbshipit-source-id: b4d62b63006f45899de38e1f40b1dfbe69550ada --- .../fabric/components/view/ViewShadowNode.cpp | 14 ++++++++------ .../fabric/components/view/ViewShadowNode.h | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/ReactCommon/fabric/components/view/ViewShadowNode.cpp b/ReactCommon/fabric/components/view/ViewShadowNode.cpp index 0fa4674d00e..0796ac2af5c 100644 --- a/ReactCommon/fabric/components/view/ViewShadowNode.cpp +++ b/ReactCommon/fabric/components/view/ViewShadowNode.cpp @@ -11,24 +11,24 @@ namespace facebook { namespace react { -const char ViewComponentName[] = "View"; +char const ViewComponentName[] = "View"; ViewShadowNode::ViewShadowNode( ShadowNodeFragment const &fragment, ShadowNodeFamily::Shared const &family, ShadowNodeTraits traits) : ConcreteViewShadowNode(fragment, family, traits) { - updateTraits(); + initialize(); } ViewShadowNode::ViewShadowNode( ShadowNode const &sourceShadowNode, ShadowNodeFragment const &fragment) : ConcreteViewShadowNode(sourceShadowNode, fragment) { - updateTraits(); + initialize(); } -static bool isColorMeaningful(SharedColor const &color) { +static bool isColorMeaningful(SharedColor const &color) noexcept { if (!color) { return false; } @@ -36,9 +36,11 @@ static bool isColorMeaningful(SharedColor const &color) { return colorComponentsFromColor(color).alpha > 0; } -void ViewShadowNode::updateTraits() { +void ViewShadowNode::initialize() noexcept { auto &viewProps = static_cast(*props_); + orderIndex_ = viewProps.zIndex; + bool formsStackingContext = !viewProps.collapsable || viewProps.pointerEvents == PointerEventsMode::None || !viewProps.nativeId.empty() || viewProps.accessible || @@ -54,7 +56,7 @@ void ViewShadowNode::updateTraits() { formsView = formsView || formsStackingContext; #ifdef ANDROID - // Force `formsStackingContext` trait for nodes which have . + // Force `formsStackingContext` trait for nodes which have `formsView`. // TODO: T63560216 Investigate why/how `formsView` entangled with // `formsStackingContext`. formsStackingContext = formsStackingContext || formsView; diff --git a/ReactCommon/fabric/components/view/ViewShadowNode.h b/ReactCommon/fabric/components/view/ViewShadowNode.h index 7e850b7df99..969c6267b2c 100644 --- a/ReactCommon/fabric/components/view/ViewShadowNode.h +++ b/ReactCommon/fabric/components/view/ViewShadowNode.h @@ -33,7 +33,7 @@ class ViewShadowNode final : public ConcreteViewShadowNode< ShadowNodeFragment const &fragment); private: - void updateTraits(); + void initialize() noexcept; }; } // namespace react