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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 } | 53 } |
54 | 54 |
55 FullscreenController::FullscreenController(WebViewImpl* webViewImpl) | 55 FullscreenController::FullscreenController(WebViewImpl* webViewImpl) |
56 : m_webViewImpl(webViewImpl) | 56 : m_webViewImpl(webViewImpl) |
57 , m_haveEnteredFullscreen(false) | 57 , m_haveEnteredFullscreen(false) |
58 , m_exitFullscreenPageScaleFactor(0) | 58 , m_exitFullscreenPageScaleFactor(0) |
59 , m_isCancelingFullScreen(false) | 59 , m_isCancelingFullScreen(false) |
60 { | 60 { |
61 } | 61 } |
62 | 62 |
63 void FullscreenController::didEnterFullScreen() | 63 void FullscreenController::didEnterFullscreen() |
64 { | 64 { |
65 if (!m_provisionalFullScreenElement) | 65 if (!m_provisionalFullScreenElement) |
66 return; | 66 return; |
67 | 67 |
68 Element* element = m_provisionalFullScreenElement.release(); | 68 Element* element = m_provisionalFullScreenElement.release(); |
69 Document& document = element->document(); | 69 Document& document = element->document(); |
70 m_fullScreenFrame = document.frame(); | 70 m_fullScreenFrame = document.frame(); |
71 | 71 |
72 if (!m_fullScreenFrame) | 72 if (!m_fullScreenFrame) |
73 return; | 73 return; |
74 | 74 |
75 if (!m_haveEnteredFullscreen) { | 75 if (!m_haveEnteredFullscreen) { |
76 updatePageScaleConstraints(false); | 76 updatePageScaleConstraints(false); |
77 m_webViewImpl->setPageScaleFactor(1.0f); | 77 m_webViewImpl->setPageScaleFactor(1.0f); |
78 if (m_webViewImpl->mainFrame()->isWebLocalFrame()) | 78 if (m_webViewImpl->mainFrame()->isWebLocalFrame()) |
79 m_webViewImpl->mainFrame()->setScrollOffset(WebSize()); | 79 m_webViewImpl->mainFrame()->setScrollOffset(WebSize()); |
80 m_webViewImpl->setVisualViewportOffset(FloatPoint()); | 80 m_webViewImpl->setVisualViewportOffset(FloatPoint()); |
81 m_haveEnteredFullscreen = true; | 81 m_haveEnteredFullscreen = true; |
82 } | 82 } |
83 | 83 |
84 Fullscreen::from(document).didEnterFullScreenForElement(element); | 84 Fullscreen::from(document).didEnterFullscreenForElement(element); |
85 DCHECK_EQ(Fullscreen::currentFullScreenElementFrom(document), element); | 85 DCHECK_EQ(Fullscreen::currentFullScreenElementFrom(document), element); |
86 | 86 |
87 if (isHTMLVideoElement(element)) { | 87 if (isHTMLVideoElement(element)) { |
88 HTMLVideoElement* videoElement = toHTMLVideoElement(element); | 88 HTMLVideoElement* videoElement = toHTMLVideoElement(element); |
89 if (videoElement->usesOverlayFullscreenVideo() && m_webViewImpl->layerTr
eeView()) | 89 if (videoElement->usesOverlayFullscreenVideo() && m_webViewImpl->layerTr
eeView()) |
90 m_webViewImpl->layerTreeView()->setHasTransparentBackground(true); | 90 m_webViewImpl->layerTreeView()->setHasTransparentBackground(true); |
91 } | 91 } |
92 } | 92 } |
93 | 93 |
94 void FullscreenController::didExitFullScreen() | 94 void FullscreenController::didExitFullscreen() |
95 { | 95 { |
96 if (!m_fullScreenFrame) | 96 if (!m_fullScreenFrame) |
97 return; | 97 return; |
98 | 98 |
99 if (m_haveEnteredFullscreen) | 99 if (m_haveEnteredFullscreen) |
100 updatePageScaleConstraints(true); | 100 updatePageScaleConstraints(true); |
101 | 101 |
102 if (Document* document = m_fullScreenFrame->document()) { | 102 if (Document* document = m_fullScreenFrame->document()) { |
103 if (Fullscreen* fullscreen = Fullscreen::fromIfExists(*document)) { | 103 if (Fullscreen* fullscreen = Fullscreen::fromIfExists(*document)) { |
104 Element* element = fullscreen->webkitCurrentFullScreenElement(); | 104 Element* element = fullscreen->webkitCurrentFullScreenElement(); |
105 if (element) { | 105 if (element) { |
106 // When the client exits from full screen we have to call fullyE
xitFullscreen to notify | 106 // When the client exits from full screen we have to call fullyE
xitFullscreen to notify |
107 // the document. While doing that, suppress notifications back t
o the client. | 107 // the document. While doing that, suppress notifications back t
o the client. |
108 m_isCancelingFullScreen = true; | 108 m_isCancelingFullScreen = true; |
109 Fullscreen::fullyExitFullscreen(*document); | 109 Fullscreen::fullyExitFullscreen(*document); |
110 m_isCancelingFullScreen = false; | 110 m_isCancelingFullScreen = false; |
111 | 111 |
112 // If the video used overlay fullscreen mode, the background was
made transparent. Restore the transparency. | 112 // If the video used overlay fullscreen mode, the background was
made transparent. Restore the transparency. |
113 if (isHTMLVideoElement(element) && m_webViewImpl->layerTreeView(
)) | 113 if (isHTMLVideoElement(element) && m_webViewImpl->layerTreeView(
)) |
114 m_webViewImpl->layerTreeView()->setHasTransparentBackground(
m_webViewImpl->isTransparent()); | 114 m_webViewImpl->layerTreeView()->setHasTransparentBackground(
m_webViewImpl->isTransparent()); |
115 | 115 |
116 if (m_haveEnteredFullscreen) { | 116 if (m_haveEnteredFullscreen) { |
117 m_webViewImpl->setPageScaleFactor(m_exitFullscreenPageScaleF
actor); | 117 m_webViewImpl->setPageScaleFactor(m_exitFullscreenPageScaleF
actor); |
118 if (m_webViewImpl->mainFrame()->isWebLocalFrame()) | 118 if (m_webViewImpl->mainFrame()->isWebLocalFrame()) |
119 m_webViewImpl->mainFrame()->setScrollOffset(WebSize(m_ex
itFullscreenScrollOffset)); | 119 m_webViewImpl->mainFrame()->setScrollOffset(WebSize(m_ex
itFullscreenScrollOffset)); |
120 m_webViewImpl->setVisualViewportOffset(m_exitFullscreenVisua
lViewportOffset); | 120 m_webViewImpl->setVisualViewportOffset(m_exitFullscreenVisua
lViewportOffset); |
121 } | 121 } |
122 | 122 |
123 fullscreen->didExitFullScreenForElement(); | 123 fullscreen->didExitFullscreen(); |
124 } | 124 } |
125 } | 125 } |
126 } | 126 } |
127 | 127 |
128 m_haveEnteredFullscreen = false; | 128 m_haveEnteredFullscreen = false; |
129 m_fullScreenFrame.clear(); | 129 m_fullScreenFrame.clear(); |
130 } | 130 } |
131 | 131 |
132 void FullscreenController::enterFullScreenForElement(Element* element) | 132 void FullscreenController::enterFullScreenForElement(Element* element) |
133 { | 133 { |
134 // We are already transitioning to fullscreen for a different element. | 134 // We are already transitioning to fullscreen for a different element. |
135 if (m_provisionalFullScreenElement) { | 135 if (m_provisionalFullScreenElement) { |
136 m_provisionalFullScreenElement = element; | 136 m_provisionalFullScreenElement = element; |
137 return; | 137 return; |
138 } | 138 } |
139 | 139 |
140 // We are already in fullscreen mode. | 140 // We are already in fullscreen mode. |
141 if (m_fullScreenFrame) { | 141 if (m_fullScreenFrame) { |
142 m_provisionalFullScreenElement = element; | 142 m_provisionalFullScreenElement = element; |
143 didEnterFullScreen(); | 143 didEnterFullscreen(); |
144 return; | 144 return; |
145 } | 145 } |
146 | 146 |
147 // We need to store these values here rather than didEnterFullScreen since | 147 // We need to store these values here rather than didEnterFullscreen since |
148 // by the time the latter is called, a Resize has already occured, clamping | 148 // by the time the latter is called, a Resize has already occured, clamping |
149 // the scroll offset. | 149 // the scroll offset. |
150 if (!m_haveEnteredFullscreen) { | 150 if (!m_haveEnteredFullscreen) { |
151 m_exitFullscreenPageScaleFactor = m_webViewImpl->pageScaleFactor(); | 151 m_exitFullscreenPageScaleFactor = m_webViewImpl->pageScaleFactor(); |
152 m_exitFullscreenScrollOffset = m_webViewImpl->mainFrame()->isWebLocalFra
me() ? m_webViewImpl->mainFrame()->scrollOffset() : WebSize(); | 152 m_exitFullscreenScrollOffset = m_webViewImpl->mainFrame()->isWebLocalFra
me() ? m_webViewImpl->mainFrame()->scrollOffset() : WebSize(); |
153 m_exitFullscreenVisualViewportOffset = m_webViewImpl->visualViewportOffs
et(); | 153 m_exitFullscreenVisualViewportOffset = m_webViewImpl->visualViewportOffs
et(); |
154 } | 154 } |
155 | 155 |
156 // We need to transition to fullscreen mode. | 156 // We need to transition to fullscreen mode. |
157 WebLocalFrameImpl* frame = WebLocalFrameImpl::fromFrame(element->document().
frame()); | 157 WebLocalFrameImpl* frame = WebLocalFrameImpl::fromFrame(element->document().
frame()); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 m_webViewImpl->updateMainFrameLayoutSize(); | 209 m_webViewImpl->updateMainFrameLayoutSize(); |
210 } | 210 } |
211 | 211 |
212 DEFINE_TRACE(FullscreenController) | 212 DEFINE_TRACE(FullscreenController) |
213 { | 213 { |
214 visitor->trace(m_provisionalFullScreenElement); | 214 visitor->trace(m_provisionalFullScreenElement); |
215 visitor->trace(m_fullScreenFrame); | 215 visitor->trace(m_fullScreenFrame); |
216 } | 216 } |
217 | 217 |
218 } // namespace blink | 218 } // namespace blink |
219 | |
OLD | NEW |