Bug 716793. Dispatch synthetic mousemove off the refresh driver, not as fast as we can. r=roc

We use Flush_Display here because mousemoves flush out layout, so we want to do the synthetic one after we've done our normal layout flushing
This commit is contained in:
Boris Zbarsky 2012-01-10 00:23:29 -05:00
parent 12b5bf3030
commit 4dd8e4b2c1
2 changed files with 17 additions and 5 deletions

View File

@ -5255,7 +5255,8 @@ void PresShell::SynthesizeMouseMove(bool aFromScroll)
nsRefPtr<nsSynthMouseMoveEvent> ev =
new nsSynthMouseMoveEvent(this, aFromScroll);
if (NS_FAILED(NS_DispatchToCurrentThread(ev))) {
if (!GetPresContext()->RefreshDriver()->AddRefreshObserver(ev,
Flush_Display)) {
NS_WARNING("failed to dispatch nsSynthMouseMoveEvent");
return;
}

View File

@ -852,17 +852,28 @@ private:
// over our window or there is no last observed mouse location for some
// reason.
nsPoint mMouseLocation;
class nsSynthMouseMoveEvent : public nsRunnable {
class nsSynthMouseMoveEvent : public nsARefreshObserver {
public:
nsSynthMouseMoveEvent(PresShell* aPresShell, bool aFromScroll)
: mPresShell(aPresShell), mFromScroll(aFromScroll) {
NS_ASSERTION(mPresShell, "null parameter");
}
void Revoke() { mPresShell = nsnull; }
NS_IMETHOD Run() {
~nsSynthMouseMoveEvent() {
Revoke();
}
NS_INLINE_DECL_REFCOUNTING(nsSynthMouseMoveEvent)
void Revoke() {
if (mPresShell) {
mPresShell->GetPresContext()->RefreshDriver()->
RemoveRefreshObserver(this, Flush_Display);
mPresShell = nsnull;
}
}
virtual void WillRefresh(mozilla::TimeStamp aTime) {
if (mPresShell)
mPresShell->ProcessSynthMouseMoveEvent(mFromScroll);
return NS_OK;
}
private:
PresShell* mPresShell;