Elimiate calls to nsFrame::Invalidate when the dirtyRect is empty. Also, removed some invalid code from nsFrame::Invalidate and added DEBUG check to catch later offenders. b=103266 r=rbs sr=hyatt

This commit is contained in:
attinasi%netscape.com 2001-11-06 01:44:20 +00:00
Родитель fdfef80f08
Коммит 94f3ab9a20
19 изменённых файлов: 141 добавлений и 47 удалений

Просмотреть файл

@ -4741,7 +4741,9 @@ PresShell::UnsuppressAndInvalidate()
if (rootFrame) {
nsRect rect;
rootFrame->GetRect(rect);
((nsFrame*)rootFrame)->Invalidate(mPresContext, rect, PR_FALSE);
if (!rect.IsEmpty()) {
((nsFrame*)rootFrame)->Invalidate(mPresContext, rect, PR_FALSE);
}
}
if (ourWindow)

Просмотреть файл

@ -913,8 +913,10 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext,
printf("%p invalidate 1 (%d, %d, %d, %d)\n",
this, 0, 0, mRect.width, mRect.height);
#endif
Invalidate(aPresContext, nsRect(0, 0, mRect.width, mRect.height));
nsRect damageRect(0, 0, mRect.width, mRect.height);
if (!damageRect.IsEmpty()) {
Invalidate(aPresContext,damageRect);
}
} else {
nsMargin border = aReflowState.mComputedBorderPadding -
aReflowState.mComputedPadding;
@ -943,7 +945,9 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext,
printf("%p invalidate 2 (%d, %d, %d, %d)\n",
this, damageRect.x, damageRect.y, damageRect.width, damageRect.height);
#endif
Invalidate(aPresContext, damageRect);
if (!damageRect.IsEmpty()) {
Invalidate(aPresContext, damageRect);
}
}
// See if our height changed
@ -970,7 +974,9 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext,
printf("%p invalidate 3 (%d, %d, %d, %d)\n",
this, damageRect.x, damageRect.y, damageRect.width, damageRect.height);
#endif
Invalidate(aPresContext, damageRect);
if (!damageRect.IsEmpty()) {
Invalidate(aPresContext, damageRect);
}
}
}
}
@ -2376,7 +2382,9 @@ nsBlockFrame::ReflowLine(nsBlockReflowState& aState,
printf("%p invalidate 6 (%d, %d, %d, %d)\n",
this, dirtyRect.x, dirtyRect.y, dirtyRect.width, dirtyRect.height);
#endif
Invalidate(aState.mPresContext, dirtyRect);
if (!dirtyRect.IsEmpty()) {
Invalidate(aState.mPresContext, dirtyRect);
}
} else {
if (oldCombinedArea.width != lineCombinedArea.width) {
@ -2396,7 +2404,9 @@ nsBlockFrame::ReflowLine(nsBlockReflowState& aState,
printf("%p invalidate 7 (%d, %d, %d, %d)\n",
this, dirtyRect.x, dirtyRect.y, dirtyRect.width, dirtyRect.height);
#endif
Invalidate(aState.mPresContext, dirtyRect);
if (!dirtyRect.IsEmpty()) {
Invalidate(aState.mPresContext, dirtyRect);
}
}
if (oldCombinedArea.height != lineCombinedArea.height) {
nsRect dirtyRect;
@ -2415,7 +2425,9 @@ nsBlockFrame::ReflowLine(nsBlockReflowState& aState,
printf("%p invalidate 8 (%d, %d, %d, %d)\n",
this, dirtyRect.x, dirtyRect.y, dirtyRect.width, dirtyRect.height);
#endif
Invalidate(aState.mPresContext, dirtyRect);
if (!dirtyRect.IsEmpty()) {
Invalidate(aState.mPresContext, dirtyRect);
}
}
}
}
@ -2516,7 +2528,9 @@ nsBlockFrame::ReflowLine(nsBlockReflowState& aState,
if (aLine->IsForceInvalidate())
printf(" dirty line is %p\n");
#endif
Invalidate(aState.mPresContext, dirtyRect);
if (!dirtyRect.IsEmpty()) {
Invalidate(aState.mPresContext, dirtyRect);
}
}
}
@ -2614,7 +2628,7 @@ nsBlockFrame::PullFrameFrom(nsBlockReflowState& aState,
else {
// Free up the fromLine now that it's empty
// Its bounds might need to be redrawn, though.
if (aDamageDeletedLines) {
if (aDamageDeletedLines && !fromLine->mBounds.IsEmpty()) {
Invalidate(aState.mPresContext, fromLine->mBounds);
}
if (aFromLine.next() != end_lines())
@ -3152,7 +3166,7 @@ nsBlockFrame::ReflowBlockFrame(nsBlockReflowState& aState,
applyTopMargin, aState.mPrevBottomMargin,
aState.IsAdjacentWithTop(),
computedOffsets, frameReflowStatus);
if (brc.BlockShouldInvalidateItself()) {
if (brc.BlockShouldInvalidateItself() && !mRect.IsEmpty()) {
Invalidate(aState.mPresContext, mRect);
}
@ -4928,7 +4942,9 @@ nsBlockFrame::DoRemoveFrame(nsIPresContext* aPresContext,
printf("%p invalidate 10 (%d, %d, %d, %d)\n",
this, lineCombinedArea.x, lineCombinedArea.y, lineCombinedArea.width, lineCombinedArea.height);
#endif
Invalidate(aPresContext, lineCombinedArea);
if (!lineCombinedArea.IsEmpty()) {
Invalidate(aPresContext, lineCombinedArea);
}
cur->Destroy(presShell);
// If we're removing a line, ReflowDirtyLines isn't going to
@ -5084,7 +5100,7 @@ nsBlockFrame::ReflowFloater(nsBlockReflowState& aState,
}
}
if (brc.BlockShouldInvalidateItself()) {
if (brc.BlockShouldInvalidateItself() && !mRect.IsEmpty()) {
Invalidate(aState.mPresContext, mRect);
}

Просмотреть файл

@ -2077,6 +2077,11 @@ nsFrame::Invalidate(nsIPresContext* aPresContext,
const nsRect& aDamageRect,
PRBool aImmediate) const
{
if (aDamageRect.IsEmpty()) {
NS_WARNING("empty damage rect: update caller to avoid fcn call overhead");
return;
}
if (aPresContext) {
// Don't allow invalidates to do anything when
// painting is suppressed.
@ -2093,6 +2098,13 @@ nsFrame::Invalidate(nsIPresContext* aPresContext,
nsIViewManager* viewManager = nsnull;
nsRect damageRect(aDamageRect);
#if 0
// NOTE: inflating the damagerect is to account for outlines but
// ONLY WHEN outlines are actually drawn outside of the frame. This
// assumes that they are *but they are not* and it also assumes that the
// entire frame is being invalidated, which it often is not
// - therefore, this code is invalid and has been removed
// Checks to see if the damaged rect should be infalted
// to include the outline
const nsStyleOutline* outline;
@ -2102,6 +2114,7 @@ nsFrame::Invalidate(nsIPresContext* aPresContext,
if (width > 0) {
damageRect.Inflate(width, width);
}
#endif
PRUint32 flags = aImmediate ? NS_VMREFRESH_IMMEDIATE : NS_VMREFRESH_NO_SYNC;
nsIView* view;
@ -2613,7 +2626,9 @@ nsFrame::SetSelected(nsIPresContext* aPresContext, nsIDOMRange *aRange, PRBool a
nsRect frameRect;
GetRect(frameRect);
nsRect rect(0, 0, frameRect.width, frameRect.height);
Invalidate(aPresContext, rect, PR_FALSE);
if (!rect.IsEmpty()) {
Invalidate(aPresContext, rect, PR_FALSE);
}
#if 0
if (aRange) {
//lets see if the range contains us, if so we must redraw!

Просмотреть файл

@ -370,7 +370,7 @@ NS_IMETHODIMP nsImageFrame::OnDataAvailable(imgIRequest *aRequest, nsIPresContex
r.x += mBorderPadding.left;
r.y += mBorderPadding.top;
if (whichLoad == 0)
if (whichLoad == 0 && !r.IsEmpty())
Invalidate(aPresContext, r, PR_FALSE);
return NS_OK;

Просмотреть файл

@ -5231,7 +5231,10 @@ nsTextFrame::Reflow(nsIPresContext* aPresContext,
maxFrameWidth = PR_MAX(maxFrameWidth, mRect.width) + onePixel;
maxFrameHeight = PR_MAX(maxFrameHeight, mRect.height);
Invalidate(aPresContext, nsRect(0,0,maxFrameWidth,maxFrameHeight));
nsRect damage(0,0,maxFrameWidth,maxFrameHeight);
if (!damage.IsEmpty()) {
Invalidate(aPresContext, damage);
}
/*}*/

Просмотреть файл

@ -612,7 +612,9 @@ ViewportFrame::Reflow(nsIPresContext* aPresContext,
(eReflowReason_Resize == aReflowState.reason) ||
(eReflowReason_StyleChange == aReflowState.reason)) {
nsRect damageRect(0, 0, aDesiredSize.width, aDesiredSize.height);
Invalidate(aPresContext, damageRect, PR_FALSE);
if (!damageRect.IsEmpty()) {
Invalidate(aPresContext, damageRect, PR_FALSE);
}
}
NS_FRAME_TRACE_REFLOW_OUT("ViewportFrame::Reflow", aStatus);

Просмотреть файл

@ -913,8 +913,10 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext,
printf("%p invalidate 1 (%d, %d, %d, %d)\n",
this, 0, 0, mRect.width, mRect.height);
#endif
Invalidate(aPresContext, nsRect(0, 0, mRect.width, mRect.height));
nsRect damageRect(0, 0, mRect.width, mRect.height);
if (!damageRect.IsEmpty()) {
Invalidate(aPresContext,damageRect);
}
} else {
nsMargin border = aReflowState.mComputedBorderPadding -
aReflowState.mComputedPadding;
@ -943,7 +945,9 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext,
printf("%p invalidate 2 (%d, %d, %d, %d)\n",
this, damageRect.x, damageRect.y, damageRect.width, damageRect.height);
#endif
Invalidate(aPresContext, damageRect);
if (!damageRect.IsEmpty()) {
Invalidate(aPresContext, damageRect);
}
}
// See if our height changed
@ -970,7 +974,9 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext,
printf("%p invalidate 3 (%d, %d, %d, %d)\n",
this, damageRect.x, damageRect.y, damageRect.width, damageRect.height);
#endif
Invalidate(aPresContext, damageRect);
if (!damageRect.IsEmpty()) {
Invalidate(aPresContext, damageRect);
}
}
}
}
@ -2376,7 +2382,9 @@ nsBlockFrame::ReflowLine(nsBlockReflowState& aState,
printf("%p invalidate 6 (%d, %d, %d, %d)\n",
this, dirtyRect.x, dirtyRect.y, dirtyRect.width, dirtyRect.height);
#endif
Invalidate(aState.mPresContext, dirtyRect);
if (!dirtyRect.IsEmpty()) {
Invalidate(aState.mPresContext, dirtyRect);
}
} else {
if (oldCombinedArea.width != lineCombinedArea.width) {
@ -2396,7 +2404,9 @@ nsBlockFrame::ReflowLine(nsBlockReflowState& aState,
printf("%p invalidate 7 (%d, %d, %d, %d)\n",
this, dirtyRect.x, dirtyRect.y, dirtyRect.width, dirtyRect.height);
#endif
Invalidate(aState.mPresContext, dirtyRect);
if (!dirtyRect.IsEmpty()) {
Invalidate(aState.mPresContext, dirtyRect);
}
}
if (oldCombinedArea.height != lineCombinedArea.height) {
nsRect dirtyRect;
@ -2415,7 +2425,9 @@ nsBlockFrame::ReflowLine(nsBlockReflowState& aState,
printf("%p invalidate 8 (%d, %d, %d, %d)\n",
this, dirtyRect.x, dirtyRect.y, dirtyRect.width, dirtyRect.height);
#endif
Invalidate(aState.mPresContext, dirtyRect);
if (!dirtyRect.IsEmpty()) {
Invalidate(aState.mPresContext, dirtyRect);
}
}
}
}
@ -2516,7 +2528,9 @@ nsBlockFrame::ReflowLine(nsBlockReflowState& aState,
if (aLine->IsForceInvalidate())
printf(" dirty line is %p\n");
#endif
Invalidate(aState.mPresContext, dirtyRect);
if (!dirtyRect.IsEmpty()) {
Invalidate(aState.mPresContext, dirtyRect);
}
}
}
@ -2614,7 +2628,7 @@ nsBlockFrame::PullFrameFrom(nsBlockReflowState& aState,
else {
// Free up the fromLine now that it's empty
// Its bounds might need to be redrawn, though.
if (aDamageDeletedLines) {
if (aDamageDeletedLines && !fromLine->mBounds.IsEmpty()) {
Invalidate(aState.mPresContext, fromLine->mBounds);
}
if (aFromLine.next() != end_lines())
@ -3152,7 +3166,7 @@ nsBlockFrame::ReflowBlockFrame(nsBlockReflowState& aState,
applyTopMargin, aState.mPrevBottomMargin,
aState.IsAdjacentWithTop(),
computedOffsets, frameReflowStatus);
if (brc.BlockShouldInvalidateItself()) {
if (brc.BlockShouldInvalidateItself() && !mRect.IsEmpty()) {
Invalidate(aState.mPresContext, mRect);
}
@ -4928,7 +4942,9 @@ nsBlockFrame::DoRemoveFrame(nsIPresContext* aPresContext,
printf("%p invalidate 10 (%d, %d, %d, %d)\n",
this, lineCombinedArea.x, lineCombinedArea.y, lineCombinedArea.width, lineCombinedArea.height);
#endif
Invalidate(aPresContext, lineCombinedArea);
if (!lineCombinedArea.IsEmpty()) {
Invalidate(aPresContext, lineCombinedArea);
}
cur->Destroy(presShell);
// If we're removing a line, ReflowDirtyLines isn't going to
@ -5084,7 +5100,7 @@ nsBlockFrame::ReflowFloater(nsBlockReflowState& aState,
}
}
if (brc.BlockShouldInvalidateItself()) {
if (brc.BlockShouldInvalidateItself() && !mRect.IsEmpty()) {
Invalidate(aState.mPresContext, mRect);
}

Просмотреть файл

@ -2077,6 +2077,11 @@ nsFrame::Invalidate(nsIPresContext* aPresContext,
const nsRect& aDamageRect,
PRBool aImmediate) const
{
if (aDamageRect.IsEmpty()) {
NS_WARNING("empty damage rect: update caller to avoid fcn call overhead");
return;
}
if (aPresContext) {
// Don't allow invalidates to do anything when
// painting is suppressed.
@ -2093,6 +2098,13 @@ nsFrame::Invalidate(nsIPresContext* aPresContext,
nsIViewManager* viewManager = nsnull;
nsRect damageRect(aDamageRect);
#if 0
// NOTE: inflating the damagerect is to account for outlines but
// ONLY WHEN outlines are actually drawn outside of the frame. This
// assumes that they are *but they are not* and it also assumes that the
// entire frame is being invalidated, which it often is not
// - therefore, this code is invalid and has been removed
// Checks to see if the damaged rect should be infalted
// to include the outline
const nsStyleOutline* outline;
@ -2102,6 +2114,7 @@ nsFrame::Invalidate(nsIPresContext* aPresContext,
if (width > 0) {
damageRect.Inflate(width, width);
}
#endif
PRUint32 flags = aImmediate ? NS_VMREFRESH_IMMEDIATE : NS_VMREFRESH_NO_SYNC;
nsIView* view;
@ -2613,7 +2626,9 @@ nsFrame::SetSelected(nsIPresContext* aPresContext, nsIDOMRange *aRange, PRBool a
nsRect frameRect;
GetRect(frameRect);
nsRect rect(0, 0, frameRect.width, frameRect.height);
Invalidate(aPresContext, rect, PR_FALSE);
if (!rect.IsEmpty()) {
Invalidate(aPresContext, rect, PR_FALSE);
}
#if 0
if (aRange) {
//lets see if the range contains us, if so we must redraw!

Просмотреть файл

@ -370,7 +370,7 @@ NS_IMETHODIMP nsImageFrame::OnDataAvailable(imgIRequest *aRequest, nsIPresContex
r.x += mBorderPadding.left;
r.y += mBorderPadding.top;
if (whichLoad == 0)
if (whichLoad == 0 && !r.IsEmpty())
Invalidate(aPresContext, r, PR_FALSE);
return NS_OK;

Просмотреть файл

@ -4741,7 +4741,9 @@ PresShell::UnsuppressAndInvalidate()
if (rootFrame) {
nsRect rect;
rootFrame->GetRect(rect);
((nsFrame*)rootFrame)->Invalidate(mPresContext, rect, PR_FALSE);
if (!rect.IsEmpty()) {
((nsFrame*)rootFrame)->Invalidate(mPresContext, rect, PR_FALSE);
}
}
if (ourWindow)

Просмотреть файл

@ -5231,7 +5231,10 @@ nsTextFrame::Reflow(nsIPresContext* aPresContext,
maxFrameWidth = PR_MAX(maxFrameWidth, mRect.width) + onePixel;
maxFrameHeight = PR_MAX(maxFrameHeight, mRect.height);
Invalidate(aPresContext, nsRect(0,0,maxFrameWidth,maxFrameHeight));
nsRect damage(0,0,maxFrameWidth,maxFrameHeight);
if (!damage.IsEmpty()) {
Invalidate(aPresContext, damage);
}
/*}*/

Просмотреть файл

@ -612,7 +612,9 @@ ViewportFrame::Reflow(nsIPresContext* aPresContext,
(eReflowReason_Resize == aReflowState.reason) ||
(eReflowReason_StyleChange == aReflowState.reason)) {
nsRect damageRect(0, 0, aDesiredSize.width, aDesiredSize.height);
Invalidate(aPresContext, damageRect, PR_FALSE);
if (!damageRect.IsEmpty()) {
Invalidate(aPresContext, damageRect, PR_FALSE);
}
}
NS_FRAME_TRACE_REFLOW_OUT("ViewportFrame::Reflow", aStatus);

Просмотреть файл

@ -2087,7 +2087,9 @@ nsTableFrame::ReflowTable(nsIPresContext* aPresContext,
// If we're here that means we had to reflow all the rows, e.g., the column widths
// changed. We need to make sure that any damaged areas are repainted
Invalidate(aPresContext, mRect);
if (!mRect.IsEmpty()) {
Invalidate(aPresContext, mRect);
}
if (eReflowReason_Resize == aReflowState.reason) {
if (!DidResizeReflow()) {

Просмотреть файл

@ -1525,8 +1525,10 @@ nsTableRowGroupFrame::IR_TargetIsChild(nsIPresContext* aPresContext,
// repaint the entire row
// XXX Improve this so the row knows it should bitblt (or repaint) those
// cells that change position...
Invalidate(aPresContext, kidRect);
if (!kidRect.IsEmpty()) {
Invalidate(aPresContext, kidRect);
}
// Invalidate the area we're offseting. Note that we only repaint within
// our existing frame bounds.
// XXX It would be better to bitblt the row frames and not repaint,

Просмотреть файл

@ -2087,7 +2087,9 @@ nsTableFrame::ReflowTable(nsIPresContext* aPresContext,
// If we're here that means we had to reflow all the rows, e.g., the column widths
// changed. We need to make sure that any damaged areas are repainted
Invalidate(aPresContext, mRect);
if (!mRect.IsEmpty()) {
Invalidate(aPresContext, mRect);
}
if (eReflowReason_Resize == aReflowState.reason) {
if (!DidResizeReflow()) {

Просмотреть файл

@ -1525,8 +1525,10 @@ nsTableRowGroupFrame::IR_TargetIsChild(nsIPresContext* aPresContext,
// repaint the entire row
// XXX Improve this so the row knows it should bitblt (or repaint) those
// cells that change position...
Invalidate(aPresContext, kidRect);
if (!kidRect.IsEmpty()) {
Invalidate(aPresContext, kidRect);
}
// Invalidate the area we're offseting. Note that we only repaint within
// our existing frame bounds.
// XXX It would be better to bitblt the row frames and not repaint,

Просмотреть файл

@ -774,9 +774,11 @@ nsSliderFrame::CurrentPositionChanged(nsIPresContext* aPresContext)
nsRect changeRect;
changeRect.UnionRect(thumbRect, newThumbRect);
// redraw just the change
Invalidate(aPresContext, changeRect, mRedrawImmediate);
if (!changeRect.IsEmpty()) {
// redraw just the change
Invalidate(aPresContext, changeRect, mRedrawImmediate);
}
if (mScrollbarListener)
mScrollbarListener->PositionChanged(aPresContext, mCurPos, curpos);

Просмотреть файл

@ -581,7 +581,9 @@ NS_IMETHODIMP nsOutlinerBodyFrame::GetPageCount(PRInt32 *_retval)
NS_IMETHODIMP nsOutlinerBodyFrame::Invalidate()
{
nsLeafBoxFrame::Invalidate(mPresContext, mRect, PR_FALSE);
if (!mRect.IsEmpty()) {
nsLeafBoxFrame::Invalidate(mPresContext, mRect, PR_FALSE);
}
return NS_OK;
}
@ -591,7 +593,9 @@ NS_IMETHODIMP nsOutlinerBodyFrame::InvalidateRow(PRInt32 aIndex)
return NS_OK;
nsRect rowRect(mInnerBox.x, mInnerBox.y+mRowHeight*(aIndex-mTopRowIndex), mInnerBox.width, mRowHeight);
nsLeafBoxFrame::Invalidate(mPresContext, rowRect, PR_FALSE);
if (!rowRect.IsEmpty()) {
nsLeafBoxFrame::Invalidate(mPresContext, rowRect, PR_FALSE);
}
return NS_OK;
}

Просмотреть файл

@ -581,7 +581,9 @@ NS_IMETHODIMP nsOutlinerBodyFrame::GetPageCount(PRInt32 *_retval)
NS_IMETHODIMP nsOutlinerBodyFrame::Invalidate()
{
nsLeafBoxFrame::Invalidate(mPresContext, mRect, PR_FALSE);
if (!mRect.IsEmpty()) {
nsLeafBoxFrame::Invalidate(mPresContext, mRect, PR_FALSE);
}
return NS_OK;
}
@ -591,7 +593,9 @@ NS_IMETHODIMP nsOutlinerBodyFrame::InvalidateRow(PRInt32 aIndex)
return NS_OK;
nsRect rowRect(mInnerBox.x, mInnerBox.y+mRowHeight*(aIndex-mTopRowIndex), mInnerBox.width, mRowHeight);
nsLeafBoxFrame::Invalidate(mPresContext, rowRect, PR_FALSE);
if (!rowRect.IsEmpty()) {
nsLeafBoxFrame::Invalidate(mPresContext, rowRect, PR_FALSE);
}
return NS_OK;
}