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

Side by Side Diff: third_party/WebKit/Source/core/dom/Fullscreen.cpp

Issue 2565183002: Add a nextLocalAncestor helper for Fullscreen (Closed)
Patch Set: add continue and test that would break without it 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) 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 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All
7 * rights reserved. 7 * rights reserved.
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 10 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 } 187 }
188 188
189 Event* createEvent(const AtomicString& type, EventTarget& target) { 189 Event* createEvent(const AtomicString& type, EventTarget& target) {
190 EventInit initializer; 190 EventInit initializer;
191 initializer.setBubbles(isPrefixed(type)); 191 initializer.setBubbles(isPrefixed(type));
192 Event* event = Event::create(type, initializer); 192 Event* event = Event::create(type, initializer);
193 event->setTarget(&target); 193 event->setTarget(&target);
194 return event; 194 return event;
195 } 195 }
196 196
197 // Walks the frame tree and returns the first local ancestor frame, if any.
198 LocalFrame* nextLocalAncestor(Frame& frame) {
199 Frame* parent = frame.tree().parent();
200 if (!parent)
201 return nullptr;
202 if (parent->isLocalFrame())
203 return toLocalFrame(parent);
204 return nextLocalAncestor(*parent);
205 }
206
207 // Walks the document's frame tree and returns the document of the first local
208 // ancestor frame, if any.
209 Document* nextLocalAncestor(Document& document) {
210 LocalFrame* frame = document.frame();
211 if (!frame)
212 return nullptr;
213 LocalFrame* next = nextLocalAncestor(*document.frame());
214 if (!next)
215 return nullptr;
216 DCHECK(next->document());
217 return next->document();
218 }
219
197 // Helper to walk the ancestor chain and return the Document of the topmost 220 // Helper to walk the ancestor chain and return the Document of the topmost
198 // local ancestor frame. Note that this is not the same as the topmost frame's 221 // local ancestor frame. Note that this is not the same as the topmost frame's
199 // Document, which might be unavailable in OOPIF scenarios. For example, with 222 // Document, which might be unavailable in OOPIF scenarios. For example, with
200 // OOPIFs, when called on the bottom frame's Document in a A-B-C-B hierarchy in 223 // OOPIFs, when called on the bottom frame's Document in a A-B-C-B hierarchy in
201 // process B, this will skip remote frame C and return this frame: A-[B]-C-B. 224 // process B, this will skip remote frame C and return this frame: A-[B]-C-B.
202 Document& topmostLocalAncestor(Document& document) { 225 Document& topmostLocalAncestor(Document& document) {
203 Document* topmost = &document; 226 if (Document* next = nextLocalAncestor(document))
204 Frame* frame = document.frame(); 227 return topmostLocalAncestor(*next);
205 while (frame) { 228 return document;
206 frame = frame->tree().parent();
207 if (frame && frame->isLocalFrame())
208 topmost = toLocalFrame(frame)->document();
209 }
210 return *topmost;
211 } 229 }
212 230
213 // Helper to find the browsing context container in |doc| that embeds the 231 // Helper to find the browsing context container in |doc| that embeds the
214 // |descendant| Document, possibly through multiple levels of nesting. This 232 // |descendant| Document, possibly through multiple levels of nesting. This
215 // works even in OOPIF scenarios like A-B-A, where there may be remote frames 233 // works even in OOPIF scenarios like A-B-A, where there may be remote frames
216 // in between |doc| and |descendant|. 234 // in between |doc| and |descendant|.
217 HTMLFrameOwnerElement* findContainerForDescendant(const Document& doc, 235 HTMLFrameOwnerElement* findContainerForDescendant(const Document& doc,
218 const Document& descendant) { 236 const Document& descendant) {
219 Frame* frame = descendant.frame(); 237 Frame* frame = descendant.frame();
220 while (frame->tree().parent() != doc.frame()) 238 while (frame->tree().parent() != doc.frame())
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 // 400 //
383 // For OOPIF scenarios, |docs| will only contain documents for local 401 // For OOPIF scenarios, |docs| will only contain documents for local
384 // ancestors, and remote ancestors will be processed in their 402 // ancestors, and remote ancestors will be processed in their
385 // respective processes. This preserves the spec's event firing order 403 // respective processes. This preserves the spec's event firing order
386 // for local ancestors, but not for remote ancestors. However, that 404 // for local ancestors, but not for remote ancestors. However, that
387 // difference shouldn't be observable in practice: a fullscreenchange 405 // difference shouldn't be observable in practice: a fullscreenchange
388 // event handler would need to postMessage a frame in another renderer 406 // event handler would need to postMessage a frame in another renderer
389 // process, where the message should be queued up and processed after 407 // process, where the message should be queued up and processed after
390 // the IPC that dispatches fullscreenchange. 408 // the IPC that dispatches fullscreenchange.
391 HeapDeque<Member<Document>> docs; 409 HeapDeque<Member<Document>> docs;
392 410 for (Document* doc = &document; doc; doc = nextLocalAncestor(*doc))
393 docs.prepend(&document); 411 docs.prepend(doc);
394 for (Frame* frame = document.frame()->tree().parent(); frame;
395 frame = frame->tree().parent()) {
396 if (frame->isLocalFrame())
397 docs.prepend(toLocalFrame(frame)->document());
398 }
399 412
400 // 4. For each document in docs, run these substeps: 413 // 4. For each document in docs, run these substeps:
401 HeapDeque<Member<Document>>::iterator current = docs.begin(), 414 HeapDeque<Member<Document>>::iterator current = docs.begin(),
402 following = docs.begin(); 415 following = docs.begin();
403 416
404 do { 417 do {
405 ++following; 418 ++following;
406 419
407 // 1. Let following document be the document after document in docs, or 420 // 1. Let following document be the document after document in docs, or
408 // null if there is no such document. 421 // null if there is no such document.
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 // 3. If doc's fullscreen element stack is empty and doc's browsing context 554 // 3. If doc's fullscreen element stack is empty and doc's browsing context
542 // has a browsing context container, set doc to that browsing context 555 // has a browsing context container, set doc to that browsing context
543 // container's node document. 556 // container's node document.
544 // 557 //
545 // OOPIF: If browsing context container's document is in another 558 // OOPIF: If browsing context container's document is in another
546 // process, keep moving up the ancestor chain and looking for a 559 // process, keep moving up the ancestor chain and looking for a
547 // browsing context container with a local document. 560 // browsing context container with a local document.
548 // TODO(alexmos): Deal with nested fullscreen cases, see 561 // TODO(alexmos): Deal with nested fullscreen cases, see
549 // https://crbug.com/617369. 562 // https://crbug.com/617369.
550 if (!newTop) { 563 if (!newTop) {
551 Frame* frame = currentDoc->frame()->tree().parent(); 564 currentDoc = nextLocalAncestor(*currentDoc);
552 while (frame && frame->isRemoteFrame()) 565 continue;
553 frame = frame->tree().parent();
554 if (frame) {
555 currentDoc = toLocalFrame(frame)->document();
556 continue;
557 }
558 } 566 }
559 567
560 // 4. Otherwise, set doc to null. 568 // 4. Otherwise, set doc to null.
561 currentDoc = nullptr; 569 currentDoc = nullptr;
562 } 570 }
563 571
564 // 6. Return, and run the remaining steps asynchronously. 572 // 6. Return, and run the remaining steps asynchronously.
565 // 7. Optionally, perform some animation. 573 // 7. Optionally, perform some animation.
566 574
567 // Only exit fullscreen mode if the fullscreen element stack is empty. 575 // Only exit fullscreen mode if the fullscreen element stack is empty.
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 DEFINE_TRACE(Fullscreen) { 826 DEFINE_TRACE(Fullscreen) {
819 visitor->trace(m_pendingFullscreenElement); 827 visitor->trace(m_pendingFullscreenElement);
820 visitor->trace(m_fullscreenElementStack); 828 visitor->trace(m_fullscreenElementStack);
821 visitor->trace(m_currentFullScreenElement); 829 visitor->trace(m_currentFullScreenElement);
822 visitor->trace(m_eventQueue); 830 visitor->trace(m_eventQueue);
823 Supplement<Document>::trace(visitor); 831 Supplement<Document>::trace(visitor);
824 ContextLifecycleObserver::trace(visitor); 832 ContextLifecycleObserver::trace(visitor);
825 } 833 }
826 834
827 } // namespace blink 835 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/imported/wpt/fullscreen/api/element-request-fullscreen-and-exit-iframe-manual.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698