Fabric: Proper return value of `LayoutableShadowNode::setLayoutMetrics()`

Summary: `LayoutableShadowNode::setLayoutMetrics()` must return `false` is nothing was changes.

Reviewed By: fkgozali

Differential Revision: D7330334

fbshipit-source-id: 700d50b0047919fa2b919acfa72825f100cd496f
This commit is contained in:
Valentin Shergin 2018-03-19 16:51:30 -07:00 committed by Facebook Github Bot
parent aaaa946e6d
commit a5a34565e0
2 changed files with 14 additions and 0 deletions

View File

@ -22,6 +22,16 @@ struct LayoutMetrics {
EdgeInsets borderWidth {0};
DisplayType displayType {Flex};
LayoutDirection layoutDirection {Undefined};
bool operator ==(const LayoutMetrics& rhs) const {
return
std::tie(this->frame, this->contentInsets, this->borderWidth, this->displayType, this->layoutDirection) ==
std::tie(rhs.frame, rhs.contentInsets, rhs.borderWidth, rhs.displayType, rhs.layoutDirection);
}
bool operator !=(const LayoutMetrics& rhs) const {
return !(*this == rhs);
}
};
} // namespace react

View File

@ -19,6 +19,10 @@ LayoutMetrics LayoutableShadowNode::getLayoutMetrics() const {
}
bool LayoutableShadowNode::setLayoutMetrics(LayoutMetrics layoutMetrics) {
if (layoutMetrics_ == layoutMetrics) {
return false;
}
layoutMetrics_ = layoutMetrics;
return true;
}