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

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

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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) 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 } 113 }
114 114
115 return true; 115 return true;
116 } 116 }
117 117
118 static bool isPrefixed(const AtomicString& type) 118 static bool isPrefixed(const AtomicString& type)
119 { 119 {
120 return type == EventTypeNames::webkitfullscreenchange || type == EventTypeNa mes::webkitfullscreenerror; 120 return type == EventTypeNames::webkitfullscreenchange || type == EventTypeNa mes::webkitfullscreenerror;
121 } 121 }
122 122
123 static PassRefPtrWillBeRawPtr<Event> createEvent(const AtomicString& type, Event Target& target) 123 static RawPtr<Event> createEvent(const AtomicString& type, EventTarget& target)
124 { 124 {
125 EventInit initializer; 125 EventInit initializer;
126 initializer.setBubbles(isPrefixed(type)); 126 initializer.setBubbles(isPrefixed(type));
127 RefPtrWillBeRawPtr<Event> event = Event::create(type, initializer); 127 RawPtr<Event> event = Event::create(type, initializer);
128 event->setTarget(&target); 128 event->setTarget(&target);
129 return event; 129 return event;
130 } 130 }
131 131
132 const char* Fullscreen::supplementName() 132 const char* Fullscreen::supplementName()
133 { 133 {
134 return "Fullscreen"; 134 return "Fullscreen";
135 } 135 }
136 136
137 Fullscreen& Fullscreen::from(Document& document) 137 Fullscreen& Fullscreen::from(Document& document)
138 { 138 {
139 Fullscreen* fullscreen = fromIfExists(document); 139 Fullscreen* fullscreen = fromIfExists(document);
140 if (!fullscreen) { 140 if (!fullscreen) {
141 fullscreen = new Fullscreen(document); 141 fullscreen = new Fullscreen(document);
142 WillBeHeapSupplement<Document>::provideTo(document, supplementName(), ad optPtrWillBeNoop(fullscreen)); 142 HeapSupplement<Document>::provideTo(document, supplementName(), adoptPtr WillBeNoop(fullscreen));
143 } 143 }
144 144
145 return *fullscreen; 145 return *fullscreen;
146 } 146 }
147 147
148 Fullscreen* Fullscreen::fromIfExistsSlow(Document& document) 148 Fullscreen* Fullscreen::fromIfExistsSlow(Document& document)
149 { 149 {
150 return static_cast<Fullscreen*>(WillBeHeapSupplement<Document>::from(documen t, supplementName())); 150 return static_cast<Fullscreen*>(HeapSupplement<Document>::from(document, sup plementName()));
151 } 151 }
152 152
153 Element* Fullscreen::fullscreenElementFrom(Document& document) 153 Element* Fullscreen::fullscreenElementFrom(Document& document)
154 { 154 {
155 if (Fullscreen* found = fromIfExists(document)) 155 if (Fullscreen* found = fromIfExists(document))
156 return found->fullscreenElement(); 156 return found->fullscreenElement();
157 return 0; 157 return 0;
158 } 158 }
159 159
160 Element* Fullscreen::currentFullScreenElementFrom(Document& document) 160 Element* Fullscreen::currentFullScreenElementFrom(Document& document)
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 } 249 }
250 250
251 // Fullscreen is not supported. 251 // Fullscreen is not supported.
252 if (!fullscreenIsSupported(element.document())) 252 if (!fullscreenIsSupported(element.document()))
253 break; 253 break;
254 254
255 // 2. Let doc be element's node document. (i.e. "this") 255 // 2. Let doc be element's node document. (i.e. "this")
256 Document* currentDoc = document(); 256 Document* currentDoc = document();
257 257
258 // 3. Let docs be all doc's ancestor browsing context's documents (if an y) and doc. 258 // 3. Let docs be all doc's ancestor browsing context's documents (if an y) and doc.
259 WillBeHeapDeque<RawPtrWillBeMember<Document>> docs; 259 HeapDeque<Member<Document>> docs;
260 260
261 do { 261 do {
262 docs.prepend(currentDoc); 262 docs.prepend(currentDoc);
263 currentDoc = currentDoc->ownerElement() ? &currentDoc->ownerElement( )->document() : nullptr; 263 currentDoc = currentDoc->ownerElement() ? &currentDoc->ownerElement( )->document() : nullptr;
264 } while (currentDoc); 264 } while (currentDoc);
265 265
266 // 4. For each document in docs, run these substeps: 266 // 4. For each document in docs, run these substeps:
267 WillBeHeapDeque<RawPtrWillBeMember<Document>>::iterator current = docs.b egin(), following = docs.begin(); 267 HeapDeque<Member<Document>>::iterator current = docs.begin(), following = docs.begin();
268 268
269 do { 269 do {
270 ++following; 270 ++following;
271 271
272 // 1. Let following document be the document after document in docs, or null if there is no 272 // 1. Let following document be the document after document in docs, or null if there is no
273 // such document. 273 // such document.
274 Document* currentDoc = *current; 274 Document* currentDoc = *current;
275 Document* followingDoc = following != docs.end() ? *following : null ptr; 275 Document* followingDoc = following != docs.end() ? *following : null ptr;
276 276
277 // 2. If following document is null, push context object on document 's fullscreen element 277 // 2. If following document is null, push context object on document 's fullscreen element
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 if (!currentDoc->isActive()) 338 if (!currentDoc->isActive())
339 return; 339 return;
340 340
341 // 2. If doc's fullscreen element stack is empty, terminate these steps. 341 // 2. If doc's fullscreen element stack is empty, terminate these steps.
342 if (m_fullScreenElementStack.isEmpty()) 342 if (m_fullScreenElementStack.isEmpty())
343 return; 343 return;
344 344
345 // 3. Let descendants be all the doc's descendant browsing context's documen ts with a non-empty fullscreen 345 // 3. Let descendants be all the doc's descendant browsing context's documen ts with a non-empty fullscreen
346 // element stack (if any), ordered so that the child of the doc is last and the document furthest 346 // element stack (if any), ordered so that the child of the doc is last and the document furthest
347 // away from the doc is first. 347 // away from the doc is first.
348 WillBeHeapDeque<RefPtrWillBeMember<Document>> descendants; 348 HeapDeque<Member<Document>> descendants;
349 for (Frame* descendant = document()->frame() ? document()->frame()->tree().t raverseNext() : 0; descendant; descendant = descendant->tree().traverseNext()) { 349 for (Frame* descendant = document()->frame() ? document()->frame()->tree().t raverseNext() : 0; descendant; descendant = descendant->tree().traverseNext()) {
350 if (!descendant->isLocalFrame()) 350 if (!descendant->isLocalFrame())
351 continue; 351 continue;
352 ASSERT(toLocalFrame(descendant)->document()); 352 ASSERT(toLocalFrame(descendant)->document());
353 if (fullscreenElementFrom(*toLocalFrame(descendant)->document())) 353 if (fullscreenElementFrom(*toLocalFrame(descendant)->document()))
354 descendants.prepend(toLocalFrame(descendant)->document()); 354 descendants.prepend(toLocalFrame(descendant)->document());
355 } 355 }
356 356
357 // 4. For each descendant in descendants, empty descendant's fullscreen elem ent stack, and queue a 357 // 4. For each descendant in descendants, empty descendant's fullscreen elem ent stack, and queue a
358 // task to fire an event named fullscreenchange with its bubbles attribute s et to true on descendant. 358 // task to fire an event named fullscreenchange with its bubbles attribute s et to true on descendant.
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 m_fullScreenLayoutObject = layoutObject; 521 m_fullScreenLayoutObject = layoutObject;
522 } 522 }
523 523
524 void Fullscreen::fullScreenLayoutObjectDestroyed() 524 void Fullscreen::fullScreenLayoutObjectDestroyed()
525 { 525 {
526 m_fullScreenLayoutObject = nullptr; 526 m_fullScreenLayoutObject = nullptr;
527 } 527 }
528 528
529 void Fullscreen::enqueueChangeEvent(Document& document, RequestType requestType) 529 void Fullscreen::enqueueChangeEvent(Document& document, RequestType requestType)
530 { 530 {
531 RefPtrWillBeRawPtr<Event> event; 531 RawPtr<Event> event;
532 if (requestType == UnprefixedRequest) { 532 if (requestType == UnprefixedRequest) {
533 event = createEvent(EventTypeNames::fullscreenchange, document); 533 event = createEvent(EventTypeNames::fullscreenchange, document);
534 } else { 534 } else {
535 ASSERT(document.hasFullscreenSupplement()); 535 ASSERT(document.hasFullscreenSupplement());
536 Fullscreen& fullscreen = from(document); 536 Fullscreen& fullscreen = from(document);
537 EventTarget* target = fullscreen.fullscreenElement(); 537 EventTarget* target = fullscreen.fullscreenElement();
538 if (!target) 538 if (!target)
539 target = fullscreen.webkitCurrentFullScreenElement(); 539 target = fullscreen.webkitCurrentFullScreenElement();
540 if (!target) 540 if (!target)
541 target = &document; 541 target = &document;
542 event = createEvent(EventTypeNames::webkitfullscreenchange, *target); 542 event = createEvent(EventTypeNames::webkitfullscreenchange, *target);
543 } 543 }
544 m_eventQueue.append(event); 544 m_eventQueue.append(event);
545 // NOTE: The timer is started in didEnterFullScreenForElement/didExitFullScr eenForElement. 545 // NOTE: The timer is started in didEnterFullScreenForElement/didExitFullScr eenForElement.
546 } 546 }
547 547
548 void Fullscreen::enqueueErrorEvent(Element& element, RequestType requestType) 548 void Fullscreen::enqueueErrorEvent(Element& element, RequestType requestType)
549 { 549 {
550 RefPtrWillBeRawPtr<Event> event; 550 RawPtr<Event> event;
551 if (requestType == UnprefixedRequest) 551 if (requestType == UnprefixedRequest)
552 event = createEvent(EventTypeNames::fullscreenerror, element.document()) ; 552 event = createEvent(EventTypeNames::fullscreenerror, element.document()) ;
553 else 553 else
554 event = createEvent(EventTypeNames::webkitfullscreenerror, element); 554 event = createEvent(EventTypeNames::webkitfullscreenerror, element);
555 m_eventQueue.append(event); 555 m_eventQueue.append(event);
556 m_eventQueueTimer.startOneShot(0, BLINK_FROM_HERE); 556 m_eventQueueTimer.startOneShot(0, BLINK_FROM_HERE);
557 } 557 }
558 558
559 void Fullscreen::eventQueueTimerFired(Timer<Fullscreen>*) 559 void Fullscreen::eventQueueTimerFired(Timer<Fullscreen>*)
560 { 560 {
561 // Since we dispatch events in this function, it's possible that the 561 // Since we dispatch events in this function, it's possible that the
562 // document will be detached and GC'd. We protect it here to make sure we 562 // document will be detached and GC'd. We protect it here to make sure we
563 // can finish the function successfully. 563 // can finish the function successfully.
564 RefPtrWillBeRawPtr<Document> protectDocument(document()); 564 RawPtr<Document> protectDocument(document());
565 WillBeHeapDeque<RefPtrWillBeMember<Event>> eventQueue; 565 HeapDeque<Member<Event>> eventQueue;
566 m_eventQueue.swap(eventQueue); 566 m_eventQueue.swap(eventQueue);
567 567
568 while (!eventQueue.isEmpty()) { 568 while (!eventQueue.isEmpty()) {
569 RefPtrWillBeRawPtr<Event> event = eventQueue.takeFirst(); 569 RawPtr<Event> event = eventQueue.takeFirst();
570 Node* target = event->target()->toNode(); 570 Node* target = event->target()->toNode();
571 571
572 // If the element was removed from our tree, also message the documentEl ement. 572 // If the element was removed from our tree, also message the documentEl ement.
573 if (!target->inDocument() && document()->documentElement()) { 573 if (!target->inDocument() && document()->documentElement()) {
574 ASSERT(isPrefixed(event->type())); 574 ASSERT(isPrefixed(event->type()));
575 eventQueue.append(createEvent(event->type(), *document()->documentEl ement())); 575 eventQueue.append(createEvent(event->type(), *document()->documentEl ement()));
576 } 576 }
577 577
578 target->dispatchEvent(event); 578 target->dispatchEvent(event);
579 } 579 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 m_fullScreenElementStack.append(std::make_pair(&element, requestType)); 620 m_fullScreenElementStack.append(std::make_pair(&element, requestType));
621 } 621 }
622 622
623 DEFINE_TRACE(Fullscreen) 623 DEFINE_TRACE(Fullscreen)
624 { 624 {
625 #if ENABLE(OILPAN) 625 #if ENABLE(OILPAN)
626 visitor->trace(m_fullScreenElement); 626 visitor->trace(m_fullScreenElement);
627 visitor->trace(m_fullScreenElementStack); 627 visitor->trace(m_fullScreenElementStack);
628 visitor->trace(m_eventQueue); 628 visitor->trace(m_eventQueue);
629 #endif 629 #endif
630 WillBeHeapSupplement<Document>::trace(visitor); 630 HeapSupplement<Document>::trace(visitor);
631 DocumentLifecycleObserver::trace(visitor); 631 DocumentLifecycleObserver::trace(visitor);
632 } 632 }
633 633
634 } // namespace blink 634 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Fullscreen.h ('k') | third_party/WebKit/Source/core/dom/IdTargetObserver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698