| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 | 48 |
| 49 FullscreenController* FullscreenController::create(WebViewImpl* webViewImpl) | 49 FullscreenController* FullscreenController::create(WebViewImpl* webViewImpl) |
| 50 { | 50 { |
| 51 return new FullscreenController(webViewImpl); | 51 return new FullscreenController(webViewImpl); |
| 52 } | 52 } |
| 53 | 53 |
| 54 FullscreenController::FullscreenController(WebViewImpl* webViewImpl) | 54 FullscreenController::FullscreenController(WebViewImpl* webViewImpl) |
| 55 : m_webViewImpl(webViewImpl) | 55 : m_webViewImpl(webViewImpl) |
| 56 , m_haveEnteredFullscreen(false) | 56 , m_haveEnteredFullscreen(false) |
| 57 , m_exitFullscreenPageScaleFactor(0) | 57 , m_exitFullscreenPageScaleFactor(0) |
| 58 , m_fullscreenIsForCrossProcessAncestor(false) |
| 58 , m_isCancelingFullScreen(false) | 59 , m_isCancelingFullScreen(false) |
| 59 { | 60 { |
| 60 } | 61 } |
| 61 | 62 |
| 62 void FullscreenController::didEnterFullScreen() | 63 void FullscreenController::didEnterFullScreen() |
| 63 { | 64 { |
| 64 if (!m_provisionalFullScreenElement) | 65 if (!m_provisionalFullScreenElement) |
| 65 return; | 66 return; |
| 66 | 67 |
| 67 Element* element = m_provisionalFullScreenElement.release(); | 68 Element* element = m_provisionalFullScreenElement.release(); |
| 68 Document& document = element->document(); | 69 Document& document = element->document(); |
| 69 m_fullScreenFrame = document.frame(); | 70 m_fullScreenFrame = document.frame(); |
| 70 | 71 |
| 71 if (!m_fullScreenFrame) | 72 if (!m_fullScreenFrame) |
| 72 return; | 73 return; |
| 73 | 74 |
| 74 if (!m_haveEnteredFullscreen) { | 75 if (!m_haveEnteredFullscreen) { |
| 75 updatePageScaleConstraints(false); | 76 updatePageScaleConstraints(false); |
| 76 m_webViewImpl->setPageScaleFactor(1.0f); | 77 m_webViewImpl->setPageScaleFactor(1.0f); |
| 77 m_webViewImpl->mainFrame()->setScrollOffset(WebSize()); | 78 if (m_webViewImpl->mainFrame()->isWebLocalFrame()) |
| 79 m_webViewImpl->mainFrame()->setScrollOffset(WebSize()); |
| 78 m_webViewImpl->setVisualViewportOffset(FloatPoint()); | 80 m_webViewImpl->setVisualViewportOffset(FloatPoint()); |
| 79 m_haveEnteredFullscreen = true; | 81 m_haveEnteredFullscreen = true; |
| 80 } | 82 } |
| 81 | 83 |
| 82 Fullscreen::from(document).didEnterFullScreenForElement(element); | 84 Fullscreen::from(document).didEnterFullScreenForElement(element, m_fullscree
nIsForCrossProcessAncestor); |
| 83 DCHECK_EQ(Fullscreen::currentFullScreenElementFrom(document), element); | 85 DCHECK_EQ(Fullscreen::currentFullScreenElementFrom(document), element); |
| 84 | 86 |
| 85 if (isHTMLVideoElement(element)) { | 87 if (isHTMLVideoElement(element)) { |
| 86 HTMLVideoElement* videoElement = toHTMLVideoElement(element); | 88 HTMLVideoElement* videoElement = toHTMLVideoElement(element); |
| 87 if (videoElement->usesOverlayFullscreenVideo() && m_webViewImpl->layerTr
eeView()) | 89 if (videoElement->usesOverlayFullscreenVideo() && m_webViewImpl->layerTr
eeView()) |
| 88 m_webViewImpl->layerTreeView()->setHasTransparentBackground(true); | 90 m_webViewImpl->layerTreeView()->setHasTransparentBackground(true); |
| 89 } | 91 } |
| 90 } | 92 } |
| 91 | 93 |
| 92 void FullscreenController::didExitFullScreen() | 94 void FullscreenController::didExitFullScreen() |
| (...skipping 11 matching lines...) Expand all Loading... |
| 104 Fullscreen::fullyExitFullscreen(*document); | 106 Fullscreen::fullyExitFullscreen(*document); |
| 105 m_isCancelingFullScreen = false; | 107 m_isCancelingFullScreen = false; |
| 106 | 108 |
| 107 // If the video used overlay fullscreen mode, the background was
made transparent. Restore the transparency. | 109 // If the video used overlay fullscreen mode, the background was
made transparent. Restore the transparency. |
| 108 if (isHTMLVideoElement(element) && m_webViewImpl->layerTreeView(
)) | 110 if (isHTMLVideoElement(element) && m_webViewImpl->layerTreeView(
)) |
| 109 m_webViewImpl->layerTreeView()->setHasTransparentBackground(
m_webViewImpl->isTransparent()); | 111 m_webViewImpl->layerTreeView()->setHasTransparentBackground(
m_webViewImpl->isTransparent()); |
| 110 | 112 |
| 111 if (m_haveEnteredFullscreen) { | 113 if (m_haveEnteredFullscreen) { |
| 112 updatePageScaleConstraints(true); | 114 updatePageScaleConstraints(true); |
| 113 m_webViewImpl->setPageScaleFactor(m_exitFullscreenPageScaleF
actor); | 115 m_webViewImpl->setPageScaleFactor(m_exitFullscreenPageScaleF
actor); |
| 114 m_webViewImpl->mainFrame()->setScrollOffset(WebSize(m_exitFu
llscreenScrollOffset)); | 116 if (m_webViewImpl->mainFrame()->isWebLocalFrame()) |
| 117 m_webViewImpl->mainFrame()->setScrollOffset(WebSize(m_ex
itFullscreenScrollOffset)); |
| 115 m_webViewImpl->setVisualViewportOffset(m_exitFullscreenVisua
lViewportOffset); | 118 m_webViewImpl->setVisualViewportOffset(m_exitFullscreenVisua
lViewportOffset); |
| 116 m_haveEnteredFullscreen = false; | 119 m_haveEnteredFullscreen = false; |
| 117 } | 120 } |
| 118 | 121 |
| 119 fullscreen->didExitFullScreenForElement(0); | 122 fullscreen->didExitFullScreenForElement(m_fullscreenIsForCrossPr
ocessAncestor); |
| 123 m_fullscreenIsForCrossProcessAncestor = false; |
| 120 } | 124 } |
| 121 } | 125 } |
| 122 } | 126 } |
| 123 | 127 |
| 124 m_fullScreenFrame.clear(); | 128 m_fullScreenFrame.clear(); |
| 125 } | 129 } |
| 126 | 130 |
| 127 void FullscreenController::enterFullScreenForElement(Element* element) | 131 void FullscreenController::enterFullScreenForElement(Element* element) |
| 128 { | 132 { |
| 129 // We are already transitioning to fullscreen for a different element. | 133 // We are already transitioning to fullscreen for a different element. |
| 130 if (m_provisionalFullScreenElement) { | 134 if (m_provisionalFullScreenElement) { |
| 131 m_provisionalFullScreenElement = element; | 135 m_provisionalFullScreenElement = element; |
| 132 return; | 136 return; |
| 133 } | 137 } |
| 134 | 138 |
| 135 // We are already in fullscreen mode. | 139 // We are already in fullscreen mode. |
| 136 if (m_fullScreenFrame) { | 140 if (m_fullScreenFrame) { |
| 137 m_provisionalFullScreenElement = element; | 141 m_provisionalFullScreenElement = element; |
| 138 didEnterFullScreen(); | 142 didEnterFullScreen(); |
| 139 return; | 143 return; |
| 140 } | 144 } |
| 141 | 145 |
| 142 // We need to store these values here rather than didEnterFullScreen since | 146 // We need to store these values here rather than didEnterFullScreen since |
| 143 // by the time the latter is called, a Resize has already occured, clamping | 147 // by the time the latter is called, a Resize has already occured, clamping |
| 144 // the scroll offset. | 148 // the scroll offset. |
| 145 if (!m_haveEnteredFullscreen) { | 149 if (!m_haveEnteredFullscreen) { |
| 146 m_exitFullscreenPageScaleFactor = m_webViewImpl->pageScaleFactor(); | 150 m_exitFullscreenPageScaleFactor = m_webViewImpl->pageScaleFactor(); |
| 147 m_exitFullscreenScrollOffset = m_webViewImpl->mainFrame()->scrollOffset(
); | 151 m_exitFullscreenScrollOffset = m_webViewImpl->mainFrame()->isWebLocalFra
me() ? m_webViewImpl->mainFrame()->scrollOffset() : WebSize(); |
| 148 m_exitFullscreenVisualViewportOffset = m_webViewImpl->visualViewportOffs
et(); | 152 m_exitFullscreenVisualViewportOffset = m_webViewImpl->visualViewportOffs
et(); |
| 149 } | 153 } |
| 150 | 154 |
| 151 // We need to transition to fullscreen mode. | 155 // We need to transition to fullscreen mode. |
| 152 WebLocalFrameImpl* frame = WebLocalFrameImpl::fromFrame(element->document().
frame()); | 156 WebLocalFrameImpl* frame = WebLocalFrameImpl::fromFrame(element->document().
frame()); |
| 153 if (frame && frame->client()) { | 157 if (frame && frame->client()) { |
| 154 frame->client()->enterFullscreen(); | 158 if (!m_fullscreenIsForCrossProcessAncestor) |
| 159 frame->client()->enterFullscreen(); |
| 155 m_provisionalFullScreenElement = element; | 160 m_provisionalFullScreenElement = element; |
| 156 } | 161 } |
| 157 } | 162 } |
| 158 | 163 |
| 159 void FullscreenController::exitFullScreenForElement(Element* element) | 164 void FullscreenController::exitFullScreenForElement(Element* element) |
| 160 { | 165 { |
| 161 DCHECK(element); | 166 DCHECK(element); |
| 162 | 167 |
| 163 // The client is exiting full screen, so don't send a notification. | 168 // The client is exiting full screen, so don't send a notification. |
| 164 if (m_isCancelingFullScreen) | 169 if (m_isCancelingFullScreen) |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 } | 209 } |
| 205 | 210 |
| 206 DEFINE_TRACE(FullscreenController) | 211 DEFINE_TRACE(FullscreenController) |
| 207 { | 212 { |
| 208 visitor->trace(m_provisionalFullScreenElement); | 213 visitor->trace(m_provisionalFullScreenElement); |
| 209 visitor->trace(m_fullScreenFrame); | 214 visitor->trace(m_fullScreenFrame); |
| 210 } | 215 } |
| 211 | 216 |
| 212 } // namespace blink | 217 } // namespace blink |
| 213 | 218 |
| OLD | NEW |