Bug 629823 - Use the right view manager for the parent view. r=tnikkel a=roc
authorMats Palmgren <matspal@gmail.com>
Thu, 10 Feb 2011 23:38:37 +0100
changeset 62313 0a9069e1e1b8335db1b4b32c6ef0a8565707e999
parent 62312 a28d7d3ce0f0e8ade62d477559fc9ae14f3a16d3
child 62314 502b2bea2c4de2b2a7d96ae40c18c38ccbb44fe0
push idunknown
push userunknown
push dateunknown
reviewerstnikkel, roc
bugs629823
milestone2.0b12pre
Bug 629823 - Use the right view manager for the parent view. r=tnikkel a=roc
view/src/nsViewManager.cpp
--- a/view/src/nsViewManager.cpp
+++ b/view/src/nsViewManager.cpp
@@ -1322,16 +1322,18 @@ void nsViewManager::InvalidateHorizontal
   if (aCutOut.XMost() < aRect.XMost()) {
     nsRect r(aCutOut.XMost(), aY1, aRect.XMost() - aCutOut.XMost(), height);
     UpdateView(aView, r, aUpdateFlags);
   }
 }
 
 void nsViewManager::InvalidateRectDifference(nsView *aView, const nsRect& aRect, const nsRect& aCutOut,
   PRUint32 aUpdateFlags) {
+  NS_ASSERTION(aView->GetViewManager() == this,
+               "InvalidateRectDifference called on view we don't own");
   if (aRect.y < aCutOut.y) {
     InvalidateHorizontalBandDifference(aView, aRect, aCutOut, aUpdateFlags, aRect.y, aCutOut.y, PR_FALSE);
   }
   if (aCutOut.y < aCutOut.YMost()) {
     InvalidateHorizontalBandDifference(aView, aRect, aCutOut, aUpdateFlags, aCutOut.y, aCutOut.YMost(), PR_TRUE);
   }
   if (aCutOut.YMost() < aRect.YMost()) {
     InvalidateHorizontalBandDifference(aView, aRect, aCutOut, aUpdateFlags, aCutOut.YMost(), aRect.YMost(), PR_FALSE);
@@ -1341,35 +1343,37 @@ void nsViewManager::InvalidateRectDiffer
 NS_IMETHODIMP nsViewManager::ResizeView(nsIView *aView, const nsRect &aRect, PRBool aRepaintExposedAreaOnly)
 {
   nsView* view = static_cast<nsView*>(aView);
   NS_ASSERTION(view->GetViewManager() == this, "wrong view manager");
   nsRect oldDimensions;
 
   view->GetDimensions(oldDimensions);
   if (!oldDimensions.IsExactEqual(aRect)) {
-    nsView* parentView = view->GetParent();
-    if (parentView == nsnull)
-      parentView = view;
-
     // resize the view.
     // Prevent Invalidation of hidden views 
     if (view->GetVisibility() == nsViewVisibility_kHide) {  
       view->SetDimensions(aRect, PR_FALSE);
     } else {
+      nsView* parentView = view->GetParent();
+      if (!parentView) {
+        parentView = view;
+      }
       nsRect oldBounds = view->GetBoundsInParentUnits();
       view->SetDimensions(aRect, PR_TRUE);
+      nsViewManager* parentVM = parentView->GetViewManager();
       if (!aRepaintExposedAreaOnly) {
         //Invalidate the union of the old and new size
         UpdateView(view, aRect, NS_VMREFRESH_NO_SYNC);
-        UpdateView(parentView, oldBounds, NS_VMREFRESH_NO_SYNC);
+        parentVM->UpdateView(parentView, oldBounds, NS_VMREFRESH_NO_SYNC);
       } else {
         InvalidateRectDifference(view, aRect, oldDimensions, NS_VMREFRESH_NO_SYNC);
         nsRect newBounds = view->GetBoundsInParentUnits();
-        InvalidateRectDifference(parentView, oldBounds, newBounds, NS_VMREFRESH_NO_SYNC);
+        parentVM->InvalidateRectDifference(parentView, oldBounds, newBounds,
+                                           NS_VMREFRESH_NO_SYNC);
       } 
     }
   }
 
   // Note that if layout resizes the view and the view has a custom clip
   // region set, then we expect layout to update the clip region too. Thus
   // in the case where mClipRect has been optimized away to just be a null
   // pointer, and this resize is implicitly changing the clip rect, it's OK