Fixing bug 115352. Making FlushPendingNotifications() properly flush the parent document as well if there is one. This causes layout data in iframes to not always be up to date since iframe sizes are dependent on the parent being reflown. r=peterv@netscape.com, sr=rpotts@netscape.com

This commit is contained in:
jst%netscape.com 2002-02-05 05:47:22 +00:00
Родитель 4efc3ec90e
Коммит c628cca2e5
4 изменённых файлов: 77 добавлений и 116 удалений

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

@ -3465,7 +3465,37 @@ NS_IMETHODIMP
nsDocument::FlushPendingNotifications(PRBool aFlushReflows,
PRBool aUpdateViews)
{
if (aFlushReflows) {
if (aFlushReflows && mScriptGlobalObject) {
// We should be able to replace all this nsIDocShell* code with
// code that uses mParentDocument, but mParentDocument is never
// set in the current code!
nsCOMPtr<nsIDocShell> docShell;
mScriptGlobalObject->GetDocShell(getter_AddRefs(docShell));
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem =
do_QueryInterface(docShell);
if (docShellAsItem) {
nsCOMPtr<nsIDocShellTreeItem> docShellParent;
docShellAsItem->GetSameTypeParent(getter_AddRefs(docShellParent));
nsCOMPtr<nsIDOMWindow> win(do_GetInterface(docShellParent));
if (win) {
nsCOMPtr<nsIDOMDocument> dom_doc;
win->GetDocument(getter_AddRefs(dom_doc));
nsCOMPtr<nsIDocument> doc(do_QueryInterface(dom_doc));
if (doc) {
// If we have a parent we must flush the parent too to ensure
// that our container is reflown if its size was changed.
doc->FlushPendingNotifications(aFlushReflows, aUpdateViews);
}
}
}
PRInt32 i, count = mPresShells.Count();

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

@ -283,7 +283,7 @@ IdAndNameHashInitEntry(PLDHashTable *table, PLDHashEntryHdr *entry,
const nsAString *keyStr = NS_STATIC_CAST(const nsAString *, key);
// Inititlize the entry with placement new
IdAndNameMapEntry *e = new (entry) IdAndNameMapEntry(*keyStr);
new (entry) IdAndNameMapEntry(*keyStr);
}
nsHTMLDocument::nsHTMLDocument()
@ -558,7 +558,7 @@ nsHTMLDocument::TryUserForcedCharset(nsIMarkupDocumentViewer* aMarkupDV,
PRInt32& aCharsetSource,
nsAString& aCharset)
{
nsresult rv;
nsresult rv = NS_OK;
if(kCharsetFromUserForced <= aCharsetSource)
return PR_TRUE;
@ -567,7 +567,7 @@ nsHTMLDocument::TryUserForcedCharset(nsIMarkupDocumentViewer* aMarkupDV,
if (aMarkupDV)
rv = aMarkupDV->GetForceCharacterSet(&forceCharsetFromWebShell);
if(NS_SUCCEEDED(rv) && (nsnull != forceCharsetFromWebShell))
if(NS_SUCCEEDED(rv) && forceCharsetFromWebShell)
{
aCharset = forceCharsetFromWebShell;
Recycle(forceCharsetFromWebShell);
@ -2889,48 +2889,44 @@ NS_IMETHODIMP
nsHTMLDocument::GetWidth(PRInt32* aWidth)
{
NS_ENSURE_ARG_POINTER(aWidth);
FlushPendingNotifications();
*aWidth = 0;
nsCOMPtr<nsIPresShell> shell;
nsresult result = NS_OK;
// We make the assumption that the first presentation shell
// is the one for which we need information.
GetShellAt(0, getter_AddRefs(shell));
if (shell) {
PRInt32 width, height;
if (!shell) {
return NS_OK;
}
result = GetPixelDimensions(shell, &width, &height);
*aWidth = width;
} else
*aWidth = 0;
PRInt32 dummy;
return result;
// GetPixelDimensions() does the flushing for us, no need to flush
// here too
return GetPixelDimensions(shell, aWidth, &dummy);
}
NS_IMETHODIMP
NS_IMETHODIMP
nsHTMLDocument::GetHeight(PRInt32* aHeight)
{
NS_ENSURE_ARG_POINTER(aHeight);
FlushPendingNotifications();
*aHeight = 0;
nsCOMPtr<nsIPresShell> shell;
nsresult result = NS_OK;
// We make the assumption that the first presentation shell
// is the one for which we need information.
GetShellAt(0, getter_AddRefs(shell));
if (shell) {
PRInt32 width, height;
if (!shell) {
return NS_OK;
}
result = GetPixelDimensions(shell, &width, &height);
*aHeight = height;
} else
*aHeight = 0;
PRInt32 dummy;
return result;
// GetPixelDimensions() does the flushing for us, no need to flush
// here too
return GetPixelDimensions(shell, &dummy, aHeight);
}
NS_IMETHODIMP
@ -3264,21 +3260,6 @@ nsHTMLDocument::GetCompatMode(nsAWritableString& aCompatMode)
return NS_OK;
}
static PRBool PR_CALLBACK
NameHashCleanupEnumeratorCallback(nsHashKey *aKey, void *aData, void* closure)
{
nsBaseContentList *list = (nsBaseContentList *)aData;
// The document this hash is in is most likely going away so we
// reset the live nodelists to avoid leaving dangling pointers to
// non-existing content
list->Reset();
NS_RELEASE(list);
return PR_TRUE;
}
PR_STATIC_CALLBACK(PLDHashOperator)
IdAndNameMapEntryRemoveCallback(PLDHashTable *table, PLDHashEntryHdr *hdr,
PRUint32 number, void *arg)

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

@ -1213,18 +1213,7 @@ 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();
FlushPendingNotifications(PR_TRUE);
nsCOMPtr<nsIBaseWindow> docShellWin(do_QueryInterface(mDocShell));
*aInnerWidth = 0;
@ -1264,18 +1253,7 @@ 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();
FlushPendingNotifications(PR_TRUE);
nsCOMPtr<nsIBaseWindow> docShellWin(do_QueryInterface(mDocShell));
*aInnerHeight = 0;
@ -1316,22 +1294,11 @@ 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);
FlushPendingNotifications();
FlushPendingNotifications(PR_TRUE);
NS_ENSURE_SUCCESS(treeOwnerAsWin->GetSize(aOuterWidth, nsnull),
NS_ERROR_FAILURE);
@ -1359,22 +1326,11 @@ 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);
FlushPendingNotifications();
FlushPendingNotifications(PR_TRUE);
NS_ENSURE_SUCCESS(treeOwnerAsWin->GetSize(nsnull, aOuterHeight),
NS_ERROR_FAILURE);
@ -1516,7 +1472,7 @@ GlobalWindowImpl::CheckSecurityLeftAndTop(PRInt32* aLeft, PRInt32* aTop)
PRInt32 screenLeft, screenTop, screenWidth, screenHeight;
PRInt32 winLeft, winTop, winWidth, winHeight;
FlushPendingNotifications();
FlushPendingNotifications(PR_TRUE);
// Get the window size
nsCOMPtr<nsIBaseWindow> treeOwner;
@ -1671,19 +1627,24 @@ NS_IMETHODIMP GlobalWindowImpl::Dump(const nsAReadableString& aStr)
return NS_OK;
}
static void EnsureReflowFlushAndPaint(nsIDocShell* aDocShell)
void
GlobalWindowImpl::EnsureReflowFlushAndPaint()
{
if (!aDocShell)
return;
NS_ASSERTION(mDocShell, "EnsureReflowFlushAndPaint() called with no "
"docshell!");
nsCOMPtr<nsIPresShell> presShell;
aDocShell->GetPresShell(getter_AddRefs(presShell));
mDocShell->GetPresShell(getter_AddRefs(presShell));
if (!presShell)
return;
// Flush pending reflows.
presShell->FlushPendingNotifications(PR_FALSE);
nsCOMPtr<nsIDocument> doc(do_QueryInterface(mDocument));
if (doc) {
doc->FlushPendingNotifications(PR_TRUE, PR_FALSE);
}
// Unsuppress painting.
presShell->UnsuppressPainting();
@ -1732,7 +1693,7 @@ GlobalWindowImpl::Alert(const nsAReadableString& aString)
// Before bringing up the window, unsuppress painting and flush
// pending reflows.
EnsureReflowFlushAndPaint(mDocShell);
EnsureReflowFlushAndPaint();
return prompter->Alert(nsnull, str.get());
}
@ -1755,7 +1716,7 @@ GlobalWindowImpl::Confirm(const nsAReadableString& aString, PRBool* aReturn)
// Before bringing up the window, unsuppress painting and flush
// pending reflows.
EnsureReflowFlushAndPaint(mDocShell);
EnsureReflowFlushAndPaint();
return prompter->Confirm(nsnull, str.get(), aReturn);
}
@ -1782,7 +1743,7 @@ GlobalWindowImpl::Prompt(const nsAReadableString& aMessage,
// Before bringing up the window, unsuppress painting and flush
// pending reflows.
EnsureReflowFlushAndPaint(mDocShell);
EnsureReflowFlushAndPaint();
rv = prompter->Prompt(PromiseFlatString(aTitle).get(),
PromiseFlatString(aMessage).get(), nsnull,
@ -2510,7 +2471,7 @@ GlobalWindowImpl::GetFrames(nsIDOMWindow** aFrames)
*aFrames = this;
NS_ADDREF(*aFrames);
FlushPendingNotifications();
FlushPendingNotifications(PR_FALSE);
return NS_OK;
}
@ -4231,20 +4192,9 @@ 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();
FlushPendingNotifications(PR_TRUE);
nsCOMPtr<nsIPresContext> presContext;
mDocShell->GetPresContext(getter_AddRefs(presContext));
@ -4317,12 +4267,11 @@ GlobalWindowImpl::SecurityCheckURL(const char *aURL)
return NS_OK;
}
void GlobalWindowImpl::FlushPendingNotifications()
void GlobalWindowImpl::FlushPendingNotifications(PRBool aFlushReflows)
{
if (mDocument) {
nsCOMPtr<nsIDocument> doc(do_QueryInterface(mDocument));
if (doc)
doc->FlushPendingNotifications();
nsCOMPtr<nsIDocument> doc(do_QueryInterface(mDocument));
if (doc) {
doc->FlushPendingNotifications(aFlushReflows);
}
}

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

@ -233,7 +233,8 @@ protected:
nsresult SecurityCheckURL(const char *aURL);
PRBool CheckForAbusePoint();
void FlushPendingNotifications();
void FlushPendingNotifications(PRBool aFlushReflows);
void EnsureReflowFlushAndPaint();
nsresult CheckSecurityWidthAndHeight(PRInt32* width, PRInt32* height);
nsresult CheckSecurityLeftAndTop(PRInt32* left, PRInt32* top);