Title: [257189] trunk/Source
Revision
257189
Author
jer.no...@apple.com
Date
2020-02-22 21:45:57 -0800 (Sat, 22 Feb 2020)

Log Message

Stop using QTKit for rendering WK1 video fullscreen controls
https://bugs.webkit.org/show_bug.cgi?id=207795
<rdar://problem/48894915>

Reviewed by Jon Lee.

Source/WebCore:

Drive-by fixes:

- Don't set the video layer to not-visible when in video fullscreen mode.
- Export previously un-exported methods.
- Make some ios-only classes available on mac.
- Add a couple previously unimplemented properties to WebAVPlayerController needed by AVKit.
- WebCoreFullscreenWindow doesn't depend on FULLSCREEN_API.

* WebCore.xcodeproj/project.pbxproj:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::visibilityStateChanged):
* html/HTMLMediaElement.h:
(WebCore::HTMLMediaElement::setVideoFullscreenLayer):
* platform/ios/PlaybackSessionInterfaceAVKit.h:
* platform/ios/PlaybackSessionInterfaceAVKit.mm:
(WebCore::PlaybackSessionInterfaceAVKit::externalPlaybackChanged):
* platform/ios/WebAVPlayerController.h:
* platform/ios/WebAVPlayerController.mm:
(-[WebAVPlayerController canSeekFrameBackward]):
(-[WebAVPlayerController canSeekFrameForward]):
* platform/mac/WebCoreFullScreenWindow.h:
* platform/mac/WebCoreFullScreenWindow.mm:

Source/WebCore/PAL:

* PAL.xcodeproj/project.pbxproj:
* pal/spi/cocoa/AVKitSPI.h:
* pal/spi/mac/NSWindowSPI.h:
* pal/spi/mac/QTKitSPI.h: Removed.

Source/WebKit:

Use NSWindowSPI.h rather than declaring SPI in the source file.

* UIProcess/mac/WKFullScreenWindowController.mm:

Source/WebKitLegacy/mac:

Switch to using AVPlayerView instead of QTHUD to render our fullscreen controls.

In addition, switch to a modern NSWindow fullscreen API, with custom, smooth animations which
move the fullscreen window to a separate space. This requires subclassing AVPlayerView so that
fullscreen toggling will signal to the controller, so that our fullscreen button and the inline
version of same don't get out of sync. Because AVPlayerView requires an AVPlayer in order to
display the video layer, and we won't necessarily have an AVPlayer for MSE-backed videos, instead
install a custom overlay view inside the AVPlayerView in which to host the fullscreen video layer.

* WebView/WebVideoFullscreenController.h:
* WebView/WebVideoFullscreenController.mm:
(-[WebOverlayLayer layoutSublayers]):
(WebAVPlayerView_delegate):
(WebAVPlayerView_setDelegate):
(WebAVPlayerView_isFullScreen):
(WebAVPlayerView_enterFullScreen):
(WebAVPlayerView_exitFullScreen):
(allocWebAVPlayerViewInstance):
(-[WebVideoFullscreenController init]):
(-[WebVideoFullscreenController dealloc]):
(-[WebVideoFullscreenController fullscreenWindow]):
(-[WebVideoFullscreenController windowDidLoad]):
(-[WebVideoFullscreenController setVideoElement:]):
(-[WebVideoFullscreenController enterFullscreen:]):
(-[WebVideoFullscreenController exitFullscreen]):
(-[WebVideoFullscreenController applicationDidResignActive:]):
(-[WebVideoFullscreenController _requestExit]):
(-[WebVideoFullscreenController _requestEnter]):
(-[WebVideoFullscreenController cancelOperation:]):
(-[WebVideoFullscreenController playerViewIsFullScreen:]):
(-[WebVideoFullscreenController playerViewRequestEnterFullscreen:]):
(-[WebVideoFullscreenController playerViewRequestExitFullscreen:]):
(-[WebVideoFullscreenController customWindowsToEnterFullScreenForWindow:]):
(-[WebVideoFullscreenController window:startCustomAnimationToEnterFullScreenWithDuration:]):
(-[WebVideoFullscreenController customWindowsToExitFullScreenForWindow:]):
(-[WebVideoFullscreenController window:startCustomAnimationToExitFullScreenWithDuration:]):
(-[WebVideoFullscreenController windowDidEnterFullScreen:]):
(-[WebVideoFullscreenController windowWillExitFullScreen:]):
(-[WebVideoFullscreenController windowDidExitFullScreen:]):
(-[WebVideoFullscreenController clearFadeAnimation]): Deleted.
(-[WebVideoFullscreenController windowDidExitFullscreen]): Deleted.
(-[WebVideoFullscreenController windowDidEnterFullscreen]): Deleted.
(frameExpandedToRatioOfFrame): Deleted.
(createBackgroundFullscreenWindow): Deleted.
(-[WebVideoFullscreenController setupFadeAnimationIfNeededAndFadeIn:]): Deleted.
(-[WebVideoFullscreenController applicationDidChangeScreenParameters:]): Deleted.
(-[WebVideoFullscreenController updateMenuAndDockForFullscreen]): Deleted.
(-[WebVideoFullscreenController requestExitFullscreenWithAnimation:]): Deleted.
(-[WebVideoFullscreenController requestExitFullscreen]): Deleted.
(-[WebVideoFullscreenController fadeHUDIn]): Deleted.
(-[WebVideoFullscreenController observeValueForKeyPath:ofObject:change:context:]): Deleted.
(-[WebVideoFullscreenController rateChanged:]): Deleted.
(-[WebVideoFullscreenWindow initWithContentRect:styleMask:backing:defer:]): Deleted.
(-[WebVideoFullscreenWindow dealloc]): Deleted.
(-[WebVideoFullscreenWindow resignFirstResponder]): Deleted.
(-[WebVideoFullscreenWindow canBecomeKeyWindow]): Deleted.
(-[WebVideoFullscreenWindow mouseDown:]): Deleted.
(-[WebVideoFullscreenWindow cancelOperation:]): Deleted.
(-[WebVideoFullscreenWindow animatedResizeDidEnd]): Deleted.
(-[WebVideoFullscreenWindow animateFromRect:toRect:withSubAnimation:controllerAction:]): Deleted.
(-[WebVideoFullscreenWindow animationDidEnd:]): Deleted.
(-[WebVideoFullscreenWindow mouseMoved:]): Deleted.
* WebView/WebVideoFullscreenHUDWindowController.h: Removed.
* WebView/WebVideoFullscreenHUDWindowController.mm: Removed.

Modified Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (257188 => 257189)


--- trunk/Source/WebCore/ChangeLog	2020-02-23 04:56:03 UTC (rev 257188)
+++ trunk/Source/WebCore/ChangeLog	2020-02-23 05:45:57 UTC (rev 257189)
@@ -1,3 +1,34 @@
+2020-02-22  Jer Noble  <jer.no...@apple.com>
+
+        Stop using QTKit for rendering WK1 video fullscreen controls
+        https://bugs.webkit.org/show_bug.cgi?id=207795
+        <rdar://problem/48894915>
+
+        Reviewed by Jon Lee.
+
+        Drive-by fixes:
+
+        - Don't set the video layer to not-visible when in video fullscreen mode.
+        - Export previously un-exported methods.
+        - Make some ios-only classes available on mac.
+        - Add a couple previously unimplemented properties to WebAVPlayerController needed by AVKit.
+        - WebCoreFullscreenWindow doesn't depend on FULLSCREEN_API.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::visibilityStateChanged):
+        * html/HTMLMediaElement.h:
+        (WebCore::HTMLMediaElement::setVideoFullscreenLayer):
+        * platform/ios/PlaybackSessionInterfaceAVKit.h:
+        * platform/ios/PlaybackSessionInterfaceAVKit.mm:
+        (WebCore::PlaybackSessionInterfaceAVKit::externalPlaybackChanged):
+        * platform/ios/WebAVPlayerController.h:
+        * platform/ios/WebAVPlayerController.mm:
+        (-[WebAVPlayerController canSeekFrameBackward]):
+        (-[WebAVPlayerController canSeekFrameForward]):
+        * platform/mac/WebCoreFullScreenWindow.h:
+        * platform/mac/WebCoreFullScreenWindow.mm:
+
 2020-02-22  Darin Adler  <da...@apple.com>
 
         Use DOM element iterators more, and more consistently

Modified: trunk/Source/WebCore/PAL/ChangeLog (257188 => 257189)


--- trunk/Source/WebCore/PAL/ChangeLog	2020-02-23 04:56:03 UTC (rev 257188)
+++ trunk/Source/WebCore/PAL/ChangeLog	2020-02-23 05:45:57 UTC (rev 257189)
@@ -1,3 +1,16 @@
+2020-02-22  Jer Noble  <jer.no...@apple.com>
+
+        Stop using QTKit for rendering WK1 video fullscreen controls
+        https://bugs.webkit.org/show_bug.cgi?id=207795
+        <rdar://problem/48894915>
+
+        Reviewed by Jon Lee.
+
+        * PAL.xcodeproj/project.pbxproj:
+        * pal/spi/cocoa/AVKitSPI.h:
+        * pal/spi/mac/NSWindowSPI.h:
+        * pal/spi/mac/QTKitSPI.h: Removed.
+
 2020-02-21  Wenson Hsieh  <wenson_hs...@apple.com>
 
         [macOS] Large form controls are rendered at the wrong NSControlSize

Modified: trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj (257188 => 257189)


--- trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj	2020-02-23 04:56:03 UTC (rev 257188)
+++ trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj	2020-02-23 05:45:57 UTC (rev 257189)
@@ -95,7 +95,6 @@
 		0C77859C1F45130F00F4EBB6 /* NSViewSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 0C7785831F45130F00F4EBB6 /* NSViewSPI.h */; };
 		0C77859D1F45130F00F4EBB6 /* NSWindowSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 0C7785841F45130F00F4EBB6 /* NSWindowSPI.h */; };
 		0C77859E1F45130F00F4EBB6 /* PIPSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 0C7785851F45130F00F4EBB6 /* PIPSPI.h */; };
-		0C77859F1F45130F00F4EBB6 /* QTKitSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 0C7785861F45130F00F4EBB6 /* QTKitSPI.h */; };
 		0C7785A01F45130F00F4EBB6 /* QuickLookMacSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 0C7785871F45130F00F4EBB6 /* QuickLookMacSPI.h */; };
 		0C7785A11F45130F00F4EBB6 /* TelephonyUtilitiesSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 0C7785881F45130F00F4EBB6 /* TelephonyUtilitiesSPI.h */; };
 		0CF99CA41F736375007EE793 /* MediaTimeAVFoundation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0C00CFD11F68CE4600AAC26D /* MediaTimeAVFoundation.cpp */; };
@@ -264,7 +263,6 @@
 		0C7785831F45130F00F4EBB6 /* NSViewSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSViewSPI.h; sourceTree = "<group>"; };
 		0C7785841F45130F00F4EBB6 /* NSWindowSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSWindowSPI.h; sourceTree = "<group>"; };
 		0C7785851F45130F00F4EBB6 /* PIPSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PIPSPI.h; sourceTree = "<group>"; };
-		0C7785861F45130F00F4EBB6 /* QTKitSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QTKitSPI.h; sourceTree = "<group>"; };
 		0C7785871F45130F00F4EBB6 /* QuickLookMacSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QuickLookMacSPI.h; sourceTree = "<group>"; };
 		0C7785881F45130F00F4EBB6 /* TelephonyUtilitiesSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TelephonyUtilitiesSPI.h; sourceTree = "<group>"; };
 		0CF99CA61F738436007EE793 /* CoreMediaSoftLink.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CoreMediaSoftLink.cpp; sourceTree = "<group>"; };
@@ -513,7 +511,6 @@
 				0C7785831F45130F00F4EBB6 /* NSViewSPI.h */,
 				0C7785841F45130F00F4EBB6 /* NSWindowSPI.h */,
 				0C7785851F45130F00F4EBB6 /* PIPSPI.h */,
-				0C7785861F45130F00F4EBB6 /* QTKitSPI.h */,
 				0C7785871F45130F00F4EBB6 /* QuickLookMacSPI.h */,
 				A1175B481F6AFF8E00C4B9F0 /* SpeechSynthesisSPI.h */,
 				0C7785881F45130F00F4EBB6 /* TelephonyUtilitiesSPI.h */,
@@ -817,7 +814,6 @@
 				0C77859E1F45130F00F4EBB6 /* PIPSPI.h in Headers */,
 				A1175B4E1F6B337300C4B9F0 /* PopupMenu.h in Headers */,
 				0C2DA1561F3BEB4900DBC317 /* pthreadSPI.h in Headers */,
-				0C77859F1F45130F00F4EBB6 /* QTKitSPI.h in Headers */,
 				0C2DA1571F3BEB4900DBC317 /* QuartzCoreSPI.h in Headers */,
 				0C7785A01F45130F00F4EBB6 /* QuickLookMacSPI.h in Headers */,
 				4450FCA021F5F602004DFA56 /* QuickLookSoftLink.h in Headers */,

Modified: trunk/Source/WebCore/PAL/pal/spi/cocoa/AVKitSPI.h (257188 => 257189)


--- trunk/Source/WebCore/PAL/pal/spi/cocoa/AVKitSPI.h	2020-02-23 04:56:03 UTC (rev 257188)
+++ trunk/Source/WebCore/PAL/pal/spi/cocoa/AVKitSPI.h	2020-02-23 05:45:57 UTC (rev 257189)
@@ -26,7 +26,35 @@
 #import <objc/runtime.h>
 #import <wtf/SoftLinking.h>
 
+#if USE(APPLE_INTERNAL_SDK)
+#import <AVKit/AVPlayerController.h>
+#else
 #if PLATFORM(IOS_FAMILY)
+#import <UIKit/UIResponder.h>
+@interface AVPlayerController : UIResponder
+#else
+#import <AppKit/NSResponder.h>
+@interface AVPlayerController : NSResponder <NSUserInterfaceValidations>
+#endif
+@end
+
+@interface AVPlayerController ()
+typedef NS_ENUM(NSInteger, AVPlayerControllerStatus) {
+    AVPlayerControllerStatusUnknown = 0,
+    AVPlayerControllerStatusReadyToPlay = 2,
+};
+
+typedef NS_ENUM(NSInteger, AVPlayerControllerExternalPlaybackType) {
+    AVPlayerControllerExternalPlaybackTypeNone = 0,
+    AVPlayerControllerExternalPlaybackTypeAirPlay = 1,
+    AVPlayerControllerExternalPlaybackTypeTVOut = 2,
+};
+
+@property (NS_NONATOMIC_IOSONLY, readonly) AVPlayerControllerStatus status;
+@end
+#endif // USE(APPLE_INTERNAL_SDK)
+
+#if PLATFORM(IOS_FAMILY)
 #import <AVKit/AVKit.h>
 #import <QuartzCore/QuartzCore.h>
 #import <UIKit/UIKit.h>
@@ -37,7 +65,6 @@
 #import <AVKit/AVBackgroundView.h>
 #endif
 
-#import <AVKit/AVPlayerController.h>
 IGNORE_WARNINGS_BEGIN("objc-property-no-attribute")
 #import <AVKit/AVPlayerLayerView.h>
 IGNORE_WARNINGS_END
@@ -115,24 +142,6 @@
 - (void)addSubview:(UIView *)subview applyingMaterialStyle:(AVBackgroundViewMaterialStyle)materialStyle tintEffectStyle:(AVBackgroundViewTintEffectStyle)tintEffectStyle;
 @end
 
-@interface AVPlayerController : UIResponder
-@end
-
-@interface AVPlayerController ()
-typedef NS_ENUM(NSInteger, AVPlayerControllerStatus) {
-    AVPlayerControllerStatusUnknown = 0,
-    AVPlayerControllerStatusReadyToPlay = 2,
-};
-
-typedef NS_ENUM(NSInteger, AVPlayerControllerExternalPlaybackType) {
-    AVPlayerControllerExternalPlaybackTypeNone = 0,
-    AVPlayerControllerExternalPlaybackTypeAirPlay = 1,
-    AVPlayerControllerExternalPlaybackTypeTVOut = 2,
-};
-
-@property (NS_NONATOMIC_IOSONLY, readonly) AVPlayerControllerStatus status;
-@end
-
 @class AVPlayerLayer;
 
 @interface AVPictureInPicturePlayerLayerView : UIView
@@ -178,6 +187,26 @@
 #endif // USE(APPLE_INTERNAL_SDK)
 #endif // PLATFORM(IOS_FAMILY)
 
+#if PLATFORM(MAC)
+#if USE(APPLE_INTERNAL_SDK)
+#import <AVKit/AVPlayerView_Private.h>
+#else
+#import <AVKit/AVPlayerView.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface AVPlayerView (WebKitFullscreenSPI)
+@property AVPlayerController *playerController;
+@property (readonly) BOOL isFullScreen;
+- (void)enterFullScreen:(id)sender;
+- (void)exitFullScreen:(id)sender;
+@end
+
+NS_ASSUME_NONNULL_END
+
+#endif // USE(APPLE_INTERNAL_SDK)
+#endif // PLATFORM(MAC)
+
 #if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS_FAMILY)
 
 #if USE(APPLE_INTERNAL_SDK)

Modified: trunk/Source/WebCore/PAL/pal/spi/mac/NSWindowSPI.h (257188 => 257189)


--- trunk/Source/WebCore/PAL/pal/spi/mac/NSWindowSPI.h	2020-02-23 04:56:03 UTC (rev 257188)
+++ trunk/Source/WebCore/PAL/pal/spi/mac/NSWindowSPI.h	2020-02-23 05:45:57 UTC (rev 257189)
@@ -40,7 +40,8 @@
 - (id)_oldFirstResponderBeforeBecoming;
 - (id)_newFirstResponderAfterResigning;
 - (void)_setCursorForMouseLocation:(NSPoint)point;
-
+- (void)exitFullScreenMode:(id)sender;
+- (void)enterFullScreenMode:(id)sender;
 @end
 
 enum {

Deleted: trunk/Source/WebCore/PAL/pal/spi/mac/QTKitSPI.h (257188 => 257189)


--- trunk/Source/WebCore/PAL/pal/spi/mac/QTKitSPI.h	2020-02-23 04:56:03 UTC (rev 257188)
+++ trunk/Source/WebCore/PAL/pal/spi/mac/QTKitSPI.h	2020-02-23 05:45:57 UTC (rev 257189)
@@ -1,150 +0,0 @@
-/*
- * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#if USE(APPLE_INTERNAL_SDK)
-
-#import <QTKit/QTHUDBackgroundView_Private.h>
-#import <QTKit/QTKit_Private.h>
-#import <QTKit/QTUtilities_Private.h>
-
-#else
-
-enum {
-    kQTTimeIsIndefinite = 1 << 0
-};
-
-typedef struct {
-    long long timeValue;
-    long timeScale;
-    long flags;
-} QTTime;
-
-typedef struct {
-    QTTime time;
-    QTTime duration;
-} QTTimeRange;
-
-typedef enum {
-    QTIncludeCommonTypes = 0,
-    QTIncludeOnlyFigMediaFileTypes = 1 << 8,
-} QTMovieFileTypeOptions;
-
-enum {
-    QTMovieTypeUnknown = 0,
-    QTMovieTypeLocal,
-    QTMovieTypeFastStart,
-    QTMovieTypeLiveStream,
-    QTMovieTypeStoredStream
-};
-
-@class QTTrack;
-
-@interface QTMedia : NSObject
-
-- (id)attributeForKey:(NSString *)attributeKey;
-
-@end
-
-@interface QTMovie : NSObject <NSCoding, NSCopying>
-
-+ (NSArray *)movieFileTypes:(QTMovieFileTypeOptions)types;
-
-+ (void)disableComponent:(ComponentDescription)component;
-
-- (id)initWithAttributes:(NSDictionary *)attributes error:(NSError **)errorPtr;
-
-- (void)play;
-- (void)stop;
-
-- (QTTime)duration;
-
-- (QTTime)currentTime;
-- (void)setCurrentTime:(QTTime)time;
-
-- (float)rate;
-- (void)setRate:(float)rate;
-
-- (float)volume;
-- (void)setVolume:(float)volume;
-
-- (NSDictionary *)movieAttributes;
-
-- (id)attributeForKey:(NSString *)attributeKey;
-- (void)setAttribute:(id)value forKey:(NSString *)attributeKey;
-
-- (NSArray *)tracks;
-
-- (NSArray *)alternateGroupTypes;
-- (NSArray *)alternatesForMediaType:(NSString *)type;
-- (void)deselectAlternateGroupTrack:(QTTrack *)alternateTrack;
-- (void)selectAlternateGroupTrack:(QTTrack *)alternateTrack;
-
-- (NSURL *)URL;
-- (UInt32)movieType;
-
-@end
-
-@interface QTMovieLayer : CALayer
-
-- (void)setMovie:(QTMovie *)movie;
-- (QTMovie *)movie;
-
-@end
-
-@interface NSValue (NSValueQTTimeRangeExtensions)
-+ (NSValue *)valueWithQTTimeRange:(QTTimeRange)range;
-- (QTTimeRange)QTTimeRangeValue;
-@end
-
-@interface QTTrack : NSObject
-
-- (QTMedia *)media;
-
-- (BOOL)isEnabled;
-- (void)setEnabled:(BOOL)enabled;
-
-- (id)attributeForKey:(NSString *)attributeKey;
-
-@end
-
-@interface QTHUDBackgroundView : NSView
-
-- (void)setContentBorderPosition:(CGFloat)contentBorderPosition;
-
-@end
-
-@interface QTUtilities : NSObject
-
-+ (id)qtUtilities;
-
-- (NSArray *)sitesInDownloadCache;
-- (void)clearDownloadCache;
-- (void)clearDownloadCacheForSite:(NSString *)site;
-
-@end
-
-#endif

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (257188 => 257189)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-02-23 04:56:03 UTC (rev 257188)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-02-23 05:45:57 UTC (rev 257189)
@@ -4131,6 +4131,7 @@
 		CDAB6D2917C7DE6C00C60B34 /* MediaControlsHost.h in Headers */ = {isa = PBXBuildFile; fileRef = CDAB6D2717C7DE6C00C60B34 /* MediaControlsHost.h */; };
 		CDAB6D2E17C814EE00C60B34 /* JSMediaControlsHost.h in Headers */ = {isa = PBXBuildFile; fileRef = CDAB6D2C17C814EE00C60B34 /* JSMediaControlsHost.h */; };
 		CDAB6D3117C9259500C60B34 /* UserAgentScripts.h in Headers */ = {isa = PBXBuildFile; fileRef = CDAB6D2F17C9259500C60B34 /* UserAgentScripts.h */; };
+		CDB6354923F6023A00C0F9DE /* WebAVPlayerController.h in Headers */ = {isa = PBXBuildFile; fileRef = CDA29A2C1CBF73FC00901CCF /* WebAVPlayerController.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		CDB7045A1F7465A1003923DF /* CDMFairPlayStreaming.h in Headers */ = {isa = PBXBuildFile; fileRef = CDB704581F7465A1003923DF /* CDMFairPlayStreaming.h */; };
 		CDB7045B1F7465A1003923DF /* CDMFairPlayStreaming.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDB704591F7465A1003923DF /* CDMFairPlayStreaming.cpp */; };
 		CDBEAEAC19D92B6C00BEBA88 /* MediaSelectionGroupAVFObjC.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDBEAEAA19D92B6C00BEBA88 /* MediaSelectionGroupAVFObjC.mm */; };
@@ -32913,6 +32914,7 @@
 				07D637401BB0B11300256CE9 /* WebAudioSourceProviderAVFObjC.h in Headers */,
 				574F55E1204F3B23002948C6 /* WebAuthenticationConstants.h in Headers */,
 				57152B8021DDA581000C37CA /* WebAuthenticationUtils.h in Headers */,
+				CDB6354923F6023A00C0F9DE /* WebAVPlayerController.h in Headers */,
 				1F36EA9C1E21BA1700621E25 /* WebBackgroundTaskController.h in Headers */,
 				A5B81CB51FAA44620037D1E6 /* WebConsoleAgent.h in Headers */,
 				9BBA2CAB1F679E0C00FD1C1E /* WebContentReader.h in Headers */,

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (257188 => 257189)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2020-02-23 04:56:03 UTC (rev 257188)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2020-02-23 05:45:57 UTC (rev 257189)
@@ -5793,7 +5793,7 @@
 
 void HTMLMediaElement::visibilityStateChanged()
 {
-    bool elementIsHidden = document().hidden() && m_videoFullscreenMode != VideoFullscreenModePictureInPicture;
+    bool elementIsHidden = document().hidden() && m_videoFullscreenMode == VideoFullscreenModeNone;
     if (elementIsHidden == m_elementIsHidden)
         return;
 

Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (257188 => 257189)


--- trunk/Source/WebCore/html/HTMLMediaElement.h	2020-02-23 04:56:03 UTC (rev 257188)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h	2020-02-23 05:45:57 UTC (rev 257189)
@@ -181,7 +181,7 @@
     void setPreparedToReturnVideoLayerToInline(bool);
     void waitForPreparedForInlineThen(WTF::Function<void()>&& completionHandler = [] { });
 #if PLATFORM(IOS_FAMILY) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
-    void setVideoFullscreenLayer(PlatformLayer*, WTF::Function<void()>&& completionHandler = [] { });
+    WEBCORE_EXPORT void setVideoFullscreenLayer(PlatformLayer*, WTF::Function<void()>&& completionHandler = [] { });
 #ifdef __OBJC__
     PlatformLayer* videoFullscreenLayer() const { return m_videoFullscreenLayer.get(); }
 #endif
@@ -446,7 +446,7 @@
     virtual void fullscreenModeChanged(VideoFullscreenMode);
 
     void enterFullscreen(VideoFullscreenMode);
-    void enterFullscreen() override;
+    WEBCORE_EXPORT void enterFullscreen() override;
     WEBCORE_EXPORT void exitFullscreen();
     WEBCORE_EXPORT void setVideoFullscreenStandby(bool);
 

Modified: trunk/Source/WebCore/platform/ios/PlaybackSessionInterfaceAVKit.h (257188 => 257189)


--- trunk/Source/WebCore/platform/ios/PlaybackSessionInterfaceAVKit.h	2020-02-23 04:56:03 UTC (rev 257188)
+++ trunk/Source/WebCore/platform/ios/PlaybackSessionInterfaceAVKit.h	2020-02-23 05:45:57 UTC (rev 257189)
@@ -26,7 +26,7 @@
 
 #pragma once
 
-#if PLATFORM(IOS_FAMILY)
+#if HAVE(AVKIT)
 
 #include "EventListener.h"
 #include "HTMLMediaElementEnums.h"
@@ -41,10 +41,6 @@
 #include <wtf/RetainPtr.h>
 
 OBJC_CLASS WebAVPlayerController;
-OBJC_CLASS AVPlayerViewController;
-OBJC_CLASS UIViewController;
-OBJC_CLASS UIWindow;
-OBJC_CLASS UIView;
 
 namespace WebCore {
 class IntRect;
@@ -92,5 +88,4 @@
 
 }
 
-#endif
-
+#endif // HAVE(AVKIT)

Modified: trunk/Source/WebCore/platform/ios/PlaybackSessionInterfaceAVKit.mm (257188 => 257189)


--- trunk/Source/WebCore/platform/ios/PlaybackSessionInterfaceAVKit.mm	2020-02-23 04:56:03 UTC (rev 257188)
+++ trunk/Source/WebCore/platform/ios/PlaybackSessionInterfaceAVKit.mm	2020-02-23 05:45:57 UTC (rev 257189)
@@ -27,7 +27,6 @@
 #import "config.h"
 #import "PlaybackSessionInterfaceAVKit.h"
 
-#if PLATFORM(IOS_FAMILY)
 #if HAVE(AVKIT)
 
 #import "Logging.h"
@@ -185,9 +184,9 @@
 void PlaybackSessionInterfaceAVKit::externalPlaybackChanged(bool enabled, PlaybackSessionModel::ExternalPlaybackTargetType targetType, const String& localizedDeviceName)
 {
     AVPlayerControllerExternalPlaybackType externalPlaybackType = AVPlayerControllerExternalPlaybackTypeNone;
-    if (targetType == PlaybackSessionModel::TargetTypeAirPlay)
+    if (enabled && targetType == PlaybackSessionModel::TargetTypeAirPlay)
         externalPlaybackType = AVPlayerControllerExternalPlaybackTypeAirPlay;
-    else if (targetType == PlaybackSessionModel::TargetTypeTVOut)
+    else if (enabled && targetType == PlaybackSessionModel::TargetTypeTVOut)
         externalPlaybackType = AVPlayerControllerExternalPlaybackTypeTVOut;
 
     WebAVPlayerController* playerController = m_playerController.get();
@@ -231,4 +230,3 @@
 }
 
 #endif // HAVE(AVKIT)
-#endif // PLATFORM(IOS_FAMILY)

Modified: trunk/Source/WebCore/platform/ios/WebAVPlayerController.h (257188 => 257189)


--- trunk/Source/WebCore/platform/ios/WebAVPlayerController.h	2020-02-23 04:56:03 UTC (rev 257188)
+++ trunk/Source/WebCore/platform/ios/WebAVPlayerController.h	2020-02-23 05:45:57 UTC (rev 257189)
@@ -23,7 +23,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#if PLATFORM(IOS_FAMILY) && HAVE(AVKIT)
+#if HAVE(AVKIT)
 
 #import <pal/spi/cocoa/AVKitSPI.h>
 
@@ -36,7 +36,7 @@
 @property (retain) NSString *localizedDisplayName;
 @end
 
-@interface WebAVPlayerController : NSObject {
+WEBCORE_EXPORT @interface WebAVPlayerController : NSObject {
     WebAVMediaSelectionOption *_currentAudioMediaSelectionOption;
     WebAVMediaSelectionOption *_currentLegibleMediaSelectionOption;
     BOOL _pictureInPictureInterrupted;
@@ -52,6 +52,9 @@
 @property (readonly) BOOL canSeekToBeginning;
 @property (readonly) BOOL canSeekToEnd;
 @property (readonly) BOOL isScrubbing;
+@property (readonly) BOOL canSeekFrameBackward;
+@property (readonly) BOOL canSeekFrameForward;
+@property (readonly) BOOL hasContentChapters;
 
 @property BOOL canPlay;
 @property (getter=isPlaying) BOOL playing;
@@ -100,4 +103,3 @@
 @end
 
 #endif
-

Modified: trunk/Source/WebCore/platform/ios/WebAVPlayerController.mm (257188 => 257189)


--- trunk/Source/WebCore/platform/ios/WebAVPlayerController.mm	2020-02-23 04:56:03 UTC (rev 257188)
+++ trunk/Source/WebCore/platform/ios/WebAVPlayerController.mm	2020-02-23 05:45:57 UTC (rev 257189)
@@ -27,7 +27,7 @@
 #import "config.h"
 #import "WebAVPlayerController.h"
 
-#if PLATFORM(IOS_FAMILY) && HAVE(AVKIT)
+#if HAVE(AVKIT)
 
 #import "Logging.h"
 #import "PlaybackSessionInterfaceAVKit.h"
@@ -397,6 +397,16 @@
     [self seekToEnd:sender];
 }
 
+- (BOOL)canSeekFrameBackward
+{
+    return YES;
+}
+
+- (BOOL)canSeekFrameForward
+{
+    return YES;
+}
+
 - (BOOL)hasMediaSelectionOptions
 {
     return [self hasAudioMediaSelectionOptions] || [self hasLegibleMediaSelectionOptions];
@@ -650,5 +660,5 @@
 
 @end
 
-#endif // PLATFORM(IOS_FAMILY)
+#endif // HAVE(AVKIT)
 

Modified: trunk/Source/WebCore/platform/mac/WebCoreFullScreenWindow.h (257188 => 257189)


--- trunk/Source/WebCore/platform/mac/WebCoreFullScreenWindow.h	2020-02-23 04:56:03 UTC (rev 257188)
+++ trunk/Source/WebCore/platform/mac/WebCoreFullScreenWindow.h	2020-02-23 05:45:57 UTC (rev 257189)
@@ -23,14 +23,11 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef WebCoreFullScreenWindow_h
-#define WebCoreFullScreenWindow_h
+#pragma once
 
-#if ENABLE(FULLSCREEN_API) && !PLATFORM(IOS_FAMILY)
+#if !PLATFORM(IOS_FAMILY)
 
 WEBCORE_EXPORT @interface WebCoreFullScreenWindow : NSWindow
 @end
 
-#endif // ENABLE(FULLSCREEN_API)
-
-#endif // WebCoreFullScreenWindow_h
+#endif // PLATFORM(IOS_FAMILY)

Modified: trunk/Source/WebCore/platform/mac/WebCoreFullScreenWindow.mm (257188 => 257189)


--- trunk/Source/WebCore/platform/mac/WebCoreFullScreenWindow.mm	2020-02-23 04:56:03 UTC (rev 257188)
+++ trunk/Source/WebCore/platform/mac/WebCoreFullScreenWindow.mm	2020-02-23 05:45:57 UTC (rev 257189)
@@ -25,7 +25,7 @@
 
 #import "config.h"
 
-#if ENABLE(FULLSCREEN_API) && !PLATFORM(IOS_FAMILY)
+#if !PLATFORM(IOS_FAMILY)
 
 #import "WebCoreFullScreenWindow.h"
 
@@ -101,4 +101,4 @@
 }
 @end
 
-#endif // ENABLE(FULLSCREEN_API)
+#endif // !PLATFORM(IOS_FAMILY)

Modified: trunk/Source/WebKit/ChangeLog (257188 => 257189)


--- trunk/Source/WebKit/ChangeLog	2020-02-23 04:56:03 UTC (rev 257188)
+++ trunk/Source/WebKit/ChangeLog	2020-02-23 05:45:57 UTC (rev 257189)
@@ -1,3 +1,15 @@
+2020-02-22  Jer Noble  <jer.no...@apple.com>
+
+        Stop using QTKit for rendering WK1 video fullscreen controls
+        https://bugs.webkit.org/show_bug.cgi?id=207795
+        <rdar://problem/48894915>
+
+        Reviewed by Jon Lee.
+
+        Use NSWindowSPI.h rather than declaring SPI in the source file.
+
+        * UIProcess/mac/WKFullScreenWindowController.mm:
+
 2020-02-22  Darin Adler  <da...@apple.com>
 
         Use DOM element iterators more, and more consistently

Modified: trunk/Source/WebKit/UIProcess/mac/WKFullScreenWindowController.mm (257188 => 257189)


--- trunk/Source/WebKit/UIProcess/mac/WKFullScreenWindowController.mm	2020-02-23 04:56:03 UTC (rev 257188)
+++ trunk/Source/WebKit/UIProcess/mac/WKFullScreenWindowController.mm	2020-02-23 05:45:57 UTC (rev 257189)
@@ -47,6 +47,7 @@
 #import <WebCore/WebCoreFullScreenPlaceholderView.h>
 #import <WebCore/WebCoreFullScreenWindow.h>
 #import <pal/spi/cg/CoreGraphicsSPI.h>
+#import <pal/spi/mac/NSWindowSPI.h>
 #import <pal/system/SleepDisabler.h>
 #import <wtf/BlockObjCExceptions.h>
 #import <wtf/NakedRef.h>
@@ -95,11 +96,6 @@
     ExitingFullScreen,
 };
 
-@interface NSWindow (WebNSWindowFullScreenDetails)
-- (void)exitFullScreenMode:(id)sender;
-- (void)enterFullScreenMode:(id)sender;
-@end
-
 @interface WKFullScreenWindowController (Private) <NSAnimationDelegate>
 - (void)_replaceView:(NSView *)view with:(NSView *)otherView;
 - (WebKit::WebFullScreenManagerProxy *)_manager;

Modified: trunk/Source/WebKitLegacy/WebKitLegacy.xcodeproj/project.pbxproj (257188 => 257189)


--- trunk/Source/WebKitLegacy/WebKitLegacy.xcodeproj/project.pbxproj	2020-02-23 04:56:03 UTC (rev 257188)
+++ trunk/Source/WebKitLegacy/WebKitLegacy.xcodeproj/project.pbxproj	2020-02-23 05:45:57 UTC (rev 257189)
@@ -664,7 +664,6 @@
 		C11EBF4121419CCE00D659E7 /* WebSwitchingGPUClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C11EBF3F21419CCE00D659E7 /* WebSwitchingGPUClient.cpp */; };
 		C11EBF4221419CCE00D659E7 /* WebSwitchingGPUClient.h in Headers */ = {isa = PBXBuildFile; fileRef = C11EBF4021419CCE00D659E7 /* WebSwitchingGPUClient.h */; };
 		C1D81128202CD80000EE74F9 /* WebVideoFullscreenController.mm in Sources */ = {isa = PBXBuildFile; fileRef = C1D81127202CD80000EE74F9 /* WebVideoFullscreenController.mm */; };
-		C1D8112B202CDCC400EE74F9 /* WebVideoFullscreenHUDWindowController.mm in Sources */ = {isa = PBXBuildFile; fileRef = C1D81129202CDCC200EE74F9 /* WebVideoFullscreenHUDWindowController.mm */; };
 		C1D8112E202CED0800EE74F9 /* WebWindowAnimation.mm in Sources */ = {isa = PBXBuildFile; fileRef = C1D8112D202CED0700EE74F9 /* WebWindowAnimation.mm */; };
 		CD8BFCE715531224005AFB25 /* WebKitFullScreenListener.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD8BFCE515531224005AFB25 /* WebKitFullScreenListener.mm */; };
 		CD8BFCE815531224005AFB25 /* WebKitFullScreenListener.h in Headers */ = {isa = PBXBuildFile; fileRef = CD8BFCE615531224005AFB25 /* WebKitFullScreenListener.h */; };
@@ -1495,8 +1494,6 @@
 		C11EBF4021419CCE00D659E7 /* WebSwitchingGPUClient.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebSwitchingGPUClient.h; sourceTree = "<group>"; };
 		C1D81126202CD7FE00EE74F9 /* WebVideoFullscreenController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebVideoFullscreenController.h; sourceTree = "<group>"; };
 		C1D81127202CD80000EE74F9 /* WebVideoFullscreenController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebVideoFullscreenController.mm; sourceTree = "<group>"; };
-		C1D81129202CDCC200EE74F9 /* WebVideoFullscreenHUDWindowController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebVideoFullscreenHUDWindowController.mm; sourceTree = "<group>"; };
-		C1D8112A202CDCC300EE74F9 /* WebVideoFullscreenHUDWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebVideoFullscreenHUDWindowController.h; sourceTree = "<group>"; };
 		C1D8112C202CED0600EE74F9 /* WebWindowAnimation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebWindowAnimation.h; sourceTree = "<group>"; };
 		C1D8112D202CED0700EE74F9 /* WebWindowAnimation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebWindowAnimation.mm; sourceTree = "<group>"; };
 		CD8BFCE515531224005AFB25 /* WebKitFullScreenListener.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebKitFullScreenListener.mm; sourceTree = "<group>"; };
@@ -2083,8 +2080,6 @@
 				65A7D44A0568AB2600E70EF6 /* WebUIDelegatePrivate.h */,
 				C1D81126202CD7FE00EE74F9 /* WebVideoFullscreenController.h */,
 				C1D81127202CD80000EE74F9 /* WebVideoFullscreenController.mm */,
-				C1D8112A202CDCC300EE74F9 /* WebVideoFullscreenHUDWindowController.h */,
-				C1D81129202CDCC200EE74F9 /* WebVideoFullscreenHUDWindowController.mm */,
 				51A8B579042834F700CA2D3A /* WebView.h */,
 				51A8B57A042834F700CA2D3A /* WebView.mm */,
 				BC2E464B0FD8A96800A9D9DE /* WebViewData.h */,
@@ -3574,7 +3569,6 @@
 				C0C5B3EF1177A4A0002B0AEF /* WebUserContentURLPattern.mm in Sources */,
 				4618DFF91DEF760A0033C3AA /* WebValidationMessageClient.mm in Sources */,
 				C1D81128202CD80000EE74F9 /* WebVideoFullscreenController.mm in Sources */,
-				C1D8112B202CDCC400EE74F9 /* WebVideoFullscreenHUDWindowController.mm in Sources */,
 				BC2E464E0FD8A96800A9D9DE /* WebViewData.mm in Sources */,
 				1430C12C1B2C5DF700DEA01D /* WebViewGroup.cpp in Sources */,
 				A10C1D771820300E0036883A /* WebVisiblePosition.mm in Sources */,

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (257188 => 257189)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2020-02-23 04:56:03 UTC (rev 257188)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2020-02-23 05:45:57 UTC (rev 257189)
@@ -1,3 +1,76 @@
+2020-02-22  Jer Noble  <jer.no...@apple.com>
+
+        Stop using QTKit for rendering WK1 video fullscreen controls
+        https://bugs.webkit.org/show_bug.cgi?id=207795
+        <rdar://problem/48894915>
+
+        Reviewed by Jon Lee.
+
+        Switch to using AVPlayerView instead of QTHUD to render our fullscreen controls.
+
+        In addition, switch to a modern NSWindow fullscreen API, with custom, smooth animations which 
+        move the fullscreen window to a separate space. This requires subclassing AVPlayerView so that
+        fullscreen toggling will signal to the controller, so that our fullscreen button and the inline
+        version of same don't get out of sync. Because AVPlayerView requires an AVPlayer in order to
+        display the video layer, and we won't necessarily have an AVPlayer for MSE-backed videos, instead
+        install a custom overlay view inside the AVPlayerView in which to host the fullscreen video layer.
+
+        * WebView/WebVideoFullscreenController.h:
+        * WebView/WebVideoFullscreenController.mm:
+        (-[WebOverlayLayer layoutSublayers]):
+        (WebAVPlayerView_delegate):
+        (WebAVPlayerView_setDelegate):
+        (WebAVPlayerView_isFullScreen):
+        (WebAVPlayerView_enterFullScreen):
+        (WebAVPlayerView_exitFullScreen):
+        (allocWebAVPlayerViewInstance):
+        (-[WebVideoFullscreenController init]):
+        (-[WebVideoFullscreenController dealloc]):
+        (-[WebVideoFullscreenController fullscreenWindow]):
+        (-[WebVideoFullscreenController windowDidLoad]):
+        (-[WebVideoFullscreenController setVideoElement:]):
+        (-[WebVideoFullscreenController enterFullscreen:]):
+        (-[WebVideoFullscreenController exitFullscreen]):
+        (-[WebVideoFullscreenController applicationDidResignActive:]):
+        (-[WebVideoFullscreenController _requestExit]):
+        (-[WebVideoFullscreenController _requestEnter]):
+        (-[WebVideoFullscreenController cancelOperation:]):
+        (-[WebVideoFullscreenController playerViewIsFullScreen:]):
+        (-[WebVideoFullscreenController playerViewRequestEnterFullscreen:]):
+        (-[WebVideoFullscreenController playerViewRequestExitFullscreen:]):
+        (-[WebVideoFullscreenController customWindowsToEnterFullScreenForWindow:]):
+        (-[WebVideoFullscreenController window:startCustomAnimationToEnterFullScreenWithDuration:]):
+        (-[WebVideoFullscreenController customWindowsToExitFullScreenForWindow:]):
+        (-[WebVideoFullscreenController window:startCustomAnimationToExitFullScreenWithDuration:]):
+        (-[WebVideoFullscreenController windowDidEnterFullScreen:]):
+        (-[WebVideoFullscreenController windowWillExitFullScreen:]):
+        (-[WebVideoFullscreenController windowDidExitFullScreen:]):
+        (-[WebVideoFullscreenController clearFadeAnimation]): Deleted.
+        (-[WebVideoFullscreenController windowDidExitFullscreen]): Deleted.
+        (-[WebVideoFullscreenController windowDidEnterFullscreen]): Deleted.
+        (frameExpandedToRatioOfFrame): Deleted.
+        (createBackgroundFullscreenWindow): Deleted.
+        (-[WebVideoFullscreenController setupFadeAnimationIfNeededAndFadeIn:]): Deleted.
+        (-[WebVideoFullscreenController applicationDidChangeScreenParameters:]): Deleted.
+        (-[WebVideoFullscreenController updateMenuAndDockForFullscreen]): Deleted.
+        (-[WebVideoFullscreenController requestExitFullscreenWithAnimation:]): Deleted.
+        (-[WebVideoFullscreenController requestExitFullscreen]): Deleted.
+        (-[WebVideoFullscreenController fadeHUDIn]): Deleted.
+        (-[WebVideoFullscreenController observeValueForKeyPath:ofObject:change:context:]): Deleted.
+        (-[WebVideoFullscreenController rateChanged:]): Deleted.
+        (-[WebVideoFullscreenWindow initWithContentRect:styleMask:backing:defer:]): Deleted.
+        (-[WebVideoFullscreenWindow dealloc]): Deleted.
+        (-[WebVideoFullscreenWindow resignFirstResponder]): Deleted.
+        (-[WebVideoFullscreenWindow canBecomeKeyWindow]): Deleted.
+        (-[WebVideoFullscreenWindow mouseDown:]): Deleted.
+        (-[WebVideoFullscreenWindow cancelOperation:]): Deleted.
+        (-[WebVideoFullscreenWindow animatedResizeDidEnd]): Deleted.
+        (-[WebVideoFullscreenWindow animateFromRect:toRect:withSubAnimation:controllerAction:]): Deleted.
+        (-[WebVideoFullscreenWindow animationDidEnd:]): Deleted.
+        (-[WebVideoFullscreenWindow mouseMoved:]): Deleted.
+        * WebView/WebVideoFullscreenHUDWindowController.h: Removed.
+        * WebView/WebVideoFullscreenHUDWindowController.mm: Removed.
+
 2020-02-21  Wenson Hsieh  <wenson_hs...@apple.com>
 
         [macOS] Large form controls are rendered at the wrong NSControlSize

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebVideoFullscreenController.h (257188 => 257189)


--- trunk/Source/WebKitLegacy/mac/WebView/WebVideoFullscreenController.h	2020-02-23 04:56:03 UTC (rev 257188)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebVideoFullscreenController.h	2020-02-23 05:45:57 UTC (rev 257189)
@@ -33,7 +33,6 @@
 class HTMLVideoElement;
 }
 
-@class WebVideoFullscreenHUDWindowController;
 @class WebWindowFadeAnimation;
 
 @interface WebVideoFullscreenController : NSWindowController {
@@ -40,7 +39,6 @@
     RefPtr<WebCore::HTMLVideoElement> _videoElement;
 
     NSWindow *_backgroundFullscreenWindow; // (retain)
-    WebVideoFullscreenHUDWindowController *_hudController; // (retain)
 
     WebWindowFadeAnimation *_fadeAnimation; // (retain)
 

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebVideoFullscreenController.mm (257188 => 257189)


--- trunk/Source/WebKitLegacy/mac/WebView/WebVideoFullscreenController.mm	2020-02-23 04:56:03 UTC (rev 257188)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebVideoFullscreenController.mm	2020-02-23 05:45:57 UTC (rev 257189)
@@ -27,70 +27,169 @@
 
 #if ENABLE(VIDEO) && PLATFORM(MAC)
 
-#import "WebVideoFullscreenHUDWindowController.h"
-#import "WebWindowAnimation.h"
 #import <AVFoundation/AVPlayer.h>
-#import <AVFoundation/AVPlayerLayer.h>
-#import <Carbon/Carbon.h>
 #import <WebCore/HTMLVideoElement.h>
+#import <WebCore/PlaybackSessionInterfaceAVKit.h>
+#import <WebCore/PlaybackSessionModelMediaElement.h>
+#import <WebCore/WebAVPlayerController.h>
+#import <WebCore/WebCoreFullScreenWindow.h>
+#import <objc/message.h>
 #import <objc/runtime.h>
-#import <pal/system/SleepDisabler.h>
+#import <pal/spi/cocoa/AVKitSPI.h>
+#import <pal/spi/mac/NSWindowSPI.h>
 #import <wtf/RetainPtr.h>
 
+#import <pal/cf/CoreMediaSoftLink.h>
 #import <pal/cocoa/AVFoundationSoftLink.h>
 
+SOFTLINK_AVKIT_FRAMEWORK()
+SOFT_LINK_CLASS(AVKit, AVPlayerView)
+
 ALLOW_DEPRECATED_DECLARATIONS_BEGIN
 
-@interface WebVideoFullscreenWindow : NSWindow<NSAnimationDelegate> {
-    SEL _controllerActionOnAnimationEnd;
-    WebWindowScaleAnimation *_fullscreenAnimation; // (retain)
+@interface AVPlayerView (SecretStuff)
+@property (nonatomic, assign) BOOL showsAudioOnlyIndicatorView;
+@end
+
+@interface WebOverlayLayer : CALayer
+@end
+
+@implementation WebOverlayLayer
+- (void)layoutSublayers
+{
+    for (CALayer* layer in self.sublayers)
+        layer.frame = self.bounds;
 }
-- (void)animateFromRect:(NSRect)startRect toRect:(NSRect)endRect withSubAnimation:(NSAnimation *)subAnimation controllerAction:(SEL)controllerAction;
 @end
 
-@interface WebVideoFullscreenController () <WebVideoFullscreenHUDWindowControllerDelegate>
+@class WebAVPlayerView;
+
+@protocol WebAVPlayerViewDelegate
+- (BOOL)playerViewIsFullScreen:(WebAVPlayerView*)playerView;
+- (void)playerViewRequestEnterFullscreen:(WebAVPlayerView*)playerView;
+- (void)playerViewRequestExitFullscreen:(WebAVPlayerView*)playerView;
 @end
 
+@interface WebAVPlayerView : AVPlayerView
+@property (weak) id<WebAVPlayerViewDelegate> delegate;
+@end
+
+static id<WebAVPlayerViewDelegate> WebAVPlayerView_delegate(id aSelf, SEL)
+{
+    void* delegate = nil;
+    object_getInstanceVariable(aSelf, "_webDelegate", &delegate);
+    return static_cast<id<WebAVPlayerViewDelegate>>(delegate);
+}
+
+static void WebAVPlayerView_setDelegate(id aSelf, SEL, id<WebAVPlayerViewDelegate> delegate)
+{
+    object_setInstanceVariable(aSelf, "_webDelegate", delegate);
+}
+
+static BOOL WebAVPlayerView_isFullScreen(id aSelf, SEL)
+{
+    WebAVPlayerView *playerView = aSelf;
+    return [playerView.delegate playerViewIsFullScreen:playerView];
+}
+
+static void WebAVPlayerView_enterFullScreen(id aSelf, SEL, id sender)
+{
+    WebAVPlayerView *playerView = aSelf;
+    [playerView.delegate playerViewRequestEnterFullscreen:playerView];
+}
+
+static void WebAVPlayerView_exitFullScreen(id aSelf, SEL, id sender)
+{
+    WebAVPlayerView *playerView = aSelf;
+    [playerView.delegate playerViewRequestExitFullscreen:playerView];
+}
+
+static WebAVPlayerView *allocWebAVPlayerViewInstance()
+{
+    static Class theClass = nil;
+    static dispatch_once_t onceToken;
+    dispatch_once(&onceToken, ^{
+        ASSERT(getAVPlayerViewClass());
+        Class aClass = objc_allocateClassPair(getAVPlayerViewClass(), "WebAVPlayerView", 0);
+        theClass = aClass;
+        class_addMethod(theClass, @selector(setDelegate:), (IMP)WebAVPlayerView_setDelegate, "v@:@");
+        class_addMethod(theClass, @selector(delegate), (IMP)WebAVPlayerView_delegate, "@@:");
+        class_addMethod(theClass, @selector(isFullScreen), (IMP)WebAVPlayerView_isFullScreen, "B@:");
+        class_addMethod(theClass, @selector(enterFullScreen:), (IMP)WebAVPlayerView_enterFullScreen, "v@:@");
+        class_addMethod(theClass, @selector(exitFullScreen:), (IMP)WebAVPlayerView_exitFullScreen, "v@:@");
+
+        class_addIvar(theClass, "_webDelegate", sizeof(id), log2(sizeof(id)), "@");
+        class_addIvar(theClass, "_webIsFullScreen", sizeof(BOOL), log2(sizeof(BOOL)), "B");
+
+        objc_registerClassPair(theClass);
+    });
+    return (WebAVPlayerView *)[theClass alloc];
+}
+
+@interface WebVideoFullscreenController () <WebAVPlayerViewDelegate, NSWindowDelegate> {
+    RefPtr<WebCore::PlaybackSessionModelMediaElement> _playbackModel;
+    RefPtr<WebCore::PlaybackSessionInterfaceAVKit> _playbackInterface;
+    RetainPtr<NSView> _contentOverlay;
+    BOOL _isFullScreen;
+}
+@property (readonly) WebCoreFullScreenWindow* fullscreenWindow;
+@property (readonly) WebAVPlayerView* playerView;
+@end
+
 @implementation WebVideoFullscreenController
 
 - (id)init
 {
     // Do not defer window creation, to make sure -windowNumber is created (needed by WebWindowScaleAnimation).
-    NSWindow *window = [[WebVideoFullscreenWindow alloc] initWithContentRect:NSZeroRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO];
+    NSWindow *window = [[WebCoreFullScreenWindow alloc] initWithContentRect:NSZeroRect styleMask:(NSWindowStyleMaskFullSizeContentView | NSWindowStyleMaskResizable) backing:NSBackingStoreBuffered defer:NO];
+    [window setCollectionBehavior:([window collectionBehavior] | NSWindowCollectionBehaviorFullScreenPrimary)];
+    window.delegate = self;
     self = [super initWithWindow:window];
     [window release];
     if (!self)
         return nil;
+    _playbackModel = WebCore::PlaybackSessionModelMediaElement::create();
+    _playbackInterface = WebCore::PlaybackSessionInterfaceAVKit::create(*_playbackModel);
+    _contentOverlay = adoptNS([[NSView alloc] initWithFrame:NSZeroRect]);
+    _contentOverlay.get().layerContentsRedrawPolicy = NSViewLayerContentsRedrawNever;
+    _contentOverlay.get().layer = [[[WebOverlayLayer alloc] init] autorelease];
+    [_contentOverlay setWantsLayer:YES];
+    [_contentOverlay setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
     [self windowDidLoad];
+
     return self;
-    
 }
 - (void)dealloc
 {
     ASSERT(!_backgroundFullscreenWindow);
     ASSERT(!_fadeAnimation);
-    [[NSNotificationCenter defaultCenter] removeObserver:self];
+    _playerView.delegate = nil;
+    _playbackModel = nil;
     [super dealloc];
 }
 
-- (WebVideoFullscreenWindow *)fullscreenWindow
+- (WebCoreFullScreenWindow *)fullscreenWindow
 {
-    return (WebVideoFullscreenWindow *)[super window];
+    return (WebCoreFullScreenWindow *)[super window];
 }
 
 - (void)windowDidLoad
 {
     auto window = [self fullscreenWindow];
-    auto contentView = [window contentView];
 
     [window setHasShadow:YES]; // This is nicer with a shadow.
     [window setLevel:NSPopUpMenuWindowLevel-1];
 
-    [contentView setLayer:[CALayer layer]];
-    [contentView setWantsLayer:YES];
+    _playerView = [allocWebAVPlayerViewInstance() initWithFrame:window.contentLayoutRect];
+    _playerView.controlsStyle = AVPlayerViewControlsStyleNone;
+    _playerView.showsFullScreenToggleButton = YES;
+    _playerView.showsAudioOnlyIndicatorView = NO;
+    _playerView.delegate = self;
+    window.contentView = _playerView;
+    [_contentOverlay setFrame:_playerView.contentOverlayView.bounds];
+    [_playerView.contentOverlayView addSubview:_contentOverlay.get()];
 
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidResignActive:) name:NSApplicationDidResignActiveNotification object:NSApp];
-    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidChangeScreenParameters:) name:NSApplicationDidChangeScreenParametersNotification object:NSApp];
 }
 
 - (NakedPtr<WebCore::HTMLVideoElement>)videoElement
@@ -107,77 +206,29 @@
 
     if (![self isWindowLoaded])
         return;
-    auto corePlayer = videoElement->player();
-    if (!corePlayer)
-        return;
-    auto player = corePlayer->objCAVFoundationAVPlayer();
-    if (!player)
-        return;
 
-    auto contentView = [[self fullscreenWindow] contentView];
-
-    auto layer = adoptNS([PAL::allocAVPlayerLayerInstance() init]);
-    [layer setPlayer:player];
-
-    [contentView setLayer:layer.get()];
-
-    // FIXME: The windowDidLoad method already called this, so it should
-    // not be necessary to do it again here.
-    [contentView setWantsLayer:YES];
-
-    // FIXME: This can be called multiple times, and won't necessarily be
-    // balanced by calls to windowDidExitFullscreen in some cases, so it
-    // would be better to change things so the observer is reliably added
-    // only once and guaranteed removed even in unusual edge cases.
-    [player addObserver:self forKeyPath:@"rate" options:0 context:nullptr];
+    _playbackModel->setMediaElement(videoElement);
+    self.playerView.playerController = (AVPlayerController*)_playbackInterface->playerController();
 }
 
-- (CGFloat)clearFadeAnimation
+- (void)enterFullscreen:(NSScreen *)screen
 {
-    [_fadeAnimation stopAnimation];
-    CGFloat previousAlpha = [_fadeAnimation currentAlpha];
-    [_fadeAnimation setWindow:nil];
-    [_fadeAnimation release];
-    _fadeAnimation = nil;
-    return previousAlpha;
+    if (!_videoElement)
+        return;
+    [NSAnimationContext beginGrouping];
+    _videoElement->setVideoFullscreenLayer(_contentOverlay.get().layer, [self, protectedSelf = retainPtr(self)] {
+        [self.fullscreenWindow setFrame:self.videoElementRect display:YES];
+        [self.fullscreenWindow makeKeyAndOrderFront:self];
+        [self.fullscreenWindow enterFullScreenMode:self];
+        [NSAnimationContext endGrouping];
+    });
 }
 
-- (void)windowDidExitFullscreen
+- (void)exitFullscreen
 {
-    CALayer *layer = [[[self window] contentView] layer];
-    if ([layer isKindOfClass:PAL::getAVPlayerLayerClass()])
-        [[(AVPlayerLayer *)layer player] removeObserver:self forKeyPath:@"rate"];
-
-    [self clearFadeAnimation];
-    [[self window] close];
-    [self setWindow:nil];
-    [self updateMenuAndDockForFullscreen];   
-    [_hudController setDelegate:nil];
-    [_hudController release];
-    _hudController = nil;
-    [_backgroundFullscreenWindow close];
-    [_backgroundFullscreenWindow release];
-    _backgroundFullscreenWindow = nil;
-    
-    [self autorelease]; // Associated -retain is in -exitFullscreen.
-    _isEndingFullscreen = NO;
+    [self.fullscreenWindow exitFullScreenMode:self];
 }
 
-- (void)windowDidEnterFullscreen
-{
-    [self clearFadeAnimation];
-
-    ASSERT(!_hudController);
-    _hudController = [[WebVideoFullscreenHUDWindowController alloc] init];
-    [_hudController setDelegate:self];
-
-    [self updateMenuAndDockForFullscreen];
-    [NSCursor setHiddenUntilMouseMoves:YES];
-    
-    // Give the HUD keyboard focus initially
-    [_hudController fadeWindowIn];
-}
-
 - (NSRect)videoElementRect
 {
     return _videoElement->screenRect();
@@ -184,326 +235,109 @@
 }
 
 - (void)applicationDidResignActive:(NSNotification*)notification
-{   
+{
     UNUSED_PARAM(notification);
     NSWindow* fullscreenWindow = [self fullscreenWindow];
 
     // Replicate the QuickTime Player (X) behavior when losing active application status:
-    // Is the fullscreen screen the main screen? (Note: this covers the case where only a 
-    // single screen is available.)  Is the fullscreen screen on the current space? IFF so, 
-    // then exit fullscreen mode.    
+    // Is the fullscreen screen the main screen? (Note: this covers the case where only a
+    // single screen is available.)  Is the fullscreen screen on the current space? IFF so,
+    // then exit fullscreen mode.
     if (fullscreenWindow.screen == [NSScreen screens][0] && fullscreenWindow.onActiveSpace)
-        [self requestExitFullscreenWithAnimation:NO];
+        [self _requestExit];
 }
 
-
-// MARK: -
-// MARK: Exposed Interface
-
-static NSRect frameExpandedToRatioOfFrame(NSRect frameToExpand, NSRect frame)
+- (void)_requestExit
 {
-    // Keep a constrained aspect ratio for the destination window
-    NSRect result = frameToExpand;
-    CGFloat newRatio = frame.size.width / frame.size.height;
-    CGFloat originalRatio = frameToExpand.size.width / frameToExpand.size.height;
-    if (newRatio > originalRatio) {
-        CGFloat newWidth = newRatio * frameToExpand.size.height;
-        CGFloat diff = newWidth - frameToExpand.size.width;
-        result.size.width = newWidth;
-        result.origin.x -= diff / 2;
-    } else {
-        CGFloat newHeight = frameToExpand.size.width / newRatio;
-        CGFloat diff = newHeight - frameToExpand.size.height;
-        result.size.height = newHeight;
-        result.origin.y -= diff / 2;
-    }
-    return result;
+    [self.fullscreenWindow exitFullScreenMode:self];
 }
 
-static NSWindow *createBackgroundFullscreenWindow(NSRect frame, int level)
+- (void)_requestEnter
 {
-    NSWindow *window = [[NSWindow alloc] initWithContentRect:frame styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO];
-    [window setOpaque:YES];
-    [window setBackgroundColor:[NSColor blackColor]];
-    [window setLevel:level];
-    [window setReleasedWhenClosed:NO];
-    return window;
-}
-
-- (void)setupFadeAnimationIfNeededAndFadeIn:(BOOL)fadeIn
-{
-    CGFloat initialAlpha = fadeIn ? 0 : 1;
-    if (_fadeAnimation) {
-        // Make sure we support queuing animation if the previous one isn't over yet
-        initialAlpha = [self clearFadeAnimation];
-    }
-    if (!_forceDisableAnimation)
-        _fadeAnimation = [[WebWindowFadeAnimation alloc] initWithDuration:0.2 window:_backgroundFullscreenWindow initialAlpha:initialAlpha finalAlpha:fadeIn ? 1 : 0];
-}
-
-- (void)enterFullscreen:(NSScreen *)screen
-{
-    if (!screen)
-        screen = [NSScreen mainScreen];
-
-    NSRect endFrame = [screen frame];
-    NSRect frame = frameExpandedToRatioOfFrame([self videoElementRect], endFrame);
-
-    // Create a black window if needed
-    if (!_backgroundFullscreenWindow)
-        _backgroundFullscreenWindow = createBackgroundFullscreenWindow([screen frame], [[self window] level]-1);
-    else
-        [_backgroundFullscreenWindow setFrame:[screen frame] display:NO];
-
-    [self setupFadeAnimationIfNeededAndFadeIn:YES];
-    if (_forceDisableAnimation) {
-        // This will disable scale animation
-        frame = NSZeroRect;
-    }
-    [[self fullscreenWindow] animateFromRect:frame toRect:endFrame withSubAnimation:_fadeAnimation controllerAction:@selector(windowDidEnterFullscreen)];
-
-    [_backgroundFullscreenWindow orderWindow:NSWindowBelow relativeTo:[[self fullscreenWindow] windowNumber]];
-}
-
-- (void)exitFullscreen
-{
-    if (_isEndingFullscreen)
-        return;
-    _isEndingFullscreen = YES;
-    [_hudController closeWindow];
-
-    NSRect endFrame = [self videoElementRect];
-
-    [self setupFadeAnimationIfNeededAndFadeIn:NO];
-    if (_forceDisableAnimation) {
-        // This will disable scale animation
-        endFrame = NSZeroRect;
-    }
-    
-    // We have to retain ourselves because we want to be alive for the end of the animation.
-    // If our owner releases us we could crash if this is not the case.
-    // Balanced in windowDidExitFullscreen
-    [self retain];    
-
-    NSRect startFrame = [[self window] frame];
-    endFrame = frameExpandedToRatioOfFrame(endFrame, startFrame);
-
-    [[self fullscreenWindow] animateFromRect:startFrame toRect:endFrame withSubAnimation:_fadeAnimation controllerAction:@selector(windowDidExitFullscreen)];
-}
-
-- (void)applicationDidChangeScreenParameters:(NSNotification*)notification
-{
-    UNUSED_PARAM(notification);
-    // The user may have changed the main screen by moving the menu bar, or they may have changed
-    // the Dock's size or location, or they may have changed the fullscreen screen's dimensions.  
-    // Update our presentation parameters, and ensure that the full screen window occupies the 
-    // entire screen:
-    [self updateMenuAndDockForFullscreen];
-    [[self window] setFrame:[[[self window] screen] frame] display:YES];
-}
-
-- (void)updateMenuAndDockForFullscreen
-{
-    // NSApplicationPresentationOptions is available on > 10.6 only:
-    NSApplicationPresentationOptions options = NSApplicationPresentationDefault;
-    NSScreen* fullscreenScreen = [[self window] screen];
-
-    if (!_isEndingFullscreen) {
-        // Auto-hide the menu bar if the fullscreenScreen contains the menu bar:
-        // NOTE: if the fullscreenScreen contains the menu bar but not the dock, we must still 
-        // auto-hide the dock, or an exception will be thrown.
-        if ([[NSScreen screens] objectAtIndex:0] == fullscreenScreen)
-            options |= (NSApplicationPresentationAutoHideMenuBar | NSApplicationPresentationAutoHideDock);
-        // Check if the current screen contains the dock by comparing the screen's frame to its
-        // visibleFrame; if a dock is present, the visibleFrame will differ. If the current screen
-        // contains the dock, hide it.
-        else if (!NSEqualRects([fullscreenScreen frame], [fullscreenScreen visibleFrame]))
-            options |= NSApplicationPresentationAutoHideDock;
-    }
-
-    NSApp.presentationOptions = options;
-}
-
-// MARK: -
-// MARK: Window callback
-
-- (void)_requestExit
-{
     if (_videoElement)
-        _videoElement->exitFullscreen();
-    _forceDisableAnimation = NO;
+        _videoElement->enterFullscreen();
 }
 
-- (void)requestExitFullscreenWithAnimation:(BOOL)animation
+- (void)cancelOperation:(id)sender
 {
-    if (_isEndingFullscreen)
-        return;
-
-    _forceDisableAnimation = !animation;
-    [self performSelector:@selector(_requestExit) withObject:nil afterDelay:0];
-
+    [self _requestExit];
 }
 
-- (void)requestExitFullscreen
+- (BOOL)playerViewIsFullScreen:(WebAVPlayerView*)playerView
 {
-    [self requestExitFullscreenWithAnimation:YES];
+    return _isFullScreen;
 }
 
-- (void)fadeHUDIn
+- (void)playerViewRequestEnterFullscreen:(AVPlayerView*)playerView
 {
-    [_hudController fadeWindowIn];
+    [self _requestEnter];
 }
 
-- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
+- (void)playerViewRequestExitFullscreen:(AVPlayerView*)playerView
 {
-    UNUSED_PARAM(object);
-    UNUSED_PARAM(change);
-    UNUSED_PARAM(context);
-
-    if ([keyPath isEqualTo:@"rate"])
-        [self rateChanged:nil];
+    [self _requestExit];
 }
 
-- (void)rateChanged:(NSNotification *)unusedNotification
+- (nullable NSArray<NSWindow *> *)customWindowsToEnterFullScreenForWindow:(NSWindow *)window
 {
-    UNUSED_PARAM(unusedNotification);
-    [_hudController updateRate];
+    return @[self.fullscreenWindow];
 }
 
-@end
-
-@implementation WebVideoFullscreenWindow
-
-- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag
+- (void)window:(NSWindow *)window startCustomAnimationToEnterFullScreenWithDuration:(NSTimeInterval)duration
 {
-    UNUSED_PARAM(aStyle);
-    self = [super initWithContentRect:contentRect styleMask:NSBorderlessWindowMask backing:bufferingType defer:flag];
-    if (!self)
-        return nil;
-    [self setOpaque:NO];
-    [self setBackgroundColor:[NSColor clearColor]];
-    [self setIgnoresMouseEvents:NO];
-    [self setAcceptsMouseMovedEvents:YES];
-    return self;
+    [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) {
+        context.allowsImplicitAnimation = YES;
+        context.duration = duration;
+        [window setFrame:window.screen.frame display:YES];
+    } completionHandler:NULL];
 }
 
-- (void)dealloc
+- (nullable NSArray<NSWindow *> *)customWindowsToExitFullScreenForWindow:(NSWindow *)window
 {
-    ASSERT(!_fullscreenAnimation);
-    [super dealloc];
+    return @[self.fullscreenWindow];
 }
 
-- (BOOL)resignFirstResponder
+- (void)window:(NSWindow *)window startCustomAnimationToExitFullScreenWithDuration:(NSTimeInterval)duration
 {
-    return NO;
+    [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) {
+        context.allowsImplicitAnimation = YES;
+        context.duration = duration;
+        [window setFrame:self.videoElementRect display:YES];
+    } completionHandler:NULL];
 }
 
-- (BOOL)canBecomeKeyWindow
+- (void)windowDidEnterFullScreen:(NSNotification *)notification
 {
-    return NO;
+    _playerView.controlsStyle = AVPlayerViewControlsStyleFloating;
+    [_playerView willChangeValueForKey:@"isFullScreen"];
+    _isFullScreen = YES;
+    [_playerView didChangeValueForKey:@"isFullScreen"];
 }
 
-- (void)mouseDown:(NSEvent *)event
+- (void)windowWillExitFullScreen:(NSNotification *)notification
 {
-    UNUSED_PARAM(event);
+    _playerView.controlsStyle = AVPlayerViewControlsStyleNone;
 }
 
-- (void)cancelOperation:(id)sender
+- (void)windowDidExitFullScreen:(NSNotification *)notification
 {
-    UNUSED_PARAM(sender);
-    [[self windowController] requestExitFullscreen];
-}
+    [_playerView willChangeValueForKey:@"isFullScreen"];
+    _isFullScreen = NO;
+    [_playerView didChangeValueForKey:@"isFullScreen"];
 
-- (void)animatedResizeDidEnd
-{
-    if (_controllerActionOnAnimationEnd)
-        [[self windowController] performSelector:_controllerActionOnAnimationEnd];
-    _controllerActionOnAnimationEnd = NULL;
-}
-
-//
-// This function will animate a change of frame rectangle
-// We support queuing animation, that means that we'll correctly
-// interrupt the running animation, and queue the next one.
-//
-- (void)animateFromRect:(NSRect)startRect toRect:(NSRect)endRect withSubAnimation:(NSAnimation *)subAnimation controllerAction:(SEL)controllerAction
-{
-    _controllerActionOnAnimationEnd = controllerAction;
-
-    BOOL wasAnimating = NO;
-    if (_fullscreenAnimation) {
-        wasAnimating = YES;
-
-        // Interrupt any running animation.
-        [_fullscreenAnimation stopAnimation];
-
-        // Save the current rect to ensure a smooth transition.
-        startRect = [_fullscreenAnimation currentFrame];
-        [_fullscreenAnimation release];
-        _fullscreenAnimation = nil;
-    }
-    
-    if (NSIsEmptyRect(startRect) || NSIsEmptyRect(endRect)) {
-        // Fakely end the subanimation.
-        [subAnimation setCurrentProgress:1];
-        // And remove the weak link to the window.
-        [subAnimation stopAnimation];
-
-        [self setFrame:endRect display:NO];
-        [self makeKeyAndOrderFront:self];
-        [self animatedResizeDidEnd];
+    if (!_videoElement) {
+        [self.fullscreenWindow close];
         return;
     }
 
-    if (!wasAnimating) {
-        // We'll downscale the window during the animation based on the higher resolution rect
-        BOOL higherResolutionIsEndRect = startRect.size.width < endRect.size.width && startRect.size.height < endRect.size.height;
-        [self setFrame:higherResolutionIsEndRect ? endRect : startRect display:NO];
-    }
-    
-    ASSERT(!_fullscreenAnimation);
-    _fullscreenAnimation = [[WebWindowScaleAnimation alloc] initWithHintedDuration:0.2 window:self initalFrame:startRect finalFrame:endRect];
-    [_fullscreenAnimation setSubAnimation:subAnimation];
-    [_fullscreenAnimation setDelegate:self];
-    
-    // Make sure the animation has scaled the window before showing it.
-    [_fullscreenAnimation setCurrentProgress:0];
-    [self makeKeyAndOrderFront:self];
-
-    [_fullscreenAnimation startAnimation];
+    [NSAnimationContext beginGrouping];
+    _videoElement->setVideoFullscreenLayer(nil, [self, protectedSelf = retainPtr(self)] {
+        [self.fullscreenWindow close];
+        [NSAnimationContext endGrouping];
+    });
+    _videoElement->exitFullscreen();
 }
 
-- (void)animationDidEnd:(NSAnimation *)animation
-{
-    if (![NSThread isMainThread]) {
-        [self performSelectorOnMainThread:@selector(animationDidEnd:) withObject:animation waitUntilDone:NO];
-        return;
-    }
-    if (animation != _fullscreenAnimation)
-        return;
-
-    // The animation is not really over and was interrupted
-    // Don't send completion events.
-    if ([animation currentProgress] < 1.0)
-        return;
-
-    // Ensure that animation (and subanimation) don't keep
-    // the weak reference to the window ivar that may be destroyed from
-    // now on.
-    [_fullscreenAnimation setWindow:nil];
-
-    [_fullscreenAnimation autorelease];
-    _fullscreenAnimation = nil;
-
-    [self animatedResizeDidEnd];
-}
-
-- (void)mouseMoved:(NSEvent *)event
-{
-    UNUSED_PARAM(event);
-    [[self windowController] fadeHUDIn];
-}
-
 @end
 
 ALLOW_DEPRECATED_DECLARATIONS_END

Deleted: trunk/Source/WebKitLegacy/mac/WebView/WebVideoFullscreenHUDWindowController.h (257188 => 257189)


--- trunk/Source/WebKitLegacy/mac/WebView/WebVideoFullscreenHUDWindowController.h	2020-02-23 04:56:03 UTC (rev 257188)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebVideoFullscreenHUDWindowController.h	2020-02-23 05:45:57 UTC (rev 257189)
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2009 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#if ENABLE(VIDEO)
-
-#import <AppKit/NSButton.h>
-#import <AppKit/NSControl.h>
-#import <AppKit/NSTextField.h>
-#import <AppKit/NSTrackingArea.h>
-#import <AppKit/NSWindow.h>
-#import <AppKit/NSWindowController.h>
-#import <wtf/NakedPtr.h>
-
-namespace WebCore {
-class HTMLVideoElement;
-}
-
-@protocol WebVideoFullscreenHUDWindowControllerDelegate;
-
-@interface WebVideoFullscreenHUDWindowController : NSWindowController {
-    id <WebVideoFullscreenHUDWindowControllerDelegate> _delegate;
-    NSTimer *_timelineUpdateTimer;
-    NSTrackingArea *_area;
-    BOOL _mouseIsInHUD;
-    BOOL _isEndingFullscreen;
-    BOOL _isScrubbing;
-
-    NSControl *_timeline;
-    NSTextField *_remainingTimeText;
-    NSTextField *_elapsedTimeText;
-    NSControl *_volumeSlider;
-    NSButton *_playButton;
-}
-
-- (id <WebVideoFullscreenHUDWindowControllerDelegate>)delegate;
-- (void)setDelegate:(id <WebVideoFullscreenHUDWindowControllerDelegate>)delegate;
-- (void)fadeWindowIn;
-- (void)fadeWindowOut;
-- (void)closeWindow;
-- (void)updateRate;
-
-@end
-
-@protocol WebVideoFullscreenHUDWindowControllerDelegate <NSObject>
-- (void)requestExitFullscreen;
-- (NakedPtr<WebCore::HTMLVideoElement>)videoElement;
-@end
-
-#endif

Deleted: trunk/Source/WebKitLegacy/mac/WebView/WebVideoFullscreenHUDWindowController.mm (257188 => 257189)


--- trunk/Source/WebKitLegacy/mac/WebView/WebVideoFullscreenHUDWindowController.mm	2020-02-23 04:56:03 UTC (rev 257188)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebVideoFullscreenHUDWindowController.mm	2020-02-23 05:45:57 UTC (rev 257189)
@@ -1,737 +0,0 @@
-/*
- * Copyright (C) 2009-2017 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#if ENABLE(VIDEO) && PLATFORM(MAC)
-
-#import "WebVideoFullscreenHUDWindowController.h"
-
-#import <WebCore/FloatConversion.h>
-#import <WebCore/HTMLVideoElement.h>
-#import <pal/spi/cg/CoreGraphicsSPI.h>
-#import <pal/spi/mac/QTKitSPI.h>
-#import <wtf/SoftLinking.h>
-
-SOFT_LINK_FRAMEWORK_OPTIONAL(QTKit)
-
-SOFT_LINK_CLASS_OPTIONAL(QTKit, QTHUDBackgroundView)
-SOFT_LINK_CLASS_OPTIONAL(QTKit, QTHUDButton)
-SOFT_LINK_CLASS_OPTIONAL(QTKit, QTHUDSlider)
-SOFT_LINK_CLASS_OPTIONAL(QTKit, QTHUDTimeline)
-
-#define QTHUDBackgroundView getQTHUDBackgroundViewClass()
-#define QTHUDButton getQTHUDButtonClass()
-#define QTHUDSlider getQTHUDSliderClass()
-#define QTHUDTimeline getQTHUDTimelineClass()
-
-enum class MediaUIControl {
-    Timeline,
-    Slider,
-    PlayPauseButton,
-    ExitFullscreenButton,
-    RewindButton,
-    FastForwardButton,
-    VolumeUpButton,
-    VolumeDownButton,
-};
-
-using WebCore::HTMLVideoElement;
-using WebCore::narrowPrecisionToFloat;
-
-@interface WebVideoFullscreenHUDWindowController (Private) <NSWindowDelegate>
-
-- (void)updateTime;
-- (void)timelinePositionChanged:(id)sender;
-- (float)currentTime;
-- (void)setCurrentTime:(float)currentTime;
-- (double)duration;
-
-- (void)volumeChanged:(id)sender;
-- (float)maxVolume;
-- (float)volume;
-- (void)setVolume:(float)volume;
-- (void)decrementVolume;
-- (void)incrementVolume;
-
-- (void)updatePlayButton;
-- (void)togglePlaying:(id)sender;
-- (BOOL)playing;
-- (void)setPlaying:(BOOL)playing;
-
-- (void)rewind:(id)sender;
-- (void)fastForward:(id)sender;
-
-- (NSString *)remainingTimeText;
-- (NSString *)elapsedTimeText;
-
-- (void)exitFullscreen:(id)sender;
-@end
-
-@interface WebVideoFullscreenHUDWindow : NSWindow
-@end
-
-@implementation WebVideoFullscreenHUDWindow
-
-- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag
-{
-    UNUSED_PARAM(aStyle);
-    self = [super initWithContentRect:contentRect styleMask:NSWindowStyleMaskBorderless backing:bufferingType defer:flag];
-    if (!self)
-        return nil;
-
-    [self setOpaque:NO];
-    [self setBackgroundColor:[NSColor clearColor]];
-    [self setLevel:NSPopUpMenuWindowLevel];
-    [self setAcceptsMouseMovedEvents:YES];
-    [self setIgnoresMouseEvents:NO];
-    [self setMovableByWindowBackground:YES];
-
-    return self;
-}
-
-- (BOOL)canBecomeKeyWindow
-{
-    return YES;
-}
-
-- (void)cancelOperation:(id)sender
-{
-    UNUSED_PARAM(sender);
-    [[self windowController] exitFullscreen:self];
-}
-
-- (void)center
-{
-    NSRect hudFrame = [self frame];
-    NSRect screenFrame = [[NSScreen mainScreen] frame];
-    [self setFrameTopLeftPoint:NSMakePoint(screenFrame.origin.x + (screenFrame.size.width - hudFrame.size.width) / 2, screenFrame.origin.y + (screenFrame.size.height - hudFrame.size.height) / 6)];
-}
-
-- (void)keyDown:(NSEvent *)event
-{
-    [super keyDown:event];
-    [[self windowController] fadeWindowIn];
-}
-
-- (BOOL)resignFirstResponder
-{
-    return NO;
-}
-
-- (BOOL)performKeyEquivalent:(NSEvent *)event
-{
-    // Block all command key events while the fullscreen window is up.
-    if ([event type] != NSEventTypeKeyDown)
-        return NO;
-    
-    if (!([event modifierFlags] & NSEventModifierFlagCommand))
-        return NO;
-    return YES;
-}
-
-@end
-
-static const CGFloat windowHeight = 59;
-static const CGFloat windowWidth = 438;
-
-static const NSTimeInterval HUDWindowFadeOutDelay = 3;
-
-@implementation WebVideoFullscreenHUDWindowController
-
-- (id)init
-{
-    NSWindow *window = [[WebVideoFullscreenHUDWindow alloc] initWithContentRect:NSMakeRect(0, 0, windowWidth, windowHeight) styleMask:NSWindowStyleMaskBorderless backing:NSBackingStoreBuffered defer:NO];
-    self = [super initWithWindow:window];
-    [window setDelegate:self];
-    [window release];
-    if (!self)
-        return nil;
-    [self windowDidLoad];
-    return self;
-}
-
-- (void)dealloc
-{
-    ASSERT(!_timelineUpdateTimer);
-    ASSERT(!_area);
-    ASSERT(!_isScrubbing);
-    [_timeline release];
-    [_remainingTimeText release];
-    [_elapsedTimeText release];
-    [_volumeSlider release];
-    [_playButton release];
-    [super dealloc];
-}
-
-- (void)setArea:(NSTrackingArea *)area
-{
-    if (area == _area)
-        return;
-    [_area release];
-    _area = [area retain];
-}
-
-- (void)keyDown:(NSEvent *)event
-{
-    NSString *charactersIgnoringModifiers = [event charactersIgnoringModifiers];
-    if ([charactersIgnoringModifiers length] == 1) {
-        switch ([charactersIgnoringModifiers characterAtIndex:0]) {
-        case ' ':
-            [self togglePlaying:nil];
-            return;
-        case NSUpArrowFunctionKey:
-            if ([event modifierFlags] & NSEventModifierFlagOption)
-                [self setVolume:[self maxVolume]];
-            else
-                [self incrementVolume];
-            return;
-        case NSDownArrowFunctionKey:
-            if ([event modifierFlags] & NSEventModifierFlagOption)
-                [self setVolume:0];
-            else
-                [self decrementVolume];
-            return;
-        default:
-            break;
-        }
-    }
-
-    [super keyDown:event];
-}
-
-- (id <WebVideoFullscreenHUDWindowControllerDelegate>)delegate
-{
-    return _delegate;
-}
-
-- (void)setDelegate:(id <WebVideoFullscreenHUDWindowControllerDelegate>)delegate
-{
-    _delegate = delegate;
-}
-
-- (void)scheduleTimeUpdate
-{
-    [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(unscheduleTimeUpdate) object:self];
-
-    // First, update right away, then schedule future update
-    [self updateTime];
-    [self updatePlayButton];
-
-    [_timelineUpdateTimer invalidate];
-    [_timelineUpdateTimer release];
-
-    // Note that this creates a retain cycle between the window and us.
-    _timelineUpdateTimer = [[NSTimer timerWithTimeInterval:0.25 target:self selector:@selector(updateTime) userInfo:nil repeats:YES] retain];
-    [[NSRunLoop currentRunLoop] addTimer:_timelineUpdateTimer forMode:NSRunLoopCommonModes];
-}
-
-- (void)unscheduleTimeUpdate
-{
-    [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(unscheduleTimeUpdate) object:nil];
-
-    [_timelineUpdateTimer invalidate];
-    [_timelineUpdateTimer release];
-    _timelineUpdateTimer = nil;
-}
-
-- (void)fadeWindowIn
-{
-    NSWindow *window = [self window];
-    if (![window isVisible])
-        [window setAlphaValue:0];
-
-    [window makeKeyAndOrderFront:self];
-    [[window animator] setAlphaValue:1];
-    [self scheduleTimeUpdate];
-
-    [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(fadeWindowOut) object:nil];
-    if (!_mouseIsInHUD && [self playing]) // Don't fade out when paused.
-        [self performSelector:@selector(fadeWindowOut) withObject:nil afterDelay:HUDWindowFadeOutDelay];
-}
-
-- (void)fadeWindowOut
-{
-    [NSCursor setHiddenUntilMouseMoves:YES];
-    [[[self window] animator] setAlphaValue:0];
-    [self performSelector:@selector(unscheduleTimeUpdate) withObject:nil afterDelay:1];
-}
-
-- (void)closeWindow
-{
-    [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(fadeWindowOut) object:nil];
-    [self unscheduleTimeUpdate];
-    NSWindow *window = [self window];
-    [[window contentView] removeTrackingArea:_area];
-    [self setArea:nil];
-    [window close];
-    [window setDelegate:nil];
-    [self setWindow:nil];
-}
-
-static NSControl *createMediaUIControl(MediaUIControl controlType)
-{
-    switch (controlType) {
-    case MediaUIControl::Timeline: {
-        NSSlider *slider = [[QTHUDTimeline alloc] init];
-        [[slider cell] setContinuous:YES];
-        return slider;
-    }
-    case MediaUIControl::Slider: {
-        NSButton *slider = [[QTHUDSlider alloc] init];
-        [[slider cell] setContinuous:YES];
-        return slider;
-    }
-    case MediaUIControl::PlayPauseButton: {
-        NSButton *button = [[QTHUDButton alloc] init];
-        [button setImage:[NSImage imageNamed:@"NSPlayTemplate"]];
-        [button setAlternateImage:[NSImage imageNamed:@"NSPauseQTPrivateTemplate"]];
-
-        [[button cell] setShowsStateBy:NSContentsCellMask];
-        [button setBordered:NO];
-        return button;
-    }
-    case MediaUIControl::ExitFullscreenButton: {
-        NSButton *button = [[QTHUDButton alloc] init];
-        [button setImage:[NSImage imageNamed:@"NSExitFullScreenTemplate"]];
-        [button setBordered:NO];
-        return button;
-    }
-    case MediaUIControl::RewindButton: {
-        NSButton *button = [[QTHUDButton alloc] init];
-        [button setImage:[NSImage imageNamed:@"NSRewindTemplate"]];
-        [button setBordered:NO];
-        return button;
-    }
-    case MediaUIControl::FastForwardButton: {
-        NSButton *button = [[QTHUDButton alloc] init];
-        [button setImage:[NSImage imageNamed:@"NSFastForwardTemplate"]];
-        [button setBordered:NO];
-        return button;
-    }
-    case MediaUIControl::VolumeUpButton: {
-        NSButton *button = [[QTHUDButton alloc] init];
-        [button setImage:[NSImage imageNamed:@"NSAudioOutputVolumeHighTemplate"]];
-        [button setBordered:NO];
-        return button;
-    }
-    case MediaUIControl::VolumeDownButton: {
-        NSButton *button = [[QTHUDButton alloc] init];
-        [button setImage:[NSImage imageNamed:@"NSAudioOutputVolumeLowTemplate"]];
-        [button setBordered:NO];
-        return button;
-    }
-    }
-
-    ASSERT_NOT_REACHED();
-    return nil;
-}
-
-static NSControl *createControlWithMediaUIControlType(MediaUIControl controlType, NSRect frame)
-{
-    NSControl *control = createMediaUIControl(controlType);
-    control.frame = frame;
-    return control;
-}
-
-static NSTextField *createTimeTextField(NSRect frame)
-{
-    NSTextField *textField = [[NSTextField alloc] initWithFrame:frame];
-    [textField setTextColor:[NSColor whiteColor]];
-    [textField setBordered:NO];
-    [textField setFont:[NSFont boldSystemFontOfSize:10]];
-    [textField setDrawsBackground:NO];
-    [textField setBezeled:NO];
-    [textField setEditable:NO];
-    [textField setSelectable:NO];
-    return textField;
-}
-
-static NSView *createMediaUIBackgroundView()
-{
-    id view = [[QTHUDBackgroundView alloc] init];
-
-    const CGFloat quickTimePlayerHUDHeight = 59;
-    const CGFloat quickTimePlayerHUDContentBorderPosition = 38;
-
-    ALLOW_DEPRECATED_DECLARATIONS_BEGIN
-    [view setContentBorderPosition:quickTimePlayerHUDContentBorderPosition / quickTimePlayerHUDHeight];
-    ALLOW_DEPRECATED_DECLARATIONS_END
-
-    return view;
-}
-
-- (void)windowDidLoad
-{
-    static const CGFloat horizontalMargin = 10;
-    static const CGFloat playButtonWidth = 41;
-    static const CGFloat playButtonHeight = 35;
-    static const CGFloat playButtonTopMargin = 4;
-    static const CGFloat volumeSliderWidth = 50;
-    static const CGFloat volumeSliderHeight = 13;
-    static const CGFloat volumeButtonWidth = 18;
-    static const CGFloat volumeButtonHeight = 16;
-    static const CGFloat volumeUpButtonLeftMargin = 4;
-    static const CGFloat volumeControlsTopMargin = 13;
-    static const CGFloat exitFullscreenButtonWidth = 25;
-    static const CGFloat exitFullscreenButtonHeight = 21;
-    static const CGFloat exitFullscreenButtonTopMargin = 11;
-    static const CGFloat timelineWidth = 315;
-    static const CGFloat timelineHeight = 14;
-    static const CGFloat timelineBottomMargin = 7;
-    static const CGFloat timeTextFieldWidth = 54;
-    static const CGFloat timeTextFieldHeight = 13;
-    static const CGFloat timeTextFieldHorizontalMargin = 7;
-
-    if (!QTKitLibrary()
-        || !getQTHUDBackgroundViewClass()
-        || !getQTHUDButtonClass()
-        || !getQTHUDSliderClass()
-        || !getQTHUDTimelineClass())
-        return;
-
-    NSWindow *window = [self window];
-    ASSERT(window);
-
-    NSView *background = ""
-
-    [window setContentView:background];
-    _area = [[NSTrackingArea alloc] initWithRect:[background bounds] options:NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways owner:self userInfo:nil];
-    [background addTrackingArea:_area];
-    [background release];    
-
-    NSView *contentView = [window contentView];
-
-    CGFloat center = CGFloor((windowWidth - playButtonWidth) / 2);
-    _playButton = (NSButton *)createControlWithMediaUIControlType(MediaUIControl::PlayPauseButton, NSMakeRect(center, windowHeight - playButtonTopMargin - playButtonHeight, playButtonWidth, playButtonHeight));
-    ASSERT([_playButton isKindOfClass:[NSButton class]]);
-    [_playButton setTarget:self];
-    [_playButton setAction:@selector(togglePlaying:)];
-    [contentView addSubview:_playButton];
-
-    CGFloat closeToRight = windowWidth - horizontalMargin - exitFullscreenButtonWidth;
-    NSControl *exitFullscreenButton = createControlWithMediaUIControlType(MediaUIControl::ExitFullscreenButton, NSMakeRect(closeToRight, windowHeight - exitFullscreenButtonTopMargin - exitFullscreenButtonHeight, exitFullscreenButtonWidth, exitFullscreenButtonHeight));
-    [exitFullscreenButton setAction:@selector(exitFullscreen:)];
-    [exitFullscreenButton setTarget:self];
-    [contentView addSubview:exitFullscreenButton];
-    [exitFullscreenButton release];
-    
-    CGFloat volumeControlsBottom = windowHeight - volumeControlsTopMargin - volumeButtonHeight;
-    CGFloat left = horizontalMargin;
-    NSControl *volumeDownButton = createControlWithMediaUIControlType(MediaUIControl::VolumeDownButton, NSMakeRect(left, volumeControlsBottom, volumeButtonWidth, volumeButtonHeight));
-    [contentView addSubview:volumeDownButton];
-    [volumeDownButton setTarget:self];
-    [volumeDownButton setAction:@selector(setVolumeToZero:)];
-    [volumeDownButton release];
-
-    left += volumeButtonWidth;
-    _volumeSlider = createControlWithMediaUIControlType(MediaUIControl::Slider, NSMakeRect(left, volumeControlsBottom + CGFloor((volumeButtonHeight - volumeSliderHeight) / 2), volumeSliderWidth, volumeSliderHeight));
-    [_volumeSlider setValue:[NSNumber numberWithDouble:[self maxVolume]] forKey:@"maxValue"];
-    [_volumeSlider setTarget:self];
-    [_volumeSlider setAction:@selector(volumeChanged:)];
-    [contentView addSubview:_volumeSlider];
-
-    left += volumeSliderWidth + volumeUpButtonLeftMargin;
-    NSControl *volumeUpButton = createControlWithMediaUIControlType(MediaUIControl::VolumeUpButton, NSMakeRect(left, volumeControlsBottom, volumeButtonWidth, volumeButtonHeight));
-    [volumeUpButton setTarget:self];
-    [volumeUpButton setAction:@selector(setVolumeToMaximum:)];
-    [contentView addSubview:volumeUpButton];
-    [volumeUpButton release];
-
-    _timeline = createMediaUIControl(MediaUIControl::Timeline);
-
-    [_timeline setTarget:self];
-    [_timeline setAction:@selector(timelinePositionChanged:)];
-    [_timeline setFrame:NSMakeRect(CGFloor((windowWidth - timelineWidth) / 2), timelineBottomMargin, timelineWidth, timelineHeight)];
-    [contentView addSubview:_timeline];
-
-    _elapsedTimeText = createTimeTextField(NSMakeRect(timeTextFieldHorizontalMargin, timelineBottomMargin, timeTextFieldWidth, timeTextFieldHeight));
-    [_elapsedTimeText setAlignment:NSTextAlignmentLeft];
-    [contentView addSubview:_elapsedTimeText];
-
-    _remainingTimeText = createTimeTextField(NSMakeRect(windowWidth - timeTextFieldHorizontalMargin - timeTextFieldWidth, timelineBottomMargin, timeTextFieldWidth, timeTextFieldHeight));
-    [_remainingTimeText setAlignment:NSTextAlignmentRight];
-    [contentView addSubview:_remainingTimeText];
-
-    [window recalculateKeyViewLoop];
-    [window setInitialFirstResponder:_playButton];
-    [window center];
-}
-
-- (void)updateVolume
-{
-    [_volumeSlider setFloatValue:[self volume]];
-}
-
-- (void)updateTime
-{
-    [self updateVolume];
-
-    [_timeline setFloatValue:[self currentTime]];
-    [_timeline setValue:[NSNumber numberWithDouble:[self duration]] forKey:@"maxValue"];
-
-    [_remainingTimeText setStringValue:[self remainingTimeText]];
-    [_elapsedTimeText setStringValue:[self elapsedTimeText]];
-}
-
-- (void)endScrubbing
-{
-    ASSERT(_isScrubbing);
-    _isScrubbing = NO;
-    if (HTMLVideoElement* videoElement = [_delegate videoElement])
-        videoElement->endScrubbing();
-}
-
-- (void)timelinePositionChanged:(id)sender
-{
-    UNUSED_PARAM(sender);
-    [self setCurrentTime:[_timeline floatValue]];
-    if (!_isScrubbing) {
-        _isScrubbing = YES;
-        if (HTMLVideoElement* videoElement = [_delegate videoElement])
-            videoElement->beginScrubbing();
-        static NSArray *endScrubbingModes = [[NSArray alloc] initWithObjects:NSDefaultRunLoopMode, NSModalPanelRunLoopMode, nil];
-        // Schedule -endScrubbing for when leaving mouse tracking mode.
-        [[NSRunLoop currentRunLoop] performSelector:@selector(endScrubbing) target:self argument:nil order:0 modes:endScrubbingModes];
-    }
-}
-
-- (float)currentTime
-{
-    return [_delegate videoElement] ? [_delegate videoElement]->currentTime() : 0;
-}
-
-- (void)setCurrentTime:(float)currentTime
-{
-    if (![_delegate videoElement])
-        return;
-    [_delegate videoElement]->setCurrentTime(currentTime);
-    [self updateTime];
-}
-
-- (double)duration
-{
-    return [_delegate videoElement] ? [_delegate videoElement]->duration() : 0;
-}
-
-- (float)maxVolume
-{
-    // Set the volume slider resolution
-    return 100;
-}
-
-- (void)volumeChanged:(id)sender
-{
-    UNUSED_PARAM(sender);
-    [self setVolume:[_volumeSlider floatValue]];
-}
-
-- (void)setVolumeToZero:(id)sender
-{
-    UNUSED_PARAM(sender);
-    [self setVolume:0];
-}
-
-- (void)setVolumeToMaximum:(id)sender
-{
-    UNUSED_PARAM(sender);
-    [self setVolume:[self maxVolume]];
-}
-
-- (void)decrementVolume
-{
-    if (![_delegate videoElement])
-        return;
-
-    float volume = [self volume] - 10;
-    [self setVolume:std::max(volume, 0.0f)];
-}
-
-- (void)incrementVolume
-{
-    if (![_delegate videoElement])
-        return;
-
-    float volume = [self volume] + 10;
-    [self setVolume:std::min(volume, [self maxVolume])];
-}
-
-- (float)volume
-{
-    return [_delegate videoElement] ? [_delegate videoElement]->volume() * [self maxVolume] : 0;
-}
-
-- (void)setVolume:(float)volume
-{
-    if (![_delegate videoElement])
-        return;
-    if ([_delegate videoElement]->muted())
-        [_delegate videoElement]->setMuted(false);
-    [_delegate videoElement]->setVolume(volume / [self maxVolume]);
-    [self updateVolume];
-}
-
-- (void)updatePlayButton
-{
-    [_playButton setIntValue:[self playing]];
-}
-
-- (void)updateRate
-{
-    BOOL playing = [self playing];
-
-    // Keep the HUD visible when paused.
-    if (!playing)
-        [self fadeWindowIn];
-    else if (!_mouseIsInHUD) {
-        [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(fadeWindowOut) object:nil];
-        [self performSelector:@selector(fadeWindowOut) withObject:nil afterDelay:HUDWindowFadeOutDelay];
-    }
-    [self updatePlayButton];
-}
-
-- (void)togglePlaying:(id)sender
-{
-    UNUSED_PARAM(sender);
-    [self setPlaying:![self playing]];
-}
-
-- (BOOL)playing
-{
-    HTMLVideoElement* videoElement = [_delegate videoElement];
-    if (!videoElement)
-        return NO;
-
-    return !videoElement->canPlay();
-}
-
-- (void)setPlaying:(BOOL)playing
-{
-    HTMLVideoElement* videoElement = [_delegate videoElement];
-
-    if (!videoElement)
-        return;
-
-    if (playing)
-        videoElement->play();
-    else
-        videoElement->pause();
-}
-
-static NSString *timeToString(double time)
-{
-    ASSERT_ARG(time, time >= 0);
-
-    if (!std::isfinite(time))
-        time = 0;
-
-    int seconds = narrowPrecisionToFloat(std::abs(time));
-    int hours = seconds / (60 * 60);
-    int minutes = (seconds / 60) % 60;
-    seconds %= 60;
-
-    if (hours)
-        return [NSString stringWithFormat:@"%d:%02d:%02d", hours, minutes, seconds];
-
-    return [NSString stringWithFormat:@"%02d:%02d", minutes, seconds];    
-}
-
-- (NSString *)remainingTimeText
-{
-    HTMLVideoElement* videoElement = [_delegate videoElement];
-    if (!videoElement)
-        return @"";
-
-    double remainingTime = 0;
-
-    if (std::isfinite(videoElement->duration()) && std::isfinite(videoElement->currentTime()))
-        remainingTime = videoElement->duration() - videoElement->currentTime();
-
-    return [@"-" stringByAppendingString:timeToString(remainingTime)];
-}
-
-- (NSString *)elapsedTimeText
-{
-    if (![_delegate videoElement])
-        return @"";
-
-    return timeToString([_delegate videoElement]->currentTime());
-}
-
-// MARK: NSResponder
-
-- (void)mouseEntered:(NSEvent *)theEvent
-{
-    UNUSED_PARAM(theEvent);
-    // Make sure the HUD won't be hidden from now
-    _mouseIsInHUD = YES;
-    [self fadeWindowIn];
-}
-
-- (void)mouseExited:(NSEvent *)theEvent
-{
-    UNUSED_PARAM(theEvent);
-    _mouseIsInHUD = NO;
-    [self fadeWindowIn];
-}
-
-- (void)rewind:(id)sender
-{
-    UNUSED_PARAM(sender);
-    if (![_delegate videoElement])
-        return;
-    [_delegate videoElement]->rewind(30);
-}
-
-- (void)fastForward:(id)sender
-{
-    UNUSED_PARAM(sender);
-    if (![_delegate videoElement])
-        return;
-}
-
-- (void)exitFullscreen:(id)sender
-{
-    UNUSED_PARAM(sender);
-    if (_isEndingFullscreen)
-        return;
-    _isEndingFullscreen = YES;
-    [_delegate requestExitFullscreen]; 
-}
-
-// MARK: NSWindowDelegate
-
-- (void)windowDidExpose:(NSNotification *)notification
-{
-    UNUSED_PARAM(notification);
-    [self scheduleTimeUpdate];
-}
-
-- (void)windowDidClose:(NSNotification *)notification
-{
-    UNUSED_PARAM(notification);
-    [self unscheduleTimeUpdate];
-}
-
-@end
-
-#endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to