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

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

Issue 2700663002: Adds keyboard functionality for videos. (Closed)
Patch Set: Addresses mlamouri's #22, adds tests. Created 3 years, 8 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 15 matching lines...) Expand all
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/ResizeObserver.h" 32 #include "core/dom/ResizeObserver.h"
33 #include "core/dom/ResizeObserverCallback.h" 33 #include "core/dom/ResizeObserverCallback.h"
34 #include "core/dom/ResizeObserverEntry.h" 34 #include "core/dom/ResizeObserverEntry.h"
35 #include "core/dom/TaskRunnerHelper.h" 35 #include "core/dom/TaskRunnerHelper.h"
36 #include "core/events/KeyboardEvent.h"
36 #include "core/events/MouseEvent.h" 37 #include "core/events/MouseEvent.h"
37 #include "core/frame/Settings.h" 38 #include "core/frame/Settings.h"
38 #include "core/frame/UseCounter.h" 39 #include "core/frame/UseCounter.h"
39 #include "core/html/HTMLMediaElement.h" 40 #include "core/html/HTMLMediaElement.h"
40 #include "core/html/HTMLVideoElement.h" 41 #include "core/html/HTMLVideoElement.h"
41 #include "core/html/media/HTMLMediaElementControlsList.h" 42 #include "core/html/media/HTMLMediaElementControlsList.h"
42 #include "core/html/track/TextTrackContainer.h" 43 #include "core/html/track/TextTrackContainer.h"
43 #include "core/html/track/TextTrackList.h" 44 #include "core/html/track/TextTrackList.h"
44 #include "core/layout/LayoutObject.h" 45 #include "core/layout/LayoutObject.h"
45 #include "core/layout/LayoutTheme.h" 46 #include "core/layout/LayoutTheme.h"
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 StartHideMediaControlsTimer(); 765 StartHideMediaControlsTimer();
765 return; 766 return;
766 } 767 }
767 768
768 // If the user is interacting with the controls via the keyboard, don't hide 769 // If the user is interacting with the controls via the keyboard, don't hide
769 // the controls. This will fire when the user tabs between controls (focusin) 770 // the controls. This will fire when the user tabs between controls (focusin)
770 // or when they seek either the timeline or volume sliders (input). 771 // or when they seek either the timeline or volume sliders (input).
771 if (event->type() == EventTypeNames::focusin || 772 if (event->type() == EventTypeNames::focusin ||
772 event->type() == EventTypeNames::input) 773 event->type() == EventTypeNames::input)
773 ResetHideMediaControlsTimer(); 774 ResetHideMediaControlsTimer();
775
776 if (event->IsKeyboardEvent()) {
777 const String& key = ToKeyboardEvent(event)->key();
778 if (key == "Enter" || ToKeyboardEvent(event)->keyCode() == ' ') {
779 play_button_->OnMediaKeyboardEvent(event);
780 return;
781 }
782 if (key == "ArrowLeft" || key == "ArrowRight" || key == "Home" ||
783 key == "End") {
784 timeline_->onMediaKeyboardEvent(event);
785 return;
786 }
787 if (key == "ArrowDown" || key == "ArrowUp") {
788 volume_slider_->onMediaKeyboardEvent(event);
789 return;
790 }
791 }
774 } 792 }
775 793
776 void MediaControlsImpl::HideMediaControlsTimerFired(TimerBase*) { 794 void MediaControlsImpl::HideMediaControlsTimerFired(TimerBase*) {
777 unsigned behavior_flags = 795 unsigned behavior_flags =
778 hide_timer_behavior_flags_ | kIgnoreFocus | kIgnoreVideoHover; 796 hide_timer_behavior_flags_ | kIgnoreFocus | kIgnoreVideoHover;
779 hide_timer_behavior_flags_ = kIgnoreNone; 797 hide_timer_behavior_flags_ = kIgnoreNone;
780 keep_showing_until_timer_fires_ = false; 798 keep_showing_until_timer_fires_ = false;
781 799
782 if (MediaElement().paused()) 800 if (MediaElement().paused())
783 return; 801 return;
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 visitor->Trace(cast_button_); 1152 visitor->Trace(cast_button_);
1135 visitor->Trace(overlay_cast_button_); 1153 visitor->Trace(overlay_cast_button_);
1136 visitor->Trace(media_event_listener_); 1154 visitor->Trace(media_event_listener_);
1137 visitor->Trace(window_event_listener_); 1155 visitor->Trace(window_event_listener_);
1138 visitor->Trace(orientation_lock_delegate_); 1156 visitor->Trace(orientation_lock_delegate_);
1139 MediaControls::Trace(visitor); 1157 MediaControls::Trace(visitor);
1140 HTMLDivElement::Trace(visitor); 1158 HTMLDivElement::Trace(visitor);
1141 } 1159 }
1142 1160
1143 } // namespace blink 1161 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698