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

Side by Side Diff: Source/core/dom/FullscreenElementStack.cpp

Issue 462103002: Extract "fullscreen element ready check" from requestFullscreen() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix test Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/FullscreenElementStack.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 8 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
9 * Copyright (C) 2013 Google Inc. All rights reserved. 9 * Copyright (C) 2013 Google Inc. All rights reserved.
10 * 10 *
(...skipping 17 matching lines...) Expand all
28 #include "config.h" 28 #include "config.h"
29 #include "core/dom/FullscreenElementStack.h" 29 #include "core/dom/FullscreenElementStack.h"
30 30
31 #include "core/HTMLNames.h" 31 #include "core/HTMLNames.h"
32 #include "core/dom/Document.h" 32 #include "core/dom/Document.h"
33 #include "core/events/Event.h" 33 #include "core/events/Event.h"
34 #include "core/frame/FrameHost.h" 34 #include "core/frame/FrameHost.h"
35 #include "core/frame/LocalFrame.h" 35 #include "core/frame/LocalFrame.h"
36 #include "core/frame/Settings.h" 36 #include "core/frame/Settings.h"
37 #include "core/frame/UseCounter.h" 37 #include "core/frame/UseCounter.h"
38 #include "core/html/HTMLFrameOwnerElement.h" 38 #include "core/html/HTMLIFrameElement.h"
39 #include "core/html/HTMLMediaElement.h" 39 #include "core/html/HTMLMediaElement.h"
40 #include "core/page/Chrome.h" 40 #include "core/page/Chrome.h"
41 #include "core/page/ChromeClient.h" 41 #include "core/page/ChromeClient.h"
42 #include "core/rendering/RenderFullScreen.h" 42 #include "core/rendering/RenderFullScreen.h"
43 #include "platform/UserGestureIndicator.h" 43 #include "platform/UserGestureIndicator.h"
44 44
45 namespace blink { 45 namespace blink {
46 46
47 using namespace HTMLNames; 47 using namespace HTMLNames;
48 48
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 #if !ENABLE(OILPAN) 162 #if !ENABLE(OILPAN)
163 void FullscreenElementStack::documentWasDisposed() 163 void FullscreenElementStack::documentWasDisposed()
164 { 164 {
165 // NOTE: the context dispose phase is not supported in oilpan. Please 165 // NOTE: the context dispose phase is not supported in oilpan. Please
166 // consider using the detach phase instead. 166 // consider using the detach phase instead.
167 m_fullScreenElement = nullptr; 167 m_fullScreenElement = nullptr;
168 m_fullScreenElementStack.clear(); 168 m_fullScreenElementStack.clear();
169 } 169 }
170 #endif 170 #endif
171 171
172 bool FullscreenElementStack::elementReady(Element& element, RequestType requestT ype)
173 {
174 // A fullscreen element ready check for an element returns true if all of th e following are
175 // true, and false otherwise:
176
177 // element is in a document.
178 if (!element.inDocument())
179 return false;
180
181 // element's node document's fullscreen enabled flag is set.
182 if (!fullscreenIsAllowedForAllOwners(element.document())) {
183 if (requestType == PrefixedVideoRequest)
184 UseCounter::count(element.document(), UseCounter::VideoFullscreenAll owedExemption);
185 else
186 return false;
187 }
188
189 // element's node document fullscreen element stack is either empty or its t op element is an
190 // ancestor of element.
191 if (Element* lastElementOnStack = fullscreenElementFrom(element.document())) {
192 if (!element.isDescendantOf(lastElementOnStack)) {
193 if (requestType == PrefixedMozillaRequest || requestType == Prefixed MozillaAllowKeyboardInputRequest)
194 UseCounter::count(element.document(), UseCounter::LegacyFullScre enErrorExemption);
195 else
196 return false;
197 }
198 }
199
200 // element has no ancestor element whose local name is iframe and namespace is the HTML
201 // namespace.
202 if (Traversal<HTMLIFrameElement>::firstAncestor(element))
203 return false;
204
205 return true;
206 }
207
172 void FullscreenElementStack::requestFullscreen(Element& element, RequestType req uestType) 208 void FullscreenElementStack::requestFullscreen(Element& element, RequestType req uestType)
173 { 209 {
174 // Ignore this request if the document is not in a live frame. 210 // Ignore this request if the document is not in a live frame.
175 if (!document()->isActive()) 211 if (!document()->isActive())
176 return; 212 return;
177 213
178 // The Mozilla Full Screen API <https://wiki.mozilla.org/Gecko:FullScreenAPI > has different requirements
179 // for full screen mode, and do not have the concept of a full screen elemen t stack.
180 bool inLegacyMozillaMode = requestType == PrefixedMozillaRequest || requestT ype == PrefixedMozillaAllowKeyboardInputRequest;
181
182 do { 214 do {
183 // 1. If any of the following conditions are true, terminate these steps and queue a task to fire 215 // 1. If any of the following conditions are true, terminate these steps and queue a task to fire
184 // an event named fullscreenerror with its bubbles attribute set to true on the context object's 216 // an event named fullscreenerror with its bubbles attribute set to true on the context object's
185 // node document: 217 // node document:
186 218
187 // The context object is not in a document. 219 // The fullscreen element ready check returns false.
188 if (!element.inDocument()) 220 if (!elementReady(element, requestType))
189 break; 221 break;
190 222
191 // The context object's node document, or an ancestor browsing context's document does not have
192 // the fullscreen enabled flag set.
193 if (!fullscreenIsAllowedForAllOwners(element.document())) {
194 if (requestType == PrefixedVideoRequest)
195 UseCounter::count(element.document(), UseCounter::VideoFullscree nAllowedExemption);
196 else
197 break;
198 }
199
200 // The context object's node document fullscreen element stack is not em pty and its top element
201 // is not an ancestor of the context object. (NOTE: Ignore this requirem ent if the request was
202 // made via the legacy Mozilla-style API.)
203 if (Element* lastElementOnStack = fullscreenElement()) {
204 if (!element.isDescendantOf(lastElementOnStack)) {
205 if (inLegacyMozillaMode)
206 UseCounter::count(element.document(), UseCounter::LegacyFull ScreenErrorExemption);
207 else
208 break;
209 }
210 }
211
212 // A descendant browsing context's document has a non-empty fullscreen e lement stack.
213 bool descendentHasNonEmptyStack = false;
214 for (Frame* descendant = document()->frame() ? document()->frame()->tree ().traverseNext() : 0; descendant; descendant = descendant->tree().traverseNext( )) {
215 if (!descendant->isLocalFrame())
216 continue;
217 ASSERT(toLocalFrame(descendant)->document());
218 if (fullscreenElementFrom(*toLocalFrame(descendant)->document())) {
219 descendentHasNonEmptyStack = true;
220 break;
221 }
222 }
223 if (descendentHasNonEmptyStack) {
224 if (inLegacyMozillaMode)
225 UseCounter::count(element.document(), UseCounter::LegacyFullScre enErrorExemption);
226 else
227 break;
228 }
229
230 // This algorithm is not allowed to show a pop-up: 223 // This algorithm is not allowed to show a pop-up:
231 // An algorithm is allowed to show a pop-up if, in the task in which t he algorithm is running, either: 224 // An algorithm is allowed to show a pop-up if, in the task in which t he algorithm is running, either:
232 // - an activation behavior is currently being processed whose click e vent was trusted, or 225 // - an activation behavior is currently being processed whose click e vent was trusted, or
233 // - the event listener for a trusted click event is being handled. 226 // - the event listener for a trusted click event is being handled.
234 if (!UserGestureIndicator::processingUserGesture()) 227 if (!UserGestureIndicator::processingUserGesture())
235 break; 228 break;
236 229
237 // Fullscreen is not supported. 230 // Fullscreen is not supported.
238 if (!fullscreenIsSupported(element.document(), element)) 231 if (!fullscreenIsSupported(element.document(), element))
239 break; 232 break;
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 void FullscreenElementStack::trace(Visitor* visitor) 606 void FullscreenElementStack::trace(Visitor* visitor)
614 { 607 {
615 visitor->trace(m_fullScreenElement); 608 visitor->trace(m_fullScreenElement);
616 visitor->trace(m_fullScreenElementStack); 609 visitor->trace(m_fullScreenElementStack);
617 visitor->trace(m_fullScreenRenderer); 610 visitor->trace(m_fullScreenRenderer);
618 visitor->trace(m_eventQueue); 611 visitor->trace(m_eventQueue);
619 DocumentSupplement::trace(visitor); 612 DocumentSupplement::trace(visitor);
620 } 613 }
621 614
622 } // namespace blink 615 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/dom/FullscreenElementStack.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698