Skip to content
Permalink
Browse files
2011-05-02 Jer Noble <jer.noble@apple.com>
        Reviewed by Adam Roben.

        Implement FULLSCREEN_API on Windows, Part 3: WebKit2
        https://bugs.webkit.org/show_bug.cgi?id=59845

        Move WebFullScreenController into WebCore to facilitate code sharing between WebKit
        and WebKit2.  WebFullScreenController now uses a Client class to request work on its
        behalf by WebKit and WebKit2.  MediaPlayerPrivateFullscreenWindow now only creates a
        CALayerHost once a root layer is set, as the CALayerHost was causing child window drawing
        problems, and because a CALayerHost is overkill if the window is only drawing black to
        its client area.

        * WebCore.vcproj/WebCore.vcproj:
        * platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp:
        (WebCore::MediaPlayerPrivateFullscreenWindow::MediaPlayerPrivateFullscreenWindow): Do not create
            m_layerHost in the constructor.
        (WebCore::MediaPlayerPrivateFullscreenWindow::createWindow): NULL check m_layerHost.
        (WebCore::MediaPlayerPrivateFullscreenWindow::setRootChildLayer): Lazily instantiate m_layerHost.
        (WebCore::MediaPlayerPrivateFullscreenWindow::wndProc): NULL check m_layerHost; if a root layer is
            not present, fill the window with black in WM_PAINT.
        * platform/graphics/win/MediaPlayerPrivateFullscreenWindow.h:
        * platform/graphics/win/FullScreenController.cpp: Renamed from Source/WebKit/win/WebFullScreenController.cpp.
        * platform/graphics/win/FullScreenController.h: Renamed from Source/WebKit/win/WebFullScreenController.h.
        * platform/graphics/win/FullScreenControllerClient.h: Split out from FullScreenController.h
        (WebCore::FullScreenControllerClient::~FullScreenControllerClient):
2011-05-02  Jer Noble  <jer.noble@apple.com>

        Reviewed by Adam Roben.

        Implement FULLSCREEN_API on Windows, Part 3: WebKit2
        https://bugs.webkit.org/show_bug.cgi?id=59845

        Implementation of WebFullScreenController has been moved into WebCore, and
        required virutal functions of WebFullScreenControllerClient have been added to
        WebView.  These functions are mostly simple accessors of existing ivars, but
        m_fullScreenElement and its accessors have also been added to WebView.

        * WebCoreSupport/WebChromeClient.cpp:
        (WebChromeClient::enterFullScreenForElement):
        * WebFullScreenController.cpp: Removed.
        * WebKit.vcproj/WebKit.vcproj:
        * WebView.cpp:
        (WebView::setFullScreenElement): Added accessor.
        (WebVIew::fullScreenElement): Ditto.
        (WebView::fullScreenClientWindow): Ditto.
        (WebView::fullScreenClientParentWindow): Ditto.
        (WebView::fullScreenClientSetParentWindow): Ditto.
        (WebView::fullScreenClientWillEnterFullScreen): Pass through to Document.
        (WebView::fullScreenClientDidEnterFullScreen): Ditto.
        (WebView::fullScreenClientWillExitFullScreen): Ditto.
        (WebView::fullScreenClientDidExitFullScreen): Ditto.
        * WebView.h:
2011-05-02  Jer Noble  <jer.noble@apple.com>

        Reviewed by Adam Roben.

        Implement FULLSCREEN_API on Windows, Part 3: WebKit2
        https://bugs.webkit.org/show_bug.cgi?id=59845

        Implement a similar full screen mode to WebKit; Re-use the same
        full screen window class used in WebKit in the new WebFullScreenController.
        No animations (yet), so many of the stubs remain unimplemented.

        * UIProcess/win/WebView.cpp:
        (WebKit::WebView::onKeyEvent): Handle VK_ESCAPE and cancel full screen
            mode if caught.
        (WebKit::WebView::fullScreenController): Lazily instantiate m_fullScreenController.
        (WebKit::WebView::fullScreenClientWindow): Added accessor.
        (WebKit::WebView::fullScreenClientParentWindow): Ditto.
        (WebKit::WebView::fullScreenClientSetParentWindow): Ditto.
        (WebKit::WebView::fullScreenClientWillEnterFullScreen): Pass through to WebFullScreenManagerProxy.
        (WebKit::WebView::fullScreenClientDidEnterFullScreen): Ditto.
        (WebKit::WebView::fullScreenClientWillExitFullScreen): Ditto.
        (WebKit::WebView::fullScreenClientDidExitFullScreen): Ditto.
        * UIProcess/win/WebView.h:
        * UIProcess/win/WebFullScreenManagerProxyWin.cpp:
        (WebKit::WebFullScreenManagerProxy::enterFullScreen): Pass through to
            WebFullScreenController.
        (WebKit::WebFullScreenManagerProxy::exitFullScreen): Ditto.
        * UIProcess/win/WebView.cpp:
        (WebKit::WebView::WebView):
        (WebKit::WebView::onKeyEvent): Handle the escape key and exit
           full screen mode when detected.
        (WebKit::WebView::fullScreenWindowController): Added.
        * UIProcess/win/WebView.h:
        * WebProcess/FullScreen/win/WebFullScreenManagerWin.cpp:
        (WebKit::WebFullScreenManagerWin::~WebFullScreenManagerWin):
        (WebKit::WebFullScreenManagerWin::setRootFullScreenLayer): Host the root
            full screen layer if it gets detached.
        * WebProcess/FullScreen/win/WebFullScreenManagerWin.h:
        * win/WebKit2.vcproj:

Canonical link: https://commits.webkit.org/75384@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@85699 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
jernoble committed May 4, 2011
1 parent d47108e commit a77c08548b12b03c58b34ba97fa909c8d35e4a26
Showing 19 changed files with 626 additions and 267 deletions.
@@ -1,3 +1,31 @@
2011-05-02 Jer Noble <jer.noble@apple.com>

Reviewed by Adam Roben.

Implement FULLSCREEN_API on Windows, Part 3: WebKit2
https://bugs.webkit.org/show_bug.cgi?id=59845

Move WebFullScreenController into WebCore to facilitate code sharing between WebKit
and WebKit2. WebFullScreenController now uses a Client class to request work on its
behalf by WebKit and WebKit2. MediaPlayerPrivateFullscreenWindow now only creates a
CALayerHost once a root layer is set, as the CALayerHost was causing child window drawing
problems, and because a CALayerHost is overkill if the window is only drawing black to
its client area.

* WebCore.vcproj/WebCore.vcproj:
* platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp:
(WebCore::MediaPlayerPrivateFullscreenWindow::MediaPlayerPrivateFullscreenWindow): Do not create
m_layerHost in the constructor.
(WebCore::MediaPlayerPrivateFullscreenWindow::createWindow): NULL check m_layerHost.
(WebCore::MediaPlayerPrivateFullscreenWindow::setRootChildLayer): Lazily instantiate m_layerHost.
(WebCore::MediaPlayerPrivateFullscreenWindow::wndProc): NULL check m_layerHost; if a root layer is
not present, fill the window with black in WM_PAINT.
* platform/graphics/win/MediaPlayerPrivateFullscreenWindow.h:
* platform/graphics/win/FullScreenController.cpp: Renamed from Source/WebKit/win/WebFullScreenController.cpp.
* platform/graphics/win/FullScreenController.h: Renamed from Source/WebKit/win/WebFullScreenController.h.
* platform/graphics/win/FullScreenControllerClient.h: Split out from FullScreenController.h
(WebCore::FullScreenControllerClient::~FullScreenControllerClient):

2011-05-03 Brady Eidson <beidson@apple.com>

Reviewed by Sam Weinig.
@@ -24721,14 +24721,14 @@
RelativePath="..\page\PageGroupLoadDeferrer.h"
>
</File>
<File
RelativePath="..\page\PageSerializer.cpp"
>
</File>
<File
RelativePath="..\page\PageSerializer.h"
>
</File>
<File
RelativePath="..\page\PageSerializer.cpp"
>
</File>
<File
RelativePath="..\page\PageSerializer.h"
>
</File>
<File
RelativePath="..\page\Performance.cpp"
>
@@ -27115,6 +27115,18 @@
RelativePath="..\platform\graphics\win\FontWin.cpp"
>
</File>
<File
RelativePath="..\platform\graphics\win\FullScreenController.cpp"
>
</File>
<File
RelativePath="..\platform\graphics\win\FullScreenController.h"
>
</File>
<File
RelativePath="..\platform\graphics\win\FullScreenControllerClient.h"
>
</File>
<File
RelativePath="..\platform\graphics\win\GlyphPageTreeNodeCairoWin.cpp"
>
@@ -28951,6 +28963,14 @@
RelativePath="..\platform\graphics\filters\FEGaussianBlur.h"
>
</File>
<File
RelativePath="..\platform\graphics\filters\arm\FEGaussianBlurNEON.cpp"
>
</File>
<File
RelativePath="..\platform\graphics\filters\arm\FEGaussianBlurNEON.h"
>
</File>
<File
RelativePath="..\platform\graphics\filters\FELighting.cpp"
>
@@ -28959,6 +28979,14 @@
RelativePath="..\platform\graphics\filters\FELighting.h"
>
</File>
<File
RelativePath="..\platform\graphics\filters\arm\FELightingNEON.cpp"
>
</File>
<File
RelativePath="..\platform\graphics\filters\arm\FELightingNEON.h"
>
</File>
<File
RelativePath="..\platform\graphics\filters\FEMerge.cpp"
>
@@ -29059,22 +29087,6 @@
RelativePath="..\platform\graphics\filters\SpotLightSource.h"
>
</File>
<File
RelativePath="..\platform\graphics\filters\arm\FEGaussianBlurNEON.cpp"
>
</File>
<File
RelativePath="..\platform\graphics\filters\arm\FEGaussianBlurNEON.h"
>
</File>
<File
RelativePath="..\platform\graphics\filters\arm\FELightingNEON.cpp"
>
</File>
<File
RelativePath="..\platform\graphics\filters\arm\FELightingNEON.h"
>
</File>
</Filter>
<Filter
Name="ca"
@@ -42705,6 +42717,10 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="..\dom\DataTransferItem.h"
>
</File>
<File
RelativePath="..\dom\DataTransferItems.cpp"
>
@@ -42757,10 +42773,6 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="..\dom\DataTransferItem.h"
>
</File>
<File
RelativePath="..\dom\DataTransferItems.h"
>
@@ -66704,6 +66716,10 @@
RelativePath="..\inspector\front-end\inspectorSyntaxHighlight.css"
>
</File>
<File
RelativePath="..\inspector\front-end\UglifyJS\JavaScriptFormatter.js"
>
</File>
<File
RelativePath="..\inspector\front-end\JavaScriptFormatter.js"
>
@@ -66748,10 +66764,6 @@
RelativePath="..\inspector\front-end\PanelEnablerView.js"
>
</File>
<File
RelativePath="..\inspector\front-end\UglifyJS\JavaScriptFormatter.js"
>
</File>
<File
RelativePath="..\inspector\front-end\UglifyJS\parse-js.js"
>
@@ -0,0 +1,167 @@
/*
* Copyright (C) 2006, 2007, 2008, 2009, 2011 Apple Inc. All rights reserved.
* Copyright (C) Research In Motion Limited 2009. 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 COMPUTER, INC. ``AS IS'' 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 COMPUTER, INC. OR
* 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"

#if ENABLE(FULLSCREEN_API)

#include "FullScreenController.h"

#include "Element.h"
#include "FullScreenControllerClient.h"
#include "IntRect.h"
#include "MediaPlayerPrivateFullscreenWindow.h"
#include "Timer.h"
#include "WebCoreInstanceHandle.h"
#include <wtf/RefPtr.h>

using namespace WebCore;

static const int kFullScreenAnimationDuration = 500; // milliseconds

class FullScreenController::Private : public MediaPlayerPrivateFullscreenClient {
public:
Private(FullScreenController* controller, FullScreenControllerClient* client)
: m_controller(controller)
, m_client(client)
, m_originalHost(0)
, m_isFullScreen(false)
{
}
virtual ~Private() { }

virtual LRESULT fullscreenClientWndProc(HWND, UINT, WPARAM, LPARAM);

FullScreenController* m_controller;
FullScreenControllerClient* m_client;
OwnPtr<MediaPlayerPrivateFullscreenWindow> m_fullScreenWindow;
OwnPtr<MediaPlayerPrivateFullscreenWindow> m_backgroundWindow;
IntRect m_fullScreenFrame;
IntRect m_originalFrame;
HWND m_originalHost;
bool m_isFullScreen;
};

LRESULT FullScreenController::Private::fullscreenClientWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
LRESULT lResult = 0;

switch (msg) {
case WM_MOVE:
m_fullScreenFrame.setX(LOWORD(lParam));
m_fullScreenFrame.setY(HIWORD(lParam));
break;
case WM_SIZE:
m_fullScreenFrame.setWidth(LOWORD(lParam));
m_fullScreenFrame.setHeight(HIWORD(lParam));
if (m_client->fullScreenClientWindow())
::SetWindowPos(m_client->fullScreenClientWindow(), 0, 0, 0, m_fullScreenFrame.width(), m_fullScreenFrame.height(), SWP_NOREPOSITION | SWP_NOMOVE);
break;
case WM_KEYDOWN:
if (wParam == VK_ESCAPE) {
m_controller->exitFullScreen();
break;
}
// Fall through.
default:
lResult = ::DefWindowProc(hwnd, msg, wParam, lParam);
}

return lResult;
}

FullScreenController::FullScreenController(FullScreenControllerClient* client)
: m_private(adoptPtr(new FullScreenController::Private(this, client)))
{
ASSERT_ARG(client, client);
}

FullScreenController::~FullScreenController()
{
}

bool FullScreenController::isFullScreen() const
{
return m_private->m_isFullScreen;
}

void FullScreenController::enterFullScreen()
{
if (m_private->m_isFullScreen)
return;
m_private->m_isFullScreen = true;

m_private->m_originalHost = m_private->m_client->fullScreenClientParentWindow();
RECT originalFrame = {0, 0, 0, 0};
::GetClientRect(m_private->m_client->fullScreenClientWindow(), &originalFrame);
::MapWindowPoints(m_private->m_client->fullScreenClientWindow(), m_private->m_originalHost, reinterpret_cast<LPPOINT>(&originalFrame), 2);
m_private->m_originalFrame = originalFrame;

ASSERT(!m_private->m_backgroundWindow);
m_private->m_backgroundWindow = adoptPtr(new MediaPlayerPrivateFullscreenWindow(m_private.get()));
m_private->m_backgroundWindow->createWindow(0);
::AnimateWindow(m_private->m_backgroundWindow->hwnd(), kFullScreenAnimationDuration, AW_BLEND | AW_ACTIVATE);

m_private->m_client->fullScreenClientWillEnterFullScreen();

ASSERT(!m_private->m_fullScreenWindow);
m_private->m_fullScreenWindow = adoptPtr(new MediaPlayerPrivateFullscreenWindow(m_private.get()));
ASSERT(m_private->m_fullScreenWindow);
m_private->m_fullScreenWindow->createWindow(0);

m_private->m_client->fullScreenClientSetParentWindow(m_private->m_fullScreenWindow->hwnd());

IntRect viewFrame(IntPoint(), m_private->m_fullScreenFrame.size());
::SetWindowPos(m_private->m_fullScreenWindow->hwnd(), HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
::SetWindowPos(m_private->m_client->fullScreenClientWindow(), HWND_TOP, 0, 0, viewFrame.width(), viewFrame.height(), SWP_NOACTIVATE);
::RedrawWindow(m_private->m_client->fullScreenClientWindow(), 0, 0, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE | RDW_ALLCHILDREN);

m_private->m_client->fullScreenClientDidEnterFullScreen();
::AnimateWindow(m_private->m_fullScreenWindow->hwnd(), kFullScreenAnimationDuration, AW_BLEND | AW_ACTIVATE);
}

void FullScreenController::exitFullScreen()
{
if (!m_private->m_isFullScreen)
return;
m_private->m_isFullScreen = false;

::AnimateWindow(m_private->m_fullScreenWindow->hwnd(), kFullScreenAnimationDuration, AW_HIDE | AW_BLEND);

m_private->m_client->fullScreenClientWillExitFullScreen();
m_private->m_client->fullScreenClientSetParentWindow(m_private->m_originalHost);
m_private->m_fullScreenWindow = nullptr;

m_private->m_client->fullScreenClientDidExitFullScreen();
::SetWindowPos(m_private->m_client->fullScreenClientWindow(), 0, m_private->m_originalFrame.x(), m_private->m_originalFrame.y(), m_private->m_originalFrame.width(), m_private->m_originalFrame.height(), SWP_NOACTIVATE | SWP_NOZORDER);
::RedrawWindow(m_private->m_client->fullScreenClientWindow(), 0, 0, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE | RDW_ALLCHILDREN);

ASSERT(m_private->m_backgroundWindow);
::AnimateWindow(m_private->m_backgroundWindow->hwnd(), kFullScreenAnimationDuration, AW_HIDE | AW_BLEND);
m_private->m_backgroundWindow = nullptr;
}

#endif
@@ -28,25 +28,18 @@

#if ENABLE(FULLSCREEN_API)

#include "WebKit.h"
#include <wtf/OwnPtr.h>
#include <wtf/RefPtr.h>

namespace WebCore {
class Element;
}

class WebView;
class FullScreenControllerClient;

class WebFullScreenController {
class FullScreenController {
public:
WebFullScreenController(WebView*);
~WebFullScreenController();
FullScreenController(FullScreenControllerClient*);
~FullScreenController();

public:
void setElement(PassRefPtr<WebCore::Element>);
WebCore::Element* element() const;

void enterFullScreen();
void exitFullScreen();

@@ -55,9 +48,11 @@ class WebFullScreenController {
protected:
class Private;
friend class Private;
OwnPtr<WebFullScreenController::Private> m_private;
OwnPtr<FullScreenController::Private> m_private;
};

}

#endif

#endif

0 comments on commit a77c085

Please sign in to comment.