2011-01-28 Dimitri Glazkov <dglazkov@chromium.org>
authordglazkov@chromium.org <dglazkov@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Feb 2011 18:35:22 +0000 (18:35 +0000)
committerdglazkov@chromium.org <dglazkov@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Feb 2011 18:35:22 +0000 (18:35 +0000)
        Reviewed by Darin Adler.

        Change the rest of HTMLMediaElement shadow DOM parts to use shadowPseudoId.
        https://bugs.webkit.org/show_bug.cgi?id=53190

        This is the second part of refactoring the HTMLMediaElement to use new
        shadow DOM. The changes are mainly mechanical, except for needing to
        add a new method to RenderTheme, which indicates whether or not status
        display is being used by it. Previously, we relied on existence of a cached
        pseudo style.

        Refactoring, covered by existing tests.

        * css/CSSSelector.cpp:
        (WebCore::CSSSelector::pseudoId): Removed now-unused enum values.
        (WebCore::nameToPseudoTypeMap): Ditto.
        (WebCore::CSSSelector::extractPseudoType): Ditto.
        * css/CSSSelector.h: Ditto.
        * html/shadow/MediaControls.cpp:
        (WebCore::MediaControls::createPanel): Changed to use the newly-added MediaControlPanelElement.
        (WebCore::MediaControls::createCurrentTimeDisplay): Changed to use the newly-added
            MediaControlCurrentTimeDisplayElement.
        (WebCore::MediaControls::createTimeRemainingDisplay): Changed to use the newly-added
                MediaControlTimeRemainingDisplayElement.
        * rendering/MediaControlElements.cpp:
        (WebCore::MediaControlShadowRootElement::updateStyle): Changed to use the
            standard style resolution.
        (WebCore::MediaControlShadowRootElement::shadowPseudoId): Added.
        (WebCore::MediaControlElement::MediaControlElement): Removed the switch statement
            that is no longer necessary.
        (WebCore::MediaControlElement::styleForElement): Changed to use the standard
            style resolution.
        (WebCore::MediaControlPanelElement::MediaControlPanelElement): Added.
        (WebCore::MediaControlPanelElement::create): Added.
        (WebCore::MediaControlPanelElement::displayType): Added.
        (WebCore::MediaControlPanelElement::shadowPseudoId): Added.
        (WebCore::MediaControlTimelineContainerElement::MediaControlTimelineContainerElement):
            Removed PseudoId constructor arg.
        (WebCore::MediaControlTimelineContainerElement::rendererIsNeeded):
            Changed to use the newly-plumbed usesMediaControlStatusDisplay helper.
        (WebCore::MediaControlTimelineContainerElement::displayType): Added.
        (WebCore::MediaControlTimelineContainerElement::shadowPseudoId): Added.
        (WebCore::MediaControlVolumeSliderContainerElement::MediaControlVolumeSliderContainerElement):
            Removed PseudoId constructor arg.
        (WebCore::MediaControlVolumeSliderContainerElement::displayType): Added.
        (WebCore::MediaControlVolumeSliderContainerElement::shadowPseudoId): Added.
        (WebCore::MediaControlStatusDisplayElement::MediaControlStatusDisplayElement):
            Removed PseudoId constructor arg.
        (WebCore::MediaControlStatusDisplayElement::rendererIsNeeded): Changed to
            use the newly-plumbed usesMediaControlStatusDisplay helper.
        (WebCore::MediaControlStatusDisplayElement::displayType): Added.
        (WebCore::MediaControlStatusDisplayElement::shadowPseudoId): Added.
        (WebCore::MediaControlTimeDisplayElement::MediaControlTimeDisplayElement):
            Removed PseudoId constructor arg.
        (WebCore::MediaControlTimeRemainingDisplayElement::create): Added.
        (WebCore::MediaControlTimeRemainingDisplayElement::MediaControlTimeRemainingDisplayElement): Added.
        (WebCore::MediaControlTimeRemainingDisplayElement::displayType): Added.
        (WebCore::MediaControlTimeRemainingDisplayElement::shadowPseudoId): Added.
        (WebCore::MediaControlCurrentTimeDisplayElement::create): Added.
        (WebCore::MediaControlCurrentTimeDisplayElement::MediaControlCurrentTimeDisplayElement): Added.
        (WebCore::MediaControlCurrentTimeDisplayElement::displayType): Added.
        (WebCore::MediaControlCurrentTimeDisplayElement::shadowPseudoId): Added.
        * rendering/MediaControlElements.h: Added/changed defs accordingly.
        * rendering/RenderTheme.h:
        (WebCore::RenderTheme::usesMediaControlStatusDisplay): Added.
        * rendering/RenderThemeMac.h: Added def.
        * rendering/RenderThemeMac.mm:
        (WebCore::RenderThemeMac::usesMediaControlStatusDisplay): Added.
        * rendering/style/RenderStyleConstants.h: Removed now-unused enum values.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@77954 268f45cc-cd09-0410-ab3c-d52691b4dbfc

12 files changed:
Source/WebCore/ChangeLog
Source/WebCore/css/CSSSelector.cpp
Source/WebCore/css/CSSSelector.h
Source/WebCore/html/shadow/MediaControls.cpp
Source/WebCore/html/shadow/MediaControls.h
Source/WebCore/rendering/MediaControlElements.cpp
Source/WebCore/rendering/MediaControlElements.h
Source/WebCore/rendering/RenderTheme.h
Source/WebCore/rendering/RenderThemeChromiumMac.h
Source/WebCore/rendering/RenderThemeMac.h
Source/WebCore/rendering/RenderThemeMac.mm
Source/WebCore/rendering/style/RenderStyleConstants.h

index e67a32d..a0df8f3 100644 (file)
@@ -1,3 +1,75 @@
+2011-01-28  Dimitri Glazkov  <dglazkov@chromium.org>
+
+        Reviewed by Darin Adler.
+
+        Change the rest of HTMLMediaElement shadow DOM parts to use shadowPseudoId.
+        https://bugs.webkit.org/show_bug.cgi?id=53190
+
+        This is the second part of refactoring the HTMLMediaElement to use new
+        shadow DOM. The changes are mainly mechanical, except for needing to
+        add a new method to RenderTheme, which indicates whether or not status
+        display is being used by it. Previously, we relied on existence of a cached
+        pseudo style.
+
+        Refactoring, covered by existing tests.
+
+        * css/CSSSelector.cpp:
+        (WebCore::CSSSelector::pseudoId): Removed now-unused enum values.
+        (WebCore::nameToPseudoTypeMap): Ditto.
+        (WebCore::CSSSelector::extractPseudoType): Ditto.
+        * css/CSSSelector.h: Ditto.
+        * html/shadow/MediaControls.cpp:
+        (WebCore::MediaControls::createPanel): Changed to use the newly-added MediaControlPanelElement.
+        (WebCore::MediaControls::createCurrentTimeDisplay): Changed to use the newly-added
+            MediaControlCurrentTimeDisplayElement.
+        (WebCore::MediaControls::createTimeRemainingDisplay): Changed to use the newly-added
+                MediaControlTimeRemainingDisplayElement.
+        * rendering/MediaControlElements.cpp:
+        (WebCore::MediaControlShadowRootElement::updateStyle): Changed to use the
+            standard style resolution.
+        (WebCore::MediaControlShadowRootElement::shadowPseudoId): Added.
+        (WebCore::MediaControlElement::MediaControlElement): Removed the switch statement
+            that is no longer necessary.
+        (WebCore::MediaControlElement::styleForElement): Changed to use the standard
+            style resolution.
+        (WebCore::MediaControlPanelElement::MediaControlPanelElement): Added.
+        (WebCore::MediaControlPanelElement::create): Added.
+        (WebCore::MediaControlPanelElement::displayType): Added.
+        (WebCore::MediaControlPanelElement::shadowPseudoId): Added.
+        (WebCore::MediaControlTimelineContainerElement::MediaControlTimelineContainerElement):
+            Removed PseudoId constructor arg.
+        (WebCore::MediaControlTimelineContainerElement::rendererIsNeeded):
+            Changed to use the newly-plumbed usesMediaControlStatusDisplay helper.
+        (WebCore::MediaControlTimelineContainerElement::displayType): Added.
+        (WebCore::MediaControlTimelineContainerElement::shadowPseudoId): Added.
+        (WebCore::MediaControlVolumeSliderContainerElement::MediaControlVolumeSliderContainerElement):
+            Removed PseudoId constructor arg.
+        (WebCore::MediaControlVolumeSliderContainerElement::displayType): Added.
+        (WebCore::MediaControlVolumeSliderContainerElement::shadowPseudoId): Added.
+        (WebCore::MediaControlStatusDisplayElement::MediaControlStatusDisplayElement):
+            Removed PseudoId constructor arg.
+        (WebCore::MediaControlStatusDisplayElement::rendererIsNeeded): Changed to
+            use the newly-plumbed usesMediaControlStatusDisplay helper.
+        (WebCore::MediaControlStatusDisplayElement::displayType): Added.
+        (WebCore::MediaControlStatusDisplayElement::shadowPseudoId): Added.
+        (WebCore::MediaControlTimeDisplayElement::MediaControlTimeDisplayElement):
+            Removed PseudoId constructor arg.
+        (WebCore::MediaControlTimeRemainingDisplayElement::create): Added.
+        (WebCore::MediaControlTimeRemainingDisplayElement::MediaControlTimeRemainingDisplayElement): Added.
+        (WebCore::MediaControlTimeRemainingDisplayElement::displayType): Added.
+        (WebCore::MediaControlTimeRemainingDisplayElement::shadowPseudoId): Added.
+        (WebCore::MediaControlCurrentTimeDisplayElement::create): Added.
+        (WebCore::MediaControlCurrentTimeDisplayElement::MediaControlCurrentTimeDisplayElement): Added.
+        (WebCore::MediaControlCurrentTimeDisplayElement::displayType): Added.
+        (WebCore::MediaControlCurrentTimeDisplayElement::shadowPseudoId): Added.
+        * rendering/MediaControlElements.h: Added/changed defs accordingly.
+        * rendering/RenderTheme.h:
+        (WebCore::RenderTheme::usesMediaControlStatusDisplay): Added.
+        * rendering/RenderThemeMac.h: Added def.
+        * rendering/RenderThemeMac.mm:
+        (WebCore::RenderThemeMac::usesMediaControlStatusDisplay): Added.
+        * rendering/style/RenderStyleConstants.h: Removed now-unused enum values.
+
 2011-02-08  Xiaomei Ji  <xji@chromium.org>
 
         Reviewed by Dan Bernstein.
index df192d7..c804697 100644 (file)
@@ -138,18 +138,6 @@ PseudoId CSSSelector::pseudoId(PseudoType type)
         return SEARCH_RESULTS_DECORATION;
     case PseudoSearchResultsButton:
         return SEARCH_RESULTS_BUTTON;
-    case PseudoMediaControlsPanel:
-        return MEDIA_CONTROLS_PANEL;
-    case PseudoMediaControlsTimelineContainer:
-        return MEDIA_CONTROLS_TIMELINE_CONTAINER;
-    case PseudoMediaControlsVolumeSliderContainer:
-        return MEDIA_CONTROLS_VOLUME_SLIDER_CONTAINER;
-    case PseudoMediaControlsCurrentTimeDisplay:
-        return MEDIA_CONTROLS_CURRENT_TIME_DISPLAY;
-    case PseudoMediaControlsTimeRemainingDisplay:
-        return MEDIA_CONTROLS_TIME_REMAINING_DISPLAY;
-    case PseudoMediaControlsStatusDisplay:
-        return MEDIA_CONTROLS_STATUS_DISPLAY;
     case PseudoScrollbar:
         return SCROLLBAR;
     case PseudoScrollbarButton:
@@ -316,12 +304,6 @@ static HashMap<AtomicStringImpl*, CSSSelector::PseudoType>* nameToPseudoTypeMap(
     DEFINE_STATIC_LOCAL(AtomicString, lastOfType, ("last-of-type"));
     DEFINE_STATIC_LOCAL(AtomicString, link, ("link"));
     DEFINE_STATIC_LOCAL(AtomicString, lang, ("lang("));
-    DEFINE_STATIC_LOCAL(AtomicString, mediaControlsPanel, ("-webkit-media-controls-panel"));
-    DEFINE_STATIC_LOCAL(AtomicString, mediaControlsStatusDisplay, ("-webkit-media-controls-status-display"));
-    DEFINE_STATIC_LOCAL(AtomicString, mediaControlsTimelineContainer, ("-webkit-media-controls-timeline-container"));
-    DEFINE_STATIC_LOCAL(AtomicString, mediaControlsVolumeSliderContainer, ("-webkit-media-controls-volume-slider-container"));
-    DEFINE_STATIC_LOCAL(AtomicString, mediaControlsCurrentTimeDisplay, ("-webkit-media-controls-current-time-display"));
-    DEFINE_STATIC_LOCAL(AtomicString, mediaControlsTimeRemainingDisplay, ("-webkit-media-controls-time-remaining-display"));
     DEFINE_STATIC_LOCAL(AtomicString, notStr, ("not("));
     DEFINE_STATIC_LOCAL(AtomicString, onlyChild, ("only-child"));
     DEFINE_STATIC_LOCAL(AtomicString, onlyOfType, ("only-of-type"));
@@ -418,12 +400,6 @@ static HashMap<AtomicStringImpl*, CSSSelector::PseudoType>* nameToPseudoTypeMap(
         nameToPseudoType->set(innerSpinButton.impl(), CSSSelector::PseudoInnerSpinButton);
         nameToPseudoType->set(link.impl(), CSSSelector::PseudoLink);
         nameToPseudoType->set(lang.impl(), CSSSelector::PseudoLang);
-        nameToPseudoType->set(mediaControlsPanel.impl(), CSSSelector::PseudoMediaControlsPanel);
-        nameToPseudoType->set(mediaControlsCurrentTimeDisplay.impl(), CSSSelector::PseudoMediaControlsCurrentTimeDisplay);
-        nameToPseudoType->set(mediaControlsTimeRemainingDisplay.impl(), CSSSelector::PseudoMediaControlsTimeRemainingDisplay);
-        nameToPseudoType->set(mediaControlsStatusDisplay.impl(), CSSSelector::PseudoMediaControlsStatusDisplay);
-        nameToPseudoType->set(mediaControlsTimelineContainer.impl(), CSSSelector::PseudoMediaControlsTimelineContainer);
-        nameToPseudoType->set(mediaControlsVolumeSliderContainer.impl(), CSSSelector::PseudoMediaControlsVolumeSliderContainer);
         nameToPseudoType->set(notStr.impl(), CSSSelector::PseudoNot);
         nameToPseudoType->set(nthChild.impl(), CSSSelector::PseudoNthChild);
         nameToPseudoType->set(nthOfType.impl(), CSSSelector::PseudoNthOfType);
@@ -514,12 +490,6 @@ void CSSSelector::extractPseudoType() const
     case PseudoInputSpeechButton:
 #endif
     case PseudoInnerSpinButton:
-    case PseudoMediaControlsPanel:
-    case PseudoMediaControlsCurrentTimeDisplay:
-    case PseudoMediaControlsTimeRemainingDisplay:
-    case PseudoMediaControlsStatusDisplay:
-    case PseudoMediaControlsTimelineContainer:
-    case PseudoMediaControlsVolumeSliderContainer:
     case PseudoMeterHorizontalBar:
     case PseudoMeterHorizontalOptimum:
     case PseudoMeterHorizontalSuboptimal:
index f3f800b..ea161c3 100644 (file)
@@ -175,12 +175,6 @@ namespace WebCore {
             PseudoSearchDecoration,
             PseudoSearchResultsDecoration,
             PseudoSearchResultsButton,
-            PseudoMediaControlsPanel,
-            PseudoMediaControlsTimelineContainer,
-            PseudoMediaControlsVolumeSliderContainer,
-            PseudoMediaControlsCurrentTimeDisplay,
-            PseudoMediaControlsTimeRemainingDisplay,
-            PseudoMediaControlsStatusDisplay,
             PseudoMeterHorizontalBar,
             PseudoMeterVerticalBar,
             PseudoMeterHorizontalOptimum,
index d31258a..731a934 100644 (file)
@@ -239,7 +239,7 @@ void MediaControls::createControlsShadowRoot()
 void MediaControls::createPanel()
 {
     ASSERT(!m_panel);
-    m_panel = MediaControlElement::create(m_mediaElement, MEDIA_CONTROLS_PANEL);
+    m_panel = MediaControlPanelElement::create(m_mediaElement);
     m_panel->attachToParent(m_controlsShadowRoot.get());
 }
 
@@ -341,14 +341,14 @@ void MediaControls::createVolumeSliderMuteButton()
 void MediaControls::createCurrentTimeDisplay()
 {
     ASSERT(!m_currentTimeDisplay);
-    m_currentTimeDisplay = MediaControlTimeDisplayElement::create(m_mediaElement, MEDIA_CONTROLS_CURRENT_TIME_DISPLAY);
+    m_currentTimeDisplay = MediaControlCurrentTimeDisplayElement::create(m_mediaElement);
     m_currentTimeDisplay->attachToParent(m_timelineContainer.get());
 }
 
 void MediaControls::createTimeRemainingDisplay()
 {
     ASSERT(!m_timeRemainingDisplay);
-    m_timeRemainingDisplay = MediaControlTimeDisplayElement::create(m_mediaElement, MEDIA_CONTROLS_TIME_REMAINING_DISPLAY);
+    m_timeRemainingDisplay = MediaControlTimeRemainingDisplayElement::create(m_mediaElement);
     m_timeRemainingDisplay->attachToParent(m_timelineContainer.get());
 }
 
index 14b9f81..98e017f 100644 (file)
@@ -41,6 +41,7 @@ class Event;
 class MediaControlMuteButtonElement;
 class MediaControlPlayButtonElement;
 class MediaControlSeekButtonElement;
+class MediaControlShadowRootElement;
 class MediaControlRewindButtonElement;
 class MediaControlReturnToRealtimeButtonElement;
 class MediaControlToggleClosedCaptionsButtonElement;
@@ -102,7 +103,7 @@ private:
     void updateVolumeSliderContainer(bool visible);
 
 private:
-    RefPtr<HTMLElement> m_controlsShadowRoot;
+    RefPtr<MediaControlShadowRootElement> m_controlsShadowRoot;
     RefPtr<MediaControlElement> m_panel;
     RefPtr<MediaControlMuteButtonElement> m_muteButton;
     RefPtr<MediaControlPlayButtonElement> m_playButton;
index ee3b8da..653a355 100644 (file)
@@ -90,14 +90,6 @@ PassRefPtr<MediaControlShadowRootElement> MediaControlShadowRootElement::create(
     return element.release();
 }
 
-void MediaControlShadowRootElement::updateStyle()
-{
-    if (renderer()) {
-        RenderStyle* timelineContainerStyle = shadowHost()->renderer()->getCachedPseudoStyle(MEDIA_CONTROLS_TIMELINE_CONTAINER);
-        renderer()->setStyle(timelineContainerStyle);
-    }
-}
-
 void MediaControlShadowRootElement::detach()
 {
     HTMLDivElement::detach();
@@ -107,40 +99,11 @@ void MediaControlShadowRootElement::detach()
 
 // ----------------------------
 
-MediaControlElement::MediaControlElement(HTMLMediaElement* mediaElement, PseudoId pseudo)
+MediaControlElement::MediaControlElement(HTMLMediaElement* mediaElement)
     : HTMLDivElement(divTag, mediaElement->document())
     , m_mediaElement(mediaElement)
-    , m_pseudoStyleId(pseudo)
 {
     setInDocument();
-    switch (pseudo) {
-    case MEDIA_CONTROLS_CURRENT_TIME_DISPLAY:
-        m_displayType = MediaCurrentTimeDisplay;
-        break;
-    case MEDIA_CONTROLS_TIME_REMAINING_DISPLAY:
-        m_displayType = MediaTimeRemainingDisplay;
-        break;
-    case MEDIA_CONTROLS_TIMELINE_CONTAINER:
-        m_displayType = MediaTimelineContainer;
-        break;
-    case MEDIA_CONTROLS_STATUS_DISPLAY:
-        m_displayType = MediaStatusDisplay;
-        break;
-    case MEDIA_CONTROLS_PANEL:
-        m_displayType = MediaControlsPanel;
-        break;
-    case MEDIA_CONTROLS_VOLUME_SLIDER_CONTAINER:
-        m_displayType = MediaVolumeSliderContainer;
-        break;
-    default:
-        ASSERT_NOT_REACHED();
-        break;
-    }
-}
-
-PassRefPtr<MediaControlElement> MediaControlElement::create(HTMLMediaElement* mediaElement, PseudoId pseudoStyleId)
-{
-    return adoptRef(new MediaControlElement(mediaElement, pseudoStyleId));
 }
 
 void MediaControlElement::attachToParent(Element* parent)
@@ -159,7 +122,8 @@ void MediaControlElement::update()
 
 PassRefPtr<RenderStyle> MediaControlElement::styleForElement()
 {
-    RenderStyle* style = m_mediaElement->renderer()->getCachedPseudoStyle(m_pseudoStyleId);
+    ASSERT(m_mediaElement->renderer());
+    RefPtr<RenderStyle> style = document()->styleSelector()->styleForElement(this, m_mediaElement->renderer()->style(), true);
     if (!style)
         return 0;
     
@@ -227,8 +191,31 @@ void MediaControlElement::updateStyle()
 
 // ----------------------------
 
+inline MediaControlPanelElement::MediaControlPanelElement(HTMLMediaElement* mediaElement)
+    : MediaControlElement(mediaElement)
+{
+}
+
+PassRefPtr<MediaControlPanelElement> MediaControlPanelElement::create(HTMLMediaElement* mediaElement)
+{
+    return adoptRef(new MediaControlPanelElement(mediaElement));
+}
+
+MediaControlElementType MediaControlPanelElement::displayType() const
+{
+    return MediaControlsPanel;
+}
+
+const AtomicString& MediaControlPanelElement::shadowPseudoId() const
+{
+    DEFINE_STATIC_LOCAL(AtomicString, id, ("-webkit-media-controls-panel"));
+    return id;
+}
+
+// ----------------------------
+
 inline MediaControlTimelineContainerElement::MediaControlTimelineContainerElement(HTMLMediaElement* mediaElement)
-    : MediaControlElement(mediaElement, MEDIA_CONTROLS_TIMELINE_CONTAINER)
+    : MediaControlElement(mediaElement)
 {
 }
 
@@ -242,20 +229,29 @@ bool MediaControlTimelineContainerElement::rendererIsNeeded(RenderStyle* style)
     if (!MediaControlElement::rendererIsNeeded(style))
         return false;
 
-    // This is for MediaControllerThemeClassic:
-    // If there is no style for MediaControlStatusDisplayElement style, don't hide
-    // the timeline.
-    if (!mediaElement()->renderer()->getCachedPseudoStyle(MEDIA_CONTROLS_STATUS_DISPLAY))
+    // Always show the timeline if the theme doesn't use status display (MediaControllerThemeClassic, for instance).
+    if (!document()->page()->theme()->usesMediaControlStatusDisplay())
         return true;
 
     float duration = mediaElement()->duration();
     return !isnan(duration) && !isinf(duration);
 }
 
+MediaControlElementType MediaControlTimelineContainerElement::displayType() const
+{
+    return MediaTimelineContainer;
+}
+
+const AtomicString& MediaControlTimelineContainerElement::shadowPseudoId() const
+{
+    DEFINE_STATIC_LOCAL(AtomicString, id, ("-webkit-media-controls-timeline-container"));
+    return id;
+}
+
 // ----------------------------
 
 inline MediaControlVolumeSliderContainerElement::MediaControlVolumeSliderContainerElement(HTMLMediaElement* mediaElement)
-    : MediaControlElement(mediaElement, MEDIA_CONTROLS_VOLUME_SLIDER_CONTAINER)
+    : MediaControlElement(mediaElement)
     , m_isVisible(false)
     , m_x(0)
     , m_y(0)
@@ -300,10 +296,21 @@ bool MediaControlVolumeSliderContainerElement::hitTest(const IntPoint& absPoint)
     return false;
 }
 
+MediaControlElementType MediaControlVolumeSliderContainerElement::displayType() const
+{
+    return MediaVolumeSliderContainer;
+}
+
+const AtomicString& MediaControlVolumeSliderContainerElement::shadowPseudoId() const
+{
+    DEFINE_STATIC_LOCAL(AtomicString, id, ("-webkit-media-controls-volume-slider-container"));
+    return id;
+}
+
 // ----------------------------
 
 inline MediaControlStatusDisplayElement::MediaControlStatusDisplayElement(HTMLMediaElement* mediaElement)
-    : MediaControlElement(mediaElement, MEDIA_CONTROLS_STATUS_DISPLAY)
+    : MediaControlElement(mediaElement)
     , m_stateBeingDisplayed(Nothing)
 {
 }
@@ -346,12 +353,23 @@ void MediaControlStatusDisplayElement::update()
 
 bool MediaControlStatusDisplayElement::rendererIsNeeded(RenderStyle* style)
 {
-    if (!MediaControlElement::rendererIsNeeded(style))
+    if (!MediaControlElement::rendererIsNeeded(style) || !document()->page()->theme()->usesMediaControlStatusDisplay())
         return false;
     float duration = mediaElement()->duration();
     return (isnan(duration) || isinf(duration));
 }
 
+MediaControlElementType MediaControlStatusDisplayElement::displayType() const
+{
+    return MediaStatusDisplay;
+}
+
+const AtomicString& MediaControlStatusDisplayElement::shadowPseudoId() const
+{
+    DEFINE_STATIC_LOCAL(AtomicString, id, ("-webkit-media-controls-status-display"));
+    return id;
+}
+
 // ----------------------------
     
 MediaControlInputElement::MediaControlInputElement(HTMLMediaElement* mediaElement, MediaControlElementType displayType)
@@ -893,18 +911,13 @@ const AtomicString& MediaControlFullscreenButtonElement::shadowPseudoId() const
 
 // ----------------------------
 
-inline MediaControlTimeDisplayElement::MediaControlTimeDisplayElement(HTMLMediaElement* mediaElement, PseudoId pseudo)
-    : MediaControlElement(mediaElement, pseudo)
+inline MediaControlTimeDisplayElement::MediaControlTimeDisplayElement(HTMLMediaElement* mediaElement)
+    : MediaControlElement(mediaElement)
     , m_currentValue(0)
     , m_isVisible(true)
 {
 }
 
-PassRefPtr<MediaControlTimeDisplayElement> MediaControlTimeDisplayElement::create(HTMLMediaElement* mediaElement, PseudoId pseudoStyleId)
-{
-    return adoptRef(new MediaControlTimeDisplayElement(mediaElement, pseudoStyleId));
-}
-
 PassRefPtr<RenderStyle> MediaControlTimeDisplayElement::styleForElement()
 {
     RefPtr<RenderStyle> style = MediaControlElement::styleForElement();
@@ -935,6 +948,52 @@ void MediaControlTimeDisplayElement::setCurrentValue(float time)
     m_currentValue = time;
 }
 
+// ----------------------------
+
+PassRefPtr<MediaControlTimeRemainingDisplayElement> MediaControlTimeRemainingDisplayElement::create(HTMLMediaElement* mediaElement)
+{
+    return adoptRef(new MediaControlTimeRemainingDisplayElement(mediaElement));
+}
+
+MediaControlTimeRemainingDisplayElement::MediaControlTimeRemainingDisplayElement(HTMLMediaElement* mediaElement)
+    : MediaControlTimeDisplayElement(mediaElement)
+{
+}
+
+MediaControlElementType MediaControlTimeRemainingDisplayElement::displayType() const
+{
+    return MediaTimeRemainingDisplay;
+}
+
+const AtomicString& MediaControlTimeRemainingDisplayElement::shadowPseudoId() const
+{
+    DEFINE_STATIC_LOCAL(AtomicString, id, ("-webkit-media-controls-time-remaining-display"));
+    return id;
+}
+
+// ----------------------------
+
+PassRefPtr<MediaControlCurrentTimeDisplayElement> MediaControlCurrentTimeDisplayElement::create(HTMLMediaElement* mediaElement)
+{
+    return adoptRef(new MediaControlCurrentTimeDisplayElement(mediaElement));
+}
+
+MediaControlCurrentTimeDisplayElement::MediaControlCurrentTimeDisplayElement(HTMLMediaElement* mediaElement)
+    : MediaControlTimeDisplayElement(mediaElement)
+{
+}
+
+MediaControlElementType MediaControlCurrentTimeDisplayElement::displayType() const
+{
+    return MediaCurrentTimeDisplay;
+}
+
+const AtomicString& MediaControlCurrentTimeDisplayElement::shadowPseudoId() const
+{
+    DEFINE_STATIC_LOCAL(AtomicString, id, ("-webkit-media-controls-current-time-display"));
+    return id;
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(VIDEO)
index c3253c4..ff9541d 100644 (file)
@@ -75,7 +75,6 @@ class MediaControlShadowRootElement : public HTMLDivElement {
 public:
     static PassRefPtr<MediaControlShadowRootElement> create(HTMLMediaElement*);
 
-    void updateStyle();
     virtual void detach();
     
 private:
@@ -86,19 +85,17 @@ private:
 
 class MediaControlElement : public HTMLDivElement {
 public:
-    static PassRefPtr<MediaControlElement> create(HTMLMediaElement*, PseudoId);
-
     virtual void attach();
     void attachToParent(Element*);
     void update();
     void updateStyle();
 
-    MediaControlElementType displayType() const { return m_displayType; }
+    virtual MediaControlElementType displayType() const = 0;
 
     HTMLMediaElement* mediaElement() const { return m_mediaElement; }
 
 protected:
-    MediaControlElement(HTMLMediaElement*, PseudoId);
+    MediaControlElement(HTMLMediaElement*);
 
     virtual bool rendererIsNeeded(RenderStyle*);
 
@@ -108,19 +105,32 @@ private:
     virtual bool isMediaControlElement() const { return true; }
 
     HTMLMediaElement* m_mediaElement;   
-    PseudoId m_pseudoStyleId;
-    MediaControlElementType m_displayType;  // some elements can show multiple types (e.g. play/pause)
 };
 
 // ----------------------------
 
+class MediaControlPanelElement : public MediaControlElement {
+public:
+    static PassRefPtr<MediaControlPanelElement> create(HTMLMediaElement*);
+
+private:
+    MediaControlPanelElement(HTMLMediaElement*);
+    virtual MediaControlElementType displayType() const;
+    virtual const AtomicString& shadowPseudoId() const;
+};
+
+
+// ----------------------------
+
 class MediaControlTimelineContainerElement : public MediaControlElement {
 public:
     static PassRefPtr<MediaControlTimelineContainerElement> create(HTMLMediaElement*);
 
 private:
     MediaControlTimelineContainerElement(HTMLMediaElement*);
+    virtual MediaControlElementType displayType() const;
     virtual bool rendererIsNeeded(RenderStyle*);
+    virtual const AtomicString& shadowPseudoId() const;
 };
 
 // ----------------------------
@@ -137,6 +147,8 @@ public:
 
 private:
     MediaControlVolumeSliderContainerElement(HTMLMediaElement*);
+    virtual MediaControlElementType displayType() const;
+    virtual const AtomicString& shadowPseudoId() const;
 
     bool m_isVisible;
     int m_x, m_y;
@@ -153,7 +165,9 @@ public:
 private:
     MediaControlStatusDisplayElement(HTMLMediaElement*);
 
+    virtual MediaControlElementType displayType() const;
     virtual bool rendererIsNeeded(RenderStyle*);
+    virtual const AtomicString& shadowPseudoId() const;
 
     enum StateBeingDisplayed { Nothing, Loading, LiveBroadcast };
     StateBeingDisplayed m_stateBeingDisplayed;
@@ -373,16 +387,15 @@ private:
 
 class MediaControlTimeDisplayElement : public MediaControlElement {
 public:
-    static PassRefPtr<MediaControlTimeDisplayElement> create(HTMLMediaElement*, PseudoId);
-
     void setVisible(bool);
 
     void setCurrentValue(float);
     float currentValue() const { return m_currentValue; }
 
-private:
-    MediaControlTimeDisplayElement(HTMLMediaElement*, PseudoId);
+protected:
+    MediaControlTimeDisplayElement(HTMLMediaElement*);
 
+private:
     virtual PassRefPtr<RenderStyle> styleForElement();
     float m_currentValue;
     bool m_isVisible;
@@ -390,6 +403,32 @@ private:
 
 // ----------------------------
 
+class MediaControlTimeRemainingDisplayElement : public MediaControlTimeDisplayElement {
+public:
+    static PassRefPtr<MediaControlTimeRemainingDisplayElement> create(HTMLMediaElement*);
+
+private:
+    MediaControlTimeRemainingDisplayElement(HTMLMediaElement*);
+
+    virtual MediaControlElementType displayType() const;
+    virtual const AtomicString& shadowPseudoId() const;
+};
+
+// ----------------------------
+
+class MediaControlCurrentTimeDisplayElement : public MediaControlTimeDisplayElement {
+public:
+    static PassRefPtr<MediaControlCurrentTimeDisplayElement> create(HTMLMediaElement*);
+
+private:
+    MediaControlCurrentTimeDisplayElement(HTMLMediaElement*);
+
+    virtual MediaControlElementType displayType() const;
+    virtual const AtomicString& shadowPseudoId() const;
+};
+
+// ----------------------------
+
 class RenderMediaControlShadowRoot : public RenderBlock {
 public:
     RenderMediaControlShadowRoot(Element* e) : RenderBlock(e) { }
index b2d1585..bce8d78 100644 (file)
@@ -180,6 +180,7 @@ public:
     // Media controls
     virtual bool hitTestMediaControlPart(RenderObject*, const IntPoint& absPoint);
     virtual bool shouldRenderMediaControlPart(ControlPart, Element*);
+    virtual bool usesMediaControlStatusDisplay() { return false; }
     virtual double mediaControlsFadeInDuration() { return 0.1; }
     virtual double mediaControlsFadeOutDuration() { return 0.3; }
     virtual String formatMediaControlsTime(float time) const;
index d1875fc..80bbae4 100644 (file)
@@ -46,6 +46,7 @@ protected:
     virtual bool paintMediaVolumeSliderTrack(RenderObject*, const PaintInfo&, const IntRect&);
     virtual bool paintMediaVolumeSliderThumb(RenderObject*, const PaintInfo&, const IntRect&);
     virtual IntPoint volumeSliderOffsetFromMuteButton(Node*, const IntSize&) const;
+    virtual bool usesMediaControlStatusDisplay() { return false; }
 
 #endif
 
index a2644e2..9837c2a 100644 (file)
@@ -164,6 +164,7 @@ protected:
     virtual String extraMediaControlsStyleSheet();
 
     virtual bool shouldRenderMediaControlPart(ControlPart, Element*);
+    virtual bool usesMediaControlStatusDisplay();
     virtual void adjustMediaSliderThumbSize(RenderObject*) const;
     virtual IntPoint volumeSliderOffsetFromMuteButton(Node*, const IntSize&) const;
 #endif
index f1384ef..e3c75c5 100644 (file)
@@ -1981,6 +1981,11 @@ bool RenderThemeMac::shouldRenderMediaControlPart(ControlPart part, Element* ele
     return RenderTheme::shouldRenderMediaControlPart(part, element);
 }
 
+bool RenderThemeMac::usesMediaControlStatusDisplay()
+{
+    return mediaControllerTheme() == MediaControllerThemeQuickTime;
+}
+
 IntPoint RenderThemeMac::volumeSliderOffsetFromMuteButton(Node* muteButton, const IntSize& size) const
 {
     static const int xOffset = -4;
index c95bf5a..44cd3f5 100644 (file)
@@ -68,9 +68,8 @@ enum StyleDifferenceContextSensitiveProperty {
 enum PseudoId {
     // The order must be NOP ID, public IDs, and then internal IDs.
     NOPSEUDO, FIRST_LINE, FIRST_LETTER, BEFORE, AFTER, SELECTION, FIRST_LINE_INHERITED, SCROLLBAR, FILE_UPLOAD_BUTTON, INPUT_PLACEHOLDER,
-    SEARCH_CANCEL_BUTTON, SEARCH_DECORATION, SEARCH_RESULTS_DECORATION, SEARCH_RESULTS_BUTTON, MEDIA_CONTROLS_PANEL,
-    MEDIA_CONTROLS_TIMELINE_CONTAINER, MEDIA_CONTROLS_VOLUME_SLIDER_CONTAINER, MEDIA_CONTROLS_CURRENT_TIME_DISPLAY, MEDIA_CONTROLS_TIME_REMAINING_DISPLAY, 
-    MEDIA_CONTROLS_STATUS_DISPLAY, SCROLLBAR_THUMB, SCROLLBAR_BUTTON, SCROLLBAR_TRACK, SCROLLBAR_TRACK_PIECE, SCROLLBAR_CORNER, RESIZER,
+    SEARCH_CANCEL_BUTTON, SEARCH_DECORATION, SEARCH_RESULTS_DECORATION, SEARCH_RESULTS_BUTTON,
+    SCROLLBAR_THUMB, SCROLLBAR_BUTTON, SCROLLBAR_TRACK, SCROLLBAR_TRACK_PIECE, SCROLLBAR_CORNER, RESIZER,
     INPUT_LIST_BUTTON, INPUT_SPEECH_BUTTON, INNER_SPIN_BUTTON, OUTER_SPIN_BUTTON, VISITED_LINK,
     METER_HORIZONTAL_BAR, METER_HORIZONTAL_OPTIMUM, METER_HORIZONTAL_SUBOPTIMAL, METER_HORIZONTAL_EVEN_LESS_GOOD,
     METER_VERTICAL_BAR, METER_VERTICAL_OPTIMUM, METER_VERTICAL_SUBOPTIMAL, METER_VERTICAL_EVEN_LESS_GOOD,