Bug 675015. Wait until scrolling is complete to dispatch synthetic mouse moves. r=roc

This commit is contained in:
Timothy Nikkel 2012-01-18 22:13:02 -06:00
parent 87deebd24e
commit 29578a4ba9
2 changed files with 36 additions and 1 deletions

View File

@ -1486,6 +1486,11 @@ nsGfxScrollFrameInner::~nsGfxScrollFrameInner()
gScrollFrameActivityTracker = nsnull;
}
delete mAsyncScroll;
if (mScrollActivityTimer) {
mScrollActivityTimer->Cancel();
mScrollActivityTimer = nsnull;
}
}
static nscoord
@ -1818,6 +1823,31 @@ nsGfxScrollFrameInner::ClampAndRestrictToDevPixels(const nsPoint& aPt,
NSIntPixelsToAppUnits(aPtDevPx->y, appUnitsPerDevPixel));
}
/* static */ void
nsGfxScrollFrameInner::ScrollActivityCallback(nsITimer *aTimer, void* anInstance)
{
nsGfxScrollFrameInner* self = static_cast<nsGfxScrollFrameInner*>(anInstance);
// Fire the synth mouse move.
self->mScrollActivityTimer->Cancel();
self->mScrollActivityTimer = nsnull;
self->mOuter->PresContext()->PresShell()->SynthesizeMouseMove(true);
}
void
nsGfxScrollFrameInner::ScheduleSyntheticMouseMove()
{
if (!mScrollActivityTimer) {
mScrollActivityTimer = do_CreateInstance("@mozilla.org/timer;1");
if (!mScrollActivityTimer)
return;
}
mScrollActivityTimer->InitWithFuncCallback(
ScrollActivityCallback, this, 100, nsITimer::TYPE_ONE_SHOT);
}
void
nsGfxScrollFrameInner::ScrollToImpl(nsPoint aPt)
{
@ -1851,7 +1881,7 @@ nsGfxScrollFrameInner::ScrollToImpl(nsPoint aPt)
// We pass in the amount to move visually
ScrollVisual(oldScrollFramePos);
presContext->PresShell()->SynthesizeMouseMove(true);
ScheduleSyntheticMouseMove();
UpdateScrollbarPosition();
PostScrollEvent();

View File

@ -266,6 +266,9 @@ public:
void MarkInactive();
nsExpirationState* GetExpirationState() { return &mActivityExpirationState; }
void ScheduleSyntheticMouseMove();
static void ScrollActivityCallback(nsITimer *aTimer, void* anInstance);
// owning references to the nsIAnonymousContentCreator-built content
nsCOMPtr<nsIContent> mHScrollbarContent;
nsCOMPtr<nsIContent> mVScrollbarContent;
@ -296,6 +299,8 @@ public:
nsExpirationState mActivityExpirationState;
nsCOMPtr<nsITimer> mScrollActivityTimer;
bool mNeverHasVerticalScrollbar:1;
bool mNeverHasHorizontalScrollbar:1;
bool mHasVerticalScrollbar:1;