mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: It's not clear why exactly but seems in some cases, for some views the hierarchical relationship between views is required (when it should not be conceptually). Turning this feature off for Android for now. Changelog: [Internal] Fabric-specific internal change. Reviewed By: JoshuaGross Differential Revision: D20292833 fbshipit-source-id: 1aab8468cedeb5c1440a95944be7eca3216e0db0
78 lines
2.2 KiB
C++
78 lines
2.2 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 {
|
|
|
|
const char ViewComponentName[] = "View";
|
|
|
|
ViewShadowNode::ViewShadowNode(
|
|
ShadowNodeFragment const &fragment,
|
|
ShadowNodeFamily::Shared const &family,
|
|
ShadowNodeTraits traits)
|
|
: ConcreteViewShadowNode(fragment, family, traits) {
|
|
updateTraits();
|
|
}
|
|
|
|
ViewShadowNode::ViewShadowNode(
|
|
ShadowNode const &sourceShadowNode,
|
|
ShadowNodeFragment const &fragment)
|
|
: ConcreteViewShadowNode(sourceShadowNode, fragment) {
|
|
updateTraits();
|
|
}
|
|
|
|
static bool isColorMeaningful(SharedColor const &color) {
|
|
if (!color) {
|
|
return false;
|
|
}
|
|
|
|
return colorComponentsFromColor(color).alpha > 0;
|
|
}
|
|
|
|
void ViewShadowNode::updateTraits() {
|
|
auto &viewProps = static_cast<ViewProps const &>(*props_);
|
|
|
|
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 .
|
|
// 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
|