diff --git a/content/base/public/nsIDocument.h b/content/base/public/nsIDocument.h index cac8f5804b77..8adc104f7807 100644 --- a/content/base/public/nsIDocument.h +++ b/content/base/public/nsIDocument.h @@ -93,8 +93,8 @@ class nsIDOMUserDataHandler; // IID for the nsIDocument interface #define NS_IDOCUMENT_IID \ -{ 0x65d26965, 0x8fed, 0x4f55, \ - { 0x80, 0xef, 0xaa, 0xd0, 0x1d, 0xd6, 0x92, 0xfd } } +{ 0xbcb48147, 0xed60, 0x490e, \ + { 0xa2, 0x47, 0xe2, 0x35, 0x3c, 0xf7, 0xc8, 0x68 } } // Flag for AddStyleSheet(). #define NS_STYLESHEET_FROM_CATALOG (1 << 0) @@ -506,6 +506,13 @@ public: */ virtual nsPIDOMWindow *GetWindow() = 0; + /** + * Return the inner window used as the script compilation scope for + * this document. If you're not absolutely sure you need this, use + * GetWindow(). + */ + virtual nsPIDOMWindow *GetInnerWindow() = 0; + /** * Get the script loader for this document */ diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index a93efdf67d20..21fa6dce0fb1 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -2023,6 +2023,14 @@ nsDocument::GetWindow() return win->GetOuterWindow(); } +nsPIDOMWindow * +nsDocument::GetInnerWindow() +{ + nsCOMPtr win(do_QueryInterface(GetScriptGlobalObject())); + + return win; +} + nsIScriptLoader * nsDocument::GetScriptLoader() { diff --git a/content/base/src/nsDocument.h b/content/base/src/nsDocument.h index 3a20331c7c46..0fa64bfc7bac 100644 --- a/content/base/src/nsDocument.h +++ b/content/base/src/nsDocument.h @@ -455,6 +455,13 @@ public: */ virtual nsPIDOMWindow *GetWindow(); + /** + * Return the inner window used as the script compilation scope for + * this document. If you're not absolutely sure you need this, use + * GetWindow(). + */ + virtual nsPIDOMWindow *GetInnerWindow(); + /** * Get the script loader for this document */ diff --git a/content/events/src/nsEventListenerManager.cpp b/content/events/src/nsEventListenerManager.cpp index f5cd782136db..b04f4bc16b7a 100644 --- a/content/events/src/nsEventListenerManager.cpp +++ b/content/events/src/nsEventListenerManager.cpp @@ -740,7 +740,7 @@ nsEventListenerManager::AddEventListener(nsIDOMEventListener *aListener, document = content->GetOwnerDoc(); else document = do_QueryInterface(mTarget); if (document) - window = document->GetWindow(); + window = document->GetInnerWindow(); else window = do_QueryInterface(mTarget); if (window) { NS_ASSERTION(window->IsInnerWindow(), diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index 7d4c190b6bae..201a9e5cf56c 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -1735,8 +1735,7 @@ nsGenericHTMLElement::GetEventListenerManagerForAttr(nsIEventListenerManager** a // override BindToTree for those classes and munge event listeners there? nsIDocument *document = GetOwnerDoc(); nsresult rv = NS_OK; - if (document && (win = document->GetWindow()) && - (win = win->GetCurrentInnerWindow())) { + if (document && (win = document->GetInnerWindow())) { nsCOMPtr receiver(do_QueryInterface(win)); NS_ENSURE_TRUE(receiver, NS_ERROR_FAILURE); diff --git a/content/xul/content/src/nsXULElement.cpp b/content/xul/content/src/nsXULElement.cpp index 7dbb28e4c0af..df577946837d 100644 --- a/content/xul/content/src/nsXULElement.cpp +++ b/content/xul/content/src/nsXULElement.cpp @@ -565,10 +565,7 @@ nsXULElement::GetEventListenerManagerForAttr(nsIEventListenerManager** aManager, nsIContent *root = doc->GetRootContent(); if ((!root || root == this) && !mNodeInfo->Equals(nsXULAtoms::overlay)) { - nsPIDOMWindow *window = doc->GetWindow(); - - if (!window || !(window = window->GetCurrentInnerWindow())) - return NS_ERROR_UNEXPECTED; + nsPIDOMWindow *window = doc->GetInnerWindow(); nsCOMPtr receiver = do_QueryInterface(window); if (!receiver)