From 3adbf1e822dc8a50b8852599741d3bdc9c535daf Mon Sep 17 00:00:00 2001 From: Ahmed El-Helw Date: Fri, 12 Aug 2016 12:16:17 -0700 Subject: [PATCH] Fix measureLayout for Nodes Summary: For Nodes that don't mount to views, measureLayout wasn't working because our calls for getting the width and height would return the view delta bounds, which won't exist for Nodes. #accept2ship Differential Revision: D3707880 --- .../com/facebook/react/flat/FlatShadowNode.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatShadowNode.java b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatShadowNode.java index bb77a8ce06b..d41b90b77ae 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatShadowNode.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatShadowNode.java @@ -184,12 +184,24 @@ import com.facebook.react.views.view.ReactClippingViewGroupHelper; @Override public final int getScreenWidth() { - return mViewRight - mViewLeft; + if (mountsToView()) { + return mViewRight - mViewLeft; + } else { + // this is not technically correct since hitSlop affects the NodeRegion, but it's a temporary + // work around for now, since mView{Right,Left} are only set for views + return Math.round(mNodeRegion.mRight - mNodeRegion.mLeft); + } } @Override public final int getScreenHeight() { - return mViewBottom - mViewTop; + if (mountsToView()) { + return mViewBottom - mViewTop; + } else { + // this is not technically correct since hitSlop affects the NodeRegion, but it's a temporary + // work around for now, since mView{Bottom,Top} are only set for views + return Math.round(mNodeRegion.mBottom - mNodeRegion.mTop); + } } @Override