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