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

Side by Side 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 unified diff | Download patch
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/MediaControlToggleClosedCaptionsButton Element.h"
6
7 #include "core/InputTypeNames.h"
8 #include "core/events/Event.h"
9 #include "core/html/HTMLMediaElement.h"
10 #include "core/html/track/TextTrackList.h"
11 #include "modules/media_controls/MediaControlsImpl.h"
12
13 namespace blink {
14
15 MediaControlToggleClosedCaptionsButtonElement::
16 MediaControlToggleClosedCaptionsButtonElement(
17 MediaControlsImpl& media_controls)
18 : MediaControlInputElement(media_controls, kMediaShowClosedCaptionsButton) {
19 EnsureUserAgentShadowRoot();
20 setType(InputTypeNames::button);
21 SetShadowPseudoId(
22 AtomicString("-webkit-media-controls-toggle-closed-captions-button"));
23 }
24
25 bool MediaControlToggleClosedCaptionsButtonElement::
26 WillRespondToMouseClickEvents() {
27 return true;
28 }
29
30 void MediaControlToggleClosedCaptionsButtonElement::UpdateDisplayType() {
31 bool captions_visible = MediaElement().TextTracksVisible();
32 SetDisplayType(captions_visible ? kMediaHideClosedCaptionsButton
33 : kMediaShowClosedCaptionsButton);
34 }
35
36 WebLocalizedString::Name
37 MediaControlToggleClosedCaptionsButtonElement::GetOverflowStringName() {
38 return WebLocalizedString::kOverflowMenuCaptions;
39 }
40
41 bool MediaControlToggleClosedCaptionsButtonElement::HasOverflowButton() {
42 return true;
43 }
44
45 void MediaControlToggleClosedCaptionsButtonElement::DefaultEventHandler(
46 Event* event) {
47 if (event->type() == EventTypeNames::click) {
48 if (MediaElement().textTracks()->length() == 1) {
49 // If only one track exists, toggle it on/off
50 if (MediaElement().textTracks()->HasShowingTracks()) {
51 static_cast<MediaControlsImpl&>(GetMediaControls())
52 .DisableShowingTextTracks();
53 } else {
54 static_cast<MediaControlsImpl&>(GetMediaControls())
55 .ShowTextTrackAtIndex(0);
56 }
57 } else {
58 static_cast<MediaControlsImpl&>(GetMediaControls()).ToggleTextTrackList();
59 }
60
61 UpdateDisplayType();
62 event->SetDefaultHandled();
63 }
64
65 MediaControlInputElement::DefaultEventHandler(event);
66 }
67
68 } // namespace blink
OLDNEW
« 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