diff --git a/content/base/public/nsIDocument.h b/content/base/public/nsIDocument.h index 547be7daaa5..36bd5435778 100644 --- a/content/base/public/nsIDocument.h +++ b/content/base/public/nsIDocument.h @@ -1518,11 +1518,7 @@ public: */ virtual Element* LookupImageElement(const nsAString& aElementId) = 0; - void ScheduleBeforePaintEvent(nsIFrameRequestCallback* aCallback); - void BeforePaintEventFiring() - { - mHavePendingPaint = false; - } + void ScheduleFrameRequestCallback(nsIFrameRequestCallback* aCallback); typedef nsTArray< nsCOMPtr > FrameRequestCallbackList; /** @@ -1746,9 +1742,6 @@ protected: // True if document has ever had script handling object. bool mHasHadScriptHandlingObject; - // True if we're waiting for a before-paint event. - bool mHavePendingPaint; - // True if we're an SVG document being used as an image. bool mIsBeingUsedAsImage; diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 43735f152b9..a80e1354e3a 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -3214,9 +3214,6 @@ nsDocument::MaybeRescheduleAnimationFrameNotifications() } nsRefreshDriver* rd = mPresShell->GetPresContext()->RefreshDriver(); - if (mHavePendingPaint) { - rd->ScheduleBeforePaintEvent(this); - } if (!mFrameRequestCallbacks.IsEmpty()) { rd->ScheduleFrameRequestCallbacks(this); } @@ -3243,9 +3240,6 @@ nsDocument::DeleteShell() void nsDocument::RevokeAnimationFrameNotifications() { - if (mHavePendingPaint) { - mPresShell->GetPresContext()->RefreshDriver()->RevokeBeforePaintEvent(this); - } if (!mFrameRequestCallbacks.IsEmpty()) { mPresShell->GetPresContext()->RefreshDriver()-> RevokeFrameRequestCallbacks(this); @@ -8074,30 +8068,14 @@ nsIDocument::CreateStaticClone(nsISupports* aCloneContainer) } void -nsIDocument::ScheduleBeforePaintEvent(nsIFrameRequestCallback* aCallback) +nsIDocument::ScheduleFrameRequestCallback(nsIFrameRequestCallback* aCallback) { - if (aCallback) { - bool alreadyRegistered = !mFrameRequestCallbacks.IsEmpty(); - if (mFrameRequestCallbacks.AppendElement(aCallback) && - !alreadyRegistered && mPresShell && IsEventHandlingEnabled()) { - mPresShell->GetPresContext()->RefreshDriver()-> - ScheduleFrameRequestCallbacks(this); - } - - return; + bool alreadyRegistered = !mFrameRequestCallbacks.IsEmpty(); + if (mFrameRequestCallbacks.AppendElement(aCallback) && + !alreadyRegistered && mPresShell && IsEventHandlingEnabled()) { + mPresShell->GetPresContext()->RefreshDriver()-> + ScheduleFrameRequestCallbacks(this); } - - if (!mHavePendingPaint) { - // We don't want to use GetShell() here, because we want to schedule the - // paint even if we're frozen. Either we'll get unfrozen and then the - // event will fire, or we'll quietly go away at some point. - mHavePendingPaint = - !mPresShell || - !IsEventHandlingEnabled() || - mPresShell->GetPresContext()->RefreshDriver()-> - ScheduleBeforePaintEvent(this); - } - } nsresult diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index f1c502167c6..c0c6fc86704 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -3966,7 +3966,7 @@ nsGlobalWindow::MozRequestAnimationFrame(nsIFrameRequestCallback* aCallback) return NS_OK; } - mDoc->ScheduleBeforePaintEvent(aCallback); + mDoc->ScheduleFrameRequestCallback(aCallback); return NS_OK; } diff --git a/dom/interfaces/base/nsIDOMWindow.idl b/dom/interfaces/base/nsIDOMWindow.idl index d3938e9dea0..dadc78e3293 100644 --- a/dom/interfaces/base/nsIDOMWindow.idl +++ b/dom/interfaces/base/nsIDOMWindow.idl @@ -418,7 +418,7 @@ interface nsIDOMWindow : nsISupports * @see */ void - mozRequestAnimationFrame([optional] in nsIFrameRequestCallback aCallback); + mozRequestAnimationFrame(in nsIFrameRequestCallback aCallback); /** * The current animation start time in milliseconds since the epoch. diff --git a/layout/base/nsRefreshDriver.cpp b/layout/base/nsRefreshDriver.cpp index fe2d5e87496..acda81fda55 100644 --- a/layout/base/nsRefreshDriver.cpp +++ b/layout/base/nsRefreshDriver.cpp @@ -269,7 +269,6 @@ nsRefreshDriver::ObserverCount() const // style changes, etc. sum += mStyleFlushObservers.Length(); sum += mLayoutFlushObservers.Length(); - sum += mBeforePaintTargets.Length(); sum += mFrameRequestCallbackDocs.Length(); return sum; } @@ -365,16 +364,7 @@ nsRefreshDriver::Notify(nsITimer *aTimer) } if (i == 0) { - // Don't just loop while we have things in mBeforePaintTargets, - // the whole point is that event handlers should readd the - // target as needed. - nsTArray< nsCOMPtr > targets; - targets.SwapElements(mBeforePaintTargets); - for (PRUint32 i = 0; i < targets.Length(); ++i) { - targets[i]->BeforePaintEventFiring(); - } - - // Also grab all of our frame request callbacks up front. + // Grab all of our frame request callbacks up front. nsIDocument::FrameRequestCallbackList frameRequestCallbacks; for (PRUint32 i = 0; i < mFrameRequestCallbackDocs.Length(); ++i) { mFrameRequestCallbackDocs[i]-> @@ -385,12 +375,6 @@ nsRefreshDriver::Notify(nsITimer *aTimer) mFrameRequestCallbackDocs.Clear(); PRInt64 eventTime = mMostRecentRefreshEpochTime / PR_USEC_PER_MSEC; - for (PRUint32 i = 0; i < targets.Length(); ++i) { - nsEvent ev(true, NS_BEFOREPAINT); - ev.time = eventTime; - nsEventDispatcher::Dispatch(targets[i], nsnull, &ev); - } - for (PRUint32 i = 0; i < frameRequestCallbacks.Length(); ++i) { frameRequestCallbacks[i]->Sample(eventTime); } @@ -541,17 +525,6 @@ nsRefreshDriver::IsRefreshObserver(nsARefreshObserver *aObserver, } #endif -bool -nsRefreshDriver::ScheduleBeforePaintEvent(nsIDocument* aDocument) -{ - NS_ASSERTION(mBeforePaintTargets.IndexOf(aDocument) == - mBeforePaintTargets.NoIndex, - "Shouldn't have a paint event posted for this document"); - bool appended = mBeforePaintTargets.AppendElement(aDocument) != nsnull; - EnsureTimerStarted(false); - return appended; -} - void nsRefreshDriver::ScheduleFrameRequestCallbacks(nsIDocument* aDocument) { @@ -564,12 +537,6 @@ nsRefreshDriver::ScheduleFrameRequestCallbacks(nsIDocument* aDocument) EnsureTimerStarted(false); } -void -nsRefreshDriver::RevokeBeforePaintEvent(nsIDocument* aDocument) -{ - mBeforePaintTargets.RemoveElement(aDocument); -} - void nsRefreshDriver::RevokeFrameRequestCallbacks(nsIDocument* aDocument) { diff --git a/layout/base/nsRefreshDriver.h b/layout/base/nsRefreshDriver.h index c378cfd6089..8c0b01dec5d 100644 --- a/layout/base/nsRefreshDriver.h +++ b/layout/base/nsRefreshDriver.h @@ -176,21 +176,11 @@ public: return mLayoutFlushObservers.Contains(aShell); } - /** - * Add a document for which we should fire a MozBeforePaint event. - */ - bool ScheduleBeforePaintEvent(nsIDocument* aDocument); - /** * Add a document for which we have nsIFrameRequestCallbacks */ void ScheduleFrameRequestCallbacks(nsIDocument* aDocument); - /** - * Remove a document for which we should fire a MozBeforePaint event. - */ - void RevokeBeforePaintEvent(nsIDocument* aDocument); - /** * Remove a document for which we have nsIFrameRequestCallbacks */ @@ -283,8 +273,6 @@ private: nsAutoTArray mStyleFlushObservers; nsAutoTArray mLayoutFlushObservers; // nsTArray on purpose, because we want to be able to swap. - nsTArray< nsCOMPtr > mBeforePaintTargets; - // nsTArray on purpose, because we want to be able to swap. nsTArray mFrameRequestCallbackDocs; // This is the last interval we used for our timer. May be 0 if we