From d7f1fc09f7e267c0cab68fd0edf5b32c8ba1ca53 Mon Sep 17 00:00:00 2001 From: Josh Aas Date: Tue, 22 Sep 2009 18:17:41 -0400 Subject: [PATCH] 64-bit Mac OS X fixes for nsObjectFrame.cpp. b=518184 r=roc --- layout/generic/nsObjectFrame.cpp | 56 ++++++++++++++++++++++-------- layout/generic/nsPluginUtilsOSX.h | 4 +++ layout/generic/nsPluginUtilsOSX.mm | 2 ++ 3 files changed, 47 insertions(+), 15 deletions(-) diff --git a/layout/generic/nsObjectFrame.cpp b/layout/generic/nsObjectFrame.cpp index 75eacefd9f1c..3ee8d4463bcb 100644 --- a/layout/generic/nsObjectFrame.cpp +++ b/layout/generic/nsObjectFrame.cpp @@ -1300,7 +1300,7 @@ nsObjectFrame::PrintPlugin(nsIRenderingContext& aRenderingContext, window.clipRect.left = 0; window.clipRect.right = 0; // platform specific printing code -#if defined(XP_MACOSX) +#if defined(XP_MACOSX) && !defined(NP_NO_CARBON) window.x = 0; window.y = 0; window.width = presContext->AppUnitsToDevPixels(mRect.width); @@ -3350,6 +3350,7 @@ nsresult nsPluginInstanceOwner::EnsureCachedAttrParamArrays() #ifdef XP_MACOSX +#ifndef NP_NO_CARBON static void InitializeEventRecord(EventRecord* event, Point* aMousePosition) { memset(event, 0, sizeof(EventRecord)); @@ -3361,6 +3362,7 @@ static void InitializeEventRecord(EventRecord* event, Point* aMousePosition) event->when = ::TickCount(); event->modifiers = ::GetCurrentEventKeyModifiers(); } +#endif static void InitializeNPCocoaEvent(NPCocoaEvent* event) { @@ -3429,8 +3431,8 @@ void* nsPluginInstanceOwner::SetPluginPortAndDetectChange() return nsnull; mPluginWindow->window = pluginPort; - NPDrawingModel drawingModel = GetDrawingModel(); #ifndef NP_NO_QUICKDRAW + NPDrawingModel drawingModel = GetDrawingModel(); if (drawingModel == NPDrawingModelQuickDraw) { NP_Port* windowQDPort = static_cast(mPluginWindow->window); if (windowQDPort->port != mQDPluginPortCopy.port) { @@ -3493,7 +3495,7 @@ nsPluginInstanceOwner::GetEventloopNestingLevel() nsresult nsPluginInstanceOwner::ScrollPositionWillChange(nsIScrollableView* aScrollable, nscoord aX, nscoord aY) { -#ifdef XP_MACOSX +#if defined(XP_MACOSX) && !defined(NP_NO_CARBON) if (GetEventModel() != NPEventModelCarbon) return NS_OK; @@ -3520,7 +3522,7 @@ nsresult nsPluginInstanceOwner::ScrollPositionWillChange(nsIScrollableView* aScr nsresult nsPluginInstanceOwner::ScrollPositionDidChange(nsIScrollableView* aScrollable, nscoord aX, nscoord aY) { -#ifdef XP_MACOSX +#if defined(XP_MACOSX) && !defined(NP_NO_CARBON) if (GetEventModel() != NPEventModelCarbon) return NS_OK; @@ -3601,7 +3603,7 @@ nsresult nsPluginInstanceOwner::KeyUp(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 if (GetEventModel() != NPEventModelCarbon) return aKeyEvent->PreventDefault(); @@ -4152,7 +4154,9 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const nsGUIEvent& anEvent) NPEventModel eventModel = GetEventModel(); // If we have to synthesize an event we'll use one of these. +#ifndef NP_NO_CARBON EventRecord synthCarbonEvent; +#endif NPCocoaEvent synthCocoaEvent; void* event = anEvent.nativeMsg; @@ -4163,12 +4167,15 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const nsGUIEvent& anEvent) nsIntPoint ptPx(presContext->AppUnitsToDevPixels(pt.x), presContext->AppUnitsToDevPixels(pt.y)); +#ifndef NP_NO_CARBON if (eventModel == NPEventModelCarbon) { Point carbonPt = { ptPx.y + mPluginWindow->y, ptPx.x + mPluginWindow->x }; event = &synthCarbonEvent; InitializeEventRecord(&synthCarbonEvent, &carbonPt); - } else { + } else +#endif + { event = &synthCocoaEvent; InitializeNPCocoaEvent(&synthCocoaEvent); } @@ -4176,43 +4183,57 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const nsGUIEvent& anEvent) switch (anEvent.message) { case NS_FOCUS_CONTENT: case NS_BLUR_CONTENT: +#ifndef NP_NO_CARBON if (eventModel == NPEventModelCarbon) { synthCarbonEvent.what = (anEvent.message == NS_FOCUS_CONTENT) ? NPEventType_GetFocusEvent : NPEventType_LoseFocusEvent; - } else { + } else +#endif + { synthCocoaEvent.type = NPCocoaEventFocusChanged; synthCocoaEvent.data.focus.hasFocus = (anEvent.message == NS_FOCUS_CONTENT); } break; case NS_MOUSE_MOVE: +#ifndef NP_NO_CARBON if (eventModel == NPEventModelCarbon) { synthCarbonEvent.what = osEvt; - } else { + } else +#endif + { synthCocoaEvent.type = NPCocoaEventMouseMoved; synthCocoaEvent.data.mouse.pluginX = static_cast(ptPx.x); synthCocoaEvent.data.mouse.pluginY = static_cast(ptPx.y); } break; case NS_MOUSE_BUTTON_DOWN: +#ifndef NP_NO_CARBON if (eventModel == NPEventModelCarbon) { synthCarbonEvent.what = mouseDown; - } else { + } else +#endif + { synthCocoaEvent.type = NPCocoaEventMouseDown; synthCocoaEvent.data.mouse.pluginX = static_cast(ptPx.x); synthCocoaEvent.data.mouse.pluginY = static_cast(ptPx.y); } break; case NS_MOUSE_BUTTON_UP: +#ifndef NP_NO_CARBON if (eventModel == NPEventModelCarbon) { synthCarbonEvent.what = mouseUp; - } else { + } else +#endif + { synthCocoaEvent.type = NPCocoaEventMouseUp; synthCocoaEvent.data.mouse.pluginX = static_cast(ptPx.x); synthCocoaEvent.data.mouse.pluginY = static_cast(ptPx.y); } break; } - } else if ((eventModel == NPEventModelCarbon) && (static_cast(event)->what == nullEvent)) { + } +#ifndef NP_NO_CARBON + else if ((eventModel == NPEventModelCarbon) && (static_cast(event)->what == nullEvent)) { Point carbonPt = { 20000, 20000 }; InitializeEventRecord(&synthCarbonEvent, &carbonPt); 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. if (eventModel == NPEventModelCarbon && anEvent.message == NS_FOCUS_CONTENT) ::DeactivateTSMDocument(::TSMGetActiveDocument()); +#endif PRBool eventHandled = PR_FALSE; void* window = FixUpPluginWindow(ePluginPaintEnable); @@ -4636,6 +4658,7 @@ void nsPluginInstanceOwner::Paint(const gfxRect& aDirtyRect) nsCOMPtr pluginWidget = do_QueryInterface(mWidget); if (pluginWidget && NS_SUCCEEDED(pluginWidget->StartDrawPlugin())) { void* window = FixUpPluginWindow(ePluginPaintEnable); +#ifndef NP_NO_CARBON if (GetEventModel() == NPEventModelCarbon && window) { EventRecord updateEvent; InitializeEventRecord(&updateEvent, nsnull); @@ -4644,8 +4667,9 @@ void nsPluginInstanceOwner::Paint(const gfxRect& aDirtyRect) PRBool eventHandled = PR_FALSE; mInstance->HandleEvent(&updateEvent, &eventHandled); - } - else { + } else +#endif + { // The context given here is only valid during the HandleEvent call. NPCocoaEvent updateEvent; InitializeNPCocoaEvent(&updateEvent); @@ -4961,7 +4985,7 @@ nsPluginInstanceOwner::Renderer::NativeDraw(QWidget * drawable, NS_IMETHODIMP nsPluginInstanceOwner::Notify(nsITimer* timer) { -#ifdef XP_MACOSX +#if defined(XP_MACOSX) && !defined(NP_NO_CARBON) if (GetEventModel() != NPEventModelCarbon) return NS_OK; @@ -4995,7 +5019,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::Notify(nsITimer* timer) void nsPluginInstanceOwner::StartTimer(unsigned int aDelay) { -#ifdef XP_MACOSX +#if defined(XP_MACOSX) && !defined(NP_NO_CARBON) if (GetEventModel() != NPEventModelCarbon) return; @@ -5269,9 +5293,11 @@ void* nsPluginInstanceOwner::FixUpPluginWindow(PRInt32 inPaintState) nsIntPoint geckoScreenCoords = mWidget->WidgetToScreenOffset(); nsRect windowRect; +#ifndef NP_NO_CARBON if (eventModel == NPEventModelCarbon) NS_NPAPI_CarbonWindowFrame(static_cast(static_cast(pluginPort)->window), windowRect); else +#endif NS_NPAPI_CocoaWindowFrame(static_cast(pluginPort)->window, windowRect); mPluginWindow->x = geckoScreenCoords.x - windowRect.x; diff --git a/layout/generic/nsPluginUtilsOSX.h b/layout/generic/nsPluginUtilsOSX.h index aa92895f8954..525609d4d42d 100644 --- a/layout/generic/nsPluginUtilsOSX.h +++ b/layout/generic/nsPluginUtilsOSX.h @@ -39,7 +39,9 @@ // We can use Carbon in this header but not Cocoa. Cocoa pointers must be void. +#ifndef __LP64__ #import +#endif #include "nsRect.h" #include "nsIWidget.h" @@ -47,8 +49,10 @@ // 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. void NS_NPAPI_CarbonWindowFrame(WindowRef aWindow, nsRect& outRect); +#endif // Get the rect for an entire top-level Cocoa window in screen coords. void NS_NPAPI_CocoaWindowFrame(void* aWindow, nsRect& outRect); diff --git a/layout/generic/nsPluginUtilsOSX.mm b/layout/generic/nsPluginUtilsOSX.mm index 94d26db9d48c..c5b3e0d542c2 100644 --- a/layout/generic/nsPluginUtilsOSX.mm +++ b/layout/generic/nsPluginUtilsOSX.mm @@ -42,6 +42,7 @@ #import #include "nsObjCExceptions.h" +#ifndef __LP64__ void NS_NPAPI_CarbonWindowFrame(WindowRef aWindow, nsRect& outRect) { if (!aWindow) @@ -54,6 +55,7 @@ void NS_NPAPI_CarbonWindowFrame(WindowRef aWindow, nsRect& outRect) outRect.width = windowRect.right - windowRect.left; outRect.height = windowRect.bottom - windowRect.top; } +#endif void NS_NPAPI_CocoaWindowFrame(void* aWindow, nsRect& outRect) {