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 10 matching lines...) Expand all Loading... |
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/Fullscreen.h" | 29 #include "core/dom/Fullscreen.h" |
30 | 30 |
| 31 #include "bindings/core/v8/ExceptionMessages.h" |
31 #include "core/HTMLNames.h" | 32 #include "core/HTMLNames.h" |
32 #include "core/dom/Document.h" | 33 #include "core/dom/Document.h" |
33 #include "core/dom/ElementTraversal.h" | 34 #include "core/dom/ElementTraversal.h" |
34 #include "core/events/Event.h" | 35 #include "core/events/Event.h" |
35 #include "core/frame/FrameHost.h" | 36 #include "core/frame/FrameHost.h" |
36 #include "core/frame/LocalFrame.h" | 37 #include "core/frame/LocalFrame.h" |
37 #include "core/frame/OriginsUsingFeatures.h" | 38 #include "core/frame/OriginsUsingFeatures.h" |
38 #include "core/frame/Settings.h" | 39 #include "core/frame/Settings.h" |
39 #include "core/frame/UseCounter.h" | 40 #include "core/frame/UseCounter.h" |
40 #include "core/html/HTMLIFrameElement.h" | 41 #include "core/html/HTMLIFrameElement.h" |
41 #include "core/html/HTMLMediaElement.h" | 42 #include "core/html/HTMLMediaElement.h" |
42 #include "core/input/EventHandler.h" | 43 #include "core/input/EventHandler.h" |
43 #include "core/inspector/ConsoleMessage.h" | 44 #include "core/inspector/ConsoleMessage.h" |
44 #include "core/layout/LayoutFullScreen.h" | |
45 #include "core/page/ChromeClient.h" | 45 #include "core/page/ChromeClient.h" |
| 46 #include "core/page/Page.h" |
| 47 #include "core/style/ComputedStyle.h" |
46 #include "platform/UserGestureIndicator.h" | 48 #include "platform/UserGestureIndicator.h" |
47 | 49 |
48 namespace blink { | 50 namespace blink { |
49 | 51 |
50 using namespace HTMLNames; | 52 using namespace HTMLNames; |
51 | 53 |
52 static bool fullscreenIsAllowedForAllOwners(const Document& document) | 54 static bool fullscreenIsAllowedForAllOwners(const Document& document) |
53 { | 55 { |
54 for (const Element* owner = document.ownerElement(); owner; owner = owner->d
ocument().ownerElement()) { | 56 for (const Element* owner = document.ownerElement(); owner; owner = owner->d
ocument().ownerElement()) { |
55 if (!isHTMLIFrameElement(owner)) | 57 if (!isHTMLIFrameElement(owner)) |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 return 0; | 154 return 0; |
153 } | 155 } |
154 | 156 |
155 bool Fullscreen::isFullScreen(Document& document) | 157 bool Fullscreen::isFullScreen(Document& document) |
156 { | 158 { |
157 return currentFullScreenElementFrom(document); | 159 return currentFullScreenElementFrom(document); |
158 } | 160 } |
159 | 161 |
160 Fullscreen::Fullscreen(Document& document) | 162 Fullscreen::Fullscreen(Document& document) |
161 : DocumentLifecycleObserver(&document) | 163 : DocumentLifecycleObserver(&document) |
162 , m_fullScreenLayoutObject(nullptr) | |
163 , m_eventQueueTimer(this, &Fullscreen::eventQueueTimerFired) | 164 , m_eventQueueTimer(this, &Fullscreen::eventQueueTimerFired) |
164 { | 165 { |
165 document.setHasFullscreenSupplement(); | 166 document.setHasFullscreenSupplement(); |
166 } | 167 } |
167 | 168 |
168 Fullscreen::~Fullscreen() | 169 Fullscreen::~Fullscreen() |
169 { | 170 { |
170 } | 171 } |
171 | 172 |
172 inline Document* Fullscreen::document() | 173 inline Document* Fullscreen::document() |
173 { | 174 { |
174 return lifecycleContext(); | 175 return lifecycleContext(); |
175 } | 176 } |
176 | 177 |
177 void Fullscreen::documentWasDetached() | 178 void Fullscreen::documentWasDetached() |
178 { | 179 { |
179 m_eventQueue.clear(); | 180 m_eventQueue.clear(); |
180 | 181 |
181 if (m_fullScreenLayoutObject) | |
182 m_fullScreenLayoutObject->destroy(); | |
183 | |
184 #if ENABLE(OILPAN) | 182 #if ENABLE(OILPAN) |
185 m_fullScreenElement = nullptr; | 183 m_fullScreenElement = nullptr; |
186 m_fullScreenElementStack.clear(); | 184 m_fullScreenElementStack.clear(); |
187 #endif | 185 #endif |
188 | 186 |
189 } | 187 } |
190 | 188 |
191 #if !ENABLE(OILPAN) | 189 #if !ENABLE(OILPAN) |
192 void Fullscreen::documentWasDisposed() | 190 void Fullscreen::documentWasDisposed() |
193 { | 191 { |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 // Top-level browsing contexts are implied to have their allowFullScreen att
ribute set. | 419 // Top-level browsing contexts are implied to have their allowFullScreen att
ribute set. |
422 return fullscreenIsAllowedForAllOwners(document) && fullscreenIsSupported(do
cument); | 420 return fullscreenIsAllowedForAllOwners(document) && fullscreenIsSupported(do
cument); |
423 } | 421 } |
424 | 422 |
425 void Fullscreen::didEnterFullScreenForElement(Element* element) | 423 void Fullscreen::didEnterFullScreenForElement(Element* element) |
426 { | 424 { |
427 ASSERT(element); | 425 ASSERT(element); |
428 if (!document()->isActive()) | 426 if (!document()->isActive()) |
429 return; | 427 return; |
430 | 428 |
431 if (m_fullScreenLayoutObject) | |
432 m_fullScreenLayoutObject->unwrapLayoutObject(); | |
433 | |
434 m_fullScreenElement = element; | 429 m_fullScreenElement = element; |
435 | 430 |
436 // Create a placeholder block for a the full-screen element, to keep the pag
e from reflowing | 431 // FIXME: Why can we get here without calling pushFullscreenElementStack? |
437 // when the element is removed from the normal flow. Only do this for a Layo
utBox, as only | 432 document()->addToTopLayer(m_fullScreenElement.get()); |
438 // a box will have a frameRect. The placeholder will be created in setFullSc
reenLayoutObject() | |
439 // during layout. | |
440 LayoutObject* layoutObject = m_fullScreenElement->layoutObject(); | |
441 bool shouldCreatePlaceholder = layoutObject && layoutObject->isBox(); | |
442 if (shouldCreatePlaceholder) { | |
443 m_savedPlaceholderFrameRect = toLayoutBox(layoutObject)->frameRect(); | |
444 m_savedPlaceholderComputedStyle = ComputedStyle::clone(layoutObject->sty
leRef()); | |
445 } | |
446 | |
447 if (m_fullScreenElement != document()->documentElement()) | |
448 LayoutFullScreen::wrapLayoutObject(layoutObject, layoutObject ? layoutOb
ject->parent() : 0, document()); | |
449 | |
450 m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBou
ndaries(true); | 433 m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBou
ndaries(true); |
451 | 434 |
452 // FIXME: This should not call updateStyleIfNeeded. | 435 // FIXME: This should not call updateStyleIfNeeded. |
453 document()->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTrac
ing::create(StyleChangeReason::FullScreen)); | 436 document()->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTrac
ing::create(StyleChangeReason::FullScreen)); |
454 document()->updateLayoutTreeIfNeeded(); | 437 document()->updateLayoutTreeIfNeeded(); |
455 | 438 |
456 m_fullScreenElement->didBecomeFullscreenElement(); | 439 m_fullScreenElement->didBecomeFullscreenElement(); |
457 | 440 |
458 if (document()->frame()) | 441 if (document()->frame()) |
459 document()->frame()->eventHandler().scheduleHoverStateUpdate(); | 442 document()->frame()->eventHandler().scheduleHoverStateUpdate(); |
460 | 443 |
461 m_eventQueueTimer.startOneShot(0, FROM_HERE); | 444 m_eventQueueTimer.startOneShot(0, FROM_HERE); |
462 } | 445 } |
463 | 446 |
464 void Fullscreen::didExitFullScreenForElement(Element*) | 447 void Fullscreen::didExitFullScreenForElement(Element*) |
465 { | 448 { |
466 if (!m_fullScreenElement) | 449 if (!m_fullScreenElement) |
467 return; | 450 return; |
468 | 451 |
469 if (!document()->isActive()) | 452 if (!document()->isActive()) |
470 return; | 453 return; |
471 | 454 |
| 455 document()->removeFromTopLayer(m_fullScreenElement.get()); |
472 m_fullScreenElement->willStopBeingFullscreenElement(); | 456 m_fullScreenElement->willStopBeingFullscreenElement(); |
473 | 457 |
474 m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBou
ndaries(false); | 458 m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBou
ndaries(false); |
475 | 459 |
476 if (m_fullScreenLayoutObject) | |
477 m_fullScreenLayoutObject->unwrapLayoutObject(); | |
478 | |
479 m_fullScreenElement = nullptr; | 460 m_fullScreenElement = nullptr; |
480 document()->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTrac
ing::create(StyleChangeReason::FullScreen)); | 461 document()->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTrac
ing::create(StyleChangeReason::FullScreen)); |
481 | 462 |
482 if (document()->frame()) | 463 if (document()->frame()) |
483 document()->frame()->eventHandler().scheduleHoverStateUpdate(); | 464 document()->frame()->eventHandler().scheduleHoverStateUpdate(); |
484 | 465 |
485 // When fullyExitFullscreen is called, we call exitFullscreen on the topDocu
ment(). That means | 466 // When fullyExitFullscreen is called, we call exitFullscreen on the topDocu
ment(). That means |
486 // that the events will be queued there. So if we have no events here, start
the timer on the | 467 // that the events will be queued there. So if we have no events here, start
the timer on the |
487 // exiting document. | 468 // exiting document. |
488 Document* exitingDocument = document(); | 469 Document* exitingDocument = document(); |
489 if (m_eventQueue.isEmpty()) | 470 if (m_eventQueue.isEmpty()) |
490 exitingDocument = &document()->topDocument(); | 471 exitingDocument = &document()->topDocument(); |
491 ASSERT(exitingDocument); | 472 ASSERT(exitingDocument); |
492 from(*exitingDocument).m_eventQueueTimer.startOneShot(0, FROM_HERE); | 473 from(*exitingDocument).m_eventQueueTimer.startOneShot(0, FROM_HERE); |
493 } | 474 } |
494 | 475 |
495 void Fullscreen::setFullScreenLayoutObject(LayoutFullScreen* layoutObject) | |
496 { | |
497 if (layoutObject == m_fullScreenLayoutObject) | |
498 return; | |
499 | |
500 if (layoutObject && m_savedPlaceholderComputedStyle) { | |
501 layoutObject->createPlaceholder(m_savedPlaceholderComputedStyle.release(
), m_savedPlaceholderFrameRect); | |
502 } else if (layoutObject && m_fullScreenLayoutObject && m_fullScreenLayoutObj
ect->placeholder()) { | |
503 LayoutBlock* placeholder = m_fullScreenLayoutObject->placeholder(); | |
504 layoutObject->createPlaceholder(ComputedStyle::clone(placeholder->styleR
ef()), placeholder->frameRect()); | |
505 } | |
506 | |
507 if (m_fullScreenLayoutObject) | |
508 m_fullScreenLayoutObject->unwrapLayoutObject(); | |
509 ASSERT(!m_fullScreenLayoutObject); | |
510 | |
511 m_fullScreenLayoutObject = layoutObject; | |
512 } | |
513 | |
514 void Fullscreen::fullScreenLayoutObjectDestroyed() | |
515 { | |
516 m_fullScreenLayoutObject = nullptr; | |
517 } | |
518 | |
519 void Fullscreen::enqueueChangeEvent(Document& document, RequestType requestType) | 476 void Fullscreen::enqueueChangeEvent(Document& document, RequestType requestType) |
520 { | 477 { |
521 RefPtrWillBeRawPtr<Event> event; | 478 RefPtrWillBeRawPtr<Event> event; |
522 if (requestType == UnprefixedRequest) { | 479 if (requestType == UnprefixedRequest) { |
523 event = createEvent(EventTypeNames::fullscreenchange, document); | 480 event = createEvent(EventTypeNames::fullscreenchange, document); |
524 } else { | 481 } else { |
525 ASSERT(document.hasFullscreenSupplement()); | 482 ASSERT(document.hasFullscreenSupplement()); |
526 Fullscreen& fullscreen = from(document); | 483 Fullscreen& fullscreen = from(document); |
527 EventTarget* target = fullscreen.fullscreenElement(); | 484 EventTarget* target = fullscreen.fullscreenElement(); |
528 if (!target) | 485 if (!target) |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 void Fullscreen::clearFullscreenElementStack() | 552 void Fullscreen::clearFullscreenElementStack() |
596 { | 553 { |
597 m_fullScreenElementStack.clear(); | 554 m_fullScreenElementStack.clear(); |
598 } | 555 } |
599 | 556 |
600 void Fullscreen::popFullscreenElementStack() | 557 void Fullscreen::popFullscreenElementStack() |
601 { | 558 { |
602 if (m_fullScreenElementStack.isEmpty()) | 559 if (m_fullScreenElementStack.isEmpty()) |
603 return; | 560 return; |
604 | 561 |
| 562 document()->removeFromTopLayer(m_fullScreenElementStack.last().first.get()); |
605 m_fullScreenElementStack.removeLast(); | 563 m_fullScreenElementStack.removeLast(); |
606 } | 564 } |
607 | 565 |
608 void Fullscreen::pushFullscreenElementStack(Element& element, RequestType reques
tType) | 566 void Fullscreen::pushFullscreenElementStack(Element& element, RequestType reques
tType) |
609 { | 567 { |
610 m_fullScreenElementStack.append(std::make_pair(&element, requestType)); | 568 m_fullScreenElementStack.append(std::make_pair(&element, requestType)); |
| 569 document()->addToTopLayer(&element); |
611 } | 570 } |
612 | 571 |
613 DEFINE_TRACE(Fullscreen) | 572 DEFINE_TRACE(Fullscreen) |
614 { | 573 { |
615 #if ENABLE(OILPAN) | 574 #if ENABLE(OILPAN) |
616 visitor->trace(m_fullScreenElement); | 575 visitor->trace(m_fullScreenElement); |
617 visitor->trace(m_fullScreenElementStack); | 576 visitor->trace(m_fullScreenElementStack); |
618 visitor->trace(m_eventQueue); | 577 visitor->trace(m_eventQueue); |
619 #endif | 578 #endif |
620 WillBeHeapSupplement<Document>::trace(visitor); | 579 WillBeHeapSupplement<Document>::trace(visitor); |
621 DocumentLifecycleObserver::trace(visitor); | 580 DocumentLifecycleObserver::trace(visitor); |
622 } | 581 } |
623 | 582 |
624 } // namespace blink | 583 } // namespace blink |
OLD | NEW |