From 1a8fc22417a38c525313affb9386aa891f770094 Mon Sep 17 00:00:00 2001 From: Markus Stange Date: Fri, 23 Dec 2011 22:52:21 -0500 Subject: [PATCH] Bug 598482 part 2 - Remove synchronous painting APIs from nsIViewManager. r=roc --- dom/plugins/base/nsPluginInstanceOwner.cpp | 6 -- layout/base/nsPresShell.cpp | 21 ------ layout/xul/base/src/nsListBoxBodyFrame.cpp | 9 --- view/public/nsIViewManager.h | 20 ------ view/src/nsViewManager.cpp | 75 +--------------------- view/src/nsViewManager.h | 9 --- 6 files changed, 1 insertion(+), 139 deletions(-) diff --git a/dom/plugins/base/nsPluginInstanceOwner.cpp b/dom/plugins/base/nsPluginInstanceOwner.cpp index fcda12e45af..28001885af0 100644 --- a/dom/plugins/base/nsPluginInstanceOwner.cpp +++ b/dom/plugins/base/nsPluginInstanceOwner.cpp @@ -654,12 +654,6 @@ NS_IMETHODIMP nsPluginInstanceOwner::InvalidateRegion(NPRegion invalidRegion) NS_IMETHODIMP nsPluginInstanceOwner::ForceRedraw() { - NS_ENSURE_TRUE(mObjectFrame, NS_ERROR_NULL_POINTER); - nsIView* view = mObjectFrame->GetView(); - if (view) { - return view->GetViewManager()->Composite(); - } - return NS_OK; } diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 098f7fc3fd9..1d24dd3dff4 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -2468,17 +2468,6 @@ PresShell::ScrollLine(bool aForward) scrollFrame->ScrollBy(nsIntPoint(0, aForward ? lineCount : -lineCount), nsIScrollableFrame::LINES, nsIScrollableFrame::SMOOTH); - -//NEW FOR LINES - // force the update to happen now, otherwise multiple scrolls can - // occur before the update is processed. (bug #7354) - - // I'd use Composite here, but it doesn't always work. - // vm->Composite(); - nsIViewManager* viewManager = GetViewManager(); - if (viewManager) { - viewManager->ForceUpdate(); - } } return NS_OK; } @@ -2492,16 +2481,6 @@ PresShell::ScrollCharacter(bool aRight) scrollFrame->ScrollBy(nsIntPoint(aRight ? 1 : -1, 0), nsIScrollableFrame::LINES, nsIScrollableFrame::SMOOTH); -//NEW FOR LINES - // force the update to happen now, otherwise multiple scrolls can - // occur before the update is processed. (bug #7354) - - // I'd use Composite here, but it doesn't always work. - // vm->Composite(); - nsIViewManager* viewManager = GetViewManager(); - if (viewManager) { - viewManager->ForceUpdate(); - } } return NS_OK; } diff --git a/layout/xul/base/src/nsListBoxBodyFrame.cpp b/layout/xul/base/src/nsListBoxBodyFrame.cpp index bd02444a00a..566a9c60a71 100644 --- a/layout/xul/base/src/nsListBoxBodyFrame.cpp +++ b/layout/xul/base/src/nsListBoxBodyFrame.cpp @@ -559,15 +559,6 @@ nsListBoxBodyFrame::ScrollByLines(PRInt32 aNumLines) ScrollToIndex(scrollIndex); - // we have to do a sync update for mac because if we scroll too quickly - // w/out going back to the main event loop we can easily scroll the wrong - // bits and it looks like garbage (bug 63465). - // XXXbz is this seriously still needed? - - // I'd use Composite here, but it doesn't always work. - // vm->Composite(); - PresContext()->GetPresShell()->GetViewManager()->ForceUpdate(); - return NS_OK; } diff --git a/view/public/nsIViewManager.h b/view/public/nsIViewManager.h index 608944b63be..674ddd7e810 100644 --- a/view/public/nsIViewManager.h +++ b/view/public/nsIViewManager.h @@ -116,16 +116,6 @@ public: */ NS_IMETHOD FlushDelayedResize(bool aDoReflow) = 0; - /** - * Called to force a redrawing of any dirty areas. - */ - // XXXbz why is this exposed? Shouldn't update view batches handle this? - // It's not like Composite() does what's expected inside a view update batch - // anyway, since dirty areas may not have been invalidated on the widget yet - // and widget changes may not have been propagated yet. Maybe this should - // call FlushPendingInvalidates()? - NS_IMETHOD Composite(void) = 0; - /** * Called to inform the view manager that the entire area of a view * is dirty and needs to be redrawn. @@ -351,16 +341,6 @@ public: */ NS_IMETHOD GetRootWidget(nsIWidget **aWidget) = 0; - /** - * Force update of view manager widget - * Callers should use UpdateView(view, NS_VMREFRESH_IMMEDIATE) in most cases instead - * @result error status - */ - // XXXbz Callers seem to be confused about this one... and it doesn't play - // right with view update batching at all (will miss updates). Maybe this - // should call FlushPendingInvalidates()? - NS_IMETHOD ForceUpdate() = 0; - /** * Indicate whether the viewmanager is currently painting * diff --git a/view/src/nsViewManager.cpp b/view/src/nsViewManager.cpp index 61c8af143b3..4784c98f69e 100644 --- a/view/src/nsViewManager.cpp +++ b/view/src/nsViewManager.cpp @@ -461,17 +461,6 @@ void nsViewManager::ProcessPendingUpdates(nsView* aView, bool aDoInvalidate) } } -NS_IMETHODIMP nsViewManager::Composite() -{ - if (!IsRootVM()) { - return RootViewManager()->Composite(); - } - ForceUpdate(); - ClearUpdateCount(); - - return NS_OK; -} - NS_IMETHODIMP nsViewManager::UpdateView(nsIView *aView, PRUint32 aUpdateFlags) { // Mark the entire view as damaged @@ -657,15 +646,6 @@ NS_IMETHODIMP nsViewManager::UpdateViewNoSuppression(nsIView *aView, RootViewManager()->IncrementUpdateCount(); - if (!IsRefreshEnabled()) { - return NS_OK; - } - - // See if we should do an immediate refresh or wait - if (aUpdateFlags & NS_VMREFRESH_IMMEDIATE) { - Composite(); - } - return NS_OK; } @@ -1341,37 +1321,6 @@ NS_IMETHODIMP nsViewManager::SetViewVisibility(nsIView *aView, nsViewVisibility return NS_OK; } -void nsViewManager::UpdateWidgetsForView(nsView* aView) -{ - NS_PRECONDITION(aView, "Must have view!"); - - // No point forcing an update if invalidations have been suppressed. - if (!IsRefreshEnabled()) - return; - - nsWeakView parentWeakView = aView; - if (aView->HasWidget()) { - aView->GetWidget()->Update(); // Flushes Layout! - if (!parentWeakView.IsAlive()) { - return; - } - } - - nsView* childView = aView->GetFirstChild(); - while (childView) { - nsWeakView childWeakView = childView; - UpdateWidgetsForView(childView); - if (NS_LIKELY(childWeakView.IsAlive())) { - childView = childView->GetNextSibling(); - } - else { - // The current view was destroyed - restart at the first child if the - // parent is still alive. - childView = parentWeakView.IsAlive() ? aView->GetFirstChild() : nsnull; - } - } -} - bool nsViewManager::IsViewInserted(nsView *aView) { if (mRootView == aView) { @@ -1438,15 +1387,7 @@ void nsViewManager::TriggerRefresh(PRUint32 aUpdateFlags) if (mUpdateBatchCnt > 0) return; - // nested batching can combine IMMEDIATE with DEFERRED. Favour - // IMMEDIATE over DEFERRED and DEFERRED over NO_SYNC. We need to - // check for IMMEDIATE before checking mHasPendingUpdates, because - // the latter might be false as far as gecko is concerned but the OS - // might still have queued up expose events that it hasn't sent yet. - if (aUpdateFlags & NS_VMREFRESH_IMMEDIATE) { - FlushPendingInvalidates(); - Composite(); - } else if (!mHasPendingUpdates) { + if (!mHasPendingUpdates) { // Nothing to do } else if (aUpdateFlags & NS_VMREFRESH_DEFERRED) { PostInvalidateEvent(); @@ -1509,20 +1450,6 @@ NS_IMETHODIMP nsViewManager::GetRootWidget(nsIWidget **aWidget) return NS_OK; } -NS_IMETHODIMP nsViewManager::ForceUpdate() -{ - if (!IsRootVM()) { - return RootViewManager()->ForceUpdate(); - } - - // Walk the view tree looking for widgets, and call Update() on each one - if (mRootView) { - UpdateWidgetsForView(mRootView); - } - - return NS_OK; -} - nsIntRect nsViewManager::ViewToWidget(nsView *aView, const nsRect &aRect) const { NS_ASSERTION(aView->GetViewManager() == this, "wrong view manager"); diff --git a/view/src/nsViewManager.h b/view/src/nsViewManager.h index 1aa94632feb..1be861b4e5e 100644 --- a/view/src/nsViewManager.h +++ b/view/src/nsViewManager.h @@ -104,8 +104,6 @@ public: NS_IMETHOD SetWindowDimensions(nscoord width, nscoord height); NS_IMETHOD FlushDelayedResize(bool aDoReflow); - NS_IMETHOD Composite(void); - NS_IMETHOD UpdateView(nsIView *aView, PRUint32 aUpdateFlags); NS_IMETHOD UpdateViewNoSuppression(nsIView *aView, const nsRect &aRect, PRUint32 aUpdateFlags); @@ -141,7 +139,6 @@ public: NS_IMETHOD EndUpdateViewBatch(PRUint32 aUpdateFlags); NS_IMETHOD GetRootWidget(nsIWidget **aWidget); - NS_IMETHOD ForceUpdate(); NS_IMETHOD IsPainting(bool& aIsPainting); NS_IMETHOD GetLastUserEventTime(PRUint32& aTime); @@ -189,12 +186,6 @@ private: bool IsViewInserted(nsView *aView); - /** - * Function to recursively call Update() on all widgets belonging to - * a view or its kids. - */ - void UpdateWidgetsForView(nsView* aView); - /** * Intersects aRect with aView's bounds and then transforms it from aView's * coordinate system to the coordinate system of the widget attached to