Commit 7c36b9d6 authored by Mounir Lamouri's avatar Mounir Lamouri Committed by Commit Bot

Remove static_cast<MediaControlsImpl*> that are no longer needed with the refactoring.

With all the media controls code moved the modules, there is no need to
cast from the MediaControls interface to the its modules' implementation.
The few remaining static_cast<> are from code calling the GetMediaControls()
method defined on the HTMLMediaElement.

Bug: 662761
Change-Id: Ic72baca68f1c54d6117ea47efdf9a808b3d02aea
Reviewed-on: https://chromium-review.googlesource.com/571820Reviewed-by: default avatarJennifer Apacible <apacible@chromium.org>
Commit-Queue: Mounir Lamouri <mlamouri@chromium.org>
Cr-Commit-Position: refs/heads/master@{#487118}
parent 38d4de72
......@@ -51,9 +51,9 @@ void MediaControlFullscreenButtonElement::DefaultEventHandler(Event* event) {
if (event->type() == EventTypeNames::click) {
RecordClickMetrics();
if (MediaElement().IsFullscreen())
static_cast<MediaControlsImpl&>(GetMediaControls()).ExitFullscreen();
GetMediaControls().ExitFullscreen();
else
static_cast<MediaControlsImpl&>(GetMediaControls()).EnterFullscreen();
GetMediaControls().EnterFullscreen();
event->SetDefaultHandled();
}
MediaControlInputElement::DefaultEventHandler(event);
......
......@@ -31,8 +31,7 @@ const char* MediaControlOverflowMenuButtonElement::GetNameForHistograms()
void MediaControlOverflowMenuButtonElement::DefaultEventHandler(Event* event) {
if (event->type() == EventTypeNames::click) {
if (static_cast<MediaControlsImpl&>(GetMediaControls())
.OverflowMenuVisible()) {
if (GetMediaControls().OverflowMenuVisible()) {
Platform::Current()->RecordAction(
UserMetricsAction("Media.Controls.OverflowClose"));
} else {
......@@ -40,7 +39,7 @@ void MediaControlOverflowMenuButtonElement::DefaultEventHandler(Event* event) {
UserMetricsAction("Media.Controls.OverflowOpen"));
}
static_cast<MediaControlsImpl&>(GetMediaControls()).ToggleOverflowMenu();
GetMediaControls().ToggleOverflowMenu();
event->SetDefaultHandled();
}
......
......@@ -25,8 +25,7 @@ MediaControlOverlayEnclosureElement::PreDispatchEventHandler(Event* event) {
// can prevent their translation to click events.
if (event && (event->type() == EventTypeNames::click ||
event->type() == EventTypeNames::touchstart)) {
static_cast<MediaControlsImpl&>(GetMediaControls())
.ShowOverlayCastButtonIfNeeded();
GetMediaControls().ShowOverlayCastButtonIfNeeded();
}
return MediaControlDivElement::PreDispatchEventHandler(event);
}
......
......@@ -74,14 +74,12 @@ void MediaControlTextTrackListElement::DefaultEventHandler(Event* event) {
if (!target || !target->IsElementNode())
return;
static_cast<MediaControlsImpl&>(GetMediaControls())
.DisableShowingTextTracks();
GetMediaControls().DisableShowingTextTracks();
int track_index =
ToElement(target)->GetIntegralAttribute(TrackIndexAttrName());
if (track_index != kTrackIndexOffValue) {
DCHECK_GE(track_index, 0);
static_cast<MediaControlsImpl&>(GetMediaControls())
.ShowTextTrackAtIndex(track_index);
GetMediaControls().ShowTextTrackAtIndex(track_index);
MediaElement().DisableAutomaticTextTrackSelection();
}
......
......@@ -74,9 +74,9 @@ void MediaControlTimelineElement::DefaultEventHandler(Event* event) {
// TODO(crbug.com/706504): These should listen for pointerdown/up.
if (event->type() == EventTypeNames::mousedown)
static_cast<MediaControlsImpl&>(GetMediaControls()).BeginScrubbing();
GetMediaControls().BeginScrubbing();
if (event->type() == EventTypeNames::mouseup)
static_cast<MediaControlsImpl&>(GetMediaControls()).EndScrubbing();
GetMediaControls().EndScrubbing();
// Only respond to main button of primary pointer(s).
if (event->IsPointerEvent() && ToPointerEvent(event)->isPrimary() &&
......@@ -85,7 +85,7 @@ void MediaControlTimelineElement::DefaultEventHandler(Event* event) {
if (event->type() == EventTypeNames::pointerdown) {
Platform::Current()->RecordAction(
UserMetricsAction("Media.Controls.ScrubbingBegin"));
static_cast<MediaControlsImpl&>(GetMediaControls()).BeginScrubbing();
GetMediaControls().BeginScrubbing();
Element* thumb = UserAgentShadowRoot()->getElementById(
ShadowElementNames::SliderThumb());
bool started_from_thumb = thumb && thumb == event->target()->ToNode();
......@@ -94,7 +94,7 @@ void MediaControlTimelineElement::DefaultEventHandler(Event* event) {
if (event->type() == EventTypeNames::pointerup) {
Platform::Current()->RecordAction(
UserMetricsAction("Media.Controls.ScrubbingEnd"));
static_cast<MediaControlsImpl&>(GetMediaControls()).EndScrubbing();
GetMediaControls().EndScrubbing();
metrics_.RecordEndGesture(TimelineWidth(), MediaElement().duration());
}
}
......@@ -134,8 +134,7 @@ void MediaControlTimelineElement::DefaultEventHandler(Event* event) {
// Provide immediate feedback (without waiting for media to seek) to make it
// easier for user to seek to a precise time.
static_cast<MediaControlsImpl&>(GetMediaControls())
.UpdateCurrentTimeDisplay();
GetMediaControls().UpdateCurrentTimeDisplay();
}
bool MediaControlTimelineElement::KeepEventInNode(Event* event) {
......
......@@ -53,15 +53,12 @@ void MediaControlToggleClosedCaptionsButtonElement::DefaultEventHandler(
if (event->type() == EventTypeNames::click) {
if (MediaElement().textTracks()->length() == 1) {
// If only one track exists, toggle it on/off
if (MediaElement().textTracks()->HasShowingTracks()) {
static_cast<MediaControlsImpl&>(GetMediaControls())
.DisableShowingTextTracks();
} else {
static_cast<MediaControlsImpl&>(GetMediaControls())
.ShowTextTrackAtIndex(0);
}
if (MediaElement().textTracks()->HasShowingTracks())
GetMediaControls().DisableShowingTextTracks();
else
GetMediaControls().ShowTextTrackAtIndex(0);
} else {
static_cast<MediaControlsImpl&>(GetMediaControls()).ToggleTextTrackList();
GetMediaControls().ToggleTextTrackList();
}
UpdateDisplayType();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment