mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Extract getViewportOffset out RootView
Summary: This diff moves the method getViewportOffset out of ReactRootView. This is necessary to avoid Fabric to depend from paper. changelog: [internal] internal Reviewed By: JoshuaGross Differential Revision: D26716901 fbshipit-source-id: cec67c24860a776fb361d7cda08d3142e1214c8c
This commit is contained in:
committed by
Facebook GitHub Bot
parent
21a434ceec
commit
05f687fa88
@@ -27,7 +27,6 @@ import android.view.ViewTreeObserver;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.FrameLayout;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.UiThread;
|
||||
import com.facebook.common.logging.FLog;
|
||||
import com.facebook.infer.annotation.Assertions;
|
||||
import com.facebook.infer.annotation.ThreadConfined;
|
||||
@@ -52,6 +51,7 @@ import com.facebook.react.uimanager.JSTouchDispatcher;
|
||||
import com.facebook.react.uimanager.PixelUtil;
|
||||
import com.facebook.react.uimanager.ReactRoot;
|
||||
import com.facebook.react.uimanager.RootView;
|
||||
import com.facebook.react.uimanager.RootViewUtil;
|
||||
import com.facebook.react.uimanager.UIManagerHelper;
|
||||
import com.facebook.react.uimanager.common.UIManagerType;
|
||||
import com.facebook.react.uimanager.events.EventDispatcher;
|
||||
@@ -420,21 +420,6 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
|
||||
return mState;
|
||||
}
|
||||
|
||||
@UiThread
|
||||
public static Point getViewportOffset(View v) {
|
||||
int[] locationInWindow = new int[2];
|
||||
v.getLocationInWindow(locationInWindow);
|
||||
|
||||
// we need to subtract visibleWindowCoords - to subtract possible window insets, split
|
||||
// screen or multi window
|
||||
Rect visibleWindowFrame = new Rect();
|
||||
v.getWindowVisibleDisplayFrame(visibleWindowFrame);
|
||||
locationInWindow[0] -= visibleWindowFrame.left;
|
||||
locationInWindow[1] -= visibleWindowFrame.top;
|
||||
|
||||
return new Point(locationInWindow[0], locationInWindow[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call whenever measure specs change, or if you want to force an update of offsetX/offsetY. If
|
||||
* measureSpecsChanged is false and the offsetX/offsetY don't change, updateRootLayoutSpecs will
|
||||
@@ -472,7 +457,7 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
|
||||
int offsetX = 0;
|
||||
int offsetY = 0;
|
||||
if (getUIManagerType() == FABRIC) {
|
||||
Point viewportOffset = getViewportOffset(this);
|
||||
Point viewportOffset = RootViewUtil.getViewportOffset(this);
|
||||
offsetX = viewportOffset.x;
|
||||
offsetY = viewportOffset.y;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user