Changed GetWindowOffsets() to specify the view to check rather than assuming

the root view. This fixes scrolling problems when scrolling views are used
as a sub-view
This commit is contained in:
troy%netscape.com 1998-10-15 05:27:00 +00:00
Родитель fb3e6503a0
Коммит 6ad120c16d
3 изменённых файлов: 14 добавлений и 55 удалений

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

@ -100,22 +100,12 @@ public:
NS_IMETHOD SetWindowDimensions(nscoord width, nscoord height) = 0;
/**
* Get the position of the root window relative to the
* composited area. This indicates the scrolled position of the
* root window.
* Get the position of the window relative to the composited
* area. This indicates the scrolled position of the window.
* @param xoffset out parameter for X scroll position of window in twips
* @param yoffset out parameter for Y scroll position of window in twips
*/
NS_IMETHOD GetWindowOffsets(nscoord *xoffset, nscoord *yoffset) = 0;
/**
* Set the position of the root window relative to the
* composited area. This indicates the scrolled position of the
* root window. Called when the root window is scrolled.
* @param xoffset X scroll position of window in twips
* @param yoffset Y scroll position of window in twips
*/
NS_IMETHOD SetWindowOffsets(nscoord xoffset, nscoord yoffset) = 0;
NS_IMETHOD GetWindowOffsets(nsIView *aView, nscoord *xoffset, nscoord *yoffset) const = 0;
/**
* Reset the state of scrollbars and the scrolling region

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

@ -236,13 +236,13 @@ NS_IMETHODIMP nsViewManager :: SetWindowDimensions(nscoord width, nscoord height
return NS_OK;
}
NS_IMETHODIMP nsViewManager :: GetWindowOffsets(nscoord *xoffset, nscoord *yoffset)
NS_IMETHODIMP nsViewManager :: GetWindowOffsets(nsIView *aView, nscoord *xoffset, nscoord *yoffset) const
{
if (nsnull != mRootView)
{
nsIScrollableView *scroller;
if (NS_OK == mRootView->QueryInterface(kIScrollableViewIID, (void **)&scroller))
if (NS_OK == aView->QueryInterface(kIScrollableViewIID, (void **)&scroller))
scroller->GetVisibleOffset(xoffset, yoffset);
else
*xoffset = *yoffset = 0;
@ -252,24 +252,6 @@ NS_IMETHODIMP nsViewManager :: GetWindowOffsets(nscoord *xoffset, nscoord *yoffs
return NS_OK;
}
NS_IMETHODIMP nsViewManager :: SetWindowOffsets(nscoord xoffset, nscoord yoffset)
{
if (nsnull != mRootView)
{
nsIScrollableView *scroller;
nsresult retval;
retval = mRootView->QueryInterface(kIScrollableViewIID, (void **)&scroller);
if (NS_SUCCEEDED(retval))
scroller->SetVisibleOffset(xoffset, yoffset);
return retval;
}
return NS_OK;
}
NS_IMETHODIMP nsViewManager :: ResetScrolling(void)
{
if (nsnull != mRootView)
@ -334,7 +316,7 @@ void nsViewManager :: Refresh(nsIView *aView, nsIRenderingContext *aContext, nsI
mContext->GetAppUnitsToDevUnits(scale);
GetWindowOffsets(&xoff, &yoff);
GetWindowOffsets(aView, &xoff, &yoff);
region->Offset(NSTwipsToIntPixels(-xoff, scale), NSTwipsToIntPixels(-yoff, scale));
// localcx->SetClipRegion(*region, nsClipCombine_kIntersect);
@ -423,7 +405,7 @@ void nsViewManager :: Refresh(nsIView *aView, nsIRenderingContext *aContext, con
if (aUpdateFlags & NS_VMREFRESH_SCREEN_RECT)
localcx->SetClipRect(*rect, nsClipCombine_kReplace);
GetWindowOffsets(&xoff, &yoff);
GetWindowOffsets(aView, &xoff, &yoff);
nsRect trect = *rect;
@ -572,15 +554,9 @@ NS_IMETHODIMP nsViewManager :: UpdateView(nsIView *aView, const nsRect &aRect, P
while ((nsnull != par) && (par != widgetView));
}
// If widgetView is a scrolling view, then offset the rect by the visible
// offset
nsIScrollableView *scroller;
if (NS_OK == widgetView->QueryInterface(kIScrollableViewIID, (void **)&scroller))
{
nscoord xoffset, yoffset;
scroller->GetVisibleOffset(&xoffset, &yoffset);
trect.MoveBy(-xoffset, -yoffset);
}
nscoord xoffset, yoffset;
GetWindowOffsets(widgetView, &xoffset, &yoffset);
trect.MoveBy(-xoffset, -yoffset);
// Add this rect to the widgetView's dirty region.
AddRectToDirtyRegion(widgetView, trect);
@ -675,15 +651,9 @@ NS_IMETHODIMP nsViewManager :: DispatchEvent(nsGUIEvent *aEvent, nsEventStatus &
mContext->GetDevUnitsToAppUnits(p2t);
trect.ScaleRoundOut(p2t);
// If the view is a scrolling view, then offset the rect by the visible
// offset
nsIScrollableView *scroller;
if (NS_OK == view->QueryInterface(kIScrollableViewIID, (void **)&scroller))
{
nscoord xoffset, yoffset;
scroller->GetVisibleOffset(&xoffset, &yoffset);
trect.MoveBy(xoffset, yoffset);
}
nscoord xoffset, yoffset;
GetWindowOffsets(view, &xoffset, &yoffset);
trect.MoveBy(xoffset, yoffset);
// Add the rect to the existing dirty region
AddRectToDirtyRegion(view, trect);

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

@ -50,8 +50,7 @@ public:
NS_IMETHOD GetWindowDimensions(nscoord *width, nscoord *height);
NS_IMETHOD SetWindowDimensions(nscoord width, nscoord height);
NS_IMETHOD GetWindowOffsets(nscoord *xoffset, nscoord *yoffset);
NS_IMETHOD SetWindowOffsets(nscoord xoffset, nscoord yoffset);
NS_IMETHOD GetWindowOffsets(nsIView *aView, nscoord *xoffset, nscoord *yoffset) const;
NS_IMETHOD ResetScrolling(void);