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

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

Issue 2830653002: Media Controls: move volume slider to modules/. (Closed)
Patch Set: _ 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
« no previous file with comments | « third_party/WebKit/Source/modules/media_controls/elements/MediaControlVolumeSliderElement.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "modules/media_controls/elements/MediaControlVolumeSliderElement.h"
6
7 #include "core/HTMLNames.h"
8 #include "core/InputTypeNames.h"
9 #include "core/events/Event.h"
10 #include "core/html/HTMLMediaElement.h"
11 #include "core/layout/LayoutObject.h"
12 #include "modules/media_controls/MediaControlsImpl.h"
13 #include "modules/media_controls/elements/MediaControlElementsHelper.h"
14 #include "public/platform/Platform.h"
15
16 namespace blink {
17
18 MediaControlVolumeSliderElement::MediaControlVolumeSliderElement(
19 MediaControlsImpl& media_controls)
20 : MediaControlInputElement(media_controls, kMediaVolumeSlider) {
21 EnsureUserAgentShadowRoot();
22 setType(InputTypeNames::range);
23 setAttribute(HTMLNames::stepAttr, "any");
24 setAttribute(HTMLNames::maxAttr, "1");
25 SetShadowPseudoId(AtomicString("-webkit-media-controls-volume-slider"));
26 }
27
28 void MediaControlVolumeSliderElement::DefaultEventHandler(Event* event) {
29 if (!isConnected() || !GetDocument().IsActive())
30 return;
31
32 MediaControlInputElement::DefaultEventHandler(event);
33
34 if (event->type() == EventTypeNames::mousedown) {
35 Platform::Current()->RecordAction(
36 UserMetricsAction("Media.Controls.VolumeChangeBegin"));
37 }
38
39 if (event->type() == EventTypeNames::mouseup) {
40 Platform::Current()->RecordAction(
41 UserMetricsAction("Media.Controls.VolumeChangeEnd"));
42 }
43
44 if (event->type() == EventTypeNames::input) {
45 double volume = value().ToDouble();
46 MediaElement().setVolume(volume);
47 MediaElement().setMuted(false);
48 if (LayoutObject* layout_object = this->GetLayoutObject())
49 layout_object->SetShouldDoFullPaintInvalidation();
50 }
51 }
52
53 void MediaControlVolumeSliderElement::SetVolume(double volume) {
54 if (value().ToDouble() == volume)
55 return;
56
57 setValue(String::Number(volume));
58 if (LayoutObject* layout_object = this->GetLayoutObject())
59 layout_object->SetShouldDoFullPaintInvalidation();
60 }
61
62 bool MediaControlVolumeSliderElement::WillRespondToMouseMoveEvents() {
63 if (!isConnected() || !GetDocument().IsActive())
64 return false;
65
66 return MediaControlInputElement::WillRespondToMouseMoveEvents();
67 }
68
69 bool MediaControlVolumeSliderElement::WillRespondToMouseClickEvents() {
70 if (!isConnected() || !GetDocument().IsActive())
71 return false;
72
73 return MediaControlInputElement::WillRespondToMouseClickEvents();
74 }
75
76 bool MediaControlVolumeSliderElement::KeepEventInNode(Event* event) {
77 return MediaControlElementsHelper::IsUserInteractionEventForSlider(
78 event, GetLayoutObject());
79 }
80
81 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/media_controls/elements/MediaControlVolumeSliderElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698