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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 , m_textDisplayContainer(nullptr) | 47 , m_textDisplayContainer(nullptr) |
| 48 , m_overlayPlayButton(nullptr) | 48 , m_overlayPlayButton(nullptr) |
| 49 , m_overlayEnclosure(nullptr) | 49 , m_overlayEnclosure(nullptr) |
| 50 , m_playButton(nullptr) | 50 , m_playButton(nullptr) |
| 51 , m_currentTimeDisplay(nullptr) | 51 , m_currentTimeDisplay(nullptr) |
| 52 , m_timeline(nullptr) | 52 , m_timeline(nullptr) |
| 53 , m_muteButton(nullptr) | 53 , m_muteButton(nullptr) |
| 54 , m_volumeSlider(nullptr) | 54 , m_volumeSlider(nullptr) |
| 55 , m_toggleClosedCaptionsButton(nullptr) | 55 , m_toggleClosedCaptionsButton(nullptr) |
| 56 , m_fullScreenButton(nullptr) | 56 , m_fullScreenButton(nullptr) |
| 57 , m_castButton(nullptr) | |
| 58 , m_overlayCastButton(nullptr) | |
| 57 , m_durationDisplay(nullptr) | 59 , m_durationDisplay(nullptr) |
| 58 , m_enclosure(nullptr) | 60 , m_enclosure(nullptr) |
| 59 , m_hideMediaControlsTimer(this, &MediaControls::hideMediaControlsTimerFired ) | 61 , m_hideMediaControlsTimer(this, &MediaControls::hideMediaControlsTimerFired ) |
| 60 , m_isMouseOverControls(false) | 62 , m_isMouseOverControls(false) |
| 61 , m_isPausedForScrubbing(false) | 63 , m_isPausedForScrubbing(false) |
| 62 { | 64 { |
| 63 } | 65 } |
| 64 | 66 |
| 65 PassRefPtrWillBeRawPtr<MediaControls> MediaControls::create(HTMLMediaElement& me diaElement) | 67 PassRefPtrWillBeRawPtr<MediaControls> MediaControls::create(HTMLMediaElement& me diaElement) |
| 66 { | 68 { |
| 67 RefPtrWillBeRawPtr<MediaControls> controls = adoptRefWillBeNoop(new MediaCon trols(mediaElement)); | 69 RefPtrWillBeRawPtr<MediaControls> controls = adoptRefWillBeNoop(new MediaCon trols(mediaElement)); |
| 68 | 70 |
| 69 if (controls->initializeControls()) | 71 if (controls->initializeControls()) |
| 70 return controls.release(); | 72 return controls.release(); |
| 71 | 73 |
| 72 return nullptr; | 74 return nullptr; |
| 73 } | 75 } |
| 74 | 76 |
| 75 bool MediaControls::initializeControls() | 77 bool MediaControls::initializeControls() |
| 76 { | 78 { |
| 77 TrackExceptionState exceptionState; | 79 TrackExceptionState exceptionState; |
| 78 | 80 |
| 81 RefPtrWillBeRawPtr<MediaControlOverlayEnclosureElement> overlayEnclosure = M ediaControlOverlayEnclosureElement::create(*this); | |
| 82 | |
| 79 if (document().settings() && document().settings()->mediaControlsOverlayPlay ButtonEnabled()) { | 83 if (document().settings() && document().settings()->mediaControlsOverlayPlay ButtonEnabled()) { |
| 80 RefPtrWillBeRawPtr<MediaControlOverlayEnclosureElement> overlayEnclosure = MediaControlOverlayEnclosureElement::create(*this); | |
| 81 RefPtrWillBeRawPtr<MediaControlOverlayPlayButtonElement> overlayPlayButt on = MediaControlOverlayPlayButtonElement::create(*this); | 84 RefPtrWillBeRawPtr<MediaControlOverlayPlayButtonElement> overlayPlayButt on = MediaControlOverlayPlayButtonElement::create(*this); |
| 82 m_overlayPlayButton = overlayPlayButton.get(); | 85 m_overlayPlayButton = overlayPlayButton.get(); |
| 83 overlayEnclosure->appendChild(overlayPlayButton.release(), exceptionStat e); | 86 overlayEnclosure->appendChild(overlayPlayButton.release(), exceptionStat e); |
| 84 if (exceptionState.hadException()) | 87 if (exceptionState.hadException()) |
| 85 return false; | 88 return false; |
| 89 } | |
| 86 | 90 |
| 87 m_overlayEnclosure = overlayEnclosure.get(); | 91 RefPtrWillBeRawPtr<MediaControlOverlayCastButtonElement> overlayCastButton = MediaControlOverlayCastButtonElement::create(*this); |
| 88 appendChild(overlayEnclosure.release(), exceptionState); | 92 m_overlayCastButton = overlayCastButton.get(); |
| 89 if (exceptionState.hadException()) | 93 overlayEnclosure->appendChild(overlayCastButton.release(), exceptionState); |
| 90 return false; | 94 if (exceptionState.hadException()) |
| 91 } | 95 return false; |
| 96 | |
| 97 m_overlayEnclosure = overlayEnclosure.get(); | |
| 98 appendChild(overlayEnclosure.release(), exceptionState); | |
| 99 if (exceptionState.hadException()) | |
| 100 return false; | |
| 92 | 101 |
| 93 // Create an enclosing element for the panel so we can visually offset the c ontrols correctly. | 102 // Create an enclosing element for the panel so we can visually offset the c ontrols correctly. |
| 94 RefPtrWillBeRawPtr<MediaControlPanelEnclosureElement> enclosure = MediaContr olPanelEnclosureElement::create(*this); | 103 RefPtrWillBeRawPtr<MediaControlPanelEnclosureElement> enclosure = MediaContr olPanelEnclosureElement::create(*this); |
| 95 | 104 |
| 96 RefPtrWillBeRawPtr<MediaControlPanelElement> panel = MediaControlPanelElemen t::create(*this); | 105 RefPtrWillBeRawPtr<MediaControlPanelElement> panel = MediaControlPanelElemen t::create(*this); |
| 97 | 106 |
| 98 RefPtrWillBeRawPtr<MediaControlPlayButtonElement> playButton = MediaControlP layButtonElement::create(*this); | 107 RefPtrWillBeRawPtr<MediaControlPlayButtonElement> playButton = MediaControlP layButtonElement::create(*this); |
| 99 m_playButton = playButton.get(); | 108 m_playButton = playButton.get(); |
| 100 panel->appendChild(playButton.release(), exceptionState); | 109 panel->appendChild(playButton.release(), exceptionState); |
| 101 if (exceptionState.hadException()) | 110 if (exceptionState.hadException()) |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 131 panel->appendChild(slider.release(), exceptionState); | 140 panel->appendChild(slider.release(), exceptionState); |
| 132 if (exceptionState.hadException()) | 141 if (exceptionState.hadException()) |
| 133 return false; | 142 return false; |
| 134 | 143 |
| 135 RefPtrWillBeRawPtr<MediaControlToggleClosedCaptionsButtonElement> toggleClos edCaptionsButton = MediaControlToggleClosedCaptionsButtonElement::create(*this); | 144 RefPtrWillBeRawPtr<MediaControlToggleClosedCaptionsButtonElement> toggleClos edCaptionsButton = MediaControlToggleClosedCaptionsButtonElement::create(*this); |
| 136 m_toggleClosedCaptionsButton = toggleClosedCaptionsButton.get(); | 145 m_toggleClosedCaptionsButton = toggleClosedCaptionsButton.get(); |
| 137 panel->appendChild(toggleClosedCaptionsButton.release(), exceptionState); | 146 panel->appendChild(toggleClosedCaptionsButton.release(), exceptionState); |
| 138 if (exceptionState.hadException()) | 147 if (exceptionState.hadException()) |
| 139 return false; | 148 return false; |
| 140 | 149 |
| 150 RefPtrWillBeRawPtr<MediaControlCastButtonElement> castButton = MediaControlC astButtonElement::create(*this); | |
| 151 m_castButton = castButton.get(); | |
| 152 panel->appendChild(castButton.release(), exceptionState); | |
| 153 if (exceptionState.hadException()) | |
| 154 return false; | |
| 155 | |
| 141 RefPtrWillBeRawPtr<MediaControlFullscreenButtonElement> fullscreenButton = M ediaControlFullscreenButtonElement::create(*this); | 156 RefPtrWillBeRawPtr<MediaControlFullscreenButtonElement> fullscreenButton = M ediaControlFullscreenButtonElement::create(*this); |
| 142 m_fullScreenButton = fullscreenButton.get(); | 157 m_fullScreenButton = fullscreenButton.get(); |
| 143 panel->appendChild(fullscreenButton.release(), exceptionState); | 158 panel->appendChild(fullscreenButton.release(), exceptionState); |
| 144 if (exceptionState.hadException()) | 159 if (exceptionState.hadException()) |
| 145 return false; | 160 return false; |
| 146 | 161 |
| 147 m_panel = panel.get(); | 162 m_panel = panel.get(); |
| 148 enclosure->appendChild(panel.release(), exceptionState); | 163 enclosure->appendChild(panel.release(), exceptionState); |
| 149 if (exceptionState.hadException()) | 164 if (exceptionState.hadException()) |
| 150 return false; | 165 return false; |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 176 m_volumeSlider->show(); | 191 m_volumeSlider->show(); |
| 177 updateVolume(); | 192 updateVolume(); |
| 178 | 193 |
| 179 refreshClosedCaptionsButtonVisibility(); | 194 refreshClosedCaptionsButtonVisibility(); |
| 180 | 195 |
| 181 if (mediaElement().hasVideo()) | 196 if (mediaElement().hasVideo()) |
| 182 m_fullScreenButton->show(); | 197 m_fullScreenButton->show(); |
| 183 else | 198 else |
| 184 m_fullScreenButton->hide(); | 199 m_fullScreenButton->hide(); |
| 185 | 200 |
| 201 refreshCastButtonVisibility(); | |
| 186 makeOpaque(); | 202 makeOpaque(); |
| 187 } | 203 } |
| 188 | 204 |
| 189 void MediaControls::show() | 205 void MediaControls::show() |
| 190 { | 206 { |
| 191 makeOpaque(); | 207 makeOpaque(); |
| 192 m_panel->setIsDisplayed(true); | 208 m_panel->setIsDisplayed(true); |
| 193 m_panel->show(); | 209 m_panel->show(); |
| 194 if (m_overlayPlayButton) | 210 if (m_overlayPlayButton) |
| 195 m_overlayPlayButton->updateDisplayType(); | 211 m_overlayPlayButton->updateDisplayType(); |
| 196 } | 212 } |
| 197 | 213 |
| 198 void MediaControls::mediaElementFocused() | 214 void MediaControls::mediaElementFocused() |
| 199 { | 215 { |
| 200 show(); | 216 if (mediaElement().shouldShowControls()) { |
|
acolwell GONE FROM CHROMIUM
2014/08/05 19:36:34
This doesn't seem right. It feels like you are add
aberent
2014/08/22 14:08:34
Done.
| |
| 217 show(); | |
| 218 } else if (mediaElement().hasRemoteRoutes()) { | |
| 219 m_overlayCastButton->show(); | |
| 220 } | |
| 221 | |
| 201 stopHideMediaControlsTimer(); | 222 stopHideMediaControlsTimer(); |
| 223 if (!mediaElement().paused()) | |
| 224 startHideMediaControlsTimer(); | |
| 202 } | 225 } |
| 203 | 226 |
| 204 void MediaControls::hide() | 227 void MediaControls::hide() |
| 205 { | 228 { |
| 206 m_panel->setIsDisplayed(false); | 229 m_panel->setIsDisplayed(false); |
| 207 m_panel->hide(); | 230 m_panel->hide(); |
| 208 if (m_overlayPlayButton) | 231 if (m_overlayPlayButton) |
| 209 m_overlayPlayButton->hide(); | 232 m_overlayPlayButton->hide(); |
| 210 } | 233 } |
| 211 | 234 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 334 m_toggleClosedCaptionsButton->show(); | 357 m_toggleClosedCaptionsButton->show(); |
| 335 else | 358 else |
| 336 m_toggleClosedCaptionsButton->hide(); | 359 m_toggleClosedCaptionsButton->hide(); |
| 337 } | 360 } |
| 338 | 361 |
| 339 void MediaControls::closedCaptionTracksChanged() | 362 void MediaControls::closedCaptionTracksChanged() |
| 340 { | 363 { |
| 341 refreshClosedCaptionsButtonVisibility(); | 364 refreshClosedCaptionsButtonVisibility(); |
| 342 } | 365 } |
| 343 | 366 |
| 367 void MediaControls::refreshCastButtonVisibility() | |
| 368 { | |
| 369 if (mediaElement().hasRemoteRoutes()) { | |
| 370 if (!mediaElement().shouldShowControls() && !mediaElement().autoplay() & & mediaElement().paused()) { | |
|
acolwell GONE FROM CHROMIUM
2014/08/05 19:36:34
Why does autoplay() matter here?
aberent
2014/08/22 14:08:34
Some pages (e.g. vimeo.com) have an autoplay backg
| |
| 371 m_overlayCastButton->show(); | |
| 372 } else if (mediaElement().shouldShowControls()) { | |
| 373 m_overlayCastButton->hide(); | |
| 374 m_castButton->show(); | |
| 375 } | |
| 376 } else { | |
| 377 m_castButton->hide(); | |
| 378 m_overlayCastButton->hide(); | |
| 379 } | |
| 380 } | |
| 381 | |
| 344 void MediaControls::enteredFullscreen() | 382 void MediaControls::enteredFullscreen() |
| 345 { | 383 { |
| 346 m_fullScreenButton->setIsFullscreen(true); | 384 m_fullScreenButton->setIsFullscreen(true); |
| 347 stopHideMediaControlsTimer(); | 385 stopHideMediaControlsTimer(); |
| 348 startHideMediaControlsTimer(); | 386 startHideMediaControlsTimer(); |
| 349 } | 387 } |
| 350 | 388 |
| 351 void MediaControls::exitedFullscreen() | 389 void MediaControls::exitedFullscreen() |
| 352 { | 390 { |
| 353 m_fullScreenButton->setIsFullscreen(false); | 391 m_fullScreenButton->setIsFullscreen(false); |
| 354 stopHideMediaControlsTimer(); | 392 stopHideMediaControlsTimer(); |
| 355 startHideMediaControlsTimer(); | 393 startHideMediaControlsTimer(); |
| 356 } | 394 } |
| 357 | 395 |
| 396 void MediaControls::startedCasting() | |
| 397 { | |
| 398 m_castButton->setIsCasting(true); | |
| 399 m_overlayCastButton->setIsCasting(true); | |
| 400 } | |
| 401 | |
| 402 void MediaControls::stoppedCasting() | |
| 403 { | |
| 404 m_castButton->setIsCasting(false); | |
| 405 m_overlayCastButton->setIsCasting(false); | |
| 406 } | |
| 407 | |
| 358 void MediaControls::defaultEventHandler(Event* event) | 408 void MediaControls::defaultEventHandler(Event* event) |
| 359 { | 409 { |
| 360 HTMLDivElement::defaultEventHandler(event); | 410 HTMLDivElement::defaultEventHandler(event); |
| 361 | 411 |
| 362 if (event->type() == EventTypeNames::mouseover) { | 412 if (event->type() == EventTypeNames::mouseover) { |
| 363 if (!containsRelatedTarget(event)) { | 413 if (!containsRelatedTarget(event)) { |
| 364 m_isMouseOverControls = true; | 414 m_isMouseOverControls = true; |
| 365 if (!mediaElement().togglePlayStateWillPlay()) { | 415 if (!mediaElement().togglePlayStateWillPlay()) { |
| 366 makeOpaque(); | 416 makeOpaque(); |
| 367 if (shouldHideMediaControls()) | 417 if (shouldHideMediaControls()) |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 391 | 441 |
| 392 void MediaControls::hideMediaControlsTimerFired(Timer<MediaControls>*) | 442 void MediaControls::hideMediaControlsTimerFired(Timer<MediaControls>*) |
| 393 { | 443 { |
| 394 if (mediaElement().togglePlayStateWillPlay()) | 444 if (mediaElement().togglePlayStateWillPlay()) |
| 395 return; | 445 return; |
| 396 | 446 |
| 397 if (!shouldHideMediaControls(IgnoreFocus | IgnoreVideoHover)) | 447 if (!shouldHideMediaControls(IgnoreFocus | IgnoreVideoHover)) |
| 398 return; | 448 return; |
| 399 | 449 |
| 400 makeTransparent(); | 450 makeTransparent(); |
| 451 m_overlayCastButton->hide(); | |
| 401 } | 452 } |
| 402 | 453 |
| 403 void MediaControls::startHideMediaControlsTimer() | 454 void MediaControls::startHideMediaControlsTimer() |
| 404 { | 455 { |
| 405 m_hideMediaControlsTimer.startOneShot(timeWithoutMouseMovementBeforeHidingMe diaControls, FROM_HERE); | 456 m_hideMediaControlsTimer.startOneShot(timeWithoutMouseMovementBeforeHidingMe diaControls, FROM_HERE); |
| 406 } | 457 } |
| 407 | 458 |
| 408 void MediaControls::stopHideMediaControlsTimer() | 459 void MediaControls::stopHideMediaControlsTimer() |
| 409 { | 460 { |
| 410 m_hideMediaControlsTimer.stop(); | 461 m_hideMediaControlsTimer.stop(); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 476 visitor->trace(m_muteButton); | 527 visitor->trace(m_muteButton); |
| 477 visitor->trace(m_volumeSlider); | 528 visitor->trace(m_volumeSlider); |
| 478 visitor->trace(m_toggleClosedCaptionsButton); | 529 visitor->trace(m_toggleClosedCaptionsButton); |
| 479 visitor->trace(m_fullScreenButton); | 530 visitor->trace(m_fullScreenButton); |
| 480 visitor->trace(m_durationDisplay); | 531 visitor->trace(m_durationDisplay); |
| 481 visitor->trace(m_enclosure); | 532 visitor->trace(m_enclosure); |
| 482 HTMLDivElement::trace(visitor); | 533 HTMLDivElement::trace(visitor); |
| 483 } | 534 } |
| 484 | 535 |
| 485 } | 536 } |
| OLD | NEW |