From 46ec98b10e5f307b48d594ef570975e98650b47c Mon Sep 17 00:00:00 2001 From: "joshmoz%gmail.com" Date: Wed, 12 Apr 2006 17:51:32 +0000 Subject: [PATCH] handle popup rollup correctly when scrolling. b=330999 r=mento --- widget/src/cocoa/nsChildView.mm | 12 +++++++++++- widget/src/cocoa/nsNativeScrollbar.mm | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/widget/src/cocoa/nsChildView.mm b/widget/src/cocoa/nsChildView.mm index 3be3dc812e7..e7481f8362d 100644 --- a/widget/src/cocoa/nsChildView.mm +++ b/widget/src/cocoa/nsChildView.mm @@ -20,6 +20,7 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): + * Josh Aas * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or @@ -2871,7 +2872,7 @@ static nsEventStatus SendMouseEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w // No sense in firing off a Gecko event. Note that as of 10.4 Tiger, // a single NSScrollWheel event might result in deltaX = deltaY = 0. return; - + nsMouseScrollEvent geckoEvent(PR_TRUE, 0, nsnull); [self convertEvent:theEvent message:NS_MOUSE_SCROLL toGeckoEvent:&geckoEvent]; geckoEvent.scrollFlags |= inAxis; @@ -2932,6 +2933,15 @@ static nsEventStatus SendMouseEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w -(void)scrollWheel:(NSEvent*)theEvent { + // close popups if we're supposed to... + if (gRollupListener && gRollupWidget && + [self window] != gRollupWidget->GetNativeData(NS_NATIVE_WINDOW)) { + PRBool rollup = PR_FALSE; + gRollupListener->ShouldRollupOnMouseWheelEvent(&rollup); + if (rollup) + gRollupListener->Rollup(); + } + // It's possible for a single NSScrollWheel event to carry both useful // deltaX and deltaY, for example, when the "wheel" is a trackpad. // NSMouseScrollEvent can only carry one axis at a time, so the system diff --git a/widget/src/cocoa/nsNativeScrollbar.mm b/widget/src/cocoa/nsNativeScrollbar.mm index d35dac507f0..1ddb4fa6328 100644 --- a/widget/src/cocoa/nsNativeScrollbar.mm +++ b/widget/src/cocoa/nsNativeScrollbar.mm @@ -43,9 +43,13 @@ #include "nsINameSpaceManager.h" #include "nsIDOMElement.h" #include "nsIScrollbarMediator.h" +#include "nsIRollupListener.h" NS_IMPL_ISUPPORTS_INHERITED1(nsNativeScrollbar, nsChildView, nsINativeScrollbar) +extern nsIRollupListener * gRollupListener; +extern nsIWidget * gRollupWidget; + inline void BoundsCheck(PRInt32 low, PRUint32& value, PRUint32 high) { if ((PRInt32) value < low) @@ -678,7 +682,13 @@ nsNativeScrollbar::UpdateScroller() // - (IBAction)scroll:(NSScroller*)sender { - if ( mGeckoChild ) + // roll up popup windows if there are any + if (gRollupListener && gRollupWidget && + gRollupWidget->GetNativeData(NS_NATIVE_WINDOW) != [self getNativeWindow]) { + gRollupListener->Rollup(); + } + + if (mGeckoChild) mGeckoChild->DoScroll([sender hitPart]); }