mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 840559 - Convert MediaError to WebIDL. r=smaug
This commit is contained in:
parent
9760ea465e
commit
c614e41e70
@ -6,33 +6,45 @@
|
||||
|
||||
#include "mozilla/dom/MediaError.h"
|
||||
#include "nsDOMClassInfoID.h"
|
||||
#include "mozilla/dom/MediaErrorBinding.h"
|
||||
|
||||
DOMCI_DATA(MediaError, mozilla::dom::MediaError)
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
NS_IMPL_ADDREF(MediaError)
|
||||
NS_IMPL_RELEASE(MediaError)
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(MediaError, mParent)
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(MediaError)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(MediaError)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(MediaError)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MediaError)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMMediaError)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMMediaError)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MediaError)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
MediaError::MediaError(uint16_t aCode)
|
||||
: mCode(aCode)
|
||||
MediaError::MediaError(nsHTMLMediaElement* aParent, uint16_t aCode)
|
||||
: mParent(aParent)
|
||||
, mCode(aCode)
|
||||
{
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MediaError::GetCode(uint16_t* aCode)
|
||||
{
|
||||
if (aCode)
|
||||
*aCode = mCode;
|
||||
*aCode = Code();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
JSObject*
|
||||
MediaError::WrapObject(JSContext* aCx, JSObject* aScope,
|
||||
bool* aTriedToWrap)
|
||||
{
|
||||
return MediaErrorBinding::Wrap(aCx, aScope, this, aTriedToWrap);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
@ -8,26 +8,44 @@
|
||||
#define mozilla_dom_MediaError_h
|
||||
|
||||
#include "nsIDOMMediaError.h"
|
||||
#include "nsHTMLMediaElement.h"
|
||||
#include "nsWrapperCache.h"
|
||||
#include "nsISupports.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class MediaError MOZ_FINAL : public nsIDOMMediaError
|
||||
class MediaError MOZ_FINAL : public nsIDOMMediaError,
|
||||
public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
MediaError(uint16_t aCode);
|
||||
MediaError(nsHTMLMediaElement* aParent, uint16_t aCode);
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(MediaError)
|
||||
|
||||
// nsIDOMMediaError
|
||||
NS_DECL_NSIDOMMEDIAERROR
|
||||
|
||||
nsHTMLMediaElement* GetParentObject() const
|
||||
{
|
||||
return mParent;
|
||||
}
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope, bool* aTriedToWrap);
|
||||
|
||||
uint16_t Code() const
|
||||
{
|
||||
return mCode;
|
||||
}
|
||||
|
||||
private:
|
||||
nsRefPtr<nsHTMLMediaElement> mParent;
|
||||
|
||||
// Error code
|
||||
uint16_t mCode;
|
||||
const uint16_t mCode;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
@ -436,6 +436,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsHTMLMediaElement, nsGenericH
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSourcePointer)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mLoadBlockedDoc)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSourceLoadCandidate)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mError)
|
||||
for (uint32_t i = 0; i < tmp->mOutputStreams.Length(); ++i) {
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOutputStreams[i].mStream);
|
||||
}
|
||||
@ -451,6 +452,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsHTMLMediaElement, nsGenericHTM
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSourcePointer)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mLoadBlockedDoc)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSourceLoadCandidate)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mError)
|
||||
for (uint32_t i = 0; i < tmp->mOutputStreams.Length(); ++i) {
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mOutputStreams[i].mStream);
|
||||
}
|
||||
@ -660,7 +662,7 @@ void nsHTMLMediaElement::NoSupportedMediaSourceError()
|
||||
{
|
||||
NS_ASSERTION(mDelayingLoadEvent, "Load event not delayed during source selection?");
|
||||
|
||||
mError = new MediaError(nsIDOMMediaError::MEDIA_ERR_SRC_NOT_SUPPORTED);
|
||||
mError = new MediaError(this, nsIDOMMediaError::MEDIA_ERR_SRC_NOT_SUPPORTED);
|
||||
mNetworkState = nsIDOMHTMLMediaElement::NETWORK_NO_SOURCE;
|
||||
DispatchAsyncEvent(NS_LITERAL_STRING("error"));
|
||||
// This clears mDelayingLoadEvent, so AddRemoveSelfReference will be called
|
||||
@ -2740,7 +2742,7 @@ void nsHTMLMediaElement::Error(uint16_t aErrorCode)
|
||||
aErrorCode == nsIDOMMediaError::MEDIA_ERR_NETWORK ||
|
||||
aErrorCode == nsIDOMMediaError::MEDIA_ERR_ABORTED,
|
||||
"Only use nsIDOMMediaError codes!");
|
||||
mError = new MediaError(aErrorCode);
|
||||
mError = new MediaError(this, aErrorCode);
|
||||
mBegun = false;
|
||||
DispatchAsyncEvent(NS_LITERAL_STRING("error"));
|
||||
if (mReadyState == nsIDOMHTMLMediaElement::HAVE_NOTHING) {
|
||||
|
@ -601,6 +601,10 @@ DOMInterfaces = {
|
||||
'register': False
|
||||
},
|
||||
|
||||
'MediaError': {
|
||||
'hasInstanceInterface': 'nsIDOMMediaError',
|
||||
},
|
||||
|
||||
'MediaStream': [{
|
||||
'nativeType': 'nsIDOMMediaStream',
|
||||
},
|
||||
|
22
dom/webidl/MediaError.webidl
Normal file
22
dom/webidl/MediaError.webidl
Normal file
@ -0,0 +1,22 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/.
|
||||
*
|
||||
* The origin of this IDL file is
|
||||
* http://www.whatwg.org/html/#mediaerror
|
||||
*
|
||||
* © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
|
||||
* Opera Software ASA. You are granted a license to use, reproduce
|
||||
* and create derivative works of this document.
|
||||
*/
|
||||
|
||||
interface MediaError {
|
||||
const unsigned short MEDIA_ERR_ABORTED = 1;
|
||||
const unsigned short MEDIA_ERR_NETWORK = 2;
|
||||
const unsigned short MEDIA_ERR_DECODE = 3;
|
||||
const unsigned short MEDIA_ERR_SRC_NOT_SUPPORTED = 4;
|
||||
|
||||
[Constant]
|
||||
readonly attribute unsigned short code;
|
||||
};
|
@ -223,6 +223,7 @@ endif
|
||||
ifdef MOZ_MEDIA
|
||||
webidl_files += \
|
||||
HTMLSourceElement.webidl \
|
||||
MediaError.webidl \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user