mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
5d55c8eeb5
Differential Revision: D50998164 Original commit changeset: 248396f9587e Original Phabricator Diff: D50998164 fbshipit-source-id: 4f592158324d758bb9e3731ced36b8e3587c459c
79 lines
2.7 KiB
C++
79 lines
2.7 KiB
C++
/*
|
|
* Copyright (c) Meta Platforms, Inc. and 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/config/ReactNativeConfig.h>
|
|
#include <react/renderer/components/view/HostPlatformViewTraitsInitializer.h>
|
|
#include <react/renderer/components/view/primitives.h>
|
|
#include <react/utils/CoreFeatures.h>
|
|
|
|
namespace facebook::react {
|
|
|
|
const char ViewComponentName[] = "View";
|
|
|
|
ViewShadowNodeProps::ViewShadowNodeProps(
|
|
const PropsParserContext& context,
|
|
const ViewShadowNodeProps& sourceProps,
|
|
const RawProps& rawProps)
|
|
: ViewProps(context, sourceProps, rawProps){};
|
|
|
|
ViewShadowNode::ViewShadowNode(
|
|
const ShadowNodeFragment& fragment,
|
|
const ShadowNodeFamily::Shared& family,
|
|
ShadowNodeTraits traits)
|
|
: ConcreteViewShadowNode(fragment, family, traits) {
|
|
initialize();
|
|
}
|
|
|
|
ViewShadowNode::ViewShadowNode(
|
|
const ShadowNode& sourceShadowNode,
|
|
const ShadowNodeFragment& fragment)
|
|
: ConcreteViewShadowNode(sourceShadowNode, fragment) {
|
|
initialize();
|
|
}
|
|
|
|
void ViewShadowNode::initialize() noexcept {
|
|
auto& viewProps = static_cast<const ViewProps&>(*props_);
|
|
|
|
bool formsStackingContext = !viewProps.collapsable ||
|
|
viewProps.pointerEvents == PointerEventsMode::None ||
|
|
!viewProps.nativeId.empty() || viewProps.accessible ||
|
|
viewProps.opacity != 1.0 || viewProps.transform != Transform{} ||
|
|
(viewProps.zIndex.has_value() &&
|
|
viewProps.yogaStyle.positionType() != yoga::PositionType::Static) ||
|
|
viewProps.yogaStyle.display() == yoga::Display::None ||
|
|
viewProps.getClipsContentToBounds() || viewProps.events.bits.any() ||
|
|
isColorMeaningful(viewProps.shadowColor) ||
|
|
viewProps.accessibilityElementsHidden ||
|
|
viewProps.accessibilityViewIsModal ||
|
|
viewProps.importantForAccessibility != ImportantForAccessibility::Auto ||
|
|
viewProps.removeClippedSubviews ||
|
|
HostPlatformViewTraitsInitializer::formsStackingContext(viewProps);
|
|
|
|
bool formsView = formsStackingContext ||
|
|
isColorMeaningful(viewProps.backgroundColor) ||
|
|
!(viewProps.yogaStyle.border() == yoga::Style::Edges{}) ||
|
|
!viewProps.testId.empty() ||
|
|
HostPlatformViewTraitsInitializer::formsView(viewProps);
|
|
|
|
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);
|
|
}
|
|
|
|
traits_.set(HostPlatformViewTraitsInitializer::extraTraits());
|
|
}
|
|
|
|
} // namespace facebook::react
|