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

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

Issue 2855843002: Reland "Sync requestFullscreen() and exitFullscreen() algorithms with the spec" (Closed)
Patch Set: Reland "Sync requestFullscreen() and exitFullscreen() algorithms with the spec" Created 3 years, 6 months 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 // Notify all local frames that we have entered fullscreen. 82 // Notify all local frames that we have entered fullscreen.
83 for (Frame* frame = web_view_base_->GetPage()->MainFrame(); frame; 83 for (Frame* frame = web_view_base_->GetPage()->MainFrame(); frame;
84 frame = frame->Tree().TraverseNext()) { 84 frame = frame->Tree().TraverseNext()) {
85 if (!frame->IsLocalFrame()) 85 if (!frame->IsLocalFrame())
86 continue; 86 continue;
87 if (Document* document = ToLocalFrame(frame)->GetDocument()) { 87 if (Document* document = ToLocalFrame(frame)->GetDocument()) {
88 if (Fullscreen* fullscreen = Fullscreen::FromIfExists(*document)) 88 if (Fullscreen* fullscreen = Fullscreen::FromIfExists(*document))
89 fullscreen->DidEnterFullscreen(); 89 fullscreen->DidEnterFullscreen();
90 } 90 }
91 } 91 }
92
93 // TODO(foolip): If the top level browsing context (main frame) ends up with
94 // no fullscreen element, exit fullscreen again to recover.
92 } 95 }
93 96
94 void FullscreenController::DidExitFullscreen() { 97 void FullscreenController::DidExitFullscreen() {
95 // The browser process can exit fullscreen at any time, e.g. if the user 98 // The browser process can exit fullscreen at any time, e.g. if the user
96 // presses Esc. After |Browser::EnterFullscreenModeForTab()|, 99 // presses Esc. After |Browser::EnterFullscreenModeForTab()|,
97 // |Browser::ExitFullscreenModeForTab()| will make it seem like we exit when 100 // |Browser::ExitFullscreenModeForTab()| will make it seem like we exit when
98 // not even in fullscreen. Do nothing. 101 // not even in fullscreen. Do nothing.
99 if (state_ == State::kInitial) 102 if (state_ == State::kInitial)
100 return; 103 return;
101 104
102 UpdatePageScaleConstraints(true); 105 UpdatePageScaleConstraints(true);
103 106
104 // Set |m_state| so that any |exitFullscreen()| calls from within
105 // |Fullscreen::didExitFullscreen()| do not call
106 // |WebFrameClient::exitFullscreen()| again.
107 // TODO(foolip): Remove this when state changes and events are synchronized
108 // with animation frames. https://crbug.com/402376
109 state_ = State::kExitingFullscreen;
110
111 // Notify all local frames that we have exited fullscreen.
112 // TODO(foolip): This should only need to notify the topmost local roots. That
113 // doesn't currently work because |Fullscreen::m_currentFullScreenElement|
114 // isn't set for the topmost document when an iframe goes fullscreen, but can
115 // be done once |m_currentFullScreenElement| is gone and all state is in the
116 // fullscreen element stack. https://crbug.com/402421
117 for (Frame* frame = web_view_base_->GetPage()->MainFrame(); frame;
118 frame = frame->Tree().TraverseNext()) {
119 if (!frame->IsLocalFrame())
120 continue;
121 if (Document* document = ToLocalFrame(frame)->GetDocument()) {
122 if (Fullscreen* fullscreen = Fullscreen::FromIfExists(*document))
123 fullscreen->DidExitFullscreen();
124 }
125 }
126
127 // We need to wait until style and layout are updated in order to properly 107 // We need to wait until style and layout are updated in order to properly
128 // restore scroll offsets since content may not be overflowing in the same way 108 // restore scroll offsets since content may not be overflowing in the same way
129 // until they are. 109 // until they are.
130 state_ = State::kNeedsScrollAndScaleRestore; 110 state_ = State::kNeedsScrollAndScaleRestore;
111
112 // Notify the topmost local frames that we have exited fullscreen.
113 // |Fullscreen::didExitFullscreen()| will take care of descendant frames.
114 for (Frame* frame = web_view_base_->GetPage()->MainFrame(); frame;) {
115 Frame* next_frame = frame->Tree().TraverseNext();
116
117 if (frame->IsRemoteFrame()) {
118 frame = next_frame;
119 continue;
120 }
121
122 DCHECK(frame->IsLocalRoot());
123 if (Document* document = ToLocalFrame(frame)->GetDocument()) {
124 if (Fullscreen* fullscreen = Fullscreen::FromIfExists(*document))
125 fullscreen->DidExitFullscreen();
126 }
127
128 // Skip over all descendant frames.
129 while (next_frame && next_frame->Tree().IsDescendantOf(frame))
130 next_frame = next_frame->Tree().TraverseNext();
131 frame = next_frame;
132 }
131 } 133 }
132 134
133 void FullscreenController::EnterFullscreen(LocalFrame& frame) { 135 void FullscreenController::EnterFullscreen(LocalFrame& frame) {
134 // If already fullscreen or exiting fullscreen, synchronously call 136 // If already fullscreen or exiting fullscreen, synchronously call
135 // |didEnterFullscreen()|. When exiting, the coming |didExitFullscren()| call 137 // |didEnterFullscreen()|. When exiting, the coming |didExitFullscren()| call
136 // will again notify all frames. 138 // will again notify all frames.
137 if (state_ == State::kFullscreen || state_ == State::kExitingFullscreen) { 139 if (state_ == State::kFullscreen || state_ == State::kExitingFullscreen) {
138 State old_state = state_; 140 State old_state = state_;
139 state_ = State::kEnteringFullscreen; 141 state_ = State::kEnteringFullscreen;
140 DidEnterFullscreen(); 142 DidEnterFullscreen();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 188
187 void FullscreenController::FullscreenElementChanged(Element* from_element, 189 void FullscreenController::FullscreenElementChanged(Element* from_element,
188 Element* to_element) { 190 Element* to_element) {
189 DCHECK_NE(from_element, to_element); 191 DCHECK_NE(from_element, to_element);
190 192
191 // We only override the WebView's background color for overlay fullscreen 193 // We only override the WebView's background color for overlay fullscreen
192 // video elements, so have to restore the override when the element changes. 194 // video elements, so have to restore the override when the element changes.
193 RestoreBackgroundColorOverride(); 195 RestoreBackgroundColorOverride();
194 196
195 if (to_element) { 197 if (to_element) {
196 DCHECK(Fullscreen::IsCurrentFullScreenElement(*to_element)); 198 DCHECK(Fullscreen::IsFullscreenElement(*to_element));
197 199
198 if (isHTMLVideoElement(*to_element)) { 200 if (isHTMLVideoElement(*to_element)) {
199 HTMLVideoElement& video_element = toHTMLVideoElement(*to_element); 201 HTMLVideoElement& video_element = toHTMLVideoElement(*to_element);
200 video_element.DidEnterFullscreen(); 202 video_element.DidEnterFullscreen();
201 203
202 // If the video uses overlay fullscreen mode, make the background 204 // If the video uses overlay fullscreen mode, make the background
203 // transparent. 205 // transparent.
204 if (video_element.UsesOverlayFullscreenVideo()) 206 if (video_element.UsesOverlayFullscreenVideo())
205 web_view_base_->SetBackgroundColorOverride(Color::kTransparent); 207 web_view_base_->SetBackgroundColorOverride(Color::kTransparent);
206 } 208 }
207 } 209 }
208 210
209 if (from_element) { 211 if (from_element) {
210 DCHECK(!Fullscreen::IsCurrentFullScreenElement(*from_element)); 212 DCHECK(!Fullscreen::IsFullscreenElement(*from_element));
211 213
212 if (isHTMLVideoElement(*from_element)) { 214 if (isHTMLVideoElement(*from_element)) {
213 HTMLVideoElement& video_element = toHTMLVideoElement(*from_element); 215 HTMLVideoElement& video_element = toHTMLVideoElement(*from_element);
214 video_element.DidExitFullscreen(); 216 video_element.DidExitFullscreen();
215 } 217 }
216 } 218 }
217 } 219 }
218 220
219 void FullscreenController::RestoreBackgroundColorOverride() { 221 void FullscreenController::RestoreBackgroundColorOverride() {
220 if (web_view_base_->BackgroundColorOverrideEnabled() != 222 if (web_view_base_->BackgroundColorOverrideEnabled() !=
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 // again to ensure the final constraints pick up the latest contents size. 288 // again to ensure the final constraints pick up the latest contents size.
287 web_view_base_->DidChangeContentsSize(); 289 web_view_base_->DidChangeContentsSize();
288 if (web_view_base_->MainFrameImpl() && 290 if (web_view_base_->MainFrameImpl() &&
289 web_view_base_->MainFrameImpl()->GetFrameView()) 291 web_view_base_->MainFrameImpl()->GetFrameView())
290 web_view_base_->MainFrameImpl()->GetFrameView()->SetNeedsLayout(); 292 web_view_base_->MainFrameImpl()->GetFrameView()->SetNeedsLayout();
291 293
292 web_view_base_->UpdateMainFrameLayoutSize(); 294 web_view_base_->UpdateMainFrameLayoutSize();
293 } 295 }
294 296
295 } // namespace blink 297 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/FullscreenController.h ('k') | third_party/WebKit/Source/web/WebPluginContainerImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698