Fabric: Using new shiny ShadowNode::getAncestors in LayoutableShadowNode

Summary: Same algorithm using a new API.

Reviewed By: JoshuaGross

Differential Revision: D14423509

fbshipit-source-id: c40f61fdd001f68785512c304941f523585d641c
This commit is contained in:
Valentin Shergin
2019-03-18 23:38:12 -07:00
committed by Facebook Github Bot
parent 4602bf5cc6
commit f24fd6e9ee

View File

@@ -38,21 +38,23 @@ bool LayoutableShadowNode::LayoutableShadowNode::isLayoutOnly() const {
LayoutMetrics LayoutableShadowNode::getRelativeLayoutMetrics(
const LayoutableShadowNode &ancestorLayoutableShadowNode) const {
std::vector<std::reference_wrapper<const ShadowNode>> ancestors;
auto &ancestorShadowNode =
dynamic_cast<const ShadowNode &>(ancestorLayoutableShadowNode);
auto &shadowNode = dynamic_cast<const ShadowNode &>(*this);
if (!shadowNode.constructAncestorPath(ancestorShadowNode, ancestors)) {
auto ancestors = shadowNode.getAncestors(ancestorShadowNode);
if (ancestors.size() == 0) {
return EmptyLayoutMetrics;
}
auto layoutMetrics = getLayoutMetrics();
for (const auto &currentShadowNode : ancestors) {
for (auto it = ancestors.rbegin(); it != ancestors.rend(); ++it) {
auto &currentShadowNode = it->first.get();
auto layoutableCurrentShadowNode =
dynamic_cast<const LayoutableShadowNode *>(&currentShadowNode.get());
dynamic_cast<const LayoutableShadowNode *>(&currentShadowNode);
if (!layoutableCurrentShadowNode) {
return EmptyLayoutMetrics;