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

Side by Side Diff: third_party/WebKit/Source/core/html/shadow/MediaControls.cpp

Issue 2700663002: Adds keyboard functionality for videos. (Closed)
Patch Set: Clean up. Created 3 years, 9 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 "core/html/shadow/MediaControls.h" 27 #include "core/html/shadow/MediaControls.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/shadow/MediaControlsMediaEventListener.h" 42 #include "core/html/shadow/MediaControlsMediaEventListener.h"
42 #include "core/html/shadow/MediaControlsOrientationLockDelegate.h" 43 #include "core/html/shadow/MediaControlsOrientationLockDelegate.h"
43 #include "core/html/shadow/MediaControlsWindowEventListener.h" 44 #include "core/html/shadow/MediaControlsWindowEventListener.h"
44 #include "core/html/track/TextTrackContainer.h" 45 #include "core/html/track/TextTrackContainer.h"
45 #include "core/html/track/TextTrackList.h" 46 #include "core/html/track/TextTrackList.h"
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 } 745 }
745 746
746 if (event->type() == EventTypeNames::mousemove) { 747 if (event->type() == EventTypeNames::mousemove) {
747 // When we get a mouse move, show the media controls, and start a timer 748 // When we get a mouse move, show the media controls, and start a timer
748 // that will hide the media controls after a 3 seconds without a mouse move. 749 // that will hide the media controls after a 3 seconds without a mouse move.
749 makeOpaque(); 750 makeOpaque();
750 if (shouldHideMediaControls(IgnoreVideoHover)) 751 if (shouldHideMediaControls(IgnoreVideoHover))
751 startHideMediaControlsTimer(); 752 startHideMediaControlsTimer();
752 return; 753 return;
753 } 754 }
755
756 if (event->type() == EventTypeNames::input) {
mlamouri (slow - plz ping) 2017/03/27 13:02:12 stupid question: why is that?
CJ 2017/04/08 00:31:27 So we don't hide media controls while manipulating
757 resetHideMediaControlsTimer();
758 }
759
760 if (event->isKeyboardEvent()) {
761 const String& key = toKeyboardEvent(event)->key();
762 if (key == "Enter" || key == " ") {
763 m_playButton->onMediaKeyboardEvent(event);
764 return;
765 }
766 if (key == "ArrowLeft" || key == "ArrowRight") {
767 timelineElement()->onMediaKeyboardEvent(event);
768 return;
769 }
770 if (key == "ArrowDown" || key == "ArrowUp") {
771 volumeSliderElement()->onMediaKeyboardEvent(event);
772 return;
773 }
774 }
754 } 775 }
755 776
756 void MediaControls::hideMediaControlsTimerFired(TimerBase*) { 777 void MediaControls::hideMediaControlsTimerFired(TimerBase*) {
757 unsigned behaviorFlags = 778 unsigned behaviorFlags =
758 m_hideTimerBehaviorFlags | IgnoreFocus | IgnoreVideoHover; 779 m_hideTimerBehaviorFlags | IgnoreFocus | IgnoreVideoHover;
759 m_hideTimerBehaviorFlags = IgnoreNone; 780 m_hideTimerBehaviorFlags = IgnoreNone;
760 m_keepShowingUntilTimerFires = false; 781 m_keepShowingUntilTimerFires = false;
761 782
762 if (mediaElement().paused()) 783 if (mediaElement().paused())
763 return; 784 return;
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
1100 visitor->trace(m_overflowList); 1121 visitor->trace(m_overflowList);
1101 visitor->trace(m_castButton); 1122 visitor->trace(m_castButton);
1102 visitor->trace(m_overlayCastButton); 1123 visitor->trace(m_overlayCastButton);
1103 visitor->trace(m_mediaEventListener); 1124 visitor->trace(m_mediaEventListener);
1104 visitor->trace(m_windowEventListener); 1125 visitor->trace(m_windowEventListener);
1105 visitor->trace(m_orientationLockDelegate); 1126 visitor->trace(m_orientationLockDelegate);
1106 HTMLDivElement::trace(visitor); 1127 HTMLDivElement::trace(visitor);
1107 } 1128 }
1108 1129
1109 } // namespace blink 1130 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698