Title: [295628] trunk/Source/WebCore
Revision
295628
Author
wenson_hs...@apple.com
Date
2022-06-16 23:05:39 -0700 (Thu, 16 Jun 2022)

Log Message

[iOS] Callout bar is sometimes obscured when selecting Live Text in a fullscreen video in AVPlayerViewController
https://bugs.webkit.org/show_bug.cgi?id=241700
rdar://95310525

Reviewed by Tim Horton.

Even after the changes in r295052, `UITextEffectsWindow`-hosted text selection views (e.g. grabber
dots and callout bar) are still _sometimes_ obscured behind the fullscreen player view controller
window. This happens because UIKit may actually maintain multiple `UITextEffectsWindow`s at
different window levels (only one of which is used to host text selection UI for Live Text in
fullscreen videos). For instance, if the user focuses the unified field in Safari and selects or
edits text in the unified field, a `UITextEffectsWindow` with a window level of 1.0 will be
instantiated; if this happens prior to triggering Live Text for a fullscreen video, this text
effects window may be reused for Live Text.

In cases where this `.windowLevel = 1.0` text effects window is used, the window used for the player
view controller (which currently has a level of `UITextEffectsBeneathStatusBarWindowLevel - 1`) will
be above the rest of the Live Text selection UI, which causes this bug to occur.

Mitigate this by explicitly grabbing the `UITextEffectsWindow` that corresponds to the player view's
window using `+sharedTextEffectsWindowForWindowScene:`, and setting the player view window's level
to a value that's right below this text effects window.

* Source/WebCore/PAL/pal/ios/UIKitSoftLink.h:
* Source/WebCore/PAL/pal/ios/UIKitSoftLink.mm:
* Source/WebCore/PAL/pal/spi/ios/UIKitSPI.h:
* Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.mm:
(VideoFullscreenInterfaceAVKit::doSetup):

Canonical link: https://commits.webkit.org/251633@main

Modified Paths

Diff

Modified: trunk/Source/WebCore/PAL/pal/ios/UIKitSoftLink.h (295627 => 295628)


--- trunk/Source/WebCore/PAL/pal/ios/UIKitSoftLink.h	2022-06-17 05:26:58 UTC (rev 295627)
+++ trunk/Source/WebCore/PAL/pal/ios/UIKitSoftLink.h	2022-06-17 06:05:39 UTC (rev 295628)
@@ -58,6 +58,7 @@
 SOFT_LINK_CLASS_FOR_HEADER(PAL, UIPasteboard)
 SOFT_LINK_CLASS_FOR_HEADER(PAL, UIScreen)
 SOFT_LINK_CLASS_FOR_HEADER(PAL, UITapGestureRecognizer)
+SOFT_LINK_CLASS_FOR_HEADER(PAL, UITextEffectsWindow)
 SOFT_LINK_CLASS_FOR_HEADER(PAL, UITraitCollection)
 SOFT_LINK_CLASS_FOR_HEADER(PAL, UIView)
 SOFT_LINK_CLASS_FOR_HEADER(PAL, UIViewController)

Modified: trunk/Source/WebCore/PAL/pal/ios/UIKitSoftLink.mm (295627 => 295628)


--- trunk/Source/WebCore/PAL/pal/ios/UIKitSoftLink.mm	2022-06-17 05:26:58 UTC (rev 295627)
+++ trunk/Source/WebCore/PAL/pal/ios/UIKitSoftLink.mm	2022-06-17 06:05:39 UTC (rev 295628)
@@ -58,6 +58,7 @@
 SOFT_LINK_CLASS_FOR_SOURCE(PAL, UIKit, UIPasteboard)
 SOFT_LINK_CLASS_FOR_SOURCE(PAL, UIKit, UIScreen)
 SOFT_LINK_CLASS_FOR_SOURCE(PAL, UIKit, UITapGestureRecognizer)
+SOFT_LINK_CLASS_FOR_SOURCE(PAL, UIKit, UITextEffectsWindow)
 SOFT_LINK_CLASS_FOR_SOURCE(PAL, UIKit, UITraitCollection)
 SOFT_LINK_CLASS_FOR_SOURCE(PAL, UIKit, UIView)
 SOFT_LINK_CLASS_FOR_SOURCE(PAL, UIKit, UIViewController)

Modified: trunk/Source/WebCore/PAL/pal/spi/ios/UIKitSPI.h (295627 => 295628)


--- trunk/Source/WebCore/PAL/pal/spi/ios/UIKitSPI.h	2022-06-17 05:26:58 UTC (rev 295627)
+++ trunk/Source/WebCore/PAL/pal/spi/ios/UIKitSPI.h	2022-06-17 06:05:39 UTC (rev 295628)
@@ -43,6 +43,7 @@
 #import <UIKit/UIInterface_Private.h>
 #import <UIKit/UIPasteboard_Private.h>
 #import <UIKit/UIScreen_Private.h>
+#import <UIKit/UITextEffectsWindow.h>
 #import <UIKit/UIViewController_Private.h>
 #import <UIKit/NSItemProvider+UIKitAdditions.h>
 #import <UIKit/NSItemProvider+UIKitAdditions_Private.h>
@@ -173,6 +174,16 @@
 + (CGFloat)alphaThreshold;
 @end
 
+@interface UIApplicationRotationFollowingWindow : UIWindow
+@end
+
+@interface UIAutoRotatingWindow : UIApplicationRotationFollowingWindow
+@end
+
+@interface UITextEffectsWindow : UIAutoRotatingWindow
++ (UITextEffectsWindow *)sharedTextEffectsWindowForWindowScene:(UIWindowScene *)windowScene;
+@end
+
 #endif // USE(APPLE_INTERNAL_SDK)
 
 @interface UIColor (IPI)

Modified: trunk/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.mm (295627 => 295628)


--- trunk/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.mm	2022-06-17 05:26:58 UTC (rev 295627)
+++ trunk/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.mm	2022-06-17 06:05:39 UTC (rev 295628)
@@ -1371,10 +1371,14 @@
         [[m_viewController view] setFrame:[m_window bounds]];
         [m_viewController _setIgnoreAppSupportedOrientations:YES];
         [m_window setRootViewController:m_viewController.get()];
-        [m_window setWindowLevel:PAL::get_UIKit_UITextEffectsBeneathStatusBarWindowLevel() - 1];
+        auto textEffectsWindowLevel = [&] {
+            auto *textEffectsWindow = [PAL::getUITextEffectsWindowClass() sharedTextEffectsWindowForWindowScene:[m_window windowScene]];
+            return textEffectsWindow ? textEffectsWindow.windowLevel : PAL::get_UIKit_UITextEffectsBeneathStatusBarWindowLevel();
+        }();
+        [m_window setWindowLevel:textEffectsWindowLevel - 1];
         [m_window makeKeyAndVisible];
     }
-#endif
+#endif // !PLATFORM(WATCHOS)
 
     if (!m_playerLayerView)
         m_playerLayerView = adoptNS([allocWebAVPlayerLayerViewInstance() init]);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to