--- a/dom/html/HTMLAudioElement.cpp
+++ b/dom/html/HTMLAudioElement.cpp
@@ -64,17 +64,17 @@ HTMLAudioElement::Audio(const GlobalObje
RefPtr<HTMLAudioElement> audio = new HTMLAudioElement(nodeInfo);
audio->SetHTMLAttr(nsGkAtoms::preload, NS_LITERAL_STRING("auto"), aRv);
if (aRv.Failed()) {
return nullptr;
}
if (aSrc.WasPassed()) {
- aRv = audio->SetSrc(aSrc.Value());
+ audio->SetSrc(aSrc.Value(), aRv);
}
return audio.forget();
}
nsresult HTMLAudioElement::SetAcceptHeader(nsIHttpChannel* aChannel)
{
nsAutoCString value(
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -17,17 +17,16 @@
#include "mozilla/AsyncEventDispatcher.h"
#include "mozilla/dom/MediaEncryptedEvent.h"
#include "mozilla/EMEUtils.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/Sprintf.h"
#include "AutoplayPolicy.h"
#include "base/basictypes.h"
-#include "nsIDOMHTMLMediaElement.h"
#include "TimeRanges.h"
#include "nsGenericHTMLElement.h"
#include "nsAttrValueInlines.h"
#include "nsPresContext.h"
#include "nsIClassOfService.h"
#include "nsIPresShell.h"
#include "nsGkAtoms.h"
#include "nsSize.h"
@@ -969,18 +968,19 @@ private:
{
if (IsSuspended()) {
return;
}
SetSuspended(aSuspend);
if (aSuspend == nsISuspendedTypes::SUSPENDED_PAUSE ||
aSuspend == nsISuspendedTypes::SUSPENDED_PAUSE_DISPOSABLE) {
- nsresult rv = mOwner->Pause();
- if (NS_WARN_IF(NS_FAILED(rv))) {
+ IgnoredErrorResult rv;
+ mOwner->Pause(rv);
+ if (NS_WARN_IF(rv.Failed())) {
return;
}
}
NotifyAudioPlaybackChanged(
AudioChannelService::AudibleChangedReasons::ePauseStateChanged);
}
void
@@ -1465,19 +1465,16 @@ private:
}
// Media elememt's life cycle would be longer than error sink, so we use the
// raw pointer and this class would only be referenced by media element.
HTMLMediaElement* mOwner;
bool mSrcIsUnsupportedTypeMedia;
};
-NS_IMPL_ADDREF_INHERITED(HTMLMediaElement, nsGenericHTMLElement)
-NS_IMPL_RELEASE_INHERITED(HTMLMediaElement, nsGenericHTMLElement)
-
NS_IMPL_CYCLE_COLLECTION_CLASS(HTMLMediaElement)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLMediaElement, nsGenericHTMLElement)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMediaSource)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSrcMediaSource)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSrcStream)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSrcAttrStream)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSourcePointer)
@@ -1526,59 +1523,43 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_IN
NS_IMPL_CYCLE_COLLECTION_UNLINK(mMediaKeys)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mIncomingMediaKeys)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSelectedVideoStreamTrack)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mPendingPlayPromises)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSeekDOMPromise)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSetMediaKeysDOMPromise)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(HTMLMediaElement)
- NS_INTERFACE_MAP_ENTRY(nsIDOMHTMLMediaElement)
-NS_INTERFACE_MAP_END_INHERITING(nsGenericHTMLElement)
-
-// nsIDOMHTMLMediaElement
-NS_IMPL_URI_ATTR(HTMLMediaElement, Src, src)
-NS_IMPL_BOOL_ATTR(HTMLMediaElement, Controls, controls)
-NS_IMPL_BOOL_ATTR(HTMLMediaElement, Autoplay, autoplay)
-NS_IMPL_BOOL_ATTR(HTMLMediaElement, Loop, loop)
-NS_IMPL_BOOL_ATTR(HTMLMediaElement, DefaultMuted, muted)
-NS_IMPL_ENUM_ATTR_DEFAULT_VALUE(HTMLMediaElement, Preload, preload, nullptr)
+NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED_0(HTMLMediaElement, nsGenericHTMLElement)
void
HTMLMediaElement::ContentRemoved(nsIDocument* aDocument,
nsIContent* aContainer,
nsIContent* aChild,
nsIContent* aPreviousSibling)
{
if (aChild == mSourcePointer) {
mSourcePointer = aPreviousSibling;
}
}
-NS_IMETHODIMP_(bool)
-HTMLMediaElement::IsVideo()
-{
- return false;
-}
-
already_AddRefed<MediaSource>
HTMLMediaElement::GetMozMediaSourceObject() const
{
RefPtr<MediaSource> source = mMediaSource;
return source.forget();
}
void
HTMLMediaElement::GetMozDebugReaderData(nsAString& aString)
{
if (mDecoder && !mSrcStream) {
nsAutoCString result;
mDecoder->GetMozDebugReaderData(result);
- aString = NS_ConvertUTF8toUTF16(result);
+ CopyUTF8toUTF16(result, aString);
}
}
already_AddRefed<Promise>
HTMLMediaElement::MozRequestDebugInfo(ErrorResult& aRv)
{
RefPtr<Promise> promise = CreateDOMPromise(aRv);
if (NS_WARN_IF(aRv.Failed())) {
@@ -1719,34 +1700,22 @@ HTMLMediaElement::SetSrcObject(DOMMediaS
bool
HTMLMediaElement::Ended()
{
return (mDecoder && mDecoder->IsEnded()) ||
(mSrcStream && !mSrcStream->Active());
}
-NS_IMETHODIMP HTMLMediaElement::GetEnded(bool* aEnded)
-{
- *aEnded = Ended();
- return NS_OK;
-}
-
-NS_IMETHODIMP HTMLMediaElement::GetCurrentSrc(nsAString & aCurrentSrc)
+void
+HTMLMediaElement::GetCurrentSrc(nsAString & aCurrentSrc)
{
nsAutoCString src;
GetCurrentSpec(src);
- aCurrentSrc = NS_ConvertUTF8toUTF16(src);
- return NS_OK;
-}
-
-NS_IMETHODIMP HTMLMediaElement::GetNetworkState(uint16_t* aNetworkState)
-{
- *aNetworkState = NetworkState();
- return NS_OK;
+ CopyUTF8toUTF16(src, aCurrentSrc);
}
nsresult
HTMLMediaElement::OnChannelRedirect(nsIChannel* aChannel,
nsIChannel* aNewChannel,
uint32_t aFlags)
{
MOZ_ASSERT(mChannelLoader);
@@ -1975,32 +1944,31 @@ static bool HasSourceChildren(nsIContent
if (child->IsHTMLElement(nsGkAtoms::source))
{
return true;
}
}
return false;
}
-NS_IMETHODIMP HTMLMediaElement::Load()
+void
+HTMLMediaElement::Load()
{
LOG(LogLevel::Debug,
("%p Load() hasSrcAttrStream=%d hasSrcAttr=%d hasSourceChildren=%d "
"handlingInput=%d",
this, !!mSrcAttrStream, HasAttr(kNameSpaceID_None, nsGkAtoms::src),
HasSourceChildren(this), EventStateManager::IsHandlingUserInput()));
if (mIsRunningLoadMethod) {
- return NS_OK;
+ return;
}
mIsDoingExplicitLoad = true;
DoLoad();
-
- return NS_OK;
}
void HTMLMediaElement::DoLoad()
{
// Check if media is allowed for the docshell.
nsCOMPtr<nsIDocShell> docShell = OwnerDoc()->GetDocShell();
if (docShell && !docShell->GetAllowMedia()) {
LOG(LogLevel::Debug, ("%p Media not allowed", this));
@@ -2022,17 +1990,17 @@ void HTMLMediaElement::DoLoad()
if (HasAttr(kNameSpaceID_None, nsGkAtoms::autoplay)) {
mUseUrgentStartForChannel = true;
}
}
SetPlayedOrSeeked(false);
mIsRunningLoadMethod = true;
AbortExistingLoads();
- SetPlaybackRate(mDefaultPlaybackRate);
+ SetPlaybackRate(mDefaultPlaybackRate, IgnoreErrors());
QueueSelectResourceTask();
ResetState();
mIsRunningLoadMethod = false;
}
void HTMLMediaElement::ResetState()
{
// There might be a pending MediaDecoder::PlaybackPositionChanged() which
@@ -2652,41 +2620,28 @@ nsresult HTMLMediaElement::LoadWithChann
ChangeDelayLoadStatus(true);
rv = InitializeDecoderForChannel(aChannel, aListener);
if (NS_FAILED(rv)) {
ChangeDelayLoadStatus(false);
return rv;
}
- SetPlaybackRate(mDefaultPlaybackRate);
+ SetPlaybackRate(mDefaultPlaybackRate, IgnoreErrors());
DispatchAsyncEvent(NS_LITERAL_STRING("loadstart"));
return NS_OK;
}
-NS_IMETHODIMP HTMLMediaElement::GetReadyState(uint16_t* aReadyState)
-{
- *aReadyState = ReadyState();
-
- return NS_OK;
-}
-
bool
HTMLMediaElement::Seeking() const
{
return mDecoder && mDecoder->IsSeeking();
}
-NS_IMETHODIMP HTMLMediaElement::GetSeeking(bool* aSeeking)
-{
- *aSeeking = Seeking();
- return NS_OK;
-}
-
double
HTMLMediaElement::CurrentTime() const
{
if (MediaStream* stream = GetSrcMediaStream()) {
if (mSrcStreamPausedCurrentTime >= 0) {
return mSrcStreamPausedCurrentTime;
}
return stream->StreamTimeToSeconds(stream->GetCurrentTime());
@@ -2694,22 +2649,16 @@ HTMLMediaElement::CurrentTime() const
if (mDefaultPlaybackStartPosition == 0.0 && mDecoder) {
return mDecoder->GetCurrentTime();
}
return mDefaultPlaybackStartPosition;
}
-NS_IMETHODIMP HTMLMediaElement::GetCurrentTime(double* aCurrentTime)
-{
- *aCurrentTime = CurrentTime();
- return NS_OK;
-}
-
void
HTMLMediaElement::FastSeek(double aTime, ErrorResult& aRv)
{
LOG(LogLevel::Debug, ("Reporting telemetry VIDEO_FASTSEEK_USED"));
Telemetry::Accumulate(Telemetry::VIDEO_FASTSEEK_USED, 1);
RefPtr<Promise> tobeDropped = Seek(aTime, SeekTarget::PrevSyncPoint, aRv);
}
@@ -2919,72 +2868,39 @@ HTMLMediaElement::Seek(double aTime,
AddRemoveSelfReference();
// Keep the DOM promise.
mSeekDOMPromise = promise;
return promise.forget();
}
-NS_IMETHODIMP HTMLMediaElement::SetCurrentTime(double aCurrentTime)
-{
- // Detect for a NaN and invalid values.
- if (mozilla::IsNaN(aCurrentTime)) {
- LOG(LogLevel::Debug, ("%p SetCurrentTime(%f) failed: bad time", this, aCurrentTime));
- return NS_ERROR_FAILURE;
- }
-
- ErrorResult rv;
- SetCurrentTime(aCurrentTime, rv);
- return rv.StealNSResult();
-}
-
double
HTMLMediaElement::Duration() const
{
if (mSrcStream) {
return std::numeric_limits<double>::infinity();
}
if (mDecoder) {
return mDecoder->GetDuration();
}
return std::numeric_limits<double>::quiet_NaN();
}
-NS_IMETHODIMP HTMLMediaElement::GetDuration(double* aDuration)
-{
- *aDuration = Duration();
- return NS_OK;
-}
-
already_AddRefed<TimeRanges>
HTMLMediaElement::Seekable() const
{
media::TimeIntervals seekable =
mDecoder ? mDecoder->GetSeekable() : media::TimeIntervals();
RefPtr<TimeRanges> ranges = new TimeRanges(ToSupports(OwnerDoc()), seekable);
return ranges.forget();
}
-NS_IMETHODIMP HTMLMediaElement::GetSeekable(nsIDOMTimeRanges** aSeekable)
-{
- RefPtr<TimeRanges> ranges = Seekable();
- ranges.forget(aSeekable);
- return NS_OK;
-}
-
-NS_IMETHODIMP HTMLMediaElement::GetPaused(bool* aPaused)
-{
- *aPaused = Paused();
-
- return NS_OK;
-}
-
already_AddRefed<TimeRanges>
HTMLMediaElement::Played()
{
RefPtr<TimeRanges> ranges = new TimeRanges(ToSupports(OwnerDoc()));
uint32_t timeRangeCount = 0;
if (mPlayed) {
mPlayed->GetLength(&timeRangeCount);
@@ -3003,23 +2919,16 @@ HTMLMediaElement::Played()
ranges->Add(mCurrentPlayRangeStart, now);
}
}
ranges->Normalize();
return ranges.forget();
}
-NS_IMETHODIMP HTMLMediaElement::GetPlayed(nsIDOMTimeRanges** aPlayed)
-{
- RefPtr<TimeRanges> ranges = Played();
- ranges.forget(aPlayed);
- return NS_OK;
-}
-
void
HTMLMediaElement::Pause(ErrorResult& aRv)
{
if (mNetworkState == NETWORK_EMPTY) {
LOG(LogLevel::Debug, ("Loading due to Pause()"));
DoLoad();
} else if (mDecoder) {
mDecoder->Pause();
@@ -3037,29 +2946,16 @@ HTMLMediaElement::Pause(ErrorResult& aRv
if (!oldPaused) {
FireTimeUpdate(false);
DispatchAsyncEvent(NS_LITERAL_STRING("pause"));
AsyncRejectPendingPlayPromises(NS_ERROR_DOM_MEDIA_ABORT_ERR);
}
}
-NS_IMETHODIMP HTMLMediaElement::Pause()
-{
- ErrorResult rv;
- Pause(rv);
- return rv.StealNSResult();
-}
-
-NS_IMETHODIMP HTMLMediaElement::GetVolume(double* aVolume)
-{
- *aVolume = Volume();
- return NS_OK;
-}
-
void
HTMLMediaElement::SetVolume(double aVolume, ErrorResult& aRv)
{
if (aVolume < 0.0 || aVolume > 1.0) {
aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
return;
}
@@ -3069,23 +2965,16 @@ HTMLMediaElement::SetVolume(double aVolu
mVolume = aVolume;
// Here we want just to update the volume.
SetVolumeInternal();
DispatchAsyncEvent(NS_LITERAL_STRING("volumechange"));
}
-NS_IMETHODIMP HTMLMediaElement::SetVolume(double aVolume)
-{
- ErrorResult rv;
- SetVolume(aVolume, rv);
- return rv.StealNSResult();
-}
-
void
HTMLMediaElement::MozGetMetadata(JSContext* cx,
JS::MutableHandle<JSObject*> aRetval,
ErrorResult& aRv)
{
if (mReadyState < HAVE_METADATA) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
@@ -3093,93 +2982,76 @@ HTMLMediaElement::MozGetMetadata(JSConte
JS::Rooted<JSObject*> tags(cx, JS_NewPlainObject(cx));
if (!tags) {
aRv.Throw(NS_ERROR_FAILURE);
return;
}
if (mTags) {
for (auto iter = mTags->ConstIter(); !iter.Done(); iter.Next()) {
- nsString wideValue = NS_ConvertUTF8toUTF16(iter.UserData());
+ nsString wideValue;
+ CopyUTF8toUTF16(iter.UserData(), wideValue);
JS::Rooted<JSString*> string(cx,
JS_NewUCStringCopyZ(cx, wideValue.Data()));
if (!string || !JS_DefineProperty(cx, tags, iter.Key().Data(), string,
JSPROP_ENUMERATE)) {
NS_WARNING("couldn't create metadata object!");
aRv.Throw(NS_ERROR_FAILURE);
return;
}
}
}
aRetval.set(tags);
}
-NS_IMETHODIMP
-HTMLMediaElement::MozGetMetadata(JSContext* cx, JS::MutableHandle<JS::Value> aValue)
-{
- ErrorResult rv;
- JS::Rooted<JSObject*> obj(cx);
- MozGetMetadata(cx, &obj, rv);
- if (!rv.Failed()) {
- MOZ_ASSERT(obj);
- aValue.setObject(*obj);
- }
-
- return rv.StealNSResult();
-}
-
-NS_IMETHODIMP HTMLMediaElement::GetMuted(bool* aMuted)
-{
- *aMuted = Muted();
- return NS_OK;
-}
-
-void HTMLMediaElement::SetMutedInternal(uint32_t aMuted)
+void
+HTMLMediaElement::SetMutedInternal(uint32_t aMuted)
{
uint32_t oldMuted = mMuted;
mMuted = aMuted;
if (!!aMuted == !!oldMuted) {
return;
}
SetVolumeInternal();
}
-void HTMLMediaElement::SetVolumeInternal()
+void
+HTMLMediaElement::SetVolumeInternal()
{
float effectiveVolume = ComputedVolume();
if (mDecoder) {
mDecoder->SetVolume(effectiveVolume);
} else if (MediaStream* stream = GetSrcMediaStream()) {
if (mSrcStreamIsPlaying) {
stream->SetAudioOutputVolume(this, effectiveVolume);
}
}
NotifyAudioPlaybackChanged(
AudioChannelService::AudibleChangedReasons::eVolumeChanged);
}
-NS_IMETHODIMP HTMLMediaElement::SetMuted(bool aMuted)
+void
+HTMLMediaElement::SetMuted(bool aMuted)
{
if (aMuted == Muted()) {
- return NS_OK;
+ return;
}
if (aMuted) {
SetMutedInternal(mMuted | MUTED_BY_CONTENT);
} else {
SetMutedInternal(mMuted & ~MUTED_BY_CONTENT);
}
DispatchAsyncEvent(NS_LITERAL_STRING("volumechange"));
- return NS_OK;
}
class HTMLMediaElement::StreamCaptureTrackSource :
public MediaStreamTrackSource,
public MediaStreamTrackSource::Sink
{
public:
NS_DECL_ISUPPORTS_INHERITED
@@ -3762,22 +3634,16 @@ HTMLMediaElement::MozCaptureStreamUntilE
if (!stream) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
return stream.forget();
}
-NS_IMETHODIMP HTMLMediaElement::GetMozAudioCaptured(bool* aCaptured)
-{
- *aCaptured = MozAudioCaptured();
- return NS_OK;
-}
-
class MediaElementSetForURI : public nsURIHashKey {
public:
explicit MediaElementSetForURI(const nsIURI* aKey) : nsURIHashKey(aKey) {}
MediaElementSetForURI(const MediaElementSetForURI& toCopy)
: nsURIHashKey(toCopy), mElements(toCopy.mElements) {}
nsTArray<HTMLMediaElement*> mElements;
};
@@ -3956,16 +3822,17 @@ HTMLMediaElement::HTMLMediaElement(alrea
: nsGenericHTMLElement(aNodeInfo),
mMainThreadEventTarget(OwnerDoc()->EventTargetFor(TaskCategory::Other)),
mAbstractMainThread(OwnerDoc()->AbstractMainThreadFor(TaskCategory::Other)),
mSrcStreamTracksAvailable(false),
mSrcStreamPausedCurrentTime(-1),
mShutdownObserver(new ShutdownObserver),
mSourcePointer(nullptr),
mNetworkState(NETWORK_EMPTY),
+ mReadyState(HAVE_NOTHING),
mCurrentLoadID(0),
mLoadWaitStatus(NOT_WAITING),
mVolume(1.0),
mIsAudioTrackAudible(false),
mMuted(0),
mPreloadAction(PRELOAD_UNDEFINED),
mLastCurrentTime(0.0),
mFragmentStart(-1.0),
@@ -4840,17 +4707,17 @@ HTMLMediaElement::GetCanPlay(const nsASt
// TODO: Instead, missing `codecs` should be checked in each decoder's
// `IsSupportedType` call from `CanHandleCodecsType()`.
// See bug 1399023.
return CANPLAY_MAYBE;
}
return status;
}
-NS_IMETHODIMP
+void
HTMLMediaElement::CanPlayType(const nsAString& aType, nsAString& aResult)
{
DecoderDoctorDiagnostics diagnostics;
CanPlayStatus canPlay = GetCanPlay(aType, &diagnostics);
diagnostics.StoreFormatDiagnostics(
OwnerDoc(), aType, canPlay != CANPLAY_NO, __func__);
switch (canPlay) {
case CANPLAY_NO:
@@ -4865,18 +4732,16 @@ HTMLMediaElement::CanPlayType(const nsAS
default:
MOZ_ASSERT_UNREACHABLE("Unexpected case.");
break;
}
LOG(LogLevel::Debug, ("%p CanPlayType(%s) = \"%s\"", this,
NS_ConvertUTF16toUTF8(aType).get(),
NS_ConvertUTF16toUTF8(aResult).get()));
-
- return NS_OK;
}
void
HTMLMediaElement::AssertReadyStateIsNothing()
{
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
if (mReadyState != HAVE_NOTHING) {
char buf[1024];
@@ -6755,23 +6620,16 @@ already_AddRefed<TimeRanges>
HTMLMediaElement::Buffered() const
{
media::TimeIntervals buffered =
mDecoder ? mDecoder->GetBuffered() : media::TimeIntervals();
RefPtr<TimeRanges> ranges = new TimeRanges(ToSupports(OwnerDoc()), buffered);
return ranges.forget();
}
-nsresult HTMLMediaElement::GetBuffered(nsIDOMTimeRanges** aBuffered)
-{
- RefPtr<TimeRanges> ranges = Buffered();
- ranges.forget(aBuffered);
- return NS_OK;
-}
-
void HTMLMediaElement::SetRequestHeaders(nsIHttpChannel* aChannel)
{
// Send Accept header for video and audio types only (Bug 489071)
SetAcceptHeader(aChannel);
// Apache doesn't send Content-Length when gzip transfer encoding is used,
// which prevents us from estimating the video length (if explicit Content-Duration
// and a length spec in the container are not present either) and from seeking.
@@ -6857,69 +6715,44 @@ HTMLMediaElement::MozFragmentEnd()
{
double duration = Duration();
// If there is no end fragment, or the fragment end is greater than the
// duration, return the duration.
return (mFragmentEnd < 0.0 || mFragmentEnd > duration) ? duration : mFragmentEnd;
}
-NS_IMETHODIMP HTMLMediaElement::GetMozFragmentEnd(double* aTime)
-{
- *aTime = MozFragmentEnd();
- return NS_OK;
-}
-
static double ClampPlaybackRate(double aPlaybackRate)
{
MOZ_ASSERT(aPlaybackRate >= 0.0);
if (aPlaybackRate == 0.0) {
return aPlaybackRate;
}
if (aPlaybackRate < MIN_PLAYBACKRATE) {
return MIN_PLAYBACKRATE;
}
if (aPlaybackRate > MAX_PLAYBACKRATE) {
return MAX_PLAYBACKRATE;
}
return aPlaybackRate;
}
-NS_IMETHODIMP HTMLMediaElement::GetDefaultPlaybackRate(double* aDefaultPlaybackRate)
-{
- *aDefaultPlaybackRate = DefaultPlaybackRate();
- return NS_OK;
-}
-
void
HTMLMediaElement::SetDefaultPlaybackRate(double aDefaultPlaybackRate, ErrorResult& aRv)
{
if (aDefaultPlaybackRate < 0) {
aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
return;
}
mDefaultPlaybackRate = ClampPlaybackRate(aDefaultPlaybackRate);
DispatchAsyncEvent(NS_LITERAL_STRING("ratechange"));
}
-NS_IMETHODIMP HTMLMediaElement::SetDefaultPlaybackRate(double aDefaultPlaybackRate)
-{
- ErrorResult rv;
- SetDefaultPlaybackRate(aDefaultPlaybackRate, rv);
- return rv.StealNSResult();
-}
-
-NS_IMETHODIMP HTMLMediaElement::GetPlaybackRate(double* aPlaybackRate)
-{
- *aPlaybackRate = PlaybackRate();
- return NS_OK;
-}
-
void
HTMLMediaElement::SetPlaybackRate(double aPlaybackRate, ErrorResult& aRv)
{
// Changing the playback rate of a media that has more than two channels is
// not supported.
if (aPlaybackRate < 0) {
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
return;
@@ -6940,39 +6773,27 @@ HTMLMediaElement::SetPlaybackRate(double
}
if (mDecoder) {
mDecoder->SetPlaybackRate(ClampPlaybackRate(mPlaybackRate));
}
DispatchAsyncEvent(NS_LITERAL_STRING("ratechange"));
}
-NS_IMETHODIMP HTMLMediaElement::SetPlaybackRate(double aPlaybackRate)
-{
- ErrorResult rv;
- SetPlaybackRate(aPlaybackRate, rv);
- return rv.StealNSResult();
-}
-
-NS_IMETHODIMP HTMLMediaElement::GetMozPreservesPitch(bool* aPreservesPitch)
-{
- *aPreservesPitch = MozPreservesPitch();
- return NS_OK;
-}
-
-NS_IMETHODIMP HTMLMediaElement::SetMozPreservesPitch(bool aPreservesPitch)
+void
+HTMLMediaElement::SetMozPreservesPitch(bool aPreservesPitch)
{
mPreservesPitch = aPreservesPitch;
if (mDecoder) {
mDecoder->SetPreservesPitch(mPreservesPitch);
}
- return NS_OK;
-}
-
-ImageContainer* HTMLMediaElement::GetImageContainer()
+}
+
+ImageContainer*
+HTMLMediaElement::GetImageContainer()
{
VideoFrameContainer* container = GetVideoFrameContainer();
return container ? container->GetImageContainer() : nullptr;
}
void
HTMLMediaElement::UpdateAudioChannelPlayingState(bool aForcePlaying)
{
--- a/dom/html/HTMLMediaElement.h
+++ b/dom/html/HTMLMediaElement.h
@@ -2,17 +2,16 @@
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_HTMLMediaElement_h
#define mozilla_dom_HTMLMediaElement_h
#include "nsAutoPtr.h"
-#include "nsIDOMHTMLMediaElement.h"
#include "nsGenericHTMLElement.h"
#include "MediaEventSource.h"
#include "SeekTarget.h"
#include "MediaDecoderOwner.h"
#include "MediaPromiseDefs.h"
#include "nsCycleCollectionParticipant.h"
#include "nsIObserver.h"
#include "mozilla/CORSMode.h"
@@ -96,17 +95,16 @@ enum class StreamCaptureType : uint8_t
enum class StreamCaptureBehavior : uint8_t
{
CONTINUE_WHEN_ENDED,
FINISH_WHEN_ENDED
};
class HTMLMediaElement : public nsGenericHTMLElement,
- public nsIDOMHTMLMediaElement,
public MediaDecoderOwner,
public PrincipalChangeObserver<DOMMediaStream>,
public SupportsWeakPtr<HTMLMediaElement>,
public nsStubMutationObserver
{
public:
typedef mozilla::TimeStamp TimeStamp;
typedef mozilla::layers::ImageContainer ImageContainer;
@@ -132,19 +130,16 @@ public:
* a channel that we've already started loading. The src attribute and
* <source> children are ignored.
* @param aChannel the channel to use
* @param aListener returns a stream listener that should receive
* notifications for the stream
*/
nsresult LoadWithChannel(nsIChannel *aChannel, nsIStreamListener **aListener);
- // nsIDOMHTMLMediaElement
- NS_DECL_NSIDOMHTMLMEDIAELEMENT
-
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLMediaElement,
nsGenericHTMLElement)
NS_IMPL_FROMCONTENT_HELPER(HTMLMediaElement,
IsAnyOfHTMLElements(nsGkAtoms::video,
nsGkAtoms::audio))
@@ -440,22 +435,30 @@ public:
* cycle collection unlinking!
*/
MediaStream* GetSrcMediaStream() const;
// WebIDL
MediaError* GetError() const;
- void SetSrc(const nsAString& aSrc, nsIPrincipal* aTriggeringPrincipal, ErrorResult& aRv)
+ void GetSrc(nsAString& aSrc)
+ {
+ GetURIAttr(nsGkAtoms::src, nullptr, aSrc);
+ }
+ void SetSrc(const nsAString& aSrc, ErrorResult& aError)
{
- SetHTMLAttr(nsGkAtoms::src, aSrc, aTriggeringPrincipal, aRv);
+ SetHTMLAttr(nsGkAtoms::src, aSrc, aError);
+ }
+ void SetSrc(const nsAString& aSrc, nsIPrincipal* aTriggeringPrincipal, ErrorResult& aError)
+ {
+ SetHTMLAttr(nsGkAtoms::src, aSrc, aTriggeringPrincipal, aError);
}
- // XPCOM GetCurrentSrc() is OK
+ void GetCurrentSrc(nsAString& aCurrentSrc);
void GetCrossOrigin(nsAString& aResult)
{
// Null for both missing and invalid defaults is ok, since we
// always parse to an enum value, so we don't need an invalid
// default, and we _want_ the missing default to be null.
GetEnumAttr(nsGkAtoms::crossorigin, nullptr, aResult);
}
@@ -473,50 +476,62 @@ public:
// Called by media decoder when the audible state changed or when input is
// a media stream.
virtual void SetAudibleState(bool aAudible) final override;
// Notify agent when the MediaElement changes its audible state.
void NotifyAudioPlaybackChanged(AudibleChangedReasons aReason);
- // XPCOM GetPreload() is OK
+ void GetPreload(nsAString& aValue)
+ {
+ GetEnumAttr(nsGkAtoms::preload, nullptr, aValue);
+ }
void SetPreload(const nsAString& aValue, ErrorResult& aRv)
{
SetHTMLAttr(nsGkAtoms::preload, aValue, aRv);
}
already_AddRefed<TimeRanges> Buffered() const;
- // XPCOM Load() is OK
+ void Load();
- // XPCOM CanPlayType() is OK
+ void CanPlayType(const nsAString& aType, nsAString& aResult);
uint16_t ReadyState() const
{
return mReadyState;
}
bool Seeking() const;
double CurrentTime() const;
void SetCurrentTime(double aCurrentTime, ErrorResult& aRv);
+ void SetCurrentTime(double aCurrentTime)
+ {
+ SetCurrentTime(aCurrentTime, IgnoreErrors());
+ }
void FastSeek(double aTime, ErrorResult& aRv);
already_AddRefed<Promise> SeekToNextFrame(ErrorResult& aRv);
double Duration() const;
bool HasAudio() const
{
return mMediaInfo.HasAudio();
}
+ virtual bool IsVideo() const
+ {
+ return false;
+ }
+
bool HasVideo() const
{
return mMediaInfo.HasVideo();
}
bool IsEncrypted() const
{
return mIsEncrypted;
@@ -565,16 +580,20 @@ public:
void SetLoop(bool aValue, ErrorResult& aRv)
{
SetHTMLBoolAttr(nsGkAtoms::loop, aValue, aRv);
}
already_AddRefed<Promise> Play(ErrorResult& aRv);
void Pause(ErrorResult& aRv);
+ void Pause()
+ {
+ Pause(IgnoreErrors());
+ }
bool Controls() const
{
return GetBoolAttr(nsGkAtoms::controls);
}
void SetControls(bool aValue, ErrorResult& aRv)
{
@@ -587,18 +606,17 @@ public:
}
void SetVolume(double aVolume, ErrorResult& aRv);
bool Muted() const
{
return mMuted & MUTED_BY_CONTENT;
}
-
- // XPCOM SetMuted() is OK
+ void SetMuted(bool aMuted);
bool DefaultMuted() const
{
return GetBoolAttr(nsGkAtoms::muted);
}
void SetDefaultMuted(bool aMuted, ErrorResult& aRv)
{
@@ -660,18 +678,17 @@ public:
already_AddRefed<DOMMediaStream> GetSrcObject() const;
void SetSrcObject(DOMMediaStream& aValue);
void SetSrcObject(DOMMediaStream* aValue);
bool MozPreservesPitch() const
{
return mPreservesPitch;
}
-
- // XPCOM MozPreservesPitch() is OK
+ void SetMozPreservesPitch(bool aPreservesPitch);
MediaKeys* GetMediaKeys() const;
already_AddRefed<Promise> SetMediaKeys(MediaKeys* mediaKeys,
ErrorResult& aRv);
mozilla::dom::EventHandlerNonNull* GetOnencrypted();
void SetOnencrypted(mozilla::dom::EventHandlerNonNull* aCallback);
@@ -755,16 +772,19 @@ public:
// A method to check whether we are currently playing.
bool IsCurrentlyPlaying() const;
// Returns true if the media element is being destroyed. Used in
// dormancy checks to prevent dormant processing for an element
// that will soon be gone.
bool IsBeingDestroyed();
+ void OnVisibilityChange(Visibility aNewVisibility);
+
+
// These are used for testing only
float ComputedVolume() const;
bool ComputedMuted() const;
nsSuspendedTypes ComputedSuspended() const;
void SetMediaInfo(const MediaInfo& aInfo);
virtual AbstractThread* AbstractMainThread() const final override;
@@ -1183,17 +1203,17 @@ protected:
/**
* Dispatches an error event to a child source element.
*/
void DispatchAsyncSourceError(nsIContent* aSourceElement);
/**
* Resets the media element for an error condition as per aErrorCode.
- * aErrorCode must be one of nsIDOMHTMLMediaError codes.
+ * aErrorCode must be one of WebIDL HTMLMediaElement error codes.
*/
void Error(uint16_t aErrorCode, const nsACString& aErrorDetails = nsCString());
/**
* Returns the URL spec of the currentSrc.
**/
void GetCurrentSpec(nsCString& aString);
@@ -1224,19 +1244,17 @@ protected:
virtual HTMLMediaElement* GetMediaElement() final override
{
return this;
}
// Return true if decoding should be paused
virtual bool GetPaused() final override
{
- bool isPaused = false;
- GetPaused(&isPaused);
- return isPaused;
+ return Paused();
}
/**
* Video has been playing while hidden and, if feature was enabled, would
* trigger suspending decoder.
* Used to track hidden-video-decode-suspend telemetry.
*/
static void VideoDecodeSuspendTimerCallback(nsITimer* aTimer, void* aClosure);
@@ -1434,17 +1452,17 @@ protected:
// Contains names of events that have been raised while in the bfcache.
// These events get re-dispatched when the bfcache is exited.
nsTArray<nsString> mPendingEvents;
// Media loading flags. See:
// http://www.whatwg.org/specs/web-apps/current-work/#video)
nsMediaNetworkState mNetworkState;
- nsMediaReadyState mReadyState = HTMLMediaElementBinding::HAVE_NOTHING;
+ nsMediaReadyState mReadyState;
enum LoadAlgorithmState {
// No load algorithm instance is waiting for a source to be added to the
// media in order to continue loading.
NOT_WAITING,
// We've run the load algorithm, and we tried all source children of the
// media element, and failed to load any successfully. We're waiting for
// another source element to be added to the media element, and will try
--- a/dom/html/HTMLTrackElement.cpp
+++ b/dom/html/HTMLTrackElement.cpp
@@ -21,17 +21,16 @@
#include "nsGkAtoms.h"
#include "nsIAsyncVerifyRedirectCallback.h"
#include "nsICachingChannel.h"
#include "nsIChannelEventSink.h"
#include "nsIContentPolicy.h"
#include "nsIContentSecurityPolicy.h"
#include "nsIDocument.h"
#include "nsIDOMEventTarget.h"
-#include "nsIDOMHTMLMediaElement.h"
#include "nsIHttpChannel.h"
#include "nsIInterfaceRequestor.h"
#include "nsILoadGroup.h"
#include "nsIObserver.h"
#include "nsIStreamListener.h"
#include "nsISupportsImpl.h"
#include "nsISupportsPrimitives.h"
#include "nsMappedAttributes.h"
--- a/dom/html/HTMLVideoElement.h
+++ b/dom/html/HTMLVideoElement.h
@@ -26,17 +26,17 @@ public:
typedef mozilla::dom::NodeInfo NodeInfo;
explicit HTMLVideoElement(already_AddRefed<NodeInfo>& aNodeInfo);
NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLVideoElement, video)
using HTMLMediaElement::GetPaused;
- NS_IMETHOD_(bool) IsVideo() override {
+ virtual bool IsVideo() const override {
return true;
}
virtual bool ParseAttribute(int32_t aNamespaceID,
nsAtom* aAttribute,
const nsAString& aValue,
nsIPrincipal* aMaybeScriptedPrincipal,
nsAttrValue& aResult) override;
--- a/dom/html/VideoDocument.cpp
+++ b/dom/html/VideoDocument.cpp
@@ -110,18 +110,18 @@ VideoDocument::CreateSyntheticVideoDocum
kNameSpaceID_XHTML,
nsINode::ELEMENT_NODE);
RefPtr<HTMLMediaElement> element =
static_cast<HTMLMediaElement*>(NS_NewHTMLVideoElement(nodeInfo.forget(),
NOT_FROM_PARSER));
if (!element)
return NS_ERROR_OUT_OF_MEMORY;
- element->SetAutoplay(true);
- element->SetControls(true);
+ element->SetAutoplay(true, IgnoreErrors());
+ element->SetControls(true, IgnoreErrors());
element->LoadWithChannel(aChannel, aListener);
UpdateTitle(aChannel);
if (nsContentUtils::IsChildOfSameType(this)) {
// Video documents that aren't toplevel should fill their frames and
// not have margins
element->SetAttr(kNameSpaceID_None, nsGkAtoms::style,
NS_LITERAL_STRING("position:absolute; top:0; left:0; width:100%; height:100%"),
--- a/layout/generic/nsVideoFrame.cpp
+++ b/layout/generic/nsVideoFrame.cpp
@@ -804,38 +804,38 @@ nsVideoFrame::AttributeChanged(int32_t a
aModType);
}
void
nsVideoFrame::OnVisibilityChange(Visibility aNewVisibility,
const Maybe<OnNonvisible>& aNonvisibleAction)
{
if (HasVideoElement()) {
- static_cast<HTMLMediaElement*>(mContent)->OnVisibilityChange(aNewVisibility);
+ static_cast<HTMLMediaElement*>(GetContent())->OnVisibilityChange(aNewVisibility);
}
nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(mPosterImage);
if (imageLoader) {
imageLoader->OnVisibilityChange(aNewVisibility,
aNonvisibleAction);
}
nsContainerFrame::OnVisibilityChange(aNewVisibility, aNonvisibleAction);
}
bool nsVideoFrame::HasVideoElement() {
- return static_cast<HTMLMediaElement*>(mContent)->IsVideo();
+ return static_cast<HTMLMediaElement*>(GetContent())->IsVideo();
}
bool nsVideoFrame::HasVideoData()
{
if (!HasVideoElement())
return false;
HTMLVideoElement* element = static_cast<HTMLVideoElement*>(GetContent());
nsIntSize size(0, 0);
element->GetVideoSize(&size);
return size != nsIntSize(0,0);
}
void nsVideoFrame::UpdateTextTrack()
{
- static_cast<HTMLMediaElement*>(mContent)->NotifyCueDisplayStatesChanged();
+ static_cast<HTMLMediaElement*>(GetContent())->NotifyCueDisplayStatesChanged();
}