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

Side by Side Diff: third_party/WebKit/Source/core/html/shadow/MediaControls.cpp

Issue 2539023002: Media Controls: Use events to update controls for closed captions. (Closed)
Patch Set: ready for review Created 4 years 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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 mediaElement().pause(); 332 mediaElement().pause();
333 333
334 updatePlayState(); 334 updatePlayState();
335 335
336 updateCurrentTimeDisplay(); 336 updateCurrentTimeDisplay();
337 337
338 m_timeline->setDuration(duration); 338 m_timeline->setDuration(duration);
339 m_timeline->setPosition(mediaElement().currentTime()); 339 m_timeline->setPosition(mediaElement().currentTime());
340 340
341 onVolumeChange(); 341 onVolumeChange();
342 342 onTextTracksAddedRemoved();
343 refreshClosedCaptionsButtonVisibility();
344 343
345 m_fullscreenButton->setIsWanted(shouldShowFullscreenButton(mediaElement())); 344 m_fullscreenButton->setIsWanted(shouldShowFullscreenButton(mediaElement()));
346 345
347 refreshCastButtonVisibilityWithoutUpdate(); 346 refreshCastButtonVisibilityWithoutUpdate();
348 347
349 m_downloadButton->setIsWanted( 348 m_downloadButton->setIsWanted(
350 m_downloadButton->shouldDisplayDownloadButton()); 349 m_downloadButton->shouldDisplayDownloadButton());
351 } 350 }
352 351
353 LayoutObject* MediaControls::layoutObjectForTextTrackLayout() { 352 LayoutObject* MediaControls::layoutObjectForTextTrackLayout() {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 double now = mediaElement().currentTime(); 446 double now = mediaElement().currentTime();
448 double duration = mediaElement().duration(); 447 double duration = mediaElement().duration();
449 448
450 // Allow the theme to format the time. 449 // Allow the theme to format the time.
451 m_currentTimeDisplay->setInnerText( 450 m_currentTimeDisplay->setInnerText(
452 LayoutTheme::theme().formatMediaControlsCurrentTime(now, duration), 451 LayoutTheme::theme().formatMediaControlsCurrentTime(now, duration),
453 IGNORE_EXCEPTION); 452 IGNORE_EXCEPTION);
454 m_currentTimeDisplay->setCurrentValue(now); 453 m_currentTimeDisplay->setCurrentValue(now);
455 } 454 }
456 455
457 void MediaControls::changedClosedCaptionsVisibility() {
458 m_toggleClosedCaptionsButton->updateDisplayType();
459 }
460
461 void MediaControls::refreshClosedCaptionsButtonVisibility() {
462 m_toggleClosedCaptionsButton->setIsWanted(mediaElement().hasClosedCaptions());
463 BatchedControlUpdate batch(this);
464 }
465
466 void MediaControls::toggleTextTrackList() { 456 void MediaControls::toggleTextTrackList() {
467 if (!mediaElement().hasClosedCaptions()) { 457 if (!mediaElement().hasClosedCaptions()) {
468 m_textTrackList->setVisible(false); 458 m_textTrackList->setVisible(false);
469 return; 459 return;
470 } 460 }
471 461
472 if (!m_textTrackList->isWanted()) 462 if (!m_textTrackList->isWanted())
473 m_windowEventListener->start(); 463 m_windowEventListener->start();
474 464
475 m_textTrackList->setVisible(!m_textTrackList->isWanted()); 465 m_textTrackList->setVisible(!m_textTrackList->isWanted());
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 707
718 void MediaControls::onPause() { 708 void MediaControls::onPause() {
719 updatePlayState(); 709 updatePlayState();
720 m_timeline->setPosition(mediaElement().currentTime()); 710 m_timeline->setPosition(mediaElement().currentTime());
721 updateCurrentTimeDisplay(); 711 updateCurrentTimeDisplay();
722 makeOpaque(); 712 makeOpaque();
723 713
724 stopHideMediaControlsTimer(); 714 stopHideMediaControlsTimer();
725 } 715 }
726 716
717 void MediaControls::onTextTracksAddedRemoved() {
718 m_toggleClosedCaptionsButton->setIsWanted(mediaElement().hasClosedCaptions());
719 BatchedControlUpdate batch(this);
720 }
721
722 void MediaControls::onTextTracksChanged() {
723 m_toggleClosedCaptionsButton->updateDisplayType();
724 }
725
727 void MediaControls::notifyPanelWidthChanged(const LayoutUnit& newWidth) { 726 void MediaControls::notifyPanelWidthChanged(const LayoutUnit& newWidth) {
728 // Don't bother to do any work if this matches the most recent panel 727 // Don't bother to do any work if this matches the most recent panel
729 // width, since we're called after layout. 728 // width, since we're called after layout.
730 // Note that this code permits a bad frame on resize, since it is 729 // Note that this code permits a bad frame on resize, since it is
731 // run after the relayout / paint happens. It would be great to improve 730 // run after the relayout / paint happens. It would be great to improve
732 // this, but it would be even greater to move this code entirely to 731 // this, but it would be even greater to move this code entirely to
733 // JS and fix it there. 732 // JS and fix it there.
734 m_panelWidth = newWidth.toInt(); 733 m_panelWidth = newWidth.toInt();
735 734
736 // Adjust for effective zoom. 735 // Adjust for effective zoom.
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 visitor->trace(m_overflowMenu); 913 visitor->trace(m_overflowMenu);
915 visitor->trace(m_overflowList); 914 visitor->trace(m_overflowList);
916 visitor->trace(m_castButton); 915 visitor->trace(m_castButton);
917 visitor->trace(m_overlayCastButton); 916 visitor->trace(m_overlayCastButton);
918 visitor->trace(m_mediaEventListener); 917 visitor->trace(m_mediaEventListener);
919 visitor->trace(m_windowEventListener); 918 visitor->trace(m_windowEventListener);
920 HTMLDivElement::trace(visitor); 919 HTMLDivElement::trace(visitor);
921 } 920 }
922 921
923 } // namespace blink 922 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698