diff options
author | Jiang Jiang <jiang.jiang@nokia.com> | 2011-07-08 07:57:45 (GMT) |
---|---|---|
committer | Jiang Jiang <jiang.jiang@nokia.com> | 2011-07-08 07:57:45 (GMT) |
commit | 978e22d6529d7cbe9472749352d632eefd22cd07 (patch) | |
tree | ac92a4f489c0a93a48eb502457c679659e472ac0 /src/3rdparty/webkit/Source/WebKit2/WebProcess/FullScreen | |
parent | cb11bb0df08f134bbded52fd4140197a01570a0e (diff) | |
parent | 1dd26ea2486db87b61e8e9f70a1e04f7386405ef (diff) | |
download | Qt-978e22d6529d7cbe9472749352d632eefd22cd07.zip Qt-978e22d6529d7cbe9472749352d632eefd22cd07.tar.gz Qt-978e22d6529d7cbe9472749352d632eefd22cd07.tar.bz2 |
Merge remote branch 'mainline/4.8' into staging
Conflicts:
dist/changes-4.8.0
Diffstat (limited to 'src/3rdparty/webkit/Source/WebKit2/WebProcess/FullScreen')
9 files changed, 906 insertions, 0 deletions
diff --git a/src/3rdparty/webkit/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.cpp b/src/3rdparty/webkit/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.cpp new file mode 100644 index 0000000..47f1d42 --- /dev/null +++ b/src/3rdparty/webkit/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.cpp @@ -0,0 +1,146 @@ +/* + * Copyright (C) 2011 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 ``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 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 "WebFullScreenManager.h" + +#if ENABLE(FULLSCREEN_API) + +#include "Connection.h" +#include "MessageID.h" +#include "WebCoreArgumentCoders.h" +#include "WebFullScreenManagerProxyMessages.h" +#include "WebPage.h" +#include "WebProcess.h" +#include <WebCore/Color.h> +#include <WebCore/Page.h> +#include <WebCore/Settings.h> + +using namespace WebCore; + +namespace WebKit { + +WebFullScreenManager::WebFullScreenManager(WebPage* page) + : m_page(page) +{ +} + +WebFullScreenManager::~WebFullScreenManager() +{ + +} + +WebCore::Element* WebFullScreenManager::element() +{ + return m_element.get(); +} + +void WebFullScreenManager::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments) +{ + didReceiveWebFullScreenManagerMessage(connection, messageID, arguments); +} + +bool WebFullScreenManager::supportsFullScreen(bool withKeyboard) +{ + if (!m_page->corePage()->settings()->fullScreenEnabled()) + return false; + + return m_page->injectedBundleFullScreenClient().supportsFullScreen(m_page.get(), withKeyboard); + +} + +void WebFullScreenManager::enterFullScreenForElement(WebCore::Element* element) +{ + ASSERT(element); + m_element = element; + m_initialFrame = m_element->screenRect(); + m_page->injectedBundleFullScreenClient().enterFullScreenForElement(m_page.get(), element); +} + +void WebFullScreenManager::exitFullScreenForElement(WebCore::Element* element) +{ + ASSERT(element); + ASSERT(m_element == element); + m_page->injectedBundleFullScreenClient().exitFullScreenForElement(m_page.get(), element); +} + +void WebFullScreenManager::beganEnterFullScreenAnimation() +{ + m_page->send(Messages::WebFullScreenManagerProxy::BeganEnterFullScreenAnimation()); +} + +void WebFullScreenManager::finishedEnterFullScreenAnimation(bool completed) +{ + m_page->send(Messages::WebFullScreenManagerProxy::FinishedEnterFullScreenAnimation(completed)); +} + +void WebFullScreenManager::beganExitFullScreenAnimation() +{ + m_page->send(Messages::WebFullScreenManagerProxy::BeganExitFullScreenAnimation()); +} + +void WebFullScreenManager::finishedExitFullScreenAnimation(bool completed) +{ + m_page->send(Messages::WebFullScreenManagerProxy::FinishedExitFullScreenAnimation(completed)); +} + +IntRect WebFullScreenManager::getFullScreenRect() +{ + IntRect rect; + m_page->sendSync(Messages::WebFullScreenManagerProxy::GetFullScreenRect(), Messages::WebFullScreenManagerProxy::GetFullScreenRect::Reply(rect)); + return rect; +} + +void WebFullScreenManager::willEnterFullScreen() +{ + ASSERT(m_element); + m_element->document()->webkitWillEnterFullScreenForElement(m_element.get()); + m_element->document()->setFullScreenRendererBackgroundColor(Color::transparent); +} + +void WebFullScreenManager::didEnterFullScreen() +{ + ASSERT(m_element); + m_element->document()->webkitDidEnterFullScreenForElement(m_element.get()); + m_element->document()->setFullScreenRendererBackgroundColor(Color::black); +} + +void WebFullScreenManager::willExitFullScreen() +{ + ASSERT(m_element); + m_element->document()->webkitWillExitFullScreenForElement(m_element.get()); + m_element->document()->setFullScreenRendererBackgroundColor(Color::transparent); +} + +void WebFullScreenManager::didExitFullScreen() +{ + ASSERT(m_element); + m_element->document()->webkitDidExitFullScreenForElement(m_element.get()); + m_element->document()->setFullScreenRendererBackgroundColor(Color::black); +} + + +} // namespace WebKit + +#endif // ENABLE(FULLSCREEN_API) diff --git a/src/3rdparty/webkit/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.h b/src/3rdparty/webkit/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.h new file mode 100644 index 0000000..d6ccb15 --- /dev/null +++ b/src/3rdparty/webkit/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.h @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2011 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 ``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 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 WebFullScreenManager_h +#define WebFullScreenManager_h + +#if ENABLE(FULLSCREEN_API) + +#include <WebCore/IntRect.h> +#include <wtf/RefCounted.h> +#include <wtf/RefPtr.h> + +namespace CoreIPC { +class ArgumentDecoder; +class Connection; +class MessageID; +} + +namespace WebCore { +class IntRect; +class Element; +class GraphicsLayer; +} + +namespace WebKit { + +class WebPage; + +class WebFullScreenManager : public RefCounted<WebFullScreenManager> { +public: + static PassRefPtr<WebFullScreenManager> create(WebPage*); + virtual ~WebFullScreenManager(); + + void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); + + bool supportsFullScreen(bool withKeyboard); + void enterFullScreenForElement(WebCore::Element*); + void exitFullScreenForElement(WebCore::Element*); + void beganEnterFullScreenAnimation(); + void finishedEnterFullScreenAnimation(bool completed); + void beganExitFullScreenAnimation(); + void finishedExitFullScreenAnimation(bool completed); + virtual void setRootFullScreenLayer(WebCore::GraphicsLayer*) = 0; + + void willEnterFullScreen(); + void didEnterFullScreen(); + void willExitFullScreen(); + void didExitFullScreen(); + + WebCore::Element* element(); + +protected: + WebFullScreenManager(WebPage*); + + virtual void beginEnterFullScreenAnimation(float duration) = 0; + virtual void beginExitFullScreenAnimation(float duration) = 0; + WebCore::IntRect getFullScreenRect(); + + void didReceiveWebFullScreenManagerMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); + + WebCore::IntRect m_initialFrame; + RefPtr<WebPage> m_page; + RefPtr<WebCore::Element> m_element; +}; + +} // namespace WebKit + +#endif // ENABLE(FULLSCREEN_API) + +#endif // WebFullScreenManager_h diff --git a/src/3rdparty/webkit/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.messages.in b/src/3rdparty/webkit/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.messages.in new file mode 100644 index 0000000..d53f9d5 --- /dev/null +++ b/src/3rdparty/webkit/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.messages.in @@ -0,0 +1,32 @@ +# Copyright (C) 2011 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 ``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 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. + +#if ENABLE(FULLSCREEN_API) +messages -> WebFullScreenManager { + WillEnterFullScreen() + DidEnterFullScreen() + WillExitFullScreen() + DidExitFullScreen() + BeginEnterFullScreenAnimation(float duration) + BeginExitFullScreenAnimation(float duration) +} +#endif diff --git a/src/3rdparty/webkit/Source/WebKit2/WebProcess/FullScreen/gtk/WebFullScreenManagerGtk.cpp b/src/3rdparty/webkit/Source/WebKit2/WebProcess/FullScreen/gtk/WebFullScreenManagerGtk.cpp new file mode 100644 index 0000000..5c4e697 --- /dev/null +++ b/src/3rdparty/webkit/Source/WebKit2/WebProcess/FullScreen/gtk/WebFullScreenManagerGtk.cpp @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2011 Igalia S.L. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "config.h" +#include "WebFullScreenManagerGtk.h" + +#if ENABLE(FULLSCREEN_API) + +#include <WebCore/NotImplemented.h> + +namespace WebKit { + +WebFullScreenManagerGtk::WebFullScreenManagerGtk(WebPage* page) + : WebFullScreenManager(page) +{ +} + +PassRefPtr<WebFullScreenManager> WebFullScreenManager::create(WebPage* page) +{ + return adoptRef(new WebFullScreenManagerGtk(page)); +} + +void WebFullScreenManagerGtk::setRootFullScreenLayer(WebCore::GraphicsLayer* layer) +{ + notImplemented(); +} + +void WebFullScreenManagerGtk::beginEnterFullScreenAnimation(float duration) +{ + notImplemented(); +} + +void WebFullScreenManagerGtk::beginExitFullScreenAnimation(float duration) +{ + notImplemented(); +} + +} // namespace WebKit + +#endif // ENABLE(FULLSCREEN_API) diff --git a/src/3rdparty/webkit/Source/WebKit2/WebProcess/FullScreen/gtk/WebFullScreenManagerGtk.h b/src/3rdparty/webkit/Source/WebKit2/WebProcess/FullScreen/gtk/WebFullScreenManagerGtk.h new file mode 100644 index 0000000..51f5527 --- /dev/null +++ b/src/3rdparty/webkit/Source/WebKit2/WebProcess/FullScreen/gtk/WebFullScreenManagerGtk.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2011 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 ``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 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 WebFullScreenManagerGtk_h +#define WebFullScreenManagerGtk_h + +#if ENABLE(FULLSCREEN_API) + +#include "WebFullScreenManager.h" + +namespace WebKit { + +class WebFullScreenManagerGtk : public WebFullScreenManager { +public: + WebFullScreenManagerGtk(WebPage*); + virtual void setRootFullScreenLayer(WebCore::GraphicsLayer*); + +private: + virtual void beginEnterFullScreenAnimation(float duration); + virtual void beginExitFullScreenAnimation(float duration); + +}; + +} + +#endif // ENABLE(FULLSCREEN_API) + +#endif // WebFullScreenManagerGtk_h diff --git a/src/3rdparty/webkit/Source/WebKit2/WebProcess/FullScreen/mac/WebFullScreenManagerMac.h b/src/3rdparty/webkit/Source/WebKit2/WebProcess/FullScreen/mac/WebFullScreenManagerMac.h new file mode 100644 index 0000000..805b129 --- /dev/null +++ b/src/3rdparty/webkit/Source/WebKit2/WebProcess/FullScreen/mac/WebFullScreenManagerMac.h @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2011 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 ``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 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 WebFullScreenManagerMac_h +#define WebFullScreenManagerMac_h + +#if ENABLE(FULLSCREEN_API) + +#import "LayerTreeContext.h" +#import "WebFullScreenManager.h" + +#import <WebCore/GraphicsLayer.h> +#import <WebCore/IntRect.h> +#import <wtf/RetainPtr.h> + +typedef struct __WKCARemoteLayerClientRef* WKCARemoteLayerClientRef; +OBJC_CLASS WebFullScreenManagerAnimationListener; + +namespace WebKit { + +class WebFullScreenManagerMac : public WebFullScreenManager { +public: + static PassRefPtr<WebFullScreenManagerMac> create(WebPage*); + + virtual void setRootFullScreenLayer(WebCore::GraphicsLayer*); + +private: + WebFullScreenManagerMac(WebPage*); + virtual ~WebFullScreenManagerMac(); + + virtual void beginEnterFullScreenAnimation(float duration); + virtual void beginExitFullScreenAnimation(float duration); + + OwnPtr<WebCore::GraphicsLayer> m_rootLayer; + RetainPtr<PlatformLayer> m_fullScreenRootLayer; + LayerTreeContext m_layerTreeContext; + RetainPtr<WKCARemoteLayerClientRef> m_remoteLayerClient; + RetainPtr<id> m_enterFullScreenListener; + RetainPtr<id> m_exitFullScreenListener; +}; + +} + +#endif // ENABLE(FULLSCREEN_API) + +#endif // WebFullScreenManagerMac_h diff --git a/src/3rdparty/webkit/Source/WebKit2/WebProcess/FullScreen/mac/WebFullScreenManagerMac.mm b/src/3rdparty/webkit/Source/WebKit2/WebProcess/FullScreen/mac/WebFullScreenManagerMac.mm new file mode 100644 index 0000000..4ca225a --- /dev/null +++ b/src/3rdparty/webkit/Source/WebKit2/WebProcess/FullScreen/mac/WebFullScreenManagerMac.mm @@ -0,0 +1,293 @@ +/* + * Copyright (C) 2011 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 ``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 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. + */ +#import "config.h" +#import "WebFullScreenManagerMac.h" + +#if ENABLE(FULLSCREEN_API) + +#import "Connection.h" +#import "LayerTreeContext.h" +#import "MessageID.h" +#import "WebFullScreenManagerProxyMessages.h" +#import "WebPage.h" +#import "WebProcess.h" +#import <QuartzCore/QuartzCore.h> +#import <WebCore/Frame.h> +#import <WebCore/FrameView.h> +#import <WebCore/GraphicsLayer.h> +#import <WebCore/Page.h> +#import <WebCore/Settings.h> +#import <WebKitSystemInterface.h> + +using namespace WebCore; + +typedef void (WebKit::WebFullScreenManager::*AnimationBeganFunction)(); +typedef void (WebKit::WebFullScreenManager::*AnimationFinishedFunction)(bool); + +#if defined(BUILDING_ON_LEOPARD) +@interface CATransaction(SnowLeopardConvenienceFunctions) ++ (void)setDisableActions:(BOOL)flag; +@end + +@implementation CATransaction(SnowLeopardConvenienceFunctions) ++ (void)setDisableActions:(BOOL)flag +{ + [self setValue:[NSNumber numberWithBool:flag] forKey:kCATransactionDisableActions]; +} +@end +#endif + +@interface WebFullScreenManagerAnimationListener : NSObject { + WebKit::WebFullScreenManager* _manager; + AnimationBeganFunction _began; + AnimationFinishedFunction _finished; +} +- (id)initWithManager:(WebKit::WebFullScreenManager*)manager began:(AnimationBeganFunction)began finished:(AnimationFinishedFunction)finished; +- (void)animationDidStart:(CAAnimation *)anim; +- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag; +- (void)invalidate; +@end + +@implementation WebFullScreenManagerAnimationListener +- (id)initWithManager:(WebKit::WebFullScreenManager*)manager began:(AnimationBeganFunction)began finished:(AnimationFinishedFunction)finished +{ + self = [super init]; + if (!self) + return nil; + + _manager = manager; + _began = began; + _finished = finished; + return self; +} + +- (void)animationDidStart:(CAAnimation *)anim +{ + if (_manager && _began) + (_manager->*_began)(); +} + +- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag +{ + if (_manager && _finished) + (_manager->*_finished)(flag); +} + +- (void)invalidate +{ + _manager = 0; + _began = 0; + _finished = 0; +} +@end + +namespace WebKit { + +PassRefPtr<WebFullScreenManager> WebFullScreenManager::create(WebPage* page) +{ + return WebFullScreenManagerMac::create(page); +} + +PassRefPtr<WebFullScreenManagerMac> WebFullScreenManagerMac::create(WebPage* page) +{ + return adoptRef(new WebFullScreenManagerMac(page)); +} + +WebFullScreenManagerMac::WebFullScreenManagerMac(WebPage* page) + : WebFullScreenManager(page) +{ + m_enterFullScreenListener.adoptNS([[WebFullScreenManagerAnimationListener alloc] initWithManager:this began:&WebFullScreenManagerMac::beganEnterFullScreenAnimation finished:&WebFullScreenManagerMac::finishedEnterFullScreenAnimation]); + m_exitFullScreenListener.adoptNS([[WebFullScreenManagerAnimationListener alloc] initWithManager:this began:&WebFullScreenManagerMac::beganExitFullScreenAnimation finished:&WebFullScreenManagerMac::finishedExitFullScreenAnimation]); +} + +WebFullScreenManagerMac::~WebFullScreenManagerMac() +{ + m_page->send(Messages::WebFullScreenManagerProxy::ExitAcceleratedCompositingMode()); + [m_enterFullScreenListener.get() invalidate]; + [m_exitFullScreenListener.get() invalidate]; +} + +void WebFullScreenManagerMac::setRootFullScreenLayer(WebCore::GraphicsLayer* layer) +{ + if (m_fullScreenRootLayer == (layer ? layer->platformLayer() : 0)) + return; + + if (!layer) { + m_page->send(Messages::WebFullScreenManagerProxy::ExitAcceleratedCompositingMode()); + if (m_rootLayer) { + m_rootLayer->removeAllChildren(); + m_rootLayer = nullptr; + } + + [[NSNotificationCenter defaultCenter] postNotificationName:@"WebKitLayerHostChanged" object:m_fullScreenRootLayer.get() userInfo:nil]; + m_fullScreenRootLayer = 0; + return; + } + + if (!m_rootLayer) { + mach_port_t serverPort = WebProcess::shared().compositingRenderServerPort(); + m_remoteLayerClient = WKCARemoteLayerClientMakeWithServerPort(serverPort); + + m_rootLayer = GraphicsLayer::create(NULL); +#ifndef NDEBUG + m_rootLayer->setName("Full screen root layer"); +#endif + m_rootLayer->setDrawsContent(false); + m_rootLayer->setSize(getFullScreenRect().size()); + + [m_rootLayer->platformLayer() setGeometryFlipped:YES]; + WKCARemoteLayerClientSetLayer(m_remoteLayerClient.get(), m_rootLayer->platformLayer()); + m_layerTreeContext.contextID = WKCARemoteLayerClientGetClientId(m_remoteLayerClient.get()); + m_page->send(Messages::WebFullScreenManagerProxy::EnterAcceleratedCompositingMode(m_layerTreeContext)); + } + + m_rootLayer->removeAllChildren(); + m_rootLayer->addChild(layer); + + m_rootLayer->syncCompositingStateForThisLayerOnly(); + m_page->corePage()->mainFrame()->view()->syncCompositingStateIncludingSubframes(); + m_fullScreenRootLayer = layer->platformLayer(); + layer->syncCompositingState(); + + [[NSNotificationCenter defaultCenter] postNotificationName:@"WebKitLayerHostChanged" object:m_fullScreenRootLayer.get() userInfo:nil]; +} + +void WebFullScreenManagerMac::beginEnterFullScreenAnimation(float duration) +{ + ASSERT(m_element); + + if (!m_fullScreenRootLayer) { + // If we don't have a root layer, we can't animate in and out of full screen + this->beganEnterFullScreenAnimation(); + this->finishedEnterFullScreenAnimation(true); + return; + } + + IntRect destinationFrame = getFullScreenRect(); + m_element->document()->setFullScreenRendererSize(destinationFrame.size()); + m_rootLayer->syncCompositingStateForThisLayerOnly(); + m_page->corePage()->mainFrame()->view()->syncCompositingStateIncludingSubframes(); + + // FIXME: Once we gain the ability to do native WebKit animations of generated + // content, this can change to use them. Meanwhile, we'll have to animate the + // CALayer directly: + CALayer* caLayer = m_fullScreenRootLayer.get(); + + // Create a transformation matrix that will transform the renderer layer such that + // the fullscreen element appears to move from its starting position and size to its + // final one. + CGPoint destinationPosition = [caLayer position]; + CGPoint layerAnchor = [caLayer anchorPoint]; + CGPoint initialPosition = CGPointMake( + m_initialFrame.x() + m_initialFrame.width() * layerAnchor.x, + m_initialFrame.y() + m_initialFrame.height() * layerAnchor.y); + CATransform3D shrinkTransform = CATransform3DMakeScale( + static_cast<CGFloat>(m_initialFrame.width()) / destinationFrame.width(), + static_cast<CGFloat>(m_initialFrame.height()) / destinationFrame.height(), 1); + CATransform3D shiftTransform = CATransform3DMakeTranslation( + initialPosition.x - destinationPosition.x, + // Drawing is flipped here, and so much be the translation transformation + destinationPosition.y - initialPosition.y, 0); + CATransform3D finalTransform = CATransform3DConcat(shrinkTransform, shiftTransform); + + // Use a CABasicAnimation here for the zoom effect. We want to be notified that the animation has + // completed by way of the CAAnimation delegate. + CABasicAnimation* zoomAnimation = [CABasicAnimation animationWithKeyPath:@"transform"]; + [zoomAnimation setFromValue:[NSValue valueWithCATransform3D:finalTransform]]; + [zoomAnimation setToValue:[NSValue valueWithCATransform3D:CATransform3DIdentity]]; + [zoomAnimation setDelegate:m_enterFullScreenListener.get()]; + [zoomAnimation setDuration:duration]; + [zoomAnimation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]]; + [zoomAnimation setFillMode:kCAFillModeForwards]; + + // Disable implicit animations and set the layer's transformation matrix to its final state. + [CATransaction begin]; + [CATransaction setDisableActions:YES]; + [caLayer addAnimation:zoomAnimation forKey:@"zoom"]; + [CATransaction commit]; +} + +void WebFullScreenManagerMac::beginExitFullScreenAnimation(float duration) +{ + ASSERT(m_element); + + if (!m_fullScreenRootLayer) { + // If we don't have a root layer, we can't animate in and out of full screen + this->beganExitFullScreenAnimation(); + this->finishedExitFullScreenAnimation(true); + return; + } + + IntRect destinationFrame = getFullScreenRect(); + m_element->document()->setFullScreenRendererSize(destinationFrame.size()); + m_rootLayer->syncCompositingStateForThisLayerOnly(); + m_page->corePage()->mainFrame()->view()->syncCompositingStateIncludingSubframes(); + + // FIXME: Once we gain the ability to do native WebKit animations of generated + // content, this can change to use them. Meanwhile, we'll have to animate the + // CALayer directly: + CALayer* caLayer = m_fullScreenRootLayer.get(); + + // Create a transformation matrix that will transform the renderer layer such that + // the fullscreen element appears to move from its starting position and size to its + // final one. + CGPoint destinationPosition = [(CALayer *)[caLayer presentationLayer] position]; + CGRect destinationBounds = [(CALayer *)[caLayer presentationLayer] bounds]; + CGPoint layerAnchor = [caLayer anchorPoint]; + CGPoint initialPosition = CGPointMake( + m_initialFrame.x() + m_initialFrame.width() * layerAnchor.x, + m_initialFrame.y() + m_initialFrame.height() * layerAnchor.y); + CATransform3D shrinkTransform = CATransform3DMakeScale( + static_cast<CGFloat>(m_initialFrame.width()) / destinationBounds.size.width, + static_cast<CGFloat>(m_initialFrame.height()) / destinationBounds.size.height, 1); + CATransform3D shiftTransform = CATransform3DMakeTranslation( + initialPosition.x - destinationPosition.x, + // Drawing is flipped here, and so must be the translation transformation + destinationPosition.y - initialPosition.y, 0); + CATransform3D finalTransform = CATransform3DConcat(shrinkTransform, shiftTransform); + + CATransform3D initialTransform = [(CALayer*)[caLayer presentationLayer] transform]; + + // Use a CABasicAnimation here for the zoom effect. We want to be notified that the animation has + // completed by way of the CAAnimation delegate. + CABasicAnimation* zoomAnimation = [CABasicAnimation animationWithKeyPath:@"transform"]; + [zoomAnimation setFromValue:[NSValue valueWithCATransform3D:initialTransform]]; + [zoomAnimation setToValue:[NSValue valueWithCATransform3D:finalTransform]]; + [zoomAnimation setDelegate:m_exitFullScreenListener.get()]; + [zoomAnimation setDuration:duration]; + [zoomAnimation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]]; + [zoomAnimation setFillMode:kCAFillModeForwards]; + + // Disable implicit animations and set the layer's transformation matrix to its final state. + [CATransaction begin]; + [CATransaction setDisableActions:YES]; + [caLayer addAnimation:zoomAnimation forKey:@"zoom"]; + [caLayer setTransform:finalTransform]; + [CATransaction commit]; +} + +} // namespace WebKit + +#endif // ENABLE(FULLSCREEN_API) diff --git a/src/3rdparty/webkit/Source/WebKit2/WebProcess/FullScreen/win/WebFullScreenManagerWin.cpp b/src/3rdparty/webkit/Source/WebKit2/WebProcess/FullScreen/win/WebFullScreenManagerWin.cpp new file mode 100644 index 0000000..75e0c5e --- /dev/null +++ b/src/3rdparty/webkit/Source/WebKit2/WebProcess/FullScreen/win/WebFullScreenManagerWin.cpp @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2011 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 ``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 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 "WebFullScreenManagerWin.h" + +#if ENABLE(FULLSCREEN_API) + +#include "MessageID.h" +#include "WebFullScreenManagerProxyMessages.h" +#include "WebPage.h" +#include "WebProcess.h" +#include <WebCore/Frame.h> +#include <WebCore/FrameView.h> +#include <WebCore/GraphicsLayer.h> +#include <WebCore/Page.h> +#include <WebKitSystemInterface/WebKitSystemInterface.h> + +using namespace WebCore; + +namespace WebKit { + +PassRefPtr<WebFullScreenManager> WebFullScreenManager::create(WebPage* page) +{ + return WebFullScreenManagerWin::create(page); +} + +PassRefPtr<WebFullScreenManagerWin> WebFullScreenManagerWin::create(WebPage* page) +{ + return adoptRef(new WebFullScreenManagerWin(page)); +} + +WebFullScreenManagerWin::WebFullScreenManagerWin(WebPage* page) + : WebFullScreenManager(page) +{ +} + +WebFullScreenManagerWin::~WebFullScreenManagerWin() +{ + m_page->send(Messages::WebFullScreenManagerProxy::ExitAcceleratedCompositingMode()); +} + +void WebFullScreenManagerWin::setRootFullScreenLayer(WebCore::GraphicsLayer* layer) +{ + // Host the full screen layer if its given to us; otherwise it will be disconnected + // from the layer heirarchy and cause an ASSERT during resync. + // FIXME: Disable setting RenderLayer::setAnimating() to make this unnecessary. + if (m_fullScreenRootLayer == layer) + return; + m_fullScreenRootLayer = layer; + + if (!m_fullScreenRootLayer) { + m_page->send(Messages::WebFullScreenManagerProxy::ExitAcceleratedCompositingMode()); + if (m_rootLayer) { + m_rootLayer->removeAllChildren(); + m_rootLayer = 0; + } + return; + } + + if (!m_rootLayer) { + m_rootLayer = GraphicsLayer::create(0); +#ifndef NDEBUG + m_rootLayer->setName("Full screen root layer"); +#endif + m_rootLayer->setDrawsContent(false); + m_rootLayer->setSize(getFullScreenRect().size()); + } + + m_rootLayer->removeAllChildren(); + + if (m_fullScreenRootLayer) + m_rootLayer->addChild(m_fullScreenRootLayer); + + m_rootLayer->syncCompositingStateForThisLayerOnly(); + m_page->corePage()->mainFrame()->view()->syncCompositingStateIncludingSubframes(); +} + +void WebFullScreenManagerWin::beginEnterFullScreenAnimation(float) +{ + // FIXME: Add support for animating the content into full screen. +} + +void WebFullScreenManagerWin::beginExitFullScreenAnimation(float) +{ + // FIXME: Add support for animating the content into full screen. +} + +} // namespace WebKit + +#endif // ENABLE(FULLSCREEN_API) diff --git a/src/3rdparty/webkit/Source/WebKit2/WebProcess/FullScreen/win/WebFullScreenManagerWin.h b/src/3rdparty/webkit/Source/WebKit2/WebProcess/FullScreen/win/WebFullScreenManagerWin.h new file mode 100644 index 0000000..22f74f1 --- /dev/null +++ b/src/3rdparty/webkit/Source/WebKit2/WebProcess/FullScreen/win/WebFullScreenManagerWin.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2011 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 ``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 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 WebFullScreenManagerWin_h +#define WebFullScreenManagerWin_h + +#if ENABLE(FULLSCREEN_API) + +#include "WebFullScreenManager.h" + +#include <WebCore/IntRect.h> + +namespace WebKit { + +class WebFullScreenManagerWin : public WebFullScreenManager { +public: + static PassRefPtr<WebFullScreenManagerWin> create(WebPage*); + +private: + WebFullScreenManagerWin(WebPage*); + virtual ~WebFullScreenManagerWin(); + + virtual void setRootFullScreenLayer(WebCore::GraphicsLayer*); + virtual void beginEnterFullScreenAnimation(float duration); + virtual void beginExitFullScreenAnimation(float duration); + + OwnPtr<WebCore::GraphicsLayer> m_rootLayer; + WebCore::GraphicsLayer* m_fullScreenRootLayer; +}; + +} + +#endif // ENABLE(FULLSCREEN_API) + +#endif // WebFullScreenManagerWin_h |