diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp
index bb247cbd2fc..d7e8016fd48 100644
--- a/mozilla/content/html/document/src/nsHTMLDocument.cpp
+++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp
@@ -231,7 +231,6 @@ nsHTMLDocument::nsHTMLDocument()
mCSSLoader = nsnull;
mDocWriteDummyRequest = nsnull;
- mBodyContent = nsnull;
mForms = nsnull;
mIsWriting = 0;
mWriteLevel = 0;
@@ -291,8 +290,6 @@ nsHTMLDocument::~nsHTMLDocument()
mCSSLoader->DropDocumentReference(); // release weak ref
}
- NS_IF_RELEASE(mBodyContent);
-
if (--gRefCntRDFService == 0)
{
nsServiceManager::ReleaseService("@mozilla.org/rdf/rdf-service;1", gRDF);
@@ -337,6 +334,8 @@ nsHTMLDocument::Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup)
NS_IF_RELEASE(mAnchors);
NS_IF_RELEASE(mLayers);
+ mBodyContent = nsnull;
+
mImageMaps.Clear();
NS_IF_RELEASE(mForms);
@@ -1828,7 +1827,7 @@ nsHTMLDocument::SetBody(nsIDOMHTMLElement* aBody)
nsresult rv = root->ReplaceChild(aBody, child, getter_AddRefs(ret));
- NS_IF_RELEASE(mBodyContent);
+ mBodyContent = nsnull;
return rv;
}
@@ -2603,7 +2602,7 @@ nsHTMLDocument::GetPixelDimensions(nsIPresShell* aShell,
// Find the
element: this is what we'll want to use for the
// document's width and height values.
- if (mBodyContent == nsnull && PR_FALSE == GetBodyContent()) {
+ if (!mBodyContent && PR_FALSE == GetBodyContent()) {
return NS_OK;
}
@@ -2664,6 +2663,8 @@ nsHTMLDocument::GetWidth(PRInt32* aWidth)
{
NS_ENSURE_ARG_POINTER(aWidth);
+ FlushPendingNotifications();
+
nsCOMPtr shell;
nsresult result = NS_OK;
@@ -2686,6 +2687,8 @@ nsHTMLDocument::GetHeight(PRInt32* aHeight)
{
NS_ENSURE_ARG_POINTER(aHeight);
+ FlushPendingNotifications();
+
nsCOMPtr shell;
nsresult result = NS_OK;
@@ -3525,7 +3528,7 @@ nsHTMLDocument::GetBodyContent()
NS_IMETHODIMP
nsHTMLDocument::GetBodyElement(nsIDOMHTMLBodyElement** aBody)
{
- if (mBodyContent == nsnull && PR_FALSE == GetBodyContent()) {
+ if (!mBodyContent && PR_FALSE == GetBodyContent()) {
return NS_ERROR_FAILURE;
}
diff --git a/mozilla/content/html/document/src/nsHTMLDocument.h b/mozilla/content/html/document/src/nsHTMLDocument.h
index 7ebea0f4ade..18f0455940f 100644
--- a/mozilla/content/html/document/src/nsHTMLDocument.h
+++ b/mozilla/content/html/document/src/nsHTMLDocument.h
@@ -244,7 +244,7 @@ protected:
PRUint32 mIsWriting : 1;
PRUint32 mWriteLevel : 31;
- nsIDOMNode * mBodyContent;
+ nsCOMPtr mBodyContent;
/*
* Bug 13871: Frameset spoofing - find out if document.domain was set
diff --git a/mozilla/dom/src/base/nsGlobalWindow.cpp b/mozilla/dom/src/base/nsGlobalWindow.cpp
index c763fe90bf9..30eb60ac6dc 100644
--- a/mozilla/dom/src/base/nsGlobalWindow.cpp
+++ b/mozilla/dom/src/base/nsGlobalWindow.cpp
@@ -278,10 +278,10 @@ NS_IMETHODIMP GlobalWindowImpl::SetContext(nsIScriptContext* aContext)
mContext = aContext;
if (mContext) {
- nsCOMPtr parent;
- GetParent(getter_AddRefs(parent));
+ nsCOMPtr parent;
+ GetParentInternal(getter_AddRefs(parent));
- if (parent && parent != NS_STATIC_CAST(nsIDOMWindow *, this)) {
+ if (parent) {
// This window is a [i]frame, don't bother GC'ing when the
// frame's context is destroyed since a GC will happen when the
// frameset or host document is destroyed anyway.
@@ -727,11 +727,11 @@ NS_IMETHODIMP GlobalWindowImpl::GetPrincipal(nsIPrincipal** result)
// loading a frameset that has a , in
// that case the global window is used in JS before we've loaded
// a document into the window.
- nsCOMPtr parent;
+ nsCOMPtr parent;
- GetParent(getter_AddRefs(parent));
+ GetParentInternal(getter_AddRefs(parent));
- if (parent && (parent.get() != NS_STATIC_CAST(nsIDOMWindow *, this))) {
+ if (parent) {
nsCOMPtr objPrincipal(do_QueryInterface(parent));
if (objPrincipal) {
@@ -1190,6 +1190,17 @@ GlobalWindowImpl::SetTitle(const nsAReadableString& aTitle)
NS_IMETHODIMP GlobalWindowImpl::GetInnerWidth(PRInt32* aInnerWidth)
{
+ nsCOMPtr parent;
+
+ GetParentInternal(getter_AddRefs(parent));
+
+ if (parent) {
+ PRInt32 dummy;
+
+ // Force a flush in the parent
+ parent->GetInnerWidth(&dummy);
+ }
+
FlushPendingNotifications();
nsCOMPtr docShellWin(do_QueryInterface(mDocShell));
@@ -1230,6 +1241,17 @@ NS_IMETHODIMP GlobalWindowImpl::SetInnerWidth(PRInt32 aInnerWidth)
NS_IMETHODIMP GlobalWindowImpl::GetInnerHeight(PRInt32* aInnerHeight)
{
+ nsCOMPtr parent;
+
+ GetParentInternal(getter_AddRefs(parent));
+
+ if (parent) {
+ PRInt32 dummy;
+
+ // Force a flush in the parent
+ parent->GetInnerHeight(&dummy);
+ }
+
FlushPendingNotifications();
nsCOMPtr docShellWin(do_QueryInterface(mDocShell));
@@ -1271,6 +1293,17 @@ NS_IMETHODIMP GlobalWindowImpl::SetInnerHeight(PRInt32 aInnerHeight)
NS_IMETHODIMP GlobalWindowImpl::GetOuterWidth(PRInt32* aOuterWidth)
{
+ nsCOMPtr parent;
+
+ GetParentInternal(getter_AddRefs(parent));
+
+ if (parent) {
+ PRInt32 dummy;
+
+ // Force a flush in the parent
+ parent->GetOuterWidth(&dummy);
+ }
+
nsCOMPtr treeOwnerAsWin;
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
@@ -1303,6 +1336,17 @@ NS_IMETHODIMP GlobalWindowImpl::SetOuterWidth(PRInt32 aOuterWidth)
NS_IMETHODIMP GlobalWindowImpl::GetOuterHeight(PRInt32* aOuterHeight)
{
+ nsCOMPtr parent;
+
+ GetParentInternal(getter_AddRefs(parent));
+
+ if (parent) {
+ PRInt32 dummy;
+
+ // Force a flush in the parent
+ parent->GetOuterHeight(&dummy);
+ }
+
nsCOMPtr treeOwnerAsWin;
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
@@ -1339,8 +1383,6 @@ NS_IMETHODIMP GlobalWindowImpl::GetScreenX(PRInt32* aScreenX)
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
- FlushPendingNotifications();
-
PRInt32 y;
NS_ENSURE_SUCCESS(treeOwnerAsWin->GetPosition(aScreenX, &y),
@@ -1374,8 +1416,6 @@ NS_IMETHODIMP GlobalWindowImpl::GetScreenY(PRInt32* aScreenY)
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
- FlushPendingNotifications();
-
PRInt32 x;
NS_ENSURE_SUCCESS(treeOwnerAsWin->GetPosition(&x, aScreenY),
@@ -3306,6 +3346,21 @@ NS_IMETHODIMP GlobalWindowImpl::GetInterface(const nsIID & aIID, void **aSink)
// GlobalWindowImpl: Window Control Functions
//*****************************************************************************
+void
+GlobalWindowImpl::GetParentInternal(nsIDOMWindowInternal **aParent)
+{
+ *aParent = nsnull;
+
+ nsCOMPtr parent;
+
+ GetParent(getter_AddRefs(parent));
+
+ if (parent && parent != NS_STATIC_CAST(nsIDOMWindow *, this)) {
+ CallQueryInterface(parent, aParent);
+ NS_ASSERTION(*aParent, "Huh, parent not an nsIDOMWindowInternal?");
+ }
+}
+
NS_IMETHODIMP
GlobalWindowImpl::OpenInternal(const nsAReadableString& aUrl,
const nsAReadableString& aName,
@@ -4096,6 +4151,17 @@ GlobalWindowImpl::GetScrollInfo(nsIScrollableView **aScrollableView,
{
*aScrollableView = nsnull;
+ nsCOMPtr parent;
+
+ GetParentInternal(getter_AddRefs(parent));
+
+ if (parent) {
+ PRInt32 dummy;
+
+ // Force a flush in the parent
+ parent->GetScrollX(&dummy);
+ }
+
// Flush pending notifications so that the presentation is up to
// date.
FlushPendingNotifications();
diff --git a/mozilla/dom/src/base/nsGlobalWindow.h b/mozilla/dom/src/base/nsGlobalWindow.h
index 7da5b6a601e..cce6e8a7e7b 100644
--- a/mozilla/dom/src/base/nsGlobalWindow.h
+++ b/mozilla/dom/src/base/nsGlobalWindow.h
@@ -201,6 +201,9 @@ protected:
virtual ~GlobalWindowImpl();
void CleanUp();
+ // Get the parent, returns null if this is a toplevel window
+ void GetParentInternal(nsIDOMWindowInternal **parent);
+
// Window Control Functions
NS_IMETHOD OpenInternal(const nsAReadableString& aUrl,
const nsAReadableString& aName,