From 2d49769823ff3805f3aeb988a3f19775ba922634 Mon Sep 17 00:00:00 2001 From: Markus Stange Date: Fri, 23 Dec 2011 22:52:25 -0500 Subject: [PATCH] Bug 598482 part 20 - Rename Update to Invalidate; view updates are now always asynchronous. r=roc --- docshell/base/nsDocShell.cpp | 4 +- layout/base/nsDocumentViewer.cpp | 2 +- layout/base/nsPresShell.cpp | 2 +- layout/generic/nsFrame.cpp | 2 +- .../src/nsLayoutDebuggingTools.cpp | 2 +- view/public/nsIViewManager.h | 9 ++- view/src/nsViewManager.cpp | 70 +++++++++---------- view/src/nsViewManager.h | 12 ++-- widget/src/gtk2/nsNativeThemeGTK.cpp | 2 +- 9 files changed, 52 insertions(+), 53 deletions(-) diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 52adec93ad05..f18d29e59db3 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -4732,7 +4732,7 @@ nsDocShell::Repaint(bool aForce) nsIViewManager* viewManager = presShell->GetViewManager(); NS_ENSURE_TRUE(viewManager, NS_ERROR_FAILURE); - NS_ENSURE_SUCCESS(viewManager->UpdateAllViews(), NS_ERROR_FAILURE); + NS_ENSURE_SUCCESS(viewManager->InvalidateAllViews(), NS_ERROR_FAILURE); return NS_OK; } @@ -7323,7 +7323,7 @@ nsDocShell::RestoreFromHistory() // call Thaw. So we issue the invalidate here. newRootView = newVM->GetRootView(); if (newRootView) { - newVM->UpdateView(newRootView); + newVM->InvalidateView(newRootView); } } } diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index cb61c1f3e4f9..9b6055545a7f 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -1554,7 +1554,7 @@ DocumentViewerImpl::Destroy() // The invalidate that removing this view causes is dropped because // the Freeze call above sets painting to be suppressed for our // document. So we do it ourselves and make it happen. - vm->UpdateViewNoSuppression(rootView, + vm->InvalidateViewNoSuppression(rootView, rootView->GetBounds() - rootView->GetPosition()); nsIView *rootViewParent = rootView->GetParent(); diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index dfc5b3882234..f7ff1d36b55a 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -7371,7 +7371,7 @@ PresShell::DoVerifyReflow() // First synchronously render what we have so far so that we can // see it. nsIView* rootView = mViewManager->GetRootView(); - mViewManager->UpdateView(rootView); + mViewManager->InvalidateView(rootView); FlushPendingNotifications(Flush_Layout); mInVerifyReflow = true; diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index 6e3c58761c9f..f2e4302030f5 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -4659,7 +4659,7 @@ nsIFrame::InvalidateRoot(const nsRect& aDamageRect, PRUint32 aFlags) nsIView* view = GetView(); NS_ASSERTION(view, "This can only be called on frames with views"); - view->GetViewManager()->UpdateViewNoSuppression(view, rect); + view->GetViewManager()->InvalidateViewNoSuppression(view, rect); } void diff --git a/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp b/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp index 8b34720094cb..0d732be677fe 100644 --- a/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp +++ b/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp @@ -562,7 +562,7 @@ void nsLayoutDebuggingTools::ForceRefresh() return; nsIView* root = vm->GetRootView(); if (root) { - vm->UpdateView(root); + vm->InvalidateView(root); } } diff --git a/view/public/nsIViewManager.h b/view/public/nsIViewManager.h index 4e130b7346db..8d1f86c7c550 100644 --- a/view/public/nsIViewManager.h +++ b/view/public/nsIViewManager.h @@ -121,7 +121,7 @@ public: * is dirty and needs to be redrawn. * @param aView view to paint. should be root view */ - NS_IMETHOD UpdateView(nsIView *aView) = 0; + NS_IMETHOD InvalidateView(nsIView *aView) = 0; /** * Called to inform the view manager that some portion of a view is dirty and @@ -130,13 +130,12 @@ public: * @param aView view to paint. should be root view * @param rect rect to mark as damaged */ - NS_IMETHOD UpdateViewNoSuppression(nsIView *aView, const nsRect &aRect) = 0; + NS_IMETHOD InvalidateViewNoSuppression(nsIView *aView, const nsRect &aRect) = 0; /** - * Called to inform the view manager that it should redraw all views. - * @param aView view to paint. should be root view + * Called to inform the view manager that it should invalidate all views. */ - NS_IMETHOD UpdateAllViews() = 0; + NS_IMETHOD InvalidateAllViews() = 0; /** * Called to dispatch an event to the appropriate view. Often called diff --git a/view/src/nsViewManager.cpp b/view/src/nsViewManager.cpp index 4103175dbede..d9064fc121dd 100644 --- a/view/src/nsViewManager.cpp +++ b/view/src/nsViewManager.cpp @@ -375,7 +375,7 @@ void nsViewManager::Refresh(nsView *aView, nsIWidget *aWidget, if (RootViewManager()->mRecursiveRefreshPending) { RootViewManager()->mRecursiveRefreshPending = false; - UpdateAllViews(); + InvalidateAllViews(); } } @@ -437,14 +437,14 @@ void nsViewManager::FlushDirtyRegionToWidget(nsView* aView) nsRegion r = ConvertRegionBetweenViews(*dirtyRegion, aView, nearestViewWithWidget); nsViewManager* widgetVM = nearestViewWithWidget->GetViewManager(); - widgetVM->UpdateWidgetArea(nearestViewWithWidget, r); + widgetVM->InvalidateWidgetArea(nearestViewWithWidget, r); dirtyRegion->SetEmpty(); } -NS_IMETHODIMP nsViewManager::UpdateView(nsIView *aView) +NS_IMETHODIMP nsViewManager::InvalidateView(nsIView *aView) { // Mark the entire view as damaged - return UpdateView(aView, aView->GetDimensions()); + return InvalidateView(aView, aView->GetDimensions()); } static void @@ -474,16 +474,16 @@ nsViewManager::PostPendingUpdate() * every widget child of aWidgetView, plus aWidgetView's own widget */ void -nsViewManager::UpdateWidgetArea(nsView *aWidgetView, - const nsRegion &aDamagedRegion) +nsViewManager::InvalidateWidgetArea(nsView *aWidgetView, + const nsRegion &aDamagedRegion) { NS_ASSERTION(aWidgetView->GetViewManager() == this, - "UpdateWidgetArea called on view we don't own"); + "InvalidateWidgetArea called on view we don't own"); nsIWidget* widget = aWidgetView->GetWidget(); #if 0 nsRect dbgBounds = aDamagedRegion.GetBounds(); - printf("UpdateWidgetArea view:%X (%d) widget:%X region: %d, %d, %d, %d\n", + printf("InvalidateWidgetArea view:%X (%d) widget:%X region: %d, %d, %d, %d\n", aWidgetView, aWidgetView->IsAttachedToTopLevel(), widget, dbgBounds.x, dbgBounds.y, dbgBounds.width, dbgBounds.height); #endif @@ -576,7 +576,7 @@ ShouldIgnoreInvalidation(nsViewManager* aVM) return false; } -nsresult nsViewManager::UpdateView(nsIView *aView, const nsRect &aRect) +nsresult nsViewManager::InvalidateView(nsIView *aView, const nsRect &aRect) { // If painting is suppressed in the presshell or an ancestor drop all // invalidates, it will invalidate everything when it unsuppresses. @@ -584,18 +584,18 @@ nsresult nsViewManager::UpdateView(nsIView *aView, const nsRect &aRect) return NS_OK; } - return UpdateViewNoSuppression(aView, aRect); + return InvalidateViewNoSuppression(aView, aRect); } -NS_IMETHODIMP nsViewManager::UpdateViewNoSuppression(nsIView *aView, - const nsRect &aRect) +NS_IMETHODIMP nsViewManager::InvalidateViewNoSuppression(nsIView *aView, + const nsRect &aRect) { NS_PRECONDITION(nsnull != aView, "null view"); nsView* view = static_cast(aView); NS_ASSERTION(view->GetViewManager() == this, - "UpdateView called on view we don't own"); + "InvalidateViewNoSuppression called on view we don't own"); nsRect damagedRect(aRect); if (damagedRect.IsEmpty()) { @@ -622,25 +622,25 @@ NS_IMETHODIMP nsViewManager::UpdateViewNoSuppression(nsIView *aView, return NS_OK; } -NS_IMETHODIMP nsViewManager::UpdateAllViews() +NS_IMETHODIMP nsViewManager::InvalidateAllViews() { if (RootViewManager() != this) { - return RootViewManager()->UpdateAllViews(); + return RootViewManager()->InvalidateAllViews(); } - UpdateViews(mRootView); + InvalidateViews(mRootView); return NS_OK; } -void nsViewManager::UpdateViews(nsView *aView) +void nsViewManager::InvalidateViews(nsView *aView) { - // update this view. - UpdateView(aView); + // Invalidate this view. + InvalidateView(aView); - // update all children as well. + // Invalidate all children as well. nsView* childView = aView->GetFirstChild(); while (nsnull != childView) { - childView->GetViewManager()->UpdateViews(childView); + childView->GetViewManager()->InvalidateViews(childView); childView = childView->GetNextSibling(); } } @@ -775,7 +775,7 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, vm->mRootView->IsEffectivelyVisible() && mPresShell && mPresShell->IsVisible()) { vm->FlushDelayedResize(true); - vm->UpdateView(vm->mRootView); + vm->InvalidateView(vm->mRootView); } } @@ -1071,7 +1071,7 @@ NS_IMETHODIMP nsViewManager::InsertChild(nsIView *aParent, nsIView *aChild, nsIV //and mark this area as dirty if the view is visible... if (nsViewVisibility_kHide != child->GetVisibility()) - child->GetViewManager()->UpdateView(child); + child->GetViewManager()->InvalidateView(child); } return NS_OK; } @@ -1094,7 +1094,7 @@ NS_IMETHODIMP nsViewManager::RemoveChild(nsIView *aChild) if (nsnull != parent) { NS_ASSERTION(child->GetViewManager() == this || parent->GetViewManager() == this, "wrong view manager"); - child->GetViewManager()->UpdateView(child); + child->GetViewManager()->InvalidateView(child); parent->RemoveChild(child); } @@ -1116,8 +1116,8 @@ NS_IMETHODIMP nsViewManager::MoveViewTo(nsIView *aView, nscoord aX, nscoord aY) nsView* parentView = view->GetParent(); if (parentView) { nsViewManager* parentVM = parentView->GetViewManager(); - parentVM->UpdateView(parentView, oldBounds); - parentVM->UpdateView(parentView, view->GetBoundsInParentUnits()); + parentVM->InvalidateView(parentView, oldBounds); + parentVM->InvalidateView(parentView, view->GetBoundsInParentUnits()); } } } @@ -1129,15 +1129,15 @@ void nsViewManager::InvalidateHorizontalBandDifference(nsView *aView, const nsRe nscoord height = aY2 - aY1; if (aRect.x < aCutOut.x) { nsRect r(aRect.x, aY1, aCutOut.x - aRect.x, height); - UpdateView(aView, r); + InvalidateView(aView, r); } if (!aInCutOut && aCutOut.x < aCutOut.XMost()) { nsRect r(aCutOut.x, aY1, aCutOut.width, height); - UpdateView(aView, r); + InvalidateView(aView, r); } if (aCutOut.XMost() < aRect.XMost()) { nsRect r(aCutOut.XMost(), aY1, aRect.XMost() - aCutOut.XMost(), height); - UpdateView(aView, r); + InvalidateView(aView, r); } } @@ -1175,9 +1175,9 @@ NS_IMETHODIMP nsViewManager::ResizeView(nsIView *aView, const nsRect &aRect, boo view->SetDimensions(aRect, true); nsViewManager* parentVM = parentView->GetViewManager(); if (!aRepaintExposedAreaOnly) { - //Invalidate the union of the old and new size - UpdateView(view, aRect); - parentVM->UpdateView(parentView, oldBounds); + // Invalidate the union of the old and new size + InvalidateView(view, aRect); + parentVM->InvalidateView(parentView, oldBounds); } else { InvalidateRectDifference(view, aRect, oldDimensions); nsRect newBounds = view->GetBoundsInParentUnits(); @@ -1220,11 +1220,11 @@ NS_IMETHODIMP nsViewManager::SetViewVisibility(nsIView *aView, nsViewVisibility nsView* parentView = view->GetParent(); if (parentView) { parentView->GetViewManager()-> - UpdateView(parentView, view->GetBoundsInParentUnits()); + InvalidateView(parentView, view->GetBoundsInParentUnits()); } } else { - UpdateView(view); + InvalidateView(view); } } } @@ -1275,7 +1275,7 @@ NS_IMETHODIMP nsViewManager::SetViewZIndex(nsIView *aView, bool aAutoZIndex, PRI if (oldidx != aZIndex || oldTopMost != aTopMost || oldIsAuto != aAutoZIndex) { - UpdateView(view); + InvalidateView(view); } return rv; diff --git a/view/src/nsViewManager.h b/view/src/nsViewManager.h index 7e73dfc472ed..31f6b0da80c9 100644 --- a/view/src/nsViewManager.h +++ b/view/src/nsViewManager.h @@ -102,9 +102,9 @@ public: NS_IMETHOD SetWindowDimensions(nscoord width, nscoord height); NS_IMETHOD FlushDelayedResize(bool aDoReflow); - NS_IMETHOD UpdateView(nsIView *aView); - NS_IMETHOD UpdateViewNoSuppression(nsIView *aView, const nsRect &aRect); - NS_IMETHOD UpdateAllViews(); + NS_IMETHOD InvalidateView(nsIView *aView); + NS_IMETHOD InvalidateViewNoSuppression(nsIView *aView, const nsRect &aRect); + NS_IMETHOD InvalidateAllViews(); NS_IMETHOD DispatchEvent(nsGUIEvent *aEvent, nsIView* aTargetView, nsEventStatus* aStatus); @@ -163,9 +163,9 @@ private: void CallDidPaintOnObservers(); void ReparentChildWidgets(nsIView* aView, nsIWidget *aNewWidget); void ReparentWidgets(nsIView* aView, nsIView *aParent); - void UpdateWidgetArea(nsView *aWidgetView, const nsRegion &aDamagedRegion); + void InvalidateWidgetArea(nsView *aWidgetView, const nsRegion &aDamagedRegion); - void UpdateViews(nsView *aView); + void InvalidateViews(nsView *aView); // aView is the view for aWidget and aRegion is relative to aWidget. void Refresh(nsView *aView, nsIWidget *aWidget, const nsIntRegion& aRegion); @@ -200,7 +200,7 @@ private: RootViewManager()->mPainting = aPainting; } - nsresult UpdateView(nsIView *aView, const nsRect &aRect); + nsresult InvalidateView(nsIView *aView, const nsRect &aRect); public: // NOT in nsIViewManager, so private to the view module nsView* GetRootViewImpl() const { return mRootView; } diff --git a/widget/src/gtk2/nsNativeThemeGTK.cpp b/widget/src/gtk2/nsNativeThemeGTK.cpp index 97eb4c9f0b62..a4ed7b64b993 100644 --- a/widget/src/gtk2/nsNativeThemeGTK.cpp +++ b/widget/src/gtk2/nsNativeThemeGTK.cpp @@ -116,7 +116,7 @@ nsNativeThemeGTK::RefreshWidgetWindow(nsIFrame* aFrame) if (!vm) return; - vm->UpdateAllViews(); + vm->InvalidateAllViews(); } static bool IsFrameContentNodeInNamespace(nsIFrame *aFrame, PRUint32 aNamespace)