Bug 232951. Make scrolling of scrolling-views-without-widgets work properly even when there are child widgets. r+sr=dbaron

This commit is contained in:
roc+%cs.cmu.edu 2004-02-20 04:31:20 +00:00
Родитель eb75dde69f
Коммит 3c1b167fd1
2 изменённых файлов: 38 добавлений и 27 удалений

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

@ -378,32 +378,29 @@ NS_IMETHODIMP nsScrollPortView::GetScrollbarVisibility(PRBool *aVerticalVisible,
return NS_OK;
}
void nsScrollPortView::AdjustChildWidgets(nsScrollPortView *aScrolling, nsView *aView, nscoord aDx, nscoord aDy, float scale)
static void AdjustChildWidgets(nsView *aView,
nsPoint aWidgetToParentViewOrigin, float aScale, PRBool aInvalidate)
{
NS_ASSERTION(aScrolling != aView, "We should only be scrolling children of aScrolling");
nsPoint pt = aView->GetPosition();
aDx += pt.x;
aDy += pt.y;
if (aView->HasWidget()) {
nsRect bounds = aView->GetBounds();
nsPoint widgetOrigin = aWidgetToParentViewOrigin
+ nsPoint(bounds.x, bounds.y);
nsIWidget* widget = aView->GetWidget();
widget->Move(NSTwipsToIntPixels(widgetOrigin.x, aScale),
NSTwipsToIntPixels(widgetOrigin.y, aScale));
if (aInvalidate) {
widget->Invalidate(PR_FALSE);
}
} else {
// Don't recurse if the view has a widget, because we adjusted the view's
// widget position, and its child widgets are relative to its positon
nsPoint widgetToViewOrigin = aWidgetToParentViewOrigin
+ aView->GetPosition();
for (nsView* kid = aView->GetFirstChild(); kid; kid = kid->GetNextSibling())
{
nsIWidget *win = kid->GetWidget();
if (win)
{
#if 0
win->BeginResizingChildren();
#endif
nsRect bounds = kid->GetBounds();
win->Move(NSTwipsToIntPixels((bounds.x + aDx), scale), NSTwipsToIntPixels((bounds.y + aDy), scale));
AdjustChildWidgets(kid, widgetToViewOrigin, aScale, aInvalidate);
}
// Don't recurse if the view has a widget, because we adjusted the view's
// widget position, and its child widgets are relative to its positon
if (!win)
AdjustChildWidgets(aScrolling, kid, aDx, aDy, scale);
}
}
@ -525,12 +522,27 @@ void nsScrollPortView::Scroll(nsView *aScrolledView, PRInt32 aDx, PRInt32 aDy, f
if (!scrollWidget)
{
// if we don't have a scroll widget then we must just update.
nsPoint offsetToWidget;
GetNearestWidget(&offsetToWidget);
// We're moving the child widgets because we are scrolling. But
// the child widgets may stick outside our bounds, so their area
// may include area that's not supposed to be scrolled. We need
// to invalidate to ensure that any such area is properly
// repainted back to the right rendering.
AdjustChildWidgets(aScrolledView, offsetToWidget, scale, PR_TRUE);
// If we don't have a scroll widget then we must just update.
// We should call this after fixing up the widget positions to be
// consistent with the view hierarchy.
mViewManager->UpdateView(this, 0);
} else if (CannotBitBlt(aScrolledView)) {
// we can't blit for some reason just update the view and adjust any heavy weight widgets
// We can't blit for some reason.
// Just update the view and adjust widgets
// Recall that our widget's origin is at our bounds' top-left
AdjustChildWidgets(aScrolledView,
GetPosition() - GetBounds().TopLeft(), scale, PR_FALSE);
// We should call this after fixing up the widget positions to be
// consistent with the view hierarchy.
mViewManager->UpdateView(this, 0);
AdjustChildWidgets(this, aScrolledView, 0, 0, scale);
} else { // if we can blit and have a scrollwidget then scroll.
// Scroll the contents of the widget by the specfied amount, and scroll
// the child widgets

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

@ -112,7 +112,6 @@ protected:
virtual ~nsScrollPortView();
//private
void AdjustChildWidgets(nsScrollPortView *aScrolling, nsView *aView, nscoord aDx, nscoord aDy, float aScale);
void Scroll(nsView *aScrolledView, PRInt32 aDx, PRInt32 aDy, float scale, PRUint32 aUpdateFlags);
PRBool CannotBitBlt(nsView* aScrolledView);