diff --git a/mozilla/content/base/src/nsDocument.cpp b/mozilla/content/base/src/nsDocument.cpp index dad7fef72d7..6a3e6e7709b 100644 --- a/mozilla/content/base/src/nsDocument.cpp +++ b/mozilla/content/base/src/nsDocument.cpp @@ -1126,7 +1126,7 @@ nsDocument::Init() // subclasses currently do, other don't). This is because the code in // nsNodeUtils always notifies the first observer first, expecting the // first observer to be the document. - NS_ENSURE_TRUE(slots->mMutationObservers.PrependElementUnlessExists(this), + NS_ENSURE_TRUE(slots->mMutationObservers.PrependElementUnlessExists(static_cast(this)), NS_ERROR_OUT_OF_MEMORY); @@ -2585,6 +2585,11 @@ nsDocument::SetScriptGlobalObject(nsIScriptGlobalObject *aScriptGlobalObject) mLayoutHistoryState = nsnull; mScopeObject = do_GetWeakReference(aScriptGlobalObject); } + + // Remember the pointer to our window (or lack there of), to avoid + // having to QI every time it's asked for. + nsCOMPtr window = do_QueryInterface(mScriptGlobalObject); + mWindow = window; } nsIScriptGlobalObject* @@ -2625,6 +2630,10 @@ nsDocument::SetScriptHandlingObject(nsIScriptGlobalObject* aScriptObject) nsPIDOMWindow * nsDocument::GetWindow() { + if (mWindow) { + return mWindow->GetOuterWindow(); + } + nsCOMPtr win(do_QueryInterface(GetScriptGlobalObject())); if (!win) { diff --git a/mozilla/content/base/src/nsDocument.h b/mozilla/content/base/src/nsDocument.h index 15997c3c12f..528bd2ed06d 100644 --- a/mozilla/content/base/src/nsDocument.h +++ b/mozilla/content/base/src/nsDocument.h @@ -747,6 +747,9 @@ protected: // document can get its script context and scope. This is the // *inner* window object. nsCOMPtr mScriptGlobalObject; + // Weak reference to mScriptGlobalObject QI:d to nsPIDOMWindow, + // updated on every set of mSecriptGlobalObject. + nsPIDOMWindow *mWindow; // If document is created for example using // document.implementation.createDocument(...), mScriptObject points to diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp index 58d5f017454..6be529a5418 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp @@ -3399,7 +3399,7 @@ nsHTMLDocument::ResolveName(const nsAString& aName, IdAndNameMapEntry *entry = static_cast (PL_DHashTableOperate(&mIdAndNameHashTable, name, - PL_DHASH_ADD)); + PL_DHASH_ADD)); NS_ENSURE_TRUE(entry, NS_ERROR_OUT_OF_MEMORY); if (entry->mNameContentList == NAME_NOT_VALID) { @@ -3419,7 +3419,7 @@ nsHTMLDocument::ResolveName(const nsAString& aName, // If we already have an entry->mNameContentList, we need to flush out // notifications too, so that it will get updated properly. FlushPendingNotifications(entry->mNameContentList ? - Flush_ContentAndNotify : Flush_Content); + Flush_ContentAndNotify : Flush_Content); if (generation != mIdAndNameHashTable.generation) { // Table changed, so the entry pointer is no longer valid; look up the @@ -3428,7 +3428,7 @@ nsHTMLDocument::ResolveName(const nsAString& aName, entry = static_cast (PL_DHashTableOperate(&mIdAndNameHashTable, name, - PL_DHASH_ADD)); + PL_DHASH_ADD)); NS_ENSURE_TRUE(entry, NS_ERROR_OUT_OF_MEMORY); } diff --git a/mozilla/dom/src/base/Makefile.in b/mozilla/dom/src/base/Makefile.in index 596954a5500..68d0de5eaaa 100644 --- a/mozilla/dom/src/base/Makefile.in +++ b/mozilla/dom/src/base/Makefile.in @@ -129,6 +129,8 @@ LOCAL_INCLUDES = \ -I$(topsrcdir)/content/xul/document/src \ -I$(topsrcdir)/content/events/src \ -I$(topsrcdir)/content/base/src \ + -I$(topsrcdir)/content/html/document/src \ + -I$(topsrcdir)/layout/style \ $(NULL) DEFINES += -D_IMPL_NS_LAYOUT diff --git a/mozilla/dom/src/base/nsDOMClassInfo.cpp b/mozilla/dom/src/base/nsDOMClassInfo.cpp index d939f658b9a..083f41b982e 100644 --- a/mozilla/dom/src/base/nsDOMClassInfo.cpp +++ b/mozilla/dom/src/base/nsDOMClassInfo.cpp @@ -132,7 +132,7 @@ #include "nsIDOMHTMLFormElement.h" #include "nsIDOMNSHTMLFormControlList.h" #include "nsIDOMHTMLCollection.h" -#include "nsIHTMLDocument.h" +#include "nsHTMLDocument.h" // HTMLSelectElement helper includes #include "nsIDOMHTMLSelectElement.h" @@ -7667,8 +7667,9 @@ nsHTMLDocumentSH::ResolveImpl(JSContext *cx, nsIXPConnectWrappedNative *wrapper, jsval id, nsISupports **result) { - nsCOMPtr doc(do_QueryWrappedNative(wrapper)); - NS_ENSURE_TRUE(doc, NS_ERROR_UNEXPECTED); + nsHTMLDocument *doc = + static_cast(static_cast + (wrapper->Native())); // 'id' is not always a string, it can be a number since document.1 // should map to . Thus we can't use @@ -8252,7 +8253,7 @@ nsHTMLDocumentSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx, if (id == sAll_id && !sDisableDocumentAllSupport && !ObjectIsNativeWrapper(cx, obj)) { - nsCOMPtr doc(do_QueryWrappedNative(wrapper)); + nsIDocument *doc = static_cast(wrapper->Native()); if (doc->GetCompatibilityMode() == eCompatibility_NavQuirks) { JSObject *helper =