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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« 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