Changeset 135944 in webkit
- Timestamp:
- Nov 27, 2012, 4:40:26 PM (13 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r135935 r135944 1 2012-10-22 Jer Noble <jer.noble@apple.com> 2 3 [WK2] [Mac] WebKit Full Screen API should use NSWindow full screen API. 4 https://bugs.webkit.org/show_bug.cgi?id=100025 5 6 Reviewed by Dan Bernstein. 7 8 Use the NSWindow full screen API when taking the WebView full screen. To facility the case where the browser window is already 9 in full screen mode, no longer hide the browser window when entering full screen. Instead, provide a placeholder view with 10 instructions to click the placeholder to exit full screen. 11 12 * UIProcess/mac/WKFullScreenWindowController.h: 13 * UIProcess/mac/WKFullScreenWindowController.mm: 14 (-[WKFullScreenWindowController init]): Set self as the window's delegate; enable window's full screen action. 15 (-[WKFullScreenWindowController dealloc]): Clear our window's delegate. 16 (-[WKFullScreenWindowController applicationDidChangeScreenParameters:]): Remove reference to _updateWindowAndDockForFullScreen. 17 (-[WKFullScreenWindowController enterFullScreen:]): Ditto. Create a WKFullScreenPlaceholderView instead of generic NSImageView. 18 (-[WKFullScreenWindowController beganEnterFullScreenWithInitialFrame:finalFrame:]): Ditto. Call NSWindow enterFullScreen: API. 19 (-[WKFullScreenWindowController finishedEnterFullScreenAnimation:]): Show the warning view. 20 (-[WKFullScreenWindowController exitFullScreen]): Hide the warning view. 21 (-[WKFullScreenWindowController beganExitFullScreenWithInitialFrame:finalFrame:]): Add special case where we are exiting 22 from full screen mode when the full screen window is not on screen. 23 (-[WKFullScreenWindowController finishedExitFullScreenAnimation:]): Remove reference to _updateMenuAndDockForFullScreen. 24 (-[WKFullScreenWindowController customWindowsToEnterFullScreenForWindow:]): Added. Return the background window and the full screen window. 25 (-[WKFullScreenWindowController customWindowsToExitFullScreenForWindow:]): Ditto. 26 (-[WKFullScreenWindowController window:startCustomAnimationToEnterFullScreenWithDuration:]): Added. Call through to _startEnterFullScreenAnimationWithDuration: 27 (-[WKFullScreenWindowController window:startCustomAnimationToExitFullScreenWithDuration:]): Added. Call through to _startExitFullScreenAnimationWithDuration: 28 1 29 2012-11-27 Yael Aharon <yael.aharon@intel.com> 2 30 -
trunk/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.h
r113238 r135944 39 39 40 40 @class WKView; 41 @class WebCoreFullScreenPlaceholderView; 41 42 @class WebWindowScaleAnimation; 42 43 @class WebWindowFadeAnimation; 43 44 44 @interface WKFullScreenWindowController : NSWindowController {45 @interface WKFullScreenWindowController : NSWindowController<NSWindowDelegate> { 45 46 @private 46 47 WKView *_webView; 47 RetainPtr< NSImageView> _webViewPlaceholder;48 RetainPtr<WebCoreFullScreenPlaceholderView> _webViewPlaceholder; 48 49 RetainPtr<WebWindowScaleAnimation> _scaleAnimation; 49 50 RetainPtr<WebWindowFadeAnimation> _fadeAnimation; -
trunk/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.mm
r132738 r135944 40 40 #import <WebCore/FloatRect.h> 41 41 #import <WebCore/IntRect.h> 42 #import <WebCore/LocalizedStrings.h> 43 #import <WebCore/WebCoreFullScreenPlaceholderView.h> 42 44 #import <WebCore/WebCoreFullScreenWindow.h> 43 45 #import <WebCore/WebWindowAnimation.h> … … 54 56 static const NSTimeInterval DefaultWatchdogTimerInterval = 1; 55 57 58 @interface NSWindow (WebNSWindowDetails) 59 - (void)exitFullScreenMode:(id)sender; 60 - (void)enterFullScreenMode:(id)sender; 61 @end 62 56 63 @interface WKFullScreenWindowController(Private)<NSAnimationDelegate> 57 - (void)_updateMenuAndDockForFullScreen;58 64 - (void)_replaceView:(NSView*)view with:(NSView*)otherView; 59 65 - (WebPageProxy*)_page; … … 88 94 - (id)init 89 95 { 90 NSWindow *window = [[WebCoreFullScreenWindow alloc] initWithContentRect:NSZeroRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]; 91 self = [super initWithWindow:window]; 92 [window release]; 96 RetainPtr<NSWindow> window = adoptNS([[WebCoreFullScreenWindow alloc] initWithContentRect:NSZeroRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]); 97 self = [super initWithWindow:window.get()]; 93 98 if (!self) 94 99 return nil; 100 [window.get() setDelegate:self]; 101 [window.get() setCollectionBehavior:([window collectionBehavior] | NSWindowCollectionBehaviorFullScreenPrimary)]; 95 102 [self windowDidLoad]; 96 103 … … 101 108 { 102 109 [self setWebView:nil]; 110 [[self window] setDelegate:nil]; 103 111 104 112 [NSObject cancelPreviousPerformRequestsWithTarget:self]; … … 175 183 // Update our presentation parameters, and ensure that the full screen window occupies the 176 184 // entire screen: 177 [self _updateMenuAndDockForFullScreen];178 185 NSWindow* window = [self window]; 179 186 NSRect screenFrame = [[window screen] frame]; … … 213 220 _isFullScreen = YES; 214 221 215 [self _updateMenuAndDockForFullScreen];216 217 222 if (!screen) 218 223 screen = [NSScreen mainScreen]; … … 247 252 // Swap the webView placeholder into place. 248 253 if (!_webViewPlaceholder) { 249 _webViewPlaceholder.adoptNS([[ NSImageView alloc] init]);250 [_webViewPlaceholder.get() set Layer:[CALayer layer]];251 [_webViewPlaceholder.get() set WantsLayer:YES];254 _webViewPlaceholder.adoptNS([[WebCoreFullScreenPlaceholderView alloc] initWithFrame:[_webView frame]]); 255 [_webViewPlaceholder.get() setTarget:self]; 256 [_webViewPlaceholder.get() setAction:@selector(cancelOperation:)]; 252 257 } 253 [ [_webViewPlaceholder.get() layer]setContents:(id)webViewContents.get()];258 [_webViewPlaceholder.get() setContents:(id)webViewContents.get()]; 254 259 [self _replaceView:_webView with:_webViewPlaceholder.get()]; 255 260 … … 274 279 _finalFrame = finalFrame; 275 280 276 [self _updateMenuAndDockForFullScreen]; 277 278 [self _startEnterFullScreenAnimationWithDuration:defaultAnimationDuration]; 281 if (!_backgroundWindow) 282 _backgroundWindow = createBackgroundFullscreenWindow(NSZeroRect); 283 284 [[self window] enterFullScreenMode:self]; 279 285 } 280 286 … … 294 300 windowBounds.origin = NSZeroPoint; 295 301 WKWindowSetClipRect([self window], windowBounds); 296 297 NSWindow *webWindow = [_webViewPlaceholder.get() window];298 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070299 // In Lion, NSWindow will animate into and out of orderOut operations. Suppress that300 // behavior here, making sure to reset the animation behavior afterward.301 NSWindowAnimationBehavior animationBehavior = [webWindow animationBehavior];302 [webWindow setAnimationBehavior:NSWindowAnimationBehaviorNone];303 #endif304 [webWindow orderOut:self];305 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070306 [webWindow setAnimationBehavior:animationBehavior];307 #endif308 302 309 303 [_fadeAnimation.get() stopAnimation]; … … 313 307 [_backgroundWindow.get() orderOut:self]; 314 308 [_backgroundWindow.get() setFrame:NSZeroRect display:YES]; 309 310 [_webViewPlaceholder.get() setExitWarningVisible:YES]; 315 311 NSEnableScreenUpdates(); 316 312 } else … … 329 325 _isFullScreen = NO; 330 326 331 // Screen updates to be re-enabled in _startExitFullScreenAnimationWithDuration: 327 [_webViewPlaceholder.get() setExitWarningVisible:NO]; 328 329 // Screen updates to be re-enabled in _startExitFullScreenAnimationWithDuration: or beganExitFullScreenWithInitialFrame:finalFrame: 332 330 NSDisableScreenUpdates(); 333 331 [[self window] setAutodisplay:NO]; … … 350 348 [self finishedEnterFullScreenAnimation:NO]; 351 349 352 [self _updateMenuAndDockForFullScreen]; 353 354 NSWindow* webWindow = [_webViewPlaceholder.get() window]; 355 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 356 // In Lion, NSWindow will animate into and out of orderOut operations. Suppress that 357 // behavior here, making sure to reset the animation behavior afterward. 358 NSWindowAnimationBehavior animationBehavior = [webWindow animationBehavior]; 359 [webWindow setAnimationBehavior:NSWindowAnimationBehaviorNone]; 360 #endif 361 // If the user has moved the fullScreen window into a new space, temporarily change 362 // the collectionBehavior of the webView's window so that it is pulled into the active space: 363 if (!([webWindow respondsToSelector:@selector(isOnActiveSpace)] ? [webWindow isOnActiveSpace] : YES)) { 364 NSWindowCollectionBehavior behavior = [webWindow collectionBehavior]; 365 [webWindow setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces]; 366 [webWindow orderWindow:NSWindowBelow relativeTo:[[self window] windowNumber]]; 367 [webWindow setCollectionBehavior:behavior]; 368 } else 369 [webWindow orderWindow:NSWindowBelow relativeTo:[[self window] windowNumber]]; 370 371 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 372 [webWindow setAnimationBehavior:animationBehavior]; 373 #endif 374 375 [self _startExitFullScreenAnimationWithDuration:defaultAnimationDuration]; 350 if (![[self window] isOnActiveSpace]) { 351 // If the full screen window is not in the active space, the NSWindow full screen animation delegate methods 352 // will never be called. So call finishedExitFullScreenAnimation explicitly. 353 [self finishedExitFullScreenAnimation:YES]; 354 355 // Because we are breaking the normal animation pattern, re-enable screen updates 356 // as exitFullScreen has disabled them, but _startExitFullScreenAnimationWithDuration: 357 // will never be called. 358 NSEnableScreenUpdates(); 359 } 360 361 [[self window] exitFullScreenMode:self]; 376 362 } 377 363 … … 383 369 return; 384 370 _isExitingFullScreen = NO; 385 386 [self _updateMenuAndDockForFullScreen];387 371 388 372 // Screen updates to be re-enabled in completeFinishExitFullScreenAnimationAfterRepaint. … … 445 429 446 430 #pragma mark - 447 #pragma mark NSAnimation delegate 448 449 - (void)animationDidEnd:(NSAnimation*)animation 450 { 451 if (_isFullScreen) 452 [self finishedEnterFullScreenAnimation:YES]; 453 else 454 [self finishedExitFullScreenAnimation:YES]; 431 #pragma mark Custom NSWindow Full Screen Animation 432 433 - (NSArray *)customWindowsToEnterFullScreenForWindow:(NSWindow *)window 434 { 435 return [NSArray arrayWithObjects:[self window], _backgroundWindow.get(), nil]; 436 } 437 438 - (NSArray *)customWindowsToExitFullScreenForWindow:(NSWindow *)window 439 { 440 return [NSArray arrayWithObjects:[self window], _backgroundWindow.get(), nil]; 441 } 442 443 - (void)window:(NSWindow *)window startCustomAnimationToEnterFullScreenWithDuration:(NSTimeInterval)duration 444 { 445 [self _startEnterFullScreenAnimationWithDuration:duration]; 446 } 447 448 - (void)window:(NSWindow *)window startCustomAnimationToExitFullScreenWithDuration:(NSTimeInterval)duration 449 { 450 [self _startExitFullScreenAnimationWithDuration:duration]; 451 } 452 453 - (void)windowDidFailToEnterFullScreen:(NSWindow *)window 454 { 455 [self finishedEnterFullScreenAnimation:NO]; 456 } 457 458 - (void)windowDidEnterFullScreen:(NSNotification*)notification 459 { 460 [self finishedEnterFullScreenAnimation:YES]; 461 } 462 463 - (void)windowDidFailToExitFullScreen:(NSWindow *)window 464 { 465 [self finishedExitFullScreenAnimation:NO]; 466 } 467 468 - (void)windowDidExitFullScreen:(NSNotification*)notification 469 { 470 [self finishedExitFullScreenAnimation:YES]; 455 471 } 456 472 457 473 #pragma mark - 458 474 #pragma mark Internal Interface 459 460 - (void)_updateMenuAndDockForFullScreen461 {462 // NSApplicationPresentationOptions is available on > 10.6 only:463 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060464 NSApplicationPresentationOptions options = NSApplicationPresentationDefault;465 NSScreen* fullScreenScreen = [[self window] screen];466 467 if (_isFullScreen) {468 // Auto-hide the menu bar if the fullScreenScreen contains the menu bar:469 // NOTE: if the fullScreenScreen contains the menu bar but not the dock, we must still470 // auto-hide the dock, or an exception will be thrown.471 if ([[NSScreen screens] objectAtIndex:0] == fullScreenScreen)472 options |= (NSApplicationPresentationAutoHideMenuBar | NSApplicationPresentationAutoHideDock);473 // Check if the current screen contains the dock by comparing the screen's frame to its474 // visibleFrame; if a dock is present, the visibleFrame will differ. If the current screen475 // contains the dock, hide it.476 else if (!NSEqualRects([fullScreenScreen frame], [fullScreenScreen visibleFrame]))477 options |= NSApplicationPresentationAutoHideDock;478 }479 480 if ([NSApp respondsToSelector:@selector(setPresentationOptions:)])481 [NSApp setPresentationOptions:options];482 else483 #endif484 SetSystemUIMode(_isFullScreen ? kUIModeAllHidden : kUIModeNormal, 0);485 }486 475 487 476 - (WebPageProxy*)_page … … 544 533 545 534 [_scaleAnimation.get() setAnimationBlockingMode:NSAnimationNonblocking]; 546 [_scaleAnimation.get() setDelegate:self];547 535 [_scaleAnimation.get() setCurrentProgress:0]; 548 536 [_scaleAnimation.get() startAnimation]; … … 597 585 598 586 [_scaleAnimation.get() setAnimationBlockingMode:NSAnimationNonblocking]; 599 [_scaleAnimation.get() setDelegate:self];600 587 [_scaleAnimation.get() setCurrentProgress:0]; 601 588 [_scaleAnimation.get() startAnimation];
Note:
See TracChangeset
for help on using the changeset viewer.