64-bit Mac OS X fixes for nsObjectFrame.cpp. b=518184 r=roc

This commit is contained in:
Josh Aas 2009-09-22 18:17:41 -04:00
Родитель 87fa37d561
Коммит d891610f45
3 изменённых файлов: 47 добавлений и 15 удалений

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

@ -1300,7 +1300,7 @@ nsObjectFrame::PrintPlugin(nsIRenderingContext& aRenderingContext,
window.clipRect.left = 0; window.clipRect.right = 0; window.clipRect.left = 0; window.clipRect.right = 0;
// platform specific printing code // platform specific printing code
#if defined(XP_MACOSX) #if defined(XP_MACOSX) && !defined(NP_NO_CARBON)
window.x = 0; window.x = 0;
window.y = 0; window.y = 0;
window.width = presContext->AppUnitsToDevPixels(mRect.width); window.width = presContext->AppUnitsToDevPixels(mRect.width);
@ -3350,6 +3350,7 @@ nsresult nsPluginInstanceOwner::EnsureCachedAttrParamArrays()
#ifdef XP_MACOSX #ifdef XP_MACOSX
#ifndef NP_NO_CARBON
static void InitializeEventRecord(EventRecord* event, Point* aMousePosition) static void InitializeEventRecord(EventRecord* event, Point* aMousePosition)
{ {
memset(event, 0, sizeof(EventRecord)); memset(event, 0, sizeof(EventRecord));
@ -3361,6 +3362,7 @@ static void InitializeEventRecord(EventRecord* event, Point* aMousePosition)
event->when = ::TickCount(); event->when = ::TickCount();
event->modifiers = ::GetCurrentEventKeyModifiers(); event->modifiers = ::GetCurrentEventKeyModifiers();
} }
#endif
static void InitializeNPCocoaEvent(NPCocoaEvent* event) static void InitializeNPCocoaEvent(NPCocoaEvent* event)
{ {
@ -3429,8 +3431,8 @@ void* nsPluginInstanceOwner::SetPluginPortAndDetectChange()
return nsnull; return nsnull;
mPluginWindow->window = pluginPort; mPluginWindow->window = pluginPort;
NPDrawingModel drawingModel = GetDrawingModel();
#ifndef NP_NO_QUICKDRAW #ifndef NP_NO_QUICKDRAW
NPDrawingModel drawingModel = GetDrawingModel();
if (drawingModel == NPDrawingModelQuickDraw) { if (drawingModel == NPDrawingModelQuickDraw) {
NP_Port* windowQDPort = static_cast<NP_Port*>(mPluginWindow->window); NP_Port* windowQDPort = static_cast<NP_Port*>(mPluginWindow->window);
if (windowQDPort->port != mQDPluginPortCopy.port) { if (windowQDPort->port != mQDPluginPortCopy.port) {
@ -3493,7 +3495,7 @@ nsPluginInstanceOwner::GetEventloopNestingLevel()
nsresult nsPluginInstanceOwner::ScrollPositionWillChange(nsIScrollableView* aScrollable, nscoord aX, nscoord aY) nsresult nsPluginInstanceOwner::ScrollPositionWillChange(nsIScrollableView* aScrollable, nscoord aX, nscoord aY)
{ {
#ifdef XP_MACOSX #if defined(XP_MACOSX) && !defined(NP_NO_CARBON)
if (GetEventModel() != NPEventModelCarbon) if (GetEventModel() != NPEventModelCarbon)
return NS_OK; return NS_OK;
@ -3520,7 +3522,7 @@ nsresult nsPluginInstanceOwner::ScrollPositionWillChange(nsIScrollableView* aScr
nsresult nsPluginInstanceOwner::ScrollPositionDidChange(nsIScrollableView* aScrollable, nscoord aX, nscoord aY) nsresult nsPluginInstanceOwner::ScrollPositionDidChange(nsIScrollableView* aScrollable, nscoord aX, nscoord aY)
{ {
#ifdef XP_MACOSX #if defined(XP_MACOSX) && !defined(NP_NO_CARBON)
if (GetEventModel() != NPEventModelCarbon) if (GetEventModel() != NPEventModelCarbon)
return NS_OK; return NS_OK;
@ -3601,7 +3603,7 @@ nsresult nsPluginInstanceOwner::KeyUp(nsIDOMEvent* aKeyEvent)
nsresult nsPluginInstanceOwner::KeyPress(nsIDOMEvent* aKeyEvent) nsresult nsPluginInstanceOwner::KeyPress(nsIDOMEvent* aKeyEvent)
{ {
#ifdef XP_MACOSX #if defined(XP_MACOSX) && !defined(NP_NO_CARBON)
// send KeyPress events only for Mac OS X Carbon event model // send KeyPress events only for Mac OS X Carbon event model
if (GetEventModel() != NPEventModelCarbon) if (GetEventModel() != NPEventModelCarbon)
return aKeyEvent->PreventDefault(); return aKeyEvent->PreventDefault();
@ -4152,7 +4154,9 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const nsGUIEvent& anEvent)
NPEventModel eventModel = GetEventModel(); NPEventModel eventModel = GetEventModel();
// If we have to synthesize an event we'll use one of these. // If we have to synthesize an event we'll use one of these.
#ifndef NP_NO_CARBON
EventRecord synthCarbonEvent; EventRecord synthCarbonEvent;
#endif
NPCocoaEvent synthCocoaEvent; NPCocoaEvent synthCocoaEvent;
void* event = anEvent.nativeMsg; void* event = anEvent.nativeMsg;
@ -4163,12 +4167,15 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const nsGUIEvent& anEvent)
nsIntPoint ptPx(presContext->AppUnitsToDevPixels(pt.x), nsIntPoint ptPx(presContext->AppUnitsToDevPixels(pt.x),
presContext->AppUnitsToDevPixels(pt.y)); presContext->AppUnitsToDevPixels(pt.y));
#ifndef NP_NO_CARBON
if (eventModel == NPEventModelCarbon) { if (eventModel == NPEventModelCarbon) {
Point carbonPt = { ptPx.y + mPluginWindow->y, ptPx.x + mPluginWindow->x }; Point carbonPt = { ptPx.y + mPluginWindow->y, ptPx.x + mPluginWindow->x };
event = &synthCarbonEvent; event = &synthCarbonEvent;
InitializeEventRecord(&synthCarbonEvent, &carbonPt); InitializeEventRecord(&synthCarbonEvent, &carbonPt);
} else { } else
#endif
{
event = &synthCocoaEvent; event = &synthCocoaEvent;
InitializeNPCocoaEvent(&synthCocoaEvent); InitializeNPCocoaEvent(&synthCocoaEvent);
} }
@ -4176,43 +4183,57 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const nsGUIEvent& anEvent)
switch (anEvent.message) { switch (anEvent.message) {
case NS_FOCUS_CONTENT: case NS_FOCUS_CONTENT:
case NS_BLUR_CONTENT: case NS_BLUR_CONTENT:
#ifndef NP_NO_CARBON
if (eventModel == NPEventModelCarbon) { if (eventModel == NPEventModelCarbon) {
synthCarbonEvent.what = (anEvent.message == NS_FOCUS_CONTENT) ? synthCarbonEvent.what = (anEvent.message == NS_FOCUS_CONTENT) ?
NPEventType_GetFocusEvent : NPEventType_LoseFocusEvent; NPEventType_GetFocusEvent : NPEventType_LoseFocusEvent;
} else { } else
#endif
{
synthCocoaEvent.type = NPCocoaEventFocusChanged; synthCocoaEvent.type = NPCocoaEventFocusChanged;
synthCocoaEvent.data.focus.hasFocus = (anEvent.message == NS_FOCUS_CONTENT); synthCocoaEvent.data.focus.hasFocus = (anEvent.message == NS_FOCUS_CONTENT);
} }
break; break;
case NS_MOUSE_MOVE: case NS_MOUSE_MOVE:
#ifndef NP_NO_CARBON
if (eventModel == NPEventModelCarbon) { if (eventModel == NPEventModelCarbon) {
synthCarbonEvent.what = osEvt; synthCarbonEvent.what = osEvt;
} else { } else
#endif
{
synthCocoaEvent.type = NPCocoaEventMouseMoved; synthCocoaEvent.type = NPCocoaEventMouseMoved;
synthCocoaEvent.data.mouse.pluginX = static_cast<double>(ptPx.x); synthCocoaEvent.data.mouse.pluginX = static_cast<double>(ptPx.x);
synthCocoaEvent.data.mouse.pluginY = static_cast<double>(ptPx.y); synthCocoaEvent.data.mouse.pluginY = static_cast<double>(ptPx.y);
} }
break; break;
case NS_MOUSE_BUTTON_DOWN: case NS_MOUSE_BUTTON_DOWN:
#ifndef NP_NO_CARBON
if (eventModel == NPEventModelCarbon) { if (eventModel == NPEventModelCarbon) {
synthCarbonEvent.what = mouseDown; synthCarbonEvent.what = mouseDown;
} else { } else
#endif
{
synthCocoaEvent.type = NPCocoaEventMouseDown; synthCocoaEvent.type = NPCocoaEventMouseDown;
synthCocoaEvent.data.mouse.pluginX = static_cast<double>(ptPx.x); synthCocoaEvent.data.mouse.pluginX = static_cast<double>(ptPx.x);
synthCocoaEvent.data.mouse.pluginY = static_cast<double>(ptPx.y); synthCocoaEvent.data.mouse.pluginY = static_cast<double>(ptPx.y);
} }
break; break;
case NS_MOUSE_BUTTON_UP: case NS_MOUSE_BUTTON_UP:
#ifndef NP_NO_CARBON
if (eventModel == NPEventModelCarbon) { if (eventModel == NPEventModelCarbon) {
synthCarbonEvent.what = mouseUp; synthCarbonEvent.what = mouseUp;
} else { } else
#endif
{
synthCocoaEvent.type = NPCocoaEventMouseUp; synthCocoaEvent.type = NPCocoaEventMouseUp;
synthCocoaEvent.data.mouse.pluginX = static_cast<double>(ptPx.x); synthCocoaEvent.data.mouse.pluginX = static_cast<double>(ptPx.x);
synthCocoaEvent.data.mouse.pluginY = static_cast<double>(ptPx.y); synthCocoaEvent.data.mouse.pluginY = static_cast<double>(ptPx.y);
} }
break; break;
} }
} else if ((eventModel == NPEventModelCarbon) && (static_cast<EventRecord*>(event)->what == nullEvent)) { }
#ifndef NP_NO_CARBON
else if ((eventModel == NPEventModelCarbon) && (static_cast<EventRecord*>(event)->what == nullEvent)) {
Point carbonPt = { 20000, 20000 }; Point carbonPt = { 20000, 20000 };
InitializeEventRecord(&synthCarbonEvent, &carbonPt); InitializeEventRecord(&synthCarbonEvent, &carbonPt);
event = &synthCarbonEvent; event = &synthCarbonEvent;
@ -4223,6 +4244,7 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const nsGUIEvent& anEvent)
// and try to activate it after it has been deleted. See bug 183313. // and try to activate it after it has been deleted. See bug 183313.
if (eventModel == NPEventModelCarbon && anEvent.message == NS_FOCUS_CONTENT) if (eventModel == NPEventModelCarbon && anEvent.message == NS_FOCUS_CONTENT)
::DeactivateTSMDocument(::TSMGetActiveDocument()); ::DeactivateTSMDocument(::TSMGetActiveDocument());
#endif
PRBool eventHandled = PR_FALSE; PRBool eventHandled = PR_FALSE;
void* window = FixUpPluginWindow(ePluginPaintEnable); void* window = FixUpPluginWindow(ePluginPaintEnable);
@ -4636,6 +4658,7 @@ void nsPluginInstanceOwner::Paint(const gfxRect& aDirtyRect)
nsCOMPtr<nsIPluginWidget> pluginWidget = do_QueryInterface(mWidget); nsCOMPtr<nsIPluginWidget> pluginWidget = do_QueryInterface(mWidget);
if (pluginWidget && NS_SUCCEEDED(pluginWidget->StartDrawPlugin())) { if (pluginWidget && NS_SUCCEEDED(pluginWidget->StartDrawPlugin())) {
void* window = FixUpPluginWindow(ePluginPaintEnable); void* window = FixUpPluginWindow(ePluginPaintEnable);
#ifndef NP_NO_CARBON
if (GetEventModel() == NPEventModelCarbon && window) { if (GetEventModel() == NPEventModelCarbon && window) {
EventRecord updateEvent; EventRecord updateEvent;
InitializeEventRecord(&updateEvent, nsnull); InitializeEventRecord(&updateEvent, nsnull);
@ -4644,8 +4667,9 @@ void nsPluginInstanceOwner::Paint(const gfxRect& aDirtyRect)
PRBool eventHandled = PR_FALSE; PRBool eventHandled = PR_FALSE;
mInstance->HandleEvent(&updateEvent, &eventHandled); mInstance->HandleEvent(&updateEvent, &eventHandled);
} } else
else { #endif
{
// The context given here is only valid during the HandleEvent call. // The context given here is only valid during the HandleEvent call.
NPCocoaEvent updateEvent; NPCocoaEvent updateEvent;
InitializeNPCocoaEvent(&updateEvent); InitializeNPCocoaEvent(&updateEvent);
@ -4961,7 +4985,7 @@ nsPluginInstanceOwner::Renderer::NativeDraw(QWidget * drawable,
NS_IMETHODIMP nsPluginInstanceOwner::Notify(nsITimer* timer) NS_IMETHODIMP nsPluginInstanceOwner::Notify(nsITimer* timer)
{ {
#ifdef XP_MACOSX #if defined(XP_MACOSX) && !defined(NP_NO_CARBON)
if (GetEventModel() != NPEventModelCarbon) if (GetEventModel() != NPEventModelCarbon)
return NS_OK; return NS_OK;
@ -4995,7 +5019,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::Notify(nsITimer* timer)
void nsPluginInstanceOwner::StartTimer(unsigned int aDelay) void nsPluginInstanceOwner::StartTimer(unsigned int aDelay)
{ {
#ifdef XP_MACOSX #if defined(XP_MACOSX) && !defined(NP_NO_CARBON)
if (GetEventModel() != NPEventModelCarbon) if (GetEventModel() != NPEventModelCarbon)
return; return;
@ -5269,9 +5293,11 @@ void* nsPluginInstanceOwner::FixUpPluginWindow(PRInt32 inPaintState)
nsIntPoint geckoScreenCoords = mWidget->WidgetToScreenOffset(); nsIntPoint geckoScreenCoords = mWidget->WidgetToScreenOffset();
nsRect windowRect; nsRect windowRect;
#ifndef NP_NO_CARBON
if (eventModel == NPEventModelCarbon) if (eventModel == NPEventModelCarbon)
NS_NPAPI_CarbonWindowFrame(static_cast<WindowRef>(static_cast<NP_CGContext*>(pluginPort)->window), windowRect); NS_NPAPI_CarbonWindowFrame(static_cast<WindowRef>(static_cast<NP_CGContext*>(pluginPort)->window), windowRect);
else else
#endif
NS_NPAPI_CocoaWindowFrame(static_cast<NP_CGContext*>(pluginPort)->window, windowRect); NS_NPAPI_CocoaWindowFrame(static_cast<NP_CGContext*>(pluginPort)->window, windowRect);
mPluginWindow->x = geckoScreenCoords.x - windowRect.x; mPluginWindow->x = geckoScreenCoords.x - windowRect.x;

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

@ -39,7 +39,9 @@
// We can use Carbon in this header but not Cocoa. Cocoa pointers must be void. // We can use Carbon in this header but not Cocoa. Cocoa pointers must be void.
#ifndef __LP64__
#import <Carbon/Carbon.h> #import <Carbon/Carbon.h>
#endif
#include "nsRect.h" #include "nsRect.h"
#include "nsIWidget.h" #include "nsIWidget.h"
@ -47,8 +49,10 @@
// We use void pointers to avoid exporting native event types to cross-platform code. // We use void pointers to avoid exporting native event types to cross-platform code.
#ifndef __LP64__
// Get the rect for an entire top-level Carbon window in screen coords. // Get the rect for an entire top-level Carbon window in screen coords.
void NS_NPAPI_CarbonWindowFrame(WindowRef aWindow, nsRect& outRect); void NS_NPAPI_CarbonWindowFrame(WindowRef aWindow, nsRect& outRect);
#endif
// Get the rect for an entire top-level Cocoa window in screen coords. // Get the rect for an entire top-level Cocoa window in screen coords.
void NS_NPAPI_CocoaWindowFrame(void* aWindow, nsRect& outRect); void NS_NPAPI_CocoaWindowFrame(void* aWindow, nsRect& outRect);

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

@ -42,6 +42,7 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#include "nsObjCExceptions.h" #include "nsObjCExceptions.h"
#ifndef __LP64__
void NS_NPAPI_CarbonWindowFrame(WindowRef aWindow, nsRect& outRect) void NS_NPAPI_CarbonWindowFrame(WindowRef aWindow, nsRect& outRect)
{ {
if (!aWindow) if (!aWindow)
@ -54,6 +55,7 @@ void NS_NPAPI_CarbonWindowFrame(WindowRef aWindow, nsRect& outRect)
outRect.width = windowRect.right - windowRect.left; outRect.width = windowRect.right - windowRect.left;
outRect.height = windowRect.bottom - windowRect.top; outRect.height = windowRect.bottom - windowRect.top;
} }
#endif
void NS_NPAPI_CocoaWindowFrame(void* aWindow, nsRect& outRect) void NS_NPAPI_CocoaWindowFrame(void* aWindow, nsRect& outRect)
{ {