summaryrefslogtreecommitdiff
path: root/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.mm
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-05-07 11:21:11 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-05-07 11:21:11 +0200
commit2cf6c8816a73e0132bd8fa3b509d62d7c51b6e47 (patch)
tree988e8c5b116dd0466244ae2fe5af8ee9be926d76 /Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.mm
parentdd91e772430dc294e3bf478c119ef8d43c0a3358 (diff)
downloadqtwebkit-2cf6c8816a73e0132bd8fa3b509d62d7c51b6e47.tar.gz
Imported WebKit commit 7e538425aa020340619e927792f3d895061fb54b (http://svn.webkit.org/repository/webkit/trunk@116286)
Diffstat (limited to 'Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.mm')
-rw-r--r--Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.mm59
1 files changed, 48 insertions, 11 deletions
diff --git a/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.mm b/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.mm
index b32d5c9ee..9b3c11422 100644
--- a/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.mm
+++ b/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.mm
@@ -51,6 +51,7 @@ using namespace WebCore;
static RetainPtr<NSWindow> createBackgroundFullscreenWindow(NSRect frame);
static const CFTimeInterval defaultAnimationDuration = 0.5;
+static const NSTimeInterval DefaultWatchdogTimerInterval = 1;
@interface WKFullScreenWindowController(Private)<NSAnimationDelegate>
- (void)_updateMenuAndDockForFullScreen;
@@ -130,12 +131,22 @@ static const CFTimeInterval defaultAnimationDuration = 0.5;
_webView = webView;
}
+- (BOOL)isFullScreen
+{
+ return _isFullScreen;
+}
+
#pragma mark -
#pragma mark NSWindowController overrides
- (void)cancelOperation:(id)sender
{
- [self performSelector:@selector(exitFullScreen) withObject:nil afterDelay:0];
+ [self _manager]->requestExitFullScreen();
+
+ // If the page doesn't respond in DefaultWatchdogTimerInterval seconds, it could be because
+ // the WebProcess has hung, so exit anyway.
+ if (!_watchdogTimer)
+ _watchdogTimer = adoptNS([NSTimer scheduledTimerWithTimeInterval:DefaultWatchdogTimerInterval target:self selector:@selector(exitFullScreen) userInfo:nil repeats:NO]);
}
#pragma mark -
@@ -216,8 +227,8 @@ static const CFTimeInterval defaultAnimationDuration = 0.5;
[[self window] makeResponder:webWindowFirstResponder firstResponderIfDescendantOfView:_webView];
- [self _manager]->willEnterFullScreen();
[self _manager]->setAnimatingFullScreen(true);
+ [self _manager]->willEnterFullScreen();
}
- (void)beganEnterFullScreenWithInitialFrame:(const WebCore::IntRect&)initialFrame finalFrame:(const WebCore::IntRect&)finalFrame
@@ -243,8 +254,8 @@ static const CFTimeInterval defaultAnimationDuration = 0.5;
if (completed) {
// Screen updates to be re-enabled ta the end of the current block.
NSDisableScreenUpdates();
- [self _manager]->setAnimatingFullScreen(false);
[self _manager]->didEnterFullScreen();
+ [self _manager]->setAnimatingFullScreen(false);
NSRect windowBounds = [[self window] frame];
windowBounds.origin = NSZeroPoint;
@@ -275,6 +286,11 @@ static const CFTimeInterval defaultAnimationDuration = 0.5;
- (void)exitFullScreen
{
+ if (_watchdogTimer) {
+ [_watchdogTimer.get() invalidate];
+ _watchdogTimer.clear();
+ }
+
if (!_isFullScreen)
return;
_isFullScreen = NO;
@@ -283,8 +299,8 @@ static const CFTimeInterval defaultAnimationDuration = 0.5;
NSDisableScreenUpdates();
[[self window] setAutodisplay:NO];
- [self _manager]->willExitFullScreen();
[self _manager]->setAnimatingFullScreen(true);
+ [self _manager]->willExitFullScreen();
}
- (void)beganExitFullScreenWithInitialFrame:(const WebCore::IntRect&)initialFrame finalFrame:(const WebCore::IntRect&)finalFrame
@@ -307,7 +323,7 @@ static const CFTimeInterval defaultAnimationDuration = 0.5;
#endif
// If the user has moved the fullScreen window into a new space, temporarily change
// the collectionBehavior of the webView's window so that it is pulled into the active space:
- if (![webWindow isOnActiveSpace]) {
+ if (!([webWindow respondsToSelector:@selector(isOnActiveSpace)] ? [webWindow isOnActiveSpace] : YES)) {
NSWindowCollectionBehavior behavior = [webWindow collectionBehavior];
[webWindow setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces];
[webWindow orderWindow:NSWindowBelow relativeTo:[[self window] windowNumber]];
@@ -322,6 +338,8 @@ static const CFTimeInterval defaultAnimationDuration = 0.5;
[self _startExitFullScreenAnimationWithDuration:defaultAnimationDuration];
}
+static void completeFinishExitFullScreenAnimationAfterRepaint(WKErrorRef, void*);
+
- (void)finishedExitFullScreenAnimation:(bool)completed
{
if (!_isExitingFullScreen)
@@ -330,11 +348,9 @@ static const CFTimeInterval defaultAnimationDuration = 0.5;
[self _updateMenuAndDockForFullScreen];
- // Screen updates to be re-enabled ta the end of the current function.
+ // Screen updates to be re-enabled in completeFinishExitFullScreenAnimationAfterRepaint.
NSDisableScreenUpdates();
-
- [self _manager]->setAnimatingFullScreen(false);
- [self _manager]->didExitFullScreen();
+ [[_webViewPlaceholder.get() window] setAutodisplay:NO];
NSResponder *firstResponder = [[self window] firstResponder];
[self _swapView:_webViewPlaceholder.get() with:_webView];
@@ -354,9 +370,26 @@ static const CFTimeInterval defaultAnimationDuration = 0.5;
[_backgroundWindow.get() orderOut:self];
[_backgroundWindow.get() setFrame:NSZeroRect display:YES];
+ [[_webView window] makeKeyAndOrderFront:self];
+
+ // These messages must be sent after the swap or flashing will occur during forceRepaint:
+ [self _manager]->didExitFullScreen();
+ [self _manager]->setAnimatingFullScreen(false);
+
+ [self _page]->forceRepaint(VoidCallback::create(self, completeFinishExitFullScreenAnimationAfterRepaint));
+}
+
+- (void)completeFinishExitFullScreenAnimationAfterRepaint
+{
+ [[_webView window] setAutodisplay:YES];
NSEnableScreenUpdates();
}
+static void completeFinishExitFullScreenAnimationAfterRepaint(WKErrorRef, void* _self)
+{
+ [(WKFullScreenWindowController*)_self completeFinishExitFullScreenAnimationAfterRepaint];
+}
+
- (void)close
{
// We are being asked to close rapidly, most likely because the page
@@ -410,7 +443,7 @@ static const CFTimeInterval defaultAnimationDuration = 0.5;
[NSApp setPresentationOptions:options];
else
#endif
- SetSystemUIMode(_isFullScreen ? kUIModeNormal : kUIModeAllHidden, 0);
+ SetSystemUIMode(_isFullScreen ? kUIModeAllHidden : kUIModeNormal, 0);
}
- (WebPageProxy*)_page
@@ -433,7 +466,8 @@ static const CFTimeInterval defaultAnimationDuration = 0.5;
[otherView setFrame:[view frame]];
[otherView setAutoresizingMask:[view autoresizingMask]];
[otherView removeFromSuperview];
- [[view superview] replaceSubview:view with:otherView];
+ [[view superview] addSubview:otherView positioned:NSWindowAbove relativeTo:view];
+ [view removeFromSuperview];
[CATransaction commit];
}
@@ -449,6 +483,9 @@ static RetainPtr<NSWindow> createBackgroundFullscreenWindow(NSRect frame)
static NSRect windowFrameFromApparentFrames(NSRect screenFrame, NSRect initialFrame, NSRect finalFrame)
{
NSRect initialWindowFrame;
+ if (!NSWidth(initialFrame) || !NSWidth(finalFrame) || !NSHeight(initialFrame) || !NSHeight(finalFrame))
+ return screenFrame;
+
CGFloat xScale = NSWidth(screenFrame) / NSWidth(finalFrame);
CGFloat yScale = NSHeight(screenFrame) / NSHeight(finalFrame);
CGFloat xTrans = NSMinX(screenFrame) - NSMinX(finalFrame);