Fabric: Overriden equality operator for ViewShadowNode

Summary:
Computed `layoutMetrics` are also considered as part of ViewShadowNode's value.
In the future we probably have to add something like `localData` and `imperativeCommands`.
We need all this for diffing algorithm and mointing phase.

Reviewed By: mdvacca

Differential Revision: D7467800

fbshipit-source-id: 8a0dcf1fd2f97dc501d6969cb0b0f6a2c6a648b4
This commit is contained in:
Valentin Shergin 2018-04-10 12:45:48 -07:00 committed by Facebook Github Bot
parent fec0a51e85
commit 1a4b6f0b3d
2 changed files with 12 additions and 0 deletions

View File

@ -97,9 +97,17 @@ SharedLayoutableShadowNode ViewShadowNode::cloneAndReplaceChild(const SharedLayo
auto viewShadowNodeChildClone = std::make_shared<const ViewShadowNode>(viewShadowNodeChild);
ShadowNode::replaceChild(viewShadowNodeChild, viewShadowNodeChildClone);
return std::static_pointer_cast<const LayoutableShadowNode>(viewShadowNodeChildClone);
}
#pragma mark - Equality
bool ViewShadowNode::operator==(const ShadowNode& rhs) const {
if (!ShadowNode::operator==(rhs)) {
return false;
}
auto &&other = static_cast<const ViewShadowNode&>(rhs);
return getLayoutMetrics() == other.getLayoutMetrics();
}
#pragma mark - DebugStringConvertible

View File

@ -48,6 +48,10 @@ public:
void appendChild(const SharedShadowNode &child);
#pragma mark - Equality
bool operator==(const ShadowNode& rhs) const override;
#pragma mark - DebugStringConvertible
SharedDebugStringConvertibleList getDebugProps() const override;