Loading content/base/public/nsIDocument.h +6 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,7 @@ class nsIStyleSheet; class nsIStyleRule; class nsIViewManager; class nsIScriptGlobalObject; class nsPIDOMWindow; class nsIDOMEvent; class nsIDeviceContext; class nsIParser; Loading Loading @@ -472,6 +473,11 @@ public: virtual nsIScriptGlobalObject* GetScriptGlobalObject() const = 0; virtual void SetScriptGlobalObject(nsIScriptGlobalObject* aGlobalObject) = 0; /** * Return the window containing the document (the outer window). */ virtual nsPIDOMWindow *GetWindow() = 0; /** * Get the script loader for this document */ Loading content/base/src/nsDocument.cpp +33 −3 Original line number Diff line number Diff line Loading @@ -697,6 +697,12 @@ NS_IMPL_RELEASE_USING_AGGREGATOR(nsXPathDocumentTearoff, mDocument) // NOTE! nsDocument::operator new() zeroes out all members, so don't // bother initializing members to 0. nsDocument::nsDocument() : nsIDocument(), mVisible(PR_TRUE) { } nsDocument::~nsDocument() { mInDestructor = PR_TRUE; Loading Loading @@ -2043,6 +2049,15 @@ nsDocument::GetScriptGlobalObject() const void nsDocument::SetScriptGlobalObject(nsIScriptGlobalObject *aScriptGlobalObject) { #ifdef DEBUG { nsCOMPtr<nsPIDOMWindow> win(do_QueryInterface(aScriptGlobalObject)); NS_ASSERTION(!win || win->IsInnerWindow(), "Script global object must be an inner window!"); } #endif if (mScriptGlobalObject && !aScriptGlobalObject) { // We're detaching from the window. We need to grab a pointer to // our layout history state now. Loading @@ -2057,6 +2072,18 @@ nsDocument::SetScriptGlobalObject(nsIScriptGlobalObject *aScriptGlobalObject) } } nsPIDOMWindow * nsDocument::GetWindow() { nsCOMPtr<nsPIDOMWindow> win(do_QueryInterface(GetScriptGlobalObject())); if (!win) { return nsnull; } return win->GetOuterWindow(); } nsIScriptLoader * nsDocument::GetScriptLoader() { Loading Loading @@ -3037,11 +3064,14 @@ nsDocument::GetDefaultView(nsIDOMAbstractView** aDefaultView) if (win) { // The default view is our outer window. if (!win->IsInnerWindow()) { return NS_ERROR_UNEXPECTED; nsPIDOMWindow *outer = win->GetOuterWindow(); if (outer) { return CallQueryInterface(outer, aDefaultView); } return CallQueryInterface(win->GetOuterWindow(), aDefaultView); // Fall through here and return null in case our window no longer // has an outer window. } return NS_OK; Loading content/base/src/nsDocument.h +6 −1 Original line number Diff line number Diff line Loading @@ -450,6 +450,11 @@ public: virtual nsIScriptGlobalObject* GetScriptGlobalObject() const; virtual void SetScriptGlobalObject(nsIScriptGlobalObject* aGlobalObject); /** * Return the window containing the document (the outer window). */ virtual nsPIDOMWindow *GetWindow(); /** * Get the script loader for this document */ Loading Loading @@ -678,7 +683,7 @@ protected: return kNameSpaceID_None; }; nsDocument() : nsIDocument(), mVisible(PR_TRUE) {} nsDocument(); virtual ~nsDocument(); nsCString mReferrer; Loading content/events/src/nsDOMEvent.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -518,7 +518,7 @@ NS_METHOD nsDOMEvent::SetTarget(nsIDOMEventTarget* aTarget) { nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aTarget); NS_ASSERTION(!win || win == win->GetOuterWindow(), NS_ASSERTION(!win || !win->IsInnerWindow(), "Uh, inner window set as event target!"); } #endif Loading @@ -533,7 +533,7 @@ NS_METHOD nsDOMEvent::SetCurrentTarget(nsIDOMEventTarget* aCurrentTarget) { nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aCurrentTarget); NS_ASSERTION(!win || win == win->GetOuterWindow(), NS_ASSERTION(!win || !win->IsInnerWindow(), "Uh, inner window set as event target!"); } #endif Loading @@ -548,7 +548,7 @@ NS_METHOD nsDOMEvent::SetOriginalTarget(nsIDOMEventTarget* aOriginalTarget) { nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aOriginalTarget); NS_ASSERTION(!win || win == win->GetOuterWindow(), NS_ASSERTION(!win || !win->IsInnerWindow(), "Uh, inner window set as event target!"); } #endif Loading content/events/src/nsEventListenerManager.cpp +4 −1 Original line number Diff line number Diff line Loading @@ -1184,9 +1184,12 @@ nsEventListenerManager::AddScriptEventListener(nsISupports *aObject, scope = global->GetGlobalJSObject(); } } else { nsCOMPtr<nsIDOMWindow> win(do_QueryInterface(aObject)); nsCOMPtr<nsPIDOMWindow> win(do_QueryInterface(aObject)); nsCOMPtr<nsIScriptGlobalObject> global; if (win) { NS_ASSERTION(win->IsInnerWindow(), "Event listener added to outer window!"); nsCOMPtr<nsIDOMDocument> domdoc; win->GetDocument(getter_AddRefs(domdoc)); doc = do_QueryInterface(domdoc); Loading Loading
content/base/public/nsIDocument.h +6 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,7 @@ class nsIStyleSheet; class nsIStyleRule; class nsIViewManager; class nsIScriptGlobalObject; class nsPIDOMWindow; class nsIDOMEvent; class nsIDeviceContext; class nsIParser; Loading Loading @@ -472,6 +473,11 @@ public: virtual nsIScriptGlobalObject* GetScriptGlobalObject() const = 0; virtual void SetScriptGlobalObject(nsIScriptGlobalObject* aGlobalObject) = 0; /** * Return the window containing the document (the outer window). */ virtual nsPIDOMWindow *GetWindow() = 0; /** * Get the script loader for this document */ Loading
content/base/src/nsDocument.cpp +33 −3 Original line number Diff line number Diff line Loading @@ -697,6 +697,12 @@ NS_IMPL_RELEASE_USING_AGGREGATOR(nsXPathDocumentTearoff, mDocument) // NOTE! nsDocument::operator new() zeroes out all members, so don't // bother initializing members to 0. nsDocument::nsDocument() : nsIDocument(), mVisible(PR_TRUE) { } nsDocument::~nsDocument() { mInDestructor = PR_TRUE; Loading Loading @@ -2043,6 +2049,15 @@ nsDocument::GetScriptGlobalObject() const void nsDocument::SetScriptGlobalObject(nsIScriptGlobalObject *aScriptGlobalObject) { #ifdef DEBUG { nsCOMPtr<nsPIDOMWindow> win(do_QueryInterface(aScriptGlobalObject)); NS_ASSERTION(!win || win->IsInnerWindow(), "Script global object must be an inner window!"); } #endif if (mScriptGlobalObject && !aScriptGlobalObject) { // We're detaching from the window. We need to grab a pointer to // our layout history state now. Loading @@ -2057,6 +2072,18 @@ nsDocument::SetScriptGlobalObject(nsIScriptGlobalObject *aScriptGlobalObject) } } nsPIDOMWindow * nsDocument::GetWindow() { nsCOMPtr<nsPIDOMWindow> win(do_QueryInterface(GetScriptGlobalObject())); if (!win) { return nsnull; } return win->GetOuterWindow(); } nsIScriptLoader * nsDocument::GetScriptLoader() { Loading Loading @@ -3037,11 +3064,14 @@ nsDocument::GetDefaultView(nsIDOMAbstractView** aDefaultView) if (win) { // The default view is our outer window. if (!win->IsInnerWindow()) { return NS_ERROR_UNEXPECTED; nsPIDOMWindow *outer = win->GetOuterWindow(); if (outer) { return CallQueryInterface(outer, aDefaultView); } return CallQueryInterface(win->GetOuterWindow(), aDefaultView); // Fall through here and return null in case our window no longer // has an outer window. } return NS_OK; Loading
content/base/src/nsDocument.h +6 −1 Original line number Diff line number Diff line Loading @@ -450,6 +450,11 @@ public: virtual nsIScriptGlobalObject* GetScriptGlobalObject() const; virtual void SetScriptGlobalObject(nsIScriptGlobalObject* aGlobalObject); /** * Return the window containing the document (the outer window). */ virtual nsPIDOMWindow *GetWindow(); /** * Get the script loader for this document */ Loading Loading @@ -678,7 +683,7 @@ protected: return kNameSpaceID_None; }; nsDocument() : nsIDocument(), mVisible(PR_TRUE) {} nsDocument(); virtual ~nsDocument(); nsCString mReferrer; Loading
content/events/src/nsDOMEvent.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -518,7 +518,7 @@ NS_METHOD nsDOMEvent::SetTarget(nsIDOMEventTarget* aTarget) { nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aTarget); NS_ASSERTION(!win || win == win->GetOuterWindow(), NS_ASSERTION(!win || !win->IsInnerWindow(), "Uh, inner window set as event target!"); } #endif Loading @@ -533,7 +533,7 @@ NS_METHOD nsDOMEvent::SetCurrentTarget(nsIDOMEventTarget* aCurrentTarget) { nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aCurrentTarget); NS_ASSERTION(!win || win == win->GetOuterWindow(), NS_ASSERTION(!win || !win->IsInnerWindow(), "Uh, inner window set as event target!"); } #endif Loading @@ -548,7 +548,7 @@ NS_METHOD nsDOMEvent::SetOriginalTarget(nsIDOMEventTarget* aOriginalTarget) { nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aOriginalTarget); NS_ASSERTION(!win || win == win->GetOuterWindow(), NS_ASSERTION(!win || !win->IsInnerWindow(), "Uh, inner window set as event target!"); } #endif Loading
content/events/src/nsEventListenerManager.cpp +4 −1 Original line number Diff line number Diff line Loading @@ -1184,9 +1184,12 @@ nsEventListenerManager::AddScriptEventListener(nsISupports *aObject, scope = global->GetGlobalJSObject(); } } else { nsCOMPtr<nsIDOMWindow> win(do_QueryInterface(aObject)); nsCOMPtr<nsPIDOMWindow> win(do_QueryInterface(aObject)); nsCOMPtr<nsIScriptGlobalObject> global; if (win) { NS_ASSERTION(win->IsInnerWindow(), "Event listener added to outer window!"); nsCOMPtr<nsIDOMDocument> domdoc; win->GetDocument(getter_AddRefs(domdoc)); doc = do_QueryInterface(domdoc); Loading