2 * Copyright (C) 2011 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
26 #include "WebFullScreenManager.h"
28 #if ENABLE(FULLSCREEN_API)
30 #include "Connection.h"
31 #include "MessageID.h"
32 #include "WebCoreArgumentCoders.h"
33 #include "WebFullScreenManagerProxyMessages.h"
35 #include "WebProcess.h"
36 #include <WebCore/Color.h>
37 #include <WebCore/Element.h>
38 #include <WebCore/Page.h>
39 #include <WebCore/Settings.h>
41 using namespace WebCore;
45 WebFullScreenManager::WebFullScreenManager(WebPage* page)
50 WebFullScreenManager::~WebFullScreenManager()
55 WebCore::Element* WebFullScreenManager::element()
57 return m_element.get();
60 void WebFullScreenManager::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)
62 didReceiveWebFullScreenManagerMessage(connection, messageID, arguments);
65 bool WebFullScreenManager::supportsFullScreen(bool withKeyboard)
67 if (!m_page->corePage()->settings()->fullScreenEnabled())
70 return m_page->injectedBundleFullScreenClient().supportsFullScreen(m_page.get(), withKeyboard);
74 void WebFullScreenManager::enterFullScreenForElement(WebCore::Element* element)
78 m_initialFrame = m_element->screenRect();
79 m_page->injectedBundleFullScreenClient().enterFullScreenForElement(m_page.get(), element);
82 void WebFullScreenManager::exitFullScreenForElement(WebCore::Element* element)
85 ASSERT(m_element == element);
86 m_page->injectedBundleFullScreenClient().exitFullScreenForElement(m_page.get(), element);
89 void WebFullScreenManager::beganEnterFullScreenAnimation()
91 m_page->send(Messages::WebFullScreenManagerProxy::BeganEnterFullScreenAnimation());
94 void WebFullScreenManager::finishedEnterFullScreenAnimation(bool completed)
96 m_page->send(Messages::WebFullScreenManagerProxy::FinishedEnterFullScreenAnimation(completed));
99 void WebFullScreenManager::beganExitFullScreenAnimation()
101 m_page->send(Messages::WebFullScreenManagerProxy::BeganExitFullScreenAnimation());
104 void WebFullScreenManager::finishedExitFullScreenAnimation(bool completed)
106 m_page->send(Messages::WebFullScreenManagerProxy::FinishedExitFullScreenAnimation(completed));
109 IntRect WebFullScreenManager::getFullScreenRect()
112 m_page->sendSync(Messages::WebFullScreenManagerProxy::GetFullScreenRect(), Messages::WebFullScreenManagerProxy::GetFullScreenRect::Reply(rect));
116 void WebFullScreenManager::willEnterFullScreen()
119 m_element->document()->webkitWillEnterFullScreenForElement(m_element.get());
120 m_element->document()->setFullScreenRendererBackgroundColor(Color::transparent);
123 void WebFullScreenManager::didEnterFullScreen()
126 m_element->document()->setFullScreenRendererBackgroundColor(Color::black);
127 m_element->document()->webkitDidEnterFullScreenForElement(m_element.get());
130 void WebFullScreenManager::willExitFullScreen()
133 m_element->document()->webkitWillExitFullScreenForElement(m_element.get());
134 m_element->document()->setFullScreenRendererBackgroundColor(Color::transparent);
137 void WebFullScreenManager::didExitFullScreen()
140 m_element->document()->webkitDidExitFullScreenForElement(m_element.get());
141 m_element->document()->setFullScreenRendererBackgroundColor(Color::black);
145 } // namespace WebKit
147 #endif // ENABLE(FULLSCREEN_API)