1010package com.facebook.react.runtime
1111
1212import android.content.Context
13- import android.graphics.Point
1413import android.graphics.Rect
1514import android.view.KeyEvent
1615import android.view.MotionEvent
1716import android.view.View
18- import androidx.core.view.ViewCompat
19- import androidx.core.view.WindowInsetsCompat
2017import com.facebook.common.logging.FLog
2118import com.facebook.react.ReactRootView
2219import com.facebook.react.bridge.ReactContext
@@ -28,8 +25,8 @@ import com.facebook.react.uimanager.IllegalViewOperationException
2825import com.facebook.react.uimanager.JSKeyDispatcher
2926import com.facebook.react.uimanager.JSPointerDispatcher
3027import com.facebook.react.uimanager.JSTouchDispatcher
28+ import com.facebook.react.uimanager.RootViewUtil
3129import com.facebook.react.uimanager.common.UIManagerType
32- import com.facebook.react.views.view.isEdgeToEdgeFeatureFlagOn
3330import com.facebook.systrace.Systrace
3431import java.util.Objects
3532import kotlin.math.max
@@ -48,28 +45,6 @@ public class ReactSurfaceView(context: Context?, internal val surface: ReactSurf
4845 private var widthMeasureSpec = 0
4946 private var heightMeasureSpec = 0
5047
51- private val viewportOffset: Point
52- get() {
53- val locationInWindow = IntArray (2 )
54- getLocationInWindow(locationInWindow)
55-
56- if (! isEdgeToEdgeFeatureFlagOn) {
57- // When not in edge-to-edge mode, subtract the top system bar insets so the offset is
58- // relative to the content area (below the status bar / cutout).
59- ViewCompat .getRootWindowInsets(this )?.apply {
60- val insets =
61- getInsets(
62- WindowInsetsCompat .Type .statusBars() or WindowInsetsCompat .Type .displayCutout()
63- )
64-
65- locationInWindow[0 ] - = insets.left
66- locationInWindow[1 ] - = insets.top
67- }
68- }
69-
70- return Point (locationInWindow[0 ], locationInWindow[1 ])
71- }
72-
7348 init {
7449 if (ReactFeatureFlags .dispatchPointerEvents) {
7550 jsPointerDispatcher = JSPointerDispatcher (this )
@@ -107,7 +82,7 @@ public class ReactSurfaceView(context: Context?, internal val surface: ReactSurf
10782 wasMeasured = true
10883 this .widthMeasureSpec = widthMeasureSpec
10984 this .heightMeasureSpec = heightMeasureSpec
110- val viewportOffset = viewportOffset
85+ val viewportOffset = RootViewUtil .getViewportOffset( this )
11186 surface.updateLayoutSpecs(
11287 widthMeasureSpec,
11388 heightMeasureSpec,
@@ -120,7 +95,7 @@ public class ReactSurfaceView(context: Context?, internal val surface: ReactSurf
12095 override fun onLayout (changed : Boolean , left : Int , top : Int , right : Int , bottom : Int ) {
12196 // Call updateLayoutSpecs to update locationOnScreen offsets, in case they've changed
12297 if (wasMeasured && changed) {
123- val viewportOffset = viewportOffset
98+ val viewportOffset = RootViewUtil .getViewportOffset( this )
12499 surface.updateLayoutSpecs(
125100 widthMeasureSpec,
126101 heightMeasureSpec,
0 commit comments