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

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

Issue 2820633003: Media Controls: move simple buttons 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/MediaControlToggleClosedCaptionsButtonElement.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/MediaControlToggleClosedCaptionsButtonElement.cpp
diff --git a/third_party/WebKit/Source/modules/media_controls/elements/MediaControlToggleClosedCaptionsButtonElement.cpp b/third_party/WebKit/Source/modules/media_controls/elements/MediaControlToggleClosedCaptionsButtonElement.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e774df1977765ead164e7c21e5b5d66f4bb3ae22
--- /dev/null
+++ b/third_party/WebKit/Source/modules/media_controls/elements/MediaControlToggleClosedCaptionsButtonElement.cpp
@@ -0,0 +1,68 @@
+// 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/MediaControlToggleClosedCaptionsButtonElement.h"
+
+#include "core/InputTypeNames.h"
+#include "core/events/Event.h"
+#include "core/html/HTMLMediaElement.h"
+#include "core/html/track/TextTrackList.h"
+#include "modules/media_controls/MediaControlsImpl.h"
+
+namespace blink {
+
+MediaControlToggleClosedCaptionsButtonElement::
+ MediaControlToggleClosedCaptionsButtonElement(
+ MediaControlsImpl& media_controls)
+ : MediaControlInputElement(media_controls, kMediaShowClosedCaptionsButton) {
+ EnsureUserAgentShadowRoot();
+ setType(InputTypeNames::button);
+ SetShadowPseudoId(
+ AtomicString("-webkit-media-controls-toggle-closed-captions-button"));
+}
+
+bool MediaControlToggleClosedCaptionsButtonElement::
+ WillRespondToMouseClickEvents() {
+ return true;
+}
+
+void MediaControlToggleClosedCaptionsButtonElement::UpdateDisplayType() {
+ bool captions_visible = MediaElement().TextTracksVisible();
+ SetDisplayType(captions_visible ? kMediaHideClosedCaptionsButton
+ : kMediaShowClosedCaptionsButton);
+}
+
+WebLocalizedString::Name
+MediaControlToggleClosedCaptionsButtonElement::GetOverflowStringName() {
+ return WebLocalizedString::kOverflowMenuCaptions;
+}
+
+bool MediaControlToggleClosedCaptionsButtonElement::HasOverflowButton() {
+ return true;
+}
+
+void MediaControlToggleClosedCaptionsButtonElement::DefaultEventHandler(
+ Event* event) {
+ if (event->type() == EventTypeNames::click) {
+ if (MediaElement().textTracks()->length() == 1) {
+ // If only one track exists, toggle it on/off
+ if (MediaElement().textTracks()->HasShowingTracks()) {
+ static_cast<MediaControlsImpl&>(GetMediaControls())
+ .DisableShowingTextTracks();
+ } else {
+ static_cast<MediaControlsImpl&>(GetMediaControls())
+ .ShowTextTrackAtIndex(0);
+ }
+ } else {
+ static_cast<MediaControlsImpl&>(GetMediaControls()).ToggleTextTrackList();
+ }
+
+ UpdateDisplayType();
+ event->SetDefaultHandled();
+ }
+
+ MediaControlInputElement::DefaultEventHandler(event);
+}
+
+} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/modules/media_controls/elements/MediaControlToggleClosedCaptionsButtonElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698