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

Unified Diff: Source/core/html/shadow/MediaControlElements.cpp

Issue 195473002: Let MediaControls use the parent HTMLMediaElement (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/html/shadow/MediaControlElements.cpp
diff --git a/Source/core/html/shadow/MediaControlElements.cpp b/Source/core/html/shadow/MediaControlElements.cpp
index a0f6d2be7523074c9d4487f79f610f9786779d5b..2ca4af643bb3527f46d550eb419885ab55ca9307 100644
--- a/Source/core/html/shadow/MediaControlElements.cpp
+++ b/Source/core/html/shadow/MediaControlElements.cpp
@@ -59,8 +59,8 @@ static const AtomicString& getMediaControlTimeRemainingDisplayElementShadowPseud
static const double fadeInDuration = 0.1;
static const double fadeOutDuration = 0.3;
-MediaControlPanelElement::MediaControlPanelElement(Document& document)
- : MediaControlDivElement(document, MediaControlsPanel)
+MediaControlPanelElement::MediaControlPanelElement(HTMLMediaElement& mediaElement)
+ : MediaControlDivElement(mediaElement, MediaControlsPanel)
, m_canBeDragged(false)
, m_isBeingDragged(false)
, m_isDisplayed(false)
@@ -69,9 +69,9 @@ MediaControlPanelElement::MediaControlPanelElement(Document& document)
{
}
-PassRefPtr<MediaControlPanelElement> MediaControlPanelElement::create(Document& document)
+PassRefPtr<MediaControlPanelElement> MediaControlPanelElement::create(HTMLMediaElement& mediaElement)
{
- return adoptRef(new MediaControlPanelElement(document));
+ return adoptRef(new MediaControlPanelElement(mediaElement));
}
const AtomicString& MediaControlPanelElement::shadowPseudoId() const
@@ -247,15 +247,15 @@ void MediaControlPanelElement::setIsDisplayed(bool isDisplayed)
// ----------------------------
-MediaControlPanelEnclosureElement::MediaControlPanelEnclosureElement(Document& document)
+MediaControlPanelEnclosureElement::MediaControlPanelEnclosureElement(HTMLMediaElement& mediaElement)
// Mapping onto same MediaControlElementType as panel element, since it has similar properties.
- : MediaControlDivElement(document, MediaControlsPanel)
+ : MediaControlDivElement(mediaElement, MediaControlsPanel)
{
}
-PassRefPtr<MediaControlPanelEnclosureElement> MediaControlPanelEnclosureElement::create(Document& document)
+PassRefPtr<MediaControlPanelEnclosureElement> MediaControlPanelEnclosureElement::create(HTMLMediaElement& mediaElement)
{
- return adoptRef(new MediaControlPanelEnclosureElement(document));
+ return adoptRef(new MediaControlPanelEnclosureElement(mediaElement));
}
const AtomicString& MediaControlPanelEnclosureElement::shadowPseudoId() const
@@ -266,15 +266,15 @@ const AtomicString& MediaControlPanelEnclosureElement::shadowPseudoId() const
// ----------------------------
-MediaControlOverlayEnclosureElement::MediaControlOverlayEnclosureElement(Document& document)
+MediaControlOverlayEnclosureElement::MediaControlOverlayEnclosureElement(HTMLMediaElement& mediaElement)
// Mapping onto same MediaControlElementType as panel element, since it has similar properties.
- : MediaControlDivElement(document, MediaControlsPanel)
+ : MediaControlDivElement(mediaElement, MediaControlsPanel)
{
}
-PassRefPtr<MediaControlOverlayEnclosureElement> MediaControlOverlayEnclosureElement::create(Document& document)
+PassRefPtr<MediaControlOverlayEnclosureElement> MediaControlOverlayEnclosureElement::create(HTMLMediaElement& mediaElement)
{
- return adoptRef(new MediaControlOverlayEnclosureElement(document));
+ return adoptRef(new MediaControlOverlayEnclosureElement(mediaElement));
}
const AtomicString& MediaControlOverlayEnclosureElement::shadowPseudoId() const
@@ -285,14 +285,14 @@ const AtomicString& MediaControlOverlayEnclosureElement::shadowPseudoId() const
// ----------------------------
-MediaControlMuteButtonElement::MediaControlMuteButtonElement(Document& document)
- : MediaControlInputElement(document, MediaMuteButton)
+MediaControlMuteButtonElement::MediaControlMuteButtonElement(HTMLMediaElement& mediaElement)
+ : MediaControlInputElement(mediaElement, MediaMuteButton)
{
}
-PassRefPtr<MediaControlMuteButtonElement> MediaControlMuteButtonElement::create(Document& document)
+PassRefPtr<MediaControlMuteButtonElement> MediaControlMuteButtonElement::create(HTMLMediaElement& mediaElement)
{
- RefPtr<MediaControlMuteButtonElement> button = adoptRef(new MediaControlMuteButtonElement(document));
+ RefPtr<MediaControlMuteButtonElement> button = adoptRef(new MediaControlMuteButtonElement(mediaElement));
button->ensureUserAgentShadowRoot();
button->setType("button");
return button.release();
@@ -301,7 +301,7 @@ PassRefPtr<MediaControlMuteButtonElement> MediaControlMuteButtonElement::create(
void MediaControlMuteButtonElement::defaultEventHandler(Event* event)
{
if (event->type() == EventTypeNames::click) {
- mediaController()->setMuted(!mediaController()->muted());
+ mediaControllerInterface().setMuted(!mediaControllerInterface().muted());
event->setDefaultHandled();
}
@@ -310,7 +310,7 @@ void MediaControlMuteButtonElement::defaultEventHandler(Event* event)
void MediaControlMuteButtonElement::updateDisplayType()
{
- setDisplayType(mediaController()->muted() ? MediaUnMuteButton : MediaMuteButton);
+ setDisplayType(mediaControllerInterface().muted() ? MediaUnMuteButton : MediaMuteButton);
}
const AtomicString& MediaControlMuteButtonElement::shadowPseudoId() const
@@ -321,14 +321,14 @@ const AtomicString& MediaControlMuteButtonElement::shadowPseudoId() const
// ----------------------------
-MediaControlPlayButtonElement::MediaControlPlayButtonElement(Document& document)
- : MediaControlInputElement(document, MediaPlayButton)
+MediaControlPlayButtonElement::MediaControlPlayButtonElement(HTMLMediaElement& mediaElement)
+ : MediaControlInputElement(mediaElement, MediaPlayButton)
{
}
-PassRefPtr<MediaControlPlayButtonElement> MediaControlPlayButtonElement::create(Document& document)
+PassRefPtr<MediaControlPlayButtonElement> MediaControlPlayButtonElement::create(HTMLMediaElement& mediaElement)
{
- RefPtr<MediaControlPlayButtonElement> button = adoptRef(new MediaControlPlayButtonElement(document));
+ RefPtr<MediaControlPlayButtonElement> button = adoptRef(new MediaControlPlayButtonElement(mediaElement));
button->ensureUserAgentShadowRoot();
button->setType("button");
return button.release();
@@ -337,10 +337,10 @@ PassRefPtr<MediaControlPlayButtonElement> MediaControlPlayButtonElement::create(
void MediaControlPlayButtonElement::defaultEventHandler(Event* event)
{
if (event->type() == EventTypeNames::click) {
- if (mediaController()->canPlay())
- mediaController()->play();
+ if (mediaControllerInterface().canPlay())
+ mediaControllerInterface().play();
else
- mediaController()->pause();
+ mediaControllerInterface().pause();
updateDisplayType();
event->setDefaultHandled();
}
@@ -349,7 +349,7 @@ void MediaControlPlayButtonElement::defaultEventHandler(Event* event)
void MediaControlPlayButtonElement::updateDisplayType()
{
- setDisplayType(mediaController()->canPlay() ? MediaPlayButton : MediaPauseButton);
+ setDisplayType(mediaControllerInterface().canPlay() ? MediaPlayButton : MediaPauseButton);
}
const AtomicString& MediaControlPlayButtonElement::shadowPseudoId() const
@@ -360,14 +360,14 @@ const AtomicString& MediaControlPlayButtonElement::shadowPseudoId() const
// ----------------------------
-MediaControlOverlayPlayButtonElement::MediaControlOverlayPlayButtonElement(Document& document)
- : MediaControlInputElement(document, MediaOverlayPlayButton)
+MediaControlOverlayPlayButtonElement::MediaControlOverlayPlayButtonElement(HTMLMediaElement& mediaElement)
+ : MediaControlInputElement(mediaElement, MediaOverlayPlayButton)
{
}
-PassRefPtr<MediaControlOverlayPlayButtonElement> MediaControlOverlayPlayButtonElement::create(Document& document)
+PassRefPtr<MediaControlOverlayPlayButtonElement> MediaControlOverlayPlayButtonElement::create(HTMLMediaElement& mediaElement)
{
- RefPtr<MediaControlOverlayPlayButtonElement> button = adoptRef(new MediaControlOverlayPlayButtonElement(document));
+ RefPtr<MediaControlOverlayPlayButtonElement> button = adoptRef(new MediaControlOverlayPlayButtonElement(mediaElement));
button->ensureUserAgentShadowRoot();
button->setType("button");
return button.release();
@@ -375,8 +375,8 @@ PassRefPtr<MediaControlOverlayPlayButtonElement> MediaControlOverlayPlayButtonEl
void MediaControlOverlayPlayButtonElement::defaultEventHandler(Event* event)
{
- if (event->type() == EventTypeNames::click && mediaController()->canPlay()) {
- mediaController()->play();
+ if (event->type() == EventTypeNames::click && mediaControllerInterface().canPlay()) {
+ mediaControllerInterface().play();
updateDisplayType();
event->setDefaultHandled();
}
@@ -385,7 +385,7 @@ void MediaControlOverlayPlayButtonElement::defaultEventHandler(Event* event)
void MediaControlOverlayPlayButtonElement::updateDisplayType()
{
- if (mediaController()->canPlay()) {
+ if (mediaControllerInterface().canPlay()) {
show();
} else
hide();
@@ -400,14 +400,14 @@ const AtomicString& MediaControlOverlayPlayButtonElement::shadowPseudoId() const
// ----------------------------
-MediaControlToggleClosedCaptionsButtonElement::MediaControlToggleClosedCaptionsButtonElement(Document& document)
- : MediaControlInputElement(document, MediaShowClosedCaptionsButton)
+MediaControlToggleClosedCaptionsButtonElement::MediaControlToggleClosedCaptionsButtonElement(HTMLMediaElement& mediaElement)
+ : MediaControlInputElement(mediaElement, MediaShowClosedCaptionsButton)
{
}
-PassRefPtr<MediaControlToggleClosedCaptionsButtonElement> MediaControlToggleClosedCaptionsButtonElement::create(Document& document)
+PassRefPtr<MediaControlToggleClosedCaptionsButtonElement> MediaControlToggleClosedCaptionsButtonElement::create(HTMLMediaElement& mediaElement)
{
- RefPtr<MediaControlToggleClosedCaptionsButtonElement> button = adoptRef(new MediaControlToggleClosedCaptionsButtonElement(document));
+ RefPtr<MediaControlToggleClosedCaptionsButtonElement> button = adoptRef(new MediaControlToggleClosedCaptionsButtonElement(mediaElement));
button->ensureUserAgentShadowRoot();
button->setType("button");
button->hide();
@@ -416,7 +416,7 @@ PassRefPtr<MediaControlToggleClosedCaptionsButtonElement> MediaControlToggleClos
void MediaControlToggleClosedCaptionsButtonElement::updateDisplayType()
{
- bool captionsVisible = mediaController()->closedCaptionsVisible();
+ bool captionsVisible = mediaControllerInterface().closedCaptionsVisible();
setDisplayType(captionsVisible ? MediaHideClosedCaptionsButton : MediaShowClosedCaptionsButton);
setChecked(captionsVisible);
}
@@ -424,8 +424,8 @@ void MediaControlToggleClosedCaptionsButtonElement::updateDisplayType()
void MediaControlToggleClosedCaptionsButtonElement::defaultEventHandler(Event* event)
{
if (event->type() == EventTypeNames::click) {
- mediaController()->setClosedCaptionsVisible(!mediaController()->closedCaptionsVisible());
- setChecked(mediaController()->closedCaptionsVisible());
+ mediaControllerInterface().setClosedCaptionsVisible(!mediaControllerInterface().closedCaptionsVisible());
+ setChecked(mediaControllerInterface().closedCaptionsVisible());
updateDisplayType();
event->setDefaultHandled();
}
@@ -441,17 +441,17 @@ const AtomicString& MediaControlToggleClosedCaptionsButtonElement::shadowPseudoI
// ----------------------------
-MediaControlTimelineElement::MediaControlTimelineElement(Document& document, MediaControls* controls)
- : MediaControlInputElement(document, MediaSlider)
+MediaControlTimelineElement::MediaControlTimelineElement(HTMLMediaElement& mediaElement, MediaControls* controls)
+ : MediaControlInputElement(mediaElement, MediaSlider)
, m_controls(controls)
philipj_slow 2014/03/11 17:38:10 This can be removed now, but I've done it in a sep
{
}
-PassRefPtr<MediaControlTimelineElement> MediaControlTimelineElement::create(Document& document, MediaControls* controls)
+PassRefPtr<MediaControlTimelineElement> MediaControlTimelineElement::create(HTMLMediaElement& mediaElement, MediaControls* controls)
{
ASSERT(controls);
- RefPtr<MediaControlTimelineElement> timeline = adoptRef(new MediaControlTimelineElement(document, controls));
+ RefPtr<MediaControlTimelineElement> timeline = adoptRef(new MediaControlTimelineElement(mediaElement, controls));
timeline->ensureUserAgentShadowRoot();
timeline->setType("range");
timeline->setAttribute(stepAttr, "any");
@@ -468,10 +468,10 @@ void MediaControlTimelineElement::defaultEventHandler(Event* event)
return;
if (event->type() == EventTypeNames::mousedown)
- mediaController()->beginScrubbing();
+ mediaControllerInterface().beginScrubbing();
if (event->type() == EventTypeNames::mouseup)
- mediaController()->endScrubbing();
+ mediaControllerInterface().endScrubbing();
MediaControlInputElement::defaultEventHandler(event);
@@ -479,8 +479,8 @@ void MediaControlTimelineElement::defaultEventHandler(Event* event)
return;
double time = value().toDouble();
- if (event->type() == EventTypeNames::input && time != mediaController()->currentTime())
- mediaController()->setCurrentTime(time, IGNORE_EXCEPTION);
+ if (event->type() == EventTypeNames::input && time != mediaControllerInterface().currentTime())
+ mediaControllerInterface().setCurrentTime(time, IGNORE_EXCEPTION);
RenderSlider* slider = toRenderSlider(renderer());
if (slider && slider->inDragMode())
@@ -511,14 +511,14 @@ const AtomicString& MediaControlTimelineElement::shadowPseudoId() const
// ----------------------------
-MediaControlVolumeSliderElement::MediaControlVolumeSliderElement(Document& document)
- : MediaControlInputElement(document, MediaVolumeSlider)
+MediaControlVolumeSliderElement::MediaControlVolumeSliderElement(HTMLMediaElement& mediaElement)
+ : MediaControlInputElement(mediaElement, MediaVolumeSlider)
{
}
-PassRefPtr<MediaControlVolumeSliderElement> MediaControlVolumeSliderElement::create(Document& document)
+PassRefPtr<MediaControlVolumeSliderElement> MediaControlVolumeSliderElement::create(HTMLMediaElement& mediaElement)
{
- RefPtr<MediaControlVolumeSliderElement> slider = adoptRef(new MediaControlVolumeSliderElement(document));
+ RefPtr<MediaControlVolumeSliderElement> slider = adoptRef(new MediaControlVolumeSliderElement(mediaElement));
slider->ensureUserAgentShadowRoot();
slider->setType("range");
slider->setAttribute(stepAttr, "any");
@@ -540,8 +540,8 @@ void MediaControlVolumeSliderElement::defaultEventHandler(Event* event)
return;
double volume = value().toDouble();
- mediaController()->setVolume(volume, ASSERT_NO_EXCEPTION);
- mediaController()->setMuted(false);
+ mediaControllerInterface().setVolume(volume, ASSERT_NO_EXCEPTION);
+ mediaControllerInterface().setMuted(false);
}
bool MediaControlVolumeSliderElement::willRespondToMouseMoveEvents()
@@ -574,14 +574,14 @@ const AtomicString& MediaControlVolumeSliderElement::shadowPseudoId() const
// ----------------------------
-MediaControlFullscreenButtonElement::MediaControlFullscreenButtonElement(Document& document)
- : MediaControlInputElement(document, MediaEnterFullscreenButton)
+MediaControlFullscreenButtonElement::MediaControlFullscreenButtonElement(HTMLMediaElement& mediaElement)
+ : MediaControlInputElement(mediaElement, MediaEnterFullscreenButton)
{
}
-PassRefPtr<MediaControlFullscreenButtonElement> MediaControlFullscreenButtonElement::create(Document& document)
+PassRefPtr<MediaControlFullscreenButtonElement> MediaControlFullscreenButtonElement::create(HTMLMediaElement& mediaElement)
{
- RefPtr<MediaControlFullscreenButtonElement> button = adoptRef(new MediaControlFullscreenButtonElement(document));
+ RefPtr<MediaControlFullscreenButtonElement> button = adoptRef(new MediaControlFullscreenButtonElement(mediaElement));
button->ensureUserAgentShadowRoot();
button->setType("button");
button->hide();
@@ -601,8 +601,9 @@ void MediaControlFullscreenButtonElement::defaultEventHandler(Event* event)
FullscreenElementStack::from(document()).webkitCancelFullScreen();
else
FullscreenElementStack::from(document()).requestFullScreenForElement(toParentMediaElement(this), 0, FullscreenElementStack::ExemptIFrameAllowFullScreenRequirement);
- } else
- mediaController()->enterFullscreen();
+ } else {
+ mediaControllerInterface().enterFullscreen();
+ }
event->setDefaultHandled();
}
HTMLInputElement::defaultEventHandler(event);
@@ -621,14 +622,14 @@ void MediaControlFullscreenButtonElement::setIsFullscreen(bool isFullscreen)
// ----------------------------
-MediaControlTimeRemainingDisplayElement::MediaControlTimeRemainingDisplayElement(Document& document)
- : MediaControlTimeDisplayElement(document, MediaTimeRemainingDisplay)
+MediaControlTimeRemainingDisplayElement::MediaControlTimeRemainingDisplayElement(HTMLMediaElement& mediaElement)
+ : MediaControlTimeDisplayElement(mediaElement, MediaTimeRemainingDisplay)
{
}
-PassRefPtr<MediaControlTimeRemainingDisplayElement> MediaControlTimeRemainingDisplayElement::create(Document& document)
+PassRefPtr<MediaControlTimeRemainingDisplayElement> MediaControlTimeRemainingDisplayElement::create(HTMLMediaElement& mediaElement)
{
- return adoptRef(new MediaControlTimeRemainingDisplayElement(document));
+ return adoptRef(new MediaControlTimeRemainingDisplayElement(mediaElement));
}
static const AtomicString& getMediaControlTimeRemainingDisplayElementShadowPseudoId()
@@ -644,14 +645,14 @@ const AtomicString& MediaControlTimeRemainingDisplayElement::shadowPseudoId() co
// ----------------------------
-MediaControlCurrentTimeDisplayElement::MediaControlCurrentTimeDisplayElement(Document& document)
- : MediaControlTimeDisplayElement(document, MediaCurrentTimeDisplay)
+MediaControlCurrentTimeDisplayElement::MediaControlCurrentTimeDisplayElement(HTMLMediaElement& mediaElement)
+ : MediaControlTimeDisplayElement(mediaElement, MediaCurrentTimeDisplay)
{
}
-PassRefPtr<MediaControlCurrentTimeDisplayElement> MediaControlCurrentTimeDisplayElement::create(Document& document)
+PassRefPtr<MediaControlCurrentTimeDisplayElement> MediaControlCurrentTimeDisplayElement::create(HTMLMediaElement& mediaElement)
{
- return adoptRef(new MediaControlCurrentTimeDisplayElement(document));
+ return adoptRef(new MediaControlCurrentTimeDisplayElement(mediaElement));
}
static const AtomicString& getMediaControlCurrentTimeDisplayElementShadowPseudoId()
@@ -667,15 +668,15 @@ const AtomicString& MediaControlCurrentTimeDisplayElement::shadowPseudoId() cons
// ----------------------------
-MediaControlTextTrackContainerElement::MediaControlTextTrackContainerElement(Document& document)
- : MediaControlDivElement(document, MediaTextTrackDisplayContainer)
+MediaControlTextTrackContainerElement::MediaControlTextTrackContainerElement(HTMLMediaElement& mediaElement)
+ : MediaControlDivElement(mediaElement, MediaTextTrackDisplayContainer)
, m_fontSize(0)
{
}
-PassRefPtr<MediaControlTextTrackContainerElement> MediaControlTextTrackContainerElement::create(Document& document)
+PassRefPtr<MediaControlTextTrackContainerElement> MediaControlTextTrackContainerElement::create(HTMLMediaElement& mediaElement)
{
- RefPtr<MediaControlTextTrackContainerElement> element = adoptRef(new MediaControlTextTrackContainerElement(document));
+ RefPtr<MediaControlTextTrackContainerElement> element = adoptRef(new MediaControlTextTrackContainerElement(mediaElement));
element->hide();
return element.release();
}
@@ -698,7 +699,7 @@ const AtomicString& MediaControlTextTrackContainerElement::shadowPseudoId() cons
void MediaControlTextTrackContainerElement::updateDisplay()
{
- if (!mediaController()->closedCaptionsVisible()) {
+ if (!mediaControllerInterface().closedCaptionsVisible()) {
removeChildren();
return;
}

Powered by Google App Engine
This is Rietveld 408576698