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 17 matching lines...) Expand all Loading... | |
| 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 "web/FullscreenController.h" | 31 #include "web/FullscreenController.h" |
| 32 | 32 |
| 33 #include "core/dom/Document.h" | 33 #include "core/dom/Document.h" |
| 34 #include "core/dom/Fullscreen.h" | 34 #include "core/dom/Fullscreen.h" |
| 35 #include "core/frame/FrameView.h" | 35 #include "core/frame/FrameView.h" |
| 36 #include "core/frame/LocalFrame.h" | 36 #include "core/frame/LocalFrame.h" |
| 37 #include "core/frame/PageScaleConstraintsSet.h" | 37 #include "core/frame/PageScaleConstraintsSet.h" |
| 38 #include "core/html/HTMLMediaElement.h" | |
| 39 #include "core/html/HTMLVideoElement.h" | 38 #include "core/html/HTMLVideoElement.h" |
| 40 #include "core/layout/LayoutFullScreen.h" | 39 #include "core/layout/LayoutFullScreen.h" |
| 41 #include "platform/RuntimeEnabledFeatures.h" | 40 #include "platform/RuntimeEnabledFeatures.h" |
| 42 #include "public/platform/WebLayerTreeView.h" | 41 #include "public/platform/WebLayerTreeView.h" |
| 43 #include "public/web/WebFrameClient.h" | 42 #include "public/web/WebFrameClient.h" |
| 44 #include "web/WebLocalFrameImpl.h" | 43 #include "web/WebLocalFrameImpl.h" |
| 45 #include "web/WebSettingsImpl.h" | 44 #include "web/WebSettingsImpl.h" |
| 46 #include "web/WebViewImpl.h" | 45 #include "web/WebViewImpl.h" |
| 47 | 46 |
| 48 namespace blink { | 47 namespace blink { |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 73 updatePageScaleConstraints(false); | 72 updatePageScaleConstraints(false); |
| 74 m_webViewImpl->setPageScaleFactor(1.0f); | 73 m_webViewImpl->setPageScaleFactor(1.0f); |
| 75 if (m_webViewImpl->mainFrame()->isWebLocalFrame()) | 74 if (m_webViewImpl->mainFrame()->isWebLocalFrame()) |
| 76 m_webViewImpl->mainFrame()->setScrollOffset(WebSize()); | 75 m_webViewImpl->mainFrame()->setScrollOffset(WebSize()); |
| 77 m_webViewImpl->setVisualViewportOffset(FloatPoint()); | 76 m_webViewImpl->setVisualViewportOffset(FloatPoint()); |
| 78 m_haveEnteredFullscreen = true; | 77 m_haveEnteredFullscreen = true; |
| 79 } | 78 } |
| 80 | 79 |
| 81 Fullscreen::from(document).didEnterFullscreenForElement(element); | 80 Fullscreen::from(document).didEnterFullscreenForElement(element); |
| 82 DCHECK_EQ(Fullscreen::currentFullScreenElementFrom(document), element); | 81 DCHECK_EQ(Fullscreen::currentFullScreenElementFrom(document), element); |
| 83 | |
| 84 if (isHTMLVideoElement(element)) { | |
| 85 HTMLVideoElement* videoElement = toHTMLVideoElement(element); | |
| 86 if (videoElement->usesOverlayFullscreenVideo() && | |
| 87 m_webViewImpl->layerTreeView()) | |
| 88 m_webViewImpl->layerTreeView()->setHasTransparentBackground(true); | |
| 89 } | |
| 90 } | 82 } |
| 91 | 83 |
| 92 void FullscreenController::didExitFullscreen() { | 84 void FullscreenController::didExitFullscreen() { |
| 93 if (!m_fullscreenFrame) | 85 if (!m_fullscreenFrame) |
| 94 return; | 86 return; |
| 95 | 87 |
| 96 if (m_haveEnteredFullscreen) | 88 if (m_haveEnteredFullscreen) |
| 97 updatePageScaleConstraints(true); | 89 updatePageScaleConstraints(true); |
| 98 | 90 |
| 99 if (Document* document = m_fullscreenFrame->document()) { | 91 if (Document* document = m_fullscreenFrame->document()) { |
| 100 if (Fullscreen* fullscreen = Fullscreen::fromIfExists(*document)) { | 92 if (Fullscreen* fullscreen = Fullscreen::fromIfExists(*document)) { |
| 101 Element* element = fullscreen->currentFullScreenElement(); | 93 Element* element = fullscreen->currentFullScreenElement(); |
| 102 if (element) { | 94 if (element) { |
| 103 // When the client exits from full screen we have to call | 95 // When the client exits from full screen we have to call |
| 104 // fullyExitFullscreen to notify the document. While doing that, | 96 // fullyExitFullscreen to notify the document. While doing that, |
| 105 // suppress notifications back to the client. | 97 // suppress notifications back to the client. |
| 106 m_isCancelingFullscreen = true; | 98 m_isCancelingFullscreen = true; |
| 107 Fullscreen::fullyExitFullscreen(*document); | 99 Fullscreen::fullyExitFullscreen(*document); |
| 108 m_isCancelingFullscreen = false; | 100 m_isCancelingFullscreen = false; |
| 109 | 101 |
| 110 // If the video used overlay fullscreen mode, the background was made | |
| 111 // transparent. Restore the transparency. | |
| 112 if (isHTMLVideoElement(element) && m_webViewImpl->layerTreeView()) | |
| 113 m_webViewImpl->layerTreeView()->setHasTransparentBackground( | |
| 114 m_webViewImpl->isTransparent()); | |
| 115 | |
| 116 // We need to wait until style and layout are updated in order | 102 // We need to wait until style and layout are updated in order |
| 117 // to propertly restore scroll offsets since content may not be | 103 // to propertly restore scroll offsets since content may not be |
| 118 // overflowing in the same way until they do. | 104 // overflowing in the same way until they do. |
| 119 if (m_haveEnteredFullscreen) | 105 if (m_haveEnteredFullscreen) |
| 120 m_needsScrollAndScaleRestore = true; | 106 m_needsScrollAndScaleRestore = true; |
| 121 | 107 |
| 122 fullscreen->didExitFullscreen(); | 108 fullscreen->didExitFullscreen(); |
| 123 } | 109 } |
| 124 } | 110 } |
| 125 } | 111 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 172 | 158 |
| 173 // The client is exiting full screen, so don't send a notification. | 159 // The client is exiting full screen, so don't send a notification. |
| 174 if (m_isCancelingFullscreen) | 160 if (m_isCancelingFullscreen) |
| 175 return; | 161 return; |
| 176 | 162 |
| 177 WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(frame); | 163 WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(frame); |
| 178 if (webFrame && webFrame->client()) | 164 if (webFrame && webFrame->client()) |
| 179 webFrame->client()->exitFullscreen(); | 165 webFrame->client()->exitFullscreen(); |
| 180 } | 166 } |
| 181 | 167 |
| 168 void FullscreenController::fullscreenElementChanged(Element* fromElement, | |
| 169 Element* toElement) { | |
| 170 DCHECK_NE(fromElement, toElement); | |
|
foolip
2016/11/28 16:20:10
Turns out this assert can actually fail for the "r
foolip
2016/11/29 15:21:30
I've fixed that now, this is now ready to land aft
| |
| 171 | |
| 172 if (toElement) { | |
| 173 DCHECK(Fullscreen::isCurrentFullScreenElement(*toElement)); | |
| 174 | |
| 175 if (isHTMLVideoElement(*toElement)) { | |
| 176 HTMLVideoElement& videoElement = toHTMLVideoElement(*toElement); | |
| 177 videoElement.didEnterFullscreen(); | |
| 178 | |
| 179 // If the video uses overlay fullscreen mode, make the background | |
| 180 // transparent. | |
| 181 if (videoElement.usesOverlayFullscreenVideo() && | |
| 182 m_webViewImpl->layerTreeView()) { | |
| 183 m_webViewImpl->layerTreeView()->setHasTransparentBackground(true); | |
| 184 } | |
| 185 } | |
| 186 } | |
| 187 | |
| 188 if (fromElement) { | |
| 189 DCHECK(!Fullscreen::isCurrentFullScreenElement(*fromElement)); | |
| 190 | |
| 191 if (isHTMLVideoElement(*fromElement)) { | |
| 192 // If the video used overlay fullscreen mode, restore the transparency. | |
| 193 if (m_webViewImpl->layerTreeView()) { | |
| 194 m_webViewImpl->layerTreeView()->setHasTransparentBackground( | |
| 195 m_webViewImpl->isTransparent()); | |
| 196 } | |
| 197 | |
| 198 HTMLVideoElement& videoElement = toHTMLVideoElement(*fromElement); | |
| 199 videoElement.didExitFullscreen(); | |
| 200 } | |
| 201 } | |
| 202 } | |
| 203 | |
| 182 void FullscreenController::updateSize() { | 204 void FullscreenController::updateSize() { |
| 183 if (!isFullscreen()) | 205 if (!isFullscreen()) |
| 184 return; | 206 return; |
| 185 | 207 |
| 186 updatePageScaleConstraints(false); | 208 updatePageScaleConstraints(false); |
| 187 | 209 |
| 188 LayoutFullScreen* layoutObject = | 210 LayoutFullScreen* layoutObject = |
| 189 Fullscreen::from(*m_fullscreenFrame->document()).fullScreenLayoutObject(); | 211 Fullscreen::from(*m_fullscreenFrame->document()).fullScreenLayoutObject(); |
| 190 if (layoutObject) | 212 if (layoutObject) |
| 191 layoutObject->updateStyle(); | 213 layoutObject->updateStyle(); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 232 | 254 |
| 233 m_webViewImpl->updateMainFrameLayoutSize(); | 255 m_webViewImpl->updateMainFrameLayoutSize(); |
| 234 } | 256 } |
| 235 | 257 |
| 236 DEFINE_TRACE(FullscreenController) { | 258 DEFINE_TRACE(FullscreenController) { |
| 237 visitor->trace(m_provisionalFullscreenElement); | 259 visitor->trace(m_provisionalFullscreenElement); |
| 238 visitor->trace(m_fullscreenFrame); | 260 visitor->trace(m_fullscreenFrame); |
| 239 } | 261 } |
| 240 | 262 |
| 241 } // namespace blink | 263 } // namespace blink |
| OLD | NEW |