Bug 903772: Part 3 - Refactor GlobalObject. r=peterv

This commit is contained in:
Kyle Huey 2013-08-22 22:17:08 -07:00
parent 822635ee88
commit de0ee30e74
75 changed files with 221 additions and 216 deletions

View File

@ -99,9 +99,9 @@ class Element;
struct ElementRegistrationOptions;
class EventTarget;
class FrameRequestCallback;
class GlobalObject;
class HTMLBodyElement;
class Link;
class GlobalObject;
class NodeFilter;
class NodeIterator;
class ProcessingInstruction;
@ -150,6 +150,7 @@ NS_GetContentList(nsINode* aRootNode,
// Gecko.
class nsIDocument : public nsINode
{
typedef mozilla::dom::GlobalObject GlobalObject;
public:
typedef mozilla::dom::Element Element;
@ -1924,7 +1925,7 @@ public:
return GetScopeObject();
}
static already_AddRefed<nsIDocument>
Constructor(const mozilla::dom::GlobalObject& aGlobal,
Constructor(const GlobalObject& aGlobal,
mozilla::ErrorResult& rv);
virtual mozilla::dom::DOMImplementation*
GetImplementation(mozilla::ErrorResult& rv) = 0;

View File

@ -60,10 +60,10 @@ Comment::List(FILE* out, int32_t aIndent) const
#endif
/* static */ already_AddRefed<Comment>
Comment::Constructor(const GlobalObject& aGlobal, const nsAString& aData,
ErrorResult& aRv)
Comment::Constructor(const GlobalObject& aGlobal,
const nsAString& aData, ErrorResult& aRv)
{
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.Get());
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports());
if (!window || !window->GetDoc()) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;

View File

@ -122,9 +122,10 @@ DocumentFragment::DumpContent(FILE* out, int32_t aIndent,
#endif
/* static */ already_AddRefed<DocumentFragment>
DocumentFragment::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv)
DocumentFragment::Constructor(const GlobalObject& aGlobal,
ErrorResult& aRv)
{
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.Get());
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports());
if (!window || !window->GetDoc()) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;

View File

@ -285,12 +285,13 @@ EventSource::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
}
/* static */ already_AddRefed<EventSource>
EventSource::Constructor(const GlobalObject& aGlobal, const nsAString& aURL,
EventSource::Constructor(const GlobalObject& aGlobal,
const nsAString& aURL,
const EventSourceInit& aEventSourceInitDict,
ErrorResult& aRv)
{
nsRefPtr<EventSource> eventSource = new EventSource();
aRv = eventSource->Init(aGlobal.Get(), aURL,
aRv = eventSource->Init(aGlobal.GetAsSupports(), aURL,
aEventSourceInitDict.mWithCredentials);
return eventSource.forget();
}

View File

@ -21,10 +21,10 @@ Text::SplitText(uint32_t aOffset, ErrorResult& rv)
}
/* static */ already_AddRefed<Text>
Text::Constructor(const GlobalObject& aGlobal, const nsAString& aData,
ErrorResult& aRv)
Text::Constructor(const GlobalObject& aGlobal,
const nsAString& aData, ErrorResult& aRv)
{
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.Get());
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports());
if (!window || !window->GetDoc()) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;

View File

@ -29,8 +29,8 @@ public:
}
static already_AddRefed<Text>
Constructor(const GlobalObject& aGlobal, const nsAString& aData,
ErrorResult& aRv);
Constructor(const GlobalObject& aGlobal,
const nsAString& aData, ErrorResult& aRv);
};
} // namespace dom

View File

@ -521,7 +521,7 @@ WebSocket::Constructor(const GlobalObject& aGlobal,
}
nsCOMPtr<nsIScriptObjectPrincipal> scriptPrincipal =
do_QueryInterface(aGlobal.Get());
do_QueryInterface(aGlobal.GetAsSupports());
if (!scriptPrincipal) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
@ -533,13 +533,13 @@ WebSocket::Constructor(const GlobalObject& aGlobal,
return nullptr;
}
nsCOMPtr<nsIScriptGlobalObject> sgo = do_QueryInterface(aGlobal.Get());
nsCOMPtr<nsIScriptGlobalObject> sgo = do_QueryInterface(aGlobal.GetAsSupports());
if (!sgo) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
nsCOMPtr<nsPIDOMWindow> ownerWindow = do_QueryInterface(aGlobal.Get());
nsCOMPtr<nsPIDOMWindow> ownerWindow = do_QueryInterface(aGlobal.GetAsSupports());
if (!ownerWindow) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;

View File

@ -147,7 +147,7 @@ nsDOMFileReader::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv)
{
nsRefPtr<nsDOMFileReader> fileReader = new nsDOMFileReader();
nsCOMPtr<nsPIDOMWindow> owner = do_QueryInterface(aGlobal.Get());
nsCOMPtr<nsPIDOMWindow> owner = do_QueryInterface(aGlobal.GetAsSupports());
if (!owner) {
NS_WARNING("Unexpected nsIJSNativeInitializer owner");
aRv.Throw(NS_ERROR_FAILURE);

View File

@ -34,6 +34,7 @@ class nsDOMFileReader : public mozilla::dom::FileIOObject,
public nsSupportsWeakReference
{
typedef mozilla::ErrorResult ErrorResult;
typedef mozilla::dom::GlobalObject GlobalObject;
public:
nsDOMFileReader();
virtual ~nsDOMFileReader();
@ -65,7 +66,7 @@ public:
// WebIDL
static already_AddRefed<nsDOMFileReader>
Constructor(const mozilla::dom::GlobalObject& aGlobal, ErrorResult& aRv);
Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
void ReadAsArrayBuffer(JSContext* aCx, nsIDOMBlob* aBlob, ErrorResult& aRv)
{
MOZ_ASSERT(aBlob);

View File

@ -531,7 +531,7 @@ nsDOMMutationObserver::Constructor(const mozilla::dom::GlobalObject& aGlobal,
mozilla::dom::MutationCallback& aCb,
mozilla::ErrorResult& aRv)
{
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.Get());
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports());
if (!window) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;

View File

@ -361,16 +361,16 @@ nsDOMParser::Init(nsIPrincipal* principal, nsIURI* documentURI,
}
/*static */already_AddRefed<nsDOMParser>
nsDOMParser::Constructor(const GlobalObject& aOwner, nsIPrincipal* aPrincipal,
nsIURI* aDocumentURI, nsIURI* aBaseURI,
ErrorResult& rv)
nsDOMParser::Constructor(const GlobalObject& aOwner,
nsIPrincipal* aPrincipal, nsIURI* aDocumentURI,
nsIURI* aBaseURI, ErrorResult& rv)
{
if (!nsContentUtils::IsCallerChrome()) {
rv.Throw(NS_ERROR_DOM_SECURITY_ERR);
return nullptr;
}
nsRefPtr<nsDOMParser> domParser = new nsDOMParser(aOwner.Get());
rv = domParser->InitInternal(aOwner.Get(), aPrincipal, aDocumentURI,
nsRefPtr<nsDOMParser> domParser = new nsDOMParser(aOwner.GetAsSupports());
rv = domParser->InitInternal(aOwner.GetAsSupports(), aPrincipal, aDocumentURI,
aBaseURI);
if (rv.Failed()) {
return nullptr;
@ -379,7 +379,8 @@ nsDOMParser::Constructor(const GlobalObject& aOwner, nsIPrincipal* aPrincipal,
}
/*static */already_AddRefed<nsDOMParser>
nsDOMParser::Constructor(const GlobalObject& aOwner, ErrorResult& rv)
nsDOMParser::Constructor(const GlobalObject& aOwner,
ErrorResult& rv)
{
nsCOMPtr<nsIPrincipal> prin;
nsCOMPtr<nsIURI> documentURI;
@ -402,8 +403,8 @@ nsDOMParser::Constructor(const GlobalObject& aOwner, ErrorResult& rv)
return nullptr;
}
nsRefPtr<nsDOMParser> domParser = new nsDOMParser(aOwner.Get());
rv = domParser->InitInternal(aOwner.Get(), prin, documentURI, baseURI);
nsRefPtr<nsDOMParser> domParser = new nsDOMParser(aOwner.GetAsSupports());
rv = domParser->InitInternal(aOwner.GetAsSupports(), prin, documentURI, baseURI);
if (rv.Failed()) {
return nullptr;
}

View File

@ -21,6 +21,7 @@ class nsDOMParser MOZ_FINAL : public nsIDOMParser,
public nsSupportsWeakReference,
public nsWrapperCache
{
typedef mozilla::dom::GlobalObject GlobalObject;
public:
nsDOMParser();
virtual ~nsDOMParser();
@ -34,11 +35,11 @@ public:
// WebIDL API
static already_AddRefed<nsDOMParser>
Constructor(const mozilla::dom::GlobalObject& aOwner,
Constructor(const GlobalObject& aOwner,
mozilla::ErrorResult& rv);
static already_AddRefed<nsDOMParser>
Constructor(const mozilla::dom::GlobalObject& aOwner,
Constructor(const GlobalObject& aOwner,
nsIPrincipal* aPrincipal, nsIURI* aDocumentURI, nsIURI* aBaseURI,
mozilla::ErrorResult& rv);

View File

@ -32,7 +32,7 @@ public:
Constructor(const mozilla::dom::GlobalObject& aOwner,
mozilla::ErrorResult& rv)
{
nsRefPtr<nsDOMSerializer> domSerializer = new nsDOMSerializer(aOwner.Get());
nsRefPtr<nsDOMSerializer> domSerializer = new nsDOMSerializer(aOwner.GetAsSupports());
return domSerializer.forget();
}

View File

@ -11233,15 +11233,16 @@ nsDocument::QuerySelectorAll(const nsAString& aSelector, nsIDOMNodeList **aRetur
}
already_AddRefed<nsIDocument>
nsIDocument::Constructor(const GlobalObject& aGlobal, ErrorResult& rv)
nsIDocument::Constructor(const GlobalObject& aGlobal,
ErrorResult& rv)
{
nsCOMPtr<nsIScriptGlobalObject> global = do_QueryInterface(aGlobal.Get());
nsCOMPtr<nsIScriptGlobalObject> global = do_QueryInterface(aGlobal.GetAsSupports());
if (!global) {
rv.Throw(NS_ERROR_UNEXPECTED);
return nullptr;
}
nsCOMPtr<nsIScriptObjectPrincipal> prin = do_QueryInterface(aGlobal.Get());
nsCOMPtr<nsIScriptObjectPrincipal> prin = do_QueryInterface(aGlobal.GetAsSupports());
if (!prin) {
rv.Throw(NS_ERROR_UNEXPECTED);
return nullptr;

View File

@ -111,7 +111,7 @@ nsFormData::Constructor(const GlobalObject& aGlobal,
const Optional<NonNull<HTMLFormElement> >& aFormElement,
ErrorResult& aRv)
{
nsRefPtr<nsFormData> formData = new nsFormData(aGlobal.Get());
nsRefPtr<nsFormData> formData = new nsFormData(aGlobal.GetAsSupports());
if (aFormElement.WasPassed()) {
aRv = aFormElement.Value().WalkFormElements(formData);
}

View File

@ -42,7 +42,7 @@ public:
// nsWrapperCache
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
// WebIDL
nsISupports*

View File

@ -3000,9 +3000,10 @@ nsRange::AutoInvalidateSelection::~AutoInvalidateSelection()
}
/* static */ already_AddRefed<nsRange>
nsRange::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv)
nsRange::Constructor(const GlobalObject& aGlobal,
ErrorResult& aRv)
{
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.Get());
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports());
if (!window || !window->GetDoc()) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;

View File

@ -142,9 +142,9 @@ public:
const mozilla::dom::MozXMLHttpRequestParameters& aParams,
ErrorResult& aRv)
{
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aGlobal.Get());
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aGlobal.GetAsSupports());
nsCOMPtr<nsIScriptObjectPrincipal> principal =
do_QueryInterface(aGlobal.Get());
do_QueryInterface(aGlobal.GetAsSupports());
if (!global || ! principal) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;

View File

@ -150,7 +150,7 @@ DOMWheelEvent::Constructor(const GlobalObject& aGlobal,
const WheelEventInit& aParam,
mozilla::ErrorResult& aRv)
{
nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.Get());
nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
nsRefPtr<DOMWheelEvent> e = new DOMWheelEvent(t, nullptr, nullptr);
bool trusted = e->Init(t);
nsAutoString modifierList;

View File

@ -22,7 +22,7 @@ SpeechRecognitionError::Constructor(const GlobalObject& aGlobal,
const SpeechRecognitionErrorInit& aParam,
ErrorResult& aRv)
{
nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.Get());
nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
nsRefPtr<SpeechRecognitionError> e = new SpeechRecognitionError(t, nullptr, nullptr);
bool trusted = e->Init(t);
e->InitSpeechRecognitionError(aType, aParam.mBubbles, aParam.mCancelable, aParam.mError, aParam.mMessage, aRv);

View File

@ -20,10 +20,11 @@ public:
nsEvent* aEvent);
virtual ~SpeechRecognitionError();
static already_AddRefed<SpeechRecognitionError> Constructor(const GlobalObject& aGlobal,
const nsAString& aType,
const SpeechRecognitionErrorInit& aParam,
ErrorResult& aRv);
static already_AddRefed<SpeechRecognitionError>
Constructor(const GlobalObject& aGlobal,
const nsAString& aType,
const SpeechRecognitionErrorInit& aParam,
ErrorResult& aRv);
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
{

View File

@ -47,7 +47,7 @@ nsDOMAnimationEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
const mozilla::dom::AnimationEventInit& aParam,
mozilla::ErrorResult& aRv)
{
nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.Get());
nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
nsRefPtr<nsDOMAnimationEvent> e = new nsDOMAnimationEvent(t, nullptr, nullptr);
bool trusted = e->Init(t);

View File

@ -56,7 +56,7 @@ nsDOMClipboardEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
const mozilla::dom::ClipboardEventInit& aParam,
mozilla::ErrorResult& aRv)
{
nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.Get());
nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
nsRefPtr<nsDOMClipboardEvent> e =
new nsDOMClipboardEvent(t, nullptr, nullptr);
bool trusted = e->Init(t);

View File

@ -356,7 +356,7 @@ nsDOMEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
const mozilla::dom::EventInit& aParam,
mozilla::ErrorResult& aRv)
{
nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.Get());
nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
nsRefPtr<nsDOMEvent> e = new nsDOMEvent(t, nullptr, nullptr);
bool trusted = e->Init(t);
aRv = e->InitEvent(aType, aParam.mBubbles, aParam.mCancelable);

View File

@ -68,7 +68,7 @@ nsDOMFocusEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
const mozilla::dom::FocusEventInit& aParam,
mozilla::ErrorResult& aRv)
{
nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.Get());
nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
nsRefPtr<nsDOMFocusEvent> e = new nsDOMFocusEvent(t, nullptr, nullptr);
bool trusted = e->Init(t);
aRv = e->InitFocusEvent(aType, aParam.mBubbles, aParam.mCancelable, aParam.mView,

View File

@ -152,7 +152,7 @@ nsDOMMouseEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
const mozilla::dom::MouseEventInit& aParam,
mozilla::ErrorResult& aRv)
{
nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.Get());
nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
nsRefPtr<nsDOMMouseEvent> e = new nsDOMMouseEvent(t, nullptr, nullptr);
bool trusted = e->Init(t);
e->InitMouseEvent(aType, aParam.mBubbles, aParam.mCancelable,

View File

@ -47,7 +47,7 @@ nsDOMTransitionEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
const mozilla::dom::TransitionEventInit& aParam,
mozilla::ErrorResult& aRv)
{
nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.Get());
nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
nsRefPtr<nsDOMTransitionEvent> e = new nsDOMTransitionEvent(t, nullptr, nullptr);
bool trusted = e->Init(t);

View File

@ -82,7 +82,7 @@ nsDOMUIEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
const mozilla::dom::UIEventInit& aParam,
mozilla::ErrorResult& aRv)
{
nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.Get());
nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
nsRefPtr<nsDOMUIEvent> e = new nsDOMUIEvent(t, nullptr, nullptr);
bool trusted = e->Init(t);
aRv = e->InitUIEvent(aType, aParam.mBubbles, aParam.mCancelable, aParam.mView,

View File

@ -46,9 +46,9 @@ public:
// WebIDL
static already_AddRefed<HTMLAudioElement> Audio(const GlobalObject& global,
const Optional<nsAString>& src,
ErrorResult& aRv);
static already_AddRefed<HTMLAudioElement>
Audio(const GlobalObject& aGlobal,
const Optional<nsAString>& aSrc, ErrorResult& aRv);
void MozSetup(uint32_t aChannels, uint32_t aRate, ErrorResult& aRv);

View File

@ -53,7 +53,7 @@ HTMLAudioElement::Audio(const GlobalObject& aGlobal,
const Optional<nsAString>& aSrc,
ErrorResult& aRv)
{
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aGlobal.Get());
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aGlobal.GetAsSupports());
nsIDocument* doc;
if (!win || !(doc = win->GetExtantDoc())) {
aRv.Throw(NS_ERROR_FAILURE);

View File

@ -529,9 +529,10 @@ HTMLImageElement::IntrinsicState() const
already_AddRefed<HTMLImageElement>
HTMLImageElement::Image(const GlobalObject& aGlobal,
const Optional<uint32_t>& aWidth,
const Optional<uint32_t>& aHeight, ErrorResult& aError)
const Optional<uint32_t>& aHeight,
ErrorResult& aError)
{
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aGlobal.Get());
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aGlobal.GetAsSupports());
nsIDocument* doc;
if (!win || !(doc = win->GetExtantDoc())) {
aError.Throw(NS_ERROR_FAILURE);

View File

@ -25,8 +25,10 @@ public:
virtual ~HTMLImageElement();
static already_AddRefed<HTMLImageElement>
Image(const GlobalObject& aGlobal, const Optional<uint32_t>& aWidth,
const Optional<uint32_t>& aHeight, ErrorResult& aError);
Image(const GlobalObject& aGlobal,
const Optional<uint32_t>& aWidth,
const Optional<uint32_t>& aHeight,
ErrorResult& aError);
// nsISupports
NS_DECL_ISUPPORTS_INHERITED

View File

@ -335,7 +335,7 @@ HTMLOptionElement::Option(const GlobalObject& aGlobal,
const Optional<bool>& aDefaultSelected,
const Optional<bool>& aSelected, ErrorResult& aError)
{
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aGlobal.Get());
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aGlobal.GetAsSupports());
nsIDocument* doc;
if (!win || !(doc = win->GetExtantDoc())) {
aError.Throw(NS_ERROR_FAILURE);

View File

@ -26,7 +26,8 @@ public:
virtual ~HTMLOptionElement();
static already_AddRefed<HTMLOptionElement>
Option(const GlobalObject& aGlobal, const Optional<nsAString>& aText,
Option(const GlobalObject& aGlobal,
const Optional<nsAString>& aText,
const Optional<nsAString>& aValue,
const Optional<bool>& aDefaultSelected,
const Optional<bool>& aSelected, ErrorResult& aError);

View File

@ -124,7 +124,7 @@ MediaRecorder::~MediaRecorder()
}
void
MediaRecorder::Init(JSContext* aCx, nsPIDOMWindow* aOwnerWindow)
MediaRecorder::Init(nsPIDOMWindow* aOwnerWindow)
{
MOZ_ASSERT(aOwnerWindow);
MOZ_ASSERT(aOwnerWindow->IsInnerWindow());
@ -273,23 +273,23 @@ MediaRecorder::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
}
/* static */ already_AddRefed<MediaRecorder>
MediaRecorder::Constructor(const GlobalObject& aGlobal, JSContext* aCx,
MediaRecorder::Constructor(const GlobalObject& aGlobal,
DOMMediaStream& aStream, ErrorResult& aRv)
{
nsCOMPtr<nsIScriptGlobalObject> sgo = do_QueryInterface(aGlobal.Get());
nsCOMPtr<nsIScriptGlobalObject> sgo = do_QueryInterface(aGlobal.GetAsSupports());
if (!sgo) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
nsCOMPtr<nsPIDOMWindow> ownerWindow = do_QueryInterface(aGlobal.Get());
nsCOMPtr<nsPIDOMWindow> ownerWindow = do_QueryInterface(aGlobal.GetAsSupports());
if (!ownerWindow) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
nsRefPtr<MediaRecorder> object = new MediaRecorder(aStream);
object->Init(aCx, ownerWindow);
object->Init(ownerWindow);
return object.forget();
}

View File

@ -73,8 +73,8 @@ public:
void GetMimeType(nsString &aMimeType) { aMimeType = mMimeType; }
static already_AddRefed<MediaRecorder>
Constructor(const GlobalObject& aGlobal, JSContext* aCx, DOMMediaStream& aStream,
ErrorResult& aRv);
Constructor(const GlobalObject& aGlobal,
DOMMediaStream& aStream, ErrorResult& aRv);
// EventHandler
IMPL_EVENT_HANDLER(dataavailable)
@ -85,7 +85,7 @@ public:
friend class ExtractEncodedData;
protected:
void Init(JSContext* aCx, nsPIDOMWindow* aOwnerWindow);
void Init(nsPIDOMWindow* aOwnerWindow);
// Copy encoded data from encoder to EncodedBufferCache. This function runs in the Media Encoder Thread.
void ExtractEncodedData();

View File

@ -37,7 +37,7 @@ public:
const nsAString& aText,
ErrorResult& aRv)
{
nsRefPtr<TextTrackCue> ttcue = new TextTrackCue(aGlobal.Get(), aStartTime,
nsRefPtr<TextTrackCue> ttcue = new TextTrackCue(aGlobal.GetAsSupports(), aStartTime,
aEndTime, aText, aRv);
return ttcue.forget();
}

View File

@ -31,9 +31,10 @@ MediaSource::CreateInternalStream()
}
/* static */ already_AddRefed<MediaSource>
MediaSource::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv)
MediaSource::Constructor(const GlobalObject& aGlobal,
ErrorResult& aRv)
{
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.Get());
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports());
if (!window) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return nullptr;
@ -151,7 +152,8 @@ MediaSource::EndOfStream(const Optional<MediaSourceEndOfStreamError>& aError, Er
}
/* static */ bool
MediaSource::IsTypeSupported(const GlobalObject& aGlobal, const nsAString& aType)
MediaSource::IsTypeSupported(const GlobalObject& aGlobal,
const nsAString& aType)
{
ErrorResult unused;
return IsTypeSupportedInternal(aType, unused);

View File

@ -35,7 +35,9 @@ class MediaSource MOZ_FINAL : public nsDOMEventTargetHelper
{
public:
/** WebIDL Methods. */
static already_AddRefed<MediaSource> Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
static already_AddRefed<MediaSource>
Constructor(const GlobalObject& aGlobal,
ErrorResult& aRv);
SourceBufferList* SourceBuffers();
SourceBufferList* ActiveSourceBuffers();
@ -48,7 +50,8 @@ public:
void RemoveSourceBuffer(SourceBuffer& aSourceBuffer, ErrorResult& aRv);
void EndOfStream(const Optional<MediaSourceEndOfStreamError>& aError, ErrorResult& aRv);
static bool IsTypeSupported(const GlobalObject& aGlobal, const nsAString& aType);
static bool IsTypeSupported(const GlobalObject& aGlobal,
const nsAString& aType);
/** End WebIDL Methods. */
NS_DECL_ISUPPORTS_INHERITED

View File

@ -84,9 +84,10 @@ AudioContext::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
}
/* static */ already_AddRefed<AudioContext>
AudioContext::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv)
AudioContext::Constructor(const GlobalObject& aGlobal,
ErrorResult& aRv)
{
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.Get());
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports());
if (!window) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
@ -104,7 +105,7 @@ AudioContext::Constructor(const GlobalObject& aGlobal,
float aSampleRate,
ErrorResult& aRv)
{
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.Get());
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports());
if (!window) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;

View File

@ -49,9 +49,9 @@ class ConvolverNode;
class DelayNode;
class DynamicsCompressorNode;
class GainNode;
class GlobalObject;
class HTMLMediaElement;
class MediaElementAudioSourceNode;
class GlobalObject;
class MediaStreamAudioDestinationNode;
class MediaStreamAudioSourceNode;
class OscillatorNode;

View File

@ -31,9 +31,10 @@ SpeechGrammar::~SpeechGrammar()
}
SpeechGrammar*
SpeechGrammar::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv)
SpeechGrammar::Constructor(const GlobalObject& aGlobal,
ErrorResult& aRv)
{
return new SpeechGrammar(aGlobal.Get());
return new SpeechGrammar(aGlobal.GetAsSupports());
}
nsISupports*

View File

@ -39,7 +39,8 @@ public:
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
static SpeechGrammar* Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
static SpeechGrammar* Constructor(const GlobalObject& aGlobal,
ErrorResult& aRv);
void GetSrc(nsString& aRetVal, ErrorResult& aRv) const;

View File

@ -30,9 +30,10 @@ SpeechGrammarList::~SpeechGrammarList()
}
SpeechGrammarList*
SpeechGrammarList::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv)
SpeechGrammarList::Constructor(const GlobalObject& aGlobal,
ErrorResult& aRv)
{
return new SpeechGrammarList(aGlobal.Get());
return new SpeechGrammarList(aGlobal.GetAsSupports());
}
JSObject*

View File

@ -33,7 +33,8 @@ public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(SpeechGrammarList)
SpeechGrammarList* Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
SpeechGrammarList* Constructor(const GlobalObject& aGlobal,
ErrorResult& aRv);
nsISupports* GetParentObject() const;

View File

@ -107,9 +107,10 @@ SpeechRecognition::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
}
already_AddRefed<SpeechRecognition>
SpeechRecognition::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv)
SpeechRecognition::Constructor(const GlobalObject& aGlobal,
ErrorResult& aRv)
{
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aGlobal.Get());
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aGlobal.GetAsSupports());
if (!win) {
aRv.Throw(NS_ERROR_FAILURE);
}

View File

@ -70,7 +70,8 @@ public:
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
static already_AddRefed<SpeechRecognition> Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
static already_AddRefed<SpeechRecognition>
Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
already_AddRefed<SpeechGrammarList> GetGrammars(ErrorResult& aRv) const;

View File

@ -63,7 +63,7 @@ SpeechSynthesisUtterance::Constructor(GlobalObject& aGlobal,
const nsAString& aText,
ErrorResult& aRv)
{
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aGlobal.Get());
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aGlobal.GetAsSupports());
if (!win) {
aRv.Throw(NS_ERROR_FAILURE);

View File

@ -221,7 +221,8 @@ nsXPathEvaluator::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
/* static */
already_AddRefed<nsXPathEvaluator>
nsXPathEvaluator::Constructor(const GlobalObject& aGlobal, ErrorResult& rv)
nsXPathEvaluator::Constructor(const GlobalObject& aGlobal,
ErrorResult& rv)
{
nsRefPtr<nsXPathEvaluator> newObj = new nsXPathEvaluator(nullptr);
newObj->Init();

View File

@ -38,7 +38,7 @@ public:
ErrorResult& aRv)
{
nsRefPtr<Activity> activity = new Activity();
aRv = activity->Initialize(aOwner.Get(), aOptions);
aRv = activity->Initialize(aOwner.GetAsSupports(), aOptions);
return activity.forget();
}

View File

@ -65,10 +65,11 @@ DOMError::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
}
/* static */ already_AddRefed<DOMError>
DOMError::Constructor(const GlobalObject& aGlobal, const nsAString& aName,
const nsAString& aMessage, ErrorResult& aRv)
DOMError::Constructor(const GlobalObject& aGlobal,
const nsAString& aName, const nsAString& aMessage,
ErrorResult& aRv)
{
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.Get());
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports());
// Window is null for chrome code.

View File

@ -17,12 +17,13 @@ namespace mozilla {
namespace dom {
void
URL::CreateObjectURL(const GlobalObject& aGlobal, nsIDOMBlob* aBlob,
URL::CreateObjectURL(const GlobalObject& aGlobal,
nsIDOMBlob* aBlob,
const objectURLOptions& aOptions,
nsString& aResult,
ErrorResult& aError)
{
CreateObjectURLInternal(aGlobal.Get(), aBlob,
CreateObjectURLInternal(aGlobal.GetAsSupports(), aBlob,
NS_LITERAL_CSTRING(BLOBURI_SCHEME), aOptions, aResult,
aError);
}
@ -33,7 +34,7 @@ URL::CreateObjectURL(const GlobalObject& aGlobal, DOMMediaStream& aStream,
nsString& aResult,
ErrorResult& aError)
{
CreateObjectURLInternal(aGlobal.Get(), &aStream,
CreateObjectURLInternal(aGlobal.GetAsSupports(), &aStream,
NS_LITERAL_CSTRING(MEDIASTREAMURI_SCHEME), aOptions,
aResult, aError);
}
@ -44,7 +45,7 @@ URL::CreateObjectURL(const GlobalObject& aGlobal, MediaSource& aSource,
nsString& aResult,
ErrorResult& aError)
{
CreateObjectURLInternal(aGlobal.Get(), &aSource,
CreateObjectURLInternal(aGlobal.GetAsSupports(), &aSource,
NS_LITERAL_CSTRING(MEDIASOURCEURI_SCHEME), aOptions,
aResult, aError);
}
@ -83,7 +84,7 @@ URL::CreateObjectURLInternal(nsISupports* aGlobal, nsISupports* aObject,
void
URL::RevokeObjectURL(const GlobalObject& aGlobal, const nsAString& aURL)
{
nsCOMPtr<nsPIDOMWindow> w = do_QueryInterface(aGlobal.Get());
nsCOMPtr<nsPIDOMWindow> w = do_QueryInterface(aGlobal.GetAsSupports());
nsGlobalWindow* window = static_cast<nsGlobalWindow*>(w.get());
NS_PRECONDITION(!window || window->IsInnerWindow(),
"Should be inner window");

View File

@ -26,7 +26,8 @@ class URL MOZ_FINAL
{
public:
// WebIDL methods
static void CreateObjectURL(const GlobalObject& aGlobal, nsIDOMBlob* aBlob,
static void CreateObjectURL(const GlobalObject& aGlobal,
nsIDOMBlob* aBlob,
const objectURLOptions& aOptions,
nsString& aResult,
ErrorResult& aError);

View File

@ -64,31 +64,13 @@ class MOZ_STACK_CLASS GlobalObject
public:
GlobalObject(JSContext* aCx, JSObject* aObject);
nsISupports* Get() const
{
return mGlobalObject;
}
bool Failed() const
{
return !Get();
}
private:
JS::Rooted<JSObject*> mGlobalJSObject;
nsISupports* mGlobalObject;
nsCOMPtr<nsISupports> mGlobalObjectRef;
};
class MOZ_STACK_CLASS WorkerGlobalObject
{
public:
WorkerGlobalObject(JSContext* aCx, JSObject* aObject);
JSObject* Get() const
{
return mGlobalJSObject;
}
nsISupports* GetAsSupports() const;
// The context that this returns is not guaranteed to be in the compartment of
// the object returned from Get(), in fact it's generally in the caller's
// compartment.
@ -102,9 +84,11 @@ public:
return !Get();
}
private:
protected:
JS::RootedObject mGlobalJSObject;
JSContext* mCx;
mutable nsISupports* mGlobalObject;
mutable nsCOMPtr<nsISupports> mGlobalObjectRef;
};
/**

View File

@ -1704,53 +1704,53 @@ ReparentWrapper(JSContext* aCx, JS::HandleObject aObjArg)
return NS_OK;
}
template<bool mainThread>
inline JSObject*
GetGlobalObject(JSContext* aCx, JSObject* aObject,
Maybe<JSAutoCompartment>& aAutoCompartment)
GlobalObject::GlobalObject(JSContext* aCx, JSObject* aObject)
: mGlobalJSObject(aCx),
mCx(aCx),
mGlobalObject(nullptr)
{
Maybe<JSAutoCompartment> ac;
JS::Rooted<JSObject*> obj(aCx, aObject);
if (js::IsWrapper(obj)) {
obj = js::CheckedUnwrap(obj, /* stopAtOuter = */ false);
if (!obj) {
Throw<mainThread>(aCx, NS_ERROR_XPC_SECURITY_MANAGER_VETO);
return nullptr;
// We should never end up here on a worker thread, since there shouldn't
// be any security wrappers to worry about.
if (!MOZ_LIKELY(NS_IsMainThread())) {
MOZ_CRASH();
}
Throw<true>(aCx, NS_ERROR_XPC_SECURITY_MANAGER_VETO);
return;
}
aAutoCompartment.construct(aCx, obj);
ac.construct(aCx, obj);
}
return JS_GetGlobalForObject(aCx, obj);
mGlobalJSObject = JS_GetGlobalForObject(aCx, obj);
}
GlobalObject::GlobalObject(JSContext* aCx, JSObject* aObject)
: mGlobalJSObject(aCx)
nsISupports*
GlobalObject::GetAsSupports() const
{
Maybe<JSAutoCompartment> ac;
mGlobalJSObject = GetGlobalObject<true>(aCx, aObject, ac);
if (!mGlobalJSObject) {
mGlobalObject = nullptr;
return;
MOZ_ASSERT(NS_IsMainThread());
if (mGlobalObject) {
return mGlobalObject;
}
JS::Rooted<JS::Value> val(aCx, JS::ObjectValue(*mGlobalJSObject));
JS::Rooted<JS::Value> val(mCx, JS::ObjectValue(*mGlobalJSObject));
// Switch this to UnwrapDOMObjectToISupports once our global objects are
// using new bindings.
nsresult rv = xpc_qsUnwrapArg<nsISupports>(aCx, val, &mGlobalObject,
nsresult rv = xpc_qsUnwrapArg<nsISupports>(mCx, val, &mGlobalObject,
static_cast<nsISupports**>(getter_AddRefs(mGlobalObjectRef)),
val.address());
if (NS_FAILED(rv)) {
mGlobalObject = nullptr;
Throw<true>(aCx, NS_ERROR_XPC_BAD_CONVERT_JS);
Throw<true>(mCx, NS_ERROR_XPC_BAD_CONVERT_JS);
}
}
WorkerGlobalObject::WorkerGlobalObject(JSContext* aCx, JSObject* aObject)
: mGlobalJSObject(aCx),
mCx(aCx)
{
Maybe<JSAutoCompartment> ac;
mGlobalJSObject = GetGlobalObject<false>(aCx, aObject, ac);
return mGlobalObject;
}
bool
@ -1847,7 +1847,7 @@ ReportLenientThisUnwrappingFailure(JSContext* cx, JS::Handle<JSObject*> obj)
if (global.Failed()) {
return false;
}
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(global.Get());
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(global.GetAsSupports());
if (window && window->GetDoc()) {
window->GetDoc()->WarnOnceAbout(nsIDocument::eLenientThis);
}
@ -1884,7 +1884,7 @@ GetWindowForJSImplementedObject(JSContext* cx, JS::Handle<JSObject*> obj,
// It's OK if we have null here: that just means the content-side
// object really wasn't associated with any window.
nsCOMPtr<nsPIDOMWindow> win(do_QueryInterface(global.Get()));
nsCOMPtr<nsPIDOMWindow> win(do_QueryInterface(global.GetAsSupports()));
win.forget(window);
return true;
}
@ -1896,7 +1896,7 @@ ConstructJSImplementation(JSContext* aCx, const char* aContractId,
ErrorResult& aRv)
{
// Get the window to use as a parent and for initialization.
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.Get());
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports());
if (!window) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;

View File

@ -715,7 +715,6 @@ DOMInterfaces = {
'MediaRecorder': {
'headerFile': 'MediaRecorder.h',
'implicitJSContext': [ 'constructor' ],
'resultNotAddRefed': [ 'stream' ]
},
@ -875,10 +874,6 @@ DOMInterfaces = {
'headerFile': 'nsGeolocation.h'
},
'Promise': {
'implicitJSContext': [ 'constructor' ]
},
'PropertyNodeList': {
'headerFile': 'HTMLPropertiesCollection.h',
'resultNotAddRefed': [ 'item' ]

View File

@ -4679,14 +4679,11 @@ class CGPerSignatureCall(CGThing):
if static:
nativeMethodName = "%s::%s" % (descriptor.nativeType,
nativeMethodName)
globalObjectType = "GlobalObject"
if descriptor.workers:
globalObjectType = "Worker" + globalObjectType
cgThings.append(CGGeneric("""%s global(cx, obj);
cgThings.append(CGGeneric("""GlobalObject global(cx, obj);
if (global.Failed()) {
return false;
}
""" % globalObjectType))
"""))
argsPre.append("global")
# For JS-implemented interfaces we do not want to base the
@ -4701,6 +4698,8 @@ if (global.Failed()) {
if needScopeObject(returnType, arguments, self.extendedAttributes,
descriptor, descriptor.wrapperCache,
not descriptor.interface.isJSImplemented()):
# We cannot assign into obj because it's a Handle, not a
# MutableHandle, so we need a separate Rooted.
cgThings.append(CGGeneric("Maybe<JS::Rooted<JSObject*> > unwrappedObj;"))
argsPre.append("unwrappedObj.empty() ? obj : unwrappedObj.ref()")
needsUnwrap = True
@ -4734,16 +4733,15 @@ if (global.Failed()) {
xraySteps = []
if not isConstructor:
xraySteps.append(
CGGeneric("unwrappedObj.construct(cx, obj);\n"
"JS::Rooted<JSObject*>& obj = unwrappedObj.ref();"))
CGGeneric("unwrappedObj.construct(cx, obj);"))
# XXXkhuey we should be able to MOZ_ASSERT that unwrappedObj is
# XXXkhuey we should be able to MOZ_ASSERT that ${obj} is
# not null.
xraySteps.append(
CGGeneric("obj = js::CheckedUnwrap(obj);\n"
"if (!obj) {\n"
" return false;\n"
"}"))
CGGeneric(string.Template("""${obj} = js::CheckedUnwrap(${obj});
if (!${obj}) {
return false;
}""").substitute({ 'obj' : 'obj' if isConstructor else 'unwrappedObj.ref()' })))
if isConstructor:
# If we're called via an xray, we need to enter the underlying
# object's compartment and then wrap up all of our arguments into
@ -8936,16 +8934,13 @@ class CGNativeMember(ClassMethod):
if needCx(returnType, argList, self.extendedAttrs,
self.descriptorProvider, self.passJSBitsAsNeeded):
args.insert(0, Argument("JSContext*", "cx"))
if needScopeObject(returnType, argList, self.extendedAttrs,
self.descriptorProvider, self.descriptorProvider,
self.passJSBitsAsNeeded):
args.insert(0, Argument("JS::Handle<JSObject*>", "obj"))
if needScopeObject(returnType, argList, self.extendedAttrs,
self.descriptorProvider, self.descriptorProvider,
self.passJSBitsAsNeeded):
args.insert(1, Argument("JS::Handle<JSObject*>", "obj"))
# And if we're static, a global
if self.member.isStatic():
globalObjectType = "GlobalObject"
if self.descriptorProvider.workers:
globalObjectType = "Worker" + globalObjectType
args.insert(0, Argument("const %s&" % globalObjectType, "global"))
args.insert(0, Argument("const GlobalObject&", "global"))
return args
def doGetArgType(self, type, optional, isMember):
@ -9635,7 +9630,7 @@ class CGJSImplClass(CGBindingImplClass):
"if (global.Failed()) {\n"
" return false;\n"
"}\n"
"nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(global.Get());\n"
"nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(global.GetAsSupports());\n"
"if (!window) {\n"
' return ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of ${ifaceName}._create", "Window");\n'
"}\n"

View File

@ -25,7 +25,7 @@ public:
const TextDecoderOptions& aOptions,
ErrorResult& aRv)
{
nsRefPtr<TextDecoder> txtDecoder = new TextDecoder(aGlobal.Get());
nsRefPtr<TextDecoder> txtDecoder = new TextDecoder(aGlobalAsSupports.Get());
txtDecoder->Init(aEncoding, aOptions.mFatal, aRv);
if (aRv.Failed()) {
return nullptr;

View File

@ -24,7 +24,7 @@ public:
const nsAString& aEncoding,
ErrorResult& aRv)
{
nsRefPtr<TextEncoder> txtEncoder = new TextEncoder(aGlobal.Get());
nsRefPtr<TextEncoder> txtEncoder = new TextEncoder(aGlobal.GetAsSupports());
txtEncoder->Init(aEncoding, aRv);
if (aRv.Failed()) {
return nullptr;

View File

@ -23,14 +23,15 @@ using namespace mozilla::dom;
USING_FILE_NAMESPACE
/* static */ already_AddRefed<ArchiveReader>
ArchiveReader::Constructor(const GlobalObject& aGlobal, nsIDOMBlob* aBlob,
ArchiveReader::Constructor(const GlobalObject& aGlobal,
nsIDOMBlob* aBlob,
const ArchiveReaderOptions& aOptions,
ErrorResult& aError)
{
MOZ_ASSERT(aBlob);
MOZ_ASSERT(PrefEnabled());
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.Get());
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports());
if (!window) {
aError.Throw(NS_ERROR_UNEXPECTED);
return nullptr;

View File

@ -69,7 +69,7 @@ public:
if (!aOptions.mNewVersion.IsNull()) {
newVersion = aOptions.mNewVersion.Value();
}
nsCOMPtr<EventTarget> target = do_QueryInterface(aGlobal.Get());
nsCOMPtr<EventTarget> target = do_QueryInterface(aGlobal.GetAsSupports());
return CreateInternal(target, aType, aOptions.mOldVersion, newVersion);
}

View File

@ -144,10 +144,11 @@ EnterCompartment(Maybe<JSAutoCompartment>& aAc, JSContext* aCx,
}
/* static */ already_AddRefed<Promise>
Promise::Constructor(const GlobalObject& aGlobal, JSContext* aCx,
Promise::Constructor(const GlobalObject& aGlobal,
PromiseInit& aInit, ErrorResult& aRv)
{
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.Get());
JSContext* cx = aGlobal.GetContext();
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports());
if (!window) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return nullptr;
@ -160,12 +161,12 @@ Promise::Constructor(const GlobalObject& aGlobal, JSContext* aCx,
aRv.WouldReportJSException();
if (aRv.IsJSException()) {
Optional<JS::Handle<JS::Value> > value(aCx);
aRv.StealJSException(aCx, &value.Value());
Optional<JS::Handle<JS::Value> > value(cx);
aRv.StealJSException(cx, &value.Value());
Maybe<JSAutoCompartment> ac;
EnterCompartment(ac, aCx, value);
promise->mResolver->Reject(aCx, value);
EnterCompartment(ac, cx, value);
promise->mResolver->Reject(cx, value);
}
return promise.forget();
@ -175,7 +176,7 @@ Promise::Constructor(const GlobalObject& aGlobal, JSContext* aCx,
Promise::Resolve(const GlobalObject& aGlobal, JSContext* aCx,
JS::Handle<JS::Value> aValue, ErrorResult& aRv)
{
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.Get());
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports());
if (!window) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return nullptr;
@ -192,7 +193,7 @@ Promise::Resolve(const GlobalObject& aGlobal, JSContext* aCx,
Promise::Reject(const GlobalObject& aGlobal, JSContext* aCx,
JS::Handle<JS::Value> aValue, ErrorResult& aRv)
{
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.Get());
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports());
if (!window) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return nullptr;

View File

@ -54,7 +54,7 @@ public:
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
static already_AddRefed<Promise>
Constructor(const GlobalObject& aGlobal, JSContext* aCx, PromiseInit& aInit,
Constructor(const GlobalObject& aGlobal, PromiseInit& aInit,
ErrorResult& aRv);
static already_AddRefed<Promise>

View File

@ -305,7 +305,7 @@ Notification::Constructor(const GlobalObject& aGlobal,
tag,
aOptions.mIcon);
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.Get());
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports());
MOZ_ASSERT(window, "Window should not be null.");
notification->BindToOwner(window);
@ -370,8 +370,8 @@ Notification::RequestPermission(const GlobalObject& aGlobal,
ErrorResult& aRv)
{
// Get principal from global to make permission request for notifications.
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.Get());
nsCOMPtr<nsIScriptObjectPrincipal> sop = do_QueryInterface(aGlobal.Get());
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports());
nsCOMPtr<nsIScriptObjectPrincipal> sop = do_QueryInterface(aGlobal.GetAsSupports());
if (!sop) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return;
@ -391,7 +391,7 @@ Notification::RequestPermission(const GlobalObject& aGlobal,
NotificationPermission
Notification::GetPermission(const GlobalObject& aGlobal, ErrorResult& aRv)
{
return GetPermissionInternal(aGlobal.Get(), aRv);
return GetPermissionInternal(aGlobal.GetAsSupports(), aRv);
}
NotificationPermission

View File

@ -53,7 +53,7 @@ already_AddRefed<CallEvent>
CallEvent::Constructor(const GlobalObject& aGlobal, const nsAString& aType,
const CallEventInit& aOptions, ErrorResult& aRv)
{
nsCOMPtr<EventTarget> target = do_QueryInterface(aGlobal.Get());
nsCOMPtr<EventTarget> target = do_QueryInterface(aGlobal.GetAsSupports());
if (!target) {
aRv.Throw(NS_ERROR_UNEXPECTED);

View File

@ -31,7 +31,7 @@
USING_WORKERS_NAMESPACE
using namespace mozilla;
using mozilla::dom::Optional;
using mozilla::dom::WorkerGlobalObject;
using mozilla::dom::GlobalObject;
NS_IMPL_ADDREF_INHERITED(FileReaderSync, DOMBindingBase)
NS_IMPL_RELEASE_INHERITED(FileReaderSync, DOMBindingBase)
@ -58,7 +58,7 @@ FileReaderSync::_finalize(JSFreeOp* aFop)
// static
FileReaderSync*
FileReaderSync::Constructor(const WorkerGlobalObject& aGlobal, ErrorResult& aRv)
FileReaderSync::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv)
{
nsRefPtr<FileReaderSync> frs = new FileReaderSync(aGlobal.GetContext());

View File

@ -36,7 +36,7 @@ public:
_finalize(JSFreeOp* aFop) MOZ_OVERRIDE;
static FileReaderSync*
Constructor(const WorkerGlobalObject& aGlobal, ErrorResult& aRv);
Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
NS_DECL_ISUPPORTS_INHERITED

View File

@ -8,7 +8,7 @@
USING_WORKERS_NAMESPACE
using mozilla::ErrorResult;
using mozilla::dom::WorkerGlobalObject;
using mozilla::dom::GlobalObject;
void
TextEncoder::_trace(JSTracer* aTrc)
@ -24,7 +24,7 @@ TextEncoder::_finalize(JSFreeOp* aFop)
// static
TextEncoder*
TextEncoder::Constructor(const WorkerGlobalObject& aGlobal,
TextEncoder::Constructor(const GlobalObject& aGlobal,
const nsAString& aEncoding,
ErrorResult& aRv)
{

View File

@ -32,7 +32,7 @@ public:
_finalize(JSFreeOp* aFop) MOZ_OVERRIDE;
static TextEncoder*
Constructor(const WorkerGlobalObject& aGlobal,
Constructor(const GlobalObject& aGlobal,
const nsAString& aEncoding,
ErrorResult& aRv);

View File

@ -19,7 +19,7 @@
#include "nsIDOMFile.h"
USING_WORKERS_NAMESPACE
using mozilla::dom::WorkerGlobalObject;
using mozilla::dom::GlobalObject;
// Base class for the Revoke and Create runnable objects.
class URLRunnable : public nsRunnable
@ -227,7 +227,7 @@ public:
// static
void
URL::CreateObjectURL(const WorkerGlobalObject& aGlobal, JSObject* aBlob,
URL::CreateObjectURL(const GlobalObject& aGlobal, JSObject* aBlob,
const mozilla::dom::objectURLOptionsWorkers& aOptions,
nsString& aResult, mozilla::ErrorResult& aRv)
{
@ -254,7 +254,7 @@ URL::CreateObjectURL(const WorkerGlobalObject& aGlobal, JSObject* aBlob,
// static
void
URL::CreateObjectURL(const WorkerGlobalObject& aGlobal, JSObject& aBlob,
URL::CreateObjectURL(const GlobalObject& aGlobal, JSObject& aBlob,
const mozilla::dom::objectURLOptionsWorkers& aOptions,
nsString& aResult, mozilla::ErrorResult& aRv)
{
@ -263,7 +263,7 @@ URL::CreateObjectURL(const WorkerGlobalObject& aGlobal, JSObject& aBlob,
// static
void
URL::RevokeObjectURL(const WorkerGlobalObject& aGlobal, const nsAString& aUrl)
URL::RevokeObjectURL(const GlobalObject& aGlobal, const nsAString& aUrl)
{
JSContext* cx = aGlobal.GetContext();
WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(cx);

View File

@ -17,17 +17,17 @@ class URL : public EventTarget
{
public: // Methods for WebIDL
static void
CreateObjectURL(const WorkerGlobalObject& aGlobal,
CreateObjectURL(const GlobalObject& aGlobal,
JSObject* aArg, const objectURLOptionsWorkers& aOptions,
nsString& aResult, ErrorResult& aRv);
static void
CreateObjectURL(const WorkerGlobalObject& aGlobal,
CreateObjectURL(const GlobalObject& aGlobal,
JSObject& aArg, const objectURLOptionsWorkers& aOptions,
nsString& aResult, ErrorResult& aRv);
static void
RevokeObjectURL(const WorkerGlobalObject& aGlobal, const nsAString& aUrl);
RevokeObjectURL(const GlobalObject& aGlobal, const nsAString& aUrl);
};
END_WORKERS_NAMESPACE

View File

@ -1459,7 +1459,7 @@ XMLHttpRequest::_finalize(JSFreeOp* aFop)
// static
XMLHttpRequest*
XMLHttpRequest::Constructor(const WorkerGlobalObject& aGlobal,
XMLHttpRequest::Constructor(const GlobalObject& aGlobal,
const MozXMLHttpRequestParametersWorkers& aParams,
ErrorResult& aRv)
{

View File

@ -75,12 +75,12 @@ public:
_finalize(JSFreeOp* aFop) MOZ_OVERRIDE;
static XMLHttpRequest*
Constructor(const WorkerGlobalObject& aGlobal,
Constructor(const GlobalObject& aGlobal,
const MozXMLHttpRequestParametersWorkers& aParams,
ErrorResult& aRv);
static XMLHttpRequest*
Constructor(const WorkerGlobalObject& aGlobal, const nsAString& ignored,
Constructor(const GlobalObject& aGlobal, const nsAString& ignored,
ErrorResult& aRv)
{
// Pretend like someone passed null, so we can pick up the default values

View File

@ -417,7 +417,7 @@ def write_cpp(eventname, iface, fd, conf):
fd.write("const %sInit& aParam, " % eventname)
fd.write("ErrorResult& aRv)\n")
fd.write("{\n")
fd.write(" nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.Get());\n")
fd.write(" nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());\n")
fd.write(" nsRefPtr<%s> e = new %s(t, nullptr, nullptr);\n" % (eventname, eventname))
fd.write(" bool trusted = e->Init(t);\n")
fd.write(" e->Init%s(" % eventname)

View File

@ -52,7 +52,7 @@ CSS::Supports(const GlobalObject& aGlobal,
nsCSSParser parser;
SupportsParsingInfo info;
nsresult rv = GetParsingInfo(aGlobal.Get(), info);
nsresult rv = GetParsingInfo(aGlobal.GetAsSupports(), info);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return false;
@ -70,7 +70,7 @@ CSS::Supports(const GlobalObject& aGlobal,
nsCSSParser parser;
SupportsParsingInfo info;
nsresult rv = GetParsingInfo(aGlobal.Get(), info);
nsresult rv = GetParsingInfo(aGlobal.GetAsSupports(), info);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return false;