Fixing topembed bug 106105. Clear our document.body cache when resetting a document, and make sure the right things are flushed when position and size related properties are accessed. r=heikki@netscape.com, sr=vidur@netscape.com

This commit is contained in:
jst%netscape.com 2001-10-31 23:52:52 +00:00
Родитель 3bcf4f269a
Коммит 56e34c4091
4 изменённых файлов: 89 добавлений и 17 удалений

Просмотреть файл

@ -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 <body> 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<nsIPresShell> shell;
nsresult result = NS_OK;
@ -2686,6 +2687,8 @@ nsHTMLDocument::GetHeight(PRInt32* aHeight)
{
NS_ENSURE_ARG_POINTER(aHeight);
FlushPendingNotifications();
nsCOMPtr<nsIPresShell> 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;
}

Просмотреть файл

@ -244,7 +244,7 @@ protected:
PRUint32 mIsWriting : 1;
PRUint32 mWriteLevel : 31;
nsIDOMNode * mBodyContent;
nsCOMPtr<nsIDOMNode> mBodyContent;
/*
* Bug 13871: Frameset spoofing - find out if document.domain was set

Просмотреть файл

@ -278,10 +278,10 @@ NS_IMETHODIMP GlobalWindowImpl::SetContext(nsIScriptContext* aContext)
mContext = aContext;
if (mContext) {
nsCOMPtr<nsIDOMWindow> parent;
GetParent(getter_AddRefs(parent));
nsCOMPtr<nsIDOMWindowInternal> 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 <frame src="javascript:xxx">, in
// that case the global window is used in JS before we've loaded
// a document into the window.
nsCOMPtr<nsIDOMWindow> parent;
nsCOMPtr<nsIDOMWindowInternal> parent;
GetParent(getter_AddRefs(parent));
GetParentInternal(getter_AddRefs(parent));
if (parent && (parent.get() != NS_STATIC_CAST(nsIDOMWindow *, this))) {
if (parent) {
nsCOMPtr<nsIScriptObjectPrincipal> objPrincipal(do_QueryInterface(parent));
if (objPrincipal) {
@ -1190,6 +1190,17 @@ GlobalWindowImpl::SetTitle(const nsAReadableString& aTitle)
NS_IMETHODIMP GlobalWindowImpl::GetInnerWidth(PRInt32* aInnerWidth)
{
nsCOMPtr<nsIDOMWindowInternal> parent;
GetParentInternal(getter_AddRefs(parent));
if (parent) {
PRInt32 dummy;
// Force a flush in the parent
parent->GetInnerWidth(&dummy);
}
FlushPendingNotifications();
nsCOMPtr<nsIBaseWindow> docShellWin(do_QueryInterface(mDocShell));
@ -1230,6 +1241,17 @@ NS_IMETHODIMP GlobalWindowImpl::SetInnerWidth(PRInt32 aInnerWidth)
NS_IMETHODIMP GlobalWindowImpl::GetInnerHeight(PRInt32* aInnerHeight)
{
nsCOMPtr<nsIDOMWindowInternal> parent;
GetParentInternal(getter_AddRefs(parent));
if (parent) {
PRInt32 dummy;
// Force a flush in the parent
parent->GetInnerHeight(&dummy);
}
FlushPendingNotifications();
nsCOMPtr<nsIBaseWindow> docShellWin(do_QueryInterface(mDocShell));
@ -1271,6 +1293,17 @@ NS_IMETHODIMP GlobalWindowImpl::SetInnerHeight(PRInt32 aInnerHeight)
NS_IMETHODIMP GlobalWindowImpl::GetOuterWidth(PRInt32* aOuterWidth)
{
nsCOMPtr<nsIDOMWindowInternal> parent;
GetParentInternal(getter_AddRefs(parent));
if (parent) {
PRInt32 dummy;
// Force a flush in the parent
parent->GetOuterWidth(&dummy);
}
nsCOMPtr<nsIBaseWindow> 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<nsIDOMWindowInternal> parent;
GetParentInternal(getter_AddRefs(parent));
if (parent) {
PRInt32 dummy;
// Force a flush in the parent
parent->GetOuterHeight(&dummy);
}
nsCOMPtr<nsIBaseWindow> 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<nsIDOMWindow> 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<nsIDOMWindowInternal> 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();

Просмотреть файл

@ -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,