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.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2019-03-08 00:38:10 +03:00
|
|
|
#include <better/small_vector.h>
|
2019-01-29 01:07:46 +03:00
|
|
|
#include <folly/Hash.h>
|
2019-02-26 06:07:19 +03:00
|
|
|
#include <react/core/EventEmitter.h>
|
2018-11-11 01:19:08 +03:00
|
|
|
#include <react/core/LayoutMetrics.h>
|
|
|
|
#include <react/core/LocalData.h>
|
|
|
|
#include <react/core/Props.h>
|
|
|
|
#include <react/core/ReactPrimitives.h>
|
|
|
|
#include <react/core/ShadowNode.h>
|
2018-09-04 08:53:15 +03:00
|
|
|
|
|
|
|
namespace facebook {
|
|
|
|
namespace react {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Describes a view that can be mounted.
|
|
|
|
*/
|
|
|
|
struct ShadowView final {
|
|
|
|
ShadowView() = default;
|
2019-06-24 07:30:00 +03:00
|
|
|
ShadowView(ShadowView const &shadowView) = default;
|
2019-04-20 20:49:53 +03:00
|
|
|
ShadowView(ShadowView &&shadowView) noexcept = default;
|
2018-09-04 08:53:15 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Constructs a `ShadowView` from given `ShadowNode`.
|
|
|
|
*/
|
2019-06-24 07:30:00 +03:00
|
|
|
explicit ShadowView(ShadowNode const &shadowNode);
|
2018-09-04 08:53:15 +03:00
|
|
|
|
2019-06-24 07:30:00 +03:00
|
|
|
ShadowView &operator=(ShadowView const &other) = default;
|
2019-04-20 20:49:53 +03:00
|
|
|
ShadowView &operator=(ShadowView &&other) = default;
|
2018-09-04 08:53:15 +03:00
|
|
|
|
2019-06-24 07:30:00 +03:00
|
|
|
bool operator==(ShadowView const &rhs) const;
|
|
|
|
bool operator!=(ShadowView const &rhs) const;
|
|
|
|
|
|
|
|
ComponentName componentName{};
|
|
|
|
ComponentHandle componentHandle{};
|
|
|
|
Tag tag{};
|
|
|
|
Props::Shared props{};
|
|
|
|
EventEmitter::Shared eventEmitter{};
|
|
|
|
LayoutMetrics layoutMetrics{EmptyLayoutMetrics};
|
|
|
|
LocalData::Shared localData{};
|
|
|
|
State::Shared state{};
|
2018-09-04 08:53:15 +03:00
|
|
|
};
|
|
|
|
|
2019-04-04 22:32:43 +03:00
|
|
|
#if RN_DEBUG_STRING_CONVERTIBLE
|
|
|
|
|
|
|
|
std::string getDebugName(ShadowView const &object);
|
|
|
|
std::vector<DebugStringConvertibleObject> getDebugProps(
|
|
|
|
ShadowView const &object,
|
|
|
|
DebugStringConvertibleOptions options = {});
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2018-09-04 08:53:15 +03:00
|
|
|
/*
|
|
|
|
* Describes pair of a `ShadowView` and a `ShadowNode`.
|
|
|
|
*/
|
|
|
|
struct ShadowViewNodePair final {
|
2019-05-03 22:27:24 +03:00
|
|
|
using List = better::
|
|
|
|
small_vector<ShadowViewNodePair, kShadowNodeChildrenSmallVectorSize>;
|
|
|
|
|
2019-03-04 20:57:01 +03:00
|
|
|
ShadowView shadowView;
|
|
|
|
ShadowNode const *shadowNode;
|
2018-09-04 08:53:15 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The stored pointer to `ShadowNode` represents an indentity of the pair.
|
|
|
|
*/
|
|
|
|
bool operator==(const ShadowViewNodePair &rhs) const;
|
|
|
|
bool operator!=(const ShadowViewNodePair &rhs) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace react
|
|
|
|
} // namespace facebook
|
2018-11-28 05:29:39 +03:00
|
|
|
|
|
|
|
namespace std {
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct hash<facebook::react::ShadowView> {
|
|
|
|
size_t operator()(const facebook::react::ShadowView &shadowView) const {
|
2019-03-15 04:31:06 +03:00
|
|
|
return folly::hash::hash_combine(
|
|
|
|
0,
|
2019-01-29 01:07:46 +03:00
|
|
|
shadowView.componentHandle,
|
|
|
|
shadowView.tag,
|
|
|
|
shadowView.props,
|
|
|
|
shadowView.eventEmitter,
|
2019-03-19 09:40:52 +03:00
|
|
|
shadowView.localData,
|
|
|
|
shadowView.state);
|
2018-11-28 05:29:39 +03:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace std
|