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

View File

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

View File

@ -122,9 +122,10 @@ DocumentFragment::DumpContent(FILE* out, int32_t aIndent,
#endif #endif
/* static */ already_AddRefed<DocumentFragment> /* 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()) { if (!window || !window->GetDoc()) {
aRv.Throw(NS_ERROR_FAILURE); aRv.Throw(NS_ERROR_FAILURE);
return nullptr; return nullptr;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3000,9 +3000,10 @@ nsRange::AutoInvalidateSelection::~AutoInvalidateSelection()
} }
/* static */ already_AddRefed<nsRange> /* 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()) { if (!window || !window->GetDoc()) {
aRv.Throw(NS_ERROR_FAILURE); aRv.Throw(NS_ERROR_FAILURE);
return nullptr; return nullptr;

View File

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

View File

@ -150,7 +150,7 @@ DOMWheelEvent::Constructor(const GlobalObject& aGlobal,
const WheelEventInit& aParam, const WheelEventInit& aParam,
mozilla::ErrorResult& aRv) 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); nsRefPtr<DOMWheelEvent> e = new DOMWheelEvent(t, nullptr, nullptr);
bool trusted = e->Init(t); bool trusted = e->Init(t);
nsAutoString modifierList; nsAutoString modifierList;

View File

@ -22,7 +22,7 @@ SpeechRecognitionError::Constructor(const GlobalObject& aGlobal,
const SpeechRecognitionErrorInit& aParam, const SpeechRecognitionErrorInit& aParam,
ErrorResult& aRv) 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); nsRefPtr<SpeechRecognitionError> e = new SpeechRecognitionError(t, nullptr, nullptr);
bool trusted = e->Init(t); bool trusted = e->Init(t);
e->InitSpeechRecognitionError(aType, aParam.mBubbles, aParam.mCancelable, aParam.mError, aParam.mMessage, aRv); e->InitSpeechRecognitionError(aType, aParam.mBubbles, aParam.mCancelable, aParam.mError, aParam.mMessage, aRv);

View File

@ -20,10 +20,11 @@ public:
nsEvent* aEvent); nsEvent* aEvent);
virtual ~SpeechRecognitionError(); virtual ~SpeechRecognitionError();
static already_AddRefed<SpeechRecognitionError> Constructor(const GlobalObject& aGlobal, static already_AddRefed<SpeechRecognitionError>
const nsAString& aType, Constructor(const GlobalObject& aGlobal,
const SpeechRecognitionErrorInit& aParam, const nsAString& aType,
ErrorResult& aRv); const SpeechRecognitionErrorInit& aParam,
ErrorResult& aRv);
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE 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, const mozilla::dom::AnimationEventInit& aParam,
mozilla::ErrorResult& aRv) 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); nsRefPtr<nsDOMAnimationEvent> e = new nsDOMAnimationEvent(t, nullptr, nullptr);
bool trusted = e->Init(t); bool trusted = e->Init(t);

View File

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

View File

@ -356,7 +356,7 @@ nsDOMEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
const mozilla::dom::EventInit& aParam, const mozilla::dom::EventInit& aParam,
mozilla::ErrorResult& aRv) 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); nsRefPtr<nsDOMEvent> e = new nsDOMEvent(t, nullptr, nullptr);
bool trusted = e->Init(t); bool trusted = e->Init(t);
aRv = e->InitEvent(aType, aParam.mBubbles, aParam.mCancelable); 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, const mozilla::dom::FocusEventInit& aParam,
mozilla::ErrorResult& aRv) 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); nsRefPtr<nsDOMFocusEvent> e = new nsDOMFocusEvent(t, nullptr, nullptr);
bool trusted = e->Init(t); bool trusted = e->Init(t);
aRv = e->InitFocusEvent(aType, aParam.mBubbles, aParam.mCancelable, aParam.mView, 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, const mozilla::dom::MouseEventInit& aParam,
mozilla::ErrorResult& aRv) 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); nsRefPtr<nsDOMMouseEvent> e = new nsDOMMouseEvent(t, nullptr, nullptr);
bool trusted = e->Init(t); bool trusted = e->Init(t);
e->InitMouseEvent(aType, aParam.mBubbles, aParam.mCancelable, 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, const mozilla::dom::TransitionEventInit& aParam,
mozilla::ErrorResult& aRv) 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); nsRefPtr<nsDOMTransitionEvent> e = new nsDOMTransitionEvent(t, nullptr, nullptr);
bool trusted = e->Init(t); bool trusted = e->Init(t);

View File

@ -82,7 +82,7 @@ nsDOMUIEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
const mozilla::dom::UIEventInit& aParam, const mozilla::dom::UIEventInit& aParam,
mozilla::ErrorResult& aRv) 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); nsRefPtr<nsDOMUIEvent> e = new nsDOMUIEvent(t, nullptr, nullptr);
bool trusted = e->Init(t); bool trusted = e->Init(t);
aRv = e->InitUIEvent(aType, aParam.mBubbles, aParam.mCancelable, aParam.mView, aRv = e->InitUIEvent(aType, aParam.mBubbles, aParam.mCancelable, aParam.mView,

View File

@ -46,9 +46,9 @@ public:
// WebIDL // WebIDL
static already_AddRefed<HTMLAudioElement> Audio(const GlobalObject& global, static already_AddRefed<HTMLAudioElement>
const Optional<nsAString>& src, Audio(const GlobalObject& aGlobal,
ErrorResult& aRv); const Optional<nsAString>& aSrc, ErrorResult& aRv);
void MozSetup(uint32_t aChannels, uint32_t aRate, 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, const Optional<nsAString>& aSrc,
ErrorResult& aRv) ErrorResult& aRv)
{ {
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aGlobal.Get()); nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aGlobal.GetAsSupports());
nsIDocument* doc; nsIDocument* doc;
if (!win || !(doc = win->GetExtantDoc())) { if (!win || !(doc = win->GetExtantDoc())) {
aRv.Throw(NS_ERROR_FAILURE); aRv.Throw(NS_ERROR_FAILURE);

View File

@ -529,9 +529,10 @@ HTMLImageElement::IntrinsicState() const
already_AddRefed<HTMLImageElement> already_AddRefed<HTMLImageElement>
HTMLImageElement::Image(const GlobalObject& aGlobal, HTMLImageElement::Image(const GlobalObject& aGlobal,
const Optional<uint32_t>& aWidth, 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; nsIDocument* doc;
if (!win || !(doc = win->GetExtantDoc())) { if (!win || !(doc = win->GetExtantDoc())) {
aError.Throw(NS_ERROR_FAILURE); aError.Throw(NS_ERROR_FAILURE);

View File

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

View File

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

View File

@ -26,7 +26,8 @@ public:
virtual ~HTMLOptionElement(); virtual ~HTMLOptionElement();
static already_AddRefed<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<nsAString>& aValue,
const Optional<bool>& aDefaultSelected, const Optional<bool>& aDefaultSelected,
const Optional<bool>& aSelected, ErrorResult& aError); const Optional<bool>& aSelected, ErrorResult& aError);

View File

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

View File

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

View File

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

View File

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

View File

@ -35,7 +35,9 @@ class MediaSource MOZ_FINAL : public nsDOMEventTargetHelper
{ {
public: public:
/** WebIDL Methods. */ /** 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* SourceBuffers();
SourceBufferList* ActiveSourceBuffers(); SourceBufferList* ActiveSourceBuffers();
@ -48,7 +50,8 @@ public:
void RemoveSourceBuffer(SourceBuffer& aSourceBuffer, ErrorResult& aRv); void RemoveSourceBuffer(SourceBuffer& aSourceBuffer, ErrorResult& aRv);
void EndOfStream(const Optional<MediaSourceEndOfStreamError>& aError, 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. */ /** End WebIDL Methods. */
NS_DECL_ISUPPORTS_INHERITED NS_DECL_ISUPPORTS_INHERITED

View File

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

View File

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

View File

@ -31,9 +31,10 @@ SpeechGrammar::~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* nsISupports*

View File

@ -39,7 +39,8 @@ public:
virtual JSObject* WrapObject(JSContext* aCx, virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE; 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; void GetSrc(nsString& aRetVal, ErrorResult& aRv) const;

View File

@ -30,9 +30,10 @@ SpeechGrammarList::~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* JSObject*

View File

@ -33,7 +33,8 @@ public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(SpeechGrammarList) 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; nsISupports* GetParentObject() const;

View File

@ -107,9 +107,10 @@ SpeechRecognition::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
} }
already_AddRefed<SpeechRecognition> 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) { if (!win) {
aRv.Throw(NS_ERROR_FAILURE); aRv.Throw(NS_ERROR_FAILURE);
} }

View File

@ -70,7 +70,8 @@ public:
virtual JSObject* WrapObject(JSContext* aCx, virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE; 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; already_AddRefed<SpeechGrammarList> GetGrammars(ErrorResult& aRv) const;

View File

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

View File

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

View File

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

View File

@ -65,10 +65,11 @@ DOMError::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
} }
/* static */ already_AddRefed<DOMError> /* static */ already_AddRefed<DOMError>
DOMError::Constructor(const GlobalObject& aGlobal, const nsAString& aName, DOMError::Constructor(const GlobalObject& aGlobal,
const nsAString& aMessage, ErrorResult& aRv) 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. // Window is null for chrome code.

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -69,7 +69,7 @@ public:
if (!aOptions.mNewVersion.IsNull()) { if (!aOptions.mNewVersion.IsNull()) {
newVersion = aOptions.mNewVersion.Value(); 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); return CreateInternal(target, aType, aOptions.mOldVersion, newVersion);
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -75,12 +75,12 @@ public:
_finalize(JSFreeOp* aFop) MOZ_OVERRIDE; _finalize(JSFreeOp* aFop) MOZ_OVERRIDE;
static XMLHttpRequest* static XMLHttpRequest*
Constructor(const WorkerGlobalObject& aGlobal, Constructor(const GlobalObject& aGlobal,
const MozXMLHttpRequestParametersWorkers& aParams, const MozXMLHttpRequestParametersWorkers& aParams,
ErrorResult& aRv); ErrorResult& aRv);
static XMLHttpRequest* static XMLHttpRequest*
Constructor(const WorkerGlobalObject& aGlobal, const nsAString& ignored, Constructor(const GlobalObject& aGlobal, const nsAString& ignored,
ErrorResult& aRv) ErrorResult& aRv)
{ {
// Pretend like someone passed null, so we can pick up the default values // 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("const %sInit& aParam, " % eventname)
fd.write("ErrorResult& aRv)\n") fd.write("ErrorResult& aRv)\n")
fd.write("{\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(" nsRefPtr<%s> e = new %s(t, nullptr, nullptr);\n" % (eventname, eventname))
fd.write(" bool trusted = e->Init(t);\n") fd.write(" bool trusted = e->Init(t);\n")
fd.write(" e->Init%s(" % eventname) fd.write(" e->Init%s(" % eventname)

View File

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