| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 3 * Copyright (C) 2011, 2012 Google Inc. All rights 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 14 matching lines...) Expand all Loading... |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #include "core/html/shadow/MediaControls.h" | 27 #include "core/html/shadow/MediaControls.h" |
| 28 | 28 |
| 29 #include "bindings/core/v8/ExceptionState.h" | 29 #include "bindings/core/v8/ExceptionState.h" |
| 30 #include "core/dom/ClientRect.h" | 30 #include "core/dom/ClientRect.h" |
| 31 #include "core/dom/Fullscreen.h" | 31 #include "core/dom/Fullscreen.h" |
| 32 #include "core/dom/TaskRunnerHelper.h" | 32 #include "core/dom/TaskRunnerHelper.h" |
| 33 #include "core/events/MouseEvent.h" | 33 #include "core/events/MouseEvent.h" |
| 34 #include "core/frame/Settings.h" | 34 #include "core/frame/Settings.h" |
| 35 #include "core/frame/UseCounter.h" |
| 35 #include "core/html/HTMLMediaElement.h" | 36 #include "core/html/HTMLMediaElement.h" |
| 36 #include "core/html/HTMLVideoElement.h" | 37 #include "core/html/HTMLVideoElement.h" |
| 37 #include "core/html/shadow/MediaControlsMediaEventListener.h" | 38 #include "core/html/shadow/MediaControlsMediaEventListener.h" |
| 38 #include "core/html/shadow/MediaControlsOrientationLockDelegate.h" | 39 #include "core/html/shadow/MediaControlsOrientationLockDelegate.h" |
| 39 #include "core/html/shadow/MediaControlsWindowEventListener.h" | 40 #include "core/html/shadow/MediaControlsWindowEventListener.h" |
| 40 #include "core/html/track/TextTrackContainer.h" | 41 #include "core/html/track/TextTrackContainer.h" |
| 41 #include "core/html/track/TextTrackList.h" | 42 #include "core/html/track/TextTrackList.h" |
| 42 #include "core/layout/LayoutObject.h" | 43 #include "core/layout/LayoutObject.h" |
| 43 #include "core/layout/LayoutTheme.h" | 44 #include "core/layout/LayoutTheme.h" |
| 44 #include "platform/EventDispatchForbiddenScope.h" | 45 #include "platform/EventDispatchForbiddenScope.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 60 | 61 |
| 61 if (!mediaElement.isHTMLVideoElement()) | 62 if (!mediaElement.isHTMLVideoElement()) |
| 62 return false; | 63 return false; |
| 63 | 64 |
| 64 if (!mediaElement.hasVideo()) | 65 if (!mediaElement.hasVideo()) |
| 65 return false; | 66 return false; |
| 66 | 67 |
| 67 if (!Fullscreen::fullscreenEnabled(mediaElement.document())) | 68 if (!Fullscreen::fullscreenEnabled(mediaElement.document())) |
| 68 return false; | 69 return false; |
| 69 | 70 |
| 71 if (mediaElement.controlsList()->shouldHideFullscreen()) { |
| 72 UseCounter::count(mediaElement.document(), |
| 73 UseCounter::HTMLMediaElementControlsListNoFullscreen); |
| 74 return false; |
| 75 } |
| 76 |
| 70 return true; | 77 return true; |
| 71 } | 78 } |
| 72 | 79 |
| 73 static bool shouldShowCastButton(HTMLMediaElement& mediaElement) { | 80 static bool shouldShowCastButton(HTMLMediaElement& mediaElement) { |
| 74 if (mediaElement.fastHasAttribute(HTMLNames::disableremoteplaybackAttr)) | 81 if (mediaElement.fastHasAttribute(HTMLNames::disableremoteplaybackAttr)) |
| 75 return false; | 82 return false; |
| 76 | 83 |
| 77 // Explicitly do not show cast button when the mediaControlsEnabled setting is | 84 // Explicitly do not show cast button when the mediaControlsEnabled setting is |
| 78 // false to make sure the overlay does not appear. | 85 // false to make sure the overlay does not appear. |
| 79 Document& document = mediaElement.document(); | 86 Document& document = mediaElement.document(); |
| 80 if (document.settings() && !document.settings()->getMediaControlsEnabled()) | 87 if (document.settings() && !document.settings()->getMediaControlsEnabled()) |
| 81 return false; | 88 return false; |
| 82 | 89 |
| 90 // The page disabled the button via the attribute. |
| 91 if (mediaElement.controlsList()->shouldHideRemotePlayback()) { |
| 92 UseCounter::count(mediaElement.document(), |
| 93 UseCounter::HTMLMediaElementControlsListNoRemotePlayback); |
| 94 return false; |
| 95 } |
| 96 |
| 83 return mediaElement.hasRemoteRoutes(); | 97 return mediaElement.hasRemoteRoutes(); |
| 84 } | 98 } |
| 85 | 99 |
| 86 static bool preferHiddenVolumeControls(const Document& document) { | 100 static bool preferHiddenVolumeControls(const Document& document) { |
| 87 return !document.settings() || | 101 return !document.settings() || |
| 88 document.settings()->getPreferHiddenVolumeControls(); | 102 document.settings()->getPreferHiddenVolumeControls(); |
| 89 } | 103 } |
| 90 | 104 |
| 91 class MediaControls::BatchedControlUpdate { | 105 class MediaControls::BatchedControlUpdate { |
| 92 WTF_MAKE_NONCOPYABLE(BatchedControlUpdate); | 106 WTF_MAKE_NONCOPYABLE(BatchedControlUpdate); |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 updatePlayState(); | 376 updatePlayState(); |
| 363 | 377 |
| 364 updateCurrentTimeDisplay(); | 378 updateCurrentTimeDisplay(); |
| 365 | 379 |
| 366 m_timeline->setDuration(duration); | 380 m_timeline->setDuration(duration); |
| 367 m_timeline->setPosition(mediaElement().currentTime()); | 381 m_timeline->setPosition(mediaElement().currentTime()); |
| 368 | 382 |
| 369 onVolumeChange(); | 383 onVolumeChange(); |
| 370 onTextTracksAddedOrRemoved(); | 384 onTextTracksAddedOrRemoved(); |
| 371 | 385 |
| 386 onControlsListUpdated(); |
| 387 } |
| 388 |
| 389 void MediaControls::onControlsListUpdated() { |
| 390 BatchedControlUpdate batch(this); |
| 391 |
| 372 m_fullscreenButton->setIsWanted(shouldShowFullscreenButton(mediaElement())); | 392 m_fullscreenButton->setIsWanted(shouldShowFullscreenButton(mediaElement())); |
| 373 | 393 |
| 374 refreshCastButtonVisibilityWithoutUpdate(); | 394 refreshCastButtonVisibilityWithoutUpdate(); |
| 375 | 395 |
| 376 m_downloadButton->setIsWanted( | 396 m_downloadButton->setIsWanted( |
| 377 m_downloadButton->shouldDisplayDownloadButton()); | 397 m_downloadButton->shouldDisplayDownloadButton()); |
| 378 } | 398 } |
| 379 | 399 |
| 380 LayoutObject* MediaControls::layoutObjectForTextTrackLayout() { | 400 LayoutObject* MediaControls::layoutObjectForTextTrackLayout() { |
| 381 return m_panel->layoutObject(); | 401 return m_panel->layoutObject(); |
| (...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 997 visitor->trace(m_overflowList); | 1017 visitor->trace(m_overflowList); |
| 998 visitor->trace(m_castButton); | 1018 visitor->trace(m_castButton); |
| 999 visitor->trace(m_overlayCastButton); | 1019 visitor->trace(m_overlayCastButton); |
| 1000 visitor->trace(m_mediaEventListener); | 1020 visitor->trace(m_mediaEventListener); |
| 1001 visitor->trace(m_windowEventListener); | 1021 visitor->trace(m_windowEventListener); |
| 1002 visitor->trace(m_orientationLockDelegate); | 1022 visitor->trace(m_orientationLockDelegate); |
| 1003 HTMLDivElement::trace(visitor); | 1023 HTMLDivElement::trace(visitor); |
| 1004 } | 1024 } |
| 1005 | 1025 |
| 1006 } // namespace blink | 1026 } // namespace blink |
| OLD | NEW |