Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: third_party/WebKit/Source/modules/media_controls/MediaControlsImpl.cpp

Issue 2943983003: chrome/blink: Add functionality for in-product help for media elements. (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 11 matching lines...) Expand all
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */ 25 */
26 26
27 #include "modules/media_controls/MediaControlsImpl.h" 27 #include "modules/media_controls/MediaControlsImpl.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/MediaIPHManager.h"
32 #include "core/dom/MutationCallback.h" 33 #include "core/dom/MutationCallback.h"
33 #include "core/dom/MutationObserver.h" 34 #include "core/dom/MutationObserver.h"
34 #include "core/dom/MutationObserverInit.h" 35 #include "core/dom/MutationObserverInit.h"
35 #include "core/dom/MutationRecord.h" 36 #include "core/dom/MutationRecord.h"
36 #include "core/dom/ResizeObserver.h" 37 #include "core/dom/ResizeObserver.h"
37 #include "core/dom/ResizeObserverEntry.h" 38 #include "core/dom/ResizeObserverEntry.h"
38 #include "core/dom/TaskRunnerHelper.h" 39 #include "core/dom/TaskRunnerHelper.h"
39 #include "core/events/KeyboardEvent.h" 40 #include "core/events/KeyboardEvent.h"
40 #include "core/events/MouseEvent.h" 41 #include "core/events/MouseEvent.h"
41 #include "core/frame/Settings.h" 42 #include "core/frame/Settings.h"
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 const bool ignore_focus = behavior_flags & kIgnoreFocus; 637 const bool ignore_focus = behavior_flags & kIgnoreFocus;
637 if (!ignore_focus && (MediaElement().IsFocused() || 638 if (!ignore_focus && (MediaElement().IsFocused() ||
638 contains(GetDocument().FocusedElement()))) { 639 contains(GetDocument().FocusedElement()))) {
639 return false; 640 return false;
640 } 641 }
641 642
642 // Don't hide the media controls when a panel is showing. 643 // Don't hide the media controls when a panel is showing.
643 if (text_track_list_->IsWanted() || overflow_list_->IsWanted()) 644 if (text_track_list_->IsWanted() || overflow_list_->IsWanted())
644 return false; 645 return false;
645 646
647 // Don't hide the media controls while the iph is showing.
648 if (iph_active_)
649 return false;
650
646 return true; 651 return true;
647 } 652 }
648 653
649 void MediaControlsImpl::UpdatePlayState() { 654 void MediaControlsImpl::UpdatePlayState() {
650 if (is_paused_for_scrubbing_) 655 if (is_paused_for_scrubbing_)
651 return; 656 return;
652 657
653 if (overlay_play_button_) 658 if (overlay_play_button_)
654 overlay_play_button_->UpdateDisplayType(); 659 overlay_play_button_->UpdateDisplayType();
655 play_button_->UpdateDisplayType(); 660 play_button_->UpdateDisplayType();
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 UpdateCurrentTimeDisplay(); 969 UpdateCurrentTimeDisplay();
965 970
966 // Update the timeline (the UI with the seek marker). 971 // Update the timeline (the UI with the seek marker).
967 timeline_->SetDuration(duration); 972 timeline_->SetDuration(duration);
968 } 973 }
969 974
970 void MediaControlsImpl::OnPlay() { 975 void MediaControlsImpl::OnPlay() {
971 UpdatePlayState(); 976 UpdatePlayState();
972 timeline_->SetPosition(MediaElement().currentTime()); 977 timeline_->SetPosition(MediaElement().currentTime());
973 UpdateCurrentTimeDisplay(); 978 UpdateCurrentTimeDisplay();
979 MaybeDispatchDownloadIPHTrigger();
974 } 980 }
975 981
976 void MediaControlsImpl::OnPlaying() { 982 void MediaControlsImpl::OnPlaying() {
977 timeline_->OnPlaying(); 983 timeline_->OnPlaying();
978 984
979 StartHideMediaControlsTimer(); 985 StartHideMediaControlsTimer();
980 } 986 }
981 987
982 void MediaControlsImpl::OnPause() { 988 void MediaControlsImpl::OnPause() {
983 UpdatePlayState(); 989 UpdatePlayState();
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1209 1215
1210 void MediaControlsImpl::HideAllMenus() { 1216 void MediaControlsImpl::HideAllMenus() {
1211 window_event_listener_->Stop(); 1217 window_event_listener_->Stop();
1212 1218
1213 if (overflow_list_->IsWanted()) 1219 if (overflow_list_->IsWanted())
1214 overflow_list_->SetIsWanted(false); 1220 overflow_list_->SetIsWanted(false);
1215 if (text_track_list_->IsWanted()) 1221 if (text_track_list_->IsWanted())
1216 text_track_list_->SetVisible(false); 1222 text_track_list_->SetVisible(false);
1217 } 1223 }
1218 1224
1225 void MediaControlsImpl::MaybeDispatchDownloadIPHTrigger() {
1226 if (!iph_trigger_observed_ && download_button_->IsWanted() &&
1227 !MediaElement().paused() &&
1228 MediaElement().GetDocument().GetMediaIPHManager() &&
1229 MediaElement()
1230 .GetDocument()
1231 .GetMediaIPHManager()
1232 ->IPHTriggerObservedOnElement(MediaElement())) {
1233 iph_active_ = true;
1234 iph_trigger_observed_ = true;
1235 MaybeShow();
chrishtr 2017/06/23 00:39:44 Why call MaybeShow and MakeOpaque?
Khushal 2017/06/23 02:11:06 MakeOpaque is unnecessary. There should be an asse
Khushal 2017/06/28 05:32:38 Done.
1236 MakeOpaque();
1237 }
1238 }
1239
1240 bool MediaControlsImpl::GetDownloadButtonRect(IntRect& rect) {
1241 if (!IsVisible())
1242 return false;
1243 if (!download_button_->IsWanted())
1244 return false;
1245
1246 rect = download_button_->VisibleBoundsInVisualViewport();
1247 return true;
1248 }
1249
1250 void MediaControlsImpl::IPHDisabled() {
1251 if (!iph_active_)
1252 return;
1253
1254 iph_active_ = false;
1255 if (ShouldHideMediaControls())
1256 StartHideMediaControlsTimer();
1257 }
1258
1219 DEFINE_TRACE(MediaControlsImpl) { 1259 DEFINE_TRACE(MediaControlsImpl) {
1220 visitor->Trace(element_mutation_callback_); 1260 visitor->Trace(element_mutation_callback_);
1221 visitor->Trace(resize_observer_); 1261 visitor->Trace(resize_observer_);
1222 visitor->Trace(panel_); 1262 visitor->Trace(panel_);
1223 visitor->Trace(overlay_play_button_); 1263 visitor->Trace(overlay_play_button_);
1224 visitor->Trace(overlay_enclosure_); 1264 visitor->Trace(overlay_enclosure_);
1225 visitor->Trace(play_button_); 1265 visitor->Trace(play_button_);
1226 visitor->Trace(current_time_display_); 1266 visitor->Trace(current_time_display_);
1227 visitor->Trace(timeline_); 1267 visitor->Trace(timeline_);
1228 visitor->Trace(mute_button_); 1268 visitor->Trace(mute_button_);
(...skipping 10 matching lines...) Expand all
1239 visitor->Trace(overlay_cast_button_); 1279 visitor->Trace(overlay_cast_button_);
1240 visitor->Trace(media_event_listener_); 1280 visitor->Trace(media_event_listener_);
1241 visitor->Trace(window_event_listener_); 1281 visitor->Trace(window_event_listener_);
1242 visitor->Trace(orientation_lock_delegate_); 1282 visitor->Trace(orientation_lock_delegate_);
1243 visitor->Trace(rotate_to_fullscreen_delegate_); 1283 visitor->Trace(rotate_to_fullscreen_delegate_);
1244 MediaControls::Trace(visitor); 1284 MediaControls::Trace(visitor);
1245 HTMLDivElement::Trace(visitor); 1285 HTMLDivElement::Trace(visitor);
1246 } 1286 }
1247 1287
1248 } // namespace blink 1288 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698