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

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

Issue 2700663002: Adds keyboard functionality for videos. (Closed)
Patch Set: Now calls IsSpatialNavigationEnabled() directly. 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 18 matching lines...) Expand all
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/MutationCallback.h" 32 #include "core/dom/MutationCallback.h"
33 #include "core/dom/MutationObserver.h" 33 #include "core/dom/MutationObserver.h"
34 #include "core/dom/MutationObserverInit.h" 34 #include "core/dom/MutationObserverInit.h"
35 #include "core/dom/MutationRecord.h" 35 #include "core/dom/MutationRecord.h"
36 #include "core/dom/ResizeObserver.h" 36 #include "core/dom/ResizeObserver.h"
37 #include "core/dom/ResizeObserverEntry.h" 37 #include "core/dom/ResizeObserverEntry.h"
38 #include "core/dom/TaskRunnerHelper.h" 38 #include "core/dom/TaskRunnerHelper.h"
39 #include "core/events/KeyboardEvent.h"
39 #include "core/events/MouseEvent.h" 40 #include "core/events/MouseEvent.h"
40 #include "core/frame/Settings.h" 41 #include "core/frame/Settings.h"
41 #include "core/frame/UseCounter.h" 42 #include "core/frame/UseCounter.h"
42 #include "core/html/HTMLMediaElement.h" 43 #include "core/html/HTMLMediaElement.h"
43 #include "core/html/HTMLVideoElement.h" 44 #include "core/html/HTMLVideoElement.h"
44 #include "core/html/media/HTMLMediaElementControlsList.h" 45 #include "core/html/media/HTMLMediaElementControlsList.h"
45 #include "core/html/track/TextTrackContainer.h" 46 #include "core/html/track/TextTrackContainer.h"
46 #include "core/html/track/TextTrackList.h" 47 #include "core/html/track/TextTrackList.h"
47 #include "core/layout/LayoutObject.h" 48 #include "core/layout/LayoutObject.h"
48 #include "core/layout/LayoutTheme.h" 49 #include "core/layout/LayoutTheme.h"
50 #include "core/page/SpatialNavigation.h"
49 #include "modules/media_controls/MediaControlsMediaEventListener.h" 51 #include "modules/media_controls/MediaControlsMediaEventListener.h"
50 #include "modules/media_controls/MediaControlsOrientationLockDelegate.h" 52 #include "modules/media_controls/MediaControlsOrientationLockDelegate.h"
51 #include "modules/media_controls/MediaControlsRotateToFullscreenDelegate.h" 53 #include "modules/media_controls/MediaControlsRotateToFullscreenDelegate.h"
52 #include "modules/media_controls/MediaControlsWindowEventListener.h" 54 #include "modules/media_controls/MediaControlsWindowEventListener.h"
53 #include "modules/media_controls/elements/MediaControlCastButtonElement.h" 55 #include "modules/media_controls/elements/MediaControlCastButtonElement.h"
54 #include "modules/media_controls/elements/MediaControlCurrentTimeDisplayElement. h" 56 #include "modules/media_controls/elements/MediaControlCurrentTimeDisplayElement. h"
55 #include "modules/media_controls/elements/MediaControlDownloadButtonElement.h" 57 #include "modules/media_controls/elements/MediaControlDownloadButtonElement.h"
56 #include "modules/media_controls/elements/MediaControlFullscreenButtonElement.h" 58 #include "modules/media_controls/elements/MediaControlFullscreenButtonElement.h"
57 #include "modules/media_controls/elements/MediaControlMuteButtonElement.h" 59 #include "modules/media_controls/elements/MediaControlMuteButtonElement.h"
58 #include "modules/media_controls/elements/MediaControlOverflowMenuButtonElement. h" 60 #include "modules/media_controls/elements/MediaControlOverflowMenuButtonElement. h"
(...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 StartHideMediaControlsTimer(); 844 StartHideMediaControlsTimer();
843 return; 845 return;
844 } 846 }
845 847
846 // If the user is interacting with the controls via the keyboard, don't hide 848 // If the user is interacting with the controls via the keyboard, don't hide
847 // the controls. This will fire when the user tabs between controls (focusin) 849 // the controls. This will fire when the user tabs between controls (focusin)
848 // or when they seek either the timeline or volume sliders (input). 850 // or when they seek either the timeline or volume sliders (input).
849 if (event->type() == EventTypeNames::focusin || 851 if (event->type() == EventTypeNames::focusin ||
850 event->type() == EventTypeNames::input) 852 event->type() == EventTypeNames::input)
851 ResetHideMediaControlsTimer(); 853 ResetHideMediaControlsTimer();
854
855 if (event->IsKeyboardEvent() &&
856 !IsSpatialNavigationEnabled(GetDocument().GetFrame())) {
857 const String& key = ToKeyboardEvent(event)->key();
858 if (key == "Enter" || ToKeyboardEvent(event)->keyCode() == ' ') {
859 play_button_->OnMediaKeyboardEvent(event);
860 return;
861 }
862 if (key == "ArrowLeft" || key == "ArrowRight" || key == "Home" ||
863 key == "End") {
864 timeline_->OnMediaKeyboardEvent(event);
865 return;
866 }
867 if (key == "ArrowDown" || key == "ArrowUp") {
868 volume_slider_->OnMediaKeyboardEvent(event);
869 return;
870 }
871 }
852 } 872 }
853 873
854 void MediaControlsImpl::HideMediaControlsTimerFired(TimerBase*) { 874 void MediaControlsImpl::HideMediaControlsTimerFired(TimerBase*) {
855 unsigned behavior_flags = 875 unsigned behavior_flags =
856 hide_timer_behavior_flags_ | kIgnoreFocus | kIgnoreVideoHover; 876 hide_timer_behavior_flags_ | kIgnoreFocus | kIgnoreVideoHover;
857 hide_timer_behavior_flags_ = kIgnoreNone; 877 hide_timer_behavior_flags_ = kIgnoreNone;
858 keep_showing_until_timer_fires_ = false; 878 keep_showing_until_timer_fires_ = false;
859 879
860 if (MediaElement().paused()) 880 if (MediaElement().paused())
861 return; 881 return;
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
1214 visitor->Trace(overlay_cast_button_); 1234 visitor->Trace(overlay_cast_button_);
1215 visitor->Trace(media_event_listener_); 1235 visitor->Trace(media_event_listener_);
1216 visitor->Trace(window_event_listener_); 1236 visitor->Trace(window_event_listener_);
1217 visitor->Trace(orientation_lock_delegate_); 1237 visitor->Trace(orientation_lock_delegate_);
1218 visitor->Trace(rotate_to_fullscreen_delegate_); 1238 visitor->Trace(rotate_to_fullscreen_delegate_);
1219 MediaControls::Trace(visitor); 1239 MediaControls::Trace(visitor);
1220 HTMLDivElement::Trace(visitor); 1240 HTMLDivElement::Trace(visitor);
1221 } 1241 }
1222 1242
1223 } // namespace blink 1243 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698