Skip to content

Commit

Permalink
Fabric: Implementation of ViewProps::zIndex feature in C++ core
Browse files Browse the repository at this point in the history
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
  • Loading branch information
shergin authored and facebook-github-bot committed Mar 16, 2020
1 parent ca35bfe commit 14a174c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions ReactCommon/fabric/components/view/ViewShadowNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,36 @@
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;
}

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 ||
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion ReactCommon/fabric/components/view/ViewShadowNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ViewShadowNode final : public ConcreteViewShadowNode<
ShadowNodeFragment const &fragment);

private:
void updateTraits();
void initialize() noexcept;
};

} // namespace react
Expand Down

0 comments on commit 14a174c

Please sign in to comment.