mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
14a174c237
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
80 lines
2.3 KiB
C++
80 lines
2.3 KiB
C++
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#include "ViewShadowNode.h"
|
|
#include <react/components/view/primitives.h>
|
|
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
char const ViewComponentName[] = "View";
|
|
|
|
ViewShadowNode::ViewShadowNode(
|
|
ShadowNodeFragment const &fragment,
|
|
ShadowNodeFamily::Shared const &family,
|
|
ShadowNodeTraits traits)
|
|
: ConcreteViewShadowNode(fragment, family, traits) {
|
|
initialize();
|
|
}
|
|
|
|
ViewShadowNode::ViewShadowNode(
|
|
ShadowNode const &sourceShadowNode,
|
|
ShadowNodeFragment const &fragment)
|
|
: ConcreteViewShadowNode(sourceShadowNode, fragment) {
|
|
initialize();
|
|
}
|
|
|
|
static bool isColorMeaningful(SharedColor const &color) noexcept {
|
|
if (!color) {
|
|
return false;
|
|
}
|
|
|
|
return colorComponentsFromColor(color).alpha > 0;
|
|
}
|
|
|
|
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 ||
|
|
viewProps.opacity != 1.0 || viewProps.transform != Transform{} ||
|
|
viewProps.zIndex != 0 || viewProps.getClipsContentToBounds() ||
|
|
viewProps.yogaStyle.positionType() == YGPositionTypeAbsolute;
|
|
|
|
bool formsView = isColorMeaningful(viewProps.backgroundColor) ||
|
|
isColorMeaningful(viewProps.foregroundColor) ||
|
|
isColorMeaningful(viewProps.shadowColor) ||
|
|
!(viewProps.yogaStyle.border() == YGStyle::Edges{});
|
|
|
|
formsView = formsView || formsStackingContext;
|
|
|
|
#ifdef ANDROID
|
|
// Force `formsStackingContext` trait for nodes which have `formsView`.
|
|
// TODO: T63560216 Investigate why/how `formsView` entangled with
|
|
// `formsStackingContext`.
|
|
formsStackingContext = formsStackingContext || formsView;
|
|
#endif
|
|
|
|
if (formsView) {
|
|
traits_.set(ShadowNodeTraits::Trait::FormsView);
|
|
} else {
|
|
traits_.unset(ShadowNodeTraits::Trait::FormsView);
|
|
}
|
|
|
|
if (formsStackingContext) {
|
|
traits_.set(ShadowNodeTraits::Trait::FormsStackingContext);
|
|
} else {
|
|
traits_.unset(ShadowNodeTraits::Trait::FormsStackingContext);
|
|
}
|
|
}
|
|
|
|
} // namespace react
|
|
} // namespace facebook
|