Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: third_party/WebKit/Source/core/dom/Fullscreen.cpp

Issue 1410833004: Revert "Implement FullScreen using top layer." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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"
32 #include "core/HTMLNames.h" 31 #include "core/HTMLNames.h"
33 #include "core/dom/Document.h" 32 #include "core/dom/Document.h"
34 #include "core/dom/ElementTraversal.h" 33 #include "core/dom/ElementTraversal.h"
35 #include "core/events/Event.h" 34 #include "core/events/Event.h"
36 #include "core/frame/FrameHost.h" 35 #include "core/frame/FrameHost.h"
37 #include "core/frame/LocalFrame.h" 36 #include "core/frame/LocalFrame.h"
38 #include "core/frame/OriginsUsingFeatures.h" 37 #include "core/frame/OriginsUsingFeatures.h"
39 #include "core/frame/Settings.h" 38 #include "core/frame/Settings.h"
40 #include "core/frame/UseCounter.h" 39 #include "core/frame/UseCounter.h"
41 #include "core/html/HTMLIFrameElement.h" 40 #include "core/html/HTMLIFrameElement.h"
42 #include "core/html/HTMLMediaElement.h" 41 #include "core/html/HTMLMediaElement.h"
43 #include "core/input/EventHandler.h" 42 #include "core/input/EventHandler.h"
44 #include "core/inspector/ConsoleMessage.h" 43 #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"
48 #include "platform/UserGestureIndicator.h" 46 #include "platform/UserGestureIndicator.h"
49 47
50 namespace blink { 48 namespace blink {
51 49
52 using namespace HTMLNames; 50 using namespace HTMLNames;
53 51
54 static bool fullscreenIsAllowedForAllOwners(const Document& document) 52 static bool fullscreenIsAllowedForAllOwners(const Document& document)
55 { 53 {
56 for (const Element* owner = document.ownerElement(); owner; owner = owner->d ocument().ownerElement()) { 54 for (const Element* owner = document.ownerElement(); owner; owner = owner->d ocument().ownerElement()) {
57 if (!isHTMLIFrameElement(owner)) 55 if (!isHTMLIFrameElement(owner))
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 return 0; 152 return 0;
155 } 153 }
156 154
157 bool Fullscreen::isFullScreen(Document& document) 155 bool Fullscreen::isFullScreen(Document& document)
158 { 156 {
159 return currentFullScreenElementFrom(document); 157 return currentFullScreenElementFrom(document);
160 } 158 }
161 159
162 Fullscreen::Fullscreen(Document& document) 160 Fullscreen::Fullscreen(Document& document)
163 : DocumentLifecycleObserver(&document) 161 : DocumentLifecycleObserver(&document)
162 , m_fullScreenLayoutObject(nullptr)
164 , m_eventQueueTimer(this, &Fullscreen::eventQueueTimerFired) 163 , m_eventQueueTimer(this, &Fullscreen::eventQueueTimerFired)
165 { 164 {
166 document.setHasFullscreenSupplement(); 165 document.setHasFullscreenSupplement();
167 } 166 }
168 167
169 Fullscreen::~Fullscreen() 168 Fullscreen::~Fullscreen()
170 { 169 {
171 } 170 }
172 171
173 inline Document* Fullscreen::document() 172 inline Document* Fullscreen::document()
174 { 173 {
175 return lifecycleContext(); 174 return lifecycleContext();
176 } 175 }
177 176
178 void Fullscreen::documentWasDetached() 177 void Fullscreen::documentWasDetached()
179 { 178 {
180 m_eventQueue.clear(); 179 m_eventQueue.clear();
181 180
181 if (m_fullScreenLayoutObject)
182 m_fullScreenLayoutObject->destroy();
183
182 #if ENABLE(OILPAN) 184 #if ENABLE(OILPAN)
183 m_fullScreenElement = nullptr; 185 m_fullScreenElement = nullptr;
184 m_fullScreenElementStack.clear(); 186 m_fullScreenElementStack.clear();
185 #endif 187 #endif
186 188
187 } 189 }
188 190
189 #if !ENABLE(OILPAN) 191 #if !ENABLE(OILPAN)
190 void Fullscreen::documentWasDisposed() 192 void Fullscreen::documentWasDisposed()
191 { 193 {
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 // 4. The fullscreenEnabled attribute must return true if the context object has its 418 // 4. The fullscreenEnabled attribute must return true if the context object has its
417 // fullscreen enabled flag set and fullscreen is supported, and false oth erwise. 419 // fullscreen enabled flag set and fullscreen is supported, and false oth erwise.
418 420
419 // Top-level browsing contexts are implied to have their allowFullScreen att ribute set. 421 // Top-level browsing contexts are implied to have their allowFullScreen att ribute set.
420 return fullscreenIsAllowedForAllOwners(document) && fullscreenIsSupported(do cument); 422 return fullscreenIsAllowedForAllOwners(document) && fullscreenIsSupported(do cument);
421 } 423 }
422 424
423 void Fullscreen::didEnterFullScreenForElement(Element* element) 425 void Fullscreen::didEnterFullScreenForElement(Element* element)
424 { 426 {
425 ASSERT(element); 427 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
431 m_fullScreenElement = element; 434 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
432 m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBou ndaries(true); 450 m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBou ndaries(true);
433 451
434 // FIXME: This should not call updateStyleIfNeeded. 452 // FIXME: This should not call updateStyleIfNeeded.
435 document()->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTrac ing::create(StyleChangeReason::FullScreen)); 453 document()->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTrac ing::create(StyleChangeReason::FullScreen));
436 document()->updateLayoutTreeIfNeeded(); 454 document()->updateLayoutTreeIfNeeded();
437 455
438 m_fullScreenElement->didBecomeFullscreenElement(); 456 m_fullScreenElement->didBecomeFullscreenElement();
439 457
440 if (document()->frame()) 458 if (document()->frame())
441 document()->frame()->eventHandler().scheduleHoverStateUpdate(); 459 document()->frame()->eventHandler().scheduleHoverStateUpdate();
442 460
443 m_eventQueueTimer.startOneShot(0, BLINK_FROM_HERE); 461 m_eventQueueTimer.startOneShot(0, BLINK_FROM_HERE);
444 } 462 }
445 463
446 void Fullscreen::didExitFullScreenForElement(Element*) 464 void Fullscreen::didExitFullScreenForElement(Element*)
447 { 465 {
448 if (!m_fullScreenElement) 466 if (!m_fullScreenElement)
449 return; 467 return;
450 468
451 if (!document()->isActive()) 469 if (!document()->isActive())
452 return; 470 return;
453 471
454 document()->removeFromTopLayer(m_fullScreenElement.get());
455 m_fullScreenElement->willStopBeingFullscreenElement(); 472 m_fullScreenElement->willStopBeingFullscreenElement();
456 473
457 m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBou ndaries(false); 474 m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBou ndaries(false);
458 475
476 if (m_fullScreenLayoutObject)
477 m_fullScreenLayoutObject->unwrapLayoutObject();
478
459 m_fullScreenElement = nullptr; 479 m_fullScreenElement = nullptr;
460 document()->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTrac ing::create(StyleChangeReason::FullScreen)); 480 document()->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTrac ing::create(StyleChangeReason::FullScreen));
461 481
462 if (document()->frame()) 482 if (document()->frame())
463 document()->frame()->eventHandler().scheduleHoverStateUpdate(); 483 document()->frame()->eventHandler().scheduleHoverStateUpdate();
464 484
465 // When fullyExitFullscreen is called, we call exitFullscreen on the topDocu ment(). That means 485 // When fullyExitFullscreen is called, we call exitFullscreen on the topDocu ment(). That means
466 // that the events will be queued there. So if we have no events here, start the timer on the 486 // that the events will be queued there. So if we have no events here, start the timer on the
467 // exiting document. 487 // exiting document.
468 Document* exitingDocument = document(); 488 Document* exitingDocument = document();
469 if (m_eventQueue.isEmpty()) 489 if (m_eventQueue.isEmpty())
470 exitingDocument = &document()->topDocument(); 490 exitingDocument = &document()->topDocument();
471 ASSERT(exitingDocument); 491 ASSERT(exitingDocument);
472 from(*exitingDocument).m_eventQueueTimer.startOneShot(0, BLINK_FROM_HERE); 492 from(*exitingDocument).m_eventQueueTimer.startOneShot(0, BLINK_FROM_HERE);
473 } 493 }
474 494
475 void Fullscreen::didUpdateSize(Element& element) 495 void Fullscreen::setFullScreenLayoutObject(LayoutFullScreen* layoutObject)
476 { 496 {
477 // StyleAdjuster will set the size so we need to do a style recalc. 497 if (layoutObject == m_fullScreenLayoutObject)
478 // Normally changing size means layout so just doing a style recalc is a 498 return;
479 // bit surprising. 499
480 element.setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::c reate(StyleChangeReason::FullScreen)); 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;
481 } 517 }
482 518
483 void Fullscreen::enqueueChangeEvent(Document& document, RequestType requestType) 519 void Fullscreen::enqueueChangeEvent(Document& document, RequestType requestType)
484 { 520 {
485 RefPtrWillBeRawPtr<Event> event; 521 RefPtrWillBeRawPtr<Event> event;
486 if (requestType == UnprefixedRequest) { 522 if (requestType == UnprefixedRequest) {
487 event = createEvent(EventTypeNames::fullscreenchange, document); 523 event = createEvent(EventTypeNames::fullscreenchange, document);
488 } else { 524 } else {
489 ASSERT(document.hasFullscreenSupplement()); 525 ASSERT(document.hasFullscreenSupplement());
490 Fullscreen& fullscreen = from(document); 526 Fullscreen& fullscreen = from(document);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 void Fullscreen::clearFullscreenElementStack() 595 void Fullscreen::clearFullscreenElementStack()
560 { 596 {
561 m_fullScreenElementStack.clear(); 597 m_fullScreenElementStack.clear();
562 } 598 }
563 599
564 void Fullscreen::popFullscreenElementStack() 600 void Fullscreen::popFullscreenElementStack()
565 { 601 {
566 if (m_fullScreenElementStack.isEmpty()) 602 if (m_fullScreenElementStack.isEmpty())
567 return; 603 return;
568 604
569 document()->removeFromTopLayer(m_fullScreenElementStack.last().first.get());
570 m_fullScreenElementStack.removeLast(); 605 m_fullScreenElementStack.removeLast();
571 } 606 }
572 607
573 void Fullscreen::pushFullscreenElementStack(Element& element, RequestType reques tType) 608 void Fullscreen::pushFullscreenElementStack(Element& element, RequestType reques tType)
574 { 609 {
575 m_fullScreenElementStack.append(std::make_pair(&element, requestType)); 610 m_fullScreenElementStack.append(std::make_pair(&element, requestType));
576 document()->addToTopLayer(&element);
577 } 611 }
578 612
579 DEFINE_TRACE(Fullscreen) 613 DEFINE_TRACE(Fullscreen)
580 { 614 {
581 #if ENABLE(OILPAN) 615 #if ENABLE(OILPAN)
582 visitor->trace(m_fullScreenElement); 616 visitor->trace(m_fullScreenElement);
583 visitor->trace(m_fullScreenElementStack); 617 visitor->trace(m_fullScreenElementStack);
584 visitor->trace(m_eventQueue); 618 visitor->trace(m_eventQueue);
585 #endif 619 #endif
586 WillBeHeapSupplement<Document>::trace(visitor); 620 WillBeHeapSupplement<Document>::trace(visitor);
587 DocumentLifecycleObserver::trace(visitor); 621 DocumentLifecycleObserver::trace(visitor);
588 } 622 }
589 623
590 } // namespace blink 624 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Fullscreen.h ('k') | third_party/WebKit/Source/core/dom/LayoutTreeBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698