Index: third_party/WebKit/Source/modules/media_controls/elements/MediaControlVolumeSliderElement.cpp |
diff --git a/third_party/WebKit/Source/modules/media_controls/elements/MediaControlVolumeSliderElement.cpp b/third_party/WebKit/Source/modules/media_controls/elements/MediaControlVolumeSliderElement.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e51caa259c3ed78a768cbb9e8e8fb6925b84eb90 |
--- /dev/null |
+++ b/third_party/WebKit/Source/modules/media_controls/elements/MediaControlVolumeSliderElement.cpp |
@@ -0,0 +1,81 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "modules/media_controls/elements/MediaControlVolumeSliderElement.h" |
+ |
+#include "core/HTMLNames.h" |
+#include "core/InputTypeNames.h" |
+#include "core/events/Event.h" |
+#include "core/html/HTMLMediaElement.h" |
+#include "core/layout/LayoutObject.h" |
+#include "modules/media_controls/MediaControlsImpl.h" |
+#include "modules/media_controls/elements/MediaControlElementsHelper.h" |
+#include "public/platform/Platform.h" |
+ |
+namespace blink { |
+ |
+MediaControlVolumeSliderElement::MediaControlVolumeSliderElement( |
+ MediaControlsImpl& media_controls) |
+ : MediaControlInputElement(media_controls, kMediaVolumeSlider) { |
+ EnsureUserAgentShadowRoot(); |
+ setType(InputTypeNames::range); |
+ setAttribute(HTMLNames::stepAttr, "any"); |
+ setAttribute(HTMLNames::maxAttr, "1"); |
+ SetShadowPseudoId(AtomicString("-webkit-media-controls-volume-slider")); |
+} |
+ |
+void MediaControlVolumeSliderElement::DefaultEventHandler(Event* event) { |
+ if (!isConnected() || !GetDocument().IsActive()) |
+ return; |
+ |
+ MediaControlInputElement::DefaultEventHandler(event); |
+ |
+ if (event->type() == EventTypeNames::mousedown) { |
+ Platform::Current()->RecordAction( |
+ UserMetricsAction("Media.Controls.VolumeChangeBegin")); |
+ } |
+ |
+ if (event->type() == EventTypeNames::mouseup) { |
+ Platform::Current()->RecordAction( |
+ UserMetricsAction("Media.Controls.VolumeChangeEnd")); |
+ } |
+ |
+ if (event->type() == EventTypeNames::input) { |
+ double volume = value().ToDouble(); |
+ MediaElement().setVolume(volume); |
+ MediaElement().setMuted(false); |
+ if (LayoutObject* layout_object = this->GetLayoutObject()) |
+ layout_object->SetShouldDoFullPaintInvalidation(); |
+ } |
+} |
+ |
+void MediaControlVolumeSliderElement::SetVolume(double volume) { |
+ if (value().ToDouble() == volume) |
+ return; |
+ |
+ setValue(String::Number(volume)); |
+ if (LayoutObject* layout_object = this->GetLayoutObject()) |
+ layout_object->SetShouldDoFullPaintInvalidation(); |
+} |
+ |
+bool MediaControlVolumeSliderElement::WillRespondToMouseMoveEvents() { |
+ if (!isConnected() || !GetDocument().IsActive()) |
+ return false; |
+ |
+ return MediaControlInputElement::WillRespondToMouseMoveEvents(); |
+} |
+ |
+bool MediaControlVolumeSliderElement::WillRespondToMouseClickEvents() { |
+ if (!isConnected() || !GetDocument().IsActive()) |
+ return false; |
+ |
+ return MediaControlInputElement::WillRespondToMouseClickEvents(); |
+} |
+ |
+bool MediaControlVolumeSliderElement::KeepEventInNode(Event* event) { |
+ return MediaControlElementsHelper::IsUserInteractionEventForSlider( |
+ event, GetLayoutObject()); |
+} |
+ |
+} // namespace blink |