| OLD | NEW |
| 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 } | 100 } |
| 101 | 101 |
| 102 return true; | 102 return true; |
| 103 } | 103 } |
| 104 | 104 |
| 105 static bool isPrefixed(const AtomicString& type) | 105 static bool isPrefixed(const AtomicString& type) |
| 106 { | 106 { |
| 107 return type == EventTypeNames::webkitfullscreenchange || type == EventTypeNa
mes::webkitfullscreenerror; | 107 return type == EventTypeNames::webkitfullscreenchange || type == EventTypeNa
mes::webkitfullscreenerror; |
| 108 } | 108 } |
| 109 | 109 |
| 110 static PassRefPtrWillBeRawPtr<Event> createEvent(const AtomicString& type, Event
Target& target) | 110 static RawPtr<Event> createEvent(const AtomicString& type, EventTarget& target) |
| 111 { | 111 { |
| 112 EventInit initializer; | 112 EventInit initializer; |
| 113 initializer.setBubbles(isPrefixed(type)); | 113 initializer.setBubbles(isPrefixed(type)); |
| 114 RefPtrWillBeRawPtr<Event> event = Event::create(type, initializer); | 114 RawPtr<Event> event = Event::create(type, initializer); |
| 115 event->setTarget(&target); | 115 event->setTarget(&target); |
| 116 return event; | 116 return event; |
| 117 } | 117 } |
| 118 | 118 |
| 119 const char* Fullscreen::supplementName() | 119 const char* Fullscreen::supplementName() |
| 120 { | 120 { |
| 121 return "Fullscreen"; | 121 return "Fullscreen"; |
| 122 } | 122 } |
| 123 | 123 |
| 124 Fullscreen& Fullscreen::from(Document& document) | 124 Fullscreen& Fullscreen::from(Document& document) |
| 125 { | 125 { |
| 126 Fullscreen* fullscreen = fromIfExists(document); | 126 Fullscreen* fullscreen = fromIfExists(document); |
| 127 if (!fullscreen) { | 127 if (!fullscreen) { |
| 128 fullscreen = new Fullscreen(document); | 128 fullscreen = new Fullscreen(document); |
| 129 WillBeHeapSupplement<Document>::provideTo(document, supplementName(), ad
optPtrWillBeNoop(fullscreen)); | 129 HeapSupplement<Document>::provideTo(document, supplementName(), (fullscr
een)); |
| 130 } | 130 } |
| 131 | 131 |
| 132 return *fullscreen; | 132 return *fullscreen; |
| 133 } | 133 } |
| 134 | 134 |
| 135 Fullscreen* Fullscreen::fromIfExistsSlow(Document& document) | 135 Fullscreen* Fullscreen::fromIfExistsSlow(Document& document) |
| 136 { | 136 { |
| 137 return static_cast<Fullscreen*>(WillBeHeapSupplement<Document>::from(documen
t, supplementName())); | 137 return static_cast<Fullscreen*>(HeapSupplement<Document>::from(document, sup
plementName())); |
| 138 } | 138 } |
| 139 | 139 |
| 140 Element* Fullscreen::fullscreenElementFrom(Document& document) | 140 Element* Fullscreen::fullscreenElementFrom(Document& document) |
| 141 { | 141 { |
| 142 if (Fullscreen* found = fromIfExists(document)) | 142 if (Fullscreen* found = fromIfExists(document)) |
| 143 return found->fullscreenElement(); | 143 return found->fullscreenElement(); |
| 144 return 0; | 144 return 0; |
| 145 } | 145 } |
| 146 | 146 |
| 147 Element* Fullscreen::currentFullScreenElementFrom(Document& document) | 147 Element* Fullscreen::currentFullScreenElementFrom(Document& document) |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 } | 236 } |
| 237 | 237 |
| 238 // Fullscreen is not supported. | 238 // Fullscreen is not supported. |
| 239 if (!fullscreenIsSupported(element.document())) | 239 if (!fullscreenIsSupported(element.document())) |
| 240 break; | 240 break; |
| 241 | 241 |
| 242 // 2. Let doc be element's node document. (i.e. "this") | 242 // 2. Let doc be element's node document. (i.e. "this") |
| 243 Document* currentDoc = document(); | 243 Document* currentDoc = document(); |
| 244 | 244 |
| 245 // 3. Let docs be all doc's ancestor browsing context's documents (if an
y) and doc. | 245 // 3. Let docs be all doc's ancestor browsing context's documents (if an
y) and doc. |
| 246 WillBeHeapDeque<RawPtrWillBeMember<Document>> docs; | 246 HeapDeque<Member<Document>> docs; |
| 247 | 247 |
| 248 do { | 248 do { |
| 249 docs.prepend(currentDoc); | 249 docs.prepend(currentDoc); |
| 250 currentDoc = currentDoc->ownerElement() ? ¤tDoc->ownerElement(
)->document() : nullptr; | 250 currentDoc = currentDoc->ownerElement() ? ¤tDoc->ownerElement(
)->document() : nullptr; |
| 251 } while (currentDoc); | 251 } while (currentDoc); |
| 252 | 252 |
| 253 // 4. For each document in docs, run these substeps: | 253 // 4. For each document in docs, run these substeps: |
| 254 WillBeHeapDeque<RawPtrWillBeMember<Document>>::iterator current = docs.b
egin(), following = docs.begin(); | 254 HeapDeque<Member<Document>>::iterator current = docs.begin(), following
= docs.begin(); |
| 255 | 255 |
| 256 do { | 256 do { |
| 257 ++following; | 257 ++following; |
| 258 | 258 |
| 259 // 1. Let following document be the document after document in docs,
or null if there is no | 259 // 1. Let following document be the document after document in docs,
or null if there is no |
| 260 // such document. | 260 // such document. |
| 261 Document* currentDoc = *current; | 261 Document* currentDoc = *current; |
| 262 Document* followingDoc = following != docs.end() ? *following : null
ptr; | 262 Document* followingDoc = following != docs.end() ? *following : null
ptr; |
| 263 | 263 |
| 264 // 2. If following document is null, push context object on document
's fullscreen element | 264 // 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 Loading... |
| 325 if (!currentDoc->isActive()) | 325 if (!currentDoc->isActive()) |
| 326 return; | 326 return; |
| 327 | 327 |
| 328 // 2. If doc's fullscreen element stack is empty, terminate these steps. | 328 // 2. If doc's fullscreen element stack is empty, terminate these steps. |
| 329 if (m_fullScreenElementStack.isEmpty()) | 329 if (m_fullScreenElementStack.isEmpty()) |
| 330 return; | 330 return; |
| 331 | 331 |
| 332 // 3. Let descendants be all the doc's descendant browsing context's documen
ts with a non-empty fullscreen | 332 // 3. Let descendants be all the doc's descendant browsing context's documen
ts with a non-empty fullscreen |
| 333 // element stack (if any), ordered so that the child of the doc is last and
the document furthest | 333 // element stack (if any), ordered so that the child of the doc is last and
the document furthest |
| 334 // away from the doc is first. | 334 // away from the doc is first. |
| 335 WillBeHeapDeque<RefPtrWillBeMember<Document>> descendants; | 335 HeapDeque<Member<Document>> descendants; |
| 336 for (Frame* descendant = document()->frame() ? document()->frame()->tree().t
raverseNext() : 0; descendant; descendant = descendant->tree().traverseNext()) { | 336 for (Frame* descendant = document()->frame() ? document()->frame()->tree().t
raverseNext() : 0; descendant; descendant = descendant->tree().traverseNext()) { |
| 337 if (!descendant->isLocalFrame()) | 337 if (!descendant->isLocalFrame()) |
| 338 continue; | 338 continue; |
| 339 ASSERT(toLocalFrame(descendant)->document()); | 339 ASSERT(toLocalFrame(descendant)->document()); |
| 340 if (fullscreenElementFrom(*toLocalFrame(descendant)->document())) | 340 if (fullscreenElementFrom(*toLocalFrame(descendant)->document())) |
| 341 descendants.prepend(toLocalFrame(descendant)->document()); | 341 descendants.prepend(toLocalFrame(descendant)->document()); |
| 342 } | 342 } |
| 343 | 343 |
| 344 // 4. For each descendant in descendants, empty descendant's fullscreen elem
ent stack, and queue a | 344 // 4. For each descendant in descendants, empty descendant's fullscreen elem
ent stack, and queue a |
| 345 // task to fire an event named fullscreenchange with its bubbles attribute s
et to true on descendant. | 345 // task to fire an event named fullscreenchange with its bubbles attribute s
et to true on descendant. |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 m_fullScreenLayoutObject = layoutObject; | 506 m_fullScreenLayoutObject = layoutObject; |
| 507 } | 507 } |
| 508 | 508 |
| 509 void Fullscreen::fullScreenLayoutObjectDestroyed() | 509 void Fullscreen::fullScreenLayoutObjectDestroyed() |
| 510 { | 510 { |
| 511 m_fullScreenLayoutObject = nullptr; | 511 m_fullScreenLayoutObject = nullptr; |
| 512 } | 512 } |
| 513 | 513 |
| 514 void Fullscreen::enqueueChangeEvent(Document& document, RequestType requestType) | 514 void Fullscreen::enqueueChangeEvent(Document& document, RequestType requestType) |
| 515 { | 515 { |
| 516 RefPtrWillBeRawPtr<Event> event; | 516 RawPtr<Event> event; |
| 517 if (requestType == UnprefixedRequest) { | 517 if (requestType == UnprefixedRequest) { |
| 518 event = createEvent(EventTypeNames::fullscreenchange, document); | 518 event = createEvent(EventTypeNames::fullscreenchange, document); |
| 519 } else { | 519 } else { |
| 520 ASSERT(document.hasFullscreenSupplement()); | 520 ASSERT(document.hasFullscreenSupplement()); |
| 521 Fullscreen& fullscreen = from(document); | 521 Fullscreen& fullscreen = from(document); |
| 522 EventTarget* target = fullscreen.fullscreenElement(); | 522 EventTarget* target = fullscreen.fullscreenElement(); |
| 523 if (!target) | 523 if (!target) |
| 524 target = fullscreen.webkitCurrentFullScreenElement(); | 524 target = fullscreen.webkitCurrentFullScreenElement(); |
| 525 if (!target) | 525 if (!target) |
| 526 target = &document; | 526 target = &document; |
| 527 event = createEvent(EventTypeNames::webkitfullscreenchange, *target); | 527 event = createEvent(EventTypeNames::webkitfullscreenchange, *target); |
| 528 } | 528 } |
| 529 m_eventQueue.append(event); | 529 m_eventQueue.append(event); |
| 530 // NOTE: The timer is started in didEnterFullScreenForElement/didExitFullScr
eenForElement. | 530 // NOTE: The timer is started in didEnterFullScreenForElement/didExitFullScr
eenForElement. |
| 531 } | 531 } |
| 532 | 532 |
| 533 void Fullscreen::enqueueErrorEvent(Element& element, RequestType requestType) | 533 void Fullscreen::enqueueErrorEvent(Element& element, RequestType requestType) |
| 534 { | 534 { |
| 535 RefPtrWillBeRawPtr<Event> event; | 535 RawPtr<Event> event; |
| 536 if (requestType == UnprefixedRequest) | 536 if (requestType == UnprefixedRequest) |
| 537 event = createEvent(EventTypeNames::fullscreenerror, element.document())
; | 537 event = createEvent(EventTypeNames::fullscreenerror, element.document())
; |
| 538 else | 538 else |
| 539 event = createEvent(EventTypeNames::webkitfullscreenerror, element); | 539 event = createEvent(EventTypeNames::webkitfullscreenerror, element); |
| 540 m_eventQueue.append(event); | 540 m_eventQueue.append(event); |
| 541 m_eventQueueTimer.startOneShot(0, BLINK_FROM_HERE); | 541 m_eventQueueTimer.startOneShot(0, BLINK_FROM_HERE); |
| 542 } | 542 } |
| 543 | 543 |
| 544 void Fullscreen::eventQueueTimerFired(Timer<Fullscreen>*) | 544 void Fullscreen::eventQueueTimerFired(Timer<Fullscreen>*) |
| 545 { | 545 { |
| 546 // Since we dispatch events in this function, it's possible that the | 546 // Since we dispatch events in this function, it's possible that the |
| 547 // document will be detached and GC'd. We protect it here to make sure we | 547 // document will be detached and GC'd. We protect it here to make sure we |
| 548 // can finish the function successfully. | 548 // can finish the function successfully. |
| 549 RefPtrWillBeRawPtr<Document> protectDocument(document()); | 549 RawPtr<Document> protectDocument(document()); |
| 550 WillBeHeapDeque<RefPtrWillBeMember<Event>> eventQueue; | 550 HeapDeque<Member<Event>> eventQueue; |
| 551 m_eventQueue.swap(eventQueue); | 551 m_eventQueue.swap(eventQueue); |
| 552 | 552 |
| 553 while (!eventQueue.isEmpty()) { | 553 while (!eventQueue.isEmpty()) { |
| 554 RefPtrWillBeRawPtr<Event> event = eventQueue.takeFirst(); | 554 RawPtr<Event> event = eventQueue.takeFirst(); |
| 555 Node* target = event->target()->toNode(); | 555 Node* target = event->target()->toNode(); |
| 556 | 556 |
| 557 // If the element was removed from our tree, also message the documentEl
ement. | 557 // If the element was removed from our tree, also message the documentEl
ement. |
| 558 if (!target->inDocument() && document()->documentElement()) { | 558 if (!target->inDocument() && document()->documentElement()) { |
| 559 ASSERT(isPrefixed(event->type())); | 559 ASSERT(isPrefixed(event->type())); |
| 560 eventQueue.append(createEvent(event->type(), *document()->documentEl
ement())); | 560 eventQueue.append(createEvent(event->type(), *document()->documentEl
ement())); |
| 561 } | 561 } |
| 562 | 562 |
| 563 target->dispatchEvent(event); | 563 target->dispatchEvent(event); |
| 564 } | 564 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 m_fullScreenElementStack.append(std::make_pair(&element, requestType)); | 605 m_fullScreenElementStack.append(std::make_pair(&element, requestType)); |
| 606 } | 606 } |
| 607 | 607 |
| 608 DEFINE_TRACE(Fullscreen) | 608 DEFINE_TRACE(Fullscreen) |
| 609 { | 609 { |
| 610 #if ENABLE(OILPAN) | 610 #if ENABLE(OILPAN) |
| 611 visitor->trace(m_fullScreenElement); | 611 visitor->trace(m_fullScreenElement); |
| 612 visitor->trace(m_fullScreenElementStack); | 612 visitor->trace(m_fullScreenElementStack); |
| 613 visitor->trace(m_eventQueue); | 613 visitor->trace(m_eventQueue); |
| 614 #endif | 614 #endif |
| 615 WillBeHeapSupplement<Document>::trace(visitor); | 615 HeapSupplement<Document>::trace(visitor); |
| 616 DocumentLifecycleObserver::trace(visitor); | 616 DocumentLifecycleObserver::trace(visitor); |
| 617 } | 617 } |
| 618 | 618 |
| 619 } // namespace blink | 619 } // namespace blink |
| OLD | NEW |