OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights | 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights |
3 * reserved. | 3 * reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 30 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
31 #include "bindings/core/v8/ScriptController.h" | 31 #include "bindings/core/v8/ScriptController.h" |
32 #include "bindings/core/v8/ScriptEventListener.h" | 32 #include "bindings/core/v8/ScriptEventListener.h" |
33 #include "bindings/core/v8/ScriptPromiseResolver.h" | 33 #include "bindings/core/v8/ScriptPromiseResolver.h" |
34 #include "core/HTMLNames.h" | 34 #include "core/HTMLNames.h" |
35 #include "core/css/MediaList.h" | 35 #include "core/css/MediaList.h" |
36 #include "core/dom/Attribute.h" | 36 #include "core/dom/Attribute.h" |
37 #include "core/dom/DOMException.h" | 37 #include "core/dom/DOMException.h" |
38 #include "core/dom/ElementTraversal.h" | 38 #include "core/dom/ElementTraversal.h" |
39 #include "core/dom/ElementVisibilityObserver.h" | 39 #include "core/dom/ElementVisibilityObserver.h" |
40 #include "core/dom/Fullscreen.h" | |
41 #include "core/dom/TaskRunnerHelper.h" | 40 #include "core/dom/TaskRunnerHelper.h" |
42 #include "core/dom/shadow/ShadowRoot.h" | 41 #include "core/dom/shadow/ShadowRoot.h" |
43 #include "core/events/Event.h" | 42 #include "core/events/Event.h" |
44 #include "core/frame/FrameView.h" | 43 #include "core/frame/FrameView.h" |
45 #include "core/frame/LocalFrame.h" | 44 #include "core/frame/LocalFrame.h" |
46 #include "core/frame/Settings.h" | 45 #include "core/frame/Settings.h" |
47 #include "core/frame/UseCounter.h" | 46 #include "core/frame/UseCounter.h" |
48 #include "core/frame/csp/ContentSecurityPolicy.h" | 47 #include "core/frame/csp/ContentSecurityPolicy.h" |
49 #include "core/html/AutoplayUmaHelper.h" | 48 #include "core/html/AutoplayUmaHelper.h" |
50 #include "core/html/HTMLMediaSource.h" | 49 #include "core/html/HTMLMediaSource.h" |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 if ((document.settings() && | 474 if ((document.settings() && |
476 document.settings()->mediaPlaybackRequiresUserGesture()) || | 475 document.settings()->mediaPlaybackRequiresUserGesture()) || |
477 m_autoplayHelper->isExperimentEnabled()) { | 476 m_autoplayHelper->isExperimentEnabled()) { |
478 m_lockedPendingUserGesture = true; | 477 m_lockedPendingUserGesture = true; |
479 } | 478 } |
480 | 479 |
481 setHasCustomStyleCallbacks(); | 480 setHasCustomStyleCallbacks(); |
482 addElementToDocumentMap(this, &document); | 481 addElementToDocumentMap(this, &document); |
483 | 482 |
484 UseCounter::count(document, UseCounter::HTMLMediaElement); | 483 UseCounter::count(document, UseCounter::HTMLMediaElement); |
| 484 |
| 485 Fullscreen::from(document).registerObserver(this); |
485 } | 486 } |
486 | 487 |
487 HTMLMediaElement::~HTMLMediaElement() { | 488 HTMLMediaElement::~HTMLMediaElement() { |
488 BLINK_MEDIA_LOG << "~HTMLMediaElement(" << (void*)this << ")"; | 489 BLINK_MEDIA_LOG << "~HTMLMediaElement(" << (void*)this << ")"; |
489 | 490 |
490 // m_audioSourceNode is explicitly cleared by AudioNode::dispose(). | 491 // m_audioSourceNode is explicitly cleared by AudioNode::dispose(). |
491 // Since AudioNode::dispose() is guaranteed to be always called before | 492 // Since AudioNode::dispose() is guaranteed to be always called before |
492 // the AudioNode is destructed, m_audioSourceNode is explicitly cleared | 493 // the AudioNode is destructed, m_audioSourceNode is explicitly cleared |
493 // even if the AudioNode and the HTMLMediaElement die together. | 494 // even if the AudioNode and the HTMLMediaElement die together. |
494 DCHECK(!m_audioSourceNode); | 495 DCHECK(!m_audioSourceNode); |
| 496 |
| 497 Fullscreen::from(document()).removeObserver(this); |
495 } | 498 } |
496 | 499 |
497 void HTMLMediaElement::dispose() { | 500 void HTMLMediaElement::dispose() { |
498 closeMediaSource(); | 501 closeMediaSource(); |
499 | 502 |
500 // Destroying the player may cause a resource load to be canceled, | 503 // Destroying the player may cause a resource load to be canceled, |
501 // which could result in LocalDOMWindow::dispatchWindowLoadEvent() being | 504 // which could result in LocalDOMWindow::dispatchWindowLoadEvent() being |
502 // called via ResourceFetch::didLoadResource(), then | 505 // called via ResourceFetch::didLoadResource(), then |
503 // FrameLoader::checkCompleted(). But it's guaranteed that the load event | 506 // FrameLoader::checkCompleted(). But it's guaranteed that the load event |
504 // doesn't get dispatched during the object destruction. | 507 // doesn't get dispatched during the object destruction. |
(...skipping 3586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4091 } | 4094 } |
4092 | 4095 |
4093 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() | 4096 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() |
4094 const { | 4097 const { |
4095 IntRect result; | 4098 IntRect result; |
4096 if (LayoutObject* object = m_element->layoutObject()) | 4099 if (LayoutObject* object = m_element->layoutObject()) |
4097 result = object->absoluteBoundingBoxRect(); | 4100 result = object->absoluteBoundingBoxRect(); |
4098 return result; | 4101 return result; |
4099 } | 4102 } |
4100 | 4103 |
| 4104 void HTMLMediaElement::onEnteredFullscreen() { |
| 4105 if (!webMediaPlayer()) |
| 4106 return; |
| 4107 if (isFullscreen()) |
| 4108 return; |
| 4109 |
| 4110 Element* fullscreenElement = |
| 4111 Fullscreen::currentFullScreenElementFrom(document()); |
| 4112 if (fullscreenElement->isShadowIncludingInclusiveAncestorOf(this) && |
| 4113 clientWidth() >= document().domWindow()->innerWidth() * 0.9 && |
| 4114 clientHeight() >= document().domWindow()->innerHeight() * 0.9) |
| 4115 webMediaPlayer()->enteredFullWindow(); |
| 4116 } |
| 4117 |
| 4118 void HTMLMediaElement::onExitedFullscreen() { |
| 4119 if (webMediaPlayer()) |
| 4120 webMediaPlayer()->exitedFullWindow(); |
| 4121 } |
| 4122 |
4101 } // namespace blink | 4123 } // namespace blink |
OLD | NEW |