mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 10:44:56 +00:00
Call WillPaint() on all descendant view observers. b=517772 r=bzbarsky r=roc
This commit is contained in:
parent
2d83c2550e
commit
3b7aeeee5a
@ -943,10 +943,8 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent,
|
||||
if (!didResize) {
|
||||
//NS_ASSERTION(IsViewVisible(view), "painting an invisible view");
|
||||
|
||||
// Just notify our own view observer that we're about to paint
|
||||
// XXXbz do we need to notify other view observers for viewmanagers
|
||||
// in our tree?
|
||||
// Make sure to not send WillPaint notifications while scrolling
|
||||
// Notify view observers that we're about to paint.
|
||||
// Make sure to not send WillPaint notifications while scrolling.
|
||||
nsRefPtr<nsViewManager> rootVM = RootViewManager();
|
||||
|
||||
nsCOMPtr<nsIWidget> widget;
|
||||
@ -971,7 +969,7 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent,
|
||||
// We should really sort out the rules on our synch painting
|
||||
// api....
|
||||
UpdateViewBatch batch(this);
|
||||
observer->WillPaint();
|
||||
rootVM->CallWillPaintOnObservers();
|
||||
batch.EndUpdateViewBatch(NS_VMREFRESH_NO_SYNC);
|
||||
|
||||
// Get the view pointer again since the code above might have
|
||||
@ -1988,22 +1986,9 @@ nsViewManager::FlushPendingInvalidates()
|
||||
PRBool refreshEnabled = mRefreshEnabled;
|
||||
mRefreshEnabled = PR_FALSE;
|
||||
++mUpdateBatchCnt;
|
||||
|
||||
PRInt32 index;
|
||||
for (index = 0; index < mVMCount; index++) {
|
||||
nsViewManager* vm = (nsViewManager*)gViewManagers->ElementAt(index);
|
||||
if (vm->RootViewManager() == this) {
|
||||
// One of our kids
|
||||
nsIViewObserver* observer = vm->GetViewObserver();
|
||||
if (observer) {
|
||||
observer->WillPaint();
|
||||
NS_ASSERTION(mUpdateBatchCnt == 1,
|
||||
"Observer did not end view batch?");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CallWillPaintOnObservers();
|
||||
--mUpdateBatchCnt;
|
||||
|
||||
// Someone could have called EnableRefresh on us from inside WillPaint().
|
||||
// Only reset the old mRefreshEnabled value if the current value is false.
|
||||
if (!mRefreshEnabled) {
|
||||
@ -2017,6 +2002,30 @@ nsViewManager::FlushPendingInvalidates()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsViewManager::CallWillPaintOnObservers()
|
||||
{
|
||||
NS_PRECONDITION(IsRootVM(), "Must be root VM for this to be called!\n");
|
||||
NS_PRECONDITION(mUpdateBatchCnt > 0, "Must be in an update batch!");
|
||||
|
||||
#ifdef DEBUG
|
||||
PRInt32 savedUpdateBatchCnt = mUpdateBatchCnt;
|
||||
#endif
|
||||
PRInt32 index;
|
||||
for (index = 0; index < mVMCount; index++) {
|
||||
nsViewManager* vm = (nsViewManager*)gViewManagers->ElementAt(index);
|
||||
if (vm->RootViewManager() == this) {
|
||||
// One of our kids.
|
||||
nsCOMPtr<nsIViewObserver> obs = vm->GetViewObserver();
|
||||
if (obs) {
|
||||
obs->WillPaint();
|
||||
NS_ASSERTION(mUpdateBatchCnt == savedUpdateBatchCnt,
|
||||
"Observer did not end view batch?");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsViewManager::ProcessInvalidateEvent()
|
||||
{
|
||||
|
@ -197,6 +197,10 @@ private:
|
||||
|
||||
void FlushPendingInvalidates();
|
||||
void ProcessPendingUpdates(nsView *aView, PRBool aDoInvalidate);
|
||||
/**
|
||||
* Call WillPaint() on all view observers under this vm root.
|
||||
*/
|
||||
void CallWillPaintOnObservers();
|
||||
void ReparentChildWidgets(nsIView* aView, nsIWidget *aNewWidget);
|
||||
void ReparentWidgets(nsIView* aView, nsIView *aParent);
|
||||
already_AddRefed<nsIRenderingContext> CreateRenderingContext(nsView &aView);
|
||||
|
Loading…
Reference in New Issue
Block a user