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

Side by Side Diff: third_party/WebKit/Source/modules/media_controls/MediaControlsImpl.cpp

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

Powered by Google App Engine
This is Rietveld 408576698