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

Unified Diff: third_party/WebKit/Source/core/html/HTMLMediaElement.cpp

Issue 2700663002: Adds keyboard functionality for videos. (Closed)
Patch Set: Created 3 years, 10 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/core/html/HTMLMediaElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
index 9156bba583b6c602b3a8cc84b4db479d0b50a85d..4d89681c04bc37acc4956991ca3315423b0a40bd 100644
--- a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
@@ -26,6 +26,7 @@
#include "core/html/HTMLMediaElement.h"
+#include <limits>
#include "bindings/core/v8/ExceptionState.h"
#include "bindings/core/v8/Microtask.h"
#include "bindings/core/v8/ScriptController.h"
@@ -41,6 +42,7 @@
#include "core/dom/TaskRunnerHelper.h"
#include "core/dom/shadow/ShadowRoot.h"
#include "core/events/Event.h"
+#include "core/events/KeyboardEvent.h"
#include "core/frame/FrameView.h"
#include "core/frame/LocalFrame.h"
#include "core/frame/Settings.h"
@@ -84,6 +86,7 @@
#include "platform/network/mime/MIMETypeFromURL.h"
#include "platform/weborigin/SecurityOrigin.h"
#include "public/platform/Platform.h"
+#include "public/platform/UserMetricsAction.h"
#include "public/platform/WebAudioSourceProvider.h"
#include "public/platform/WebContentDecryptionModule.h"
#include "public/platform/WebInbandTextTrack.h"
@@ -97,7 +100,6 @@
#include "wtf/MathExtras.h"
#include "wtf/PtrUtil.h"
#include "wtf/text/CString.h"
-#include <limits>
#ifndef BLINK_MEDIA_LOG
#define BLINK_MEDIA_LOG DVLOG(3)
@@ -3642,6 +3644,31 @@ void HTMLMediaElement::ensureMediaControls() {
assertShadowRootChildren(shadowRoot);
}
+void HTMLMediaElement::defaultEventHandler(Event* event) {
+ if (isFocusedElementInDocument()) {
+ if (event->isKeyboardEvent()) {
+ int key = toKeyboardEvent(event)->keyCode();
+ switch (key) {
+ case ('\r'):
+ case (' '):
+ togglePlayState();
+ return;
+ case (37):
+ case (39):
+ m_mediaControls->timelineElement()->defaultEventHandler(event);
+ m_mediaControls->startHideMediaControlsTimer();
+ return;
+ case (38):
+ case (40):
+ m_mediaControls->volumeSliderElement()->defaultEventHandler(event);
+ m_mediaControls->startHideMediaControlsTimer();
+ return;
+ }
+ }
+ }
+ HTMLElement::defaultEventHandler(event);
+}
+
void HTMLMediaElement::updateControlsVisibility() {
if (!isConnected()) {
if (mediaControls())

Powered by Google App Engine
This is Rietveld 408576698