mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
709a3a0ceb
Summary: Changelog: [internal] Backout D22098586 (https://github.com/facebook/react-native/commit/476ab7481e23070fc4db3f584e45a95eb2f9f7e1) because of issues like D22843134 (https://github.com/facebook/react-native/commit/799654b1058f6685c052f4e300c6e3ab81005549). [428](https://fburl.com/codesearch/0dyyakf5) places with zIndex and most of them do not have position defined. This could cause views to be overlapped. Reviewed By: JoshuaGross Differential Revision: D22890669 fbshipit-source-id: 200d1cbe2a4c27e2a0445b315868f37418ab1d9b
120 lines
3.6 KiB
C++
120 lines
3.6 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.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <react/renderer/components/view/ViewEventEmitter.h>
|
|
#include <react/renderer/components/view/ViewProps.h>
|
|
#include <react/renderer/components/view/YogaLayoutableShadowNode.h>
|
|
#include <react/renderer/core/ConcreteShadowNode.h>
|
|
#include <react/renderer/core/LayoutableShadowNode.h>
|
|
#include <react/renderer/core/ShadowNode.h>
|
|
#include <react/renderer/core/ShadowNodeFragment.h>
|
|
#include <react/renderer/debug/DebugStringConvertibleItem.h>
|
|
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
/*
|
|
* Template for all <View>-like classes (classes which have all same props
|
|
* as <View> and similar basic behaviour).
|
|
* For example: <Paragraph>, <Image>, but not <Text>, <RawText>.
|
|
*/
|
|
template <
|
|
const char *concreteComponentName,
|
|
typename ViewPropsT = ViewProps,
|
|
typename ViewEventEmitterT = ViewEventEmitter,
|
|
typename... Ts>
|
|
class ConcreteViewShadowNode : public ConcreteShadowNode<
|
|
concreteComponentName,
|
|
YogaLayoutableShadowNode,
|
|
ViewPropsT,
|
|
ViewEventEmitterT,
|
|
Ts...> {
|
|
static_assert(
|
|
std::is_base_of<ViewProps, ViewPropsT>::value,
|
|
"ViewPropsT must be a descendant of ViewProps");
|
|
static_assert(
|
|
std::is_base_of<YogaStylableProps, ViewPropsT>::value,
|
|
"ViewPropsT must be a descendant of YogaStylableProps");
|
|
static_assert(
|
|
std::is_base_of<AccessibilityProps, ViewPropsT>::value,
|
|
"ViewPropsT must be a descendant of AccessibilityProps");
|
|
|
|
public:
|
|
using BaseShadowNode = ConcreteShadowNode<
|
|
concreteComponentName,
|
|
YogaLayoutableShadowNode,
|
|
ViewPropsT,
|
|
ViewEventEmitterT,
|
|
Ts...>;
|
|
|
|
ConcreteViewShadowNode(
|
|
ShadowNodeFragment const &fragment,
|
|
ShadowNodeFamily::Shared const &family,
|
|
ShadowNodeTraits traits)
|
|
: BaseShadowNode(fragment, family, traits) {
|
|
initialize();
|
|
}
|
|
|
|
ConcreteViewShadowNode(
|
|
ShadowNode const &sourceShadowNode,
|
|
ShadowNodeFragment const &fragment)
|
|
: BaseShadowNode(sourceShadowNode, fragment) {
|
|
initialize();
|
|
}
|
|
|
|
using ConcreteViewProps = ViewPropsT;
|
|
|
|
using BaseShadowNode::BaseShadowNode;
|
|
|
|
static ShadowNodeTraits BaseTraits() {
|
|
auto traits = BaseShadowNode::BaseTraits();
|
|
traits.set(ShadowNodeTraits::Trait::ViewKind);
|
|
traits.set(ShadowNodeTraits::Trait::FormsStackingContext);
|
|
traits.set(ShadowNodeTraits::Trait::FormsView);
|
|
return traits;
|
|
}
|
|
|
|
Transform getTransform() const override {
|
|
return BaseShadowNode::getConcreteProps().transform;
|
|
}
|
|
|
|
#pragma mark - DebugStringConvertible
|
|
|
|
#if RN_DEBUG_STRING_CONVERTIBLE
|
|
SharedDebugStringConvertibleList getDebugProps() const override {
|
|
auto list = SharedDebugStringConvertibleList{};
|
|
|
|
auto basePropsList = ShadowNode::getDebugProps();
|
|
std::move(
|
|
basePropsList.begin(), basePropsList.end(), std::back_inserter(list));
|
|
|
|
list.push_back(std::make_shared<DebugStringConvertibleItem>(
|
|
"layout", "", LayoutableShadowNode::getDebugProps()));
|
|
|
|
return list;
|
|
}
|
|
#endif
|
|
|
|
private:
|
|
void initialize() noexcept {
|
|
auto &props = BaseShadowNode::getConcreteProps();
|
|
|
|
BaseShadowNode::orderIndex_ = props.zIndex.value_or(0);
|
|
|
|
if (props.yogaStyle.display() == YGDisplayNone) {
|
|
BaseShadowNode::traits_.set(ShadowNodeTraits::Trait::Hidden);
|
|
} else {
|
|
BaseShadowNode::traits_.unset(ShadowNodeTraits::Trait::Hidden);
|
|
}
|
|
}
|
|
};
|
|
|
|
} // namespace react
|
|
} // namespace facebook
|