| 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 29 matching lines...) Expand all Loading... |
| 40 #include "core/html/HTMLVideoElement.h" | 40 #include "core/html/HTMLVideoElement.h" |
| 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/MediaControlFullscreenButtonElement.h" |
| 50 #include "modules/media_controls/elements/MediaControlMuteButtonElement.h" | 51 #include "modules/media_controls/elements/MediaControlMuteButtonElement.h" |
| 52 #include "modules/media_controls/elements/MediaControlOverflowMenuButtonElement.
h" |
| 51 #include "modules/media_controls/elements/MediaControlOverflowMenuListElement.h" | 53 #include "modules/media_controls/elements/MediaControlOverflowMenuListElement.h" |
| 52 #include "modules/media_controls/elements/MediaControlOverlayEnclosureElement.h" | 54 #include "modules/media_controls/elements/MediaControlOverlayEnclosureElement.h" |
| 55 #include "modules/media_controls/elements/MediaControlOverlayPlayButtonElement.h
" |
| 53 #include "modules/media_controls/elements/MediaControlPanelElement.h" | 56 #include "modules/media_controls/elements/MediaControlPanelElement.h" |
| 54 #include "modules/media_controls/elements/MediaControlPanelEnclosureElement.h" | 57 #include "modules/media_controls/elements/MediaControlPanelEnclosureElement.h" |
| 58 #include "modules/media_controls/elements/MediaControlPlayButtonElement.h" |
| 55 #include "modules/media_controls/elements/MediaControlRemainingTimeDisplayElemen
t.h" | 59 #include "modules/media_controls/elements/MediaControlRemainingTimeDisplayElemen
t.h" |
| 56 #include "modules/media_controls/elements/MediaControlTextTrackListElement.h" | 60 #include "modules/media_controls/elements/MediaControlTextTrackListElement.h" |
| 61 #include "modules/media_controls/elements/MediaControlToggleClosedCaptionsButton
Element.h" |
| 57 #include "platform/EventDispatchForbiddenScope.h" | 62 #include "platform/EventDispatchForbiddenScope.h" |
| 58 | 63 |
| 59 namespace blink { | 64 namespace blink { |
| 60 | 65 |
| 61 namespace { | 66 namespace { |
| 62 | 67 |
| 63 // TODO(steimel): should have better solution than hard-coding pixel values. | 68 // TODO(steimel): should have better solution than hard-coding pixel values. |
| 64 // Defined in core/css/mediaControls.css, core/css/mediaControlsAndroid.css, | 69 // Defined in core/css/mediaControls.css, core/css/mediaControlsAndroid.css, |
| 65 // and core/paint/MediaControlsPainter.cpp. | 70 // and core/paint/MediaControlsPainter.cpp. |
| 66 constexpr int kOverlayPlayButtonWidth = 48; | 71 constexpr int kOverlayPlayButtonWidth = 48; |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 // +-MediaControlTextTrackListItemInput | 303 // +-MediaControlTextTrackListItemInput |
| 299 // | (-internal-media-controls-text-track-list-item-input) | 304 // | (-internal-media-controls-text-track-list-item-input) |
| 300 // +-MediaControlTextTrackListItemCaptions | 305 // +-MediaControlTextTrackListItemCaptions |
| 301 // | (-internal-media-controls-text-track-list-kind-captions) | 306 // | (-internal-media-controls-text-track-list-kind-captions) |
| 302 // +-MediaControlTextTrackListItemSubtitles | 307 // +-MediaControlTextTrackListItemSubtitles |
| 303 // (-internal-media-controls-text-track-list-kind-subtitles) | 308 // (-internal-media-controls-text-track-list-kind-subtitles) |
| 304 void MediaControlsImpl::InitializeControls() { | 309 void MediaControlsImpl::InitializeControls() { |
| 305 overlay_enclosure_ = new MediaControlOverlayEnclosureElement(*this); | 310 overlay_enclosure_ = new MediaControlOverlayEnclosureElement(*this); |
| 306 | 311 |
| 307 if (RuntimeEnabledFeatures::mediaControlsOverlayPlayButtonEnabled()) { | 312 if (RuntimeEnabledFeatures::mediaControlsOverlayPlayButtonEnabled()) { |
| 308 MediaControlOverlayPlayButtonElement* overlay_play_button = | 313 overlay_play_button_ = new MediaControlOverlayPlayButtonElement(*this); |
| 309 MediaControlOverlayPlayButtonElement::Create(*this); | 314 overlay_enclosure_->AppendChild(overlay_play_button_); |
| 310 overlay_play_button_ = overlay_play_button; | |
| 311 overlay_enclosure_->AppendChild(overlay_play_button); | |
| 312 } | 315 } |
| 313 | 316 |
| 314 MediaControlCastButtonElement* overlay_cast_button = | 317 MediaControlCastButtonElement* overlay_cast_button = |
| 315 MediaControlCastButtonElement::Create(*this, true); | 318 MediaControlCastButtonElement::Create(*this, true); |
| 316 overlay_cast_button_ = overlay_cast_button; | 319 overlay_cast_button_ = overlay_cast_button; |
| 317 overlay_enclosure_->AppendChild(overlay_cast_button); | 320 overlay_enclosure_->AppendChild(overlay_cast_button); |
| 318 | 321 |
| 319 AppendChild(overlay_enclosure_); | 322 AppendChild(overlay_enclosure_); |
| 320 | 323 |
| 321 // Create an enclosing element for the panel so we can visually offset the | 324 // Create an enclosing element for the panel so we can visually offset the |
| 322 // controls correctly. | 325 // controls correctly. |
| 323 enclosure_ = new MediaControlPanelEnclosureElement(*this); | 326 enclosure_ = new MediaControlPanelEnclosureElement(*this); |
| 324 | 327 |
| 325 panel_ = new MediaControlPanelElement(*this); | 328 panel_ = new MediaControlPanelElement(*this); |
| 326 | 329 |
| 327 MediaControlPlayButtonElement* play_button = | 330 play_button_ = new MediaControlPlayButtonElement(*this); |
| 328 MediaControlPlayButtonElement::Create(*this); | 331 panel_->AppendChild(play_button_); |
| 329 play_button_ = play_button; | |
| 330 panel_->AppendChild(play_button); | |
| 331 | 332 |
| 332 current_time_display_ = new MediaControlCurrentTimeDisplayElement(*this); | 333 current_time_display_ = new MediaControlCurrentTimeDisplayElement(*this); |
| 333 current_time_display_->SetIsWanted(true); | 334 current_time_display_->SetIsWanted(true); |
| 334 panel_->AppendChild(current_time_display_); | 335 panel_->AppendChild(current_time_display_); |
| 335 | 336 |
| 336 duration_display_ = new MediaControlRemainingTimeDisplayElement(*this); | 337 duration_display_ = new MediaControlRemainingTimeDisplayElement(*this); |
| 337 panel_->AppendChild(duration_display_); | 338 panel_->AppendChild(duration_display_); |
| 338 | 339 |
| 339 MediaControlTimelineElement* timeline = | 340 MediaControlTimelineElement* timeline = |
| 340 MediaControlTimelineElement::Create(*this); | 341 MediaControlTimelineElement::Create(*this); |
| 341 timeline_ = timeline; | 342 timeline_ = timeline; |
| 342 panel_->AppendChild(timeline); | 343 panel_->AppendChild(timeline); |
| 343 | 344 |
| 344 mute_button_ = new MediaControlMuteButtonElement(*this); | 345 mute_button_ = new MediaControlMuteButtonElement(*this); |
| 345 panel_->AppendChild(mute_button_); | 346 panel_->AppendChild(mute_button_); |
| 346 | 347 |
| 347 MediaControlVolumeSliderElement* slider = | 348 MediaControlVolumeSliderElement* slider = |
| 348 MediaControlVolumeSliderElement::Create(*this); | 349 MediaControlVolumeSliderElement::Create(*this); |
| 349 volume_slider_ = slider; | 350 volume_slider_ = slider; |
| 350 panel_->AppendChild(slider); | 351 panel_->AppendChild(slider); |
| 351 if (PreferHiddenVolumeControls(GetDocument())) | 352 if (PreferHiddenVolumeControls(GetDocument())) |
| 352 volume_slider_->SetIsWanted(false); | 353 volume_slider_->SetIsWanted(false); |
| 353 | 354 |
| 354 MediaControlFullscreenButtonElement* fullscreen_button = | 355 fullscreen_button_ = new MediaControlFullscreenButtonElement(*this); |
| 355 MediaControlFullscreenButtonElement::Create(*this); | 356 panel_->AppendChild(fullscreen_button_); |
| 356 fullscreen_button_ = fullscreen_button; | |
| 357 panel_->AppendChild(fullscreen_button); | |
| 358 | 357 |
| 359 MediaControlDownloadButtonElement* download_button = | 358 MediaControlDownloadButtonElement* download_button = |
| 360 MediaControlDownloadButtonElement::Create(*this); | 359 MediaControlDownloadButtonElement::Create(*this); |
| 361 download_button_ = download_button; | 360 download_button_ = download_button; |
| 362 panel_->AppendChild(download_button); | 361 panel_->AppendChild(download_button); |
| 363 | 362 |
| 364 MediaControlCastButtonElement* cast_button = | 363 MediaControlCastButtonElement* cast_button = |
| 365 MediaControlCastButtonElement::Create(*this, false); | 364 MediaControlCastButtonElement::Create(*this, false); |
| 366 cast_button_ = cast_button; | 365 cast_button_ = cast_button; |
| 367 panel_->AppendChild(cast_button); | 366 panel_->AppendChild(cast_button); |
| 368 | 367 |
| 369 MediaControlToggleClosedCaptionsButtonElement* toggle_closed_captions_button = | 368 toggle_closed_captions_button_ = |
| 370 MediaControlToggleClosedCaptionsButtonElement::Create(*this); | 369 new MediaControlToggleClosedCaptionsButtonElement(*this); |
| 371 toggle_closed_captions_button_ = toggle_closed_captions_button; | 370 panel_->AppendChild(toggle_closed_captions_button_); |
| 372 panel_->AppendChild(toggle_closed_captions_button); | |
| 373 | 371 |
| 374 enclosure_->AppendChild(panel_); | 372 enclosure_->AppendChild(panel_); |
| 375 | 373 |
| 376 AppendChild(enclosure_); | 374 AppendChild(enclosure_); |
| 377 | 375 |
| 378 text_track_list_ = new MediaControlTextTrackListElement(*this); | 376 text_track_list_ = new MediaControlTextTrackListElement(*this); |
| 379 AppendChild(text_track_list_); | 377 AppendChild(text_track_list_); |
| 380 | 378 |
| 381 MediaControlOverflowMenuButtonElement* overflow_menu = | 379 overflow_menu_ = new MediaControlOverflowMenuButtonElement(*this); |
| 382 MediaControlOverflowMenuButtonElement::Create(*this); | 380 panel_->AppendChild(overflow_menu_); |
| 383 overflow_menu_ = overflow_menu; | |
| 384 panel_->AppendChild(overflow_menu); | |
| 385 | 381 |
| 386 overflow_list_ = new MediaControlOverflowMenuListElement(*this); | 382 overflow_list_ = new MediaControlOverflowMenuListElement(*this); |
| 387 AppendChild(overflow_list_); | 383 AppendChild(overflow_list_); |
| 388 | 384 |
| 389 // The order in which we append elements to the overflow list is significant | 385 // The order in which we append elements to the overflow list is significant |
| 390 // because it determines how the elements show up in the overflow menu | 386 // because it determines how the elements show up in the overflow menu |
| 391 // relative to each other. The first item appended appears at the top of the | 387 // relative to each other. The first item appended appears at the top of the |
| 392 // overflow menu. | 388 // overflow menu. |
| 393 overflow_list_->AppendChild(play_button_->CreateOverflowElement( | 389 overflow_list_->AppendChild(play_button_->CreateOverflowElement( |
| 394 *this, MediaControlPlayButtonElement::Create(*this))); | 390 *this, new MediaControlPlayButtonElement(*this))); |
| 395 overflow_list_->AppendChild(fullscreen_button_->CreateOverflowElement( | 391 overflow_list_->AppendChild(fullscreen_button_->CreateOverflowElement( |
| 396 *this, MediaControlFullscreenButtonElement::Create(*this))); | 392 *this, new MediaControlFullscreenButtonElement(*this))); |
| 397 overflow_list_->AppendChild(download_button_->CreateOverflowElement( | 393 overflow_list_->AppendChild(download_button_->CreateOverflowElement( |
| 398 *this, MediaControlDownloadButtonElement::Create(*this))); | 394 *this, MediaControlDownloadButtonElement::Create(*this))); |
| 399 overflow_list_->AppendChild(mute_button_->CreateOverflowElement( | 395 overflow_list_->AppendChild(mute_button_->CreateOverflowElement( |
| 400 *this, new MediaControlMuteButtonElement(*this))); | 396 *this, new MediaControlMuteButtonElement(*this))); |
| 401 overflow_list_->AppendChild(cast_button_->CreateOverflowElement( | 397 overflow_list_->AppendChild(cast_button_->CreateOverflowElement( |
| 402 *this, MediaControlCastButtonElement::Create(*this, false))); | 398 *this, MediaControlCastButtonElement::Create(*this, false))); |
| 403 overflow_list_->AppendChild( | 399 overflow_list_->AppendChild( |
| 404 toggle_closed_captions_button_->CreateOverflowElement( | 400 toggle_closed_captions_button_->CreateOverflowElement( |
| 405 *this, MediaControlToggleClosedCaptionsButtonElement::Create(*this))); | 401 *this, new MediaControlToggleClosedCaptionsButtonElement(*this))); |
| 406 } | 402 } |
| 407 | 403 |
| 408 Node::InsertionNotificationRequest MediaControlsImpl::InsertedInto( | 404 Node::InsertionNotificationRequest MediaControlsImpl::InsertedInto( |
| 409 ContainerNode* root) { | 405 ContainerNode* root) { |
| 410 if (!MediaElement().isConnected()) | 406 if (!MediaElement().isConnected()) |
| 411 return HTMLDivElement::InsertedInto(root); | 407 return HTMLDivElement::InsertedInto(root); |
| 412 | 408 |
| 413 // TODO(mlamouri): we should show the controls instead of having | 409 // TODO(mlamouri): we should show the controls instead of having |
| 414 // HTMLMediaElement do it. | 410 // HTMLMediaElement do it. |
| 415 | 411 |
| (...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1138 visitor->Trace(cast_button_); | 1134 visitor->Trace(cast_button_); |
| 1139 visitor->Trace(overlay_cast_button_); | 1135 visitor->Trace(overlay_cast_button_); |
| 1140 visitor->Trace(media_event_listener_); | 1136 visitor->Trace(media_event_listener_); |
| 1141 visitor->Trace(window_event_listener_); | 1137 visitor->Trace(window_event_listener_); |
| 1142 visitor->Trace(orientation_lock_delegate_); | 1138 visitor->Trace(orientation_lock_delegate_); |
| 1143 MediaControls::Trace(visitor); | 1139 MediaControls::Trace(visitor); |
| 1144 HTMLDivElement::Trace(visitor); | 1140 HTMLDivElement::Trace(visitor); |
| 1145 } | 1141 } |
| 1146 | 1142 |
| 1147 } // namespace blink | 1143 } // namespace blink |
| OLD | NEW |