зеркало из https://github.com/mozilla/gecko-dev.git
64-bit fixes for Mac OS X nsChildView, part 1. b=513777 r=mstange
This commit is contained in:
Родитель
29ff03752c
Коммит
ea03ce7acd
|
@ -60,7 +60,7 @@
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
#include "nsIDragService.h"
|
#include "nsIDragService.h"
|
||||||
|
|
||||||
#include "nsplugindefs.h"
|
#include "npapi.h"
|
||||||
|
|
||||||
#import <Carbon/Carbon.h>
|
#import <Carbon/Carbon.h>
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
@ -130,7 +130,7 @@ enum {
|
||||||
nsChildView* mGeckoChild;
|
nsChildView* mGeckoChild;
|
||||||
|
|
||||||
BOOL mIsPluginView;
|
BOOL mIsPluginView;
|
||||||
BOOL mSendCarbonPluginEvents; // true if we should send carbon events to plugins
|
NPEventModel mPluginEventModel;
|
||||||
|
|
||||||
// The following variables are only valid during key down event processing.
|
// The following variables are only valid during key down event processing.
|
||||||
// Their current usage needs to be fixed to avoid problems with nested event
|
// Their current usage needs to be fixed to avoid problems with nested event
|
||||||
|
|
|
@ -77,8 +77,6 @@
|
||||||
#include "nsMenuUtilsX.h"
|
#include "nsMenuUtilsX.h"
|
||||||
#include "nsMenuBarX.h"
|
#include "nsMenuBarX.h"
|
||||||
|
|
||||||
#include "npapi.h"
|
|
||||||
|
|
||||||
#include "gfxContext.h"
|
#include "gfxContext.h"
|
||||||
#include "gfxQuartzSurface.h"
|
#include "gfxQuartzSurface.h"
|
||||||
|
|
||||||
|
@ -179,8 +177,8 @@ PRUint32 nsChildView::sLastInputEventCount = 0;
|
||||||
|
|
||||||
- (void)setIsPluginView:(BOOL)aIsPlugin;
|
- (void)setIsPluginView:(BOOL)aIsPlugin;
|
||||||
- (BOOL)isPluginView;
|
- (BOOL)isPluginView;
|
||||||
- (void)setSendCarbonPluginEvents:(BOOL)sendCarbonEvents;
|
- (void)setPluginEventModel:(NPEventModel)eventModel;
|
||||||
- (BOOL)shouldSendCarbonPluginEvents;
|
- (NPEventModel)pluginEventModel;
|
||||||
|
|
||||||
- (BOOL)childViewHasPlugin;
|
- (BOOL)childViewHasPlugin;
|
||||||
|
|
||||||
|
@ -891,7 +889,9 @@ void nsChildView::UpdatePluginPort()
|
||||||
NS_ASSERTION(mIsPluginView, "UpdatePluginPort called on non-plugin view");
|
NS_ASSERTION(mIsPluginView, "UpdatePluginPort called on non-plugin view");
|
||||||
|
|
||||||
NSWindow* cocoaWindow = [mView nativeWindow];
|
NSWindow* cocoaWindow = [mView nativeWindow];
|
||||||
|
#if !defined(NP_NO_CARBON) || !defined(NP_NO_QUICKDRAW)
|
||||||
WindowRef carbonWindow = cocoaWindow ? (WindowRef)[cocoaWindow windowRef] : NULL;
|
WindowRef carbonWindow = cocoaWindow ? (WindowRef)[cocoaWindow windowRef] : NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (mPluginIsCG) {
|
if (mPluginIsCG) {
|
||||||
// [NSGraphicsContext currentContext] is supposed to "return the
|
// [NSGraphicsContext currentContext] is supposed to "return the
|
||||||
|
@ -903,18 +903,23 @@ void nsChildView::UpdatePluginPort()
|
||||||
// graphics context. See bug 500130.
|
// graphics context. See bug 500130.
|
||||||
mPluginPort.cgPort.context = NULL;
|
mPluginPort.cgPort.context = NULL;
|
||||||
mPluginPort.cgPort.window = NULL;
|
mPluginPort.cgPort.window = NULL;
|
||||||
if ([(ChildView*)mView shouldSendCarbonPluginEvents]) {
|
#ifndef NP_NO_CARBON
|
||||||
|
if ([(ChildView*)mView pluginEventModel] == NPEventModelCarbon) {
|
||||||
if (carbonWindow) {
|
if (carbonWindow) {
|
||||||
mPluginPort.cgPort.context = (CGContextRef)[[cocoaWindow graphicsContext] graphicsPort];
|
mPluginPort.cgPort.context = (CGContextRef)[[cocoaWindow graphicsContext] graphicsPort];
|
||||||
mPluginPort.cgPort.window = carbonWindow;
|
mPluginPort.cgPort.window = carbonWindow;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
#endif
|
||||||
|
if ([(ChildView*)mView pluginEventModel] == NPEventModelCocoa) {
|
||||||
if (cocoaWindow) {
|
if (cocoaWindow) {
|
||||||
mPluginPort.cgPort.context = (CGContextRef)[[cocoaWindow graphicsContext] graphicsPort];
|
mPluginPort.cgPort.context = (CGContextRef)[[cocoaWindow graphicsContext] graphicsPort];
|
||||||
mPluginPort.cgPort.window = cocoaWindow;
|
mPluginPort.cgPort.window = cocoaWindow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
#ifndef NP_NO_QUICKDRAW
|
||||||
|
else {
|
||||||
if (carbonWindow) {
|
if (carbonWindow) {
|
||||||
mPluginPort.qdPort.port = ::GetWindowPort(carbonWindow);
|
mPluginPort.qdPort.port = ::GetWindowPort(carbonWindow);
|
||||||
|
|
||||||
|
@ -930,6 +935,7 @@ void nsChildView::UpdatePluginPort()
|
||||||
mPluginPort.qdPort.port = NULL;
|
mPluginPort.qdPort.port = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void HideChildPluginViews(NSView* aView)
|
static void HideChildPluginViews(NSView* aView)
|
||||||
|
@ -1259,7 +1265,7 @@ NS_IMETHODIMP nsChildView::GetPluginClipRect(nsIntRect& outClipRect, nsIntPoint&
|
||||||
|
|
||||||
if (mClipRects) {
|
if (mClipRects) {
|
||||||
nsIntRect clipBounds;
|
nsIntRect clipBounds;
|
||||||
for (PRUint32 i = 0; i < mClipRectCount; ++i) {
|
for (PRInt32 i = 0; i < mClipRectCount; ++i) {
|
||||||
clipBounds.UnionRect(clipBounds, mClipRects[i]);
|
clipBounds.UnionRect(clipBounds, mClipRects[i]);
|
||||||
}
|
}
|
||||||
outClipRect.IntersectRect(outClipRect, clipBounds - outOrigin);
|
outClipRect.IntersectRect(outClipRect, clipBounds - outOrigin);
|
||||||
|
@ -1286,6 +1292,10 @@ NS_IMETHODIMP nsChildView::StartDrawPlugin()
|
||||||
NS_ASSERTION(mIsPluginView, "StartDrawPlugin must only be called on a plugin widget");
|
NS_ASSERTION(mIsPluginView, "StartDrawPlugin must only be called on a plugin widget");
|
||||||
if (!mIsPluginView) return NS_ERROR_FAILURE;
|
if (!mIsPluginView) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
|
// This code is necessary for both Quickdraw and CoreGraphics in 32-bit builds.
|
||||||
|
// See comments below about why. In 64-bit CoreGraphics mode we will not keep
|
||||||
|
// this region up to date, plugins should not depend on it.
|
||||||
|
#ifndef __LP64__
|
||||||
NSWindow* window = [mView nativeWindow];
|
NSWindow* window = [mView nativeWindow];
|
||||||
if (!window)
|
if (!window)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
@ -1350,6 +1360,7 @@ NS_IMETHODIMP nsChildView::StartDrawPlugin()
|
||||||
if (portChanged)
|
if (portChanged)
|
||||||
::SetGWorld(oldPort, oldDevice);
|
::SetGWorld(oldPort, oldDevice);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
mPluginDrawing = PR_TRUE;
|
mPluginDrawing = PR_TRUE;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -1375,13 +1386,13 @@ NS_IMETHODIMP nsChildView::SetPluginInstanceOwner(nsIPluginInstanceOwner* aInsta
|
||||||
|
|
||||||
NS_IMETHODIMP nsChildView::SetPluginEventModel(int inEventModel)
|
NS_IMETHODIMP nsChildView::SetPluginEventModel(int inEventModel)
|
||||||
{
|
{
|
||||||
[(ChildView*)mView setSendCarbonPluginEvents:(inEventModel != NPEventModelCocoa)];
|
[(ChildView*)mView setPluginEventModel:(NPEventModel)inEventModel];
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsChildView::GetPluginEventModel(int* outEventModel)
|
NS_IMETHODIMP nsChildView::GetPluginEventModel(int* outEventModel)
|
||||||
{
|
{
|
||||||
*outEventModel = ([(ChildView*)mView shouldSendCarbonPluginEvents] ? NPEventModelCarbon : NPEventModelCocoa);
|
*outEventModel = [(ChildView*)mView pluginEventModel];
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2171,8 +2182,11 @@ NSEvent* gLastDragEvent = nil;
|
||||||
mWindow = nil;
|
mWindow = nil;
|
||||||
mGeckoChild = inChild;
|
mGeckoChild = inChild;
|
||||||
mIsPluginView = NO;
|
mIsPluginView = NO;
|
||||||
mSendCarbonPluginEvents = YES;
|
#ifndef NP_NO_CARBON
|
||||||
|
mPluginEventModel = NPEventModelCarbon;
|
||||||
|
#else
|
||||||
|
mPluginEventModel = NPEventModelCocoa;
|
||||||
|
#endif
|
||||||
mCurKeyEvent = nil;
|
mCurKeyEvent = nil;
|
||||||
mKeyDownHandled = PR_FALSE;
|
mKeyDownHandled = PR_FALSE;
|
||||||
mKeyPressHandled = NO;
|
mKeyPressHandled = NO;
|
||||||
|
@ -2240,9 +2254,11 @@ NSEvent* gLastDragEvent = nil;
|
||||||
|
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
|
|
||||||
|
#ifndef NP_NO_QUICKDRAW
|
||||||
// This sets the current port to _savePort.
|
// This sets the current port to _savePort.
|
||||||
// todo: Only do if a Quickdraw plugin is present in the hierarchy!
|
// todo: Only do if a Quickdraw plugin is present in the hierarchy!
|
||||||
::SetPort(NULL);
|
::SetPort(NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||||
}
|
}
|
||||||
|
@ -2377,14 +2393,14 @@ NSEvent* gLastDragEvent = nil;
|
||||||
return mIsPluginView;
|
return mIsPluginView;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setSendCarbonPluginEvents:(BOOL)sendCarbonEvents
|
- (void)setPluginEventModel:(NPEventModel)eventModel
|
||||||
{
|
{
|
||||||
mSendCarbonPluginEvents = sendCarbonEvents;
|
mPluginEventModel = eventModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)shouldSendCarbonPluginEvents
|
- (NPEventModel)pluginEventModel;
|
||||||
{
|
{
|
||||||
return mSendCarbonPluginEvents;
|
return mPluginEventModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)childViewHasPlugin
|
- (BOOL)childViewHasPlugin
|
||||||
|
@ -2586,7 +2602,7 @@ static const PRInt32 sShadowInvalidationInterval = 100;
|
||||||
NSRectToGeckoRect(aRect, fullRect);
|
NSRectToGeckoRect(aRect, fullRect);
|
||||||
|
|
||||||
const NSRect *rects;
|
const NSRect *rects;
|
||||||
int count, i;
|
NSInteger count, i;
|
||||||
[self getRectsBeingDrawn:&rects count:&count];
|
[self getRectsBeingDrawn:&rects count:&count];
|
||||||
if (count < MAX_RECTS_IN_REGION) {
|
if (count < MAX_RECTS_IN_REGION) {
|
||||||
for (i = 0; i < count; ++i) {
|
for (i = 0; i < count; ++i) {
|
||||||
|
@ -3123,9 +3139,9 @@ static const PRInt32 sShadowInvalidationInterval = 100;
|
||||||
// Create event for use by plugins.
|
// Create event for use by plugins.
|
||||||
// This is going to our child view so we don't need to look up the destination
|
// This is going to our child view so we don't need to look up the destination
|
||||||
// event type.
|
// event type.
|
||||||
|
#ifndef NP_NO_CARBON
|
||||||
EventRecord carbonEvent;
|
EventRecord carbonEvent;
|
||||||
NPCocoaEvent cocoaEvent;
|
if (mPluginEventModel == NPEventModelCarbon) {
|
||||||
if (mSendCarbonPluginEvents) {
|
|
||||||
carbonEvent.what = mouseDown;
|
carbonEvent.what = mouseDown;
|
||||||
carbonEvent.message = 0;
|
carbonEvent.message = 0;
|
||||||
carbonEvent.when = ::TickCount();
|
carbonEvent.when = ::TickCount();
|
||||||
|
@ -3133,7 +3149,9 @@ static const PRInt32 sShadowInvalidationInterval = 100;
|
||||||
carbonEvent.modifiers = ::GetCurrentEventKeyModifiers();
|
carbonEvent.modifiers = ::GetCurrentEventKeyModifiers();
|
||||||
geckoEvent.nativeMsg = &carbonEvent;
|
geckoEvent.nativeMsg = &carbonEvent;
|
||||||
}
|
}
|
||||||
else {
|
#endif
|
||||||
|
NPCocoaEvent cocoaEvent;
|
||||||
|
if (mPluginEventModel == NPEventModelCocoa) {
|
||||||
InitNPCocoaEvent(&cocoaEvent);
|
InitNPCocoaEvent(&cocoaEvent);
|
||||||
NSPoint point = [self convertPoint:[theEvent locationInWindow] fromView:nil];
|
NSPoint point = [self convertPoint:[theEvent locationInWindow] fromView:nil];
|
||||||
cocoaEvent.type = NPCocoaEventMouseDown;
|
cocoaEvent.type = NPCocoaEventMouseDown;
|
||||||
|
@ -3175,9 +3193,9 @@ static const PRInt32 sShadowInvalidationInterval = 100;
|
||||||
// Create event for use by plugins.
|
// Create event for use by plugins.
|
||||||
// This is going to our child view so we don't need to look up the destination
|
// This is going to our child view so we don't need to look up the destination
|
||||||
// event type.
|
// event type.
|
||||||
|
#ifndef NP_NO_CARBON
|
||||||
EventRecord carbonEvent;
|
EventRecord carbonEvent;
|
||||||
NPCocoaEvent cocoaEvent;
|
if (mPluginEventModel == NPEventModelCarbon) {
|
||||||
if (mSendCarbonPluginEvents) {
|
|
||||||
carbonEvent.what = mouseUp;
|
carbonEvent.what = mouseUp;
|
||||||
carbonEvent.message = 0;
|
carbonEvent.message = 0;
|
||||||
carbonEvent.when = ::TickCount();
|
carbonEvent.when = ::TickCount();
|
||||||
|
@ -3185,7 +3203,9 @@ static const PRInt32 sShadowInvalidationInterval = 100;
|
||||||
carbonEvent.modifiers = ::GetCurrentEventKeyModifiers();
|
carbonEvent.modifiers = ::GetCurrentEventKeyModifiers();
|
||||||
geckoEvent.nativeMsg = &carbonEvent;
|
geckoEvent.nativeMsg = &carbonEvent;
|
||||||
}
|
}
|
||||||
else {
|
#endif
|
||||||
|
NPCocoaEvent cocoaEvent;
|
||||||
|
if (mPluginEventModel == NPEventModelCocoa) {
|
||||||
InitNPCocoaEvent(&cocoaEvent);
|
InitNPCocoaEvent(&cocoaEvent);
|
||||||
NSPoint point = [self convertPoint:[theEvent locationInWindow] fromView:nil];
|
NSPoint point = [self convertPoint:[theEvent locationInWindow] fromView:nil];
|
||||||
cocoaEvent.type = NPCocoaEventMouseUp;
|
cocoaEvent.type = NPCocoaEventMouseUp;
|
||||||
|
@ -3235,8 +3255,8 @@ static nsEventStatus SendGeckoMouseEnterOrExitEvent(PRBool isTrusted,
|
||||||
int eventModel;
|
int eventModel;
|
||||||
pluginWidget->GetPluginEventModel(&eventModel);
|
pluginWidget->GetPluginEventModel(&eventModel);
|
||||||
|
|
||||||
|
#ifndef NP_NO_CARBON
|
||||||
EventRecord carbonEvent;
|
EventRecord carbonEvent;
|
||||||
NPCocoaEvent cocoaEvent;
|
|
||||||
if (static_cast<NPEventModel>(eventModel) == NPEventModelCarbon) {
|
if (static_cast<NPEventModel>(eventModel) == NPEventModelCarbon) {
|
||||||
carbonEvent.what = NPEventType_AdjustCursorEvent;
|
carbonEvent.what = NPEventType_AdjustCursorEvent;
|
||||||
carbonEvent.message = 0;
|
carbonEvent.message = 0;
|
||||||
|
@ -3245,7 +3265,9 @@ static nsEventStatus SendGeckoMouseEnterOrExitEvent(PRBool isTrusted,
|
||||||
carbonEvent.modifiers = ::GetCurrentEventKeyModifiers();
|
carbonEvent.modifiers = ::GetCurrentEventKeyModifiers();
|
||||||
event.nativeMsg = &carbonEvent;
|
event.nativeMsg = &carbonEvent;
|
||||||
}
|
}
|
||||||
else {
|
#endif
|
||||||
|
NPCocoaEvent cocoaEvent;
|
||||||
|
if (static_cast<NPEventModel>(eventModel) == NPEventModelCocoa) {
|
||||||
InitNPCocoaEvent(&cocoaEvent);
|
InitNPCocoaEvent(&cocoaEvent);
|
||||||
cocoaEvent.type = ((msg == NS_MOUSE_ENTER) ? NPCocoaEventMouseEntered : NPCocoaEventMouseExited);
|
cocoaEvent.type = ((msg == NS_MOUSE_ENTER) ? NPCocoaEventMouseEntered : NPCocoaEventMouseExited);
|
||||||
cocoaEvent.data.mouse.modifierFlags = modifierFlags;
|
cocoaEvent.data.mouse.modifierFlags = modifierFlags;
|
||||||
|
@ -3388,9 +3410,9 @@ static nsEventStatus SendGeckoMouseEnterOrExitEvent(PRBool isTrusted,
|
||||||
// Create event for use by plugins.
|
// Create event for use by plugins.
|
||||||
// This is going to our child view so we don't need to look up the destination
|
// This is going to our child view so we don't need to look up the destination
|
||||||
// event type.
|
// event type.
|
||||||
|
#ifndef NP_NO_CARBON
|
||||||
EventRecord carbonEvent;
|
EventRecord carbonEvent;
|
||||||
NPCocoaEvent cocoaEvent;
|
if (mPluginEventModel == NPEventModelCarbon) {
|
||||||
if (mSendCarbonPluginEvents) {
|
|
||||||
carbonEvent.what = NPEventType_AdjustCursorEvent;
|
carbonEvent.what = NPEventType_AdjustCursorEvent;
|
||||||
carbonEvent.message = 0;
|
carbonEvent.message = 0;
|
||||||
carbonEvent.when = ::TickCount();
|
carbonEvent.when = ::TickCount();
|
||||||
|
@ -3398,7 +3420,9 @@ static nsEventStatus SendGeckoMouseEnterOrExitEvent(PRBool isTrusted,
|
||||||
carbonEvent.modifiers = ::GetCurrentEventKeyModifiers();
|
carbonEvent.modifiers = ::GetCurrentEventKeyModifiers();
|
||||||
geckoEvent.nativeMsg = &carbonEvent;
|
geckoEvent.nativeMsg = &carbonEvent;
|
||||||
}
|
}
|
||||||
else {
|
#endif
|
||||||
|
NPCocoaEvent cocoaEvent;
|
||||||
|
if (mPluginEventModel == NPEventModelCocoa) {
|
||||||
InitNPCocoaEvent(&cocoaEvent);
|
InitNPCocoaEvent(&cocoaEvent);
|
||||||
NSPoint point = [self convertPoint:[theEvent locationInWindow] fromView:nil];
|
NSPoint point = [self convertPoint:[theEvent locationInWindow] fromView:nil];
|
||||||
cocoaEvent.type = NPCocoaEventMouseMoved;
|
cocoaEvent.type = NPCocoaEventMouseMoved;
|
||||||
|
@ -3435,9 +3459,9 @@ static nsEventStatus SendGeckoMouseEnterOrExitEvent(PRBool isTrusted,
|
||||||
[self convertCocoaMouseEvent:theEvent toGeckoEvent:&geckoEvent];
|
[self convertCocoaMouseEvent:theEvent toGeckoEvent:&geckoEvent];
|
||||||
|
|
||||||
// create event for use by plugins
|
// create event for use by plugins
|
||||||
|
#ifndef NP_NO_CARBON
|
||||||
EventRecord carbonEvent;
|
EventRecord carbonEvent;
|
||||||
NPCocoaEvent cocoaEvent;
|
if (mPluginEventModel == NPEventModelCarbon) {
|
||||||
if (mSendCarbonPluginEvents) {
|
|
||||||
carbonEvent.what = nullEvent;
|
carbonEvent.what = nullEvent;
|
||||||
carbonEvent.message = 0;
|
carbonEvent.message = 0;
|
||||||
carbonEvent.when = ::TickCount();
|
carbonEvent.when = ::TickCount();
|
||||||
|
@ -3445,7 +3469,9 @@ static nsEventStatus SendGeckoMouseEnterOrExitEvent(PRBool isTrusted,
|
||||||
carbonEvent.modifiers = btnState | ::GetCurrentEventKeyModifiers();
|
carbonEvent.modifiers = btnState | ::GetCurrentEventKeyModifiers();
|
||||||
geckoEvent.nativeMsg = &carbonEvent;
|
geckoEvent.nativeMsg = &carbonEvent;
|
||||||
}
|
}
|
||||||
else {
|
#endif
|
||||||
|
NPCocoaEvent cocoaEvent;
|
||||||
|
if (mPluginEventModel == NPEventModelCocoa) {
|
||||||
InitNPCocoaEvent(&cocoaEvent);
|
InitNPCocoaEvent(&cocoaEvent);
|
||||||
NSPoint point = [self convertPoint:[theEvent locationInWindow] fromView:nil];
|
NSPoint point = [self convertPoint:[theEvent locationInWindow] fromView:nil];
|
||||||
cocoaEvent.type = NPCocoaEventMouseDragged;
|
cocoaEvent.type = NPCocoaEventMouseDragged;
|
||||||
|
@ -3492,9 +3518,9 @@ static nsEventStatus SendGeckoMouseEnterOrExitEvent(PRBool isTrusted,
|
||||||
geckoEvent.clickCount = [theEvent clickCount];
|
geckoEvent.clickCount = [theEvent clickCount];
|
||||||
|
|
||||||
// create event for use by plugins
|
// create event for use by plugins
|
||||||
|
#ifndef NP_NO_CARBON
|
||||||
EventRecord carbonEvent;
|
EventRecord carbonEvent;
|
||||||
NPCocoaEvent cocoaEvent;
|
if (mPluginEventModel == NPEventModelCarbon) {
|
||||||
if (mSendCarbonPluginEvents) {
|
|
||||||
carbonEvent.what = mouseDown;
|
carbonEvent.what = mouseDown;
|
||||||
carbonEvent.message = 0;
|
carbonEvent.message = 0;
|
||||||
carbonEvent.when = ::TickCount();
|
carbonEvent.when = ::TickCount();
|
||||||
|
@ -3502,7 +3528,9 @@ static nsEventStatus SendGeckoMouseEnterOrExitEvent(PRBool isTrusted,
|
||||||
carbonEvent.modifiers = controlKey; // fake a context menu click
|
carbonEvent.modifiers = controlKey; // fake a context menu click
|
||||||
geckoEvent.nativeMsg = &carbonEvent;
|
geckoEvent.nativeMsg = &carbonEvent;
|
||||||
}
|
}
|
||||||
else {
|
#endif
|
||||||
|
NPCocoaEvent cocoaEvent;
|
||||||
|
if (mPluginEventModel == NPEventModelCocoa) {
|
||||||
InitNPCocoaEvent(&cocoaEvent);
|
InitNPCocoaEvent(&cocoaEvent);
|
||||||
NSPoint point = [self convertPoint:[theEvent locationInWindow] fromView:nil];
|
NSPoint point = [self convertPoint:[theEvent locationInWindow] fromView:nil];
|
||||||
cocoaEvent.type = NPCocoaEventMouseDown;
|
cocoaEvent.type = NPCocoaEventMouseDown;
|
||||||
|
@ -3543,9 +3571,9 @@ static nsEventStatus SendGeckoMouseEnterOrExitEvent(PRBool isTrusted,
|
||||||
geckoEvent.clickCount = [theEvent clickCount];
|
geckoEvent.clickCount = [theEvent clickCount];
|
||||||
|
|
||||||
// create event for use by plugins
|
// create event for use by plugins
|
||||||
|
#ifndef NP_NO_CARBON
|
||||||
EventRecord carbonEvent;
|
EventRecord carbonEvent;
|
||||||
NPCocoaEvent cocoaEvent;
|
if (mPluginEventModel == NPEventModelCarbon) {
|
||||||
if (mSendCarbonPluginEvents) {
|
|
||||||
carbonEvent.what = mouseUp;
|
carbonEvent.what = mouseUp;
|
||||||
carbonEvent.message = 0;
|
carbonEvent.message = 0;
|
||||||
carbonEvent.when = ::TickCount();
|
carbonEvent.when = ::TickCount();
|
||||||
|
@ -3553,7 +3581,9 @@ static nsEventStatus SendGeckoMouseEnterOrExitEvent(PRBool isTrusted,
|
||||||
carbonEvent.modifiers = controlKey; // fake a context menu click
|
carbonEvent.modifiers = controlKey; // fake a context menu click
|
||||||
geckoEvent.nativeMsg = &carbonEvent;
|
geckoEvent.nativeMsg = &carbonEvent;
|
||||||
}
|
}
|
||||||
else {
|
#endif
|
||||||
|
NPCocoaEvent cocoaEvent;
|
||||||
|
if (mPluginEventModel == NPEventModelCocoa) {
|
||||||
InitNPCocoaEvent(&cocoaEvent);
|
InitNPCocoaEvent(&cocoaEvent);
|
||||||
NSPoint point = [self convertPoint:[theEvent locationInWindow] fromView:nil];
|
NSPoint point = [self convertPoint:[theEvent locationInWindow] fromView:nil];
|
||||||
cocoaEvent.type = NPCocoaEventMouseUp;
|
cocoaEvent.type = NPCocoaEventMouseUp;
|
||||||
|
@ -3642,6 +3672,8 @@ static nsEventStatus SendGeckoMouseEnterOrExitEvent(PRBool isTrusted,
|
||||||
mGeckoChild->DispatchWindowEvent(geckoEvent);
|
mGeckoChild->DispatchWindowEvent(geckoEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//XXXTODO handle scroll wheel events in 64-bit builds
|
||||||
|
#ifndef __LP64__
|
||||||
// Handle an NSScrollWheel event for a single axis only.
|
// Handle an NSScrollWheel event for a single axis only.
|
||||||
-(void)scrollWheel:(NSEvent*)theEvent forAxis:(enum nsMouseScrollEvent::nsMouseScrollFlags)inAxis
|
-(void)scrollWheel:(NSEvent*)theEvent forAxis:(enum nsMouseScrollEvent::nsMouseScrollFlags)inAxis
|
||||||
{
|
{
|
||||||
|
@ -3791,6 +3823,7 @@ static nsEventStatus SendGeckoMouseEnterOrExitEvent(PRBool isTrusted,
|
||||||
|
|
||||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
-(NSMenu*)menuForEvent:(NSEvent*)theEvent
|
-(NSMenu*)menuForEvent:(NSEvent*)theEvent
|
||||||
{
|
{
|
||||||
|
@ -4867,17 +4900,21 @@ GetUSLayoutCharFromKeyTranslate(UInt32 aKeyCode, UInt32 aModifiers)
|
||||||
// the input string.
|
// the input string.
|
||||||
|
|
||||||
// create event for use by plugins
|
// create event for use by plugins
|
||||||
|
#ifndef NP_NO_CARBON
|
||||||
EventRecord carbonEvent;
|
EventRecord carbonEvent;
|
||||||
|
#endif
|
||||||
if (mCurKeyEvent) {
|
if (mCurKeyEvent) {
|
||||||
// XXX The ASCII characters inputting mode of egbridge (Japanese IME)
|
// XXX The ASCII characters inputting mode of egbridge (Japanese IME)
|
||||||
// might send the keyDown event with wrong keyboard layout if other
|
// might send the keyDown event with wrong keyboard layout if other
|
||||||
// keyboard layouts are already loaded. In that case, the native event
|
// keyboard layouts are already loaded. In that case, the native event
|
||||||
// doesn't match to this gecko event...
|
// doesn't match to this gecko event...
|
||||||
if (mSendCarbonPluginEvents) {
|
#ifndef NP_NO_CARBON
|
||||||
|
if (mPluginEventModel == NPEventModelCarbon) {
|
||||||
ConvertCocoaKeyEventToCarbonEvent(mCurKeyEvent, carbonEvent);
|
ConvertCocoaKeyEventToCarbonEvent(mCurKeyEvent, carbonEvent);
|
||||||
geckoEvent.nativeMsg = &carbonEvent;
|
geckoEvent.nativeMsg = &carbonEvent;
|
||||||
}
|
} else
|
||||||
else {
|
#endif
|
||||||
|
{
|
||||||
geckoEvent.nativeMsg = NULL;
|
geckoEvent.nativeMsg = NULL;
|
||||||
}
|
}
|
||||||
geckoEvent.isShift = (nsCocoaUtils::GetCocoaEventModifierFlags(mCurKeyEvent) & NSShiftKeyMask) != 0;
|
geckoEvent.isShift = (nsCocoaUtils::GetCocoaEventModifierFlags(mCurKeyEvent) & NSShiftKeyMask) != 0;
|
||||||
|
@ -5039,7 +5076,7 @@ GetUSLayoutCharFromKeyTranslate(UInt32 aKeyCode, UInt32 aModifiers)
|
||||||
return (mMarkedRange.location != NSNotFound) && (mMarkedRange.length != 0);
|
return (mMarkedRange.location != NSNotFound) && (mMarkedRange.length != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (long) conversationIdentifier
|
- (NSInteger) conversationIdentifier
|
||||||
{
|
{
|
||||||
#if DEBUG_IME
|
#if DEBUG_IME
|
||||||
NSLog(@"****in conversationIdentifier");
|
NSLog(@"****in conversationIdentifier");
|
||||||
|
@ -5187,7 +5224,7 @@ GetUSLayoutCharFromKeyTranslate(UInt32 aKeyCode, UInt32 aModifiers)
|
||||||
NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(NSMakeRect(0.0, 0.0, 0.0, 0.0));
|
NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(NSMakeRect(0.0, 0.0, 0.0, 0.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
- (unsigned int)characterIndexForPoint:(NSPoint)thePoint
|
- (NSUInteger)characterIndexForPoint:(NSPoint)thePoint
|
||||||
{
|
{
|
||||||
#if DEBUG_IME
|
#if DEBUG_IME
|
||||||
NSLog(@"****in characterIndexForPoint");
|
NSLog(@"****in characterIndexForPoint");
|
||||||
|
@ -5280,13 +5317,15 @@ static const char* ToEscapedString(NSString* aString, nsCAutoString& aBuf)
|
||||||
[self convertCocoaKeyEvent:theEvent toGeckoEvent:&geckoEvent];
|
[self convertCocoaKeyEvent:theEvent toGeckoEvent:&geckoEvent];
|
||||||
|
|
||||||
// create event for use by plugins
|
// create event for use by plugins
|
||||||
|
#ifndef NP_NO_CARBON
|
||||||
EventRecord carbonEvent;
|
EventRecord carbonEvent;
|
||||||
NPCocoaEvent cocoaEvent;
|
if (mPluginEventModel == NPEventModelCarbon) {
|
||||||
if (mSendCarbonPluginEvents) {
|
|
||||||
ConvertCocoaKeyEventToCarbonEvent(theEvent, carbonEvent);
|
ConvertCocoaKeyEventToCarbonEvent(theEvent, carbonEvent);
|
||||||
geckoEvent.nativeMsg = &carbonEvent;
|
geckoEvent.nativeMsg = &carbonEvent;
|
||||||
}
|
}
|
||||||
else {
|
#endif
|
||||||
|
NPCocoaEvent cocoaEvent;
|
||||||
|
if (mPluginEventModel == NPEventModelCocoa) {
|
||||||
ConvertCocoaKeyEventToNPCocoaEvent(theEvent, cocoaEvent);
|
ConvertCocoaKeyEventToNPCocoaEvent(theEvent, cocoaEvent);
|
||||||
geckoEvent.nativeMsg = &cocoaEvent;
|
geckoEvent.nativeMsg = &cocoaEvent;
|
||||||
}
|
}
|
||||||
|
@ -5333,12 +5372,14 @@ static const char* ToEscapedString(NSString* aString, nsCAutoString& aBuf)
|
||||||
geckoEvent.flags |= NS_EVENT_FLAG_NO_DEFAULT;
|
geckoEvent.flags |= NS_EVENT_FLAG_NO_DEFAULT;
|
||||||
|
|
||||||
// create event for use by plugins
|
// create event for use by plugins
|
||||||
|
#ifndef NP_NO_CARBON
|
||||||
EventRecord carbonEvent;
|
EventRecord carbonEvent;
|
||||||
if (mSendCarbonPluginEvents) {
|
if (mPluginEventModel == NPEventModelCarbon) {
|
||||||
ConvertCocoaKeyEventToCarbonEvent(theEvent, carbonEvent);
|
ConvertCocoaKeyEventToCarbonEvent(theEvent, carbonEvent);
|
||||||
geckoEvent.nativeMsg = &carbonEvent;
|
geckoEvent.nativeMsg = &carbonEvent;
|
||||||
}
|
} else
|
||||||
else {
|
#endif
|
||||||
|
{
|
||||||
geckoEvent.nativeMsg = NULL;
|
geckoEvent.nativeMsg = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5375,12 +5416,14 @@ static const char* ToEscapedString(NSString* aString, nsCAutoString& aBuf)
|
||||||
geckoEvent.flags |= NS_EVENT_FLAG_NO_DEFAULT;
|
geckoEvent.flags |= NS_EVENT_FLAG_NO_DEFAULT;
|
||||||
|
|
||||||
// create event for use by plugins
|
// create event for use by plugins
|
||||||
|
#ifndef NP_NO_CARBON
|
||||||
EventRecord carbonEvent;
|
EventRecord carbonEvent;
|
||||||
if (mSendCarbonPluginEvents) {
|
if (mPluginEventModel == NPEventModelCarbon) {
|
||||||
ConvertCocoaKeyEventToCarbonEvent(theEvent, carbonEvent);
|
ConvertCocoaKeyEventToCarbonEvent(theEvent, carbonEvent);
|
||||||
geckoEvent.nativeMsg = &carbonEvent;
|
geckoEvent.nativeMsg = &carbonEvent;
|
||||||
}
|
} else
|
||||||
else {
|
#endif
|
||||||
|
{
|
||||||
geckoEvent.nativeMsg = NULL;
|
geckoEvent.nativeMsg = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5460,12 +5503,14 @@ static const char* ToEscapedString(NSString* aString, nsCAutoString& aBuf)
|
||||||
{
|
{
|
||||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||||
|
|
||||||
|
#ifndef NP_NO_CARBON
|
||||||
// If a plugin has the focus, we need to use an alternate method for
|
// If a plugin has the focus, we need to use an alternate method for
|
||||||
// handling NSKeyDown and NSKeyUp events (otherwise Carbon-based IME won't
|
// handling NSKeyDown and NSKeyUp events (otherwise Carbon-based IME won't
|
||||||
// work in plugins like the Flash plugin). The same strategy is used by the
|
// work in plugins like the Flash plugin). The same strategy is used by the
|
||||||
// WebKit. See PluginKeyEventsHandler() and [ChildView processPluginKeyEvent:]
|
// WebKit. See PluginKeyEventsHandler() and [ChildView processPluginKeyEvent:]
|
||||||
// for more info.
|
// for more info.
|
||||||
if (mGeckoChild && mIsPluginView && mSendCarbonPluginEvents) {
|
if (mGeckoChild && mIsPluginView &&
|
||||||
|
(mPluginEventModel == NPEventModelCarbon)) {
|
||||||
[self activatePluginTSMDoc];
|
[self activatePluginTSMDoc];
|
||||||
// We use the active TSM document to pass a pointer to ourselves (the
|
// We use the active TSM document to pass a pointer to ourselves (the
|
||||||
// currently focused ChildView) to PluginKeyEventsHandler(). Because this
|
// currently focused ChildView) to PluginKeyEventsHandler(). Because this
|
||||||
|
@ -5478,6 +5523,7 @@ static const char* ToEscapedString(NSString* aString, nsCAutoString& aBuf)
|
||||||
::TSMRemoveDocumentProperty(mPluginTSMDoc, kFocusedChildViewTSMDocPropertyTag);
|
::TSMRemoveDocumentProperty(mPluginTSMDoc, kFocusedChildViewTSMDocPropertyTag);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
[self processKeyDownEvent:theEvent keyEquiv:NO];
|
[self processKeyDownEvent:theEvent keyEquiv:NO];
|
||||||
|
|
||||||
|
@ -5507,44 +5553,46 @@ static BOOL keyUpAlreadySentKeyDown = NO;
|
||||||
nsAutoRetainCocoaObject kungFuDeathGrip(self);
|
nsAutoRetainCocoaObject kungFuDeathGrip(self);
|
||||||
|
|
||||||
if (mIsPluginView) {
|
if (mIsPluginView) {
|
||||||
if (!mSendCarbonPluginEvents) {
|
if (mPluginEventModel == NPEventModelCocoa) {
|
||||||
nsKeyEvent keyUpEvent(PR_TRUE, NS_KEY_UP, nsnull);
|
nsKeyEvent keyUpEvent(PR_TRUE, NS_KEY_UP, nsnull);
|
||||||
[self convertCocoaKeyEvent:theEvent toGeckoEvent:&keyUpEvent];
|
[self convertCocoaKeyEvent:theEvent toGeckoEvent:&keyUpEvent];
|
||||||
NPCocoaEvent pluginEvent;
|
NPCocoaEvent pluginEvent;
|
||||||
ConvertCocoaKeyEventToNPCocoaEvent(theEvent, pluginEvent);
|
ConvertCocoaKeyEventToNPCocoaEvent(theEvent, pluginEvent);
|
||||||
keyUpEvent.nativeMsg = &pluginEvent;
|
keyUpEvent.nativeMsg = &pluginEvent;
|
||||||
mGeckoChild->DispatchWindowEvent(keyUpEvent);
|
mGeckoChild->DispatchWindowEvent(keyUpEvent);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
#ifndef NP_NO_CARBON
|
||||||
// I'm not sure the call to TSMProcessRawKeyEvent() is needed here (though
|
if (mPluginEventModel == NPEventModelCarbon) {
|
||||||
// WebKit makes one).
|
// I'm not sure the call to TSMProcessRawKeyEvent() is needed here (though
|
||||||
::TSMProcessRawKeyEvent([theEvent _eventRef]);
|
// WebKit makes one).
|
||||||
|
::TSMProcessRawKeyEvent([theEvent _eventRef]);
|
||||||
// Don't send a keyUp event if the corresponding keyDown event(s) is/are
|
|
||||||
// still being processed (idea borrowed from WebKit).
|
// Don't send a keyUp event if the corresponding keyDown event(s) is/are
|
||||||
ChildView *keyDownTarget = nil;
|
// still being processed (idea borrowed from WebKit).
|
||||||
OSStatus status = ::TSMGetDocumentProperty(mPluginTSMDoc, kFocusedChildViewTSMDocPropertyTag,
|
ChildView *keyDownTarget = nil;
|
||||||
sizeof(ChildView *), nil, &keyDownTarget);
|
OSStatus status = ::TSMGetDocumentProperty(mPluginTSMDoc, kFocusedChildViewTSMDocPropertyTag,
|
||||||
if (status != noErr)
|
sizeof(ChildView *), nil, &keyDownTarget);
|
||||||
keyDownTarget = nil;
|
if (status != noErr)
|
||||||
if (keyDownTarget == self)
|
keyDownTarget = nil;
|
||||||
return;
|
if (keyDownTarget == self)
|
||||||
|
return;
|
||||||
// PluginKeyEventsHandler() never sends keyUp events to [ChildView
|
|
||||||
// processPluginKeyEvent:], so we need to send them to Gecko here. (This
|
// PluginKeyEventsHandler() never sends keyUp events to [ChildView
|
||||||
// means that when commiting text from IME, several keyDown events may be
|
// processPluginKeyEvent:], so we need to send them to Gecko here. (This
|
||||||
// sent to Gecko (in processPluginKeyEvent) for one keyUp event here.
|
// means that when commiting text from IME, several keyDown events may be
|
||||||
// But this is how the WebKit does it, and games expect a keyUp event to
|
// sent to Gecko (in processPluginKeyEvent) for one keyUp event here.
|
||||||
// be sent when it actually happens (they need to be able to detect how
|
// But this is how the WebKit does it, and games expect a keyUp event to
|
||||||
// long a key has been held down) -- which wouldn't be possible if we sent
|
// be sent when it actually happens (they need to be able to detect how
|
||||||
// them from processPluginKeyEvent.)
|
// long a key has been held down) -- which wouldn't be possible if we sent
|
||||||
nsKeyEvent keyUpEvent(PR_TRUE, NS_KEY_UP, nsnull);
|
// them from processPluginKeyEvent.)
|
||||||
[self convertCocoaKeyEvent:theEvent toGeckoEvent:&keyUpEvent];
|
nsKeyEvent keyUpEvent(PR_TRUE, NS_KEY_UP, nsnull);
|
||||||
EventRecord macKeyUpEvent;
|
[self convertCocoaKeyEvent:theEvent toGeckoEvent:&keyUpEvent];
|
||||||
ConvertCocoaKeyEventToCarbonEvent(theEvent, macKeyUpEvent);
|
EventRecord macKeyUpEvent;
|
||||||
keyUpEvent.nativeMsg = &macKeyUpEvent;
|
ConvertCocoaKeyEventToCarbonEvent(theEvent, macKeyUpEvent);
|
||||||
mGeckoChild->DispatchWindowEvent(keyUpEvent);
|
keyUpEvent.nativeMsg = &macKeyUpEvent;
|
||||||
|
mGeckoChild->DispatchWindowEvent(keyUpEvent);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5781,13 +5829,15 @@ static BOOL keyUpAlreadySentKeyDown = NO;
|
||||||
[self convertCocoaKeyEvent:theEvent toGeckoEvent:&geckoEvent];
|
[self convertCocoaKeyEvent:theEvent toGeckoEvent:&geckoEvent];
|
||||||
|
|
||||||
// create event for use by plugins
|
// create event for use by plugins
|
||||||
|
#ifndef NP_NO_CARBON
|
||||||
EventRecord carbonEvent;
|
EventRecord carbonEvent;
|
||||||
NPCocoaEvent cocoaEvent;
|
if (mPluginEventModel == NPEventModelCarbon) {
|
||||||
if (mSendCarbonPluginEvents) {
|
|
||||||
ConvertCocoaKeyEventToCarbonEvent(theEvent, carbonEvent, message);
|
ConvertCocoaKeyEventToCarbonEvent(theEvent, carbonEvent, message);
|
||||||
geckoEvent.nativeMsg = &carbonEvent;
|
geckoEvent.nativeMsg = &carbonEvent;
|
||||||
}
|
}
|
||||||
else {
|
#endif
|
||||||
|
NPCocoaEvent cocoaEvent;
|
||||||
|
if (mPluginEventModel == NPEventModelCocoa) {
|
||||||
ConvertCocoaKeyEventToNPCocoaEvent(theEvent, cocoaEvent, message);
|
ConvertCocoaKeyEventToNPCocoaEvent(theEvent, cocoaEvent, message);
|
||||||
geckoEvent.nativeMsg = &cocoaEvent;
|
geckoEvent.nativeMsg = &cocoaEvent;
|
||||||
}
|
}
|
||||||
|
@ -6060,7 +6110,7 @@ static BOOL keyUpAlreadySentKeyDown = NO;
|
||||||
|
|
||||||
// NSDraggingSource
|
// NSDraggingSource
|
||||||
// this is just implemented so we comply with the NSDraggingSource informal protocol
|
// this is just implemented so we comply with the NSDraggingSource informal protocol
|
||||||
- (unsigned int)draggingSourceOperationMaskForLocal:(BOOL)isLocal
|
- (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal
|
||||||
{
|
{
|
||||||
return UINT_MAX;
|
return UINT_MAX;
|
||||||
}
|
}
|
||||||
|
@ -6069,7 +6119,7 @@ static BOOL keyUpAlreadySentKeyDown = NO;
|
||||||
// or a Findow folder window; the argument passed is a path to the drop location, to be used
|
// or a Findow folder window; the argument passed is a path to the drop location, to be used
|
||||||
// in constructing a complete pathname for the file(s) we want to create as a result of
|
// in constructing a complete pathname for the file(s) we want to create as a result of
|
||||||
// the drag.
|
// the drag.
|
||||||
- (NSArray *)namesOfPromisedFilesDroppedAtDestination:(id <NSDraggingInfo>)dropDestination
|
- (NSArray *)namesOfPromisedFilesDroppedAtDestination:(NSURL*)dropDestination
|
||||||
{
|
{
|
||||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче