send native events to plugins on mouse enter and exit. b=332597 r=smichaud sr=roc

This commit is contained in:
joshmoz@gmail.com 2007-09-05 22:11:35 -07:00
Родитель 18da58e54b
Коммит 6e096da88c
1 изменённых файлов: 24 добавлений и 11 удалений

Просмотреть файл

@ -87,6 +87,11 @@
PRLogModuleInfo* sCocoaLog = nsnull;
#endif
// npapi.h defines NPEventType_AdjustCursorEvent but we don't want to include npapi.h here.
// We need to send this in the "what" field for certain native plugin events. WebKit does
// this as well.
#define adjustCursorEvent 33
extern "C" {
CG_EXTERN void CGContextResetCTM(CGContextRef);
CG_EXTERN void CGContextSetCTM(CGContextRef, CGAffineTransform);
@ -2621,11 +2626,12 @@ class nsNonNativeContextMenuEvent : public nsRunnable {
}
static nsEventStatus SendMouseEvent(PRBool isTrusted,
PRUint32 msg,
nsIWidget *widget,
nsMouseEvent::reasonType aReason,
NSPoint* localEventLocation)
// sends a mouse enter or exit event into gecko
static nsEventStatus SendGeckoMouseEnterOrExitEvent(PRBool isTrusted,
PRUint32 msg,
nsIWidget *widget,
nsMouseEvent::reasonType aReason,
NSPoint* localEventLocation)
{
if (!widget || !localEventLocation)
return nsEventStatus_eIgnore;
@ -2634,6 +2640,14 @@ static nsEventStatus SendMouseEvent(PRBool isTrusted,
event.refPoint.x = nscoord((PRInt32)localEventLocation->x);
event.refPoint.y = nscoord((PRInt32)localEventLocation->y);
EventRecord macEvent;
macEvent.what = adjustCursorEvent;
macEvent.message = 0;
macEvent.when = ::TickCount();
::GetGlobalMouse(&macEvent.where);
macEvent.modifiers = GetCurrentKeyModifiers();
event.nativeMsg = &macEvent;
nsEventStatus status;
widget->DispatchEvent(&event, status);
return status;
@ -2655,7 +2669,7 @@ static nsEventStatus SendMouseEvent(PRBool isTrusted,
if (![NSApp isActive] && ![ChildView mouseEventIsOverRollupWidget:theEvent]) {
if (sLastViewEntered) {
nsIWidget* lastViewEnteredWidget = [(NSView<mozView>*)sLastViewEntered widget];
SendMouseEvent(PR_TRUE, NS_MOUSE_EXIT, lastViewEnteredWidget, nsMouseEvent::eReal, &viewEventLocation);
SendGeckoMouseEnterOrExitEvent(PR_TRUE, NS_MOUSE_EXIT, lastViewEnteredWidget, nsMouseEvent::eReal, &viewEventLocation);
sLastViewEntered = nil;
}
return;
@ -2733,7 +2747,7 @@ static nsEventStatus SendMouseEvent(PRBool isTrusted,
if (sLastViewEntered) {
// NSLog(@"sending NS_MOUSE_EXIT event with point %f,%f\n", viewEventLocation.x, viewEventLocation.y);
nsIWidget* lastViewEnteredWidget = [(NSView<mozView>*)sLastViewEntered widget];
SendMouseEvent(PR_TRUE, NS_MOUSE_EXIT, lastViewEnteredWidget, nsMouseEvent::eReal, &viewEventLocation);
SendGeckoMouseEnterOrExitEvent(PR_TRUE, NS_MOUSE_EXIT, lastViewEnteredWidget, nsMouseEvent::eReal, &viewEventLocation);
sLastViewEntered = nil;
}
return;
@ -2748,11 +2762,11 @@ static nsEventStatus SendMouseEvent(PRBool isTrusted,
if (sLastViewEntered) {
// NSLog(@"sending NS_MOUSE_EXIT event with point %f,%f\n", viewEventLocation.x, viewEventLocation.y);
nsIWidget* lastViewEnteredWidget = [(NSView<mozView>*)sLastViewEntered widget];
SendMouseEvent(PR_TRUE, NS_MOUSE_EXIT, lastViewEnteredWidget, nsMouseEvent::eReal, &viewEventLocation);
SendGeckoMouseEnterOrExitEvent(PR_TRUE, NS_MOUSE_EXIT, lastViewEnteredWidget, nsMouseEvent::eReal, &viewEventLocation);
}
// NSLog(@"sending NS_MOUSE_ENTER event with point %f,%f\n", viewEventLocation.x, viewEventLocation.y);
SendMouseEvent(PR_TRUE, NS_MOUSE_ENTER, mGeckoChild, nsMouseEvent::eReal, &viewEventLocation);
SendGeckoMouseEnterOrExitEvent(PR_TRUE, NS_MOUSE_ENTER, mGeckoChild, nsMouseEvent::eReal, &viewEventLocation);
// mark this view as the last view entered
sLastViewEntered = (NSView*)self;
@ -2772,11 +2786,10 @@ static nsEventStatus SendMouseEvent(PRBool isTrusted,
// create native EventRecord for use by plugins
EventRecord macEvent;
macEvent.what = nullEvent;
macEvent.what = adjustCursorEvent;
macEvent.message = 0;
macEvent.when = ::TickCount();
::GetGlobalMouse(&macEvent.where);
macEvent.modifiers = GetCurrentKeyModifiers();
geckoEvent.nativeMsg = &macEvent;