2010-05-22 Jer Noble <jer.noble@apple.com>
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 May 2010 22:29:24 +0000 (22:29 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 May 2010 22:29:24 +0000 (22:29 +0000)
        Reviewed by Adam Roben.

        Full screen doesn't work for video elements
        https://bugs.webkit.org/show_bug.cgi?id=39557
        rdar://problem/8011813

        Modified FullscreenVideoController to work with MediaPlayerPrivateFullscreenWindow.  The FullscreenVideoController
        is now MediaPlayerPrivate agnostic..

        * FullscreenVideoController.cpp:
        (FullscreenVideoController::LayoutClient::LayoutClient): New helper class which implements WKCACFLayerLayoutClient.
        (FullscreenVideoController::LayoutClient::layoutSublayersOfLayer):
        (FullscreenVideoController::FullscreenVideoController):
        (FullscreenVideoController::~FullscreenVideoController):
        (FullscreenVideoController::enterFullscreen):
        (FullscreenVideoController::exitFullscreen):
        (FullscreenVideoController::fullscreenClientWndProc): Handle WM_KEYDOWN.
        (FullscreenVideoController::createHUDWindow):
        (FullscreenVideoController::hudWndProc):  Handle WM_KEYDOWN.
        (FullscreenVideoController::onChar):
        (FullscreenVideoController::onKeyDown):  New function: handles the VK_ESCAPE case more reliably than WM_CHAR.
        * FullscreenVideoController.h:
        * WebView.h:
        (WebView::viewWindow): Added a simple viewWindow() accessor.
2010-05-22  Jer Noble  <jer.noble@apple.com>

        Reviewed by Adam Roben.

        Full screen doesn't work for video elements
        https://bugs.webkit.org/show_bug.cgi?id=39557
        rdar://problem/8011813

        Add fullscreen support for MediaPlayerPrivateVisualContext.  A new class, MediaPlayerPrivateFullscreenWindow,
        provides the fullscreen hwnd and layer renderer.  Any WKCACFLayer can be provided to MediaPlayerPrivateFullscreenWindow
        so future additional MediaPlayerPrivate implementations can use the fullscreen window.

        Minor additions have been made to the FloatSize and IntSize classes.

        MediaPlayerPrivateQuickTimeVisualContext now calls retrieveCurrentImage after creating a new
        videoLayer; this is an existing bug that was never really exposed before now.

        * WebCore.vcproj/WebCore.vcproj:
        * platform/graphics/FloatSize.h: Added aspectRatio() and scale(float).
        (WebCore::FloatSize::aspectRatio):
        (WebCore::FloatSize::scale):
        * platform/graphics/IntSize.h: Added aspectRatio().
        (WebCore::IntSize::aspectRatio):
        * platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp: Added.
        * platform/graphics/win/MediaPlayerPrivateFullscreenWindow.h: Added.
        * platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp: Call retrieveCurrentImage() after creating the videoLayer.
        (WebCore::MediaPlayerPrivateQuickTimeVisualContext::supportsFullscreen):
        (WebCore::MediaPlayerPrivateQuickTimeVisualContext::retrieveCurrentImage):
        (WebCore::MediaPlayerPrivateQuickTimeVisualContext::createLayerForMovie):
        * platform/graphics/win/WKCACFLayer.cpp:
        (WebCore::WKCACFLayer::WKCACFLayer):
        (WebCore::WKCACFLayer::removeFromSuperlayer):
        (WebCore::WKCACFLayer::setFrame):
        (WebCore::WKCACFLayer::internalSetNeedsDisplay):
        (WebCore::WKCACFLayer::setLayoutClient):
        (WebCore::WKCACFLayer::layoutSublayersProc):
        (WebCore::WKCACFLayer::layoutClient):
        (WebCore::WKCACFLayer::setNeedsLayout):
        * platform/graphics/win/WKCACFLayer.h: Add layout client class.
        (WebCore::WKCACFLayerLayoutClient::~WKCACFLayerLayoutClient):
        (WebCore::WKCACFLayer::frame): Added back frame()/setFrame().
        * platform/graphics/win/WebTiledLayer.cpp:
        (WebCore::WebTiledLayer::setFrame): Implamented setFrame() in subclass of WKCACFLayer
        * platform/graphics/win/WebTiledLayer.h:
        * platform/graphics/win/WebTiledLayer.cpp: Added setFrame() overriding WKCACFLayer's implementation
        (WebCore::WebTiledLayer::setFrame):
        * platform/graphics/win/WebTiledLayer.h:

2010-05-25  Jer Noble  <jer.noble@apple.com>

        Reviewed by Adam Roben.

        Full screen doesn't work for video elements
        https://bugs.webkit.org/show_bug.cgi?id=39557
        rdar://problem/8011813

        Re-enabled fullscreen support on windows, and modified tests to match.

        * platform/win/media/controls-after-reload-expected.txt:
        * platform/win/media/controls-drag-timebar-expected.txt:
        * platform/win/media/controls-strict-expected.txt:
        * platform/win/media/controls-styling-expected.txt:
        * platform/win/media/video-controls-rendering-expected.txt:
        * platform/win/media/video-display-toggle-expected.txt:
        * platform/win/media/video-no-audio-expected.txt:

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

23 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/win/media/controls-after-reload-expected.txt
LayoutTests/platform/win/media/controls-drag-timebar-expected.txt
LayoutTests/platform/win/media/controls-strict-expected.txt
LayoutTests/platform/win/media/controls-styling-expected.txt
LayoutTests/platform/win/media/video-controls-rendering-expected.txt
LayoutTests/platform/win/media/video-display-toggle-expected.txt
LayoutTests/platform/win/media/video-no-audio-expected.txt
WebCore/ChangeLog
WebCore/WebCore.vcproj/WebCore.vcproj
WebCore/platform/graphics/FloatSize.h
WebCore/platform/graphics/IntSize.h
WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp [new file with mode: 0644]
WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.h [new file with mode: 0644]
WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp
WebCore/platform/graphics/win/WKCACFLayer.cpp
WebCore/platform/graphics/win/WKCACFLayer.h
WebCore/platform/graphics/win/WebTiledLayer.cpp
WebCore/platform/graphics/win/WebTiledLayer.h
WebKit/win/ChangeLog
WebKit/win/FullscreenVideoController.cpp
WebKit/win/FullscreenVideoController.h
WebKit/win/WebView.h

index b57f311915694466055e2765701a5b5a824593fe..125373e967b1a1a00862a37c8b865bc042e8a2ed 100644 (file)
@@ -1,3 +1,21 @@
+2010-05-25  Jer Noble  <jer.noble@apple.com>
+
+        Reviewed by Adam Roben.
+
+        Full screen doesn't work for video elements
+        https://bugs.webkit.org/show_bug.cgi?id=39557
+        rdar://problem/8011813
+
+        Re-enabled fullscreen support on windows, and modified tests to match.
+
+        * platform/win/media/controls-after-reload-expected.txt:
+        * platform/win/media/controls-drag-timebar-expected.txt:
+        * platform/win/media/controls-strict-expected.txt:
+        * platform/win/media/controls-styling-expected.txt:
+        * platform/win/media/video-controls-rendering-expected.txt:
+        * platform/win/media/video-display-toggle-expected.txt:
+        * platform/win/media/video-no-audio-expected.txt:
+
 2010-05-25  Alexey Proskuryakov  <ap@apple.com>
 
         Reviewed by Darin Adler.
index 923fac32fcfca52a789b8f59d25ead38a018472c..a433cf63a01ffeaf92d009096d6e7c57a7593c54 100644 (file)
@@ -17,9 +17,10 @@ layer at (8,42) size 320x240
 layer at (8,266) size 320x16
   RenderFlexibleBox (positioned) {DIV} at (0,224) size 320x16
     RenderButton {INPUT} at (0,0) size 16x16
-    RenderFlexibleBox {DIV} at (16,0) size 256x16
-      RenderSlider {INPUT} at (0,0) size 256x16
+    RenderFlexibleBox {DIV} at (16,0) size 240x16
+      RenderSlider {INPUT} at (0,0) size 240x16
         RenderBlock {DIV} at (2,1) size 13x14
+    RenderButton {INPUT} at (256,0) size 16x16
     RenderButton {INPUT} at (272,0) size 16x16
     RenderButton {INPUT} at (288,0) size 16x16
     RenderButton {INPUT} at (304,0) size 16x16
index 323108508fe1416a7464f0f1f4dd3c2b3b72bf94..b7dbe1d4751b66bea71d69f71f11c1143c4017cf 100644 (file)
@@ -4,10 +4,10 @@ RUN(video.autoplay = true)
 RUN(video.src = 'content/test.mp4')
 EVENT(playing)
 EVENT(seeked)
-Time: 2.1
+Time: 2.3
 EVENT(seeked)
-Time: 2.6
+Time: 2.8
 EVENT(seeked)
-Time: 3.1
+Time: 3.4
 END OF TEST
 
index 5296d5593e54bb5c333c2ffdf41b5c5f2a9ee1bc..45db871420d6506f0dcbc727cc7abc4ef9f55c6e 100644 (file)
@@ -17,9 +17,10 @@ layer at (8,50) size 320x240
 layer at (8,274) size 320x16
   RenderFlexibleBox (positioned) {DIV} at (0,224) size 320x16
     RenderButton {INPUT} at (0,0) size 16x16
-    RenderFlexibleBox {DIV} at (16,0) size 256x16
-      RenderSlider {INPUT} at (0,0) size 256x16
+    RenderFlexibleBox {DIV} at (16,0) size 240x16
+      RenderSlider {INPUT} at (0,0) size 240x16
         RenderBlock {DIV} at (2,1) size 13x14
+    RenderButton {INPUT} at (256,0) size 16x16
     RenderButton {INPUT} at (272,0) size 16x16
     RenderButton {INPUT} at (288,0) size 16x16
     RenderButton {INPUT} at (304,0) size 16x16
index fd24373b502566d41fe5995583a8a2af8f12f346..507123f4ef4215fd5087bec23be03b07450e49b8 100644 (file)
@@ -21,9 +21,10 @@ layer at (18,42) size 320x240
 layer at (18,266) size 320x16
   RenderFlexibleBox (positioned) {DIV} at (0,224) size 320x16
     RenderButton {INPUT} at (0,0) size 16x16
-    RenderFlexibleBox {DIV} at (16,0) size 256x16
-      RenderSlider {INPUT} at (0,0) size 256x16
+    RenderFlexibleBox {DIV} at (16,0) size 240x16
+      RenderSlider {INPUT} at (0,0) size 240x16
         RenderBlock {DIV} at (2,1) size 13x14
+    RenderButton {INPUT} at (256,0) size 16x16
     RenderButton {INPUT} at (272,0) size 16x16
     RenderButton {INPUT} at (288,0) size 16x16
     RenderButton {INPUT} at (304,0) size 16x16
@@ -32,9 +33,10 @@ layer at (8,282) size 320x240
 layer at (8,506) size 320x16
   RenderFlexibleBox (positioned) {DIV} at (0,224) size 320x16
     RenderButton {INPUT} at (0,0) size 16x16
-    RenderFlexibleBox {DIV} at (16,0) size 256x16
-      RenderSlider {INPUT} at (0,0) size 256x16
+    RenderFlexibleBox {DIV} at (16,0) size 240x16
+      RenderSlider {INPUT} at (0,0) size 240x16
         RenderBlock {DIV} at (2,1) size 13x14
+    RenderButton {INPUT} at (256,0) size 16x16
     RenderButton {INPUT} at (272,0) size 16x16
     RenderButton {INPUT} at (288,0) size 16x16
     RenderButton {INPUT} at (304,0) size 16x16
index fff11e122c248c748c42b7c6a9f4e09e9507b92c..791807ed69de920033fe6f6027a68dacf6404419 100644 (file)
@@ -20,9 +20,10 @@ layer at (8,42) size 320x240
 layer at (8,266) size 320x16
   RenderFlexibleBox (positioned) {DIV} at (0,224) size 320x16
     RenderButton {INPUT} at (0,0) size 16x16
-    RenderFlexibleBox {DIV} at (16,0) size 256x16
-      RenderSlider {INPUT} at (0,0) size 256x16
+    RenderFlexibleBox {DIV} at (16,0) size 240x16
+      RenderSlider {INPUT} at (0,0) size 240x16
         RenderBlock {DIV} at (2,1) size 13x14
+    RenderButton {INPUT} at (256,0) size 16x16
     RenderButton {INPUT} at (272,0) size 16x16
     RenderButton {INPUT} at (288,0) size 16x16
     RenderButton {INPUT} at (304,0) size 16x16
@@ -31,9 +32,10 @@ layer at (8,282) size 320x240
 layer at (8,506) size 320x16
   RenderFlexibleBox (positioned) {DIV} at (0,224) size 320x16
     RenderButton {INPUT} at (0,0) size 16x16
-    RenderFlexibleBox {DIV} at (16,0) size 256x16
-      RenderSlider {INPUT} at (0,0) size 256x16
+    RenderFlexibleBox {DIV} at (16,0) size 240x16
+      RenderSlider {INPUT} at (0,0) size 240x16
         RenderBlock {DIV} at (2,1) size 13x14
+    RenderButton {INPUT} at (256,0) size 16x16
     RenderButton {INPUT} at (272,0) size 16x16
     RenderButton {INPUT} at (288,0) size 16x16
     RenderButton {INPUT} at (304,0) size 16x16
@@ -44,9 +46,10 @@ layer at (8,522) size 320x240
 layer at (8,746) size 320x16
   RenderFlexibleBox (positioned) {DIV} at (0,224) size 320x16
     RenderButton {INPUT} at (0,0) size 16x16
-    RenderFlexibleBox {DIV} at (16,0) size 256x16
-      RenderSlider {INPUT} at (0,0) size 256x16
+    RenderFlexibleBox {DIV} at (16,0) size 240x16
+      RenderSlider {INPUT} at (0,0) size 240x16
         RenderBlock {DIV} at (2,1) size 13x14
+    RenderButton {INPUT} at (256,0) size 16x16
     RenderButton {INPUT} at (272,0) size 16x16
     RenderButton {INPUT} at (288,0) size 16x16
     RenderButton {INPUT} at (304,0) size 16x16
index a9baa000fa65b1b18018f6556dada257995fc4a1..a4f8539d16d3c74ac6a98b1cc00b7ae93bb70bed 100644 (file)
@@ -16,9 +16,10 @@ layer at (8,26) size 320x240
 layer at (8,250) size 320x16
   RenderFlexibleBox (positioned) {DIV} at (0,224) size 320x16
     RenderButton {INPUT} at (0,0) size 16x16
-    RenderFlexibleBox {DIV} at (16,0) size 256x16
-      RenderSlider {INPUT} at (0,0) size 256x16
+    RenderFlexibleBox {DIV} at (16,0) size 240x16
+      RenderSlider {INPUT} at (0,0) size 240x16
         RenderBlock {DIV} at (2,1) size 13x14
+    RenderButton {INPUT} at (256,0) size 16x16
     RenderButton {INPUT} at (272,0) size 16x16
     RenderButton {INPUT} at (288,0) size 16x16
     RenderButton {INPUT} at (304,0) size 16x16
index 1de7c85e527f84ed257def2cb5280a957e36f489..099b4642b8ba2e5fc092bb3352b93e213f3d9aee 100644 (file)
@@ -17,8 +17,9 @@ layer at (8,42) size 352x288
 layer at (8,314) size 352x16
   RenderFlexibleBox (positioned) {DIV} at (0,272) size 352x16
     RenderButton {INPUT} at (0,0) size 16x16
-    RenderFlexibleBox {DIV} at (16,0) size 304x16
-      RenderSlider {INPUT} at (0,0) size 304x16
+    RenderFlexibleBox {DIV} at (16,0) size 288x16
+      RenderSlider {INPUT} at (0,0) size 288x16
         RenderBlock {DIV} at (2,1) size 13x14
+    RenderButton {INPUT} at (304,0) size 16x16
     RenderButton {INPUT} at (320,0) size 16x16
     RenderButton {INPUT} at (336,0) size 16x16
index feb7a176166d5b489d5159b997b4f1b3a3b98763..3c37867822660a24031a2aef23e6332dd496d481 100644 (file)
@@ -1,3 +1,52 @@
+2010-05-22  Jer Noble  <jer.noble@apple.com>
+
+        Reviewed by Adam Roben.
+
+        Full screen doesn't work for video elements
+        https://bugs.webkit.org/show_bug.cgi?id=39557
+        rdar://problem/8011813
+        
+        Add fullscreen support for MediaPlayerPrivateVisualContext.  A new class, MediaPlayerPrivateFullscreenWindow,
+        provides the fullscreen hwnd and layer renderer.  Any WKCACFLayer can be provided to MediaPlayerPrivateFullscreenWindow
+        so future additional MediaPlayerPrivate implementations can use the fullscreen window.
+        
+        Minor additions have been made to the FloatSize and IntSize classes.
+
+        MediaPlayerPrivateQuickTimeVisualContext now calls retrieveCurrentImage after creating a new 
+        videoLayer; this is an existing bug that was never really exposed before now.
+
+        * WebCore.vcproj/WebCore.vcproj:
+        * platform/graphics/FloatSize.h: Added aspectRatio() and scale(float).
+        (WebCore::FloatSize::aspectRatio):
+        (WebCore::FloatSize::scale):
+        * platform/graphics/IntSize.h: Added aspectRatio().
+        (WebCore::IntSize::aspectRatio):
+        * platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp: Added.
+        * platform/graphics/win/MediaPlayerPrivateFullscreenWindow.h: Added.
+        * platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp: Call retrieveCurrentImage() after creating the videoLayer.
+        (WebCore::MediaPlayerPrivateQuickTimeVisualContext::supportsFullscreen):
+        (WebCore::MediaPlayerPrivateQuickTimeVisualContext::retrieveCurrentImage):
+        (WebCore::MediaPlayerPrivateQuickTimeVisualContext::createLayerForMovie):
+        * platform/graphics/win/WKCACFLayer.cpp: 
+        (WebCore::WKCACFLayer::WKCACFLayer):
+        (WebCore::WKCACFLayer::removeFromSuperlayer):
+        (WebCore::WKCACFLayer::setFrame):
+        (WebCore::WKCACFLayer::internalSetNeedsDisplay):
+        (WebCore::WKCACFLayer::setLayoutClient):
+        (WebCore::WKCACFLayer::layoutSublayersProc):
+        (WebCore::WKCACFLayer::layoutClient):
+        (WebCore::WKCACFLayer::setNeedsLayout):
+        * platform/graphics/win/WKCACFLayer.h: Add layout client class.
+        (WebCore::WKCACFLayerLayoutClient::~WKCACFLayerLayoutClient):
+        (WebCore::WKCACFLayer::frame): Added back frame()/setFrame().
+        * platform/graphics/win/WebTiledLayer.cpp:
+        (WebCore::WebTiledLayer::setFrame): Implamented setFrame() in subclass of WKCACFLayer
+        * platform/graphics/win/WebTiledLayer.h:
+        * platform/graphics/win/WebTiledLayer.cpp: Added setFrame() overriding WKCACFLayer's implementation
+        (WebCore::WebTiledLayer::setFrame):
+        * platform/graphics/win/WebTiledLayer.h:
+
+
 2010-05-25  Dumitru Daniliuc  <dumi@chromium.org>
 
         Reviewed by Brady Eidson.
index 86a0698549f80f5c17de485e33dbb0b84bf28057..c0a6e277c9f4818fb24fc687f01b9df8e6590341 100644 (file)
                                                RelativePath="..\platform\graphics\win\IntSizeWin.cpp"\r
                                                >\r
                                        </File>\r
+                                       <File\r
+                                               RelativePath="..\platform\graphics\win\MediaPlayerPrivateFullscreenWindow.cpp"\r
+                                               >\r
+                                       </File>\r
+                                       <File\r
+                                               RelativePath="..\platform\graphics\win\MediaPlayerPrivateFullscreenWindow.h"\r
+                                               >\r
+                                       </File>\r
                                        <File\r
                                                RelativePath="..\platform\graphics\win\MediaPlayerPrivateQuickTimeVisualContext.cpp"\r
                                                >\r
index 53a00719af0ad6164ed10db64e7917c29054d138..ff3d4dede1ef90b702d5d604e9b7fcd6525ec061 100644 (file)
@@ -63,6 +63,14 @@ public:
 
     bool isEmpty() const { return m_width <= 0 || m_height <= 0; }
 
+    float aspectRatio() const { return m_width / m_height; }
+
+    void scale(float scale)
+    {
+        m_width *= scale;
+        m_height *= scale;
+    }
+
     FloatSize expandedTo(const FloatSize& other) const
     {
         return FloatSize(m_width > other.m_width ? m_width : other.m_width,
index b60338cd30ebafe8c0967febefb1f5c85a606fad..9ecf38919b40ea567a89028ddbe3de7b5fad35b4 100644 (file)
@@ -72,6 +72,8 @@ public:
 
     bool isEmpty() const { return m_width <= 0 || m_height <= 0; }
     bool isZero() const { return !m_width && !m_height; }
+
+    float aspectRatio() const { return static_cast<float>(m_width) / static_cast<float>(m_height); }
     
     void expand(int width, int height)
     {
diff --git a/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp b/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp
new file mode 100644 (file)
index 0000000..2b9982e
--- /dev/null
@@ -0,0 +1,183 @@
+/*
+ * Copyright (C) 2010 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 \93AS IS\94 
+ * 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.
+ */
+
+#include "config.h"
+
+#include "MediaPlayerPrivateFullscreenWindow.h"
+
+#include "WebCoreInstanceHandle.h"
+#include <CoreGraphics/CGColor.h>
+#include <windows.h>
+#include <WebCore/IntRect.h>
+
+namespace WebCore {
+
+MediaPlayerPrivateFullscreenWindow::MediaPlayerPrivateFullscreenWindow(MediaPlayerPrivateFullscreenClient* client)
+    : m_client(client)
+    , m_hwnd(0)
+#if USE(ACCELERATED_COMPOSITING)
+    , m_layerRenderer(WKCACFLayerRenderer::create(0))
+#endif
+{
+}
+
+MediaPlayerPrivateFullscreenWindow::~MediaPlayerPrivateFullscreenWindow()
+{
+    if (m_hwnd)
+        close();
+}
+
+void MediaPlayerPrivateFullscreenWindow::createWindow(HWND parentHwnd)
+{
+    static ATOM windowAtom;
+    static LPCWSTR windowClassName = L"MediaPlayerPrivateFullscreenWindowClass";
+    if (!windowAtom) {
+        WNDCLASSEX wcex = {0};
+        wcex.cbSize = sizeof(WNDCLASSEX);
+        wcex.style = CS_HREDRAW | CS_VREDRAW;
+        wcex.lpfnWndProc = staticWndProc;
+        wcex.hInstance = instanceHandle();
+        wcex.lpszClassName = windowClassName;
+        windowAtom = ::RegisterClassEx(&wcex);
+    }
+
+    if (m_hwnd)
+        close();
+
+    MONITORINFO mi = {0};
+    mi.cbSize = sizeof(MONITORINFO);
+    if (!GetMonitorInfo(MonitorFromWindow(parentHwnd, MONITOR_DEFAULTTONEAREST), &mi))
+        return;
+
+    IntRect monitorRect = mi.rcMonitor;
+    
+    ::CreateWindowExW(WS_EX_TOOLWINDOW, windowClassName, L"", WS_POPUP | WS_VISIBLE, 
+        monitorRect.x(), monitorRect.y(), monitorRect.width(), monitorRect.height(),
+        parentHwnd, 0, WebCore::instanceHandle(), this);
+    ASSERT(IsWindow(m_hwnd));
+
+    ::SetFocus(m_hwnd);
+}
+
+void MediaPlayerPrivateFullscreenWindow::close()
+{
+    ::DestroyWindow(m_hwnd);
+    ASSERT(!m_hwnd);
+}
+
+#if USE(ACCELERATED_COMPOSITING)
+void MediaPlayerPrivateFullscreenWindow::setRootChildLayer(PassRefPtr<WKCACFLayer> rootChild)
+{
+    if (m_rootChild == rootChild)
+        return;
+
+    if (m_rootChild)
+        m_rootChild->removeFromSuperlayer();
+
+    m_rootChild = rootChild;
+
+    if (!m_rootChild)
+        return;
+
+    m_layerRenderer->setRootChildLayer(m_rootChild.get());
+    WKCACFLayer* rootLayer = m_rootChild->rootLayer();
+    CGRect rootBounds = m_rootChild->rootLayer()->bounds();
+    m_rootChild->setFrame(rootBounds);
+    m_layerRenderer->setScrollFrame(IntPoint(rootBounds.origin), IntSize(rootBounds.size));
+    m_rootChild->setBackgroundColor(CGColorGetConstantColor(kCGColorBlack));
+#ifndef NDEBUG
+    RetainPtr<CGColorRef> redColor(AdoptCF, CGColorCreateGenericRGB(1, 0, 0, 1));
+    rootLayer->setBackgroundColor(redColor.get());
+#else
+    rootLayer->setBackgroundColor(CGColorGetConstantColor(kCGColorBlack));
+#endif
+}
+#endif
+
+LRESULT MediaPlayerPrivateFullscreenWindow::staticWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+    LONG_PTR longPtr = GetWindowLongPtr(hWnd, GWLP_USERDATA);
+
+    if (!longPtr && message == WM_CREATE) {
+        LPCREATESTRUCT lpcs = reinterpret_cast<LPCREATESTRUCT>(lParam);
+        longPtr = reinterpret_cast<LONG_PTR>(lpcs->lpCreateParams);
+        ::SetWindowLongPtr(hWnd, GWLP_USERDATA, longPtr);
+    }
+
+    if (MediaPlayerPrivateFullscreenWindow* window = reinterpret_cast<MediaPlayerPrivateFullscreenWindow*>(longPtr))
+        return window->wndProc(hWnd, message, wParam, lParam);
+
+    return ::DefWindowProc(hWnd, message, wParam, lParam);    
+}
+
+LRESULT MediaPlayerPrivateFullscreenWindow::wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+    LRESULT lResult = 0;
+    switch (message) {
+    case WM_CREATE:
+        m_hwnd = hWnd;
+#if USE(ACCELERATED_COMPOSITING)
+        m_layerRenderer->setHostWindow(m_hwnd);
+        m_layerRenderer->createRenderer();
+        if (m_rootChild)
+            m_layerRenderer->setNeedsDisplay();
+#endif
+        break;
+    case WM_DESTROY:
+        m_hwnd = 0;
+#if USE(ACCELERATED_COMPOSITING)
+        m_layerRenderer->destroyRenderer();
+        m_layerRenderer->setHostWindow(0);
+#endif
+        break;
+    case WM_WINDOWPOSCHANGED:
+        {
+            LPWINDOWPOS wp = reinterpret_cast<LPWINDOWPOS>(lParam);
+            if (wp->flags & SWP_NOSIZE)
+                break;
+#if USE(ACCELERATED_COMPOSITING)
+            m_layerRenderer->resize();
+            WKCACFLayer* rootLayer = m_rootChild->rootLayer();
+            CGRect rootBounds = m_rootChild->rootLayer()->bounds();
+            m_rootChild->setFrame(rootBounds);
+            m_rootChild->setNeedsLayout();
+            m_layerRenderer->setScrollFrame(IntPoint(rootBounds.origin), IntSize(rootBounds.size));
+#endif
+        }
+        break;
+    case WM_PAINT:
+#if USE(ACCELERATED_COMPOSITING)
+        m_layerRenderer->renderSoon();
+#endif
+        break;
+    }
+
+    if (m_client)
+        lResult = m_client->fullscreenClientWndProc(hWnd, message, wParam, lParam);
+
+    return lResult;
+}
+
+}
diff --git a/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.h b/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.h
new file mode 100644 (file)
index 0000000..d42f7f3
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2010 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 \93AS IS\94 
+ * 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.
+ */
+
+#ifndef MediaPlayerPrivateFullscreenWindow_h
+#define MediaPlayerPrivateFullscreenWindow_h
+
+#if USE(ACCELERATED_COMPOSITING)
+#include "WKCACFLayer.h"
+#include "WKCACFLayerRenderer.h"
+#endif
+#include <wtf/OwnPtr.h>
+
+typedef unsigned WPARAM;
+typedef long LPARAM;
+typedef struct HWND__* HWND;
+typedef _W64 long LONG_PTR;
+typedef LONG_PTR LRESULT;
+typedef unsigned int UINT;
+
+namespace WebCore {
+
+class MediaPlayerPrivateFullscreenClient {
+public:
+    virtual LRESULT fullscreenClientWndProc(HWND, UINT message, WPARAM, LPARAM) = 0;
+protected:
+    virtual ~MediaPlayerPrivateFullscreenClient() {} 
+};
+
+class MediaPlayerPrivateFullscreenWindow {
+public:
+    MediaPlayerPrivateFullscreenWindow(MediaPlayerPrivateFullscreenClient*);
+    ~MediaPlayerPrivateFullscreenWindow();
+
+    void createWindow(HWND ownerWindow);
+    void close();
+    
+    HWND hwnd() const { return m_hwnd; }
+
+#if USE(ACCELERATED_COMPOSITING)
+    WKCACFLayerRenderer* layerRenderer() const { return m_layerRenderer.get(); }
+
+    WKCACFLayer* rootChildLayer() const { return m_rootChild.get(); }
+    void setRootChildLayer(PassRefPtr<WKCACFLayer>);
+#endif
+
+private:
+    static LRESULT __stdcall staticWndProc(HWND, UINT message, WPARAM, LPARAM);
+    LRESULT wndProc(HWND, UINT message, WPARAM, LPARAM);
+
+    MediaPlayerPrivateFullscreenClient* m_client;
+#if USE(ACCELERATED_COMPOSITING)
+    OwnPtr<WKCACFLayerRenderer> m_layerRenderer;
+    RefPtr<WKCACFLayer> m_rootChild;
+#endif
+    HWND m_hwnd;
+};
+
+}
+
+#endif
index 3feed400f515191d5e22d83f4c86363d4c9ca666..17880e953fe4c43982d4ff454ed82692d38c7731 100644 (file)
@@ -40,6 +40,7 @@
 #include "QTMovieTask.h"
 #include "QTMovieVisualContext.h"
 #include "ScrollView.h"
+#include "Settings.h"
 #include "SoftLinking.h"
 #include "StringBuilder.h"
 #include "StringHash.h"
@@ -149,6 +150,11 @@ MediaPlayerPrivateQuickTimeVisualContext::~MediaPlayerPrivateQuickTimeVisualCont
 
 bool MediaPlayerPrivateQuickTimeVisualContext::supportsFullscreen() const
 {
+#if USE(ACCELERATED_COMPOSITING)
+    Document* document = m_player->mediaPlayerClient()->mediaPlayerOwningDocument(); 
+    if (document && document->settings())
+        return document->settings()->acceleratedCompositingEnabled();
+#endif
     return false;
 }
 
@@ -761,7 +767,6 @@ void MediaPlayerPrivateQuickTimeVisualContext::retrieveCurrentImage()
         WKCACFLayer* layer = static_cast<WKCACFLayer*>(m_qtVideoLayer->platformLayer());
 
         if (!buffer.lockBaseAddress()) {
-
             if (requiredDllsAvailable()) {
                 if (!m_imageQueue) {
                     m_imageQueue = new WKCAImageQueue(buffer.width(), buffer.height(), 30);
@@ -1031,6 +1036,12 @@ void MediaPlayerPrivateQuickTimeVisualContext::createLayerForMovie()
 #endif
     // The layer will get hooked up via RenderLayerBacking::updateGraphicsLayerConfiguration().
 #endif
+
+    // Fill the newly created layer with image data, so we're not looking at 
+    // an empty layer until the next time a new image is available, which could
+    // be a long time if we're paused.
+    if (m_visualContext)
+        retrieveCurrentImage();
 }
 
 void MediaPlayerPrivateQuickTimeVisualContext::destroyLayerForMovie()
index 06146d742f26638269f67073d0c8cafec85a7e8d..d3928f1fae5b45035a501ce87aab7b3cc2821af0 100644 (file)
@@ -154,6 +154,7 @@ PassRefPtr<WKCACFLayer> WKCACFLayer::create(LayerType type)
 
 WKCACFLayer::WKCACFLayer(LayerType type)
     : m_layer(AdoptCF, CACFLayerCreate(toCACFLayerType(type)))
+    , m_layoutClient(0)
     , m_needsDisplayOnBoundsChange(false)
 {
     CACFLayerSetUserData(layer(), this);
@@ -286,11 +287,10 @@ void  WKCACFLayer::adoptSublayers(WKCACFLayer* source)
 void WKCACFLayer::removeFromSuperlayer()
 {
     WKCACFLayer* superlayer = this->superlayer();
-    if (!superlayer)
-        return;
-
     CACFLayerRemoveFromSuperlayer(layer());
-    superlayer->setNeedsCommit();
+
+    if (superlayer)
+        superlayer->setNeedsCommit();
 }
 
 WKCACFLayer* WKCACFLayer::internalSublayerAtIndex(int index) const
@@ -343,6 +343,19 @@ void WKCACFLayer::setBounds(const CGRect& rect)
         setNeedsDisplay();
 }
 
+void WKCACFLayer::setFrame(const CGRect& rect)
+{
+    CGRect oldFrame = frame();
+    if (CGRectEqualToRect(rect, oldFrame))
+        return;
+
+    CACFLayerSetFrame(layer(), rect);
+    setNeedsCommit();
+
+    if (m_needsDisplayOnBoundsChange && !CGSizeEqualToSize(rect.size, oldFrame.size))
+        setNeedsDisplay();
+}
+
 void WKCACFLayer::setContentsGravity(ContentsGravityType type)
 {
     CACFLayerSetContentsGravity(layer(), toCACFContentsGravityType(type));
@@ -418,6 +431,22 @@ void WKCACFLayer::internalSetNeedsDisplay(const CGRect* dirtyRect)
     CACFLayerSetNeedsDisplay(layer(), dirtyRect);
 }
 
+void WKCACFLayer::setLayoutClient(WKCACFLayerLayoutClient* layoutClient)
+{
+    if (layoutClient == m_layoutClient)
+        return;
+
+    m_layoutClient = layoutClient;
+    CACFLayerSetLayoutCallback(layer(), m_layoutClient ? layoutSublayersProc : 0);    
+}
+
+void WKCACFLayer::layoutSublayersProc(CACFLayerRef caLayer) 
+{
+    WKCACFLayer* layer = WKCACFLayer::layer(caLayer);
+    if (layer && layer->m_layoutClient)
+        layer->m_layoutClient->layoutSublayersOfLayer(layer);
+}
+
 #ifndef NDEBUG
 static void printIndent(int indent)
 {
index 9824f64015ffdf91548df28aa5a98f20c8d4e2c8..5e8eb051bfb0d48c0cc92e77317a1680467c39c9 100644 (file)
 
 namespace WebCore {
 
-class WKCACFAnimation;
-class WKCACFTimingFunction;
+class WKCACFLayer;
+
+class WKCACFLayerLayoutClient {
+public:
+    virtual void layoutSublayersOfLayer(WKCACFLayer*) = 0;
+protected:
+    virtual ~WKCACFLayerLayoutClient() {}
+};
 
 class WKCACFLayer : public RefCounted<WKCACFLayer> {
 public:
@@ -63,6 +69,10 @@ public:
 
     virtual void drawInContext(PlatformGraphicsContext*) { }
 
+    void setLayoutClient(WKCACFLayerLayoutClient*);
+    WKCACFLayerLayoutClient* layoutClient() const { return m_layoutClient; }
+    void setNeedsLayout() { CACFLayerSetNeedsLayout(layer()); }
+
     void setNeedsDisplay(const CGRect* dirtyRect = 0)
     {
         internalSetNeedsDisplay(dirtyRect);
@@ -173,6 +183,9 @@ public:
     void setFilters(CFArrayRef filters) { CACFLayerSetFilters(layer(), filters); setNeedsCommit(); }
     CFArrayRef filters() const { return CACFLayerGetFilters(layer()); }
 
+    virtual void setFrame(const CGRect&);
+    CGRect frame() const { return CACFLayerGetFrame(layer()); }
+
     void setHidden(bool hidden) { CACFLayerSetHidden(layer(), hidden); setNeedsCommit(); }
     bool isHidden() const { return CACFLayerIsHidden(layer()); }
 
@@ -261,7 +274,10 @@ protected:
 #endif
 
 private:
+    static void layoutSublayersProc(CACFLayerRef);
+
     RetainPtr<CACFLayerRef> m_layer;
+    WKCACFLayerLayoutClient* m_layoutClient;
     bool m_needsDisplayOnBoundsChange;
 };
 
index 0cf3f9dc88af6d4f636642bd51f7c48ade9c35a3..d8c02d27fedf5b979ca51a59459cd5e2eaf275e8 100755 (executable)
@@ -73,6 +73,15 @@ void WebTiledLayer::setBounds(const CGRect& rect)
     updateTiles();
 }
 
+void WebTiledLayer::setFrame(const CGRect& rect)
+{
+    if (CGRectEqualToRect(rect, frame()))
+        return;
+
+    WebLayer::setFrame(rect);
+    updateTiles();
+}
+
 void WebTiledLayer::internalSetNeedsDisplay(const CGRect* dirtyRect)
 {
     // FIXME: Only setNeedsDisplay for tiles that are currently visible
index ed61656fecde7ec8079c2cba41ec2d5538c92d9e..fdf0205ffa8eaff61bdefad56737fcd19b7fbf46 100755 (executable)
@@ -39,6 +39,7 @@ public:
     virtual ~WebTiledLayer();
 
     virtual void setBounds(const CGRect&);
+    virtual void setFrame(const CGRect&);
 
 protected:
     WebTiledLayer(const CGSize& tileSize, GraphicsLayer* owner);
index 27c8ceb430139ddbf43b2e2283bbbd37883278bb..944bb76fc71ab20d9f9fa2919dc17a1bfde0c23a 100644 (file)
@@ -1,3 +1,30 @@
+2010-05-22  Jer Noble  <jer.noble@apple.com>
+
+        Reviewed by Adam Roben.
+
+        Full screen doesn't work for video elements
+        https://bugs.webkit.org/show_bug.cgi?id=39557
+        rdar://problem/8011813
+        
+        Modified FullscreenVideoController to work with MediaPlayerPrivateFullscreenWindow.  The FullscreenVideoController
+        is now MediaPlayerPrivate agnostic..
+
+        * FullscreenVideoController.cpp:
+        (FullscreenVideoController::LayoutClient::LayoutClient): New helper class which implements WKCACFLayerLayoutClient.
+        (FullscreenVideoController::LayoutClient::layoutSublayersOfLayer):
+        (FullscreenVideoController::FullscreenVideoController):
+        (FullscreenVideoController::~FullscreenVideoController):
+        (FullscreenVideoController::enterFullscreen):
+        (FullscreenVideoController::exitFullscreen):
+        (FullscreenVideoController::fullscreenClientWndProc): Handle WM_KEYDOWN.
+        (FullscreenVideoController::createHUDWindow):
+        (FullscreenVideoController::hudWndProc):  Handle WM_KEYDOWN.
+        (FullscreenVideoController::onChar):
+        (FullscreenVideoController::onKeyDown):  New function: handles the VK_ESCAPE case more reliably than WM_CHAR.
+        * FullscreenVideoController.h:
+        * WebView.h: 
+        (WebView::viewWindow): Added a simple viewWindow() accessor.
+
 2010-05-25  Brady Eidson  <beidson@apple.com>
 
         Reviewed by Darin Adler.
index 6132fcae2a3202e96ea5ee28bdc91413cc6f2122..3aeb1bae2c0865bc1770f0a8cae1da7ece3bc5be 100644 (file)
 #include "FullscreenVideoController.h"
 
 #include "WebKitDLL.h"
+#include "WebView.h"
 #include <ApplicationServices/ApplicationServices.h>
 #include <WebCore/BitmapInfo.h>
+#include <WebCore/Chrome.h>
 #include <WebCore/Font.h>
 #include <WebCore/FontSelector.h>
 #include <WebCore/GraphicsContext.h>
+#include <WebCore/Page.h>
 #include <WebCore/TextRun.h>
+#include <WebCore/WKCACFLayer.h>
 #include <WebKitSystemInterface/WebKitSystemInterface.h>
 #include <windowsx.h>
 #include <wtf/StdLibExtras.h>
@@ -169,9 +173,53 @@ void HUDSlider::drag(const IntPoint& point, bool start)
     m_buttonPosition = max(0, min(m_rect.width() - m_buttonSize, point.x() - m_dragStartOffset));
 }
 
+#if USE(ACCELERATED_COMPOSITING)
+class FullscreenVideoController::LayoutClient : public WKCACFLayerLayoutClient {
+public:
+    LayoutClient(FullscreenVideoController* parent);
+    void layoutSublayersOfLayer(WKCACFLayer* layer);
+
+    FullscreenVideoController* m_parent;
+};
+
+FullscreenVideoController::LayoutClient::LayoutClient(FullscreenVideoController* parent)
+    : m_parent(parent)
+{
+}
+
+void FullscreenVideoController::LayoutClient::layoutSublayersOfLayer(WKCACFLayer* layer) 
+{
+    ASSERT_ARG(layer, layer == m_parent->m_rootChild);
+
+    HTMLMediaElement* mediaElement = m_parent->m_mediaElement.get();
+    if (!mediaElement)
+        return;
+
+    WKCACFLayer* videoLayer = mediaElement->platformLayer();
+    if (!videoLayer || videoLayer->superlayer() != layer)
+        return;
+
+    FloatRect layerBounds = layer->bounds();
+
+    FloatSize videoSize = mediaElement->player()->naturalSize();
+    float scaleFactor;
+    if (videoSize.aspectRatio() > layerBounds.size().aspectRatio())
+        scaleFactor = layerBounds.width() / videoSize.width();
+    else
+        scaleFactor = layerBounds.height() / videoSize.height();
+    videoSize.scale(scaleFactor);
+
+    // Calculate the centered position based on the videoBounds and layerBounds:
+    FloatPoint videoPosition;
+    FloatPoint videoOrigin;
+    videoOrigin.setX((layerBounds.width() - videoSize.width()) * 0.5);
+    videoOrigin.setY((layerBounds.height() - videoSize.height()) * 0.5);
+    videoLayer->setFrame(FloatRect(videoOrigin, videoSize));
+}
+#endif 
+
 FullscreenVideoController::FullscreenVideoController()
     : m_hudWindow(0)
-    , m_videoWindow(0)
     , m_playPauseButton(HUDButton::PlayPauseButton, IntPoint((windowWidth - buttonSize) / 2, marginTop))
     , m_timeSliderButton(HUDButton::TimeSliderButton, IntPoint(0, 0))
     , m_volumeUpButton(HUDButton::VolumeUpButton, IntPoint(margin + buttonMiniSize + volumeSliderWidth + buttonMiniSize / 2, marginTop + (buttonSize - buttonMiniSize) / 2))
@@ -183,25 +231,22 @@ FullscreenVideoController::FullscreenVideoController()
     , m_hitWidget(0)
     , m_movingWindow(false)
     , m_timer(this, &FullscreenVideoController::timerFired)
+#if USE(ACCELERATED_COMPOSITING)
+    , m_rootChild(WKCACFLayer::create(WKCACFLayer::Layer))
+    , m_layoutClient(new LayoutClient(this))
+#endif
+    , m_fullscreenWindow(new MediaPlayerPrivateFullscreenWindow(this))
 {
+#if USE(ACCELERATED_COMPOSITING)
+    m_rootChild->setLayoutClient(m_layoutClient.get());
+#endif
 }
 
 FullscreenVideoController::~FullscreenVideoController()
 {
-    if (movie())
-        movie()->exitFullscreen();
-}
-
-QTMovieGWorld* FullscreenVideoController::movie() const
-{
-    if (!m_mediaElement)
-        return 0;
-
-    PlatformMedia platformMedia = m_mediaElement->platformMedia();
-    if (platformMedia.type != PlatformMedia::QTMovieGWorldType)
-        return 0;
-
-    return platformMedia.media.qtMovieGWorld;
+#if USE(ACCELERATED_COMPOSITING)
+    m_rootChild->setLayoutClient(0);
+#endif
 }
 
 void FullscreenVideoController::setMediaElement(HTMLMediaElement* mediaElement)
@@ -218,13 +263,23 @@ void FullscreenVideoController::setMediaElement(HTMLMediaElement* mediaElement)
 
 void FullscreenVideoController::enterFullscreen()
 {
-    if (!movie())
+    if (!m_mediaElement)
         return;
 
-    m_videoWindow = movie()->enterFullscreen(this);
+    WebView* webView = kit(m_mediaElement->document()->page());
+    HWND parentHwnd = webView ? webView->viewWindow() : 0;
+
+    m_fullscreenWindow->createWindow(parentHwnd);
+#if USE(ACCELERATED_COMPOSITING)
+    m_fullscreenWindow->setRootChildLayer(m_rootChild);
+
+    WKCACFLayer* videoLayer = m_mediaElement->player()->platformLayer();
+    m_rootChild->addSublayer(videoLayer);
+    m_rootChild->setNeedsLayout();
+#endif
 
     RECT windowRect;
-    GetClientRect(m_videoWindow, &windowRect);
+    GetClientRect(m_fullscreenWindow->hwnd(), &windowRect);
     m_fullscreenSize.setWidth(windowRect.right - windowRect.left);
     m_fullscreenSize.setHeight(windowRect.bottom - windowRect.top);
 
@@ -234,12 +289,23 @@ void FullscreenVideoController::enterFullscreen()
 void FullscreenVideoController::exitFullscreen()
 {
     SetWindowLongPtr(m_hudWindow, 0, 0);
-    if (movie())
-        movie()->exitFullscreen();
+
+    if (m_fullscreenWindow)
+        m_fullscreenWindow = 0;
 
     ASSERT(!IsWindow(m_hudWindow));
-    m_videoWindow = 0;
     m_hudWindow = 0;
+
+    // We previously ripped the mediaElement's platform layer out
+    // of its orginial layer tree to display it in our fullscreen
+    // window.  Now, we need to get the layer back in its original
+    // tree.
+    // 
+    // As a side effect of setting the player to invisible/visible,
+    // the player's layer will be recreated, and will be picked up 
+    // the next time the layer tree is synched.
+    m_mediaElement->player()->setVisible(0);
+    m_mediaElement->player()->setVisible(1);
 }
 
 bool FullscreenVideoController::canPlay() const
@@ -308,6 +374,9 @@ LRESULT FullscreenVideoController::fullscreenClientWndProc(HWND wnd, UINT messag
     case WM_CHAR:
         onChar(wParam);
         break;
+    case WM_KEYDOWN:
+        onKeyDown(wParam);
+        break;
     case WM_LBUTTONDOWN:
         onMouseDown(IntPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)));
         break;
@@ -364,7 +433,7 @@ void FullscreenVideoController::createHUDWindow()
     
     // Dirty the window so the HUD draws
     RECT clearRect = { m_hudPosition.x(), m_hudPosition.y(), m_hudPosition.x() + windowWidth, m_hudPosition.y() + windowHeight };
-    InvalidateRect(m_videoWindow, &clearRect, true);
+    InvalidateRect(m_fullscreenWindow->hwnd(), &clearRect, true);
 
     m_playPauseButton.setShowAltButton(!canPlay());
     m_volumeSlider.setValue(volume());
@@ -377,7 +446,7 @@ void FullscreenVideoController::createHUDWindow()
 
     m_hudWindow = CreateWindowEx(WS_EX_LAYERED | WS_EX_TRANSPARENT | WS_EX_TOOLWINDOW, 
         fullscreenVideeoHUDWindowClassName, 0, WS_POPUP | WS_VISIBLE,
-        m_hudPosition.x(), m_hudPosition.y(), 0, 0, m_videoWindow, 0, gInstance, 0);
+        m_hudPosition.x(), m_hudPosition.y(), 0, 0, m_fullscreenWindow->hwnd(), 0, gInstance, 0);
     ASSERT(::IsWindow(m_hudWindow));
     SetWindowLongPtr(m_hudWindow, 0, reinterpret_cast<LONG_PTR>(this));
 
@@ -488,6 +557,9 @@ LRESULT FullscreenVideoController::hudWndProc(HWND wnd, UINT message, WPARAM wPa
     case WM_CHAR:
         controller->onChar(wParam);
         break;
+    case WM_KEYDOWN:
+        controller->onKeyDown(wParam);
+        break;
     case WM_LBUTTONDOWN:
         controller->onMouseDown(IntPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)));
         break;
@@ -511,6 +583,14 @@ void FullscreenVideoController::onChar(int c)
         togglePlay();
 }
 
+void FullscreenVideoController::onKeyDown(int virtualKey)
+{
+    if (virtualKey == VK_ESCAPE) {
+        if (m_mediaElement)
+            m_mediaElement->exitFullscreen();
+    }
+}
+
 void FullscreenVideoController::timerFired(Timer<FullscreenVideoController>*)
 {
     // Update the time slider
index 31acc63cec6407a876406d9ad74eac3276f405e4..9ac8c697cdfa08386da677835a3a5623b5a1b652 100644 (file)
@@ -28,7 +28,7 @@
 
 #if ENABLE(VIDEO)
 
-#include "QTMovieGWorld.h"
+#include "MediaPlayerPrivateFullscreenWindow.h"
 
 #include <WebCore/HTMLMediaElement.h>
 #include <WebCore/Image.h>
@@ -38,6 +38,9 @@
 
 namespace WebCore {
 class GraphicsContext;
+#if USE(ACCELERATED_COMPOSITING)
+class WKCACFLayer;
+#endif
 }
 
 class HUDWidget {
@@ -99,7 +102,7 @@ private:
     int m_dragStartOffset;
 };
 
-class FullscreenVideoController : QTMovieGWorldFullscreenClient, public Noncopyable {
+class FullscreenVideoController : WebCore::MediaPlayerPrivateFullscreenClient, public Noncopyable {
 public:
     FullscreenVideoController();
     virtual ~FullscreenVideoController();
@@ -111,12 +114,11 @@ public:
     void exitFullscreen();
 
 private:
-    // QTMovieGWorldFullscreenClient
+    // MediaPlayerPrivateFullscreenWindowClient
     virtual LRESULT fullscreenClientWndProc(HWND, UINT message, WPARAM, LPARAM);
-
+    
     void ensureWindow();
-    QTMovieGWorld* movie() const;
-
+    
     bool canPlay() const;
     void play();
     void pause();
@@ -145,13 +147,21 @@ private:
     void onMouseDown(const WebCore::IntPoint&);
     void onMouseMove(const WebCore::IntPoint&);
     void onMouseUp(const WebCore::IntPoint&);
+    void onKeyDown(int virtualKey);
 
     RefPtr<WebCore::HTMLMediaElement> m_mediaElement;
 
-    HWND m_hudWindow, m_videoWindow;
+    HWND m_hudWindow;
     OwnPtr<HBITMAP> m_bitmap;
     WebCore::IntSize m_fullscreenSize;
     WebCore::IntPoint m_hudPosition;
+    OwnPtr<WebCore::MediaPlayerPrivateFullscreenWindow> m_fullscreenWindow;
+#if USE(ACCELERATED_COMPOSITING)
+    RefPtr<WebCore::WKCACFLayer> m_rootChild;
+    class LayoutClient;
+    friend class LayoutClient;
+    OwnPtr<LayoutClient> m_layoutClient;
+#endif
 
     HUDButton m_playPauseButton;
     HUDButton m_timeSliderButton;
index ab4dffe220d0ab743969c292c1b7e617cda9b034..d44e6c6d2df4c4857d3cbc056c5ffe6089d95827 100644 (file)
@@ -886,6 +886,7 @@ public:
     void cancelDeleteBackingStoreSoon();
 
     HWND topLevelParent() const { return m_topLevelParent; }
+    HWND viewWindow() const { return m_viewWindow; }
 
     void updateActiveState();