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;
|
|
|
|
ShadowView(const ShadowView &shadowView) = default;
|
|
|
|
|
2019-03-04 09:29:28 +03:00
|
|
|
~ShadowView(){};
|
|
|
|
|
2018-09-04 08:53:15 +03:00
|
|
|
/*
|
|
|
|
* Constructs a `ShadowView` from given `ShadowNode`.
|
|
|
|
*/
|
|
|
|
explicit ShadowView(const ShadowNode &shadowNode);
|
|
|
|
|
|
|
|
ShadowView &operator=(const ShadowView &other) = default;
|
|
|
|
|
|
|
|
bool operator==(const ShadowView &rhs) const;
|
|
|
|
bool operator!=(const ShadowView &rhs) const;
|
|
|
|
|
|
|
|
ComponentName componentName = "";
|
|
|
|
ComponentHandle componentHandle = 0;
|
2019-01-26 03:55:06 +03:00
|
|
|
Tag tag = -1; // Tag does not change during the lifetime of a shadow view.
|
2018-09-04 08:53:15 +03:00
|
|
|
SharedProps props = {};
|
|
|
|
SharedEventEmitter eventEmitter = {};
|
|
|
|
LayoutMetrics layoutMetrics = EmptyLayoutMetrics;
|
|
|
|
SharedLocalData localData = {};
|
2019-02-27 11:29:19 +03:00
|
|
|
State::Shared state = {};
|
2018-09-04 08:53:15 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Describes pair of a `ShadowView` and a `ShadowNode`.
|
|
|
|
*/
|
|
|
|
struct ShadowViewNodePair final {
|
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;
|
|
|
|
};
|
|
|
|
|
2019-03-08 00:38:10 +03:00
|
|
|
using ShadowViewNodePairList = better::
|
|
|
|
small_vector<ShadowViewNodePair, kShadowNodeChildrenSmallVectorSize>;
|
2018-09-04 08:53:15 +03:00
|
|
|
|
|
|
|
} // 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
|