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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/media_controls/MediaControlsImpl.cpp
diff --git a/third_party/WebKit/Source/modules/media_controls/MediaControlsImpl.cpp b/third_party/WebKit/Source/modules/media_controls/MediaControlsImpl.cpp
index 46f1f6f2a4d238c5f6729a9a537bb81c2b7fbd85..bf0b44acfe1cad8c21329596cca2456aca8b3e65 100644
--- a/third_party/WebKit/Source/modules/media_controls/MediaControlsImpl.cpp
+++ b/third_party/WebKit/Source/modules/media_controls/MediaControlsImpl.cpp
@@ -33,6 +33,7 @@
#include "core/dom/ResizeObserverCallback.h"
#include "core/dom/ResizeObserverEntry.h"
#include "core/dom/TaskRunnerHelper.h"
+#include "core/events/KeyboardEvent.h"
#include "core/events/MouseEvent.h"
#include "core/frame/Settings.h"
#include "core/frame/UseCounter.h"
@@ -771,6 +772,23 @@ void MediaControlsImpl::DefaultEventHandler(Event* event) {
if (event->type() == EventTypeNames::focusin ||
event->type() == EventTypeNames::input)
ResetHideMediaControlsTimer();
+
+ if (event->IsKeyboardEvent()) {
+ const String& key = ToKeyboardEvent(event)->key();
+ if (key == "Enter" || ToKeyboardEvent(event)->keyCode() == ' ') {
+ play_button_->OnMediaKeyboardEvent(event);
+ return;
+ }
+ if (key == "ArrowLeft" || key == "ArrowRight" || key == "Home" ||
+ key == "End") {
+ timeline_->onMediaKeyboardEvent(event);
+ return;
+ }
+ if (key == "ArrowDown" || key == "ArrowUp") {
+ volume_slider_->onMediaKeyboardEvent(event);
+ return;
+ }
+ }
}
void MediaControlsImpl::HideMediaControlsTimerFired(TimerBase*) {

Powered by Google App Engine
This is Rietveld 408576698