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

Unified Diff: third_party/WebKit/Source/modules/media_controls/elements/MediaControlMuteButtonElement.cpp

Issue 2811703002: Move a few media controls elements into modules/media_controls/elements/. (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
Index: third_party/WebKit/Source/modules/media_controls/elements/MediaControlMuteButtonElement.cpp
diff --git a/third_party/WebKit/Source/modules/media_controls/elements/MediaControlMuteButtonElement.cpp b/third_party/WebKit/Source/modules/media_controls/elements/MediaControlMuteButtonElement.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c4bc99730b2d1ab3e01d1c3ac4f1b1b72c6fbcd2
--- /dev/null
+++ b/third_party/WebKit/Source/modules/media_controls/elements/MediaControlMuteButtonElement.cpp
@@ -0,0 +1,65 @@
+// 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/MediaControlMuteButtonElement.h"
+
+#include "core/InputTypeNames.h"
+#include "core/events/Event.h"
+#include "core/html/HTMLMediaElement.h"
+#include "modules/media_controls/MediaControlsImpl.h"
+#include "public/platform/Platform.h"
+
+namespace blink {
+
+MediaControlMuteButtonElement::MediaControlMuteButtonElement(
+ MediaControlsImpl& media_controls)
+ : MediaControlInputElement(media_controls, kMediaMuteButton) {
+ EnsureUserAgentShadowRoot();
+ setType(InputTypeNames::button);
+ SetShadowPseudoId(AtomicString("-webkit-media-controls-mute-button"));
+}
+
+bool MediaControlMuteButtonElement::WillRespondToMouseClickEvents() {
+ return true;
+}
+
+void MediaControlMuteButtonElement::UpdateDisplayType() {
+ // TODO(mlamouri): checking for volume == 0 because the mute button will look
+ // 'muted' when the volume is 0 even if the element is not muted. This allows
+ // the painting and the display type to actually match.
+ SetDisplayType((MediaElement().muted() || MediaElement().volume() == 0)
+ ? kMediaUnMuteButton
+ : kMediaMuteButton);
+ UpdateOverflowString();
+}
+
+WebLocalizedString::Name
+MediaControlMuteButtonElement::GetOverflowStringName() {
+ if (MediaElement().muted())
+ return WebLocalizedString::kOverflowMenuUnmute;
+ return WebLocalizedString::kOverflowMenuMute;
+}
+
+bool MediaControlMuteButtonElement::HasOverflowButton() {
+ return true;
+}
+
+void MediaControlMuteButtonElement::DefaultEventHandler(Event* event) {
+ if (event->type() == EventTypeNames::click) {
+ if (MediaElement().muted()) {
+ Platform::Current()->RecordAction(
+ UserMetricsAction("Media.Controls.Unmute"));
+ } else {
+ Platform::Current()->RecordAction(
+ UserMetricsAction("Media.Controls.Mute"));
+ }
+
+ MediaElement().setMuted(!MediaElement().muted());
+ event->SetDefaultHandled();
+ }
+
+ MediaControlInputElement::DefaultEventHandler(event);
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698