Skip to content

Commit

Permalink
fixing cocoa-cairo plugins. bug 35732. 6r=vlad.
Browse files Browse the repository at this point in the history
  • Loading branch information
pavlov%pavlov.net committed Nov 22, 2006
1 parent e4001e2 commit c568550
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions widget/src/cocoa/nsChildView.mm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* -*- Mode: Objective-C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* -*- Mode: objc; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
Expand Down Expand Up @@ -641,6 +641,7 @@ static void PrintViewHierarcy(NSView *view)
#endif

case NS_NATIVE_PLUGIN_PORT:
{
// this needs to be a combination of the port and the offsets.
if (!mPluginPort) {
mPluginPort = new nsPluginPort;
Expand All @@ -662,17 +663,12 @@ static void PrintViewHierarcy(NSView *view)
// then, encode as "SetOrigin" ready values.
mPluginPort->portx = (PRInt32)-viewOrigin.x;
mPluginPort->porty = (PRInt32)-viewOrigin.y;

}
}
else {
#ifdef DEBUG
printf("@@@@ Couldn't get NSWindow for plugin port. @@@@\n");
#endif
}

retVal = (void*)mPluginPort;
break;
}
}

return retVal;
Expand Down Expand Up @@ -1051,9 +1047,6 @@ static void PrintViewHierarcy(NSView *view)
//-------------------------------------------------------------------------
NS_IMETHODIMP nsChildView::StartDrawPlugin()
{
#ifdef MOZ_CAIRO_GFX
return NS_ERROR_FAILURE;
#else
NS_ASSERTION(mPluginPort, "StartDrawPlugin must only be called on a plugin widget");
if (!mPluginPort)
return NS_ERROR_FAILURE;
Expand All @@ -1075,7 +1068,15 @@ static void PrintViewHierarcy(NSView *view)
// visible region to be the entire port every time.
RgnHandle pluginRegion = ::NewRgn();
if (pluginRegion) {
StPortSetter setter(mPluginPort->port);
PRBool portChanged = (mPluginPort->port != CGrafPtr(GetQDGlobalsThePort()));
CGrafPtr oldPort;
GDHandle oldDevice;

if (portChanged) {
::GetGWorld(&oldPort, &oldDevice);
::SetGWorld(mPluginPort->port, ::IsPortOffscreen(mPluginPort->port) ? nsnull : ::GetMainDevice());
}

::SetOrigin(0, 0);

nsRect clipRect; // this is in native window coordinates
Expand All @@ -1095,11 +1096,13 @@ static void PrintViewHierarcy(NSView *view)
::SetOrigin(origin.x, origin.y);

::DisposeRgn(pluginRegion);

if (portChanged)
::SetGWorld(oldPort, oldDevice);
}

mPluginDrawing = PR_TRUE;
return NS_OK;
#endif
}

//-------------------------------------------------------------------------
Expand Down Expand Up @@ -1969,12 +1972,8 @@ inline PRUint16 COLOR8TOCOLOR16(PRUint8 color8)
GrafPtr
nsChildView::GetChildViewQuickDrawPort()
{
#ifndef MOZ_CAIRO_GFX
if ([mView isKindOfClass:[ChildView class]])
return (GrafPtr)[(ChildView*)mView qdPort];
#endif

return nsnull;
}

#pragma mark -
Expand Down

0 comments on commit c568550

Please sign in to comment.