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 * |
11 * This library is free software; you can redistribute it and/or | 11 * This library is free software; you can redistribute it and/or |
12 * modify it under the terms of the GNU Library General Public | 12 * modify it under the terms of the GNU Library General Public |
13 * License as published by the Free Software Foundation; either | 13 * License as published by the Free Software Foundation; either |
14 * version 2 of the License, or (at your option) any later version. | 14 * version 2 of the License, or (at your option) any later version. |
15 * | 15 * |
16 * This library is distributed in the hope that it will be useful, | 16 * This library is distributed in the hope that it will be useful, |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
19 * Library General Public License for more details. | 19 * Library General Public License for more details. |
20 * | 20 * |
21 * You should have received a copy of the GNU Library General Public License | 21 * You should have received a copy of the GNU Library General Public License |
22 * along with this library; see the file COPYING.LIB. If not, write to | 22 * along with this library; see the file COPYING.LIB. If not, write to |
23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
24 * Boston, MA 02110-1301, USA. | 24 * Boston, MA 02110-1301, USA. |
25 * | 25 * |
26 */ | 26 */ |
27 | 27 |
28 #include "config.h" | 28 #include "config.h" |
29 #include "core/dom/FullscreenElementStack.h" | 29 #include "core/dom/Fullscreen.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/HTMLIFrameElement.h" | 38 #include "core/html/HTMLIFrameElement.h" |
39 #include "core/html/HTMLMediaElement.h" | 39 #include "core/html/HTMLMediaElement.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 | 78 |
79 static PassRefPtrWillBeRawPtr<Event> createEvent(const AtomicString& type, Event
Target& target) | 79 static PassRefPtrWillBeRawPtr<Event> createEvent(const AtomicString& type, Event
Target& target) |
80 { | 80 { |
81 EventInit initializer; | 81 EventInit initializer; |
82 initializer.bubbles = isPrefixed(type); | 82 initializer.bubbles = isPrefixed(type); |
83 RefPtrWillBeRawPtr<Event> event = Event::create(type, initializer); | 83 RefPtrWillBeRawPtr<Event> event = Event::create(type, initializer); |
84 event->setTarget(&target); | 84 event->setTarget(&target); |
85 return event; | 85 return event; |
86 } | 86 } |
87 | 87 |
88 const char* FullscreenElementStack::supplementName() | 88 const char* Fullscreen::supplementName() |
89 { | 89 { |
90 return "FullscreenElementStack"; | 90 return "Fullscreen"; |
91 } | 91 } |
92 | 92 |
93 FullscreenElementStack& FullscreenElementStack::from(Document& document) | 93 Fullscreen& Fullscreen::from(Document& document) |
94 { | 94 { |
95 FullscreenElementStack* fullscreen = fromIfExists(document); | 95 Fullscreen* fullscreen = fromIfExists(document); |
96 if (!fullscreen) { | 96 if (!fullscreen) { |
97 fullscreen = new FullscreenElementStack(document); | 97 fullscreen = new Fullscreen(document); |
98 DocumentSupplement::provideTo(document, supplementName(), adoptPtrWillBe
Noop(fullscreen)); | 98 DocumentSupplement::provideTo(document, supplementName(), adoptPtrWillBe
Noop(fullscreen)); |
99 } | 99 } |
100 | 100 |
101 return *fullscreen; | 101 return *fullscreen; |
102 } | 102 } |
103 | 103 |
104 FullscreenElementStack* FullscreenElementStack::fromIfExistsSlow(Document& docum
ent) | 104 Fullscreen* Fullscreen::fromIfExistsSlow(Document& document) |
105 { | 105 { |
106 return static_cast<FullscreenElementStack*>(DocumentSupplement::from(documen
t, supplementName())); | 106 return static_cast<Fullscreen*>(DocumentSupplement::from(document, supplemen
tName())); |
107 } | 107 } |
108 | 108 |
109 Element* FullscreenElementStack::fullscreenElementFrom(Document& document) | 109 Element* Fullscreen::fullscreenElementFrom(Document& document) |
110 { | 110 { |
111 if (FullscreenElementStack* found = fromIfExists(document)) | 111 if (Fullscreen* found = fromIfExists(document)) |
112 return found->fullscreenElement(); | 112 return found->fullscreenElement(); |
113 return 0; | 113 return 0; |
114 } | 114 } |
115 | 115 |
116 Element* FullscreenElementStack::currentFullScreenElementFrom(Document& document
) | 116 Element* Fullscreen::currentFullScreenElementFrom(Document& document) |
117 { | 117 { |
118 if (FullscreenElementStack* found = fromIfExists(document)) | 118 if (Fullscreen* found = fromIfExists(document)) |
119 return found->webkitCurrentFullScreenElement(); | 119 return found->webkitCurrentFullScreenElement(); |
120 return 0; | 120 return 0; |
121 } | 121 } |
122 | 122 |
123 bool FullscreenElementStack::isFullScreen(Document& document) | 123 bool Fullscreen::isFullScreen(Document& document) |
124 { | 124 { |
125 if (FullscreenElementStack* found = fromIfExists(document)) | 125 if (Fullscreen* found = fromIfExists(document)) |
126 return found->webkitIsFullScreen(); | 126 return found->webkitIsFullScreen(); |
127 return false; | 127 return false; |
128 } | 128 } |
129 | 129 |
130 FullscreenElementStack::FullscreenElementStack(Document& document) | 130 Fullscreen::Fullscreen(Document& document) |
131 : DocumentLifecycleObserver(&document) | 131 : DocumentLifecycleObserver(&document) |
132 , m_areKeysEnabledInFullScreen(false) | 132 , m_areKeysEnabledInFullScreen(false) |
133 , m_fullScreenRenderer(nullptr) | 133 , m_fullScreenRenderer(nullptr) |
134 , m_eventQueueTimer(this, &FullscreenElementStack::eventQueueTimerFired) | 134 , m_eventQueueTimer(this, &Fullscreen::eventQueueTimerFired) |
135 { | 135 { |
136 document.setHasFullscreenElementStack(); | 136 document.setHasFullscreenSupplement(); |
137 } | 137 } |
138 | 138 |
139 FullscreenElementStack::~FullscreenElementStack() | 139 Fullscreen::~Fullscreen() |
140 { | 140 { |
141 } | 141 } |
142 | 142 |
143 inline Document* FullscreenElementStack::document() | 143 inline Document* Fullscreen::document() |
144 { | 144 { |
145 return lifecycleContext(); | 145 return lifecycleContext(); |
146 } | 146 } |
147 | 147 |
148 void FullscreenElementStack::documentWasDetached() | 148 void Fullscreen::documentWasDetached() |
149 { | 149 { |
150 m_eventQueue.clear(); | 150 m_eventQueue.clear(); |
151 | 151 |
152 if (m_fullScreenRenderer) | 152 if (m_fullScreenRenderer) |
153 m_fullScreenRenderer->destroy(); | 153 m_fullScreenRenderer->destroy(); |
154 | 154 |
155 #if ENABLE(OILPAN) | 155 #if ENABLE(OILPAN) |
156 m_fullScreenElement = nullptr; | 156 m_fullScreenElement = nullptr; |
157 m_fullScreenElementStack.clear(); | 157 m_fullScreenElementStack.clear(); |
158 #endif | 158 #endif |
159 | 159 |
160 } | 160 } |
161 | 161 |
162 #if !ENABLE(OILPAN) | 162 #if !ENABLE(OILPAN) |
163 void FullscreenElementStack::documentWasDisposed() | 163 void Fullscreen::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) | 172 bool Fullscreen::elementReady(Element& element, RequestType requestType) |
173 { | 173 { |
174 // A fullscreen element ready check for an element |element| returns true if
all of the | 174 // A fullscreen element ready check for an element |element| returns true if
all of the |
175 // following are true, and false otherwise: | 175 // following are true, and false otherwise: |
176 | 176 |
177 // |element| is in a document. | 177 // |element| is in a document. |
178 if (!element.inDocument()) | 178 if (!element.inDocument()) |
179 return false; | 179 return false; |
180 | 180 |
181 // |element|'s node document's fullscreen enabled flag is set. | 181 // |element|'s node document's fullscreen enabled flag is set. |
182 if (!fullscreenIsAllowedForAllOwners(element.document())) { | 182 if (!fullscreenIsAllowedForAllOwners(element.document())) { |
(...skipping 11 matching lines...) Expand all Loading... |
194 } | 194 } |
195 | 195 |
196 // |element| has no ancestor element whose local name is iframe and namespac
e is the HTML | 196 // |element| has no ancestor element whose local name is iframe and namespac
e is the HTML |
197 // namespace. | 197 // namespace. |
198 if (Traversal<HTMLIFrameElement>::firstAncestor(element)) | 198 if (Traversal<HTMLIFrameElement>::firstAncestor(element)) |
199 return false; | 199 return false; |
200 | 200 |
201 return true; | 201 return true; |
202 } | 202 } |
203 | 203 |
204 void FullscreenElementStack::requestFullscreen(Element& element, RequestType req
uestType) | 204 void Fullscreen::requestFullscreen(Element& element, RequestType requestType) |
205 { | 205 { |
206 // Ignore this request if the document is not in a live frame. | 206 // Ignore this request if the document is not in a live frame. |
207 if (!document()->isActive()) | 207 if (!document()->isActive()) |
208 return; | 208 return; |
209 | 209 |
210 do { | 210 do { |
211 // 1. If any of the following conditions are true, terminate these steps
and queue a task to fire | 211 // 1. If any of the following conditions are true, terminate these steps
and queue a task to fire |
212 // an event named fullscreenerror with its bubbles attribute set to true
on the context object's | 212 // an event named fullscreenerror with its bubbles attribute set to true
on the context object's |
213 // node document: | 213 // node document: |
214 | 214 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 m_areKeysEnabledInFullScreen = requestType != PrefixedMozillaRequest &&
requestType != PrefixedVideoRequest; | 278 m_areKeysEnabledInFullScreen = requestType != PrefixedMozillaRequest &&
requestType != PrefixedVideoRequest; |
279 document()->frameHost()->chrome().client().enterFullScreenForElement(&el
ement); | 279 document()->frameHost()->chrome().client().enterFullScreenForElement(&el
ement); |
280 | 280 |
281 // 7. Optionally, display a message indicating how the user can exit dis
playing the context object fullscreen. | 281 // 7. Optionally, display a message indicating how the user can exit dis
playing the context object fullscreen. |
282 return; | 282 return; |
283 } while (0); | 283 } while (0); |
284 | 284 |
285 enqueueErrorEvent(element, requestType); | 285 enqueueErrorEvent(element, requestType); |
286 } | 286 } |
287 | 287 |
288 void FullscreenElementStack::fullyExitFullscreen() | 288 void Fullscreen::fullyExitFullscreen() |
289 { | 289 { |
290 // "To fully exit fullscreen act as if the exitFullscreen() method was invok
ed on the top-level browsing | 290 // "To fully exit fullscreen act as if the exitFullscreen() method was invok
ed on the top-level browsing |
291 // context's document and subsequently empty that document's fullscreen elem
ent stack." | 291 // context's document and subsequently empty that document's fullscreen elem
ent stack." |
292 if (!fullscreenElementFrom(document()->topDocument())) | 292 if (!fullscreenElementFrom(document()->topDocument())) |
293 return; | 293 return; |
294 | 294 |
295 // To achieve that aim, remove all the elements from the top document's stac
k except for the first before | 295 // To achieve that aim, remove all the elements from the top document's stac
k except for the first before |
296 // calling exitFullscreen(): | 296 // calling exitFullscreen(): |
297 WillBeHeapVector<std::pair<RefPtrWillBeMember<Element>, RequestType> > repla
cementFullscreenElementStack; | 297 WillBeHeapVector<std::pair<RefPtrWillBeMember<Element>, RequestType> > repla
cementFullscreenElementStack; |
298 FullscreenElementStack& topFullscreenElementStack = from(document()->topDocu
ment()); | 298 Fullscreen& topFullscreen = from(document()->topDocument()); |
299 replacementFullscreenElementStack.append(topFullscreenElementStack.m_fullScr
eenElementStack.last()); | 299 replacementFullscreenElementStack.append(topFullscreen.m_fullScreenElementSt
ack.last()); |
300 topFullscreenElementStack.m_fullScreenElementStack.swap(replacementFullscree
nElementStack); | 300 topFullscreen.m_fullScreenElementStack.swap(replacementFullscreenElementStac
k); |
301 topFullscreenElementStack.exitFullscreen(); | 301 topFullscreen.exitFullscreen(); |
302 } | 302 } |
303 | 303 |
304 void FullscreenElementStack::exitFullscreen() | 304 void Fullscreen::exitFullscreen() |
305 { | 305 { |
306 // The exitFullscreen() method must run these steps: | 306 // The exitFullscreen() method must run these steps: |
307 | 307 |
308 // 1. Let doc be the context object. (i.e. "this") | 308 // 1. Let doc be the context object. (i.e. "this") |
309 Document* currentDoc = document(); | 309 Document* currentDoc = document(); |
310 if (!currentDoc->isActive()) | 310 if (!currentDoc->isActive()) |
311 return; | 311 return; |
312 | 312 |
313 // 2. If doc's fullscreen element stack is empty, terminate these steps. | 313 // 2. If doc's fullscreen element stack is empty, terminate these steps. |
314 if (m_fullScreenElementStack.isEmpty()) | 314 if (m_fullScreenElementStack.isEmpty()) |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 // full screen stack. | 379 // full screen stack. |
380 if (!newTop) { | 380 if (!newTop) { |
381 host->chrome().client().exitFullScreenForElement(m_fullScreenElement.get
()); | 381 host->chrome().client().exitFullScreenForElement(m_fullScreenElement.get
()); |
382 return; | 382 return; |
383 } | 383 } |
384 | 384 |
385 // Otherwise, notify the chrome of the new full screen element. | 385 // Otherwise, notify the chrome of the new full screen element. |
386 host->chrome().client().enterFullScreenForElement(newTop); | 386 host->chrome().client().enterFullScreenForElement(newTop); |
387 } | 387 } |
388 | 388 |
389 bool FullscreenElementStack::fullscreenEnabled(Document& document) | 389 bool Fullscreen::fullscreenEnabled(Document& document) |
390 { | 390 { |
391 // 4. The fullscreenEnabled attribute must return true if the context object
has its | 391 // 4. The fullscreenEnabled attribute must return true if the context object
has its |
392 // fullscreen enabled flag set and fullscreen is supported, and false oth
erwise. | 392 // fullscreen enabled flag set and fullscreen is supported, and false oth
erwise. |
393 | 393 |
394 // Top-level browsing contexts are implied to have their allowFullScreen att
ribute set. | 394 // Top-level browsing contexts are implied to have their allowFullScreen att
ribute set. |
395 return fullscreenIsAllowedForAllOwners(document) && fullscreenIsSupported(do
cument); | 395 return fullscreenIsAllowedForAllOwners(document) && fullscreenIsSupported(do
cument); |
396 } | 396 } |
397 | 397 |
398 void FullscreenElementStack::willEnterFullScreenForElement(Element* element) | 398 void Fullscreen::willEnterFullScreenForElement(Element* element) |
399 { | 399 { |
400 ASSERT(element); | 400 ASSERT(element); |
401 if (!document()->isActive()) | 401 if (!document()->isActive()) |
402 return; | 402 return; |
403 | 403 |
404 if (m_fullScreenRenderer) | 404 if (m_fullScreenRenderer) |
405 m_fullScreenRenderer->unwrapRenderer(); | 405 m_fullScreenRenderer->unwrapRenderer(); |
406 | 406 |
407 m_fullScreenElement = element; | 407 m_fullScreenElement = element; |
408 | 408 |
(...skipping 11 matching lines...) Expand all Loading... |
420 if (m_fullScreenElement != document()->documentElement()) | 420 if (m_fullScreenElement != document()->documentElement()) |
421 RenderFullScreen::wrapRenderer(renderer, renderer ? renderer->parent() :
0, document()); | 421 RenderFullScreen::wrapRenderer(renderer, renderer ? renderer->parent() :
0, document()); |
422 | 422 |
423 m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBou
ndaries(true); | 423 m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBou
ndaries(true); |
424 | 424 |
425 // FIXME: This should not call updateStyleIfNeeded. | 425 // FIXME: This should not call updateStyleIfNeeded. |
426 document()->setNeedsStyleRecalc(SubtreeStyleChange); | 426 document()->setNeedsStyleRecalc(SubtreeStyleChange); |
427 document()->updateRenderTreeIfNeeded(); | 427 document()->updateRenderTreeIfNeeded(); |
428 } | 428 } |
429 | 429 |
430 void FullscreenElementStack::didEnterFullScreenForElement(Element*) | 430 void Fullscreen::didEnterFullScreenForElement(Element*) |
431 { | 431 { |
432 if (!m_fullScreenElement) | 432 if (!m_fullScreenElement) |
433 return; | 433 return; |
434 | 434 |
435 if (!document()->isActive()) | 435 if (!document()->isActive()) |
436 return; | 436 return; |
437 | 437 |
438 m_fullScreenElement->didBecomeFullscreenElement(); | 438 m_fullScreenElement->didBecomeFullscreenElement(); |
439 | 439 |
440 m_eventQueueTimer.startOneShot(0, FROM_HERE); | 440 m_eventQueueTimer.startOneShot(0, FROM_HERE); |
441 } | 441 } |
442 | 442 |
443 void FullscreenElementStack::willExitFullScreenForElement(Element*) | 443 void Fullscreen::willExitFullScreenForElement(Element*) |
444 { | 444 { |
445 if (!m_fullScreenElement) | 445 if (!m_fullScreenElement) |
446 return; | 446 return; |
447 | 447 |
448 if (!document()->isActive()) | 448 if (!document()->isActive()) |
449 return; | 449 return; |
450 | 450 |
451 m_fullScreenElement->willStopBeingFullscreenElement(); | 451 m_fullScreenElement->willStopBeingFullscreenElement(); |
452 } | 452 } |
453 | 453 |
454 void FullscreenElementStack::didExitFullScreenForElement(Element*) | 454 void Fullscreen::didExitFullScreenForElement(Element*) |
455 { | 455 { |
456 if (!m_fullScreenElement) | 456 if (!m_fullScreenElement) |
457 return; | 457 return; |
458 | 458 |
459 if (!document()->isActive()) | 459 if (!document()->isActive()) |
460 return; | 460 return; |
461 | 461 |
462 m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBou
ndaries(false); | 462 m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBou
ndaries(false); |
463 | 463 |
464 m_areKeysEnabledInFullScreen = false; | 464 m_areKeysEnabledInFullScreen = false; |
465 | 465 |
466 if (m_fullScreenRenderer) | 466 if (m_fullScreenRenderer) |
467 m_fullScreenRenderer->unwrapRenderer(); | 467 m_fullScreenRenderer->unwrapRenderer(); |
468 | 468 |
469 m_fullScreenElement = nullptr; | 469 m_fullScreenElement = nullptr; |
470 document()->setNeedsStyleRecalc(SubtreeStyleChange); | 470 document()->setNeedsStyleRecalc(SubtreeStyleChange); |
471 | 471 |
472 // When fullyExitFullscreen is called, we call exitFullscreen on the topDocu
ment(). That means | 472 // When fullyExitFullscreen is called, we call exitFullscreen on the topDocu
ment(). That means |
473 // that the events will be queued there. So if we have no events here, start
the timer on the | 473 // that the events will be queued there. So if we have no events here, start
the timer on the |
474 // exiting document. | 474 // exiting document. |
475 Document* exitingDocument = document(); | 475 Document* exitingDocument = document(); |
476 if (m_eventQueue.isEmpty()) | 476 if (m_eventQueue.isEmpty()) |
477 exitingDocument = &document()->topDocument(); | 477 exitingDocument = &document()->topDocument(); |
478 ASSERT(exitingDocument); | 478 ASSERT(exitingDocument); |
479 from(*exitingDocument).m_eventQueueTimer.startOneShot(0, FROM_HERE); | 479 from(*exitingDocument).m_eventQueueTimer.startOneShot(0, FROM_HERE); |
480 } | 480 } |
481 | 481 |
482 void FullscreenElementStack::setFullScreenRenderer(RenderFullScreen* renderer) | 482 void Fullscreen::setFullScreenRenderer(RenderFullScreen* renderer) |
483 { | 483 { |
484 if (renderer == m_fullScreenRenderer) | 484 if (renderer == m_fullScreenRenderer) |
485 return; | 485 return; |
486 | 486 |
487 if (renderer && m_savedPlaceholderRenderStyle) { | 487 if (renderer && m_savedPlaceholderRenderStyle) { |
488 renderer->createPlaceholder(m_savedPlaceholderRenderStyle.release(), m_s
avedPlaceholderFrameRect); | 488 renderer->createPlaceholder(m_savedPlaceholderRenderStyle.release(), m_s
avedPlaceholderFrameRect); |
489 } else if (renderer && m_fullScreenRenderer && m_fullScreenRenderer->placeho
lder()) { | 489 } else if (renderer && m_fullScreenRenderer && m_fullScreenRenderer->placeho
lder()) { |
490 RenderBlock* placeholder = m_fullScreenRenderer->placeholder(); | 490 RenderBlock* placeholder = m_fullScreenRenderer->placeholder(); |
491 renderer->createPlaceholder(RenderStyle::clone(placeholder->style()), pl
aceholder->frameRect()); | 491 renderer->createPlaceholder(RenderStyle::clone(placeholder->style()), pl
aceholder->frameRect()); |
492 } | 492 } |
493 | 493 |
494 if (m_fullScreenRenderer) | 494 if (m_fullScreenRenderer) |
495 m_fullScreenRenderer->unwrapRenderer(); | 495 m_fullScreenRenderer->unwrapRenderer(); |
496 ASSERT(!m_fullScreenRenderer); | 496 ASSERT(!m_fullScreenRenderer); |
497 | 497 |
498 m_fullScreenRenderer = renderer; | 498 m_fullScreenRenderer = renderer; |
499 } | 499 } |
500 | 500 |
501 void FullscreenElementStack::fullScreenRendererDestroyed() | 501 void Fullscreen::fullScreenRendererDestroyed() |
502 { | 502 { |
503 m_fullScreenRenderer = nullptr; | 503 m_fullScreenRenderer = nullptr; |
504 } | 504 } |
505 | 505 |
506 void FullscreenElementStack::enqueueChangeEvent(Document& document, RequestType
requestType) | 506 void Fullscreen::enqueueChangeEvent(Document& document, RequestType requestType) |
507 { | 507 { |
508 RefPtrWillBeRawPtr<Event> event; | 508 RefPtrWillBeRawPtr<Event> event; |
509 if (requestType == UnprefixedRequest) { | 509 if (requestType == UnprefixedRequest) { |
510 event = createEvent(EventTypeNames::fullscreenchange, document); | 510 event = createEvent(EventTypeNames::fullscreenchange, document); |
511 } else { | 511 } else { |
512 ASSERT(document.hasFullscreenElementStack()); | 512 ASSERT(document.hasFullscreenSupplement()); |
513 FullscreenElementStack& fullscreen = from(document); | 513 Fullscreen& fullscreen = from(document); |
514 EventTarget* target = fullscreen.fullscreenElement(); | 514 EventTarget* target = fullscreen.fullscreenElement(); |
515 if (!target) | 515 if (!target) |
516 target = fullscreen.webkitCurrentFullScreenElement(); | 516 target = fullscreen.webkitCurrentFullScreenElement(); |
517 if (!target) | 517 if (!target) |
518 target = &document; | 518 target = &document; |
519 event = createEvent(EventTypeNames::webkitfullscreenchange, *target); | 519 event = createEvent(EventTypeNames::webkitfullscreenchange, *target); |
520 } | 520 } |
521 m_eventQueue.append(event); | 521 m_eventQueue.append(event); |
522 // NOTE: The timer is started in didEnterFullScreenForElement/didExitFullScr
eenForElement. | 522 // NOTE: The timer is started in didEnterFullScreenForElement/didExitFullScr
eenForElement. |
523 } | 523 } |
524 | 524 |
525 void FullscreenElementStack::enqueueErrorEvent(Element& element, RequestType req
uestType) | 525 void Fullscreen::enqueueErrorEvent(Element& element, RequestType requestType) |
526 { | 526 { |
527 RefPtrWillBeRawPtr<Event> event; | 527 RefPtrWillBeRawPtr<Event> event; |
528 if (requestType == UnprefixedRequest) | 528 if (requestType == UnprefixedRequest) |
529 event = createEvent(EventTypeNames::fullscreenerror, element.document())
; | 529 event = createEvent(EventTypeNames::fullscreenerror, element.document())
; |
530 else | 530 else |
531 event = createEvent(EventTypeNames::webkitfullscreenerror, element); | 531 event = createEvent(EventTypeNames::webkitfullscreenerror, element); |
532 m_eventQueue.append(event); | 532 m_eventQueue.append(event); |
533 m_eventQueueTimer.startOneShot(0, FROM_HERE); | 533 m_eventQueueTimer.startOneShot(0, FROM_HERE); |
534 } | 534 } |
535 | 535 |
536 void FullscreenElementStack::eventQueueTimerFired(Timer<FullscreenElementStack>*
) | 536 void Fullscreen::eventQueueTimerFired(Timer<Fullscreen>*) |
537 { | 537 { |
538 // Since we dispatch events in this function, it's possible that the | 538 // Since we dispatch events in this function, it's possible that the |
539 // document will be detached and GC'd. We protect it here to make sure we | 539 // document will be detached and GC'd. We protect it here to make sure we |
540 // can finish the function successfully. | 540 // can finish the function successfully. |
541 RefPtrWillBeRawPtr<Document> protectDocument(document()); | 541 RefPtrWillBeRawPtr<Document> protectDocument(document()); |
542 WillBeHeapDeque<RefPtrWillBeMember<Event> > eventQueue; | 542 WillBeHeapDeque<RefPtrWillBeMember<Event> > eventQueue; |
543 m_eventQueue.swap(eventQueue); | 543 m_eventQueue.swap(eventQueue); |
544 | 544 |
545 while (!eventQueue.isEmpty()) { | 545 while (!eventQueue.isEmpty()) { |
546 RefPtrWillBeRawPtr<Event> event = eventQueue.takeFirst(); | 546 RefPtrWillBeRawPtr<Event> event = eventQueue.takeFirst(); |
547 Node* target = event->target()->toNode(); | 547 Node* target = event->target()->toNode(); |
548 | 548 |
549 // If the element was removed from our tree, also message the documentEl
ement. | 549 // If the element was removed from our tree, also message the documentEl
ement. |
550 if (!target->inDocument() && document()->documentElement()) { | 550 if (!target->inDocument() && document()->documentElement()) { |
551 ASSERT(isPrefixed(event->type())); | 551 ASSERT(isPrefixed(event->type())); |
552 eventQueue.append(createEvent(event->type(), *document()->documentEl
ement())); | 552 eventQueue.append(createEvent(event->type(), *document()->documentEl
ement())); |
553 } | 553 } |
554 | 554 |
555 target->dispatchEvent(event); | 555 target->dispatchEvent(event); |
556 } | 556 } |
557 } | 557 } |
558 | 558 |
559 void FullscreenElementStack::elementRemoved(Element& element) | 559 void Fullscreen::elementRemoved(Element& element) |
560 { | 560 { |
561 // If an element |element| in a fullscreen element stack is removed from a d
ocument |document|, | 561 // If an element |element| in a fullscreen element stack is removed from a d
ocument |document|, |
562 // run these steps: | 562 // run these steps: |
563 | 563 |
564 // 1. If |element| was at the top of |document|'s fullscreen element stack,
act as if the | 564 // 1. If |element| was at the top of |document|'s fullscreen element stack,
act as if the |
565 // exitFullscreen() method was invoked on that document. | 565 // exitFullscreen() method was invoked on that document. |
566 if (fullscreenElement() == &element) { | 566 if (fullscreenElement() == &element) { |
567 exitFullscreen(); | 567 exitFullscreen(); |
568 return; | 568 return; |
569 } | 569 } |
570 | 570 |
571 // 2. Otherwise, remove |element| from |document|'s fullscreen element stack
. | 571 // 2. Otherwise, remove |element| from |document|'s fullscreen element stack
. |
572 for (size_t i = 0; i < m_fullScreenElementStack.size(); ++i) { | 572 for (size_t i = 0; i < m_fullScreenElementStack.size(); ++i) { |
573 if (m_fullScreenElementStack[i].first.get() == &element) { | 573 if (m_fullScreenElementStack[i].first.get() == &element) { |
574 m_fullScreenElementStack.remove(i); | 574 m_fullScreenElementStack.remove(i); |
575 return; | 575 return; |
576 } | 576 } |
577 } | 577 } |
578 | 578 |
579 // NOTE: |element| was not in the fullscreen element stack. | 579 // NOTE: |element| was not in the fullscreen element stack. |
580 } | 580 } |
581 | 581 |
582 void FullscreenElementStack::clearFullscreenElementStack() | 582 void Fullscreen::clearFullscreenElementStack() |
583 { | 583 { |
584 m_fullScreenElementStack.clear(); | 584 m_fullScreenElementStack.clear(); |
585 } | 585 } |
586 | 586 |
587 void FullscreenElementStack::popFullscreenElementStack() | 587 void Fullscreen::popFullscreenElementStack() |
588 { | 588 { |
589 if (m_fullScreenElementStack.isEmpty()) | 589 if (m_fullScreenElementStack.isEmpty()) |
590 return; | 590 return; |
591 | 591 |
592 m_fullScreenElementStack.removeLast(); | 592 m_fullScreenElementStack.removeLast(); |
593 } | 593 } |
594 | 594 |
595 void FullscreenElementStack::pushFullscreenElementStack(Element& element, Reques
tType requestType) | 595 void Fullscreen::pushFullscreenElementStack(Element& element, RequestType reques
tType) |
596 { | 596 { |
597 m_fullScreenElementStack.append(std::make_pair(&element, requestType)); | 597 m_fullScreenElementStack.append(std::make_pair(&element, requestType)); |
598 } | 598 } |
599 | 599 |
600 void FullscreenElementStack::trace(Visitor* visitor) | 600 void Fullscreen::trace(Visitor* visitor) |
601 { | 601 { |
602 visitor->trace(m_fullScreenElement); | 602 visitor->trace(m_fullScreenElement); |
603 visitor->trace(m_fullScreenElementStack); | 603 visitor->trace(m_fullScreenElementStack); |
604 visitor->trace(m_fullScreenRenderer); | 604 visitor->trace(m_fullScreenRenderer); |
605 visitor->trace(m_eventQueue); | 605 visitor->trace(m_eventQueue); |
606 DocumentSupplement::trace(visitor); | 606 DocumentSupplement::trace(visitor); |
607 } | 607 } |
608 | 608 |
609 } // namespace blink | 609 } // namespace blink |
OLD | NEW |