ShadowView hash: add surfaceId and LayoutMetrics
Summary: Turns out that ShadowViews that have different LayoutMetrics will have the same hash. Fix that. This helps for debugging LayoutAnimations. Changelog: [Internal] Reviewed By: sammy-SC Differential Revision: D27585133 fbshipit-source-id: f0ac50619115150339089276e34fee5ddd0270bc
This commit is contained in:
Родитель
dde48fd554
Коммит
3824c565bf
|
@ -7,6 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <folly/Hash.h>
|
||||
#include <react/renderer/core/LayoutPrimitives.h>
|
||||
#include <react/renderer/graphics/Geometry.h>
|
||||
|
||||
|
@ -65,3 +66,22 @@ static LayoutMetrics const EmptyLayoutMetrics = {
|
|||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
|
||||
namespace std {
|
||||
|
||||
template <>
|
||||
struct hash<facebook::react::LayoutMetrics> {
|
||||
size_t operator()(const facebook::react::LayoutMetrics &layoutMetrics) const {
|
||||
return folly::hash::hash_combine(
|
||||
0,
|
||||
layoutMetrics.frame,
|
||||
layoutMetrics.contentInsets,
|
||||
layoutMetrics.borderWidth,
|
||||
layoutMetrics.displayType,
|
||||
layoutMetrics.layoutDirection,
|
||||
layoutMetrics.pointScaleFactor,
|
||||
layoutMetrics.overflowInset);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace std
|
||||
|
|
|
@ -18,18 +18,18 @@ namespace react {
|
|||
* engine which should be used for laying out the node.
|
||||
*/
|
||||
enum class DisplayType {
|
||||
None,
|
||||
Flex,
|
||||
Inline,
|
||||
None = 0,
|
||||
Flex = 1,
|
||||
Inline = 2,
|
||||
};
|
||||
|
||||
/*
|
||||
* User interface layout direction.
|
||||
*/
|
||||
enum class LayoutDirection {
|
||||
Undefined,
|
||||
LeftToRight,
|
||||
RightToLeft,
|
||||
Undefined = 0,
|
||||
LeftToRight = 1,
|
||||
RightToLeft = 2,
|
||||
};
|
||||
|
||||
} // namespace react
|
||||
|
@ -42,4 +42,12 @@ struct hash<facebook::react::LayoutDirection> {
|
|||
return hash<int>()(static_cast<int>(v));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct hash<facebook::react::DisplayType> {
|
||||
size_t operator()(const facebook::react::DisplayType &v) const {
|
||||
return hash<int>()(static_cast<int>(v));
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace std
|
||||
|
|
|
@ -92,10 +92,12 @@ struct hash<facebook::react::ShadowView> {
|
|||
size_t operator()(const facebook::react::ShadowView &shadowView) const {
|
||||
return folly::hash::hash_combine(
|
||||
0,
|
||||
shadowView.surfaceId,
|
||||
shadowView.componentHandle,
|
||||
shadowView.tag,
|
||||
shadowView.props,
|
||||
shadowView.eventEmitter,
|
||||
shadowView.layoutMetrics,
|
||||
shadowView.state);
|
||||
}
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче