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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 fullscreen->didExitFullScreenForElement(0); | 130 fullscreen->didExitFullScreenForElement(0); |
131 } | 131 } |
132 } | 132 } |
133 } | 133 } |
134 | 134 |
135 m_fullScreenFrame.clear(); | 135 m_fullScreenFrame.clear(); |
136 } | 136 } |
137 | 137 |
138 void FullscreenController::enterFullScreenForElement(Element* element) | 138 void FullscreenController::enterFullScreenForElement(Element* element) |
139 { | 139 { |
140 // TODO(dsinclair): This should not be needed because we addToTopLayer | |
141 // in Fullscreen::pushFullscreenElementStack but, the WebView code doesn't | |
142 // call Fullscreen::requestFullscreen() and, instead, just enters and | |
143 // exists itself. This should be unified so there is one way to go | |
144 // fullscreen. crbug.com/538158 | |
145 element->document().addToTopLayer(element); | |
146 | |
147 // We are already transitioning to fullscreen for a different element. | 140 // We are already transitioning to fullscreen for a different element. |
148 if (m_provisionalFullScreenElement) { | 141 if (m_provisionalFullScreenElement) { |
149 m_provisionalFullScreenElement = element; | 142 m_provisionalFullScreenElement = element; |
150 return; | 143 return; |
151 } | 144 } |
152 | 145 |
153 // We are already in fullscreen mode. | 146 // We are already in fullscreen mode. |
154 if (m_fullScreenFrame) { | 147 if (m_fullScreenFrame) { |
155 m_provisionalFullScreenElement = element; | 148 m_provisionalFullScreenElement = element; |
156 didEnterFullScreen(); | 149 didEnterFullScreen(); |
157 return; | 150 return; |
158 } | 151 } |
159 | 152 |
160 // We need to transition to fullscreen mode. | 153 // We need to transition to fullscreen mode. |
161 WebLocalFrameImpl* frame = WebLocalFrameImpl::fromFrame(element->document().
frame()); | 154 WebLocalFrameImpl* frame = WebLocalFrameImpl::fromFrame(element->document().
frame()); |
162 if (frame && frame->client()) { | 155 if (frame && frame->client()) { |
163 frame->client()->enterFullscreen(); | 156 frame->client()->enterFullscreen(); |
164 m_provisionalFullScreenElement = element; | 157 m_provisionalFullScreenElement = element; |
165 } | 158 } |
166 } | 159 } |
167 | 160 |
168 void FullscreenController::exitFullScreenForElement(Element* element) | 161 void FullscreenController::exitFullScreenForElement(Element* element) |
169 { | 162 { |
170 ASSERT(element); | 163 ASSERT(element); |
171 | 164 |
172 // TODO(dsinclair): This should not be needed because we addToTopLayer | |
173 // in Fullscreen::popFullscreenElementStack but, the WebView code doesn't | |
174 // call Fullscreen::requestFullscreen() and, instead, just enters and | |
175 // exists itself. This should be unified so there is one way to go | |
176 // fullscreen. crbug.com/538158 | |
177 element->document().removeFromTopLayer(element); | |
178 | |
179 // The client is exiting full screen, so don't send a notification. | 165 // The client is exiting full screen, so don't send a notification. |
180 if (m_isCancelingFullScreen) | 166 if (m_isCancelingFullScreen) |
181 return; | 167 return; |
182 | 168 |
183 WebLocalFrameImpl* frame = WebLocalFrameImpl::fromFrame(element->document().
frame()); | 169 WebLocalFrameImpl* frame = WebLocalFrameImpl::fromFrame(element->document().
frame()); |
184 if (frame && frame->client()) | 170 if (frame && frame->client()) |
185 frame->client()->exitFullscreen(); | 171 frame->client()->exitFullscreen(); |
186 } | 172 } |
187 | 173 |
188 void FullscreenController::updateSize() | 174 void FullscreenController::updateSize() |
189 { | 175 { |
190 if (!isFullscreen()) | 176 if (!isFullscreen()) |
191 return; | 177 return; |
192 | 178 |
193 updatePageScaleConstraints(false); | 179 updatePageScaleConstraints(false); |
194 | 180 |
195 Document* document = m_fullScreenFrame->document(); | 181 LayoutFullScreen* layoutObject = Fullscreen::from(*m_fullScreenFrame->docume
nt()).fullScreenLayoutObject(); |
196 if (Element* fullscreenElement = Fullscreen::currentFullScreenElementFrom(*d
ocument)) | 182 if (layoutObject) |
197 Fullscreen::from(fullscreenElement->document()).didUpdateSize(*fullscree
nElement); | 183 layoutObject->updateStyle(); |
198 } | 184 } |
199 | 185 |
200 void FullscreenController::updatePageScaleConstraints(bool removeConstraints) | 186 void FullscreenController::updatePageScaleConstraints(bool removeConstraints) |
201 { | 187 { |
202 PageScaleConstraints fullscreenConstraints; | 188 PageScaleConstraints fullscreenConstraints; |
203 if (!removeConstraints) { | 189 if (!removeConstraints) { |
204 fullscreenConstraints = PageScaleConstraints(1.0, 1.0, 1.0); | 190 fullscreenConstraints = PageScaleConstraints(1.0, 1.0, 1.0); |
205 fullscreenConstraints.layoutSize = IntSize(m_webViewImpl->size()); | 191 fullscreenConstraints.layoutSize = IntSize(m_webViewImpl->size()); |
206 } | 192 } |
207 m_webViewImpl->pageScaleConstraintsSet().setFullscreenConstraints(fullscreen
Constraints); | 193 m_webViewImpl->pageScaleConstraintsSet().setFullscreenConstraints(fullscreen
Constraints); |
208 m_webViewImpl->pageScaleConstraintsSet().computeFinalConstraints(); | 194 m_webViewImpl->pageScaleConstraintsSet().computeFinalConstraints(); |
209 m_webViewImpl->updateMainFrameLayoutSize(); | 195 m_webViewImpl->updateMainFrameLayoutSize(); |
210 } | 196 } |
211 | 197 |
212 DEFINE_TRACE(FullscreenController) | 198 DEFINE_TRACE(FullscreenController) |
213 { | 199 { |
214 visitor->trace(m_provisionalFullScreenElement); | 200 visitor->trace(m_provisionalFullScreenElement); |
215 visitor->trace(m_fullScreenFrame); | 201 visitor->trace(m_fullScreenFrame); |
216 } | 202 } |
217 | 203 |
218 } // namespace blink | 204 } // namespace blink |
219 | 205 |
OLD | NEW |