2018-09-12 01:27:47 +03:00
|
|
|
// Copyright (c) Facebook, Inc. and its affiliates.
|
2018-09-04 08:53:15 +03:00
|
|
|
|
|
|
|
// 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"
|
|
|
|
|
2018-11-11 01:19:08 +03:00
|
|
|
#include <react/core/LayoutableShadowNode.h>
|
2018-09-04 08:53:15 +03:00
|
|
|
|
|
|
|
namespace facebook {
|
|
|
|
namespace react {
|
|
|
|
|
|
|
|
static LayoutMetrics layoutMetricsFromShadowNode(const ShadowNode &shadowNode) {
|
2018-10-10 02:25:13 +03:00
|
|
|
auto layoutableShadowNode =
|
|
|
|
dynamic_cast<const LayoutableShadowNode *>(&shadowNode);
|
|
|
|
return layoutableShadowNode ? layoutableShadowNode->getLayoutMetrics()
|
|
|
|
: EmptyLayoutMetrics;
|
2018-09-04 08:53:15 +03:00
|
|
|
}
|
|
|
|
|
2018-10-10 02:25:13 +03:00
|
|
|
ShadowView::ShadowView(const ShadowNode &shadowNode)
|
|
|
|
: componentName(shadowNode.getComponentName()),
|
|
|
|
componentHandle(shadowNode.getComponentHandle()),
|
|
|
|
tag(shadowNode.getTag()),
|
|
|
|
props(shadowNode.getProps()),
|
|
|
|
eventEmitter(shadowNode.getEventEmitter()),
|
|
|
|
layoutMetrics(layoutMetricsFromShadowNode(shadowNode)),
|
2019-02-27 11:29:19 +03:00
|
|
|
localData(shadowNode.getLocalData()),
|
|
|
|
state(shadowNode.getState()) {}
|
2018-09-04 08:53:15 +03:00
|
|
|
|
|
|
|
bool ShadowView::operator==(const ShadowView &rhs) const {
|
2018-10-10 02:25:13 +03:00
|
|
|
return std::tie(
|
|
|
|
this->tag,
|
|
|
|
this->componentName,
|
|
|
|
this->props,
|
|
|
|
this->eventEmitter,
|
|
|
|
this->layoutMetrics,
|
2019-02-27 11:29:19 +03:00
|
|
|
this->localData,
|
|
|
|
this->state) ==
|
2018-10-10 02:25:13 +03:00
|
|
|
std::tie(
|
|
|
|
rhs.tag,
|
|
|
|
rhs.componentName,
|
|
|
|
rhs.props,
|
|
|
|
rhs.eventEmitter,
|
|
|
|
rhs.layoutMetrics,
|
2019-02-27 11:29:19 +03:00
|
|
|
rhs.localData,
|
|
|
|
rhs.state);
|
2018-09-04 08:53:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ShadowView::operator!=(const ShadowView &rhs) const {
|
|
|
|
return !(*this == rhs);
|
|
|
|
}
|
|
|
|
|
2019-04-04 22:32:43 +03:00
|
|
|
#if RN_DEBUG_STRING_CONVERTIBLE
|
|
|
|
|
|
|
|
std::string getDebugName(ShadowView const &object) {
|
2019-07-18 00:11:20 +03:00
|
|
|
return object.componentHandle == 0 ? "Invalid" : object.componentName;
|
2019-04-04 22:32:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<DebugStringConvertibleObject> getDebugProps(
|
|
|
|
ShadowView const &object,
|
|
|
|
DebugStringConvertibleOptions options) {
|
|
|
|
return {
|
|
|
|
{"tag", getDebugDescription(object.tag, options)},
|
|
|
|
{"props", getDebugDescription(object.props, options)},
|
|
|
|
{"eventEmitter", getDebugDescription(object.eventEmitter, options)},
|
|
|
|
{"layoutMetrics", getDebugDescription(object.layoutMetrics, options)},
|
|
|
|
{"localData", getDebugDescription(object.localData, options)},
|
|
|
|
{"state", getDebugDescription(object.state, options)},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2018-09-04 08:53:15 +03:00
|
|
|
bool ShadowViewNodePair::operator==(const ShadowViewNodePair &rhs) const {
|
2019-03-04 20:57:01 +03:00
|
|
|
return this->shadowNode == rhs.shadowNode;
|
2018-09-04 08:53:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ShadowViewNodePair::operator!=(const ShadowViewNodePair &rhs) const {
|
|
|
|
return !(*this == rhs);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace react
|
|
|
|
} // namespace facebook
|