Bug 805745. Move the forced repaint from the Paint notification to the WillPaint notification. r=mattwoodrow
authorTimothy Nikkel <tnikkel@gmail.com>
Wed, 12 Dec 2012 15:57:08 -0600
changeset 121418 9f6c579151c5c61b9b213d7027633f90238c161c
parent 121417 b7a58a0e50664f4ffed5f5eea86c7f69acb56644
child 121419 789e54325d765bb01d6d2c3b1a2b530cb1b93999
push idunknown
push userunknown
push dateunknown
reviewersmattwoodrow
bugs805745
milestone20.0a1
Bug 805745. Move the forced repaint from the Paint notification to the WillPaint notification. r=mattwoodrow
view/src/nsViewManager.cpp
--- a/view/src/nsViewManager.cpp
+++ b/view/src/nsViewManager.cpp
@@ -330,21 +330,16 @@ void nsViewManager::Refresh(nsView *aVie
     nsRect viewRect = aView->GetDimensions();
     nsRect damageRect = damageRegion.GetBounds();
     printf("XXX Damage rectangle (%d,%d,%d,%d) does not intersect the widget's view (%d,%d,%d,%d)!\n",
            damageRect.x, damageRect.y, damageRect.width, damageRect.height,
            viewRect.x, viewRect.y, viewRect.width, viewRect.height);
 #endif
     return;
   }
-
-  if (aView->ForcedRepaint() && IsRefreshDriverPaintingEnabled()) {
-    ProcessPendingUpdates();
-    aView->SetForcedRepaint(false);
-  }
   
   nsIWidget *widget = aView->GetWidget();
   if (!widget) {
     return;
   }
 
   NS_ASSERTION(!IsPainting(), "recursive painting not permitted");
   if (IsPainting()) {
@@ -670,16 +665,29 @@ void nsViewManager::WillPaintWindow(nsIW
     // Flush things like reflows by calling WillPaint on observer presShells.
     nsRefPtr<nsViewManager> rootVM = RootViewManager();
     rootVM->CallWillPaintOnObservers(aWillSendDidPaint);
 
     // Flush view widget geometry updates and invalidations.
     rootVM->ProcessPendingUpdates();
   }
 
+  if (aWidget && IsRefreshDriverPaintingEnabled()) {
+    nsView* view = nsView::GetViewFor(aWidget);
+    if (view && view->ForcedRepaint()) {
+      ProcessPendingUpdates();
+      // Re-get the view pointer here since the ProcessPendingUpdates might have
+      // destroyed it during CallWillPaintOnObservers.
+      view = nsView::GetViewFor(aWidget);
+      if (view) {
+        view->SetForcedRepaint(false);
+      }
+    }
+  }
+
   nsCOMPtr<nsIPresShell> shell = mPresShell;
   if (shell) {
     shell->WillPaintWindow(aWillSendDidPaint);
   }
 }
 
 bool nsViewManager::PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion,
                                 uint32_t aFlags)