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

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

Issue 1417683004: Media controls refer to less magic state. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased, fixed assert. Created 5 years, 1 month 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 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 407
408 // Allow the theme to format the time. 408 // Allow the theme to format the time.
409 m_currentTimeDisplay->setInnerText(LayoutTheme::theme().formatMediaControlsC urrentTime(now, duration), IGNORE_EXCEPTION); 409 m_currentTimeDisplay->setInnerText(LayoutTheme::theme().formatMediaControlsC urrentTime(now, duration), IGNORE_EXCEPTION);
410 m_currentTimeDisplay->setCurrentValue(now); 410 m_currentTimeDisplay->setCurrentValue(now);
411 } 411 }
412 412
413 void MediaControls::updateVolume() 413 void MediaControls::updateVolume()
414 { 414 {
415 m_muteButton->updateDisplayType(); 415 m_muteButton->updateDisplayType();
416 // Invalidate the mute button because it paints differently according to vol ume. 416 // Invalidate the mute button because it paints differently according to vol ume.
417 if (LayoutObject* layoutObject = m_muteButton->layoutObject()) 417 invalidate(m_muteButton);
418 layoutObject->setShouldDoFullPaintInvalidation();
419 418
420 if (mediaElement().muted()) 419 if (mediaElement().muted())
421 m_volumeSlider->setVolume(0); 420 m_volumeSlider->setVolume(0);
422 else 421 else
423 m_volumeSlider->setVolume(mediaElement().volume()); 422 m_volumeSlider->setVolume(mediaElement().volume());
424 423
425 // Update the visibility of our audio elements. 424 // Update the visibility of our audio elements.
426 // We never want the volume slider if there's no audio. 425 // We never want the volume slider if there's no audio.
427 // If there is audio, then we want it unless hiding audio is enabled and 426 // If there is audio, then we want it unless hiding audio is enabled and
428 // we prefer to hide it. 427 // we prefer to hide it.
429 BatchedControlUpdate batch(this); 428 BatchedControlUpdate batch(this);
430 m_volumeSlider->setIsWanted(mediaElement().hasAudio() 429 m_volumeSlider->setIsWanted(mediaElement().hasAudio()
431 && !(m_allowHiddenVolumeControls && preferHiddenVolumeControls(document( )))); 430 && !(m_allowHiddenVolumeControls && preferHiddenVolumeControls(document( ))));
432 431
433 // The mute button is a little more complicated. If enableNewMediaPlaybackU i 432 // The mute button is a little more complicated. If enableNewMediaPlaybackU i
434 // is true, then we choose to hide or show the mute button to save space. 433 // is true, then we choose to hide or show the mute button to save space.
435 // If enableNew* is not set, then we never touch the mute button, and 434 // If enableNew* is not set, then we never touch the mute button, and
436 // instead leave it to the CSS. 435 // instead leave it to the CSS.
437 // Note that this is why m_allowHiddenVolumeControls isn't rolled into prefe r...(). 436 // Note that this is why m_allowHiddenVolumeControls isn't rolled into prefe r...().
438 if (m_allowHiddenVolumeControls) { 437 if (m_allowHiddenVolumeControls) {
439 // If there is no audio track, then hide the mute button. 438 // If there is no audio track, then hide the mute button.
440 m_muteButton->setIsWanted(mediaElement().hasAudio()); 439 m_muteButton->setIsWanted(mediaElement().hasAudio());
441 } 440 }
442 441
443 // Invalidate the volume slider because it paints differently according to v olume. 442 // Invalidate the volume slider because it paints differently according to v olume.
444 if (LayoutObject* layoutObject = m_volumeSlider->layoutObject()) 443 invalidate(m_volumeSlider);
445 layoutObject->setShouldDoFullPaintInvalidation();
446 } 444 }
447 445
448 void MediaControls::changedClosedCaptionsVisibility() 446 void MediaControls::changedClosedCaptionsVisibility()
449 { 447 {
450 m_toggleClosedCaptionsButton->updateDisplayType(); 448 m_toggleClosedCaptionsButton->updateDisplayType();
451 } 449 }
452 450
453 void MediaControls::refreshClosedCaptionsButtonVisibility() 451 void MediaControls::refreshClosedCaptionsButtonVisibility()
454 { 452 {
455 m_toggleClosedCaptionsButton->setIsWanted(mediaElement().hasClosedCaptions() ); 453 m_toggleClosedCaptionsButton->setIsWanted(mediaElement().hasClosedCaptions() );
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 } 699 }
702 } 700 }
703 701
704 void MediaControls::setAllowHiddenVolumeControls(bool allow) 702 void MediaControls::setAllowHiddenVolumeControls(bool allow)
705 { 703 {
706 m_allowHiddenVolumeControls = allow; 704 m_allowHiddenVolumeControls = allow;
707 // Update the controls visibility. 705 // Update the controls visibility.
708 updateVolume(); 706 updateVolume();
709 } 707 }
710 708
709 void MediaControls::invalidate(Element* element)
710 {
711 if (!element)
712 return;
713
714 if (LayoutObject* layoutObject = element->layoutObject())
715 layoutObject->setShouldDoFullPaintInvalidation();
716 }
717
718 void MediaControls::networkStateChanged()
719 {
720 invalidate(m_playButton);
721 invalidate(m_overlayPlayButton);
722 invalidate(m_muteButton);
723 invalidate(m_fullScreenButton);
724 invalidate(m_timeline);
725 invalidate(m_volumeSlider);
726 }
727
711 DEFINE_TRACE(MediaControls) 728 DEFINE_TRACE(MediaControls)
712 { 729 {
713 visitor->trace(m_mediaElement); 730 visitor->trace(m_mediaElement);
714 visitor->trace(m_panel); 731 visitor->trace(m_panel);
715 visitor->trace(m_overlayPlayButton); 732 visitor->trace(m_overlayPlayButton);
716 visitor->trace(m_overlayEnclosure); 733 visitor->trace(m_overlayEnclosure);
717 visitor->trace(m_playButton); 734 visitor->trace(m_playButton);
718 visitor->trace(m_currentTimeDisplay); 735 visitor->trace(m_currentTimeDisplay);
719 visitor->trace(m_timeline); 736 visitor->trace(m_timeline);
720 visitor->trace(m_muteButton); 737 visitor->trace(m_muteButton);
721 visitor->trace(m_volumeSlider); 738 visitor->trace(m_volumeSlider);
722 visitor->trace(m_toggleClosedCaptionsButton); 739 visitor->trace(m_toggleClosedCaptionsButton);
723 visitor->trace(m_fullScreenButton); 740 visitor->trace(m_fullScreenButton);
724 visitor->trace(m_durationDisplay); 741 visitor->trace(m_durationDisplay);
725 visitor->trace(m_enclosure); 742 visitor->trace(m_enclosure);
726 visitor->trace(m_castButton); 743 visitor->trace(m_castButton);
727 visitor->trace(m_overlayCastButton); 744 visitor->trace(m_overlayCastButton);
728 HTMLDivElement::trace(visitor); 745 HTMLDivElement::trace(visitor);
729 } 746 }
730 747
731 } 748 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698