From 0e4ff6afd5094b2d2ab9c7900e5fed8fd2cdea71 Mon Sep 17 00:00:00 2001 From: "Olli.Pettay%helsinki.fi" Date: Mon, 8 Oct 2007 08:42:43 +0000 Subject: [PATCH] Bug 397641, AsyncScrollPortEvent posted even if overflow/underflow event won't be dispatched r=mats+roc, sr=mats, a=roc git-svn-id: svn://10.0.0.236/trunk@237398 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/generic/nsGfxScrollFrame.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/mozilla/layout/generic/nsGfxScrollFrame.cpp b/mozilla/layout/generic/nsGfxScrollFrame.cpp index 7a313bc0c1a..b64a7b5aeb8 100644 --- a/mozilla/layout/generic/nsGfxScrollFrame.cpp +++ b/mozilla/layout/generic/nsGfxScrollFrame.cpp @@ -651,8 +651,6 @@ nsHTMLScrollFrame::PlaceScrollArea(const ScrollReflowState& aState) scrolledView, &scrolledArea, NS_FRAME_NO_MOVE_VIEW); - - mInner.PostOverflowEvent(); } /* virtual */ nscoord @@ -794,6 +792,7 @@ nsHTMLScrollFrame::Reflow(nsPresContext* aPresContext, aStatus = NS_FRAME_COMPLETE; NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize); + mInner.PostOverflowEvent(); return rv; } @@ -1497,6 +1496,8 @@ nsresult nsGfxScrollFrameInner::FireScrollPortEvent() { mAsyncScrollPortEvent.Forget(); + + // Keep this in sync with PostOverflowEvent(). nsSize scrollportSize = GetScrollPortSize(); nsSize childSize = GetScrolledRect(scrollportSize).Size(); @@ -2043,6 +2044,20 @@ void nsGfxScrollFrameInner::PostOverflowEvent() if (mAsyncScrollPortEvent.IsPending()) return; + // Keep this in sync with FireScrollPortEvent(). + nsSize scrollportSize = GetScrollPortSize(); + nsSize childSize = GetScrolledRect(scrollportSize).Size(); + + PRBool newVerticalOverflow = childSize.height > scrollportSize.height; + PRBool vertChanged = mVerticalOverflow != newVerticalOverflow; + + PRBool newHorizontalOverflow = childSize.width > scrollportSize.width; + PRBool horizChanged = mHorizontalOverflow != newHorizontalOverflow; + + if (!vertChanged && !horizChanged) { + return; + } + nsRefPtr ev = new AsyncScrollPortEvent(this); if (NS_SUCCEEDED(NS_DispatchToCurrentThread(ev))) mAsyncScrollPortEvent = ev;