Bug 539356 - Use rect invalidation in XUL tree's to avoid over invalidation. r=roc
authorMatt Woodrow <mwoodrow@mozilla.com>
Wed, 29 Aug 2012 17:49:18 +1200
changeset 108399 20ffee0f2e7d9573e899f6e04a624efde7b38cc9
parent 108398 bcd22436baf4ddd3010ac9bb1517b134fd6e42eb
child 108400 33be0c4f310dd9ac7ca68e83a64499099d0936cb
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
reviewersroc
bugs539356
milestone18.0a1
Bug 539356 - Use rect invalidation in XUL tree's to avoid over invalidation. r=roc
layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp
--- a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp
+++ b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp
@@ -665,17 +665,17 @@ nsTreeBodyFrame::InvalidateColumn(nsITre
 #endif
 
   nsRect columnRect;
   nsresult rv = col->GetRect(this, mInnerBox.y, mInnerBox.height, &columnRect);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // When false then column is out of view
   if (OffsetForHorzScroll(columnRect, true))
-      InvalidateFrame();
+      InvalidateFrameWithRect(columnRect);
 
   return NS_OK;
 }
 
 nsresult
 nsTreeBodyFrame::InvalidateRow(int32_t aIndex)
 {
   if (mUpdateBatchNest)
@@ -685,17 +685,18 @@ nsTreeBodyFrame::InvalidateRow(int32_t a
   if (nsIPresShell::IsAccessibilityActive())
     FireInvalidateEvent(aIndex, aIndex, nullptr, nullptr);
 #endif
 
   aIndex -= mTopRowIndex;
   if (aIndex < 0 || aIndex > mPageLength)
     return NS_OK;
 
-  InvalidateFrame();
+  nsRect rowRect(mInnerBox.x, mInnerBox.y+mRowHeight*aIndex, mInnerBox.width, mRowHeight);
+  InvalidateFrameWithRect(rowRect);
 
   return NS_OK;
 }
 
 nsresult
 nsTreeBodyFrame::InvalidateCell(int32_t aIndex, nsITreeColumn* aCol)
 {
   if (mUpdateBatchNest)
@@ -715,17 +716,17 @@ nsTreeBodyFrame::InvalidateCell(int32_t 
     return NS_ERROR_INVALID_ARG;
 
   nsRect cellRect;
   nsresult rv = col->GetRect(this, mInnerBox.y+mRowHeight*aIndex, mRowHeight,
                              &cellRect);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (OffsetForHorzScroll(cellRect, true))
-    InvalidateFrame();
+    InvalidateFrameWithRect(cellRect);
 
   return NS_OK;
 }
 
 nsresult
 nsTreeBodyFrame::InvalidateRange(int32_t aStart, int32_t aEnd)
 {
   if (mUpdateBatchNest)
@@ -747,17 +748,18 @@ nsTreeBodyFrame::InvalidateRange(int32_t
 #ifdef ACCESSIBILITY
   if (nsIPresShell::IsAccessibilityActive()) {
     int32_t end =
       mRowCount > 0 ? ((mRowCount <= aEnd) ? mRowCount - 1 : aEnd) : 0;
     FireInvalidateEvent(aStart, end, nullptr, nullptr);
   }
 #endif
 
-  InvalidateFrame();
+  nsRect rangeRect(mInnerBox.x, mInnerBox.y+mRowHeight*(aStart-mTopRowIndex), mInnerBox.width, mRowHeight*(aEnd-aStart+1));
+  InvalidateFrameWithRect(rangeRect);
 
   return NS_OK;
 }
 
 nsresult
 nsTreeBodyFrame::InvalidateColumnRange(int32_t aStart, int32_t aEnd, nsITreeColumn* aCol)
 {
   if (mUpdateBatchNest)
@@ -783,17 +785,24 @@ nsTreeBodyFrame::InvalidateColumnRange(i
 #ifdef ACCESSIBILITY
   if (nsIPresShell::IsAccessibilityActive()) {
     int32_t end =
       mRowCount > 0 ? ((mRowCount <= aEnd) ? mRowCount - 1 : aEnd) : 0;
     FireInvalidateEvent(aStart, end, aCol, aCol);
   }
 #endif
 
-  InvalidateFrame();
+  nsRect rangeRect;
+  nsresult rv = col->GetRect(this, 
+                             mInnerBox.y+mRowHeight*(aStart-mTopRowIndex),
+                             mRowHeight*(aEnd-aStart+1),
+                             &rangeRect);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  InvalidateFrameWithRect(rangeRect);
 
   return NS_OK;
 }
 
 static void
 FindScrollParts(nsIFrame* aCurrFrame, nsTreeBodyFrame::ScrollParts* aResult)
 {
   if (!aResult->mColumnsScrollFrame) {