Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 , m_hideMediaControlsTimer(this, &MediaControls::hideMediaControlsTimerFired ) | 67 , m_hideMediaControlsTimer(this, &MediaControls::hideMediaControlsTimerFired ) |
| 68 , m_isMouseOverControls(false) | 68 , m_isMouseOverControls(false) |
| 69 , m_isPausedForScrubbing(false) | 69 , m_isPausedForScrubbing(false) |
| 70 , m_wasLastEventTouch(false) | 70 , m_wasLastEventTouch(false) |
| 71 { | 71 { |
| 72 } | 72 } |
| 73 | 73 |
| 74 PassRefPtrWillBeRawPtr<MediaControls> MediaControls::create(HTMLMediaElement& me diaElement) | 74 PassRefPtrWillBeRawPtr<MediaControls> MediaControls::create(HTMLMediaElement& me diaElement) |
| 75 { | 75 { |
| 76 RefPtrWillBeRawPtr<MediaControls> controls = adoptRefWillBeNoop(new MediaCon trols(mediaElement)); | 76 RefPtrWillBeRawPtr<MediaControls> controls = adoptRefWillBeNoop(new MediaCon trols(mediaElement)); |
| 77 | 77 controls->setShadowPseudoId(AtomicString("-webkit-media-controls", AtomicStr ing::ConstructFromLiteral)); |
|
philipj_slow
2015/01/14 19:19:08
Makes sense given structure of MediaControl*Elemen
| |
| 78 if (controls->initializeControls()) | 78 controls->initializeControls(); |
| 79 return controls.release(); | 79 return controls.release(); |
| 80 | |
| 81 return nullptr; | |
| 82 } | 80 } |
| 83 | 81 |
| 84 // The media controls DOM structure looks like: | 82 // The media controls DOM structure looks like: |
| 85 // | 83 // |
| 86 // MediaControls (-webkit-media-controls) | 84 // MediaControls (-webkit-media-controls) |
| 87 // +-MediaControlOverlayEnclosureElement (-webkit-media-controls-o verlay-enclosure) | 85 // +-MediaControlOverlayEnclosureElement (-webkit-media-controls-o verlay-enclosure) |
| 88 // | +-MediaControlTextTrackContainerElement (-webkit-media-text-track -container) | 86 // | +-MediaControlTextTrackContainerElement (-webkit-media-text-track -container) |
| 89 // | | {when text tracks are enabled} | 87 // | | {when text tracks are enabled} |
| 90 // | +-MediaControlOverlayPlayButtonElement (-webkit-media-controls-o verlay-play-button) | 88 // | +-MediaControlOverlayPlayButtonElement (-webkit-media-controls-o verlay-play-button) |
| 91 // | | {if mediaControlsOverlayPlayButtonEnabled} | 89 // | | {if mediaControlsOverlayPlayButtonEnabled} |
| 92 // | \-MediaControlCastButtonElement (-internal-media-controls -overlay-cast-button) | 90 // | \-MediaControlCastButtonElement (-internal-media-controls -overlay-cast-button) |
| 93 // \-MediaControlPanelEnclosureElement (-webkit-media-controls-e nclosure) | 91 // \-MediaControlPanelEnclosureElement (-webkit-media-controls-e nclosure) |
| 94 // \-MediaControlPanelElement (-webkit-media-controls-p anel) | 92 // \-MediaControlPanelElement (-webkit-media-controls-p anel) |
| 95 // +-MediaControlPlayButtonElement (-webkit-media-controls-p lay-button) | 93 // +-MediaControlPlayButtonElement (-webkit-media-controls-p lay-button) |
| 96 // +-MediaControlTimelineElement (-webkit-media-controls-t imeline) | 94 // +-MediaControlTimelineElement (-webkit-media-controls-t imeline) |
| 97 // +-MediaControlCurrentTimeDisplayElement (-webkit-media-controls-c urrent-time-display) | 95 // +-MediaControlCurrentTimeDisplayElement (-webkit-media-controls-c urrent-time-display) |
| 98 // +-MediaControlTimeRemainingDisplayElement (-webkit-media-controls-t ime-remaining-display) | 96 // +-MediaControlTimeRemainingDisplayElement (-webkit-media-controls-t ime-remaining-display) |
| 99 // +-MediaControlMuteButtonElement (-webkit-media-controls-m ute-button) | 97 // +-MediaControlMuteButtonElement (-webkit-media-controls-m ute-button) |
| 100 // +-MediaControlVolumeSliderElement (-webkit-media-controls-v olume-slider) | 98 // +-MediaControlVolumeSliderElement (-webkit-media-controls-v olume-slider) |
| 101 // +-MediaControlToggleClosedCaptionsButtonElement (-webkit-media-controls-t oggle-closed-captions-button) | 99 // +-MediaControlToggleClosedCaptionsButtonElement (-webkit-media-controls-t oggle-closed-captions-button) |
| 102 // +-MediaControlCastButtonElement (-internal-media-controls -cast-button) | 100 // +-MediaControlCastButtonElement (-internal-media-controls -cast-button) |
| 103 // \-MediaControlFullscreenButtonElement (-webkit-media-controls-f ullscreen-button) | 101 // \-MediaControlFullscreenButtonElement (-webkit-media-controls-f ullscreen-button) |
| 104 // | 102 // |
| 105 // Most of the structure is built by MediaControls::initializeControls() - the | 103 // Most of the structure is built by MediaControls::initializeControls() - the |
| 106 // exception being MediaControlTextTrackContainerElement which is added | 104 // exception being MediaControlTextTrackContainerElement which is added |
| 107 // on-demand by MediaControls::createTextTrackDisplay(). | 105 // on-demand by MediaControls::createTextTrackDisplay(). |
| 108 bool MediaControls::initializeControls() | 106 void MediaControls::initializeControls() |
| 109 { | 107 { |
| 110 TrackExceptionState exceptionState; | |
| 111 | |
| 112 setShadowPseudoId(AtomicString("-webkit-media-controls", AtomicString::Const ructFromLiteral)); | |
| 113 | |
| 114 RefPtrWillBeRawPtr<MediaControlOverlayEnclosureElement> overlayEnclosure = M ediaControlOverlayEnclosureElement::create(*this); | 108 RefPtrWillBeRawPtr<MediaControlOverlayEnclosureElement> overlayEnclosure = M ediaControlOverlayEnclosureElement::create(*this); |
| 115 | 109 |
| 116 if (document().settings() && document().settings()->mediaControlsOverlayPlay ButtonEnabled()) { | 110 if (document().settings() && document().settings()->mediaControlsOverlayPlay ButtonEnabled()) { |
| 117 RefPtrWillBeRawPtr<MediaControlOverlayPlayButtonElement> overlayPlayButt on = MediaControlOverlayPlayButtonElement::create(*this); | 111 RefPtrWillBeRawPtr<MediaControlOverlayPlayButtonElement> overlayPlayButt on = MediaControlOverlayPlayButtonElement::create(*this); |
| 118 m_overlayPlayButton = overlayPlayButton.get(); | 112 m_overlayPlayButton = overlayPlayButton.get(); |
| 119 overlayEnclosure->appendChild(overlayPlayButton.release(), exceptionStat e); | 113 overlayEnclosure->appendChild(overlayPlayButton.release()); |
| 120 if (exceptionState.hadException()) | |
| 121 return false; | |
| 122 } | 114 } |
| 123 | 115 |
| 124 RefPtrWillBeRawPtr<MediaControlCastButtonElement> overlayCastButton = MediaC ontrolCastButtonElement::create(*this, true); | 116 RefPtrWillBeRawPtr<MediaControlCastButtonElement> overlayCastButton = MediaC ontrolCastButtonElement::create(*this, true); |
| 125 m_overlayCastButton = overlayCastButton.get(); | 117 m_overlayCastButton = overlayCastButton.get(); |
| 126 overlayEnclosure->appendChild(overlayCastButton.release(), exceptionState); | 118 overlayEnclosure->appendChild(overlayCastButton.release()); |
| 127 if (exceptionState.hadException()) | |
| 128 return false; | |
| 129 | 119 |
| 130 m_overlayEnclosure = overlayEnclosure.get(); | 120 m_overlayEnclosure = overlayEnclosure.get(); |
| 131 appendChild(overlayEnclosure.release(), exceptionState); | 121 appendChild(overlayEnclosure.release()); |
| 132 if (exceptionState.hadException()) | |
| 133 return false; | |
| 134 | 122 |
| 135 // Create an enclosing element for the panel so we can visually offset the c ontrols correctly. | 123 // Create an enclosing element for the panel so we can visually offset the c ontrols correctly. |
| 136 RefPtrWillBeRawPtr<MediaControlPanelEnclosureElement> enclosure = MediaContr olPanelEnclosureElement::create(*this); | 124 RefPtrWillBeRawPtr<MediaControlPanelEnclosureElement> enclosure = MediaContr olPanelEnclosureElement::create(*this); |
| 137 | 125 |
| 138 RefPtrWillBeRawPtr<MediaControlPanelElement> panel = MediaControlPanelElemen t::create(*this); | 126 RefPtrWillBeRawPtr<MediaControlPanelElement> panel = MediaControlPanelElemen t::create(*this); |
| 139 | 127 |
| 140 RefPtrWillBeRawPtr<MediaControlPlayButtonElement> playButton = MediaControlP layButtonElement::create(*this); | 128 RefPtrWillBeRawPtr<MediaControlPlayButtonElement> playButton = MediaControlP layButtonElement::create(*this); |
| 141 m_playButton = playButton.get(); | 129 m_playButton = playButton.get(); |
| 142 panel->appendChild(playButton.release(), exceptionState); | 130 panel->appendChild(playButton.release()); |
| 143 if (exceptionState.hadException()) | |
| 144 return false; | |
| 145 | 131 |
| 146 RefPtrWillBeRawPtr<MediaControlTimelineElement> timeline = MediaControlTimel ineElement::create(*this); | 132 RefPtrWillBeRawPtr<MediaControlTimelineElement> timeline = MediaControlTimel ineElement::create(*this); |
| 147 m_timeline = timeline.get(); | 133 m_timeline = timeline.get(); |
| 148 panel->appendChild(timeline.release(), exceptionState); | 134 panel->appendChild(timeline.release()); |
| 149 if (exceptionState.hadException()) | |
| 150 return false; | |
| 151 | 135 |
| 152 RefPtrWillBeRawPtr<MediaControlCurrentTimeDisplayElement> currentTimeDisplay = MediaControlCurrentTimeDisplayElement::create(*this); | 136 RefPtrWillBeRawPtr<MediaControlCurrentTimeDisplayElement> currentTimeDisplay = MediaControlCurrentTimeDisplayElement::create(*this); |
| 153 m_currentTimeDisplay = currentTimeDisplay.get(); | 137 m_currentTimeDisplay = currentTimeDisplay.get(); |
| 154 m_currentTimeDisplay->hide(); | 138 m_currentTimeDisplay->hide(); |
| 155 panel->appendChild(currentTimeDisplay.release(), exceptionState); | 139 panel->appendChild(currentTimeDisplay.release()); |
| 156 if (exceptionState.hadException()) | |
| 157 return false; | |
| 158 | 140 |
| 159 RefPtrWillBeRawPtr<MediaControlTimeRemainingDisplayElement> durationDisplay = MediaControlTimeRemainingDisplayElement::create(*this); | 141 RefPtrWillBeRawPtr<MediaControlTimeRemainingDisplayElement> durationDisplay = MediaControlTimeRemainingDisplayElement::create(*this); |
| 160 m_durationDisplay = durationDisplay.get(); | 142 m_durationDisplay = durationDisplay.get(); |
| 161 panel->appendChild(durationDisplay.release(), exceptionState); | 143 panel->appendChild(durationDisplay.release()); |
| 162 if (exceptionState.hadException()) | |
| 163 return false; | |
| 164 | 144 |
| 165 RefPtrWillBeRawPtr<MediaControlMuteButtonElement> muteButton = MediaControlM uteButtonElement::create(*this); | 145 RefPtrWillBeRawPtr<MediaControlMuteButtonElement> muteButton = MediaControlM uteButtonElement::create(*this); |
| 166 m_muteButton = muteButton.get(); | 146 m_muteButton = muteButton.get(); |
| 167 panel->appendChild(muteButton.release(), exceptionState); | 147 panel->appendChild(muteButton.release()); |
| 168 if (exceptionState.hadException()) | |
| 169 return false; | |
| 170 | 148 |
| 171 RefPtrWillBeRawPtr<MediaControlVolumeSliderElement> slider = MediaControlVol umeSliderElement::create(*this); | 149 RefPtrWillBeRawPtr<MediaControlVolumeSliderElement> slider = MediaControlVol umeSliderElement::create(*this); |
| 172 m_volumeSlider = slider.get(); | 150 m_volumeSlider = slider.get(); |
| 173 panel->appendChild(slider.release(), exceptionState); | 151 panel->appendChild(slider.release()); |
| 174 if (exceptionState.hadException()) | |
| 175 return false; | |
| 176 | 152 |
| 177 RefPtrWillBeRawPtr<MediaControlToggleClosedCaptionsButtonElement> toggleClos edCaptionsButton = MediaControlToggleClosedCaptionsButtonElement::create(*this); | 153 RefPtrWillBeRawPtr<MediaControlToggleClosedCaptionsButtonElement> toggleClos edCaptionsButton = MediaControlToggleClosedCaptionsButtonElement::create(*this); |
| 178 m_toggleClosedCaptionsButton = toggleClosedCaptionsButton.get(); | 154 m_toggleClosedCaptionsButton = toggleClosedCaptionsButton.get(); |
| 179 panel->appendChild(toggleClosedCaptionsButton.release(), exceptionState); | 155 panel->appendChild(toggleClosedCaptionsButton.release()); |
| 180 if (exceptionState.hadException()) | |
| 181 return false; | |
| 182 | 156 |
| 183 RefPtrWillBeRawPtr<MediaControlCastButtonElement> castButton = MediaControlC astButtonElement::create(*this, false); | 157 RefPtrWillBeRawPtr<MediaControlCastButtonElement> castButton = MediaControlC astButtonElement::create(*this, false); |
| 184 m_castButton = castButton.get(); | 158 m_castButton = castButton.get(); |
| 185 panel->appendChild(castButton.release(), exceptionState); | 159 panel->appendChild(castButton.release()); |
| 186 if (exceptionState.hadException()) | |
| 187 return false; | |
| 188 | 160 |
| 189 RefPtrWillBeRawPtr<MediaControlFullscreenButtonElement> fullscreenButton = M ediaControlFullscreenButtonElement::create(*this); | 161 RefPtrWillBeRawPtr<MediaControlFullscreenButtonElement> fullscreenButton = M ediaControlFullscreenButtonElement::create(*this); |
| 190 m_fullScreenButton = fullscreenButton.get(); | 162 m_fullScreenButton = fullscreenButton.get(); |
| 191 panel->appendChild(fullscreenButton.release(), exceptionState); | 163 panel->appendChild(fullscreenButton.release()); |
| 192 if (exceptionState.hadException()) | |
| 193 return false; | |
| 194 | 164 |
| 195 m_panel = panel.get(); | 165 m_panel = panel.get(); |
| 196 enclosure->appendChild(panel.release(), exceptionState); | 166 enclosure->appendChild(panel.release()); |
| 197 if (exceptionState.hadException()) | |
| 198 return false; | |
| 199 | 167 |
| 200 m_enclosure = enclosure.get(); | 168 m_enclosure = enclosure.get(); |
| 201 appendChild(enclosure.release(), exceptionState); | 169 appendChild(enclosure.release()); |
| 202 if (exceptionState.hadException()) | |
| 203 return false; | |
| 204 | |
| 205 return true; | |
| 206 } | 170 } |
| 207 | 171 |
| 208 void MediaControls::reset() | 172 void MediaControls::reset() |
| 209 { | 173 { |
| 210 double duration = mediaElement().duration(); | 174 double duration = mediaElement().duration(); |
| 211 m_durationDisplay->setInnerText(RenderTheme::theme().formatMediaControlsTime (duration), ASSERT_NO_EXCEPTION); | 175 m_durationDisplay->setInnerText(RenderTheme::theme().formatMediaControlsTime (duration), ASSERT_NO_EXCEPTION); |
| 212 m_durationDisplay->setCurrentValue(duration); | 176 m_durationDisplay->setCurrentValue(duration); |
| 213 | 177 |
| 214 updatePlayState(); | 178 updatePlayState(); |
| 215 | 179 |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 601 visitor->trace(m_toggleClosedCaptionsButton); | 565 visitor->trace(m_toggleClosedCaptionsButton); |
| 602 visitor->trace(m_fullScreenButton); | 566 visitor->trace(m_fullScreenButton); |
| 603 visitor->trace(m_durationDisplay); | 567 visitor->trace(m_durationDisplay); |
| 604 visitor->trace(m_enclosure); | 568 visitor->trace(m_enclosure); |
| 605 visitor->trace(m_castButton); | 569 visitor->trace(m_castButton); |
| 606 visitor->trace(m_overlayCastButton); | 570 visitor->trace(m_overlayCastButton); |
| 607 HTMLDivElement::trace(visitor); | 571 HTMLDivElement::trace(visitor); |
| 608 } | 572 } |
| 609 | 573 |
| 610 } | 574 } |
| OLD | NEW |