| 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 30 matching lines...) Expand all Loading... |
| 41 #include "core/html/media/HTMLMediaElementControlsList.h" | 41 #include "core/html/media/HTMLMediaElementControlsList.h" |
| 42 #include "core/html/track/TextTrackContainer.h" | 42 #include "core/html/track/TextTrackContainer.h" |
| 43 #include "core/html/track/TextTrackList.h" | 43 #include "core/html/track/TextTrackList.h" |
| 44 #include "core/layout/LayoutObject.h" | 44 #include "core/layout/LayoutObject.h" |
| 45 #include "core/layout/LayoutTheme.h" | 45 #include "core/layout/LayoutTheme.h" |
| 46 #include "modules/media_controls/MediaControlsMediaEventListener.h" | 46 #include "modules/media_controls/MediaControlsMediaEventListener.h" |
| 47 #include "modules/media_controls/MediaControlsOrientationLockDelegate.h" | 47 #include "modules/media_controls/MediaControlsOrientationLockDelegate.h" |
| 48 #include "modules/media_controls/MediaControlsWindowEventListener.h" | 48 #include "modules/media_controls/MediaControlsWindowEventListener.h" |
| 49 #include "modules/media_controls/elements/MediaControlCurrentTimeDisplayElement.
h" | 49 #include "modules/media_controls/elements/MediaControlCurrentTimeDisplayElement.
h" |
| 50 #include "modules/media_controls/elements/MediaControlMuteButtonElement.h" | 50 #include "modules/media_controls/elements/MediaControlMuteButtonElement.h" |
| 51 #include "modules/media_controls/elements/MediaControlOverflowMenuListElement.h" |
| 51 #include "modules/media_controls/elements/MediaControlOverlayEnclosureElement.h" | 52 #include "modules/media_controls/elements/MediaControlOverlayEnclosureElement.h" |
| 53 #include "modules/media_controls/elements/MediaControlPanelElement.h" |
| 52 #include "modules/media_controls/elements/MediaControlPanelEnclosureElement.h" | 54 #include "modules/media_controls/elements/MediaControlPanelEnclosureElement.h" |
| 53 #include "modules/media_controls/elements/MediaControlRemainingTimeDisplayElemen
t.h" | 55 #include "modules/media_controls/elements/MediaControlRemainingTimeDisplayElemen
t.h" |
| 56 #include "modules/media_controls/elements/MediaControlTextTrackListElement.h" |
| 54 #include "platform/EventDispatchForbiddenScope.h" | 57 #include "platform/EventDispatchForbiddenScope.h" |
| 55 | 58 |
| 56 namespace blink { | 59 namespace blink { |
| 57 | 60 |
| 58 namespace { | 61 namespace { |
| 59 | 62 |
| 60 // TODO(steimel): should have better solution than hard-coding pixel values. | 63 // TODO(steimel): should have better solution than hard-coding pixel values. |
| 61 // Defined in core/css/mediaControls.css, core/css/mediaControlsAndroid.css, | 64 // Defined in core/css/mediaControls.css, core/css/mediaControlsAndroid.css, |
| 62 // and core/paint/MediaControlsPainter.cpp. | 65 // and core/paint/MediaControlsPainter.cpp. |
| 63 constexpr int kOverlayPlayButtonWidth = 48; | 66 constexpr int kOverlayPlayButtonWidth = 48; |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 MediaControlCastButtonElement::Create(*this, true); | 315 MediaControlCastButtonElement::Create(*this, true); |
| 313 overlay_cast_button_ = overlay_cast_button; | 316 overlay_cast_button_ = overlay_cast_button; |
| 314 overlay_enclosure_->AppendChild(overlay_cast_button); | 317 overlay_enclosure_->AppendChild(overlay_cast_button); |
| 315 | 318 |
| 316 AppendChild(overlay_enclosure_); | 319 AppendChild(overlay_enclosure_); |
| 317 | 320 |
| 318 // Create an enclosing element for the panel so we can visually offset the | 321 // Create an enclosing element for the panel so we can visually offset the |
| 319 // controls correctly. | 322 // controls correctly. |
| 320 enclosure_ = new MediaControlPanelEnclosureElement(*this); | 323 enclosure_ = new MediaControlPanelEnclosureElement(*this); |
| 321 | 324 |
| 322 MediaControlPanelElement* panel = MediaControlPanelElement::Create(*this); | 325 panel_ = new MediaControlPanelElement(*this); |
| 323 | 326 |
| 324 MediaControlPlayButtonElement* play_button = | 327 MediaControlPlayButtonElement* play_button = |
| 325 MediaControlPlayButtonElement::Create(*this); | 328 MediaControlPlayButtonElement::Create(*this); |
| 326 play_button_ = play_button; | 329 play_button_ = play_button; |
| 327 panel->AppendChild(play_button); | 330 panel_->AppendChild(play_button); |
| 328 | 331 |
| 329 current_time_display_ = new MediaControlCurrentTimeDisplayElement(*this); | 332 current_time_display_ = new MediaControlCurrentTimeDisplayElement(*this); |
| 330 current_time_display_->SetIsWanted(true); | 333 current_time_display_->SetIsWanted(true); |
| 331 panel->AppendChild(current_time_display_); | 334 panel_->AppendChild(current_time_display_); |
| 332 | 335 |
| 333 duration_display_ = new MediaControlRemainingTimeDisplayElement(*this); | 336 duration_display_ = new MediaControlRemainingTimeDisplayElement(*this); |
| 334 panel->AppendChild(duration_display_); | 337 panel_->AppendChild(duration_display_); |
| 335 | 338 |
| 336 MediaControlTimelineElement* timeline = | 339 MediaControlTimelineElement* timeline = |
| 337 MediaControlTimelineElement::Create(*this); | 340 MediaControlTimelineElement::Create(*this); |
| 338 timeline_ = timeline; | 341 timeline_ = timeline; |
| 339 panel->AppendChild(timeline); | 342 panel_->AppendChild(timeline); |
| 340 | 343 |
| 341 mute_button_ = new MediaControlMuteButtonElement(*this); | 344 mute_button_ = new MediaControlMuteButtonElement(*this); |
| 342 panel->AppendChild(mute_button_); | 345 panel_->AppendChild(mute_button_); |
| 343 | 346 |
| 344 MediaControlVolumeSliderElement* slider = | 347 MediaControlVolumeSliderElement* slider = |
| 345 MediaControlVolumeSliderElement::Create(*this); | 348 MediaControlVolumeSliderElement::Create(*this); |
| 346 volume_slider_ = slider; | 349 volume_slider_ = slider; |
| 347 panel->AppendChild(slider); | 350 panel_->AppendChild(slider); |
| 348 if (PreferHiddenVolumeControls(GetDocument())) | 351 if (PreferHiddenVolumeControls(GetDocument())) |
| 349 volume_slider_->SetIsWanted(false); | 352 volume_slider_->SetIsWanted(false); |
| 350 | 353 |
| 351 MediaControlFullscreenButtonElement* fullscreen_button = | 354 MediaControlFullscreenButtonElement* fullscreen_button = |
| 352 MediaControlFullscreenButtonElement::Create(*this); | 355 MediaControlFullscreenButtonElement::Create(*this); |
| 353 fullscreen_button_ = fullscreen_button; | 356 fullscreen_button_ = fullscreen_button; |
| 354 panel->AppendChild(fullscreen_button); | 357 panel_->AppendChild(fullscreen_button); |
| 355 | 358 |
| 356 MediaControlDownloadButtonElement* download_button = | 359 MediaControlDownloadButtonElement* download_button = |
| 357 MediaControlDownloadButtonElement::Create(*this); | 360 MediaControlDownloadButtonElement::Create(*this); |
| 358 download_button_ = download_button; | 361 download_button_ = download_button; |
| 359 panel->AppendChild(download_button); | 362 panel_->AppendChild(download_button); |
| 360 | 363 |
| 361 MediaControlCastButtonElement* cast_button = | 364 MediaControlCastButtonElement* cast_button = |
| 362 MediaControlCastButtonElement::Create(*this, false); | 365 MediaControlCastButtonElement::Create(*this, false); |
| 363 cast_button_ = cast_button; | 366 cast_button_ = cast_button; |
| 364 panel->AppendChild(cast_button); | 367 panel_->AppendChild(cast_button); |
| 365 | 368 |
| 366 MediaControlToggleClosedCaptionsButtonElement* toggle_closed_captions_button = | 369 MediaControlToggleClosedCaptionsButtonElement* toggle_closed_captions_button = |
| 367 MediaControlToggleClosedCaptionsButtonElement::Create(*this); | 370 MediaControlToggleClosedCaptionsButtonElement::Create(*this); |
| 368 toggle_closed_captions_button_ = toggle_closed_captions_button; | 371 toggle_closed_captions_button_ = toggle_closed_captions_button; |
| 369 panel->AppendChild(toggle_closed_captions_button); | 372 panel_->AppendChild(toggle_closed_captions_button); |
| 370 | 373 |
| 371 panel_ = panel; | 374 enclosure_->AppendChild(panel_); |
| 372 enclosure_->AppendChild(panel); | |
| 373 | 375 |
| 374 AppendChild(enclosure_); | 376 AppendChild(enclosure_); |
| 375 | 377 |
| 376 MediaControlTextTrackListElement* text_track_list = | 378 text_track_list_ = new MediaControlTextTrackListElement(*this); |
| 377 MediaControlTextTrackListElement::Create(*this); | 379 AppendChild(text_track_list_); |
| 378 text_track_list_ = text_track_list; | |
| 379 AppendChild(text_track_list); | |
| 380 | 380 |
| 381 MediaControlOverflowMenuButtonElement* overflow_menu = | 381 MediaControlOverflowMenuButtonElement* overflow_menu = |
| 382 MediaControlOverflowMenuButtonElement::Create(*this); | 382 MediaControlOverflowMenuButtonElement::Create(*this); |
| 383 overflow_menu_ = overflow_menu; | 383 overflow_menu_ = overflow_menu; |
| 384 panel->AppendChild(overflow_menu); | 384 panel_->AppendChild(overflow_menu); |
| 385 | 385 |
| 386 MediaControlOverflowMenuListElement* overflow_list = | 386 overflow_list_ = new MediaControlOverflowMenuListElement(*this); |
| 387 MediaControlOverflowMenuListElement::Create(*this); | 387 AppendChild(overflow_list_); |
| 388 overflow_list_ = overflow_list; | |
| 389 AppendChild(overflow_list); | |
| 390 | 388 |
| 391 // The order in which we append elements to the overflow list is significant | 389 // The order in which we append elements to the overflow list is significant |
| 392 // because it determines how the elements show up in the overflow menu | 390 // because it determines how the elements show up in the overflow menu |
| 393 // relative to each other. The first item appended appears at the top of the | 391 // relative to each other. The first item appended appears at the top of the |
| 394 // overflow menu. | 392 // overflow menu. |
| 395 overflow_list_->AppendChild(play_button_->CreateOverflowElement( | 393 overflow_list_->AppendChild(play_button_->CreateOverflowElement( |
| 396 *this, MediaControlPlayButtonElement::Create(*this))); | 394 *this, MediaControlPlayButtonElement::Create(*this))); |
| 397 overflow_list_->AppendChild(fullscreen_button_->CreateOverflowElement( | 395 overflow_list_->AppendChild(fullscreen_button_->CreateOverflowElement( |
| 398 *this, MediaControlFullscreenButtonElement::Create(*this))); | 396 *this, MediaControlFullscreenButtonElement::Create(*this))); |
| 399 overflow_list_->AppendChild(download_button_->CreateOverflowElement( | 397 overflow_list_->AppendChild(download_button_->CreateOverflowElement( |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 | 564 |
| 567 void MediaControlsImpl::UpdatePlayState() { | 565 void MediaControlsImpl::UpdatePlayState() { |
| 568 if (is_paused_for_scrubbing_) | 566 if (is_paused_for_scrubbing_) |
| 569 return; | 567 return; |
| 570 | 568 |
| 571 if (overlay_play_button_) | 569 if (overlay_play_button_) |
| 572 overlay_play_button_->UpdateDisplayType(); | 570 overlay_play_button_->UpdateDisplayType(); |
| 573 play_button_->UpdateDisplayType(); | 571 play_button_->UpdateDisplayType(); |
| 574 } | 572 } |
| 575 | 573 |
| 574 HTMLDivElement* MediaControlsImpl::PanelElement() { |
| 575 return panel_; |
| 576 } |
| 577 |
| 576 void MediaControlsImpl::BeginScrubbing() { | 578 void MediaControlsImpl::BeginScrubbing() { |
| 577 if (!MediaElement().paused()) { | 579 if (!MediaElement().paused()) { |
| 578 is_paused_for_scrubbing_ = true; | 580 is_paused_for_scrubbing_ = true; |
| 579 MediaElement().pause(); | 581 MediaElement().pause(); |
| 580 } | 582 } |
| 581 } | 583 } |
| 582 | 584 |
| 583 void MediaControlsImpl::EndScrubbing() { | 585 void MediaControlsImpl::EndScrubbing() { |
| 584 if (is_paused_for_scrubbing_) { | 586 if (is_paused_for_scrubbing_) { |
| 585 is_paused_for_scrubbing_ = false; | 587 is_paused_for_scrubbing_ = false; |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1134 visitor->Trace(cast_button_); | 1136 visitor->Trace(cast_button_); |
| 1135 visitor->Trace(overlay_cast_button_); | 1137 visitor->Trace(overlay_cast_button_); |
| 1136 visitor->Trace(media_event_listener_); | 1138 visitor->Trace(media_event_listener_); |
| 1137 visitor->Trace(window_event_listener_); | 1139 visitor->Trace(window_event_listener_); |
| 1138 visitor->Trace(orientation_lock_delegate_); | 1140 visitor->Trace(orientation_lock_delegate_); |
| 1139 MediaControls::Trace(visitor); | 1141 MediaControls::Trace(visitor); |
| 1140 HTMLDivElement::Trace(visitor); | 1142 HTMLDivElement::Trace(visitor); |
| 1141 } | 1143 } |
| 1142 | 1144 |
| 1143 } // namespace blink | 1145 } // namespace blink |
| OLD | NEW |