diff --git a/mozilla/content/base/src/nsGenericElement.cpp b/mozilla/content/base/src/nsGenericElement.cpp index d878931da08..3a1104c4926 100644 --- a/mozilla/content/base/src/nsGenericElement.cpp +++ b/mozilla/content/base/src/nsGenericElement.cpp @@ -1808,7 +1808,8 @@ nsGenericElement::HandleDOMEvent(nsIPresContext* aPresContext, //Capturing stage evaluation if (NS_EVENT_FLAG_BUBBLE != aFlags && aEvent->message != NS_PAGE_LOAD && aEvent->message != NS_SCRIPT_LOAD && - aEvent->message != NS_IMAGE_ERROR && aEvent->message != NS_IMAGE_LOAD) { + aEvent->message != NS_IMAGE_ERROR && aEvent->message != NS_IMAGE_LOAD && + aEvent->message != NS_SCROLL_EVENT) { //Initiate capturing phase. Special case first call to document if (parent) { parent->HandleDOMEvent(aPresContext, aEvent, aDOMEvent, NS_EVENT_FLAG_CAPTURE, aEventStatus); @@ -1835,6 +1836,10 @@ nsGenericElement::HandleDOMEvent(nsIPresContext* aPresContext, nsCOMPtr curTarg(do_QueryInterface(NS_STATIC_CAST(nsIHTMLContent *, this))); mDOMSlots->mListenerManager->HandleEvent(aPresContext, aEvent, aDOMEvent, curTarg, aFlags, 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) { @@ -1849,7 +1854,8 @@ nsGenericElement::HandleDOMEvent(nsIPresContext* aPresContext, //Bubbling stage if (NS_EVENT_FLAG_CAPTURE != aFlags && mDocument && aEvent->message != NS_PAGE_LOAD && aEvent->message != NS_SCRIPT_LOAD && - aEvent->message != NS_IMAGE_ERROR && aEvent->message != NS_IMAGE_LOAD) { + aEvent->message != NS_IMAGE_ERROR && aEvent->message != NS_IMAGE_LOAD && + !(aEvent->message == NS_SCROLL_EVENT && aEvent->flags == NS_EVENT_FLAG_CANT_BUBBLE)) { 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 1b1bbf9073c..c31ef5e3efb 100644 --- a/mozilla/layout/generic/nsGfxScrollFrame.cpp +++ b/mozilla/layout/generic/nsGfxScrollFrame.cpp @@ -71,7 +71,7 @@ #include "nsIPrintPreviewContext.h" #include "nsIURI.h" - +#include "nsGUIEvent.h" //---------------------------------------------------------------------- class nsGfxScrollFrameInner : public nsIDocumentObserver, @@ -890,6 +890,8 @@ nsGfxScrollFrameInner::AttributeChanged(nsIDocument *aDocument, hframe->GetContent(getter_AddRefs(hcontent)); vframe->GetContent(getter_AddRefs(vcontent)); + nsIFrame * targetFrame = nsnull; + nsCOMPtr targetContent; if (hcontent.get() == aContent || vcontent.get() == aContent) { nscoord x = 0; @@ -902,6 +904,8 @@ nsGfxScrollFrameInner::AttributeChanged(nsIDocument *aDocument, // convert it to an integer x = value.ToInteger(&error); + targetFrame = hframe; + targetContent = hcontent; } if (NS_CONTENT_ATTR_HAS_VALUE == vcontent->GetAttr(kNameSpaceID_None, nsXULAtoms::curpos, value)) @@ -910,8 +914,23 @@ nsGfxScrollFrameInner::AttributeChanged(nsIDocument *aDocument, // convert it to an integer y = value.ToInteger(&error); + targetFrame = vframe; + targetContent = vcontent; } + nsScrollbarEvent event; + event.eventStructType = NS_SCROLLBAR_EVENT; + event.message = NS_SCROLL_EVENT; + event.flags = 0; + nsEventStatus status = nsEventStatus_eIgnore; + nsCOMPtr presShell; + mOuter->mPresContext->GetShell(getter_AddRefs(presShell)); + + // Fire the onScroll event. + if (presShell && targetFrame && targetContent) + presShell->HandleEventWithTarget(&event, targetFrame, targetContent, + NS_EVENT_FLAG_INIT, &status); + nsIScrollableView* s = GetScrollableView(mOuter->mPresContext); s->RemoveScrollPositionListener(this); ScrollbarChanged(mOuter->mPresContext, x*mOnePixel, y*mOnePixel); diff --git a/mozilla/layout/html/base/src/nsGfxScrollFrame.cpp b/mozilla/layout/html/base/src/nsGfxScrollFrame.cpp index 1b1bbf9073c..c31ef5e3efb 100644 --- a/mozilla/layout/html/base/src/nsGfxScrollFrame.cpp +++ b/mozilla/layout/html/base/src/nsGfxScrollFrame.cpp @@ -71,7 +71,7 @@ #include "nsIPrintPreviewContext.h" #include "nsIURI.h" - +#include "nsGUIEvent.h" //---------------------------------------------------------------------- class nsGfxScrollFrameInner : public nsIDocumentObserver, @@ -890,6 +890,8 @@ nsGfxScrollFrameInner::AttributeChanged(nsIDocument *aDocument, hframe->GetContent(getter_AddRefs(hcontent)); vframe->GetContent(getter_AddRefs(vcontent)); + nsIFrame * targetFrame = nsnull; + nsCOMPtr targetContent; if (hcontent.get() == aContent || vcontent.get() == aContent) { nscoord x = 0; @@ -902,6 +904,8 @@ nsGfxScrollFrameInner::AttributeChanged(nsIDocument *aDocument, // convert it to an integer x = value.ToInteger(&error); + targetFrame = hframe; + targetContent = hcontent; } if (NS_CONTENT_ATTR_HAS_VALUE == vcontent->GetAttr(kNameSpaceID_None, nsXULAtoms::curpos, value)) @@ -910,8 +914,23 @@ nsGfxScrollFrameInner::AttributeChanged(nsIDocument *aDocument, // convert it to an integer y = value.ToInteger(&error); + targetFrame = vframe; + targetContent = vcontent; } + nsScrollbarEvent event; + event.eventStructType = NS_SCROLLBAR_EVENT; + event.message = NS_SCROLL_EVENT; + event.flags = 0; + nsEventStatus status = nsEventStatus_eIgnore; + nsCOMPtr presShell; + mOuter->mPresContext->GetShell(getter_AddRefs(presShell)); + + // Fire the onScroll event. + if (presShell && targetFrame && targetContent) + presShell->HandleEventWithTarget(&event, targetFrame, targetContent, + NS_EVENT_FLAG_INIT, &status); + nsIScrollableView* s = GetScrollableView(mOuter->mPresContext); s->RemoveScrollPositionListener(this); ScrollbarChanged(mOuter->mPresContext, x*mOnePixel, y*mOnePixel);