From 8491b579c80c502f5b7035b7e323d5811219745c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Oghin=C4=83?= Date: Tue, 17 Nov 2015 07:54:37 -0800 Subject: [PATCH] fix inspecting text elements Differential Revision: D2663651 fb-gh-sync-id: 2b583fecf5fa7a88f071a7441d03b95d21b8620f --- .../facebook/react/uimanager/UIManagerModule.java | 13 +++++++++++++ .../react/uimanager/UIViewOperationQueue.java | 9 +++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java index bb68616be..64f8ae6c5 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java @@ -835,4 +835,17 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements mOperationsQueue.enqueueSendAccessibilityEvent(tag, eventType); } + /** + * Get the first non-virtual (i.e. native) parent view tag of the react view with the passed tag. + * If the passed tag represents a non-virtual view, the same tag is returned. If the passed tag + * doesn't map to a react view, or a non-virtual parent cannot be found, -1 is returned. + */ + /* package */ int getNonVirtualParent(int reactTag) { + ReactShadowNode node = mShadowNodeRegistry.getNode(reactTag); + while (node != null && node.isVirtual()) { + node = node.getParent(); + } + return node == null ? -1 : node.getReactTag(); + } + } diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java index 614f67df4..067853045 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java @@ -383,10 +383,11 @@ public class UIViewOperationQueue { final float containerX = (float) mMeasureBuffer[0]; final float containerY = (float) mMeasureBuffer[1]; - final int touchTargetReactTag = mNativeViewHierarchyManager.findTargetTagForTouch( - mReactTag, - mTargetX, - mTargetY); + final int touchTargetReactTag = mUIManagerModule.getNonVirtualParent( + mNativeViewHierarchyManager.findTargetTagForTouch( + mReactTag, + mTargetX, + mTargetY)); try { mNativeViewHierarchyManager.measure(