mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 661636 - [10.7 SDK] QuickDraw APIs undefined when doing 32-bit builds using the OS X 10.7 SDK. r=bgirard
This commit is contained in:
parent
eb202536cf
commit
efe681f006
@ -199,8 +199,43 @@ static PRLogModuleInfo *nsObjectFrameLM = PR_NewLogModule("nsObjectFrame");
|
||||
#endif /* PR_LOGGING */
|
||||
|
||||
#if defined(XP_MACOSX) && !defined(NP_NO_CARBON)
|
||||
|
||||
#define MAC_CARBON_PLUGINS
|
||||
#endif
|
||||
|
||||
// The header files QuickdrawAPI.h and QDOffscreen.h are missing on OS X 10.7
|
||||
// and up (though the QuickDraw APIs defined in them are still present) -- so
|
||||
// we need to supply the relevant parts of their contents here. It's likely
|
||||
// that Apple will eventually remove the APIs themselves (probably in OS X
|
||||
// 10.8), so we need to make them weak imports, and test for their presence
|
||||
// before using them.
|
||||
extern "C" {
|
||||
#if !defined(__QUICKDRAWAPI__)
|
||||
extern void SetRect(
|
||||
Rect * r,
|
||||
short left,
|
||||
short top,
|
||||
short right,
|
||||
short bottom)
|
||||
__attribute__((weak_import));
|
||||
#endif /* __QUICKDRAWAPI__ */
|
||||
|
||||
#if !defined(__QDOFFSCREEN__)
|
||||
extern QDErr NewGWorldFromPtr(
|
||||
GWorldPtr * offscreenGWorld,
|
||||
UInt32 PixelFormat,
|
||||
const Rect * boundsRect,
|
||||
CTabHandle cTable, /* can be NULL */
|
||||
GDHandle aGDevice, /* can be NULL */
|
||||
GWorldFlags flags,
|
||||
Ptr newBuffer,
|
||||
SInt32 rowBytes)
|
||||
__attribute__((weak_import));
|
||||
extern void DisposeGWorld(GWorldPtr offscreenGWorld)
|
||||
__attribute__((weak_import));
|
||||
#endif /* __QDOFFSCREEN__ */
|
||||
}
|
||||
|
||||
#endif /* #if defined(XP_MACOSX) && !defined(NP_NO_CARBON) */
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::plugins;
|
||||
@ -1272,6 +1307,13 @@ nsObjectFrame::PrintPlugin(nsRenderingContext& aRenderingContext,
|
||||
|
||||
// platform specific printing code
|
||||
#ifdef MAC_CARBON_PLUGINS
|
||||
// Don't use this code if any of the QuickDraw APIs it currently requires
|
||||
// are missing (as they probably will be on OS X 10.8 and up).
|
||||
if (!::SetRect || !::NewGWorldFromPtr || !::DisposeGWorld) {
|
||||
NS_WARNING("Cannot print plugin -- required QuickDraw APIs are missing!");
|
||||
return;
|
||||
}
|
||||
|
||||
nsSize contentSize = GetContentRectRelativeToSelf().Size();
|
||||
window.x = 0;
|
||||
window.y = 0;
|
||||
|
@ -66,6 +66,52 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <AppKit/NSOpenGL.h>
|
||||
|
||||
// The header files QuickdrawAPI.h and QDOffscreen.h are missing on OS X 10.7
|
||||
// and up (though the QuickDraw APIs defined in them are still present) -- so
|
||||
// we need to supply the relevant parts of their contents here. It's likely
|
||||
// that Apple will eventually remove the APIs themselves (probably in OS X
|
||||
// 10.8), so we need to make them weak imports, and test for their presence
|
||||
// before using them.
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#if !defined(__QUICKDRAWAPI__)
|
||||
|
||||
extern void SetPort(GrafPtr port)
|
||||
__attribute__((weak_import));
|
||||
extern void SetOrigin(short h, short v)
|
||||
__attribute__((weak_import));
|
||||
extern RgnHandle NewRgn(void)
|
||||
__attribute__((weak_import));
|
||||
extern void DisposeRgn(RgnHandle rgn)
|
||||
__attribute__((weak_import));
|
||||
extern void RectRgn(RgnHandle rgn, const Rect * r)
|
||||
__attribute__((weak_import));
|
||||
extern GDHandle GetMainDevice(void)
|
||||
__attribute__((weak_import));
|
||||
extern Boolean IsPortOffscreen(CGrafPtr port)
|
||||
__attribute__((weak_import));
|
||||
extern void SetPortVisibleRegion(CGrafPtr port, RgnHandle visRgn)
|
||||
__attribute__((weak_import));
|
||||
extern void SetPortClipRegion(CGrafPtr port, RgnHandle clipRgn)
|
||||
__attribute__((weak_import));
|
||||
extern CGrafPtr GetQDGlobalsThePort(void)
|
||||
__attribute__((weak_import));
|
||||
|
||||
#endif /* __QUICKDRAWAPI__ */
|
||||
|
||||
#if !defined(__QDOFFSCREEN__)
|
||||
|
||||
extern void GetGWorld(CGrafPtr * port, GDHandle * gdh)
|
||||
__attribute__((weak_import));
|
||||
extern void SetGWorld(CGrafPtr port, GDHandle gdh)
|
||||
__attribute__((weak_import));
|
||||
|
||||
#endif /* __QDOFFSCREEN__ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
class gfxASurface;
|
||||
class nsChildView;
|
||||
class nsCocoaWindow;
|
||||
|
@ -1229,44 +1229,54 @@ NS_IMETHODIMP nsChildView::StartDrawPlugin()
|
||||
// visible region to be the entire port every time. It is necessary to set up our
|
||||
// window's port even for CoreGraphics plugins, because they may still use Carbon
|
||||
// internally (see bug #420527 for details).
|
||||
CGrafPtr port = ::GetWindowPort(WindowRef([window windowRef]));
|
||||
if (isQDPlugin) {
|
||||
port = mPluginQDPort.port;
|
||||
}
|
||||
|
||||
RgnHandle pluginRegion = ::NewRgn();
|
||||
if (pluginRegion) {
|
||||
PRBool portChanged = (port != CGrafPtr(GetQDGlobalsThePort()));
|
||||
CGrafPtr oldPort;
|
||||
GDHandle oldDevice;
|
||||
|
||||
if (portChanged) {
|
||||
::GetGWorld(&oldPort, &oldDevice);
|
||||
::SetGWorld(port, ::IsPortOffscreen(port) ? nsnull : ::GetMainDevice());
|
||||
//
|
||||
// Don't use this code if any of the QuickDraw APIs it currently requires are
|
||||
// missing (as they probably will be on OS X 10.8 and up).
|
||||
if (::NewRgn && ::GetQDGlobalsThePort && ::GetGWorld && ::SetGWorld &&
|
||||
::IsPortOffscreen && ::GetMainDevice && ::SetOrigin && ::RectRgn &&
|
||||
::SetPortVisibleRegion && ::SetPortClipRegion && ::DisposeRgn) {
|
||||
CGrafPtr port = ::GetWindowPort(WindowRef([window windowRef]));
|
||||
if (isQDPlugin) {
|
||||
port = mPluginQDPort.port;
|
||||
}
|
||||
|
||||
::SetOrigin(0, 0);
|
||||
|
||||
nsIntRect clipRect; // this is in native window coordinates
|
||||
nsIntPoint origin;
|
||||
PRBool visible;
|
||||
GetPluginClipRect(clipRect, origin, visible);
|
||||
|
||||
// XXX if we're not visible, set an empty clip region?
|
||||
Rect pluginRect;
|
||||
ConvertGeckoRectToMacRect(clipRect, pluginRect);
|
||||
|
||||
::RectRgn(pluginRegion, &pluginRect);
|
||||
::SetPortVisibleRegion(port, pluginRegion);
|
||||
::SetPortClipRegion(port, pluginRegion);
|
||||
|
||||
// now set up the origin for the plugin
|
||||
::SetOrigin(origin.x, origin.y);
|
||||
|
||||
::DisposeRgn(pluginRegion);
|
||||
RgnHandle pluginRegion = ::NewRgn();
|
||||
if (pluginRegion) {
|
||||
PRBool portChanged = (port != CGrafPtr(::GetQDGlobalsThePort()));
|
||||
CGrafPtr oldPort;
|
||||
GDHandle oldDevice;
|
||||
|
||||
if (portChanged)
|
||||
::SetGWorld(oldPort, oldDevice);
|
||||
if (portChanged) {
|
||||
::GetGWorld(&oldPort, &oldDevice);
|
||||
::SetGWorld(port, ::IsPortOffscreen(port) ? nsnull : ::GetMainDevice());
|
||||
}
|
||||
|
||||
::SetOrigin(0, 0);
|
||||
|
||||
nsIntRect clipRect; // this is in native window coordinates
|
||||
nsIntPoint origin;
|
||||
PRBool visible;
|
||||
GetPluginClipRect(clipRect, origin, visible);
|
||||
|
||||
// XXX if we're not visible, set an empty clip region?
|
||||
Rect pluginRect;
|
||||
ConvertGeckoRectToMacRect(clipRect, pluginRect);
|
||||
|
||||
::RectRgn(pluginRegion, &pluginRect);
|
||||
::SetPortVisibleRegion(port, pluginRegion);
|
||||
::SetPortClipRegion(port, pluginRegion);
|
||||
|
||||
// now set up the origin for the plugin
|
||||
::SetOrigin(origin.x, origin.y);
|
||||
|
||||
::DisposeRgn(pluginRegion);
|
||||
|
||||
if (portChanged) {
|
||||
::SetGWorld(oldPort, oldDevice);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
NS_WARNING("Cannot set plugin's visible region -- required QuickDraw APIs are missing!");
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -2332,7 +2342,11 @@ NSEvent* gLastDragMouseDownEvent = nil;
|
||||
#ifndef NP_NO_QUICKDRAW
|
||||
// This sets the current port to _savePort.
|
||||
// todo: Only do if a Quickdraw plugin is present in the hierarchy!
|
||||
::SetPort(NULL);
|
||||
// Check if ::SetPort() is available -- it probably won't be on
|
||||
// OS X 10.8 and up.
|
||||
if (::SetPort) {
|
||||
::SetPort(NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||
@ -2642,7 +2656,10 @@ NSEvent* gLastDragMouseDownEvent = nil;
|
||||
// Set the current GrafPort to a "safe" port before calling [NSQuickDrawView lockFocus],
|
||||
// so that the NSQuickDrawView stashes a pointer to this known-good port internally.
|
||||
// It will set the port back to this port on destruction.
|
||||
::SetPort(NULL); // todo: only do if a Quickdraw plugin is present in the hierarchy!
|
||||
// Check if ::SetPort() is available -- it probably won't be on OS X 10.8 and up.
|
||||
if (::SetPort) {
|
||||
::SetPort(NULL); // todo: only do if a Quickdraw plugin is present in the hierarchy!
|
||||
}
|
||||
#endif
|
||||
|
||||
[super lockFocus];
|
||||
|
Loading…
Reference in New Issue
Block a user