Bug 653839. Don't call DidPaint on hidden documents. This just does for DidPaint what bug 594267 did for WillPaint. r=roc
authorTimothy Nikkel <tnikkel@gmail.com>
Sun, 01 May 2011 20:59:15 +0200
changeset 68825 38d6807354e9578cf0094dcb28f489c7ba1b8718
parent 68824 8ff1e817d45ed23628354c871bbed4697596d735
child 68826 1e7f4ce5636f6ceaa96a9aeb08655cd6101279b9
push idunknown
push userunknown
push dateunknown
reviewersroc
bugs653839, 594267
milestone6.0a1
Bug 653839. Don't call DidPaint on hidden documents. This just does for DidPaint what bug 594267 did for WillPaint. r=roc
layout/base/nsPresShell.cpp
view/src/nsViewManager.cpp
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -7356,16 +7356,20 @@ PresShell::WillPaint(PRBool aWillSendDid
   // interruptible; if we can't do all the reflows it's better to flicker a bit
   // than to freeze up.
   FlushPendingNotifications(Flush_InterruptibleLayout);
 }
 
 NS_IMETHODIMP_(void)
 PresShell::DidPaint()
 {
+  if (mPaintingSuppressed || !mIsActive) {
+    return;
+  }
+
   nsRootPresContext* rootPresContext = mPresContext->GetRootPresContext();
   if (!rootPresContext) {
     return;
   }
   if (rootPresContext == mPresContext) {
     rootPresContext->UpdatePluginGeometry();
   }
 }
--- a/view/src/nsViewManager.cpp
+++ b/view/src/nsViewManager.cpp
@@ -1689,19 +1689,21 @@ nsViewManager::CallDidPaintOnObservers()
 {
   NS_PRECONDITION(IsRootVM(), "Must be root VM for this to be called!");
 
   PRInt32 index;
   for (index = 0; index < mVMCount; index++) {
     nsViewManager* vm = (nsViewManager*)gViewManagers->ElementAt(index);
     if (vm->RootViewManager() == this) {
       // One of our kids.
-      nsCOMPtr<nsIViewObserver> obs = vm->GetViewObserver();
-      if (obs) {
-        obs->DidPaint();
+      if (vm->mRootView && vm->mRootView->IsEffectivelyVisible()) {
+        nsCOMPtr<nsIViewObserver> obs = vm->GetViewObserver();
+        if (obs) {
+          obs->DidPaint();
+        }
       }
     }
   }
 }
 
 void
 nsViewManager::ProcessInvalidateEvent()
 {