Bug 468991. Move GetVisibleArea call to avoid using a stale visible area. r+sr=dbaron
authorRobert O'Callahan <robert@ocallahan.org>
Thu, 18 Dec 2008 14:21:12 +1300
changeset 22888 71f2ef5bdb40eea55b8a8307aa74ec539e444216
parent 22887 8ab5a111e00b8bf8c4e4b103891fead3ad565f13
child 22889 d92586bc82f6049fb8b0538a7e07b23902d976c3
push idunknown
push userunknown
push dateunknown
bugs468991
milestone1.9.2a1pre
Bug 468991. Move GetVisibleArea call to avoid using a stale visible area. r+sr=dbaron
content/xul/document/src/nsXULDocument.cpp
--- a/content/xul/document/src/nsXULDocument.cpp
+++ b/content/xul/document/src/nsXULDocument.cpp
@@ -2001,18 +2001,16 @@ nsXULDocument::StartLayout(void)
         if (! container)
             return NS_ERROR_UNEXPECTED;
 
         nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(container));
         NS_ASSERTION(docShell != nsnull, "container is not a docshell");
         if (! docShell)
             return NS_ERROR_UNEXPECTED;
 
-        nsRect r = cx->GetVisibleArea();
-
         // Trigger a refresh before the call to InitialReflow(),
         // because the view manager's UpdateView() function is
         // dropping dirty rects if refresh is disabled rather than
         // accumulating them until refresh is enabled and then
         // triggering a repaint...
         // XXXbz Is that still the case?
         nsresult rv = NS_OK;
         nsIViewManager* vm = shell->GetViewManager();
@@ -2024,17 +2022,21 @@ nsXULDocument::StartLayout(void)
                 contentViewer->GetEnableRendering(&enabled);
                 if (enabled) {
                     vm->EnableRefresh(NS_VMREFRESH_IMMEDIATE);
                 }
             }
         }
 
         mMayStartLayout = PR_TRUE;
-        
+
+        // Don't try to call GetVisibleArea earlier than this --- the EnableRefresh call
+        // above can flush reflows, which can cause a parent document to be flushed,
+        // calling ResizeReflow on our document which does SetVisibleArea.
+        nsRect r = cx->GetVisibleArea();
         // Make sure we're holding a strong ref to |shell| before we call
         // InitialReflow()
         nsCOMPtr<nsIPresShell> shellGrip = shell;
         rv = shell->InitialReflow(r.width, r.height);
         NS_ENSURE_SUCCESS(rv, rv);
     }
 
     return NS_OK;