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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
418 // 4. The fullscreenEnabled attribute must return true if the context object has its | 416 // 4. The fullscreenEnabled attribute must return true if the context object has its |
419 // fullscreen enabled flag set and fullscreen is supported, and false oth erwise. | 417 // fullscreen enabled flag set and fullscreen is supported, and false oth erwise. |
420 | 418 |
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); |
426 ASSERT(element->isInTopLayer()); | |
427 | |
428 if (!document()->isActive()) | 428 if (!document()->isActive()) |
429 return; | 429 return; |
430 | 430 |
431 if (m_fullScreenLayoutObject) | |
432 m_fullScreenLayoutObject->unwrapLayoutObject(); | |
433 | |
434 m_fullScreenElement = element; | 431 m_fullScreenElement = element; |
435 | |
436 // Create a placeholder block for a the full-screen element, to keep the pag e from reflowing | |
437 // when the element is removed from the normal flow. Only do this for a Layo utBox, as only | |
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); | 432 m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBou ndaries(true); |
451 | 433 |
452 // FIXME: This should not call updateStyleIfNeeded. | 434 // FIXME: This should not call updateStyleIfNeeded. |
453 document()->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTrac ing::create(StyleChangeReason::FullScreen)); | 435 document()->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTrac ing::create(StyleChangeReason::FullScreen)); |
454 document()->updateLayoutTreeIfNeeded(); | 436 document()->updateLayoutTreeIfNeeded(); |
455 | 437 |
456 m_fullScreenElement->didBecomeFullscreenElement(); | 438 m_fullScreenElement->didBecomeFullscreenElement(); |
457 | 439 |
458 if (document()->frame()) | 440 if (document()->frame()) |
459 document()->frame()->eventHandler().scheduleHoverStateUpdate(); | 441 document()->frame()->eventHandler().scheduleHoverStateUpdate(); |
460 | 442 |
461 m_eventQueueTimer.startOneShot(0, FROM_HERE); | 443 m_eventQueueTimer.startOneShot(0, FROM_HERE); |
462 } | 444 } |
463 | 445 |
464 void Fullscreen::didExitFullScreenForElement(Element*) | 446 void Fullscreen::didExitFullScreenForElement(Element*) |
465 { | 447 { |
466 if (!m_fullScreenElement) | 448 if (!m_fullScreenElement) |
467 return; | 449 return; |
468 | 450 |
469 if (!document()->isActive()) | 451 if (!document()->isActive()) |
470 return; | 452 return; |
471 | 453 |
454 document()->removeFromTopLayer(m_fullScreenElement.get()); | |
472 m_fullScreenElement->willStopBeingFullscreenElement(); | 455 m_fullScreenElement->willStopBeingFullscreenElement(); |
473 | 456 |
474 m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBou ndaries(false); | 457 m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBou ndaries(false); |
475 | 458 |
476 if (m_fullScreenLayoutObject) | |
477 m_fullScreenLayoutObject->unwrapLayoutObject(); | |
478 | |
479 m_fullScreenElement = nullptr; | 459 m_fullScreenElement = nullptr; |
480 document()->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTrac ing::create(StyleChangeReason::FullScreen)); | 460 document()->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTrac ing::create(StyleChangeReason::FullScreen)); |
481 | 461 |
482 if (document()->frame()) | 462 if (document()->frame()) |
483 document()->frame()->eventHandler().scheduleHoverStateUpdate(); | 463 document()->frame()->eventHandler().scheduleHoverStateUpdate(); |
484 | 464 |
485 // When fullyExitFullscreen is called, we call exitFullscreen on the topDocu ment(). That means | 465 // 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 | 466 // that the events will be queued there. So if we have no events here, start the timer on the |
487 // exiting document. | 467 // exiting document. |
488 Document* exitingDocument = document(); | 468 Document* exitingDocument = document(); |
489 if (m_eventQueue.isEmpty()) | 469 if (m_eventQueue.isEmpty()) |
490 exitingDocument = &document()->topDocument(); | 470 exitingDocument = &document()->topDocument(); |
491 ASSERT(exitingDocument); | 471 ASSERT(exitingDocument); |
492 from(*exitingDocument).m_eventQueueTimer.startOneShot(0, FROM_HERE); | 472 from(*exitingDocument).m_eventQueueTimer.startOneShot(0, FROM_HERE); |
493 } | 473 } |
494 | 474 |
495 void Fullscreen::setFullScreenLayoutObject(LayoutFullScreen* layoutObject) | 475 void Fullscreen::didUpdateSize(Element& element) |
496 { | 476 { |
497 if (layoutObject == m_fullScreenLayoutObject) | 477 element.setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::c reate(StyleChangeReason::FullScreen)); |
esprehn
2015/10/09 10:34:00
Add a comment like, StyleAdjuster will set the siz
dsinclair
2015/10/13 15:50:43
Done.
| |
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 } | 478 } |
518 | 479 |
519 void Fullscreen::enqueueChangeEvent(Document& document, RequestType requestType) | 480 void Fullscreen::enqueueChangeEvent(Document& document, RequestType requestType) |
520 { | 481 { |
521 RefPtrWillBeRawPtr<Event> event; | 482 RefPtrWillBeRawPtr<Event> event; |
522 if (requestType == UnprefixedRequest) { | 483 if (requestType == UnprefixedRequest) { |
523 event = createEvent(EventTypeNames::fullscreenchange, document); | 484 event = createEvent(EventTypeNames::fullscreenchange, document); |
524 } else { | 485 } else { |
525 ASSERT(document.hasFullscreenSupplement()); | 486 ASSERT(document.hasFullscreenSupplement()); |
526 Fullscreen& fullscreen = from(document); | 487 Fullscreen& fullscreen = from(document); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
595 void Fullscreen::clearFullscreenElementStack() | 556 void Fullscreen::clearFullscreenElementStack() |
596 { | 557 { |
597 m_fullScreenElementStack.clear(); | 558 m_fullScreenElementStack.clear(); |
598 } | 559 } |
599 | 560 |
600 void Fullscreen::popFullscreenElementStack() | 561 void Fullscreen::popFullscreenElementStack() |
601 { | 562 { |
602 if (m_fullScreenElementStack.isEmpty()) | 563 if (m_fullScreenElementStack.isEmpty()) |
603 return; | 564 return; |
604 | 565 |
566 document()->removeFromTopLayer(m_fullScreenElementStack.last().first.get()); | |
605 m_fullScreenElementStack.removeLast(); | 567 m_fullScreenElementStack.removeLast(); |
606 } | 568 } |
607 | 569 |
608 void Fullscreen::pushFullscreenElementStack(Element& element, RequestType reques tType) | 570 void Fullscreen::pushFullscreenElementStack(Element& element, RequestType reques tType) |
609 { | 571 { |
610 m_fullScreenElementStack.append(std::make_pair(&element, requestType)); | 572 m_fullScreenElementStack.append(std::make_pair(&element, requestType)); |
573 document()->addToTopLayer(&element); | |
611 } | 574 } |
612 | 575 |
613 DEFINE_TRACE(Fullscreen) | 576 DEFINE_TRACE(Fullscreen) |
614 { | 577 { |
615 #if ENABLE(OILPAN) | 578 #if ENABLE(OILPAN) |
616 visitor->trace(m_fullScreenElement); | 579 visitor->trace(m_fullScreenElement); |
617 visitor->trace(m_fullScreenElementStack); | 580 visitor->trace(m_fullScreenElementStack); |
618 visitor->trace(m_eventQueue); | 581 visitor->trace(m_eventQueue); |
619 #endif | 582 #endif |
620 WillBeHeapSupplement<Document>::trace(visitor); | 583 WillBeHeapSupplement<Document>::trace(visitor); |
621 DocumentLifecycleObserver::trace(visitor); | 584 DocumentLifecycleObserver::trace(visitor); |
622 } | 585 } |
623 | 586 |
624 } // namespace blink | 587 } // namespace blink |
OLD | NEW |