mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-01 06:22:39 +08:00
Add viewIsDescendantOf for UIManager on Android
Summary: Add the ability for UIManager to check if a node is an ancestor of anther one on Android like #7876 did on iOS Closes https://github.com/facebook/react-native/pull/13129 Differential Revision: D4938319 Pulled By: hramos fbshipit-source-id: abe20779be2142a1ea9ac46f52d8cd8609236419
This commit is contained in:
committed by
Facebook Github Bot
parent
2d1c721fd6
commit
663df57c62
@@ -452,6 +452,23 @@ public class ReactShadowNode {
|
||||
return mTotalNativeChildren;
|
||||
}
|
||||
|
||||
public boolean isDescendantOf(ReactShadowNode ancestorNode) {
|
||||
ReactShadowNode parentNode = getParent();
|
||||
|
||||
boolean isDescendant = false;
|
||||
|
||||
while (parentNode != null) {
|
||||
if (parentNode == ancestorNode) {
|
||||
isDescendant = true;
|
||||
break;
|
||||
} else {
|
||||
parentNode = parentNode.getParent();
|
||||
}
|
||||
}
|
||||
|
||||
return isDescendant;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the offset within the native children owned by all layout-only nodes in the subtree
|
||||
* rooted at this node for the given child. Put another way, this returns the number of native
|
||||
|
||||
Reference in New Issue
Block a user