From 2c1245a04f985724ba49c73e84437d78bf295055 Mon Sep 17 00:00:00 2001
From: Peter E Conn <peconn@chromium.org>
Date: Wed, 7 May 2025 06:50:42 -0700
Subject: [PATCH] Move DisplayCutoutController tracking to AwViewMethodsImpl.

This change calls DisplayCutoutController#onAttachedToWindow when either
the WebView is attached to the window, or the FullScreenView is attached
to the window (whichever the AwContents is displaying to).

This is a change in behaviour, but should be more correct. There likely
wasn't an issue beforehand because when switching to full screen,
DisplayCutoutController#setCurrentContainerView was called, which also
requested full screen insets.

Bug: 380261043
Change-Id: I23a607b6450bb53cd37644e5a62ab708c97dfe90
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6513140
Reviewed-by: Peter Pakkenberg <pbirk@chromium.org>
Commit-Queue: Peter Conn <peconn@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1456964}
---
 .../java/src/org/chromium/android_webview/AwContents.java     | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/android_webview/java/src/org/chromium/android_webview/AwContents.java b/android_webview/java/src/org/chromium/android_webview/AwContents.java
index 844d7db695e48..9ac8ef519a09d 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
@@ -3351,8 +3351,6 @@ public class AwContents implements SmartClipProvider {
         // instead attached to a FullScreenView.
         mAwViewMethods.onAttachedToWindow();
 
-        if (mDisplayCutoutController != null) mDisplayCutoutController.onAttachedToWindow();
-
         mAwFrameMetricsListener =
                 AwFrameMetricsListener.maybeCreate(
                         mContainerView, mWindowAndroid.getWindowAndroid());
@@ -4650,6 +4648,8 @@ public class AwContents implements SmartClipProvider {
                 StylusWritingSettingsState.getInstance().registerObserver(mStylusWritingController);
             }
 
+            if (mDisplayCutoutController != null) mDisplayCutoutController.onAttachedToWindow();
+
             mAwWindowCoverageTracker =
                     AwWindowCoverageTracker.getOrCreateForRootView(
                             AwContents.this, mContainerView.getRootView());