From b747c5efb56bd0cd7391c606555be3aec04bfcff Mon Sep 17 00:00:00 2001 From: "roc+%cs.cmu.edu" Date: Fri, 7 Oct 2005 01:28:27 +0000 Subject: [PATCH] Bug 305160. Target viewport scroll events at the document, not the root element (they will bubble to the window from there). Always stop bubbling of scroll events out of an element. r+sr=jst git-svn-id: svn://10.0.0.236/trunk@181748 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/base/src/nsGenericElement.cpp | 10 +++------- mozilla/layout/generic/nsGfxScrollFrame.cpp | 20 ++++++++++++++----- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/mozilla/content/base/src/nsGenericElement.cpp b/mozilla/content/base/src/nsGenericElement.cpp index c2ce3dda58b..1de67bffc0b 100644 --- a/mozilla/content/base/src/nsGenericElement.cpp +++ b/mozilla/content/base/src/nsGenericElement.cpp @@ -2144,11 +2144,6 @@ nsGenericElement::HandleDOMEvent(nsPresContext* aPresContext, aEventStatus); aEvent->flags &= ~aFlags; - - // We don't want scroll events to bubble further after it has been - // handled at the local stage. - if (aEvent->message == NS_SCROLL_EVENT && aFlags & NS_EVENT_FLAG_BUBBLE) - aEvent->flags |= NS_EVENT_FLAG_CANT_BUBBLE; } if (retarget) { @@ -2165,8 +2160,9 @@ nsGenericElement::HandleDOMEvent(nsPresContext* aPresContext, if (NS_EVENT_FLAG_BUBBLE & aFlags && IsInDoc() && aEvent->message != NS_PAGE_LOAD && aEvent->message != NS_SCRIPT_LOAD && aEvent->message != NS_IMAGE_ERROR && aEvent->message != NS_IMAGE_LOAD && - !(aEvent->message == NS_SCROLL_EVENT && - aEvent->flags & NS_EVENT_FLAG_CANT_BUBBLE)) { + // scroll events fired at elements don't bubble (although scroll events + // fired at documents do, to the window) + aEvent->message != NS_SCROLL_EVENT) { if (parent) { // If there's a parent we pass the event to the parent... diff --git a/mozilla/layout/generic/nsGfxScrollFrame.cpp b/mozilla/layout/generic/nsGfxScrollFrame.cpp index ef925ac4ab6..68086e00d6c 100644 --- a/mozilla/layout/generic/nsGfxScrollFrame.cpp +++ b/mozilla/layout/generic/nsGfxScrollFrame.cpp @@ -1824,13 +1824,23 @@ void nsGfxScrollFrameInner::FireScrollEvent() { mScrollEventQueue = nsnull; - nsIPresShell *presShell = mOuter->GetPresContext()->GetPresShell(); - if (!presShell) - return; + nsScrollbarEvent event(PR_TRUE, NS_SCROLL_EVENT, nsnull); nsEventStatus status = nsEventStatus_eIgnore; - presShell->HandleEventWithTarget(&event, mOuter, mOuter->GetContent(), - NS_EVENT_FLAG_INIT, &status); + nsIContent* content = mOuter->GetContent(); + nsPresContext* prescontext = mOuter->GetPresContext(); + // Fire viewport scroll events at the document (where they + // will bubble to the window) + if (mIsRoot) { + nsIDocument* doc = content->GetCurrentDoc(); + if (doc) { + doc->HandleDOMEvent(prescontext, &event, nsnull, + NS_EVENT_FLAG_INIT, &status); + } + } else { + content->HandleDOMEvent(prescontext, &event, nsnull, + NS_EVENT_FLAG_INIT, &status); + } } void