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" |
34 #include "core/dom/ElementTraversal.h" | |
33 #include "core/events/Event.h" | 35 #include "core/events/Event.h" |
34 #include "core/frame/FrameHost.h" | 36 #include "core/frame/FrameHost.h" |
35 #include "core/frame/LocalFrame.h" | 37 #include "core/frame/LocalFrame.h" |
36 #include "core/frame/Settings.h" | 38 #include "core/frame/Settings.h" |
37 #include "core/frame/UseCounter.h" | 39 #include "core/frame/UseCounter.h" |
38 #include "core/html/HTMLIFrameElement.h" | 40 #include "core/html/HTMLIFrameElement.h" |
39 #include "core/html/HTMLMediaElement.h" | 41 #include "core/html/HTMLMediaElement.h" |
40 #include "core/page/Chrome.h" | 42 #include "core/page/Chrome.h" |
41 #include "core/page/ChromeClient.h" | 43 #include "core/page/ChromeClient.h" |
42 #include "core/page/EventHandler.h" | 44 #include "core/page/EventHandler.h" |
43 #include "core/rendering/RenderFullScreen.h" | 45 #include "core/page/Page.h" |
46 #include "core/rendering/RenderObject.h" | |
47 #include "core/rendering/style/RenderStyle.h" | |
44 #include "platform/UserGestureIndicator.h" | 48 #include "platform/UserGestureIndicator.h" |
45 | 49 |
46 namespace blink { | 50 namespace blink { |
47 | 51 |
48 using namespace HTMLNames; | 52 using namespace HTMLNames; |
49 | 53 |
50 static bool fullscreenIsAllowedForAllOwners(const Document& document) | 54 static bool fullscreenIsAllowedForAllOwners(const Document& document) |
51 { | 55 { |
52 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()) { |
53 if (!isHTMLIFrameElement(owner)) | 57 if (!isHTMLIFrameElement(owner)) |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
154 return 0; | 158 return 0; |
155 } | 159 } |
156 | 160 |
157 bool Fullscreen::isFullScreen(Document& document) | 161 bool Fullscreen::isFullScreen(Document& document) |
158 { | 162 { |
159 return currentFullScreenElementFrom(document); | 163 return currentFullScreenElementFrom(document); |
160 } | 164 } |
161 | 165 |
162 Fullscreen::Fullscreen(Document& document) | 166 Fullscreen::Fullscreen(Document& document) |
163 : DocumentLifecycleObserver(&document) | 167 : DocumentLifecycleObserver(&document) |
164 , m_fullScreenRenderer(nullptr) | |
165 , m_eventQueueTimer(this, &Fullscreen::eventQueueTimerFired) | 168 , m_eventQueueTimer(this, &Fullscreen::eventQueueTimerFired) |
166 { | 169 { |
167 document.setHasFullscreenSupplement(); | 170 document.setHasFullscreenSupplement(); |
168 } | 171 } |
169 | 172 |
170 Fullscreen::~Fullscreen() | 173 Fullscreen::~Fullscreen() |
171 { | 174 { |
172 } | 175 } |
173 | 176 |
174 inline Document* Fullscreen::document() | 177 inline Document* Fullscreen::document() |
175 { | 178 { |
176 return lifecycleContext(); | 179 return lifecycleContext(); |
177 } | 180 } |
178 | 181 |
179 void Fullscreen::documentWasDetached() | 182 void Fullscreen::documentWasDetached() |
180 { | 183 { |
181 m_eventQueue.clear(); | 184 m_eventQueue.clear(); |
182 | 185 |
183 if (m_fullScreenRenderer) | |
184 m_fullScreenRenderer->destroy(); | |
185 | |
186 #if ENABLE(OILPAN) | 186 #if ENABLE(OILPAN) |
187 m_fullScreenElement = nullptr; | 187 m_fullScreenElement = nullptr; |
188 m_fullScreenElementStack.clear(); | 188 m_fullScreenElementStack.clear(); |
189 #endif | 189 #endif |
190 | 190 |
191 } | 191 } |
192 | 192 |
193 #if !ENABLE(OILPAN) | 193 #if !ENABLE(OILPAN) |
194 void Fullscreen::documentWasDisposed() | 194 void Fullscreen::documentWasDisposed() |
195 { | 195 { |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
412 // Top-level browsing contexts are implied to have their allowFullScreen att ribute set. | 412 // Top-level browsing contexts are implied to have their allowFullScreen att ribute set. |
413 return fullscreenIsAllowedForAllOwners(document) && fullscreenIsSupported(do cument); | 413 return fullscreenIsAllowedForAllOwners(document) && fullscreenIsSupported(do cument); |
414 } | 414 } |
415 | 415 |
416 void Fullscreen::didEnterFullScreenForElement(Element* element) | 416 void Fullscreen::didEnterFullScreenForElement(Element* element) |
417 { | 417 { |
418 ASSERT(element); | 418 ASSERT(element); |
419 if (!document()->isActive()) | 419 if (!document()->isActive()) |
420 return; | 420 return; |
421 | 421 |
422 if (m_fullScreenRenderer) | |
423 m_fullScreenRenderer->unwrapRenderer(); | |
424 | |
425 m_fullScreenElement = element; | 422 m_fullScreenElement = element; |
426 | 423 |
427 // Create a placeholder block for a the full-screen element, to keep the pag e from reflowing | 424 // FIXME: Why can we get here without calling pushFullscreenElementStack? |
philipj_slow
2015/02/12 08:19:16
Not sure, but possibly it's when Chromium toggles
| |
428 // when the element is removed from the normal flow. Only do this for a Rend erBox, as only | 425 document()->addToTopLayer(m_fullScreenElement.get()); |
429 // a box will have a frameRect. The placeholder will be created in setFullSc reenRenderer() | |
430 // during layout. | |
431 RenderObject* renderer = m_fullScreenElement->renderer(); | |
432 bool shouldCreatePlaceholder = renderer && renderer->isBox(); | |
433 if (shouldCreatePlaceholder) { | |
434 m_savedPlaceholderFrameRect = toRenderBox(renderer)->frameRect(); | |
435 m_savedPlaceholderRenderStyle = RenderStyle::clone(renderer->style()); | |
436 } | |
437 | |
438 if (m_fullScreenElement != document()->documentElement()) | |
439 RenderFullScreen::wrapRenderer(renderer, renderer ? renderer->parent() : 0, document()); | |
440 | |
441 m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBou ndaries(true); | 426 m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBou ndaries(true); |
442 | 427 |
443 // FIXME: This should not call updateStyleIfNeeded. | 428 // FIXME: This should not call updateStyleIfNeeded. |
444 document()->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTrac ing::create(StyleChangeReason::FullScreen)); | 429 document()->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTrac ing::create(StyleChangeReason::FullScreen)); |
445 document()->updateRenderTreeIfNeeded(); | 430 document()->updateRenderTreeIfNeeded(); |
446 | 431 |
447 m_fullScreenElement->didBecomeFullscreenElement(); | 432 m_fullScreenElement->didBecomeFullscreenElement(); |
448 | 433 |
449 if (document()->frame()) | 434 if (document()->frame()) |
450 document()->frame()->eventHandler().scheduleHoverStateUpdate(); | 435 document()->frame()->eventHandler().scheduleHoverStateUpdate(); |
451 | 436 |
452 m_eventQueueTimer.startOneShot(0, FROM_HERE); | 437 m_eventQueueTimer.startOneShot(0, FROM_HERE); |
453 } | 438 } |
454 | 439 |
455 void Fullscreen::didExitFullScreenForElement(Element*) | 440 void Fullscreen::didExitFullScreenForElement(Element*) |
456 { | 441 { |
457 if (!m_fullScreenElement) | 442 if (!m_fullScreenElement) |
458 return; | 443 return; |
459 | 444 |
460 if (!document()->isActive()) | 445 if (!document()->isActive()) |
461 return; | 446 return; |
462 | 447 |
448 document()->removeFromTopLayer(m_fullScreenElement.get()); | |
463 m_fullScreenElement->willStopBeingFullscreenElement(); | 449 m_fullScreenElement->willStopBeingFullscreenElement(); |
464 | 450 |
465 m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBou ndaries(false); | 451 m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBou ndaries(false); |
466 | 452 |
467 if (m_fullScreenRenderer) | |
468 m_fullScreenRenderer->unwrapRenderer(); | |
469 | |
470 m_fullScreenElement = nullptr; | 453 m_fullScreenElement = nullptr; |
471 document()->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTrac ing::create(StyleChangeReason::FullScreen)); | 454 document()->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTrac ing::create(StyleChangeReason::FullScreen)); |
472 | 455 |
473 if (document()->frame()) | 456 if (document()->frame()) |
474 document()->frame()->eventHandler().scheduleHoverStateUpdate(); | 457 document()->frame()->eventHandler().scheduleHoverStateUpdate(); |
475 | 458 |
476 // When fullyExitFullscreen is called, we call exitFullscreen on the topDocu ment(). That means | 459 // When fullyExitFullscreen is called, we call exitFullscreen on the topDocu ment(). That means |
477 // that the events will be queued there. So if we have no events here, start the timer on the | 460 // that the events will be queued there. So if we have no events here, start the timer on the |
478 // exiting document. | 461 // exiting document. |
479 Document* exitingDocument = document(); | 462 Document* exitingDocument = document(); |
480 if (m_eventQueue.isEmpty()) | 463 if (m_eventQueue.isEmpty()) |
481 exitingDocument = &document()->topDocument(); | 464 exitingDocument = &document()->topDocument(); |
482 ASSERT(exitingDocument); | 465 ASSERT(exitingDocument); |
483 from(*exitingDocument).m_eventQueueTimer.startOneShot(0, FROM_HERE); | 466 from(*exitingDocument).m_eventQueueTimer.startOneShot(0, FROM_HERE); |
484 } | 467 } |
485 | 468 |
486 void Fullscreen::setFullScreenRenderer(RenderFullScreen* renderer) | |
487 { | |
488 if (renderer == m_fullScreenRenderer) | |
489 return; | |
490 | |
491 if (renderer && m_savedPlaceholderRenderStyle) { | |
492 renderer->createPlaceholder(m_savedPlaceholderRenderStyle.release(), m_s avedPlaceholderFrameRect); | |
493 } else if (renderer && m_fullScreenRenderer && m_fullScreenRenderer->placeho lder()) { | |
494 RenderBlock* placeholder = m_fullScreenRenderer->placeholder(); | |
495 renderer->createPlaceholder(RenderStyle::clone(placeholder->style()), pl aceholder->frameRect()); | |
496 } | |
497 | |
498 if (m_fullScreenRenderer) | |
499 m_fullScreenRenderer->unwrapRenderer(); | |
500 ASSERT(!m_fullScreenRenderer); | |
501 | |
502 m_fullScreenRenderer = renderer; | |
503 } | |
504 | |
505 void Fullscreen::fullScreenRendererDestroyed() | |
506 { | |
507 m_fullScreenRenderer = nullptr; | |
508 } | |
509 | |
510 void Fullscreen::enqueueChangeEvent(Document& document, RequestType requestType) | 469 void Fullscreen::enqueueChangeEvent(Document& document, RequestType requestType) |
511 { | 470 { |
512 RefPtrWillBeRawPtr<Event> event; | 471 RefPtrWillBeRawPtr<Event> event; |
513 if (requestType == UnprefixedRequest) { | 472 if (requestType == UnprefixedRequest) { |
514 event = createEvent(EventTypeNames::fullscreenchange, document); | 473 event = createEvent(EventTypeNames::fullscreenchange, document); |
515 } else { | 474 } else { |
516 ASSERT(document.hasFullscreenSupplement()); | 475 ASSERT(document.hasFullscreenSupplement()); |
517 Fullscreen& fullscreen = from(document); | 476 Fullscreen& fullscreen = from(document); |
518 EventTarget* target = fullscreen.fullscreenElement(); | 477 EventTarget* target = fullscreen.fullscreenElement(); |
519 if (!target) | 478 if (!target) |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
586 void Fullscreen::clearFullscreenElementStack() | 545 void Fullscreen::clearFullscreenElementStack() |
587 { | 546 { |
588 m_fullScreenElementStack.clear(); | 547 m_fullScreenElementStack.clear(); |
589 } | 548 } |
590 | 549 |
591 void Fullscreen::popFullscreenElementStack() | 550 void Fullscreen::popFullscreenElementStack() |
592 { | 551 { |
593 if (m_fullScreenElementStack.isEmpty()) | 552 if (m_fullScreenElementStack.isEmpty()) |
594 return; | 553 return; |
595 | 554 |
555 document()->removeFromTopLayer(m_fullScreenElementStack.last().first.get()); | |
596 m_fullScreenElementStack.removeLast(); | 556 m_fullScreenElementStack.removeLast(); |
597 } | 557 } |
598 | 558 |
599 void Fullscreen::pushFullscreenElementStack(Element& element, RequestType reques tType) | 559 void Fullscreen::pushFullscreenElementStack(Element& element, RequestType reques tType) |
600 { | 560 { |
601 m_fullScreenElementStack.append(std::make_pair(&element, requestType)); | 561 m_fullScreenElementStack.append(std::make_pair(&element, requestType)); |
562 document()->addToTopLayer(&element); | |
602 } | 563 } |
603 | 564 |
604 void Fullscreen::trace(Visitor* visitor) | 565 void Fullscreen::trace(Visitor* visitor) |
605 { | 566 { |
606 visitor->trace(m_fullScreenElement); | 567 visitor->trace(m_fullScreenElement); |
607 visitor->trace(m_fullScreenElementStack); | 568 visitor->trace(m_fullScreenElementStack); |
608 visitor->trace(m_fullScreenRenderer); | |
609 visitor->trace(m_eventQueue); | 569 visitor->trace(m_eventQueue); |
610 DocumentSupplement::trace(visitor); | 570 DocumentSupplement::trace(visitor); |
611 } | 571 } |
612 | 572 |
613 } // namespace blink | 573 } // namespace blink |
OLD | NEW |