Chromium Code Reviews| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 static bool fullscreenIsAllowedForAllOwners(const Document& document) | 54 static bool fullscreenIsAllowedForAllOwners(const Document& document) |
| 55 { | 55 { |
| 56 if (!document.frame()) | 56 if (!document.frame()) |
| 57 return false; | 57 return false; |
| 58 | 58 |
| 59 for (const Frame* frame = document.frame(); frame->owner(); frame = frame->t ree().parent()) { | 59 for (const Frame* frame = document.frame(); frame->owner(); frame = frame->t ree().parent()) { |
| 60 // TODO(alexmos): The allowfullscreen attribute will need to be | 60 // TODO(alexmos): The allowfullscreen attribute will need to be |
| 61 // replicated for this to work with OOPIFs. For now, deny fullscreen | 61 // replicated for this to work with OOPIFs. For now, deny fullscreen |
| 62 // access inside OOPIFs until https://crbug.com/550497 is fixed. | 62 // access inside OOPIFs until https://crbug.com/550497 is fixed. |
| 63 if (frame->owner()->isRemote()) | 63 if (frame->owner()->isRemote()) |
| 64 return false; | 64 return true; |
|
alexmos
2016/05/10 21:36:24
This will go away once I rebase on the allowFullsc
| |
| 65 | 65 |
| 66 HTMLFrameOwnerElement* owner = toHTMLFrameOwnerElement(frame->owner()); | 66 HTMLFrameOwnerElement* owner = toHTMLFrameOwnerElement(frame->owner()); |
| 67 if (!isHTMLIFrameElement(owner)) | 67 if (!isHTMLIFrameElement(owner)) |
| 68 return false; | 68 return false; |
| 69 if (!owner->hasAttribute(allowfullscreenAttr)) | 69 if (!owner->hasAttribute(allowfullscreenAttr)) |
| 70 return false; | 70 return false; |
| 71 } | 71 } |
| 72 return true; | 72 return true; |
| 73 } | 73 } |
| 74 | 74 |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 411 | 411 |
| 412 bool Fullscreen::fullscreenEnabled(Document& document) | 412 bool Fullscreen::fullscreenEnabled(Document& document) |
| 413 { | 413 { |
| 414 // 4. The fullscreenEnabled attribute must return true if the context object has its | 414 // 4. The fullscreenEnabled attribute must return true if the context object has its |
| 415 // fullscreen enabled flag set and fullscreen is supported, and false oth erwise. | 415 // fullscreen enabled flag set and fullscreen is supported, and false oth erwise. |
| 416 | 416 |
| 417 // Top-level browsing contexts are implied to have their allowFullScreen att ribute set. | 417 // Top-level browsing contexts are implied to have their allowFullScreen att ribute set. |
| 418 return fullscreenIsAllowedForAllOwners(document) && fullscreenIsSupported(do cument); | 418 return fullscreenIsAllowedForAllOwners(document) && fullscreenIsSupported(do cument); |
| 419 } | 419 } |
| 420 | 420 |
| 421 void Fullscreen::didEnterFullScreenForElement(Element* element) | 421 void Fullscreen::didEnterFullScreenForElement(Element* element, bool isAncestorO fFullscreenElement) |
| 422 { | 422 { |
| 423 DCHECK(element); | 423 DCHECK(element); |
| 424 if (!document()->isActive()) | 424 if (!document()->isActive()) |
| 425 return; | 425 return; |
| 426 | 426 |
| 427 if (m_fullScreenLayoutObject) | 427 if (m_fullScreenLayoutObject) |
| 428 m_fullScreenLayoutObject->unwrapLayoutObject(); | 428 m_fullScreenLayoutObject->unwrapLayoutObject(); |
| 429 | 429 |
| 430 m_fullScreenElement = element; | 430 m_fullScreenElement = element; |
| 431 | 431 |
| 432 // Create a placeholder block for a the full-screen element, to keep the pag e from reflowing | 432 // Create a placeholder block for a the full-screen element, to keep the pag e from reflowing |
| 433 // when the element is removed from the normal flow. Only do this for a Layo utBox, as only | 433 // when the element is removed from the normal flow. Only do this for a Layo utBox, as only |
| 434 // a box will have a frameRect. The placeholder will be created in setFullSc reenLayoutObject() | 434 // a box will have a frameRect. The placeholder will be created in setFullSc reenLayoutObject() |
| 435 // during layout. | 435 // during layout. |
| 436 LayoutObject* layoutObject = m_fullScreenElement->layoutObject(); | 436 LayoutObject* layoutObject = m_fullScreenElement->layoutObject(); |
| 437 bool shouldCreatePlaceholder = layoutObject && layoutObject->isBox(); | 437 bool shouldCreatePlaceholder = layoutObject && layoutObject->isBox(); |
| 438 if (shouldCreatePlaceholder) { | 438 if (shouldCreatePlaceholder) { |
| 439 m_savedPlaceholderFrameRect = toLayoutBox(layoutObject)->frameRect(); | 439 m_savedPlaceholderFrameRect = toLayoutBox(layoutObject)->frameRect(); |
| 440 m_savedPlaceholderComputedStyle = ComputedStyle::clone(layoutObject->sty leRef()); | 440 m_savedPlaceholderComputedStyle = ComputedStyle::clone(layoutObject->sty leRef()); |
| 441 } | 441 } |
| 442 | 442 |
| 443 // TODO(alexmos): When |isAncestorOfFullscreenElement| is true, some of | |
| 444 // this layout work has already been done in another process, so it should | |
| 445 // not be necessary to repeat it here. | |
|
alexmos
2016/05/10 21:36:24
Namely, the wrapLayoutObject call and stuff in Lay
| |
| 443 if (m_fullScreenElement != document()->documentElement()) | 446 if (m_fullScreenElement != document()->documentElement()) |
| 444 LayoutFullScreen::wrapLayoutObject(layoutObject, layoutObject ? layoutOb ject->parent() : 0, document()); | 447 LayoutFullScreen::wrapLayoutObject(layoutObject, layoutObject ? layoutOb ject->parent() : 0, document()); |
| 445 | 448 |
| 449 if (isAncestorOfFullscreenElement) { | |
| 450 DCHECK(m_fullScreenElement->isFrameOwnerElement()); | |
| 451 DCHECK(toHTMLFrameOwnerElement(m_fullScreenElement)->contentFrame()->isR emoteFrame()); | |
| 452 m_fullScreenElement->setContainsFullScreenElement(true); | |
| 453 } | |
| 454 | |
| 446 m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBou ndaries(true); | 455 m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBou ndaries(true); |
| 456 | |
| 447 document()->styleEngine().ensureFullscreenUAStyle(); | 457 document()->styleEngine().ensureFullscreenUAStyle(); |
| 448 m_fullScreenElement->pseudoStateChanged(CSSSelector::PseudoFullScreen); | 458 m_fullScreenElement->pseudoStateChanged(CSSSelector::PseudoFullScreen); |
| 449 | 459 |
| 450 // FIXME: This should not call updateLayoutTree. | 460 // FIXME: This should not call updateLayoutTree. |
| 451 document()->updateLayoutTree(); | 461 document()->updateLayoutTree(); |
| 452 | 462 |
| 453 m_fullScreenElement->didBecomeFullscreenElement(); | 463 m_fullScreenElement->didBecomeFullscreenElement(); |
| 454 | 464 |
| 455 if (document()->frame()) | 465 if (document()->frame()) |
| 456 document()->frame()->eventHandler().scheduleHoverStateUpdate(); | 466 document()->frame()->eventHandler().scheduleHoverStateUpdate(); |
| 457 | 467 |
| 458 m_eventQueueTimer.startOneShot(0, BLINK_FROM_HERE); | 468 m_eventQueueTimer.startOneShot(0, BLINK_FROM_HERE); |
| 459 } | 469 } |
| 460 | 470 |
| 461 void Fullscreen::didExitFullScreenForElement(Element*) | 471 void Fullscreen::didExitFullScreenForElement(bool isAncestorOfFullscreenElement) |
| 462 { | 472 { |
| 463 if (!m_fullScreenElement) | 473 if (!m_fullScreenElement) |
| 464 return; | 474 return; |
| 465 | 475 |
| 466 if (!document()->isActive()) | 476 if (!document()->isActive()) |
| 467 return; | 477 return; |
| 468 | 478 |
| 469 m_fullScreenElement->willStopBeingFullscreenElement(); | 479 m_fullScreenElement->willStopBeingFullscreenElement(); |
| 470 | 480 |
| 481 if (isAncestorOfFullscreenElement) | |
| 482 m_fullScreenElement->setContainsFullScreenElement(false); | |
| 483 | |
| 471 m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBou ndaries(false); | 484 m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBou ndaries(false); |
| 472 | 485 |
| 473 if (m_fullScreenLayoutObject) | 486 if (m_fullScreenLayoutObject) |
| 474 LayoutFullScreenItem(m_fullScreenLayoutObject).unwrapLayoutObject(); | 487 LayoutFullScreenItem(m_fullScreenLayoutObject).unwrapLayoutObject(); |
| 475 | 488 |
| 476 document()->styleEngine().ensureFullscreenUAStyle(); | 489 document()->styleEngine().ensureFullscreenUAStyle(); |
| 477 m_fullScreenElement->pseudoStateChanged(CSSSelector::PseudoFullScreen); | 490 m_fullScreenElement->pseudoStateChanged(CSSSelector::PseudoFullScreen); |
| 478 m_fullScreenElement = nullptr; | 491 m_fullScreenElement = nullptr; |
| 479 | 492 |
| 480 if (document()->frame()) | 493 if (document()->frame()) |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 607 DEFINE_TRACE(Fullscreen) | 620 DEFINE_TRACE(Fullscreen) |
| 608 { | 621 { |
| 609 visitor->trace(m_fullScreenElement); | 622 visitor->trace(m_fullScreenElement); |
| 610 visitor->trace(m_fullScreenElementStack); | 623 visitor->trace(m_fullScreenElementStack); |
| 611 visitor->trace(m_eventQueue); | 624 visitor->trace(m_eventQueue); |
| 612 Supplement<Document>::trace(visitor); | 625 Supplement<Document>::trace(visitor); |
| 613 ContextLifecycleObserver::trace(visitor); | 626 ContextLifecycleObserver::trace(visitor); |
| 614 } | 627 } |
| 615 | 628 |
| 616 } // namespace blink | 629 } // namespace blink |
| OLD | NEW |