From d5c3e5cb25a9d4bf89e7097a39201c114570c2d2 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Tue, 2 Feb 2010 12:16:09 +1300 Subject: [PATCH] Bug 539354. When scrolling an area that was partially outside the window into view, make sure we invalidate the destination area on Mac. r=mstange --HG-- extra : rebase_source : 4cb48c2bc49926d72b00bf3baa59465c149b6d6c --- layout/base/nsLayoutUtils.cpp | 2 +- widget/src/cocoa/nsChildView.mm | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index ce16b7f4e58..a4e42828098 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -1297,7 +1297,7 @@ AddItemsToRegion(nsDisplayListBuilder* aBuilder, nsDisplayList* aList, nsRegion clippedOutDestination; clippedOutDestination.Sub(aUpdateRect, clip); #ifdef DEBUG - PrintAddedRegion("Adding region for clipped out source frame %p", + PrintAddedRegion("Adding region for clipped out destination frame %p", clipFrame, clippedOutDestination); #endif aRegion->Or(*aRegion, clippedOutDestination); diff --git a/widget/src/cocoa/nsChildView.mm b/widget/src/cocoa/nsChildView.mm index d876eafca7f..0938a4f73e9 100644 --- a/widget/src/cocoa/nsChildView.mm +++ b/widget/src/cocoa/nsChildView.mm @@ -1760,6 +1760,22 @@ void nsChildView::Scroll(const nsIntPoint& aDelta, } } #endif // NS_LEOPARD_AND_LATER + // Invalidate the area that was scrolled into view from outside the window + // First, compute the destination region whose source was outside the + // window. We do this by subtracting from destRegion the window bounds, + // translated by the scroll amount. + NSView* rootView = [[mView window] contentView]; + NSRect rootViewRect = [mView convertRect:[rootView bounds] fromView: rootView]; + nsIntRect windowBounds; + NSRectToGeckoRect(rootViewRect, windowBounds); + destRegion.Sub(destRegion, windowBounds + aDelta); + nsIntRegionRectIterator iter(destRegion); + const nsIntRect* invalidate; + while ((invalidate = iter.Next()) != nsnull) { + NSRect rect; + GeckoRectToNSRect(*invalidate, rect); + [mView setNeedsDisplayInRect:rect]; + } // Leopard, at least, has a nasty bug where calling scrollRect:by: doesn't // actually trigger a window update. A window update is only triggered