Modified: trunk/Source/WebKit/ChangeLog (279286 => 279287)
--- trunk/Source/WebKit/ChangeLog 2021-06-25 15:42:07 UTC (rev 279286)
+++ trunk/Source/WebKit/ChangeLog 2021-06-25 16:31:29 UTC (rev 279287)
@@ -1,3 +1,39 @@
+2021-06-25 Peng Liu <[email protected]>
+
+ Explicitly invalidate WKFullScreenViewController after a video exits fullscreen
+ https://bugs.webkit.org/show_bug.cgi?id=227372
+
+ Reviewed by Eric Carlson.
+
+ Since `WKFullScreenWindowController` owns `WKFullScreenViewController`,
+ we had better let `WKFullScreenWindowController` manage the life cycle
+ of `WKFullScreenViewController`.
+
+ * UIProcess/ios/fullscreen/WKFullScreenViewController.h:
+ * UIProcess/ios/fullscreen/WKFullScreenViewController.mm:
+ (-[WKFullScreenViewController initWithWebView:]):
+ (-[WKFullScreenViewController invalidate]):
+ (-[WKFullScreenViewController dealloc]):
+ (-[WKFullScreenViewController showUI]):
+ (-[WKFullScreenViewController hideUI]):
+ (-[WKFullScreenViewController videoControlsManagerDidChange]):
+ (-[WKFullScreenViewController setAnimatingViewAlpha:]):
+ (-[WKFullScreenViewController setPrefersStatusBarHidden:]):
+ (-[WKFullScreenViewController setPrefersHomeIndicatorAutoHidden:]):
+ (-[WKFullScreenViewController setPlaying:]):
+ (-[WKFullScreenViewController setPictureInPictureActive:]):
+ (-[WKFullScreenViewController setAnimating:]):
+ (-[WKFullScreenViewController _manager]):
+ (-[WKFullScreenViewController _effectiveFullscreenInsets]):
+ (-[WKFullScreenViewController _cancelAction:]):
+ (-[WKFullScreenViewController _togglePiPAction:]):
+ (-[WKFullScreenViewController _touchDetected:]):
+ (-[WKFullScreenViewController _statusBarFrameDidChange:]):
+ (-[WKFullScreenViewController _updateWebViewFullscreenInsets]):
+ (-[WKFullScreenViewController _showPhishingAlert]):
+ * UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm:
+ (-[WKFullScreenWindowController _completedExitFullScreen]):
+
2021-06-25 Commit Queue <[email protected]>
Unreviewed, reverting r279266.
Modified: trunk/Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenViewController.h (279286 => 279287)
--- trunk/Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenViewController.h 2021-06-25 15:42:07 UTC (rev 279286)
+++ trunk/Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenViewController.h 2021-06-25 16:31:29 UTC (rev 279287)
@@ -42,6 +42,7 @@
@property (assign, nonatomic, getter=isAnimating) BOOL animating;
- (id)initWithWebView:(WKWebView *)webView;
+- (void)invalidate;
- (void)showUI;
- (void)hideUI;
- (void)videoControlsManagerDidChange;
Modified: trunk/Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenViewController.mm (279286 => 279287)
--- trunk/Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenViewController.mm 2021-06-25 15:42:07 UTC (rev 279286)
+++ trunk/Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenViewController.mm 2021-06-25 16:31:29 UTC (rev 279287)
@@ -39,6 +39,7 @@
#import <WebCore/LocalizedStrings.h>
#import <pal/spi/cocoa/AVKitSPI.h>
#import <wtf/RetainPtr.h>
+#import <wtf/WeakObjCPtr.h>
static const NSTimeInterval showHideAnimationDuration = 0.1;
static const NSTimeInterval pipHideAnimationDuration = 0.2;
@@ -52,7 +53,8 @@
void rateChanged(OptionSet<WebCore::PlaybackSessionModel::PlaybackState> playbackState, double /* playbackRate */, double /* defaultPlaybackRate */) override
{
- m_parent.playing = playbackState.contains(WebCore::PlaybackSessionModel::PlaybackState::Playing);
+ if (auto *controller = m_parent.getAutoreleased())
+ controller.playing = playbackState.contains(WebCore::PlaybackSessionModel::PlaybackState::Playing);
}
void isPictureInPictureSupportedChanged(bool) override
@@ -61,7 +63,8 @@
void pictureInPictureActiveChanged(bool active) override
{
- m_parent.pictureInPictureActive = active;
+ if (auto *controller = m_parent.getAutoreleased())
+ controller.pictureInPictureActive = active;
}
void setInterface(WebCore::PlaybackSessionInterfaceAVKit* interface)
@@ -77,7 +80,7 @@
}
private:
- WKFullScreenViewController *m_parent { nullptr };
+ WeakObjCPtr<WKFullScreenViewController> m_parent;
RefPtr<WebCore::PlaybackSessionInterfaceAVKit> m_interface;
};
@@ -109,6 +112,7 @@
@end
@implementation WKFullScreenViewController {
+ BOOL _valid;
RetainPtr<UILongPressGestureRecognizer> _touchGestureRecognizer;
RetainPtr<UIView> _animatingView;
RetainPtr<WKFullscreenStackView> _stackView;
@@ -142,18 +146,28 @@
self._webView = webView;
_playbackClient.setParent(self);
+ _valid = YES;
return self;
}
-- (void)dealloc
+- (void)invalidate
{
- [NSObject cancelPreviousPerformRequestsWithTarget:self];
+ if (!_valid)
+ return;
+
+ _valid = NO;
+
+ [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(hideUI) object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self];
-
_playbackClient.setParent(nullptr);
_playbackClient.setInterface(nullptr);
+}
+- (void)dealloc
+{
+ [self invalidate];
+
[_target release];
[_location release];
@@ -162,6 +176,7 @@
- (void)showUI
{
+ ASSERT(_valid);
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(hideUI) object:nil];
if (_playing) {
@@ -184,6 +199,7 @@
- (void)hideUI
{
+ ASSERT(_valid);
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(hideUI) object:nil];
[UIView animateWithDuration:showHideAnimationDuration animations:^{
@@ -206,6 +222,7 @@
- (void)videoControlsManagerDidChange
{
+ ASSERT(_valid);
auto page = [self._webView _page];
auto* videoFullscreenManager = page ? page->videoFullscreenManager() : nullptr;
auto* videoFullscreenInterface = videoFullscreenManager ? videoFullscreenManager->controlsManagerInterface() : nullptr;
@@ -224,6 +241,7 @@
- (void)setAnimatingViewAlpha:(CGFloat)alpha
{
+ ASSERT(_valid);
[UIView animateWithDuration:pipHideAnimationDuration animations:^{
_animatingView.get().alpha = alpha;
}];
@@ -231,6 +249,7 @@
- (void)setPrefersStatusBarHidden:(BOOL)value
{
+ ASSERT(_valid);
_prefersStatusBarHidden = value;
[self setNeedsStatusBarAppearanceUpdate];
[self _updateWebViewFullscreenInsets];
@@ -238,6 +257,7 @@
- (void)setPrefersHomeIndicatorAutoHidden:(BOOL)value
{
+ ASSERT(_valid);
_prefersHomeIndicatorAutoHidden = value;
[self setNeedsUpdateOfHomeIndicatorAutoHidden];
}
@@ -244,6 +264,7 @@
- (void)setPlaying:(BOOL)isPlaying
{
+ ASSERT(_valid);
if (_playing == isPlaying)
return;
@@ -263,6 +284,7 @@
- (void)setPictureInPictureActive:(BOOL)active
{
+ ASSERT(_valid);
if (_pictureInPictureActive == active)
return;
@@ -272,6 +294,7 @@
- (void)setAnimating:(BOOL)animating
{
+ ASSERT(_valid);
if (_animating == animating)
return;
_animating = animating;
@@ -418,6 +441,7 @@
@dynamic _manager;
- (WebKit::WebFullScreenManagerProxy*)_manager
{
+ ASSERT(_valid);
if (auto page = [self._webView _page])
return page->fullScreenManager();
return nullptr;
@@ -426,6 +450,7 @@
@dynamic _effectiveFullscreenInsets;
- (WebCore::FloatBoxExtent)_effectiveFullscreenInsets
{
+ ASSERT(_valid);
auto safeAreaInsets = self.view.safeAreaInsets;
WebCore::FloatBoxExtent insets { safeAreaInsets.top, safeAreaInsets.right, safeAreaInsets.bottom, safeAreaInsets.left };
@@ -437,11 +462,13 @@
- (void)_cancelAction:(id)sender
{
+ ASSERT(_valid);
[[self target] performSelector:[self exitFullScreenAction]];
}
- (void)_togglePiPAction:(id)sender
{
+ ASSERT(_valid);
auto page = [self._webView _page];
if (!page)
return;
@@ -463,6 +490,7 @@
- (void)_touchDetected:(id)sender
{
+ ASSERT(_valid);
if ([_touchGestureRecognizer state] == UIGestureRecognizerStateEnded) {
double score = _secheuristic.scoreOfNextTouch([_touchGestureRecognizer locationInView:self.view]);
if (score > _secheuristic.requiredScore())
@@ -474,6 +502,7 @@
- (void)_statusBarFrameDidChange:(NSNotificationCenter *)notification
{
+ ASSERT(_valid);
ALLOW_DEPRECATED_DECLARATIONS_BEGIN
CGFloat height = UIApplication.sharedApplication.statusBarFrame.size.height;
ALLOW_DEPRECATED_DECLARATIONS_END
@@ -486,6 +515,7 @@
- (void)_updateWebViewFullscreenInsets
{
+ ASSERT(_valid);
if (auto* manager = self._manager)
manager->setFullscreenInsets(self._effectiveFullscreenInsets);
}
@@ -492,6 +522,7 @@
- (void)_showPhishingAlert
{
+ ASSERT(_valid);
NSString *alertTitle = WEB_UI_STRING("It looks like you are typing while in full screen", "Full Screen Deceptive Website Warning Sheet Title");
NSString *alertMessage = [NSString stringWithFormat:WEB_UI_STRING("Typing is not allowed in full screen websites. “%@” may be showing a fake keyboard to trick you into disclosing personal or financial information.", "Full Screen Deceptive Website Warning Sheet Content Text"), (NSString *)self.location];
UIAlertController* alert = [UIAlertController alertControllerWithTitle:alertTitle message:alertMessage preferredStyle:UIAlertControllerStyleAlert];