Files
react-native/ReactCommon/react/renderer/mounting/StubView.cpp
T
Joshua Gross 82e9cb1b4e Add SurfaceId to ShadowView
Summary:
See title. Not used in this diff; see next diff in stack.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D26001014

fbshipit-source-id: 475eb265f1c27bd9aff978a49652764a50287e47
2021-01-21 23:47:34 -08:00

81 lines
2.3 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 "StubView.h"
namespace facebook {
namespace react {
StubView::operator ShadowView() const {
auto shadowView = ShadowView{};
shadowView.componentName = componentName;
shadowView.componentHandle = componentHandle;
shadowView.surfaceId = surfaceId;
shadowView.tag = tag;
shadowView.props = props;
shadowView.eventEmitter = eventEmitter;
shadowView.layoutMetrics = layoutMetrics;
shadowView.state = state;
return shadowView;
}
void StubView::update(ShadowView const &shadowView) {
componentName = shadowView.componentName;
componentHandle = shadowView.componentHandle;
surfaceId = shadowView.surfaceId;
tag = shadowView.tag;
props = shadowView.props;
eventEmitter = shadowView.eventEmitter;
layoutMetrics = shadowView.layoutMetrics;
state = shadowView.state;
}
bool operator==(StubView const &lhs, StubView const &rhs) {
return std::tie(lhs.props, lhs.layoutMetrics) ==
std::tie(rhs.props, rhs.layoutMetrics);
}
bool operator!=(StubView const &lhs, StubView const &rhs) {
return !(lhs == rhs);
}
#if RN_DEBUG_STRING_CONVERTIBLE
std::string getDebugName(StubView const &stubView) {
return std::string{"Stub"} +
std::string{
stubView.componentHandle ? stubView.componentName : "[invalid]"};
}
std::vector<DebugStringConvertibleObject> getDebugProps(
StubView const &stubView,
DebugStringConvertibleOptions options) {
return {
{"surfaceId", getDebugDescription(stubView.surfaceId, options)},
{"tag", getDebugDescription(stubView.tag, options)},
{"props", getDebugDescription(stubView.props, options)},
{"eventEmitter", getDebugDescription(stubView.eventEmitter, options)},
{"layoutMetrics", getDebugDescription(stubView.layoutMetrics, options)},
{"state", getDebugDescription(stubView.state, options)},
};
}
std::vector<StubView> getDebugChildren(
StubView const &stubView,
DebugStringConvertibleOptions options) {
std::vector<StubView> result;
for (auto const &child : stubView.children) {
result.push_back(*child);
}
return result;
}
#endif
} // namespace react
} // namespace facebook