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 21 matching lines...) Expand all Loading... | |
32 #include "bindings/v8/ScriptController.h" | 32 #include "bindings/v8/ScriptController.h" |
33 #include "core/dom/Document.h" | 33 #include "core/dom/Document.h" |
34 #include "core/dom/Element.h" | 34 #include "core/dom/Element.h" |
35 #include "core/dom/Event.h" | 35 #include "core/dom/Event.h" |
36 #include "core/html/HTMLFrameOwnerElement.h" | 36 #include "core/html/HTMLFrameOwnerElement.h" |
37 #include "core/page/Chrome.h" | 37 #include "core/page/Chrome.h" |
38 #include "core/page/ChromeClient.h" | 38 #include "core/page/ChromeClient.h" |
39 #include "core/page/Frame.h" | 39 #include "core/page/Frame.h" |
40 #include "core/page/Page.h" | 40 #include "core/page/Page.h" |
41 #include "core/page/Settings.h" | 41 #include "core/page/Settings.h" |
42 #include "core/rendering/RenderFullScreen.h" | |
43 | 42 |
44 namespace WebCore { | 43 namespace WebCore { |
45 | 44 |
46 using namespace HTMLNames; | 45 using namespace HTMLNames; |
47 | 46 |
48 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) |
49 { | 48 { |
50 if (!owner) | 49 if (!owner) |
51 return true; | 50 return true; |
52 do { | 51 do { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 bool FullscreenController::isFullScreen(Document* document) | 93 bool FullscreenController::isFullScreen(Document* document) |
95 { | 94 { |
96 if (FullscreenController* found = fromIfExists(document)) | 95 if (FullscreenController* found = fromIfExists(document)) |
97 return found->webkitIsFullScreen(); | 96 return found->webkitIsFullScreen(); |
98 return false; | 97 return false; |
99 } | 98 } |
100 | 99 |
101 FullscreenController::FullscreenController(Document* document) | 100 FullscreenController::FullscreenController(Document* document) |
102 : DocumentLifecycleObserver(document) | 101 : DocumentLifecycleObserver(document) |
103 , m_areKeysEnabledInFullScreen(false) | 102 , m_areKeysEnabledInFullScreen(false) |
104 , m_fullScreenRenderer(0) | |
105 , m_fullScreenChangeDelayTimer(this, &FullscreenController::fullScreenChange DelayTimerFired) | 103 , m_fullScreenChangeDelayTimer(this, &FullscreenController::fullScreenChange DelayTimerFired) |
106 { | 104 { |
107 document->setHasFullscreenController(); | 105 document->setHasFullscreenController(); |
108 } | 106 } |
109 | 107 |
110 FullscreenController::~FullscreenController() | 108 FullscreenController::~FullscreenController() |
111 { | 109 { |
112 } | 110 } |
113 | 111 |
114 inline Document* FullscreenController::document() | 112 inline Document* FullscreenController::document() |
115 { | 113 { |
116 return toDocument(scriptExecutionContext()); | 114 return toDocument(scriptExecutionContext()); |
117 } | 115 } |
118 | 116 |
119 void FullscreenController::documentWasDetached() | 117 void FullscreenController::documentWasDetached() |
120 { | 118 { |
121 m_fullScreenChangeEventTargetQueue.clear(); | 119 m_fullScreenChangeEventTargetQueue.clear(); |
122 m_fullScreenErrorEventTargetQueue.clear(); | 120 m_fullScreenErrorEventTargetQueue.clear(); |
123 | |
124 if (m_fullScreenRenderer) | |
125 setFullScreenRenderer(0); | |
126 } | 121 } |
127 | 122 |
128 void FullscreenController::documentWasDisposed() | 123 void FullscreenController::documentWasDisposed() |
129 { | 124 { |
130 m_fullScreenElement = 0; | 125 m_fullScreenElement = 0; |
131 m_fullScreenElementStack.clear(); | 126 m_fullScreenElementStack.clear(); |
132 } | 127 } |
133 | 128 |
134 bool FullscreenController::fullScreenIsAllowedForElement(Element* element) const | 129 bool FullscreenController::fullScreenIsAllowedForElement(Element* element) const |
135 { | 130 { |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
354 if (!document()->attached()) | 349 if (!document()->attached()) |
355 return; | 350 return; |
356 | 351 |
357 ASSERT(element); | 352 ASSERT(element); |
358 | 353 |
359 // Protect against being called after the document has been removed from the page. | 354 // Protect against being called after the document has been removed from the page. |
360 if (!document()->page()) | 355 if (!document()->page()) |
361 return; | 356 return; |
362 | 357 |
363 ASSERT(document()->page()->settings()->fullScreenEnabled()); | 358 ASSERT(document()->page()->settings()->fullScreenEnabled()); |
364 | |
365 if (m_fullScreenRenderer) | |
366 m_fullScreenRenderer->unwrapRenderer(); | |
367 | |
368 m_fullScreenElement = element; | 359 m_fullScreenElement = element; |
360 document()->addToTopLayer(element); | |
369 | 361 |
370 #if USE(NATIVE_FULLSCREEN_VIDEO) | 362 #if USE(NATIVE_FULLSCREEN_VIDEO) |
371 if (element && element->isMediaElement()) | 363 if (element && element->isMediaElement()) |
372 return; | 364 return; |
373 #endif | 365 #endif |
374 | 366 |
375 // Create a placeholder block for a the full-screen element, to keep the pag e from reflowing | |
376 // when the element is removed from the normal flow. Only do this for a Rend erBox, as only | |
377 // a box will have a frameRect. The placeholder will be created in setFullSc reenRenderer() | |
378 // during layout. | |
379 RenderObject* renderer = m_fullScreenElement->renderer(); | |
380 bool shouldCreatePlaceholder = renderer && renderer->isBox(); | |
381 if (shouldCreatePlaceholder) { | |
382 m_savedPlaceholderFrameRect = toRenderBox(renderer)->frameRect(); | |
383 m_savedPlaceholderRenderStyle = RenderStyle::clone(renderer->style()); | |
384 } | |
trchen
2013/07/18 22:26:29
I'm not sure how Document::addToTopLayer() works,
falken
2013/07/22 17:51:44
Yes, I think so. I thought we should remove it sin
| |
385 | |
386 if (m_fullScreenElement != document()->documentElement()) | |
387 RenderFullScreen::wrapRenderer(renderer, renderer ? renderer->parent() : 0, document()); | |
388 | |
389 m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBou ndaries(true); | 367 m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBou ndaries(true); |
390 | |
391 document()->recalcStyle(Node::Force); | |
falken
2013/07/09 12:50:22
I think this recalcStyle was a quirk needed for Re
| |
392 } | 368 } |
393 | 369 |
394 void FullscreenController::webkitDidEnterFullScreenForElement(Element*) | 370 void FullscreenController::webkitDidEnterFullScreenForElement(Element*) |
395 { | 371 { |
396 if (!m_fullScreenElement) | 372 if (!m_fullScreenElement) |
397 return; | 373 return; |
398 | 374 |
399 if (!document()->attached()) | 375 if (!document()->attached()) |
400 return; | 376 return; |
401 | 377 |
402 m_fullScreenElement->didBecomeFullscreenElement(); | 378 m_fullScreenElement->didBecomeFullscreenElement(); |
403 | 379 |
404 m_fullScreenChangeDelayTimer.startOneShot(0); | 380 m_fullScreenChangeDelayTimer.startOneShot(0); |
405 } | 381 } |
406 | 382 |
407 void FullscreenController::webkitWillExitFullScreenForElement(Element*) | 383 void FullscreenController::webkitWillExitFullScreenForElement(Element*) |
408 { | 384 { |
409 if (!m_fullScreenElement) | 385 if (!m_fullScreenElement) |
410 return; | 386 return; |
411 | 387 |
412 if (!document()->attached()) | 388 if (!document()->attached()) |
413 return; | 389 return; |
414 | 390 |
391 document()->removeFromTopLayer(m_fullScreenElement.get()); | |
415 m_fullScreenElement->willStopBeingFullscreenElement(); | 392 m_fullScreenElement->willStopBeingFullscreenElement(); |
416 } | 393 } |
417 | 394 |
418 void FullscreenController::webkitDidExitFullScreenForElement(Element*) | 395 void FullscreenController::webkitDidExitFullScreenForElement(Element*) |
419 { | 396 { |
420 if (!m_fullScreenElement) | 397 if (!m_fullScreenElement) |
421 return; | 398 return; |
422 | 399 |
423 if (!document()->attached()) | 400 if (!document()->attached()) |
424 return; | 401 return; |
425 | 402 |
426 m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBou ndaries(false); | 403 m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBou ndaries(false); |
427 | |
428 m_areKeysEnabledInFullScreen = false; | 404 m_areKeysEnabledInFullScreen = false; |
429 | 405 |
430 if (m_fullScreenRenderer) | |
431 m_fullScreenRenderer->unwrapRenderer(); | |
432 | |
433 m_fullScreenElement = 0; | 406 m_fullScreenElement = 0; |
434 document()->scheduleForcedStyleRecalc(); | 407 document()->scheduleForcedStyleRecalc(); |
435 | 408 |
436 // When webkitCancelFullScreen is called, we call webkitExitFullScreen on th e topDocument(). That | 409 // When webkitCancelFullScreen is called, we call webkitExitFullScreen on th e topDocument(). That |
437 // means that the events will be queued there. So if we have no events here, start the timer on | 410 // means that the events will be queued there. So if we have no events here, start the timer on |
438 // the exiting document. | 411 // the exiting document. |
439 Document* exitingDocument = document(); | 412 Document* exitingDocument = document(); |
440 if (m_fullScreenChangeEventTargetQueue.isEmpty() && m_fullScreenErrorEventTa rgetQueue.isEmpty()) | 413 if (m_fullScreenChangeEventTargetQueue.isEmpty() && m_fullScreenErrorEventTa rgetQueue.isEmpty()) |
441 exitingDocument = document()->topDocument(); | 414 exitingDocument = document()->topDocument(); |
442 from(exitingDocument)->m_fullScreenChangeDelayTimer.startOneShot(0); | 415 from(exitingDocument)->m_fullScreenChangeDelayTimer.startOneShot(0); |
443 } | 416 } |
444 | 417 |
445 void FullscreenController::setFullScreenRenderer(RenderFullScreen* renderer) | |
446 { | |
447 if (renderer == m_fullScreenRenderer) | |
448 return; | |
449 | |
450 if (renderer && m_savedPlaceholderRenderStyle) { | |
451 renderer->createPlaceholder(m_savedPlaceholderRenderStyle.release(), m_s avedPlaceholderFrameRect); | |
452 } else if (renderer && m_fullScreenRenderer && m_fullScreenRenderer->placeho lder()) { | |
453 RenderBlock* placeholder = m_fullScreenRenderer->placeholder(); | |
454 renderer->createPlaceholder(RenderStyle::clone(placeholder->style()), pl aceholder->frameRect()); | |
455 } | |
456 | |
457 if (m_fullScreenRenderer) | |
458 m_fullScreenRenderer->destroy(); | |
459 ASSERT(!m_fullScreenRenderer); | |
460 | |
461 m_fullScreenRenderer = renderer; | |
462 } | |
463 | |
464 void FullscreenController::fullScreenRendererDestroyed() | |
465 { | |
466 m_fullScreenRenderer = 0; | |
467 } | |
468 | |
469 void FullscreenController::fullScreenChangeDelayTimerFired(Timer<FullscreenContr oller>*) | 418 void FullscreenController::fullScreenChangeDelayTimerFired(Timer<FullscreenContr oller>*) |
470 { | 419 { |
471 // Since we dispatch events in this function, it's possible that the | 420 // Since we dispatch events in this function, it's possible that the |
472 // document will be detached and GC'd. We protect it here to make sure we | 421 // document will be detached and GC'd. We protect it here to make sure we |
473 // can finish the function successfully. | 422 // can finish the function successfully. |
474 RefPtr<Document> protectDocument(document()); | 423 RefPtr<Document> protectDocument(document()); |
475 Deque<RefPtr<Node> > changeQueue; | 424 Deque<RefPtr<Node> > changeQueue; |
476 m_fullScreenChangeEventTargetQueue.swap(changeQueue); | 425 m_fullScreenChangeEventTargetQueue.swap(changeQueue); |
477 Deque<RefPtr<Node> > errorQueue; | 426 Deque<RefPtr<Node> > errorQueue; |
478 m_fullScreenErrorEventTargetQueue.swap(errorQueue); | 427 m_fullScreenErrorEventTargetQueue.swap(errorQueue); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
534 void FullscreenController::clearFullscreenElementStack() | 483 void FullscreenController::clearFullscreenElementStack() |
535 { | 484 { |
536 m_fullScreenElementStack.clear(); | 485 m_fullScreenElementStack.clear(); |
537 } | 486 } |
538 | 487 |
539 void FullscreenController::popFullscreenElementStack() | 488 void FullscreenController::popFullscreenElementStack() |
540 { | 489 { |
541 if (m_fullScreenElementStack.isEmpty()) | 490 if (m_fullScreenElementStack.isEmpty()) |
542 return; | 491 return; |
543 | 492 |
493 document()->removeFromTopLayer(m_fullScreenElementStack.last().get()); | |
544 m_fullScreenElementStack.removeLast(); | 494 m_fullScreenElementStack.removeLast(); |
545 } | 495 } |
546 | 496 |
547 void FullscreenController::pushFullscreenElementStack(Element* element) | 497 void FullscreenController::pushFullscreenElementStack(Element* element) |
548 { | 498 { |
499 document()->addToTopLayer(element); | |
549 m_fullScreenElementStack.append(element); | 500 m_fullScreenElementStack.append(element); |
550 } | 501 } |
551 | 502 |
552 void FullscreenController::addDocumentToFullScreenChangeEventQueue(Document* doc ) | 503 void FullscreenController::addDocumentToFullScreenChangeEventQueue(Document* doc ) |
553 { | 504 { |
554 ASSERT(doc); | 505 ASSERT(doc); |
555 | 506 |
556 Node* target = 0; | 507 Node* target = 0; |
557 if (FullscreenController* controller = fromIfExists(doc)) { | 508 if (FullscreenController* controller = fromIfExists(doc)) { |
558 target = controller->webkitFullscreenElement(); | 509 target = controller->webkitFullscreenElement(); |
559 if (!target) | 510 if (!target) |
560 target = controller->webkitCurrentFullScreenElement(); | 511 target = controller->webkitCurrentFullScreenElement(); |
561 } | 512 } |
562 | 513 |
563 if (!target) | 514 if (!target) |
564 target = doc; | 515 target = doc; |
565 m_fullScreenChangeEventTargetQueue.append(target); | 516 m_fullScreenChangeEventTargetQueue.append(target); |
566 } | 517 } |
567 | 518 |
568 } // namespace WebCore | 519 } // namespace WebCore |
OLD | NEW |