2009-10-28 Eric Carlson <eric.carlson@apple.com>
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Oct 2009 22:36:47 +0000 (22:36 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Oct 2009 22:36:47 +0000 (22:36 +0000)
        Reviewed by Simon Fraser.

        <rdar://problem/7303145>
        Can't exit full screen mode or restart movie after pressing command -R.

        * html/HTMLMediaElement.cpp:
        (WebCore::HTMLMediaElement::removedFromDocument):
        (WebCore::HTMLMediaElement::documentWillBecomeInactive):
            Exit from fullscreen if necessary.
        * html/HTMLMediaElement.h:

2009-10-28  Eric Carlson  <eric.carlson@apple.com>

        Reviewed by Simon Fraser.

        <rdar://problem/7303145>
        Can't exit full screen mode or restart movie after pressing command -R.

        * WebView/WebVideoFullscreenController.mm:
        (-[WebVideoFullscreenController _requestExit]):
            New, call media element's exitFullscreen method.
        (-[WebVideoFullscreenController requestExitFullscreenWithAnimation:]):
            Call mediaElement->exitFullscreen() after a delay as it turns around and calls
            WebVideoFullscreenController:exitFullscreen.

        * WebView/WebVideoFullscreenHUDWindowController.h:
        * WebView/WebVideoFullscreenHUDWindowController.mm:
        (-[WebVideoFullscreenHUDWindow resignFirstResponder]):
            New, don't give up responder status.
        (-[WebVideoFullscreenHUDWindow performKeyEquivalent:]):
            New, block all command key events.
        (-[WebVideoFullscreenHUDWindowController exitFullscreen:]):
            Remember when we are in the process of exiting fullscreen, don't allow recursion.

        * WebView/WebView.mm:
        (-[WebView _exitFullscreen]):
            Early return if fullscreen controller is nil.

        * WebView/WebWindowAnimation.h:
            Correct comment about _window retain status.
        * WebView/WebWindowAnimation.m:
        (-[WebWindowScaleAnimation dealloc]):
            Don't release _window, we never reatained it.

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

WebCore/ChangeLog
WebCore/html/HTMLMediaElement.cpp
WebCore/html/HTMLMediaElement.h
WebKit/mac/ChangeLog
WebKit/mac/WebView/WebVideoFullscreenController.mm
WebKit/mac/WebView/WebVideoFullscreenHUDWindowController.h
WebKit/mac/WebView/WebVideoFullscreenHUDWindowController.mm
WebKit/mac/WebView/WebView.mm
WebKit/mac/WebView/WebWindowAnimation.h
WebKit/mac/WebView/WebWindowAnimation.m

index b23e41be4b167ed79be71968424187281ae6a4f1..c42a4af3633d9352391d684f61651b9c10c21285 100644 (file)
@@ -1,3 +1,16 @@
+2009-10-28  Eric Carlson  <eric.carlson@apple.com>
+
+        Reviewed by Simon Fraser.
+
+        <rdar://problem/7303145> 
+        Can't exit full screen mode or restart movie after pressing command -R.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::removedFromDocument):
+        (WebCore::HTMLMediaElement::documentWillBecomeInactive):
+            Exit from fullscreen if necessary.
+        * html/HTMLMediaElement.h:
+
 2009-10-28  Alexey Proskuryakov  <ap@apple.com>
 
         Unreviewed - a trivial fix to get Windows bots running.
index 11ca3bad8b6a4317a7d1c5c1dca806cc713b7e88..729aceb2092d5e1fde129d272e8ebc7dc2830375 100644 (file)
@@ -247,16 +247,12 @@ void HTMLMediaElement::insertedIntoDocument()
         scheduleLoad();
 }
 
-void HTMLMediaElement::willRemove()
-{
-    if (m_isFullscreen)
-        exitFullscreen();
-    HTMLElement::willRemove();
-}
 void HTMLMediaElement::removedFromDocument()
 {
     if (m_networkState > NETWORK_EMPTY)
         pause();
+    if (m_isFullscreen)
+        exitFullscreen();
     HTMLElement::removedFromDocument();
 }
 
@@ -1678,6 +1674,9 @@ void HTMLMediaElement::userCancelledLoad()
 
 void HTMLMediaElement::documentWillBecomeInactive()
 {
+    if (m_isFullscreen)
+        exitFullscreen();
+
     m_inActiveDocument = false;
     userCancelledLoad();
 
index 0005e07dcdce3ba05691af5d7e0416110b909efd..405f0133503fff12e92a297b7aff91eda0fca227 100644 (file)
@@ -57,7 +57,6 @@ public:
     virtual bool rendererIsNeeded(RenderStyle*);
     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
     virtual void insertedIntoDocument();
-    virtual void willRemove();
     virtual void removedFromDocument();
     virtual void attach();
     virtual void recalcStyle(StyleChange);
index 906d571b1e2316aeadab9ecd2434e9ec0dd16510..9104b89106e7fc440b6580d0ac7fcbc8d7685903 100644 (file)
@@ -1,3 +1,36 @@
+2009-10-28  Eric Carlson  <eric.carlson@apple.com>
+
+        Reviewed by Simon Fraser.
+
+        <rdar://problem/7303145> 
+        Can't exit full screen mode or restart movie after pressing command -R.
+
+        * WebView/WebVideoFullscreenController.mm:
+        (-[WebVideoFullscreenController _requestExit]): 
+            New, call media element's exitFullscreen method.
+        (-[WebVideoFullscreenController requestExitFullscreenWithAnimation:]): 
+            Call mediaElement->exitFullscreen() after a delay as it turns around and calls
+            WebVideoFullscreenController:exitFullscreen.
+
+        * WebView/WebVideoFullscreenHUDWindowController.h:
+        * WebView/WebVideoFullscreenHUDWindowController.mm:
+        (-[WebVideoFullscreenHUDWindow resignFirstResponder]):
+            New, don't give up responder status.
+        (-[WebVideoFullscreenHUDWindow performKeyEquivalent:]):
+            New, block all command key events.
+        (-[WebVideoFullscreenHUDWindowController exitFullscreen:]):
+            Remember when we are in the process of exiting fullscreen, don't allow recursion.
+
+        * WebView/WebView.mm:
+        (-[WebView _exitFullscreen]):
+            Early return if fullscreen controller is nil.
+
+        * WebView/WebWindowAnimation.h: 
+            Correct comment about _window retain status.
+        * WebView/WebWindowAnimation.m:
+        (-[WebWindowScaleAnimation dealloc]):
+            Don't release _window, we never reatained it.
+
 2009-10-27  Shinichiro Hamaji  <hamaji@chromium.org>
 
         Reviewed by Darin Adler.
index 39ec72a0b7ef70762fa8be291c447ee3a2756bf2..fe07f3e415c5ec98de834bddfb144750722c834e 100644 (file)
@@ -280,14 +280,21 @@ static NSWindow *createBackgroundFullscreenWindow(NSRect frame, int level)
 #pragma mark -
 #pragma mark Window callback
 
+- (void)_requestExit
+{
+    if (_mediaElement)
+        _mediaElement->exitFullscreen();
+    _forceDisableAnimation = NO;
+}
+
 - (void)requestExitFullscreenWithAnimation:(BOOL)animation
 {
     if (_isEndingFullscreen)
         return;
 
     _forceDisableAnimation = !animation;
-    _mediaElement->exitFullscreen();
-    _forceDisableAnimation = NO;
+    [self performSelector:@selector(_requestExit) withObject:nil afterDelay:0];
+
 }
 
 - (void)requestExitFullscreen
index abc809220a1862d436bf63c19959180addcf6e05..1ffa596f16d963d657bc25a27e237913c11d4b89 100644 (file)
@@ -38,6 +38,7 @@
     NSTrackingArea *_area;
 #endif
     BOOL _mouseIsInHUD;
+    BOOL _isEndingFullscreen;
 
     NSControl *_timeline;
     NSTextField *_remainingTimeText;
index 666ea10bdcbc1ab1b00c9a1d5afa264a3ddf6fa2..c61ae7cc91f8b81f6c20cdd468d648326fe405f5 100644 (file)
@@ -117,6 +117,23 @@ using namespace std;
     [[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] != NSKeyDown)
+        return NO;
+    
+    if (!([event modifierFlags] & NSCommandKeyMask))
+        return NO;
+    
+    return YES;
+}
+
 @end
 
 //
@@ -604,6 +621,9 @@ static NSString *stringToTimeTextAttributed(NSString *string, NSTextAlignment al
 
 - (void)exitFullscreen:(id)sender
 {
+    if (_isEndingFullscreen)
+        return;
+    _isEndingFullscreen = YES;
     [_delegate requestExitFullscreen]; 
 }
 
index dcd3989402912d31b5188c3501fcfd0064bf6846..25da6310fc4b05b062b74060180fe6090c11bf3b 100644 (file)
@@ -5544,6 +5544,8 @@ static void layerSyncRunLoopObserverCallBack(CFRunLoopObserverRef, CFRunLoopActi
 
 - (void)_exitFullscreen
 {
+    if (!_private->fullscreenController)
+        return;
     [_private->fullscreenController exitFullscreen];
     [_private->fullscreenController release];
     _private->fullscreenController = nil;
index c73dcce5a11a7988b16299b8baeebcc4f48116ff..ecf975bdb5f084d7dd971eb20d026e2fd80382e2 100644 (file)
@@ -46,7 +46,7 @@
 @interface WebWindowFadeAnimation : NSAnimation {
 @private
     CGFloat _initialAlpha, _finalAlpha;
-    NSWindow *_window; // (retain)
+    NSWindow *_window; // (assign)
     BOOL _isStopped;
     
 }
index 3ab64bf28df9d0e289120aa251f65f0f0c6defd8..6eadb2150e4defadbf17f5e84f3450d132e125fe 100644 (file)
@@ -80,7 +80,6 @@ static CGFloat squaredDistance(NSPoint point1, NSPoint point2)
 
 - (void) dealloc
 {
-    [_window release];
     [_subAnimation release];
     [super dealloc];
 }