Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(958)

Side by Side Diff: third_party/WebKit/Source/web/FullscreenController.cpp

Issue 2557943002: Sync requestFullscreen() and exitFullscreen() algorithms with the spec (Closed)
Patch Set: rebase Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 // Notify all local frames that we have entered fullscreen. 81 // Notify all local frames that we have entered fullscreen.
82 for (Frame* frame = m_webViewImpl->page()->mainFrame(); frame; 82 for (Frame* frame = m_webViewImpl->page()->mainFrame(); frame;
83 frame = frame->tree().traverseNext()) { 83 frame = frame->tree().traverseNext()) {
84 if (!frame->isLocalFrame()) 84 if (!frame->isLocalFrame())
85 continue; 85 continue;
86 if (Document* document = toLocalFrame(frame)->document()) { 86 if (Document* document = toLocalFrame(frame)->document()) {
87 if (Fullscreen* fullscreen = Fullscreen::fromIfExists(*document)) 87 if (Fullscreen* fullscreen = Fullscreen::fromIfExists(*document))
88 fullscreen->didEnterFullscreen(); 88 fullscreen->didEnterFullscreen();
89 } 89 }
90 } 90 }
91
92 // TODO(foolip): If the top level browsing context (main frame) ends up with
93 // no fullscreen element, exit fullscreen again to recover.
91 } 94 }
92 95
93 void FullscreenController::didExitFullscreen() { 96 void FullscreenController::didExitFullscreen() {
94 // The browser process can exit fullscreen at any time, e.g. if the user 97 // The browser process can exit fullscreen at any time, e.g. if the user
95 // presses Esc. After |Browser::EnterFullscreenModeForTab()|, 98 // presses Esc. After |Browser::EnterFullscreenModeForTab()|,
96 // |Browser::ExitFullscreenModeForTab()| will make it seem like we exit when 99 // |Browser::ExitFullscreenModeForTab()| will make it seem like we exit when
97 // not even in fullscreen. Do nothing. 100 // not even in fullscreen. Do nothing.
98 if (m_state == State::Initial) 101 if (m_state == State::Initial)
99 return; 102 return;
100 103
101 updatePageScaleConstraints(true); 104 updatePageScaleConstraints(true);
102 105
103 // Set |m_state| so that any |exitFullscreen()| calls from within
104 // |Fullscreen::didExitFullscreen()| do not call
105 // |WebFrameClient::exitFullscreen()| again.
106 // TODO(foolip): Remove this when state changes and events are synchronized
107 // with animation frames. https://crbug.com/402376
108 m_state = State::ExitingFullscreen;
109
110 // Notify all local frames that we have exited fullscreen.
111 // TODO(foolip): This should only need to notify the topmost local roots. That
112 // doesn't currently work because |Fullscreen::m_currentFullScreenElement|
113 // isn't set for the topmost document when an iframe goes fullscreen, but can
114 // be done once |m_currentFullScreenElement| is gone and all state is in the
115 // fullscreen element stack. https://crbug.com/402421
116 for (Frame* frame = m_webViewImpl->page()->mainFrame(); frame;
117 frame = frame->tree().traverseNext()) {
118 if (!frame->isLocalFrame())
119 continue;
120 if (Document* document = toLocalFrame(frame)->document()) {
121 if (Fullscreen* fullscreen = Fullscreen::fromIfExists(*document))
122 fullscreen->didExitFullscreen();
123 }
124 }
125
126 // We need to wait until style and layout are updated in order to properly 106 // We need to wait until style and layout are updated in order to properly
127 // restore scroll offsets since content may not be overflowing in the same way 107 // restore scroll offsets since content may not be overflowing in the same way
128 // until they are. 108 // until they are.
129 m_state = State::NeedsScrollAndScaleRestore; 109 m_state = State::NeedsScrollAndScaleRestore;
110
111 // Notify the topmost local frames that we have exited fullscreen.
112 // |Fullscreen::didExitFullscreen()| will take care of descendant frames.
113 for (Frame* frame = m_webViewImpl->page()->mainFrame(); frame;) {
114 Frame* nextFrame = frame->tree().traverseNext();
115
116 if (frame->isRemoteFrame()) {
117 frame = nextFrame;
118 continue;
119 }
120
121 DCHECK(frame->isLocalRoot());
122 if (Document* document = toLocalFrame(frame)->document()) {
123 if (Fullscreen* fullscreen = Fullscreen::fromIfExists(*document))
124 fullscreen->didExitFullscreen();
125 }
126
127 // Skip over all descendant frames.
128 while (nextFrame && nextFrame->tree().isDescendantOf(frame))
129 nextFrame = nextFrame->tree().traverseNext();
130 frame = nextFrame;
131 }
130 } 132 }
131 133
132 void FullscreenController::enterFullscreen(LocalFrame& frame) { 134 void FullscreenController::enterFullscreen(LocalFrame& frame) {
133 // If already fullscreen or exiting fullscreen, synchronously call 135 // If already fullscreen or exiting fullscreen, synchronously call
134 // |didEnterFullscreen()|. When exiting, the coming |didExitFullscren()| call 136 // |didEnterFullscreen()|. When exiting, the coming |didExitFullscren()| call
135 // will again notify all frames. 137 // will again notify all frames.
136 if (m_state == State::Fullscreen || m_state == State::ExitingFullscreen) { 138 if (m_state == State::Fullscreen || m_state == State::ExitingFullscreen) {
137 State oldState = m_state; 139 State oldState = m_state;
138 m_state = State::EnteringFullscreen; 140 m_state = State::EnteringFullscreen;
139 didEnterFullscreen(); 141 didEnterFullscreen();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 webFrameClient(frame).exitFullscreen(); 178 webFrameClient(frame).exitFullscreen();
177 179
178 m_state = State::ExitingFullscreen; 180 m_state = State::ExitingFullscreen;
179 } 181 }
180 182
181 void FullscreenController::fullscreenElementChanged(Element* fromElement, 183 void FullscreenController::fullscreenElementChanged(Element* fromElement,
182 Element* toElement) { 184 Element* toElement) {
183 DCHECK_NE(fromElement, toElement); 185 DCHECK_NE(fromElement, toElement);
184 186
185 if (toElement) { 187 if (toElement) {
186 DCHECK(Fullscreen::isCurrentFullScreenElement(*toElement)); 188 DCHECK(Fullscreen::isFullscreenElement(*toElement));
187 189
188 if (isHTMLVideoElement(*toElement)) { 190 if (isHTMLVideoElement(*toElement)) {
189 HTMLVideoElement& videoElement = toHTMLVideoElement(*toElement); 191 HTMLVideoElement& videoElement = toHTMLVideoElement(*toElement);
190 videoElement.didEnterFullscreen(); 192 videoElement.didEnterFullscreen();
191 193
192 // If the video uses overlay fullscreen mode, make the background 194 // If the video uses overlay fullscreen mode, make the background
193 // transparent. 195 // transparent.
194 if (videoElement.usesOverlayFullscreenVideo() && 196 if (videoElement.usesOverlayFullscreenVideo() &&
195 m_webViewImpl->layerTreeView()) { 197 m_webViewImpl->layerTreeView()) {
196 m_webViewImpl->layerTreeView()->setHasTransparentBackground(true); 198 m_webViewImpl->layerTreeView()->setHasTransparentBackground(true);
197 } 199 }
198 } 200 }
199 } 201 }
200 202
201 if (fromElement) { 203 if (fromElement) {
202 DCHECK(!Fullscreen::isCurrentFullScreenElement(*fromElement)); 204 DCHECK(!Fullscreen::isFullscreenElement(*fromElement));
203 205
204 if (isHTMLVideoElement(*fromElement)) { 206 if (isHTMLVideoElement(*fromElement)) {
205 // If the video used overlay fullscreen mode, restore the transparency. 207 // If the video used overlay fullscreen mode, restore the transparency.
206 if (m_webViewImpl->layerTreeView()) { 208 if (m_webViewImpl->layerTreeView()) {
207 m_webViewImpl->layerTreeView()->setHasTransparentBackground( 209 m_webViewImpl->layerTreeView()->setHasTransparentBackground(
208 m_webViewImpl->isTransparent()); 210 m_webViewImpl->isTransparent());
209 } 211 }
210 212
211 HTMLVideoElement& videoElement = toHTMLVideoElement(*fromElement); 213 HTMLVideoElement& videoElement = toHTMLVideoElement(*fromElement);
212 videoElement.didExitFullscreen(); 214 videoElement.didExitFullscreen();
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 // again to ensure the final constraints pick up the latest contents size. 269 // again to ensure the final constraints pick up the latest contents size.
268 m_webViewImpl->didChangeContentsSize(); 270 m_webViewImpl->didChangeContentsSize();
269 if (m_webViewImpl->mainFrameImpl() && 271 if (m_webViewImpl->mainFrameImpl() &&
270 m_webViewImpl->mainFrameImpl()->frameView()) 272 m_webViewImpl->mainFrameImpl()->frameView())
271 m_webViewImpl->mainFrameImpl()->frameView()->setNeedsLayout(); 273 m_webViewImpl->mainFrameImpl()->frameView()->setNeedsLayout();
272 274
273 m_webViewImpl->updateMainFrameLayoutSize(); 275 m_webViewImpl->updateMainFrameLayoutSize();
274 } 276 }
275 277
276 } // namespace blink 278 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/vr/VRDisplay.cpp ('k') | third_party/WebKit/Source/web/WebPluginContainerImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698