diff --git a/mozilla/view/src/nsScrollPortView.cpp b/mozilla/view/src/nsScrollPortView.cpp index 19788d0eea5..3885caf7484 100644 --- a/mozilla/view/src/nsScrollPortView.cpp +++ b/mozilla/view/src/nsScrollPortView.cpp @@ -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; - - 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)); + 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 - if (!win) - AdjustChildWidgets(aScrolling, kid, aDx, aDy, scale); + nsPoint widgetToViewOrigin = aWidgetToParentViewOrigin + + aView->GetPosition(); + + for (nsView* kid = aView->GetFirstChild(); kid; kid = kid->GetNextSibling()) + { + AdjustChildWidgets(kid, widgetToViewOrigin, aScale, aInvalidate); + } } } @@ -522,15 +519,30 @@ void nsScrollPortView::Scroll(nsView *aScrolledView, PRInt32 aDx, PRInt32 aDy, f dirtyRegion->Offset(aDx, aDy); nsIWidget *scrollWidget = GetWidget(); - + 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 diff --git a/mozilla/view/src/nsScrollPortView.h b/mozilla/view/src/nsScrollPortView.h index 0ca024c72b1..31fcabaf270 100644 --- a/mozilla/view/src/nsScrollPortView.h +++ b/mozilla/view/src/nsScrollPortView.h @@ -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);