Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ namespace facebook::react {
// NOLINTNEXTLINE(facebook-hte-CArray,modernize-avoid-c-arrays)
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,12 @@ namespace facebook::react {
// NOLINTNEXTLINE(modernize-avoid-c-arrays)
extern const char ViewComponentName[];

/**
* Implementation of the ViewProps that propagates feature flag.
*/
class ViewShadowNodeProps final : public ViewProps {
public:
ViewShadowNodeProps() = default;
ViewShadowNodeProps(
const PropsParserContext &context,
const ViewShadowNodeProps &sourceProps,
const RawProps &rawProps);
};
using ViewShadowNodeProps = ViewProps;

/*
* `ShadowNode` for <View> component.
*/
class ViewShadowNode final : public ConcreteViewShadowNode<ViewComponentName, ViewShadowNodeProps, ViewEventEmitter> {
class ViewShadowNode final : public ConcreteViewShadowNode<ViewComponentName, ViewProps, ViewEventEmitter> {
public:
ViewShadowNode(const ShadowNodeFragment &fragment, const ShadowNodeFamily::Shared &family, ShadowNodeTraits traits);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1017,8 +1017,7 @@ void YogaLayoutableShadowNode::swapLeftAndRightInYogaStyleProps() {
void YogaLayoutableShadowNode::swapLeftAndRightInViewProps() {
if (auto viewShadowNode = dynamic_cast<ViewShadowNode*>(this)) {
// TODO: Do not mutate props directly.
auto& props =
const_cast<ViewShadowNodeProps&>(viewShadowNode->getConcreteProps());
auto& props = const_cast<ViewProps&>(viewShadowNode->getConcreteProps());

// Swap border node values, borderRadii, borderColors and borderStyles.
if (props.borderRadii.topLeft.has_value()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class LayoutTest : public ::testing::Test {
.reference(viewShadowNodeA_)
.tag(2)
.props([] {
auto sharedProps = std::make_shared<ViewShadowNodeProps>();
auto sharedProps = std::make_shared<ViewProps>();
auto &props = *sharedProps;
auto &yogaStyle = props.yogaStyle;
yogaStyle.setPositionType(yoga::PositionType::Absolute);
Expand All @@ -99,7 +99,7 @@ class LayoutTest : public ::testing::Test {
.reference(viewShadowNodeAB_)
.tag(3)
.props([=] {
auto sharedProps = std::make_shared<ViewShadowNodeProps>();
auto sharedProps = std::make_shared<ViewProps>();
auto &props = *sharedProps;
auto &yogaStyle = props.yogaStyle;
yogaStyle.setPositionType(yoga::PositionType::Absolute);
Expand Down Expand Up @@ -127,7 +127,7 @@ class LayoutTest : public ::testing::Test {
.reference(viewShadowNodeABC_)
.tag(4)
.props([=] {
auto sharedProps = std::make_shared<ViewShadowNodeProps>();
auto sharedProps = std::make_shared<ViewProps>();
auto &props = *sharedProps;
auto &yogaStyle = props.yogaStyle;

Expand All @@ -147,7 +147,7 @@ class LayoutTest : public ::testing::Test {
.reference(viewShadowNodeABCD_)
.tag(5)
.props([] {
auto sharedProps = std::make_shared<ViewShadowNodeProps>();
auto sharedProps = std::make_shared<ViewProps>();
auto &props = *sharedProps;
auto &yogaStyle = props.yogaStyle;
yogaStyle.setPositionType(yoga::PositionType::Absolute);
Expand All @@ -162,7 +162,7 @@ class LayoutTest : public ::testing::Test {
.reference(viewShadowNodeABE_)
.tag(6)
.props([] {
auto sharedProps = std::make_shared<ViewShadowNodeProps>();
auto sharedProps = std::make_shared<ViewProps>();
auto &props = *sharedProps;
auto &yogaStyle = props.yogaStyle;
yogaStyle.setPositionType(yoga::PositionType::Absolute);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class YogaDirtyFlagTest : public ::testing::Test {
/*
* Some non-default props.
*/
auto mutableViewProps = std::make_shared<ViewShadowNodeProps>();
auto mutableViewProps = std::make_shared<ViewProps>();
auto &props = *mutableViewProps;
props.nativeId = "native Id";
props.opacity = 0.5;
Expand Down Expand Up @@ -113,7 +113,7 @@ TEST_F(YogaDirtyFlagTest, changingNonLayoutSubPropsMustNotDirtyYogaNode) {
*/
auto newRootShadowNode = rootShadowNode_->cloneTree(
innerShadowNode_->getFamily(), [](const ShadowNode& oldShadowNode) {
auto viewProps = std::make_shared<ViewShadowNodeProps>();
auto viewProps = std::make_shared<ViewProps>();
auto& props = *viewProps;

props.nativeId = "some new native Id";
Expand All @@ -136,7 +136,7 @@ TEST_F(YogaDirtyFlagTest, changingLayoutSubPropsMustDirtyYogaNode) {
*/
auto newRootShadowNode = rootShadowNode_->cloneTree(
innerShadowNode_->getFamily(), [](const ShadowNode& oldShadowNode) {
auto viewProps = std::make_shared<ViewShadowNodeProps>();
auto viewProps = std::make_shared<ViewProps>();
auto& props = *viewProps;

props.yogaStyle.setAlignContent(yoga::Align::Baseline);
Expand Down Expand Up @@ -243,7 +243,7 @@ TEST_F(YogaDirtyFlagTest, clonedPropsPreserveAspectRatio) {
auto newRootShadowNode = rootShadowNode_->cloneTree(
innerShadowNode_->getFamily(), [&](const ShadowNode& oldShadowNode) {
// First clone: set aspectRatio to 1.5
auto viewProps = std::make_shared<ViewShadowNodeProps>();
auto viewProps = std::make_shared<ViewProps>();
viewProps->yogaStyle.setAspectRatio(yoga::FloatOptional(1.5f));
auto nodeWithAspectRatio =
oldShadowNode.clone(ShadowNodeFragment{.props = viewProps});
Expand All @@ -255,8 +255,7 @@ TEST_F(YogaDirtyFlagTest, clonedPropsPreserveAspectRatio) {
auto clonedProps = componentDescriptor.cloneProps(
parserContext, nodeWithAspectRatio->getProps(), RawProps());

auto& clonedViewProps =
static_cast<const ViewShadowNodeProps&>(*clonedProps);
auto& clonedViewProps = static_cast<const ViewProps&>(*clonedProps);
EXPECT_TRUE(clonedViewProps.yogaStyle.aspectRatio().isDefined());
EXPECT_EQ(clonedViewProps.yogaStyle.aspectRatio().unwrap(), 1.5f);

Expand Down Expand Up @@ -303,7 +302,7 @@ class YogaCloneTest : public ::testing::Test {
.reference(parentShadowNode_)
.tag(2)
.props([] {
auto sharedProps = std::make_shared<ViewShadowNodeProps>();
auto sharedProps = std::make_shared<ViewProps>();
auto &props = *sharedProps;
auto &yogaStyle = props.yogaStyle;
yogaStyle.setFlexDirection(yoga::FlexDirection::Row);
Expand All @@ -320,7 +319,7 @@ class YogaCloneTest : public ::testing::Test {
.reference(childAShadowNode_)
.tag(3)
.props([] {
auto sharedProps = std::make_shared<ViewShadowNodeProps>();
auto sharedProps = std::make_shared<ViewProps>();
sharedProps->yogaStyle.setDimension(
yoga::Dimension::Width,
yoga::StyleSizeLength::points(100));
Expand All @@ -333,7 +332,7 @@ class YogaCloneTest : public ::testing::Test {
.reference(childBShadowNode_)
.tag(4)
.props([] {
auto sharedProps = std::make_shared<ViewShadowNodeProps>();
auto sharedProps = std::make_shared<ViewProps>();
sharedProps->yogaStyle.setDimension(
yoga::Dimension::Width,
yoga::StyleSizeLength::points(100));
Expand All @@ -346,7 +345,7 @@ class YogaCloneTest : public ::testing::Test {
.reference(childCShadowNode_)
.tag(5)
.props([] {
auto sharedProps = std::make_shared<ViewShadowNodeProps>();
auto sharedProps = std::make_shared<ViewProps>();
sharedProps->yogaStyle.setDimension(
yoga::Dimension::Width,
yoga::StyleSizeLength::points(100));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ TEST(FindNodeAtPointTest, viewIsScaled) {
Element<ViewShadowNode>()
.tag(3)
.props([] {
auto sharedProps = std::make_shared<ViewShadowNodeProps>();
auto sharedProps = std::make_shared<ViewProps>();
sharedProps->transform = Transform::Scale(0.5, 0.5, 0);
return sharedProps;
})
Expand Down Expand Up @@ -199,7 +199,7 @@ TEST(FindNodeAtPointTest, overlappingViewsWithZIndex) {
Element<ViewShadowNode>()
.tag(2)
.props([] {
auto sharedProps = std::make_shared<ViewShadowNodeProps>();
auto sharedProps = std::make_shared<ViewProps>();
sharedProps->zIndex = 1;
auto &yogaStyle = sharedProps->yogaStyle;
yogaStyle.setPositionType(yoga::PositionType::Absolute);
Expand Down Expand Up @@ -235,7 +235,7 @@ TEST(FindNodeAtPointTest, overlappingViewsWithParentPointerEventsBoxOnly) {
Element<ViewShadowNode>()
.tag(1)
.props([] {
auto sharedProps = std::make_shared<ViewShadowNodeProps>();
auto sharedProps = std::make_shared<ViewProps>();
sharedProps->pointerEvents = PointerEventsMode::BoxOnly;
return sharedProps;
})
Expand Down Expand Up @@ -277,7 +277,7 @@ TEST(FindNodeAtPointTest, overlappingViewsWithParentPointerEventsBoxNone) {
Element<ViewShadowNode>()
.tag(1)
.props([] {
auto sharedProps = std::make_shared<ViewShadowNodeProps>();
auto sharedProps = std::make_shared<ViewProps>();
sharedProps->pointerEvents = PointerEventsMode::BoxNone;
return sharedProps;
})
Expand All @@ -290,7 +290,7 @@ TEST(FindNodeAtPointTest, overlappingViewsWithParentPointerEventsBoxNone) {
Element<ViewShadowNode>()
.tag(2)
.props([] {
auto sharedProps = std::make_shared<ViewShadowNodeProps>();
auto sharedProps = std::make_shared<ViewProps>();
sharedProps->zIndex = 1;
auto &yogaStyle = sharedProps->yogaStyle;
yogaStyle.setPositionType(yoga::PositionType::Absolute);
Expand Down Expand Up @@ -326,7 +326,7 @@ TEST(FindNodeAtPointTest, overlappingViewsWithParentPointerEventsNone) {
Element<ViewShadowNode>()
.tag(1)
.props([] {
auto sharedProps = std::make_shared<ViewShadowNodeProps>();
auto sharedProps = std::make_shared<ViewProps>();
sharedProps->pointerEvents = PointerEventsMode::None;
return sharedProps;
})
Expand All @@ -339,7 +339,7 @@ TEST(FindNodeAtPointTest, overlappingViewsWithParentPointerEventsNone) {
Element<ViewShadowNode>()
.tag(2)
.props([] {
auto sharedProps = std::make_shared<ViewShadowNodeProps>();
auto sharedProps = std::make_shared<ViewProps>();
sharedProps->zIndex = 1;
auto &yogaStyle = sharedProps->yogaStyle;
yogaStyle.setPositionType(yoga::PositionType::Absolute);
Expand Down
Loading
Loading