Files
react-native/ReactCommon/fabric/mounting/ShadowView.cpp
Valentin Shergin 56501dcc47 Fabric: Changing the shape of ShadowViewNodePair class
Summary:
I am not sure why it compiled before, it clearly should not, IMO. The `const` types (and references!) are not allowed inside `std::vector` because they are not assignable.
Some experiments that I did caused compilation errors here, so I am changing that to be actually correct.

Reviewed By: JoshuaGross

Differential Revision: D14249199

fbshipit-source-id: 07a22ef13f5de9dfc7ab307493419e6006994bc2
2019-03-04 10:00:01 -08:00

63 lines
1.8 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 "ShadowView.h"
#include <react/core/LayoutableShadowNode.h>
namespace facebook {
namespace react {
static LayoutMetrics layoutMetricsFromShadowNode(const ShadowNode &shadowNode) {
auto layoutableShadowNode =
dynamic_cast<const LayoutableShadowNode *>(&shadowNode);
return layoutableShadowNode ? layoutableShadowNode->getLayoutMetrics()
: EmptyLayoutMetrics;
}
ShadowView::ShadowView(const ShadowNode &shadowNode)
: componentName(shadowNode.getComponentName()),
componentHandle(shadowNode.getComponentHandle()),
tag(shadowNode.getTag()),
props(shadowNode.getProps()),
eventEmitter(shadowNode.getEventEmitter()),
layoutMetrics(layoutMetricsFromShadowNode(shadowNode)),
localData(shadowNode.getLocalData()),
state(shadowNode.getState()) {}
bool ShadowView::operator==(const ShadowView &rhs) const {
return std::tie(
this->tag,
this->componentName,
this->props,
this->eventEmitter,
this->layoutMetrics,
this->localData,
this->state) ==
std::tie(
rhs.tag,
rhs.componentName,
rhs.props,
rhs.eventEmitter,
rhs.layoutMetrics,
rhs.localData,
rhs.state);
}
bool ShadowView::operator!=(const ShadowView &rhs) const {
return !(*this == rhs);
}
bool ShadowViewNodePair::operator==(const ShadowViewNodePair &rhs) const {
return this->shadowNode == rhs.shadowNode;
}
bool ShadowViewNodePair::operator!=(const ShadowViewNodePair &rhs) const {
return !(*this == rhs);
}
} // namespace react
} // namespace facebook