Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "FullscreenController.h" | 32 #include "FullscreenController.h" |
| 33 | 33 |
| 34 #include "RuntimeEnabledFeatures.h" | |
| 34 #include "WebFrame.h" | 35 #include "WebFrame.h" |
| 35 #include "WebViewClient.h" | 36 #include "WebViewClient.h" |
| 36 #include "WebViewImpl.h" | 37 #include "WebViewImpl.h" |
| 37 #include "core/dom/Document.h" | 38 #include "core/dom/Document.h" |
| 38 #include "core/dom/FullscreenElementStack.h" | 39 #include "core/dom/FullscreenElementStack.h" |
| 39 #include "core/html/HTMLMediaElement.h" | 40 #include "core/html/HTMLMediaElement.h" |
| 40 #include "core/page/Frame.h" | 41 #include "core/page/Frame.h" |
| 42 #include "core/platform/LayoutTestSupport.h" | |
| 41 | 43 |
| 42 using namespace WebCore; | 44 using namespace WebCore; |
| 43 | 45 |
| 44 namespace WebKit { | 46 namespace WebKit { |
| 45 | 47 |
| 46 PassOwnPtr<FullscreenController> FullscreenController::create(WebViewImpl* webVi ewImpl) | 48 PassOwnPtr<FullscreenController> FullscreenController::create(WebViewImpl* webVi ewImpl) |
| 47 { | 49 { |
| 48 return adoptPtr(new FullscreenController(webViewImpl)); | 50 return adoptPtr(new FullscreenController(webViewImpl)); |
| 49 } | 51 } |
| 50 | 52 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 76 | 78 |
| 77 if (Document* doc = m_fullScreenFrame->document()) { | 79 if (Document* doc = m_fullScreenFrame->document()) { |
| 78 if (FullscreenElementStack::isFullScreen(doc)) { | 80 if (FullscreenElementStack::isFullScreen(doc)) { |
| 79 if (!m_exitFullscreenPageScaleFactor) { | 81 if (!m_exitFullscreenPageScaleFactor) { |
| 80 m_exitFullscreenPageScaleFactor = m_webViewImpl->pageScaleFactor (); | 82 m_exitFullscreenPageScaleFactor = m_webViewImpl->pageScaleFactor (); |
| 81 m_exitFullscreenScrollOffset = m_webViewImpl->mainFrame()->scrol lOffset(); | 83 m_exitFullscreenScrollOffset = m_webViewImpl->mainFrame()->scrol lOffset(); |
| 82 m_webViewImpl->setPageScaleFactorPreservingScrollOffset(1.0f); | 84 m_webViewImpl->setPageScaleFactorPreservingScrollOffset(1.0f); |
| 83 } | 85 } |
| 84 | 86 |
| 85 FullscreenElementStack::from(doc)->webkitDidEnterFullScreenForElemen t(0); | 87 FullscreenElementStack::from(doc)->webkitDidEnterFullScreenForElemen t(0); |
| 88 if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled()) { | |
| 89 if (Element* element = FullscreenElementStack::currentFullScreen ElementFrom(doc)) { | |
|
esprehn
2013/09/13 02:46:07
How can this Element be null? If this document is
trchen
2013/09/13 05:14:58
I'll change it to an ASSERT too. ;)
| |
| 90 if (element->isMediaElement() && m_webViewImpl->layerTreeVie w()) | |
| 91 m_webViewImpl->layerTreeView()->setHasTransparentBackgro und(true); | |
| 92 } | |
| 93 } | |
| 86 } | 94 } |
| 87 } | 95 } |
| 88 } | 96 } |
| 89 | 97 |
| 90 void FullscreenController::willExitFullScreen() | 98 void FullscreenController::willExitFullScreen() |
| 91 { | 99 { |
| 92 if (!m_fullScreenFrame) | 100 if (!m_fullScreenFrame) |
| 93 return; | 101 return; |
| 94 | 102 |
| 95 if (Document* doc = m_fullScreenFrame->document()) { | 103 if (Document* doc = m_fullScreenFrame->document()) { |
| 96 FullscreenElementStack* fullscreen = FullscreenElementStack::fromIfExist s(doc); | 104 FullscreenElementStack* fullscreen = FullscreenElementStack::fromIfExist s(doc); |
| 97 if (!fullscreen) | 105 if (!fullscreen) |
| 98 return; | 106 return; |
| 99 if (fullscreen->isFullScreen(doc)) { | 107 if (fullscreen->isFullScreen(doc)) { |
| 100 // When the client exits from full screen we have to call webkitCanc elFullScreen to | 108 // When the client exits from full screen we have to call webkitCanc elFullScreen to |
| 101 // notify the document. While doing that, suppress notifications bac k to the client. | 109 // notify the document. While doing that, suppress notifications bac k to the client. |
| 102 m_isCancelingFullScreen = true; | 110 m_isCancelingFullScreen = true; |
| 103 fullscreen->webkitCancelFullScreen(); | 111 fullscreen->webkitCancelFullScreen(); |
| 104 m_isCancelingFullScreen = false; | 112 m_isCancelingFullScreen = false; |
| 105 fullscreen->webkitWillExitFullScreenForElement(0); | 113 fullscreen->webkitWillExitFullScreenForElement(0); |
| 114 if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled() && m_web ViewImpl->layerTreeView()) | |
| 115 m_webViewImpl->layerTreeView()->setHasTransparentBackground(m_we bViewImpl->isTransparent()); | |
| 106 } | 116 } |
| 107 } | 117 } |
| 108 } | 118 } |
| 109 | 119 |
| 110 void FullscreenController::didExitFullScreen() | 120 void FullscreenController::didExitFullScreen() |
| 111 { | 121 { |
| 112 if (!m_fullScreenFrame) | 122 if (!m_fullScreenFrame) |
| 113 return; | 123 return; |
| 114 | 124 |
| 115 if (Document* doc = m_fullScreenFrame->document()) { | 125 if (Document* doc = m_fullScreenFrame->document()) { |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 139 } | 149 } |
| 140 | 150 |
| 141 // We are already in fullscreen mode. | 151 // We are already in fullscreen mode. |
| 142 if (m_fullScreenFrame) { | 152 if (m_fullScreenFrame) { |
| 143 m_provisionalFullScreenElement = element; | 153 m_provisionalFullScreenElement = element; |
| 144 willEnterFullScreen(); | 154 willEnterFullScreen(); |
| 145 didEnterFullScreen(); | 155 didEnterFullScreen(); |
| 146 return; | 156 return; |
| 147 } | 157 } |
| 148 | 158 |
| 149 #if USE(NATIVE_FULLSCREEN_VIDEO) | 159 if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled() |
| 150 if (element && element->isMediaElement()) { | 160 && element && element->isMediaElement() |
| 161 // FIXME: There is no embedder-side handling in layout test mode. | |
|
esprehn
2013/09/13 02:46:07
What does this mean?
trchen
2013/09/13 05:14:58
In layout test mode there is no real hardware over
| |
| 162 && !isRunningLayoutTest()) { | |
| 151 HTMLMediaElement* mediaElement = toHTMLMediaElement(element); | 163 HTMLMediaElement* mediaElement = toHTMLMediaElement(element); |
| 152 if (mediaElement->player() && mediaElement->player()->canEnterFullscreen ()) { | 164 if (mediaElement->player() && mediaElement->player()->canShowFullscreenO verlay()) { |
| 153 mediaElement->player()->enterFullscreen(); | 165 mediaElement->player()->showFullscreenOverlay(); |
| 154 m_provisionalFullScreenElement = element; | 166 m_provisionalFullScreenElement = element; |
| 167 return; | |
| 155 } | 168 } |
| 156 return; | |
| 157 } | 169 } |
| 158 #endif | |
| 159 | 170 |
| 160 // We need to transition to fullscreen mode. | 171 // We need to transition to fullscreen mode. |
| 161 if (WebViewClient* client = m_webViewImpl->client()) { | 172 if (WebViewClient* client = m_webViewImpl->client()) { |
| 162 if (client->enterFullScreen()) | 173 if (client->enterFullScreen()) |
| 163 m_provisionalFullScreenElement = element; | 174 m_provisionalFullScreenElement = element; |
| 164 } | 175 } |
| 165 } | 176 } |
| 166 | 177 |
| 167 void FullscreenController::exitFullScreenForElement(WebCore::Element* element) | 178 void FullscreenController::exitFullScreenForElement(WebCore::Element* element) |
| 168 { | 179 { |
| 169 // The client is exiting full screen, so don't send a notification. | 180 // The client is exiting full screen, so don't send a notification. |
| 170 if (m_isCancelingFullScreen) | 181 if (m_isCancelingFullScreen) |
| 171 return; | 182 return; |
| 172 #if USE(NATIVE_FULLSCREEN_VIDEO) | 183 if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled() |
| 173 if (element && element->isMediaElement()) { | 184 && element && element->isMediaElement() |
| 185 // FIXME: There is no embedder-side handling in layout test mode. | |
| 186 && !isRunningLayoutTest()) { | |
| 174 HTMLMediaElement* mediaElement = toHTMLMediaElement(element); | 187 HTMLMediaElement* mediaElement = toHTMLMediaElement(element); |
| 175 if (mediaElement->player()) | 188 if (mediaElement->player()) |
| 176 mediaElement->player()->exitFullscreen(); | 189 mediaElement->player()->hideFullscreenOverlay(); |
| 177 return; | 190 return; |
| 178 } | 191 } |
| 179 #endif | |
| 180 if (WebViewClient* client = m_webViewImpl->client()) | 192 if (WebViewClient* client = m_webViewImpl->client()) |
| 181 client->exitFullScreen(); | 193 client->exitFullScreen(); |
| 182 } | 194 } |
| 183 | 195 |
| 184 } | 196 } |
| 185 | 197 |
| OLD | NEW |