ESC key in full screen does not result in webkitFullScreenChange event.
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Apr 2012 17:33:50 +0000 (17:33 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Apr 2012 17:33:50 +0000 (17:33 +0000)
https://bugs.webkit.org/show_bug.cgi?id=82755
<rdar://problem/11093513>

Reviewed by Eric Carlson.

Source/WebCore:

* WebCore.exp.in: Export the WebCore::Document::webkitCancelFullScreen() symbol.

Source/WebKit/mac:

Instead of exiting full screen directly, ask the document to initiate exiting full screen. This ensures
that the entire full screen element stack is cleared and that webkitFullScreenChange events are sent
out correctly.

* WebView/WebFullScreenController.mm:
(-[WebFullScreenController cancelOperation:]):
(-[WebFullScreenController requestExitFullScreen]):

Source/WebKit2:

Instead of exiting full screen directly, ask the document to initiate exiting full screen. This ensures
that the entire full screen element stack is cleared and that webkitFullScreenChange events are sent
out correctly.

Because the WebProcess may be stalled or hung, add a watchdog timer which will force an exit of full
screen if the WebProcess does not respond in a timely manner (defaults to 1s).

Add a new method, requestExitFullScreen, which calls through to the WebProcess and Document:
* UIProcess/WebFullScreenManagerProxy.cpp:
(WebKit::WebFullScreenManagerProxy::requestExitFullScreen):
* UIProcess/WebFullScreenManagerProxy.h:
* WebProcess/FullScreen/WebFullScreenManager.cpp:
(WebKit::WebFullScreenManager::requestExitFullScreen):
* WebProcess/FullScreen/WebFullScreenManager.h:
* WebProcess/FullScreen/WebFullScreenManager.messages.in:

Request that the document exits full screen when the ESC key is pressed:
* UIProcess/mac/WKFullScreenWindowController.h:
* UIProcess/mac/WKFullScreenWindowController.mm:
(-[WKFullScreenWindowController cancelOperation:]):
(-[WKFullScreenWindowController exitFullScreen]):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@113056 268f45cc-cd09-0410-ab3c-d52691b4dbfc

12 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebFullScreenController.mm
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/WebFullScreenManagerProxy.cpp
Source/WebKit2/UIProcess/WebFullScreenManagerProxy.h
Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.h
Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.mm
Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.cpp
Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.h
Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.messages.in

index db1ee62..09c9bd2 100644 (file)
@@ -1,3 +1,13 @@
+2012-04-03  Jer Noble  <jer.noble@apple.com>
+
+        ESC key in full screen does not result in webkitFullScreenChange event.
+        https://bugs.webkit.org/show_bug.cgi?id=82755
+        <rdar://problem/11093513>
+
+        Reviewed by Eric Carlson.
+
+        * WebCore.exp.in: Export the WebCore::Document::webkitCancelFullScreen() symbol.
+
 2012-04-03  Ryosuke Niwa  <rniwa@webkit.org>
 
         REGRESSION(r80439): Crash in StylePropertySet::borderSpacingValue
index 898ca47..28089ac 100644 (file)
@@ -2059,6 +2059,7 @@ __ZN7WebCore9HTMLNames8audioTagE
 #endif
 
 #if ENABLE(FULLSCREEN_API)
+__ZN7WebCore8Document22webkitCancelFullScreenEv
 __ZN7WebCore8Document33webkitDidExitFullScreenForElementEPNS_7ElementE
 __ZN7WebCore8Document34webkitDidEnterFullScreenForElementEPNS_7ElementE
 __ZN7WebCore8Document34webkitWillExitFullScreenForElementEPNS_7ElementE
index bf6f961..4c4bd52 100644 (file)
@@ -1,3 +1,19 @@
+2012-04-03  Jer Noble  <jer.noble@apple.com>
+
+        ESC key in full screen does not result in webkitFullScreenChange event.
+        https://bugs.webkit.org/show_bug.cgi?id=82755
+        <rdar://problem/11093513>
+
+        Reviewed by Eric Carlson.
+
+        Instead of exiting full screen directly, ask the document to initiate exiting full screen. This ensures
+        that the entire full screen element stack is cleared and that webkitFullScreenChange events are sent
+        out correctly.
+
+        * WebView/WebFullScreenController.mm:
+        (-[WebFullScreenController cancelOperation:]):
+        (-[WebFullScreenController requestExitFullScreen]):
+
 2012-04-01  Jon Lee  <jonlee@apple.com>
 
         Rename notification properties and functions
index eda499c..9589d83 100644 (file)
@@ -155,7 +155,7 @@ static IntRect screenRectOfContents(Element* element)
 
 - (void)cancelOperation:(id)sender
 {
-    [self performSelector:@selector(exitFullScreen) withObject:nil afterDelay:0];
+    [self performSelector:@selector(requestExitFullScreen) withObject:nil afterDelay:0];
 }
 
 #pragma mark -
@@ -290,6 +290,13 @@ static IntRect screenRectOfContents(Element* element)
         [_scaleAnimation.get() stopAnimation];
 }
 
+- (void)requestExitFullScreen
+{
+    if (!_element)
+        return;
+    _element->document()->webkitCancelFullScreen();
+}
+
 - (void)exitFullScreen
 {
     if (!_isFullScreen)
index 054d636..d966314 100644 (file)
@@ -1,3 +1,33 @@
+2012-04-03  Jer Noble  <jer.noble@apple.com>
+
+        ESC key in full screen does not result in webkitFullScreenChange event.
+        https://bugs.webkit.org/show_bug.cgi?id=82755
+        <rdar://problem/11093513>
+
+        Reviewed by Eric Carlson.
+
+        Instead of exiting full screen directly, ask the document to initiate exiting full screen. This ensures
+        that the entire full screen element stack is cleared and that webkitFullScreenChange events are sent
+        out correctly.
+
+        Because the WebProcess may be stalled or hung, add a watchdog timer which will force an exit of full
+        screen if the WebProcess does not respond in a timely manner (defaults to 1s).
+
+        Add a new method, requestExitFullScreen, which calls through to the WebProcess and Document:
+        * UIProcess/WebFullScreenManagerProxy.cpp:
+        (WebKit::WebFullScreenManagerProxy::requestExitFullScreen):
+        * UIProcess/WebFullScreenManagerProxy.h:
+        * WebProcess/FullScreen/WebFullScreenManager.cpp:
+        (WebKit::WebFullScreenManager::requestExitFullScreen):
+        * WebProcess/FullScreen/WebFullScreenManager.h:
+        * WebProcess/FullScreen/WebFullScreenManager.messages.in:
+
+        Request that the document exits full screen when the ESC key is pressed:
+        * UIProcess/mac/WKFullScreenWindowController.h:
+        * UIProcess/mac/WKFullScreenWindowController.mm:
+        (-[WKFullScreenWindowController cancelOperation:]):
+        (-[WKFullScreenWindowController exitFullScreen]):
+
 2012-04-03  Balazs Kelemen  <kbalazs@webkit.org>
 
         [Qt][WK2] ASSERT(!(outputBytes.size() % sizeof(UChar))) in PluginProcessProxyQt.cpp
index 21fe9cd..bb1bd60 100644 (file)
@@ -89,6 +89,11 @@ void WebFullScreenManagerProxy::setAnimatingFullScreen(bool animating)
     m_page->process()->send(Messages::WebFullScreenManager::SetAnimatingFullScreen(animating), m_page->pageID());
 }
 
+void WebFullScreenManagerProxy::requestExitFullScreen()
+{
+    m_page->process()->send(Messages::WebFullScreenManager::RequestExitFullScreen(), m_page->pageID());
+}
+
 void WebFullScreenManagerProxy::supportsFullScreen(bool withKeyboard, bool& supports)
 {
     supports = true;
index 4a3f07d..1e28baa 100644 (file)
@@ -82,6 +82,7 @@ public:
     void willExitFullScreen();
     void didExitFullScreen();
     void setAnimatingFullScreen(bool);
+    void requestExitFullScreen();
 
 private:
     WebFullScreenManagerProxy(WebPageProxy*);
index 4e9cbf0..263fb92 100644 (file)
@@ -50,6 +50,7 @@ class IntRect;
     RetainPtr<NSWindow> _backgroundWindow;
     NSRect _initialFrame;
     NSRect _finalFrame;
+    RetainPtr<NSTimer> _watchdogTimer;
     
     BOOL _isEnteringFullScreen;
     BOOL _isExitingFullScreen;
index b32d5c9..23bf7a1 100644 (file)
@@ -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;
@@ -135,7 +136,12 @@ static const CFTimeInterval defaultAnimationDuration = 0.5;
 
 - (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 -
@@ -275,6 +281,11 @@ static const CFTimeInterval defaultAnimationDuration = 0.5;
 
 - (void)exitFullScreen
 {
+    if (_watchdogTimer) {
+        [_watchdogTimer.get() invalidate];
+        _watchdogTimer.clear();
+    }
+
     if (!_isFullScreen)
         return;
     _isFullScreen = NO;
index bbe64e8..473a13c 100644 (file)
@@ -140,6 +140,12 @@ void WebFullScreenManager::setAnimatingFullScreen(bool animating)
     m_element->document()->setAnimatingFullScreen(animating);
 }
 
+void WebFullScreenManager::requestExitFullScreen()
+{
+    ASSERT(m_element);
+    m_element->document()->webkitCancelFullScreen();
+}
+
 } // namespace WebKit
 
 #endif // ENABLE(FULLSCREEN_API)
index 9724d55..1940762 100644 (file)
@@ -69,6 +69,7 @@ protected:
     WebFullScreenManager(WebPage*);
 
     void setAnimatingFullScreen(bool);
+    void requestExitFullScreen();
 
     void didReceiveWebFullScreenManagerMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
 
index d4ac946..239d33c 100644 (file)
@@ -22,6 +22,7 @@
 
 #if ENABLE(FULLSCREEN_API)
 messages -> WebFullScreenManager {
+    RequestExitFullScreen()
     WillEnterFullScreen()
     DidEnterFullScreen()
     WillExitFullScreen()