Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import android.graphics.Rect
import android.view.KeyEvent
import android.view.MotionEvent
import android.view.View
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.facebook.common.logging.FLog
import com.facebook.react.ReactRootView
import com.facebook.react.bridge.ReactContext
Expand All @@ -27,6 +29,7 @@ import com.facebook.react.uimanager.JSKeyDispatcher
import com.facebook.react.uimanager.JSPointerDispatcher
import com.facebook.react.uimanager.JSTouchDispatcher
import com.facebook.react.uimanager.common.UIManagerType
import com.facebook.react.views.view.isEdgeToEdgeFeatureFlagOn
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copying here comment from @javache

I don't think react.runtime can depend on react.views? There seems to be a dependency issue.
Maybe the feature flag should live in UIManager/

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could move isEdgeToEdgeFeatureFlagOn / setEdgeToEdgeFeatureFlagOn / updateEdgeToEdgeFeatureFlag in a separate file, but that introduces a change in the public API

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, com.facebook.react.views.view.isEdgeToEdgeFeatureFlagOn was add in June 2025.
@javache I also don't see any build issues so is this more of an architectural policy?

import com.facebook.systrace.Systrace
import java.util.Objects
import kotlin.math.max
Expand All @@ -47,16 +50,24 @@ public class ReactSurfaceView(context: Context?, internal val surface: ReactSurf

private val viewportOffset: Point
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic is similar to RootViewUtil.getViewportOffset(v: View), it's just not used here because of it's bad naming (getViewportOffset could be called for any view, not just the root one)

get() {
val locationOnScreen = IntArray(2)
getLocationOnScreen(locationOnScreen)
val locationInWindow = IntArray(2)
getLocationInWindow(locationInWindow)

// we need to subtract visibleWindowCoords - to subtract possible window insets, split
// screen or multi window
val visibleWindowFrame = Rect()
getWindowVisibleDisplayFrame(visibleWindowFrame)
locationOnScreen[0] -= visibleWindowFrame.left
locationOnScreen[1] -= visibleWindowFrame.top
return Point(locationOnScreen[0], locationOnScreen[1])
if (!isEdgeToEdgeFeatureFlagOn) {
// When not in edge-to-edge mode, subtract the top system bar insets so the offset is
// relative to the content area (below the status bar / cutout).
ViewCompat.getRootWindowInsets(this)?.apply {
val insets =
getInsets(
WindowInsetsCompat.Type.statusBars() or WindowInsetsCompat.Type.displayCutout()
)

locationInWindow[0] -= insets.left
locationInWindow[1] -= insets.top
}
}

return Point(locationInWindow[0], locationInWindow[1])
}

init {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
package com.facebook.react.uimanager

import android.graphics.Point
import android.graphics.Rect
import android.view.View
import androidx.annotation.UiThread
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.facebook.infer.annotation.Assertions
import com.facebook.react.views.view.isEdgeToEdgeFeatureFlagOn

public object RootViewUtil {
/** Returns the root view of a given view in a react application. */
Expand All @@ -34,12 +36,20 @@ public object RootViewUtil {
val locationInWindow = IntArray(2)
v.getLocationInWindow(locationInWindow)

// we need to subtract visibleWindowCoords - to subtract possible window insets, split
// screen or multi window
val visibleWindowFrame = Rect()
v.getWindowVisibleDisplayFrame(visibleWindowFrame)
locationInWindow[0] -= visibleWindowFrame.left
locationInWindow[1] -= visibleWindowFrame.top
if (!isEdgeToEdgeFeatureFlagOn) {
// When not in edge-to-edge mode, subtract the top system bar insets so the offset is
// relative to the content area (below the status bar / cutout).
ViewCompat.getRootWindowInsets(v)?.apply {
val insets =
getInsets(
WindowInsetsCompat.Type.statusBars() or WindowInsetsCompat.Type.displayCutout()
)

locationInWindow[0] -= insets.left
locationInWindow[1] -= insets.top
}
}

return Point(locationInWindow[0], locationInWindow[1])
}
}
Loading