| 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 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 #include "HTMLNames.h" | 31 #include "HTMLNames.h" |
| 32 #include "core/dom/Document.h" | 32 #include "core/dom/Document.h" |
| 33 #include "core/events/Event.h" | 33 #include "core/events/Event.h" |
| 34 #include "core/frame/Frame.h" | 34 #include "core/frame/Frame.h" |
| 35 #include "core/frame/FrameHost.h" | 35 #include "core/frame/FrameHost.h" |
| 36 #include "core/frame/Settings.h" | 36 #include "core/frame/Settings.h" |
| 37 #include "core/html/HTMLFrameOwnerElement.h" | 37 #include "core/html/HTMLFrameOwnerElement.h" |
| 38 #include "core/page/Chrome.h" | 38 #include "core/page/Chrome.h" |
| 39 #include "core/page/ChromeClient.h" | 39 #include "core/page/ChromeClient.h" |
| 40 #include "core/rendering/RenderFullScreen.h" |
| 40 #include "platform/UserGestureIndicator.h" | 41 #include "platform/UserGestureIndicator.h" |
| 41 | 42 |
| 42 namespace WebCore { | 43 namespace WebCore { |
| 43 | 44 |
| 44 using namespace HTMLNames; | 45 using namespace HTMLNames; |
| 45 | 46 |
| 46 static bool isAttributeOnAllOwners(const WebCore::QualifiedName& attribute, cons
t WebCore::QualifiedName& prefixedAttribute, const HTMLFrameOwnerElement* owner) | 47 static bool isAttributeOnAllOwners(const WebCore::QualifiedName& attribute, cons
t WebCore::QualifiedName& prefixedAttribute, const HTMLFrameOwnerElement* owner) |
| 47 { | 48 { |
| 48 if (!owner) | 49 if (!owner) |
| 49 return true; | 50 return true; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 bool FullscreenElementStack::isFullScreen(Document* document) | 93 bool FullscreenElementStack::isFullScreen(Document* document) |
| 93 { | 94 { |
| 94 if (FullscreenElementStack* found = fromIfExists(document)) | 95 if (FullscreenElementStack* found = fromIfExists(document)) |
| 95 return found->webkitIsFullScreen(); | 96 return found->webkitIsFullScreen(); |
| 96 return false; | 97 return false; |
| 97 } | 98 } |
| 98 | 99 |
| 99 FullscreenElementStack::FullscreenElementStack(Document* document) | 100 FullscreenElementStack::FullscreenElementStack(Document* document) |
| 100 : DocumentLifecycleObserver(document) | 101 : DocumentLifecycleObserver(document) |
| 101 , m_areKeysEnabledInFullScreen(false) | 102 , m_areKeysEnabledInFullScreen(false) |
| 103 , m_fullScreenRenderer(0) |
| 102 , m_fullScreenChangeDelayTimer(this, &FullscreenElementStack::fullScreenChan
geDelayTimerFired) | 104 , m_fullScreenChangeDelayTimer(this, &FullscreenElementStack::fullScreenChan
geDelayTimerFired) |
| 103 { | 105 { |
| 104 document->setHasFullscreenElementStack(); | 106 document->setHasFullscreenElementStack(); |
| 105 } | 107 } |
| 106 | 108 |
| 107 FullscreenElementStack::~FullscreenElementStack() | 109 FullscreenElementStack::~FullscreenElementStack() |
| 108 { | 110 { |
| 109 } | 111 } |
| 110 | 112 |
| 111 inline Document* FullscreenElementStack::document() | 113 inline Document* FullscreenElementStack::document() |
| 112 { | 114 { |
| 113 return lifecycleContext(); | 115 return lifecycleContext(); |
| 114 } | 116 } |
| 115 | 117 |
| 116 void FullscreenElementStack::documentWasDetached() | 118 void FullscreenElementStack::documentWasDetached() |
| 117 { | 119 { |
| 118 m_fullScreenChangeEventTargetQueue.clear(); | 120 m_fullScreenChangeEventTargetQueue.clear(); |
| 119 m_fullScreenErrorEventTargetQueue.clear(); | 121 m_fullScreenErrorEventTargetQueue.clear(); |
| 122 |
| 123 if (m_fullScreenRenderer) |
| 124 setFullScreenRenderer(0); |
| 120 } | 125 } |
| 121 | 126 |
| 122 void FullscreenElementStack::documentWasDisposed() | 127 void FullscreenElementStack::documentWasDisposed() |
| 123 { | 128 { |
| 124 m_fullScreenElement = 0; | 129 m_fullScreenElement = 0; |
| 125 m_fullScreenElementStack.clear(); | 130 m_fullScreenElementStack.clear(); |
| 126 } | 131 } |
| 127 | 132 |
| 128 bool FullscreenElementStack::fullScreenIsAllowedForElement(Element* element) con
st | 133 bool FullscreenElementStack::fullScreenIsAllowedForElement(Element* element) con
st |
| 129 { | 134 { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 // "To fully exit fullscreen act as if the exitFullscreen() method was invok
ed on the top-level browsing | 257 // "To fully exit fullscreen act as if the exitFullscreen() method was invok
ed on the top-level browsing |
| 253 // context's document and subsequently empty that document's fullscreen elem
ent stack." | 258 // context's document and subsequently empty that document's fullscreen elem
ent stack." |
| 254 if (!fullscreenElementFrom(document()->topDocument())) | 259 if (!fullscreenElementFrom(document()->topDocument())) |
| 255 return; | 260 return; |
| 256 | 261 |
| 257 // To achieve that aim, remove all the elements from the top document's stac
k except for the first before | 262 // To achieve that aim, remove all the elements from the top document's stac
k except for the first before |
| 258 // calling webkitExitFullscreen(): | 263 // calling webkitExitFullscreen(): |
| 259 Vector<RefPtr<Element> > replacementFullscreenElementStack; | 264 Vector<RefPtr<Element> > replacementFullscreenElementStack; |
| 260 replacementFullscreenElementStack.append(fullscreenElementFrom(document()->t
opDocument())); | 265 replacementFullscreenElementStack.append(fullscreenElementFrom(document()->t
opDocument())); |
| 261 FullscreenElementStack* topFullscreenElementStack = from(document()->topDocu
ment()); | 266 FullscreenElementStack* topFullscreenElementStack = from(document()->topDocu
ment()); |
| 262 // FIXME: This will remove a modal full screen dialog from the top layer. | |
| 263 // We shouldn't have separate vectors for full screen element stack and top
layer. http://crbug.com/336704 | |
| 264 Vector<RefPtr<Element> >::iterator end = topFullscreenElementStack->m_fullSc
reenElementStack.end(); | |
| 265 for (Vector<RefPtr<Element> >::iterator iter = topFullscreenElementStack->m_
fullScreenElementStack.begin(); iter + 1 < end; ++iter) { | |
| 266 topFullscreenElementStack->document()->removeFromTopLayer(iter->get()); | |
| 267 } | |
| 268 topFullscreenElementStack->m_fullScreenElementStack.swap(replacementFullscre
enElementStack); | 267 topFullscreenElementStack->m_fullScreenElementStack.swap(replacementFullscre
enElementStack); |
| 269 topFullscreenElementStack->webkitExitFullscreen(); | 268 topFullscreenElementStack->webkitExitFullscreen(); |
| 270 } | 269 } |
| 271 | 270 |
| 272 void FullscreenElementStack::webkitExitFullscreen() | 271 void FullscreenElementStack::webkitExitFullscreen() |
| 273 { | 272 { |
| 274 // The exitFullscreen() method must run these steps: | 273 // The exitFullscreen() method must run these steps: |
| 275 | 274 |
| 276 // 1. Let doc be the context object. (i.e. "this") | 275 // 1. Let doc be the context object. (i.e. "this") |
| 277 Document* currentDoc = document(); | 276 Document* currentDoc = document(); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 | 351 |
| 353 void FullscreenElementStack::webkitWillEnterFullScreenForElement(Element* elemen
t) | 352 void FullscreenElementStack::webkitWillEnterFullScreenForElement(Element* elemen
t) |
| 354 { | 353 { |
| 355 ASSERT(element); | 354 ASSERT(element); |
| 356 if (!document()->isActive()) | 355 if (!document()->isActive()) |
| 357 return; | 356 return; |
| 358 | 357 |
| 359 ASSERT(document()->settings()); // If we're active we must have settings. | 358 ASSERT(document()->settings()); // If we're active we must have settings. |
| 360 ASSERT(document()->settings()->fullScreenEnabled()); | 359 ASSERT(document()->settings()->fullScreenEnabled()); |
| 361 | 360 |
| 361 if (m_fullScreenRenderer) |
| 362 m_fullScreenRenderer->unwrapRenderer(); |
| 363 |
| 362 m_fullScreenElement = element; | 364 m_fullScreenElement = element; |
| 363 document()->addToTopLayer(element); | 365 |
| 366 // Create a placeholder block for a the full-screen element, to keep the pag
e from reflowing |
| 367 // when the element is removed from the normal flow. Only do this for a Rend
erBox, as only |
| 368 // a box will have a frameRect. The placeholder will be created in setFullSc
reenRenderer() |
| 369 // during layout. |
| 370 RenderObject* renderer = m_fullScreenElement->renderer(); |
| 371 bool shouldCreatePlaceholder = renderer && renderer->isBox(); |
| 372 if (shouldCreatePlaceholder) { |
| 373 m_savedPlaceholderFrameRect = toRenderBox(renderer)->frameRect(); |
| 374 m_savedPlaceholderRenderStyle = RenderStyle::clone(renderer->style()); |
| 375 } |
| 376 |
| 377 if (m_fullScreenElement != document()->documentElement()) |
| 378 RenderFullScreen::wrapRenderer(renderer, renderer ? renderer->parent() :
0, document()); |
| 379 |
| 364 m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBou
ndaries(true); | 380 m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBou
ndaries(true); |
| 365 | 381 |
| 366 document()->recalcStyle(Force); | 382 document()->recalcStyle(Force); |
| 367 } | 383 } |
| 368 | 384 |
| 369 void FullscreenElementStack::webkitDidEnterFullScreenForElement(Element*) | 385 void FullscreenElementStack::webkitDidEnterFullScreenForElement(Element*) |
| 370 { | 386 { |
| 371 if (!m_fullScreenElement) | 387 if (!m_fullScreenElement) |
| 372 return; | 388 return; |
| 373 | 389 |
| 374 if (!document()->isActive()) | 390 if (!document()->isActive()) |
| 375 return; | 391 return; |
| 376 | 392 |
| 377 m_fullScreenElement->didBecomeFullscreenElement(); | 393 m_fullScreenElement->didBecomeFullscreenElement(); |
| 378 | 394 |
| 379 m_fullScreenChangeDelayTimer.startOneShot(0); | 395 m_fullScreenChangeDelayTimer.startOneShot(0); |
| 380 } | 396 } |
| 381 | 397 |
| 382 void FullscreenElementStack::webkitWillExitFullScreenForElement(Element*) | 398 void FullscreenElementStack::webkitWillExitFullScreenForElement(Element*) |
| 383 { | 399 { |
| 384 if (!m_fullScreenElement) | 400 if (!m_fullScreenElement) |
| 385 return; | 401 return; |
| 386 | 402 |
| 387 if (!document()->isActive()) | 403 if (!document()->isActive()) |
| 388 return; | 404 return; |
| 389 | 405 |
| 390 document()->removeFromTopLayer(m_fullScreenElement.get()); | |
| 391 m_fullScreenElement->willStopBeingFullscreenElement(); | 406 m_fullScreenElement->willStopBeingFullscreenElement(); |
| 392 } | 407 } |
| 393 | 408 |
| 394 void FullscreenElementStack::webkitDidExitFullScreenForElement(Element*) | 409 void FullscreenElementStack::webkitDidExitFullScreenForElement(Element*) |
| 395 { | 410 { |
| 396 if (!m_fullScreenElement) | 411 if (!m_fullScreenElement) |
| 397 return; | 412 return; |
| 398 | 413 |
| 399 if (!document()->isActive()) | 414 if (!document()->isActive()) |
| 400 return; | 415 return; |
| 401 | 416 |
| 402 m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBou
ndaries(false); | 417 m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBou
ndaries(false); |
| 403 | 418 |
| 404 m_areKeysEnabledInFullScreen = false; | 419 m_areKeysEnabledInFullScreen = false; |
| 405 | 420 |
| 421 if (m_fullScreenRenderer) |
| 422 m_fullScreenRenderer->unwrapRenderer(); |
| 423 |
| 406 m_fullScreenElement = 0; | 424 m_fullScreenElement = 0; |
| 407 document()->setNeedsStyleRecalc(); | 425 document()->setNeedsStyleRecalc(); |
| 408 | 426 |
| 409 // When webkitCancelFullScreen is called, we call webkitExitFullScreen on th
e topDocument(). That | 427 // When webkitCancelFullScreen is called, we call webkitExitFullScreen on th
e topDocument(). That |
| 410 // means that the events will be queued there. So if we have no events here,
start the timer on | 428 // means that the events will be queued there. So if we have no events here,
start the timer on |
| 411 // the exiting document. | 429 // the exiting document. |
| 412 Document* exitingDocument = document(); | 430 Document* exitingDocument = document(); |
| 413 if (m_fullScreenChangeEventTargetQueue.isEmpty() && m_fullScreenErrorEventTa
rgetQueue.isEmpty()) | 431 if (m_fullScreenChangeEventTargetQueue.isEmpty() && m_fullScreenErrorEventTa
rgetQueue.isEmpty()) |
| 414 exitingDocument = document()->topDocument(); | 432 exitingDocument = document()->topDocument(); |
| 415 from(exitingDocument)->m_fullScreenChangeDelayTimer.startOneShot(0); | 433 from(exitingDocument)->m_fullScreenChangeDelayTimer.startOneShot(0); |
| 416 } | 434 } |
| 417 | 435 |
| 436 void FullscreenElementStack::setFullScreenRenderer(RenderFullScreen* renderer) |
| 437 { |
| 438 if (renderer == m_fullScreenRenderer) |
| 439 return; |
| 440 |
| 441 if (renderer && m_savedPlaceholderRenderStyle) { |
| 442 renderer->createPlaceholder(m_savedPlaceholderRenderStyle.release(), m_s
avedPlaceholderFrameRect); |
| 443 } else if (renderer && m_fullScreenRenderer && m_fullScreenRenderer->placeho
lder()) { |
| 444 RenderBlock* placeholder = m_fullScreenRenderer->placeholder(); |
| 445 renderer->createPlaceholder(RenderStyle::clone(placeholder->style()), pl
aceholder->frameRect()); |
| 446 } |
| 447 |
| 448 if (m_fullScreenRenderer) |
| 449 m_fullScreenRenderer->destroy(); |
| 450 ASSERT(!m_fullScreenRenderer); |
| 451 |
| 452 m_fullScreenRenderer = renderer; |
| 453 } |
| 454 |
| 455 void FullscreenElementStack::fullScreenRendererDestroyed() |
| 456 { |
| 457 m_fullScreenRenderer = 0; |
| 458 } |
| 459 |
| 418 void FullscreenElementStack::fullScreenChangeDelayTimerFired(Timer<FullscreenEle
mentStack>*) | 460 void FullscreenElementStack::fullScreenChangeDelayTimerFired(Timer<FullscreenEle
mentStack>*) |
| 419 { | 461 { |
| 420 // Since we dispatch events in this function, it's possible that the | 462 // Since we dispatch events in this function, it's possible that the |
| 421 // document will be detached and GC'd. We protect it here to make sure we | 463 // document will be detached and GC'd. We protect it here to make sure we |
| 422 // can finish the function successfully. | 464 // can finish the function successfully. |
| 423 RefPtr<Document> protectDocument(document()); | 465 RefPtr<Document> protectDocument(document()); |
| 424 Deque<RefPtr<Node> > changeQueue; | 466 Deque<RefPtr<Node> > changeQueue; |
| 425 m_fullScreenChangeEventTargetQueue.swap(changeQueue); | 467 m_fullScreenChangeEventTargetQueue.swap(changeQueue); |
| 426 Deque<RefPtr<Node> > errorQueue; | 468 Deque<RefPtr<Node> > errorQueue; |
| 427 m_fullScreenErrorEventTargetQueue.swap(errorQueue); | 469 m_fullScreenErrorEventTargetQueue.swap(errorQueue); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 elementInSubtree = m_fullScreenElement->isDescendantOf(node); | 521 elementInSubtree = m_fullScreenElement->isDescendantOf(node); |
| 480 else | 522 else |
| 481 elementInSubtree = (m_fullScreenElement == node) || m_fullScreenElement-
>isDescendantOf(node); | 523 elementInSubtree = (m_fullScreenElement == node) || m_fullScreenElement-
>isDescendantOf(node); |
| 482 | 524 |
| 483 if (elementInSubtree) | 525 if (elementInSubtree) |
| 484 fullScreenElementRemoved(); | 526 fullScreenElementRemoved(); |
| 485 } | 527 } |
| 486 | 528 |
| 487 void FullscreenElementStack::clearFullscreenElementStack() | 529 void FullscreenElementStack::clearFullscreenElementStack() |
| 488 { | 530 { |
| 489 Vector<RefPtr<Element> >::iterator end = m_fullScreenElementStack.end(); | |
| 490 for (Vector<RefPtr<Element> >::iterator iter = m_fullScreenElementStack.begi
n(); iter != end; ++iter) | |
| 491 document()->removeFromTopLayer(iter->get()); | |
| 492 m_fullScreenElementStack.clear(); | 531 m_fullScreenElementStack.clear(); |
| 493 } | 532 } |
| 494 | 533 |
| 495 void FullscreenElementStack::popFullscreenElementStack() | 534 void FullscreenElementStack::popFullscreenElementStack() |
| 496 { | 535 { |
| 497 if (m_fullScreenElementStack.isEmpty()) | 536 if (m_fullScreenElementStack.isEmpty()) |
| 498 return; | 537 return; |
| 499 | 538 |
| 500 RefPtr<Element> element = m_fullScreenElementStack.last(); | |
| 501 m_fullScreenElementStack.removeLast(); | 539 m_fullScreenElementStack.removeLast(); |
| 502 document()->removeFromTopLayer(element.get()); | |
| 503 } | 540 } |
| 504 | 541 |
| 505 void FullscreenElementStack::pushFullscreenElementStack(Element* element) | 542 void FullscreenElementStack::pushFullscreenElementStack(Element* element) |
| 506 { | 543 { |
| 507 document()->addToTopLayer(element); | |
| 508 m_fullScreenElementStack.append(element); | 544 m_fullScreenElementStack.append(element); |
| 509 } | 545 } |
| 510 | 546 |
| 511 void FullscreenElementStack::addDocumentToFullScreenChangeEventQueue(Document* d
oc) | 547 void FullscreenElementStack::addDocumentToFullScreenChangeEventQueue(Document* d
oc) |
| 512 { | 548 { |
| 513 ASSERT(doc); | 549 ASSERT(doc); |
| 514 | 550 |
| 515 Node* target = 0; | 551 Node* target = 0; |
| 516 if (FullscreenElementStack* fullscreen = fromIfExists(doc)) { | 552 if (FullscreenElementStack* fullscreen = fromIfExists(doc)) { |
| 517 target = fullscreen->webkitFullscreenElement(); | 553 target = fullscreen->webkitFullscreenElement(); |
| 518 if (!target) | 554 if (!target) |
| 519 target = fullscreen->webkitCurrentFullScreenElement(); | 555 target = fullscreen->webkitCurrentFullScreenElement(); |
| 520 } | 556 } |
| 521 | 557 |
| 522 if (!target) | 558 if (!target) |
| 523 target = doc; | 559 target = doc; |
| 524 m_fullScreenChangeEventTargetQueue.append(target); | 560 m_fullScreenChangeEventTargetQueue.append(target); |
| 525 } | 561 } |
| 526 | 562 |
| 527 } // namespace WebCore | 563 } // namespace WebCore |
| OLD | NEW |