Fix bug 292914: if scrolling up more than 32767 pixels, window didn't refresh. Fix by just manually invalidating if scrolling will redraw the entire scrolled area. r=joshmoz, sr=jhpedemonte, a=bsmedberg.

This commit is contained in:
smfr%smfr.org 2005-07-19 21:21:21 +00:00
Родитель 5117a115c4
Коммит d7b87c48e2
1 изменённых файлов: 50 добавлений и 43 удалений

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

@ -1744,62 +1744,69 @@ nsWindow::ScrollBits ( Rect & inRectToScroll, PRInt32 inLeftDelta, PRInt32 inTop
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
NS_IMETHODIMP nsWindow::Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect) NS_IMETHODIMP nsWindow::Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect)
{ {
if (mVisible && ContainerHierarchyIsVisible())
{
if (mVisible && ContainerHierarchyIsVisible()) { // If the clipping region is non-rectangular, just force a full update, sorry.
nsRect scrollRect;
// If the clipping region is non-rectangular, just force a full update, sorry.
// XXX ? // XXX ?
if (!IsRegionRectangular(mWindowRegion)) { if (!IsRegionRectangular(mWindowRegion))
Invalidate(PR_TRUE); {
goto scrollChildren; Invalidate(PR_TRUE);
} goto scrollChildren;
}
//-------- //--------
// Scroll this widget // Scroll this widget
if (aClipRect) nsRect scrollRect;
scrollRect = *aClipRect; if (aClipRect)
else scrollRect = *aClipRect;
{ else
scrollRect = mBounds; {
scrollRect.x = scrollRect.y = 0; scrollRect = mBounds;
} scrollRect.x = scrollRect.y = 0;
}
Rect macRect; // If we're scrolling by an amount that is larger than the height or
nsRectToMacRect(scrollRect, macRect); // width, just invalidate the entire area.
if (aDx >= scrollRect.width || aDy >= scrollRect.height)
{
Invalidate(scrollRect, PR_TRUE);
}
else
{
Rect macRect;
nsRectToMacRect(scrollRect, macRect);
StartDraw();
StartDraw(); // Clip to the windowRegion instead of the visRegion (note: the visRegion
// is equal to the windowRegion minus the children). The result is that
// ScrollRect() scrolls the visible bits of this widget as well as its children.
::SetClip(mWindowRegion);
// Clip to the windowRegion instead of the visRegion (note: the visRegion // Scroll the bits now. We've rolled our own because ::ScrollRect looks ugly
// is equal to the windowRegion minus the children). The result is that ScrollBits(macRect,aDx,aDy);
// ScrollRect() scrolls the visible bits of this widget as well as its children.
::SetClip(mWindowRegion);
// Scroll the bits now. We've rolled our own because ::ScrollRect looks ugly EndDraw();
ScrollBits(macRect,aDx,aDy); }
EndDraw();
} }
scrollChildren: scrollChildren:
//-------- //--------
// Scroll the children // Scroll the children
for (nsIWidget* kid = mFirstChild; kid; kid = kid->GetNextSibling()) { for (nsIWidget* kid = mFirstChild; kid; kid = kid->GetNextSibling()) {
nsWindow* childWindow = NS_STATIC_CAST(nsWindow*, kid); nsWindow* childWindow = NS_STATIC_CAST(nsWindow*, kid);
nsRect bounds; nsRect bounds;
childWindow->GetBounds(bounds); childWindow->GetBounds(bounds);
bounds.x += aDx; bounds.x += aDx;
bounds.y += aDy; bounds.y += aDy;
childWindow->SetBounds(bounds); childWindow->SetBounds(bounds);
} }
// recalculate the window regions // recalculate the window regions
CalcWindowRegions(); CalcWindowRegions();
return NS_OK; return NS_OK;
} }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------