зеркало из https://github.com/mozilla/gecko-dev.git
Add support for "setConsumeRollupEvent" on Mac OS X. b=415440 r=mstange sr=roc
This commit is contained in:
Родитель
98311e5904
Коммит
a255f48df4
|
@ -124,7 +124,9 @@ CFStringRef kOurTISPropertyUnicodeKeyLayoutData = NULL;
|
|||
CFStringRef kOurTISPropertyInputSourceID = NULL;
|
||||
CFStringRef kOurTISPropertyInputSourceLanguages = NULL;
|
||||
|
||||
extern PRBool gCocoaWindowMethodsSwizzled; // Defined in nsCocoaWindow.mm
|
||||
// these are defined in nsCocoaWindow.mm
|
||||
extern PRBool gCocoaWindowMethodsSwizzled;
|
||||
extern PRBool gConsumeRollupEvent;
|
||||
|
||||
PRBool gChildViewMethodsSwizzled = PR_FALSE;
|
||||
|
||||
|
@ -3197,24 +3199,27 @@ static const PRInt32 sShadowInvalidationInterval = 100;
|
|||
}
|
||||
|
||||
|
||||
// Returns true if the event should no longer be processed, false otherwise.
|
||||
// This does not return whether or not anything was rolled up.
|
||||
- (BOOL)maybeRollup:(NSEvent*)theEvent
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
|
||||
|
||||
PRBool retVal = PR_FALSE;
|
||||
BOOL consumeEvent = NO;
|
||||
|
||||
if (gRollupWidget && gRollupListener) {
|
||||
NSWindow* currentPopup = static_cast<NSWindow*>(gRollupWidget->GetNativeData(NS_NATIVE_WINDOW));
|
||||
if (!nsCocoaUtils::IsEventOverWindow(theEvent, currentPopup)) {
|
||||
PRBool rollup = PR_TRUE;
|
||||
// event is not over the rollup window, default is to roll up
|
||||
PRBool shouldRollup = PR_TRUE;
|
||||
|
||||
// check to see if scroll events should roll up the popup
|
||||
if ([theEvent type] == NSScrollWheel) {
|
||||
gRollupListener->ShouldRollupOnMouseWheelEvent(&rollup);
|
||||
// We don't want the event passed on for scrollwheel events if we're
|
||||
// not supposed to close the popup. Otherwise the background window
|
||||
// will scroll when a custom context menu or the autoscroll popup is
|
||||
// open (and the mouse isn't over the popup) -- which doesn't seem right.
|
||||
// This change resolves bmo bug 344367.
|
||||
retVal = PR_TRUE;
|
||||
gRollupListener->ShouldRollupOnMouseWheelEvent(&shouldRollup);
|
||||
// always consume scroll events that aren't over the popup
|
||||
consumeEvent = YES;
|
||||
}
|
||||
|
||||
// if we're dealing with menus, we probably have submenus and
|
||||
// we don't want to rollup if the click is in a parent menu of
|
||||
// the current submenu
|
||||
|
@ -3227,21 +3232,20 @@ static const PRInt32 sShadowInvalidationInterval = 100;
|
|||
nsIWidget* widget = widgetChain[i];
|
||||
NSWindow* currWindow = (NSWindow*)widget->GetNativeData(NS_NATIVE_WINDOW);
|
||||
if (nsCocoaUtils::IsEventOverWindow(theEvent, currWindow)) {
|
||||
rollup = PR_FALSE;
|
||||
shouldRollup = PR_FALSE;
|
||||
break;
|
||||
}
|
||||
} // foreach parent menu widget
|
||||
} // if rollup listener knows about menus
|
||||
}
|
||||
}
|
||||
|
||||
// if we've determined that we should still rollup, do it.
|
||||
if (rollup) {
|
||||
if (shouldRollup) {
|
||||
gRollupListener->Rollup(nsnull);
|
||||
retVal = PR_TRUE;
|
||||
consumeEvent = (BOOL)gConsumeRollupEvent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
return consumeEvent;
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(NO);
|
||||
}
|
||||
|
|
|
@ -81,6 +81,8 @@ nsCocoaWindowList *gGeckoAppModalWindowList = NULL;
|
|||
|
||||
PRBool gCocoaWindowMethodsSwizzled = PR_FALSE;
|
||||
|
||||
PRBool gConsumeRollupEvent;
|
||||
|
||||
// defined in nsMenuBarX.mm
|
||||
extern NSMenu* sApplicationMenu; // Application menu shared by all menubars
|
||||
|
||||
|
@ -1286,6 +1288,9 @@ NS_IMETHODIMP nsCocoaWindow::CaptureRollupEvents(nsIRollupListener * aListener,
|
|||
NS_ADDREF(aListener);
|
||||
gRollupWidget = this;
|
||||
NS_ADDREF(this);
|
||||
|
||||
gConsumeRollupEvent = aConsumeRollupEvent;
|
||||
|
||||
// Sometimes more than one popup window can be visible at the same time
|
||||
// (e.g. nested non-native context menus, or the test case (attachment
|
||||
// 276885) for bmo bug 392389, which displays a non-native combo-box in
|
||||
|
|
Загрузка…
Ссылка в новой задаче