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
This commit is contained in:
Valentin Shergin
2020-03-15 20:52:11 -07:00
committed by Facebook GitHub Bot
parent ca35bfe597
commit 14a174c237
2 changed files with 9 additions and 7 deletions
@@ -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<ViewProps const &>(*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;
@@ -33,7 +33,7 @@ class ViewShadowNode final : public ConcreteViewShadowNode<
ShadowNodeFragment const &fragment);
private:
void updateTraits();
void initialize() noexcept;
};
} // namespace react