From 182c294250c02fdeadd98f8ebebfa578bdccfea1 Mon Sep 17 00:00:00 2001 From: "roc+@cs.cmu.edu" Date: Sun, 27 May 2007 20:17:20 -0700 Subject: [PATCH] Bug 343430. Reduce the area we scroll on Windows to reduce flicker by excluding areas that shouldn't be moving. On Linux, since we can't control the area we scroll, just disable accelerated scrolling in that case and repaint everything. r+sr=dbaron --- view/src/nsScrollPortView.cpp | 26 +++++++++++++++++++++++++- view/src/nsViewManager.cpp | 6 +++++- widget/src/windows/nsWindow.cpp | 2 +- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/view/src/nsScrollPortView.cpp b/view/src/nsScrollPortView.cpp index 566c6446ed2c..8561b2c84bd1 100644 --- a/view/src/nsScrollPortView.cpp +++ b/view/src/nsScrollPortView.cpp @@ -578,9 +578,33 @@ void nsScrollPortView::Scroll(nsView *aScrolledView, nsPoint aTwipsDelta, nsPoin // consistent with the view hierarchy. mViewManager->UpdateView(this, 0); } else { // if we can blit and have a scrollwidget then scroll. + nsRect* toScrollPtr = nsnull; + +#ifdef XP_WIN + nsRect toScroll; + if (!updateRegion.IsEmpty()) { + nsRegion regionToScroll; + regionToScroll.Sub(nsRect(nsPoint(0,0), GetBounds().Size()), + updateRegion); + nsRegionRectIterator iter(regionToScroll); + nsRect biggestRect(0,0,0,0); + const nsRect* r; + for (r = iter.Next(); r; r = iter.Next()) { + if (r->width*r->height > biggestRect.width*biggestRect.height) { + biggestRect = *r; + } + } + regionToScroll.Sub(regionToScroll, biggestRect); + updateRegion.Or(updateRegion, regionToScroll); + toScrollPtr = &toScroll; + toScroll = biggestRect; + toScroll.ScaleRoundOut(1.0/aP2A); + } +#endif + // Scroll the contents of the widget by the specified amount, and scroll // the child widgets - scrollWidget->Scroll(aPixDelta.x, aPixDelta.y, nsnull); + scrollWidget->Scroll(aPixDelta.x, aPixDelta.y, toScrollPtr); mViewManager->UpdateViewAfterScroll(this, updateRegion); } } diff --git a/view/src/nsViewManager.cpp b/view/src/nsViewManager.cpp index 807a52d34155..fc9cfa951a51 100644 --- a/view/src/nsViewManager.cpp +++ b/view/src/nsViewManager.cpp @@ -1628,8 +1628,12 @@ PRBool nsViewManager::CanScrollWithBitBlt(nsView* aView, nsPoint aDelta, aUpdateRegion->MoveBy(-displayOffset); +#ifdef MOZ_WIDGET_GTK2 + return aUpdateRegion->IsEmpty(); +#else return PR_TRUE; -} +#endif +} NS_IMETHODIMP nsViewManager::SetViewCheckChildEvents(nsIView *aView, PRBool aEnable) { diff --git a/widget/src/windows/nsWindow.cpp b/widget/src/windows/nsWindow.cpp index fae9233619a5..7945e2d559e9 100644 --- a/widget/src/windows/nsWindow.cpp +++ b/widget/src/windows/nsWindow.cpp @@ -3278,7 +3278,7 @@ NS_METHOD nsWindow::Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect) trect.bottom = aClipRect->YMost(); } - ::ScrollWindowEx(mWnd, aDx, aDy, (nsnull != aClipRect) ? &trect : NULL, NULL, + ::ScrollWindowEx(mWnd, aDx, aDy, NULL, (nsnull != aClipRect) ? &trect : NULL, NULL, NULL, SW_INVALIDATE | SW_SCROLLCHILDREN); ::UpdateWindow(mWnd); return NS_OK;