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

Side by Side Diff: Source/core/html/shadow/MediaControls.cpp

Issue 949203002: Separate the text track container from the media controls (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: address nits Created 5 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/html/shadow/MediaControls.h ('k') | Source/core/html/track/TextTrackContainer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
3 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 3 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 static bool fullscreenIsSupported(const Document& document) 45 static bool fullscreenIsSupported(const Document& document)
46 { 46 {
47 return !document.settings() || document.settings()->fullscreenSupported(); 47 return !document.settings() || document.settings()->fullscreenSupported();
48 } 48 }
49 49
50 MediaControls::MediaControls(HTMLMediaElement& mediaElement) 50 MediaControls::MediaControls(HTMLMediaElement& mediaElement)
51 : HTMLDivElement(mediaElement.document()) 51 : HTMLDivElement(mediaElement.document())
52 , m_mediaElement(&mediaElement) 52 , m_mediaElement(&mediaElement)
53 , m_panel(nullptr) 53 , m_panel(nullptr)
54 , m_textTrackContainer(nullptr)
55 , m_overlayPlayButton(nullptr) 54 , m_overlayPlayButton(nullptr)
56 , m_overlayEnclosure(nullptr) 55 , m_overlayEnclosure(nullptr)
57 , m_playButton(nullptr) 56 , m_playButton(nullptr)
58 , m_currentTimeDisplay(nullptr) 57 , m_currentTimeDisplay(nullptr)
59 , m_timeline(nullptr) 58 , m_timeline(nullptr)
60 , m_muteButton(nullptr) 59 , m_muteButton(nullptr)
61 , m_volumeSlider(nullptr) 60 , m_volumeSlider(nullptr)
62 , m_toggleClosedCaptionsButton(nullptr) 61 , m_toggleClosedCaptionsButton(nullptr)
63 , m_fullScreenButton(nullptr) 62 , m_fullScreenButton(nullptr)
64 , m_castButton(nullptr) 63 , m_castButton(nullptr)
(...skipping 12 matching lines...) Expand all
77 RefPtrWillBeRawPtr<MediaControls> controls = adoptRefWillBeNoop(new MediaCon trols(mediaElement)); 76 RefPtrWillBeRawPtr<MediaControls> controls = adoptRefWillBeNoop(new MediaCon trols(mediaElement));
78 controls->setShadowPseudoId(AtomicString("-webkit-media-controls", AtomicStr ing::ConstructFromLiteral)); 77 controls->setShadowPseudoId(AtomicString("-webkit-media-controls", AtomicStr ing::ConstructFromLiteral));
79 controls->initializeControls(); 78 controls->initializeControls();
80 return controls.release(); 79 return controls.release();
81 } 80 }
82 81
83 // The media controls DOM structure looks like: 82 // The media controls DOM structure looks like:
84 // 83 //
85 // MediaControls (-webkit-media-controls) 84 // MediaControls (-webkit-media-controls)
86 // +-MediaControlOverlayEnclosureElement (-webkit-media-controls-o verlay-enclosure) 85 // +-MediaControlOverlayEnclosureElement (-webkit-media-controls-o verlay-enclosure)
87 // | +-TextTrackContainer (-webkit-media-text-track -container)
88 // | | {when text tracks are enabled}
89 // | +-MediaControlOverlayPlayButtonElement (-webkit-media-controls-o verlay-play-button) 86 // | +-MediaControlOverlayPlayButtonElement (-webkit-media-controls-o verlay-play-button)
90 // | | {if mediaControlsOverlayPlayButtonEnabled} 87 // | | {if mediaControlsOverlayPlayButtonEnabled}
91 // | \-MediaControlCastButtonElement (-internal-media-controls -overlay-cast-button) 88 // | \-MediaControlCastButtonElement (-internal-media-controls -overlay-cast-button)
92 // \-MediaControlPanelEnclosureElement (-webkit-media-controls-e nclosure) 89 // \-MediaControlPanelEnclosureElement (-webkit-media-controls-e nclosure)
93 // \-MediaControlPanelElement (-webkit-media-controls-p anel) 90 // \-MediaControlPanelElement (-webkit-media-controls-p anel)
94 // +-MediaControlPlayButtonElement (-webkit-media-controls-p lay-button) 91 // +-MediaControlPlayButtonElement (-webkit-media-controls-p lay-button)
95 // +-MediaControlTimelineElement (-webkit-media-controls-t imeline) 92 // +-MediaControlTimelineElement (-webkit-media-controls-t imeline)
96 // +-MediaControlCurrentTimeDisplayElement (-webkit-media-controls-c urrent-time-display) 93 // +-MediaControlCurrentTimeDisplayElement (-webkit-media-controls-c urrent-time-display)
97 // +-MediaControlTimeRemainingDisplayElement (-webkit-media-controls-t ime-remaining-display) 94 // +-MediaControlTimeRemainingDisplayElement (-webkit-media-controls-t ime-remaining-display)
98 // +-MediaControlMuteButtonElement (-webkit-media-controls-m ute-button) 95 // +-MediaControlMuteButtonElement (-webkit-media-controls-m ute-button)
99 // +-MediaControlVolumeSliderElement (-webkit-media-controls-v olume-slider) 96 // +-MediaControlVolumeSliderElement (-webkit-media-controls-v olume-slider)
100 // +-MediaControlToggleClosedCaptionsButtonElement (-webkit-media-controls-t oggle-closed-captions-button) 97 // +-MediaControlToggleClosedCaptionsButtonElement (-webkit-media-controls-t oggle-closed-captions-button)
101 // +-MediaControlCastButtonElement (-internal-media-controls -cast-button) 98 // +-MediaControlCastButtonElement (-internal-media-controls -cast-button)
102 // \-MediaControlFullscreenButtonElement (-webkit-media-controls-f ullscreen-button) 99 // \-MediaControlFullscreenButtonElement (-webkit-media-controls-f ullscreen-button)
103 //
104 // Most of the structure is built by MediaControls::initializeControls() - the
105 // exception being TextTrackContainer which is added on-demand by
106 // MediaControls::textTrackContainer().
107 void MediaControls::initializeControls() 100 void MediaControls::initializeControls()
108 { 101 {
109 RefPtrWillBeRawPtr<MediaControlOverlayEnclosureElement> overlayEnclosure = M ediaControlOverlayEnclosureElement::create(*this); 102 RefPtrWillBeRawPtr<MediaControlOverlayEnclosureElement> overlayEnclosure = M ediaControlOverlayEnclosureElement::create(*this);
110 103
111 if (document().settings() && document().settings()->mediaControlsOverlayPlay ButtonEnabled()) { 104 if (document().settings() && document().settings()->mediaControlsOverlayPlay ButtonEnabled()) {
112 RefPtrWillBeRawPtr<MediaControlOverlayPlayButtonElement> overlayPlayButt on = MediaControlOverlayPlayButtonElement::create(*this); 105 RefPtrWillBeRawPtr<MediaControlOverlayPlayButtonElement> overlayPlayButt on = MediaControlOverlayPlayButtonElement::create(*this);
113 m_overlayPlayButton = overlayPlayButton.get(); 106 m_overlayPlayButton = overlayPlayButton.get();
114 overlayEnclosure->appendChild(overlayPlayButton.release()); 107 overlayEnclosure->appendChild(overlayPlayButton.release());
115 } 108 }
116 109
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 bool MediaControls::containsRelatedTarget(Event* event) 503 bool MediaControls::containsRelatedTarget(Event* event)
511 { 504 {
512 if (!event->isMouseEvent()) 505 if (!event->isMouseEvent())
513 return false; 506 return false;
514 EventTarget* relatedTarget = toMouseEvent(event)->relatedTarget(); 507 EventTarget* relatedTarget = toMouseEvent(event)->relatedTarget();
515 if (!relatedTarget) 508 if (!relatedTarget)
516 return false; 509 return false;
517 return contains(relatedTarget->toNode()); 510 return contains(relatedTarget->toNode());
518 } 511 }
519 512
520 TextTrackContainer* MediaControls::textTrackContainer()
521 {
522 if (!m_textTrackContainer) {
523 RefPtrWillBeRawPtr<TextTrackContainer> textTrackContainer = TextTrackCon tainer::create(mediaElement().document());
524 m_textTrackContainer = textTrackContainer.get();
525
526 // Insert it before (behind) all other control elements.
527 m_overlayEnclosure->insertBefore(textTrackContainer.release(), m_overlay Enclosure->firstChild());
528 }
529 return m_textTrackContainer.get();
530 }
531
532 DEFINE_TRACE(MediaControls) 513 DEFINE_TRACE(MediaControls)
533 { 514 {
534 visitor->trace(m_mediaElement); 515 visitor->trace(m_mediaElement);
535 visitor->trace(m_panel); 516 visitor->trace(m_panel);
536 visitor->trace(m_textTrackContainer);
537 visitor->trace(m_overlayPlayButton); 517 visitor->trace(m_overlayPlayButton);
538 visitor->trace(m_overlayEnclosure); 518 visitor->trace(m_overlayEnclosure);
539 visitor->trace(m_playButton); 519 visitor->trace(m_playButton);
540 visitor->trace(m_currentTimeDisplay); 520 visitor->trace(m_currentTimeDisplay);
541 visitor->trace(m_timeline); 521 visitor->trace(m_timeline);
542 visitor->trace(m_muteButton); 522 visitor->trace(m_muteButton);
543 visitor->trace(m_volumeSlider); 523 visitor->trace(m_volumeSlider);
544 visitor->trace(m_toggleClosedCaptionsButton); 524 visitor->trace(m_toggleClosedCaptionsButton);
545 visitor->trace(m_fullScreenButton); 525 visitor->trace(m_fullScreenButton);
546 visitor->trace(m_durationDisplay); 526 visitor->trace(m_durationDisplay);
547 visitor->trace(m_enclosure); 527 visitor->trace(m_enclosure);
548 visitor->trace(m_castButton); 528 visitor->trace(m_castButton);
549 visitor->trace(m_overlayCastButton); 529 visitor->trace(m_overlayCastButton);
550 HTMLDivElement::trace(visitor); 530 HTMLDivElement::trace(visitor);
551 } 531 }
552 532
553 } 533 }
OLDNEW
« no previous file with comments | « Source/core/html/shadow/MediaControls.h ('k') | Source/core/html/track/TextTrackContainer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698