diff --git a/mozilla/layout/generic/nsBlockFrame.cpp b/mozilla/layout/generic/nsBlockFrame.cpp index a4f474e899e..d5309a0101a 100644 --- a/mozilla/layout/generic/nsBlockFrame.cpp +++ b/mozilla/layout/generic/nsBlockFrame.cpp @@ -1186,7 +1186,7 @@ nsBlockFrame::Reflow(nsPresContext* aPresContext, } // Determine if we need to repaint our border, background or outline - CheckInvalidateSizeChange(aPresContext, aMetrics, aReflowState); + CheckInvalidateSizeChange(aMetrics); FinishAndStoreOverflow(&aMetrics); diff --git a/mozilla/layout/generic/nsColumnSetFrame.cpp b/mozilla/layout/generic/nsColumnSetFrame.cpp index a27b011dce3..f2f9cde6f84 100644 --- a/mozilla/layout/generic/nsColumnSetFrame.cpp +++ b/mozilla/layout/generic/nsColumnSetFrame.cpp @@ -913,7 +913,7 @@ nsColumnSetFrame::Reflow(nsPresContext* aPresContext, } } - CheckInvalidateSizeChange(PresContext(), aDesiredSize, aReflowState); + CheckInvalidateSizeChange(aDesiredSize); FinishAndStoreOverflow(&aDesiredSize); aDesiredSize.mCarriedOutBottomMargin = carriedOutBottomMargin; diff --git a/mozilla/layout/generic/nsFrame.cpp b/mozilla/layout/generic/nsFrame.cpp index 2faa0b08767..b944d921001 100644 --- a/mozilla/layout/generic/nsFrame.cpp +++ b/mozilla/layout/generic/nsFrame.cpp @@ -3751,12 +3751,18 @@ nsIFrame::GetOverflowRect() const } void -nsFrame::CheckInvalidateSizeChange(nsPresContext* aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - const nsHTMLReflowState& aReflowState) +nsFrame::CheckInvalidateSizeChange(nsHTMLReflowMetrics& aNewDesiredSize) { - if (aDesiredSize.width == mRect.width - && aDesiredSize.height == mRect.height) + nsIFrame::CheckInvalidateSizeChange(mRect, GetOverflowRect(), aNewDesiredSize); +} + +void +nsIFrame::CheckInvalidateSizeChange(const nsRect& aOldRect, + const nsRect& aOldOverflowRect, + nsHTMLReflowMetrics& aNewDesiredSize) +{ + if (aNewDesiredSize.width == aOldRect.width && + aNewDesiredSize.height == aOldRect.height) return; // Below, we invalidate the old frame area (or, in the case of @@ -3772,9 +3778,9 @@ nsFrame::CheckInvalidateSizeChange(nsPresContext* aPresContext, // Invalidate the entire old frame+outline if the frame has an outline PRBool anyOutline; nsRect r = ComputeOutlineRect(this, &anyOutline, - aDesiredSize.mOverflowArea); + aNewDesiredSize.mOverflowArea); if (anyOutline) { - r.UnionRect(GetOverflowRect(), r); + r.UnionRect(aOldOverflowRect, r); Invalidate(r); return; } @@ -3784,7 +3790,7 @@ nsFrame::CheckInvalidateSizeChange(nsPresContext* aPresContext, const nsStyleBorder* border = GetStyleBorder(); NS_FOR_CSS_SIDES(side) { if (border->GetBorderWidth(side) != 0) { - Invalidate(nsRect(0, 0, mRect.width, mRect.height)); + Invalidate(nsRect(0, 0, aOldRect.width, aOldRect.height)); return; } } @@ -3794,7 +3800,7 @@ nsFrame::CheckInvalidateSizeChange(nsPresContext* aPresContext, const nsStyleBackground* background = GetStyleBackground(); if (background->mBackgroundFlags & (NS_STYLE_BG_X_POSITION_PERCENT | NS_STYLE_BG_Y_POSITION_PERCENT)) { - Invalidate(nsRect(0, 0, mRect.width, mRect.height)); + Invalidate(nsRect(0, 0, aOldRect.width, aOldRect.height)); return; } } diff --git a/mozilla/layout/generic/nsFrame.h b/mozilla/layout/generic/nsFrame.h index 3f4333a8f8b..e9319537353 100644 --- a/mozilla/layout/generic/nsFrame.h +++ b/mozilla/layout/generic/nsFrame.h @@ -379,17 +379,13 @@ public: /** * Helper method to invalidate portions of a standard container frame if the - * reflow state indicates that the size has changed (specifically border, + * desired size indicates that the size has changed (specifically border, * background and outline). * We assume that the difference between the old frame area and the new * frame area is invalidated by some other means. - * @param aPresContext the presentation context * @param aDesiredSize the new size of the frame - * @param aReflowState the reflow that was just done on this frame */ - void CheckInvalidateSizeChange(nsPresContext* aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - const nsHTMLReflowState& aReflowState); + void CheckInvalidateSizeChange(nsHTMLReflowMetrics& aNewDesiredSize); // Helper function that tests if the frame tree is too deep; if it // is it marks the frame as "unflowable" and zeros out the metrics diff --git a/mozilla/layout/generic/nsFrameFrame.cpp b/mozilla/layout/generic/nsFrameFrame.cpp index de198c8b645..a5f2a1ff78f 100644 --- a/mozilla/layout/generic/nsFrameFrame.cpp +++ b/mozilla/layout/generic/nsFrameFrame.cpp @@ -545,7 +545,7 @@ nsSubDocumentFrame::Reflow(nsPresContext* aPresContext, vm->ResizeView(mInnerView, nsRect(nsPoint(0, 0), innerSize), PR_TRUE); // Determine if we need to repaint our border, background or outline - CheckInvalidateSizeChange(aPresContext, aDesiredSize, aReflowState); + CheckInvalidateSizeChange(aDesiredSize); FinishAndStoreOverflow(&aDesiredSize); diff --git a/mozilla/layout/generic/nsIFrame.h b/mozilla/layout/generic/nsIFrame.h index 72cacd1b989..f2a12c7b59b 100644 --- a/mozilla/layout/generic/nsIFrame.h +++ b/mozilla/layout/generic/nsIFrame.h @@ -2132,6 +2132,17 @@ NS_PTR_TO_INT32(frame->GetProperty(nsGkAtoms::embeddingLevel)) */ nsPeekOffsetStruct GetExtremeCaretPosition(PRBool aStart); + /** + * Same thing as nsFrame::CheckInvalidateSizeChange, but more flexible. The + * implementation of this method must not depend on the mRect or + * GetOverflowRect() of the frame! Note that it's safe to assume in this + * method that the frame origin didn't change. If it did, whoever moved the + * frame will invalidate as needed anyway. + */ + void CheckInvalidateSizeChange(const nsRect& aOldRect, + const nsRect& aOldOverflowRect, + nsHTMLReflowMetrics& aNewDesiredSize); + protected: // Members nsRect mRect; diff --git a/mozilla/layout/tables/nsTableCellFrame.cpp b/mozilla/layout/tables/nsTableCellFrame.cpp index e050f232542..6372df59b24 100644 --- a/mozilla/layout/tables/nsTableCellFrame.cpp +++ b/mozilla/layout/tables/nsTableCellFrame.cpp @@ -967,7 +967,7 @@ NS_METHOD nsTableCellFrame::Reflow(nsPresContext* aPresContext, // If our parent is in initial reflow, it'll handle invalidating our // entire overflow rect. if (!(GetParent()->GetStateBits() & NS_FRAME_FIRST_REFLOW)) { - CheckInvalidateSizeChange(aPresContext, aDesiredSize, aReflowState); + CheckInvalidateSizeChange(aDesiredSize); } // remember the desired size for this reflow diff --git a/mozilla/layout/tables/nsTableFrame.cpp b/mozilla/layout/tables/nsTableFrame.cpp index f479e2a455b..a515833faf3 100644 --- a/mozilla/layout/tables/nsTableFrame.cpp +++ b/mozilla/layout/tables/nsTableFrame.cpp @@ -1998,7 +1998,7 @@ NS_METHOD nsTableFrame::Reflow(nsPresContext* aPresContext, // Fulfill the promise InvalidateFrame makes. Invalidate(aDesiredSize.mOverflowArea); } else { - CheckInvalidateSizeChange(aPresContext, aDesiredSize, aReflowState); + CheckInvalidateSizeChange(aDesiredSize); } FinishAndStoreOverflow(&aDesiredSize); @@ -6855,11 +6855,19 @@ nsTableFrame::InvalidateFrame(nsIFrame* aFrame, // coordinates relative to the old position. So invalidate via // aFrame's parent, and reposition that overflow rect to the right // place. + // XXXbz this doesn't handle outlines, does it? aFrame->Invalidate(overflowRect); parent->Invalidate(aOrigOverflowRect + aOrigRect.TopLeft()); } else { + nsHTMLReflowMetrics desiredSize; + nsRect rect = aFrame->GetRect(); + desiredSize.width = rect.width; + desiredSize.height = rect.height; + desiredSize.mOverflowArea = overflowRect; + aFrame->CheckInvalidateSizeChange(aOrigRect, aOrigOverflowRect, + desiredSize); aFrame->InvalidateRectDifference(aOrigOverflowRect, overflowRect); - parent->InvalidateRectDifference(aOrigRect, aFrame->GetRect()); + parent->InvalidateRectDifference(aOrigRect, rect); } } diff --git a/mozilla/layout/tables/nsTableRowFrame.cpp b/mozilla/layout/tables/nsTableRowFrame.cpp index 8166bcf4151..cd2c2001851 100644 --- a/mozilla/layout/tables/nsTableRowFrame.cpp +++ b/mozilla/layout/tables/nsTableRowFrame.cpp @@ -345,7 +345,7 @@ nsTableRowFrame::DidResize() desiredSize.width = mRect.width; desiredSize.height = mRect.height; desiredSize.mOverflowArea = nsRect(0, 0, desiredSize.width, - desiredSize.height); + desiredSize.height); while (childFrame) { if (IS_TABLE_CELL(childFrame->GetType())) { @@ -1064,7 +1064,7 @@ nsTableRowFrame::Reflow(nsPresContext* aPresContext, // If our parent is in initial reflow, it'll handle invalidating our // entire overflow rect. if (!(GetParent()->GetStateBits() & NS_FRAME_FIRST_REFLOW)) { - CheckInvalidateSizeChange(aPresContext, aDesiredSize, aReflowState); + CheckInvalidateSizeChange(aDesiredSize); } NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize); diff --git a/mozilla/layout/tables/nsTableRowGroupFrame.cpp b/mozilla/layout/tables/nsTableRowGroupFrame.cpp index 5e0f8106615..c41eaee36ae 100644 --- a/mozilla/layout/tables/nsTableRowGroupFrame.cpp +++ b/mozilla/layout/tables/nsTableRowGroupFrame.cpp @@ -1392,7 +1392,7 @@ nsTableRowGroupFrame::Reflow(nsPresContext* aPresContext, // If our parent is in initial reflow, it'll handle invalidating our // entire overflow rect. if (!(GetParent()->GetStateBits() & NS_FRAME_FIRST_REFLOW)) { - CheckInvalidateSizeChange(aPresContext, aDesiredSize, aReflowState); + CheckInvalidateSizeChange(aDesiredSize); } FinishAndStoreOverflow(&aDesiredSize);