mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-01-12 22:50:10 +08:00
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:
committed by
Facebook Github Bot
parent
4602bf5cc6
commit
f24fd6e9ee
@@ -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 ¤tShadowNode : ancestors) {
|
||||
for (auto it = ancestors.rbegin(); it != ancestors.rend(); ++it) {
|
||||
auto ¤tShadowNode = it->first.get();
|
||||
|
||||
auto layoutableCurrentShadowNode =
|
||||
dynamic_cast<const LayoutableShadowNode *>(¤tShadowNode.get());
|
||||
dynamic_cast<const LayoutableShadowNode *>(¤tShadowNode);
|
||||
|
||||
if (!layoutableCurrentShadowNode) {
|
||||
return EmptyLayoutMetrics;
|
||||
|
||||
Reference in New Issue
Block a user