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

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

Issue 2168373002: Revert of Reland "Implement FullScreen using top layer." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: resolve WebFrameTest.cpp conflict and appease presubmit Created 4 years, 5 months 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 *
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 "core/dom/Fullscreen.h" 28 #include "core/dom/Fullscreen.h"
29 29
30 #include "bindings/core/v8/ExceptionMessages.h"
31 #include "core/HTMLNames.h" 30 #include "core/HTMLNames.h"
32 #include "core/dom/Document.h" 31 #include "core/dom/Document.h"
33 #include "core/dom/ElementTraversal.h" 32 #include "core/dom/ElementTraversal.h"
34 #include "core/dom/StyleChangeReason.h" 33 #include "core/dom/StyleChangeReason.h"
35 #include "core/dom/StyleEngine.h" 34 #include "core/dom/StyleEngine.h"
36 #include "core/events/Event.h" 35 #include "core/events/Event.h"
37 #include "core/frame/FrameHost.h" 36 #include "core/frame/FrameHost.h"
38 #include "core/frame/HostsUsingFeatures.h" 37 #include "core/frame/HostsUsingFeatures.h"
39 #include "core/frame/LocalFrame.h" 38 #include "core/frame/LocalFrame.h"
40 #include "core/frame/Settings.h" 39 #include "core/frame/Settings.h"
41 #include "core/frame/UseCounter.h" 40 #include "core/frame/UseCounter.h"
42 #include "core/html/HTMLIFrameElement.h" 41 #include "core/html/HTMLIFrameElement.h"
43 #include "core/html/HTMLMediaElement.h" 42 #include "core/html/HTMLMediaElement.h"
44 #include "core/input/EventHandler.h" 43 #include "core/input/EventHandler.h"
45 #include "core/inspector/ConsoleMessage.h" 44 #include "core/inspector/ConsoleMessage.h"
45 #include "core/layout/LayoutBlockFlow.h"
46 #include "core/layout/LayoutFullScreen.h"
47 #include "core/layout/api/LayoutFullScreenItem.h"
46 #include "core/page/ChromeClient.h" 48 #include "core/page/ChromeClient.h"
47 #include "core/page/Page.h"
48 #include "core/style/ComputedStyle.h"
49 #include "platform/UserGestureIndicator.h" 49 #include "platform/UserGestureIndicator.h"
50 50
51 namespace blink { 51 namespace blink {
52 52
53 using namespace HTMLNames; 53 using namespace HTMLNames;
54 54
55 namespace { 55 namespace {
56 56
57 bool fullscreenIsAllowedForAllOwners(const Document& document) 57 bool fullscreenIsAllowedForAllOwners(const Document& document)
58 { 58 {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 return 0; 189 return 0;
190 } 190 }
191 191
192 bool Fullscreen::isFullScreen(Document& document) 192 bool Fullscreen::isFullScreen(Document& document)
193 { 193 {
194 return currentFullScreenElementFrom(document); 194 return currentFullScreenElementFrom(document);
195 } 195 }
196 196
197 Fullscreen::Fullscreen(Document& document) 197 Fullscreen::Fullscreen(Document& document)
198 : ContextLifecycleObserver(&document) 198 : ContextLifecycleObserver(&document)
199 , m_fullScreenLayoutObject(nullptr)
199 , m_eventQueueTimer(this, &Fullscreen::eventQueueTimerFired) 200 , m_eventQueueTimer(this, &Fullscreen::eventQueueTimerFired)
200 , m_forCrossProcessDescendant(false) 201 , m_forCrossProcessDescendant(false)
201 { 202 {
202 document.setHasFullscreenSupplement(); 203 document.setHasFullscreenSupplement();
203 } 204 }
204 205
205 Fullscreen::~Fullscreen() 206 Fullscreen::~Fullscreen()
206 { 207 {
207 } 208 }
208 209
209 inline Document* Fullscreen::document() 210 inline Document* Fullscreen::document()
210 { 211 {
211 return toDocument(lifecycleContext()); 212 return toDocument(lifecycleContext());
212 } 213 }
213 214
214 void Fullscreen::contextDestroyed() 215 void Fullscreen::contextDestroyed()
215 { 216 {
216 m_eventQueue.clear(); 217 m_eventQueue.clear();
217 218
219 if (m_fullScreenLayoutObject)
220 m_fullScreenLayoutObject->destroy();
221
218 m_fullScreenElement = nullptr; 222 m_fullScreenElement = nullptr;
219 m_fullScreenElementStack.clear(); 223 m_fullScreenElementStack.clear();
220 224
221 } 225 }
222 226
223 void Fullscreen::requestFullscreen(Element& element, RequestType requestType, bo ol forCrossProcessDescendant) 227 void Fullscreen::requestFullscreen(Element& element, RequestType requestType, bo ol forCrossProcessDescendant)
224 { 228 {
225 // Use counters only need to be incremented in the process of the actual 229 // Use counters only need to be incremented in the process of the actual
226 // fullscreen element. 230 // fullscreen element.
227 if (!forCrossProcessDescendant) { 231 if (!forCrossProcessDescendant) {
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 // 4. The fullscreenEnabled attribute must return true if the context object has its 479 // 4. The fullscreenEnabled attribute must return true if the context object has its
476 // fullscreen enabled flag set and fullscreen is supported, and false oth erwise. 480 // fullscreen enabled flag set and fullscreen is supported, and false oth erwise.
477 481
478 // Top-level browsing contexts are implied to have their allowFullScreen att ribute set. 482 // Top-level browsing contexts are implied to have their allowFullScreen att ribute set.
479 return fullscreenIsAllowedForAllOwners(document) && fullscreenIsSupported(do cument); 483 return fullscreenIsAllowedForAllOwners(document) && fullscreenIsSupported(do cument);
480 } 484 }
481 485
482 void Fullscreen::didEnterFullscreenForElement(Element* element) 486 void Fullscreen::didEnterFullscreenForElement(Element* element)
483 { 487 {
484 DCHECK(element); 488 DCHECK(element);
485 DCHECK(element->isInTopLayer());
486
487 if (!document()->isActive()) 489 if (!document()->isActive())
488 return; 490 return;
489 491
492 if (m_fullScreenLayoutObject)
493 m_fullScreenLayoutObject->unwrapLayoutObject();
494
490 m_fullScreenElement = element; 495 m_fullScreenElement = element;
491 496
497 // Create a placeholder block for a the full-screen element, to keep the pag e from reflowing
498 // when the element is removed from the normal flow. Only do this for a Layo utBox, as only
499 // a box will have a frameRect. The placeholder will be created in setFullSc reenLayoutObject()
500 // during layout.
501 LayoutObject* layoutObject = m_fullScreenElement->layoutObject();
502 bool shouldCreatePlaceholder = layoutObject && layoutObject->isBox();
503 if (shouldCreatePlaceholder) {
504 m_savedPlaceholderFrameRect = toLayoutBox(layoutObject)->frameRect();
505 m_savedPlaceholderComputedStyle = ComputedStyle::clone(layoutObject->sty leRef());
506 }
507
508 // TODO(alexmos): When |m_forCrossProcessDescendant| is true, some of
509 // this layout work has already been done in another process, so it should
510 // not be necessary to repeat it here.
511 if (m_fullScreenElement != document()->documentElement())
512 LayoutFullScreen::wrapLayoutObject(layoutObject, layoutObject ? layoutOb ject->parent() : 0, document());
513
492 // When |m_forCrossProcessDescendant| is true, m_fullScreenElement 514 // When |m_forCrossProcessDescendant| is true, m_fullScreenElement
493 // corresponds to the HTMLFrameOwnerElement for the out-of-process iframe 515 // corresponds to the HTMLFrameOwnerElement for the out-of-process iframe
494 // that contains the actual fullscreen element. Hence, it must also set 516 // that contains the actual fullscreen element. Hence, it must also set
495 // the ContainsFullScreenElement flag (so that it gains the 517 // the ContainsFullScreenElement flag (so that it gains the
496 // -webkit-full-screen-ancestor style). 518 // -webkit-full-screen-ancestor style).
497 if (m_forCrossProcessDescendant) { 519 if (m_forCrossProcessDescendant) {
498 DCHECK(m_fullScreenElement->isFrameOwnerElement()); 520 DCHECK(m_fullScreenElement->isFrameOwnerElement());
499 DCHECK(toHTMLFrameOwnerElement(m_fullScreenElement)->contentFrame()->isR emoteFrame()); 521 DCHECK(toHTMLFrameOwnerElement(m_fullScreenElement)->contentFrame()->isR emoteFrame());
500 m_fullScreenElement->setContainsFullScreenElement(true); 522 m_fullScreenElement->setContainsFullScreenElement(true);
501 } 523 }
(...skipping 15 matching lines...) Expand all
517 } 539 }
518 540
519 void Fullscreen::didExitFullscreen() 541 void Fullscreen::didExitFullscreen()
520 { 542 {
521 if (!m_fullScreenElement) 543 if (!m_fullScreenElement)
522 return; 544 return;
523 545
524 if (!document()->isActive()) 546 if (!document()->isActive())
525 return; 547 return;
526 548
527 document()->removeFromTopLayer(m_fullScreenElement.get());
528 m_fullScreenElement->willStopBeingFullscreenElement(); 549 m_fullScreenElement->willStopBeingFullscreenElement();
529 550
530 if (m_forCrossProcessDescendant) 551 if (m_forCrossProcessDescendant)
531 m_fullScreenElement->setContainsFullScreenElement(false); 552 m_fullScreenElement->setContainsFullScreenElement(false);
532 553
533 m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBou ndaries(false); 554 m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBou ndaries(false);
534 555
556 if (m_fullScreenLayoutObject)
557 LayoutFullScreenItem(m_fullScreenLayoutObject).unwrapLayoutObject();
558
535 document()->styleEngine().ensureFullscreenUAStyle(); 559 document()->styleEngine().ensureFullscreenUAStyle();
536 m_fullScreenElement->pseudoStateChanged(CSSSelector::PseudoFullScreen); 560 m_fullScreenElement->pseudoStateChanged(CSSSelector::PseudoFullScreen);
537 m_fullScreenElement = nullptr; 561 m_fullScreenElement = nullptr;
538 562
539 if (document()->frame()) 563 if (document()->frame())
540 document()->frame()->eventHandler().scheduleHoverStateUpdate(); 564 document()->frame()->eventHandler().scheduleHoverStateUpdate();
541 565
542 // When fullyExitFullscreen is called, we call exitFullscreen on the topDocu ment(). That means 566 // When fullyExitFullscreen is called, we call exitFullscreen on the topDocu ment(). That means
543 // that the events will be queued there. So if we have no events here, start the timer on the 567 // that the events will be queued there. So if we have no events here, start the timer on the
544 // exiting document. 568 // exiting document.
545 Document* exitingDocument = document(); 569 Document* exitingDocument = document();
546 if (m_eventQueue.isEmpty()) 570 if (m_eventQueue.isEmpty())
547 exitingDocument = &topmostLocalAncestor(*document()); 571 exitingDocument = &topmostLocalAncestor(*document());
548 DCHECK(exitingDocument); 572 DCHECK(exitingDocument);
549 from(*exitingDocument).m_eventQueueTimer.startOneShot(0, BLINK_FROM_HERE); 573 from(*exitingDocument).m_eventQueueTimer.startOneShot(0, BLINK_FROM_HERE);
550 574
551 m_forCrossProcessDescendant = false; 575 m_forCrossProcessDescendant = false;
552 } 576 }
553 577
554 void Fullscreen::didUpdateSize(Element& element) 578 void Fullscreen::setFullScreenLayoutObject(LayoutFullScreen* layoutObject)
555 { 579 {
556 // StyleAdjuster will set the size so we need to do a style recalc. 580 if (layoutObject == m_fullScreenLayoutObject)
557 // Normally changing size means layout so just doing a style recalc is a 581 return;
558 // bit surprising. 582
559 element.setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::c reate(StyleChangeReason::FullScreen)); 583 if (layoutObject && m_savedPlaceholderComputedStyle) {
584 layoutObject->createPlaceholder(m_savedPlaceholderComputedStyle.release( ), m_savedPlaceholderFrameRect);
585 } else if (layoutObject && m_fullScreenLayoutObject && m_fullScreenLayoutObj ect->placeholder()) {
586 LayoutBlockFlow* placeholder = m_fullScreenLayoutObject->placeholder();
587 layoutObject->createPlaceholder(ComputedStyle::clone(placeholder->styleR ef()), placeholder->frameRect());
588 }
589
590 if (m_fullScreenLayoutObject)
591 m_fullScreenLayoutObject->unwrapLayoutObject();
592 DCHECK(!m_fullScreenLayoutObject);
593
594 m_fullScreenLayoutObject = layoutObject;
595 }
596
597 void Fullscreen::fullScreenLayoutObjectDestroyed()
598 {
599 m_fullScreenLayoutObject = nullptr;
560 } 600 }
561 601
562 void Fullscreen::enqueueChangeEvent(Document& document, RequestType requestType) 602 void Fullscreen::enqueueChangeEvent(Document& document, RequestType requestType)
563 { 603 {
564 Event* event; 604 Event* event;
565 if (requestType == UnprefixedRequest) { 605 if (requestType == UnprefixedRequest) {
566 event = createEvent(EventTypeNames::fullscreenchange, document); 606 event = createEvent(EventTypeNames::fullscreenchange, document);
567 } else { 607 } else {
568 DCHECK(document.hasFullscreenSupplement()); 608 DCHECK(document.hasFullscreenSupplement());
569 Fullscreen& fullscreen = from(document); 609 Fullscreen& fullscreen = from(document);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 void Fullscreen::clearFullscreenElementStack() 674 void Fullscreen::clearFullscreenElementStack()
635 { 675 {
636 m_fullScreenElementStack.clear(); 676 m_fullScreenElementStack.clear();
637 } 677 }
638 678
639 void Fullscreen::popFullscreenElementStack() 679 void Fullscreen::popFullscreenElementStack()
640 { 680 {
641 if (m_fullScreenElementStack.isEmpty()) 681 if (m_fullScreenElementStack.isEmpty())
642 return; 682 return;
643 683
644 document()->removeFromTopLayer(m_fullScreenElementStack.last().first.get());
645 m_fullScreenElementStack.removeLast(); 684 m_fullScreenElementStack.removeLast();
646 } 685 }
647 686
648 void Fullscreen::pushFullscreenElementStack(Element& element, RequestType reques tType) 687 void Fullscreen::pushFullscreenElementStack(Element& element, RequestType reques tType)
649 { 688 {
650 m_fullScreenElementStack.append(std::make_pair(&element, requestType)); 689 m_fullScreenElementStack.append(std::make_pair(&element, requestType));
651 document()->addToTopLayer(&element);
652 } 690 }
653 691
654 DEFINE_TRACE(Fullscreen) 692 DEFINE_TRACE(Fullscreen)
655 { 693 {
656 visitor->trace(m_fullScreenElement); 694 visitor->trace(m_fullScreenElement);
657 visitor->trace(m_fullScreenElementStack); 695 visitor->trace(m_fullScreenElementStack);
658 visitor->trace(m_eventQueue); 696 visitor->trace(m_eventQueue);
659 Supplement<Document>::trace(visitor); 697 Supplement<Document>::trace(visitor);
660 ContextLifecycleObserver::trace(visitor); 698 ContextLifecycleObserver::trace(visitor);
661 } 699 }
662 700
663 } // namespace blink 701 } // 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