RenderTheme does not need to be per-page
[WebKit-https.git] / Source / WebCore / html / shadow / MediaControls.cpp
index 2228f49..3e18a10 100644 (file)
@@ -87,21 +87,17 @@ void MediaControls::setMediaController(MediaControllerInterface* controller)
 
 void MediaControls::reset()
 {
-    Page* page = document().page();
-    if (!page)
-        return;
-
     m_playButton->updateDisplayType();
 
     updateCurrentTimeDisplay();
 
     double duration = m_mediaController->duration();
-    if (std::isfinite(duration) || page->theme().hasOwnDisabledStateHandlingFor(MediaSliderPart)) {
+    if (std::isfinite(duration) || RenderTheme::singleton().hasOwnDisabledStateHandlingFor(MediaSliderPart)) {
         m_timeline->setDuration(duration);
         m_timeline->setPosition(m_mediaController->currentTime());
     }
 
-    if (m_mediaController->hasAudio() || page->theme().hasOwnDisabledStateHandlingFor(MediaMuteButtonPart))
+    if (m_mediaController->hasAudio() || RenderTheme::singleton().hasOwnDisabledStateHandlingFor(MediaMuteButtonPart))
         m_panelMuteButton->show();
     else
         m_panelMuteButton->hide();
@@ -129,19 +125,16 @@ void MediaControls::reset()
 
 void MediaControls::reportedError()
 {
-    Page* page = document().page();
-    if (!page)
-        return;
-
-    if (!page->theme().hasOwnDisabledStateHandlingFor(MediaMuteButtonPart)) {
+    auto& theme = RenderTheme::singleton();
+    if (!theme.hasOwnDisabledStateHandlingFor(MediaMuteButtonPart)) {
         m_panelMuteButton->hide();
         m_volumeSlider->hide();
     }
 
-    if (m_toggleClosedCaptionsButton && !page->theme().hasOwnDisabledStateHandlingFor(MediaToggleClosedCaptionsButtonPart))
+    if (m_toggleClosedCaptionsButton && !theme.hasOwnDisabledStateHandlingFor(MediaToggleClosedCaptionsButtonPart))
         m_toggleClosedCaptionsButton->hide();
 
-    if (m_fullScreenButton && !page->theme().hasOwnDisabledStateHandlingFor(MediaEnterFullscreenButtonPart))
+    if (m_fullScreenButton && !theme.hasOwnDisabledStateHandlingFor(MediaEnterFullscreenButtonPart))
         m_fullScreenButton->hide();
 }
 
@@ -218,12 +211,7 @@ void MediaControls::playbackStopped()
 void MediaControls::updateCurrentTimeDisplay()
 {
     double now = m_mediaController->currentTime();
-
-    Page* page = document().page();
-    if (!page)
-        return;
-
-    m_currentTimeDisplay->setInnerText(page->theme().formatMediaControlsTime(now));
+    m_currentTimeDisplay->setInnerText(RenderTheme::singleton().formatMediaControlsTime(now));
     m_currentTimeDisplay->setCurrentValue(now);
 }