Bug 596414. Tell ChildView about the plugin drawing model. r=josh

This commit is contained in:
Robert O'Callahan
2010-09-17 10:55:39 -07:00
parent e1e6aaab08
commit 7e34248eab
4 changed files with 48 additions and 14 deletions

View File

@@ -820,6 +820,7 @@ nsObjectFrame::CreateWidget(nscoord aWidth,
if (!pluginWidget)
return NS_ERROR_FAILURE;
pluginWidget->SetPluginEventModel(mInstanceOwner->GetEventModel());
pluginWidget->SetPluginDrawingModel(mInstanceOwner->GetDrawingModel());
if (mInstanceOwner->GetDrawingModel() == NPDrawingModelCoreAnimation) {
mInstanceOwner->SetupCARefresh();

View File

@@ -44,6 +44,9 @@
struct nsIntPoint;
class nsIPluginInstanceOwner;
/**
* This is used by Mac only.
*/
class NS_NO_VTABLE nsIPluginWidget : public nsISupports
{
public:
@@ -62,6 +65,8 @@ class NS_NO_VTABLE nsIPluginWidget : public nsISupports
NS_IMETHOD GetPluginEventModel(int* outEventModel) = 0;
NS_IMETHOD SetPluginDrawingModel(int inDrawingModel) = 0;
NS_IMETHOD StartComplexTextInputForCurrentEvent() = 0;
};

View File

@@ -123,6 +123,7 @@ extern "C" long TSMProcessRawKeyEvent(EventRef carbonEvent);
BOOL mIsPluginView;
NPEventModel mPluginEventModel;
NPDrawingModel mPluginDrawingModel;
// The following variables are only valid during key down event processing.
// Their current usage needs to be fixed to avoid problems with nested event
@@ -355,6 +356,7 @@ public:
NS_IMETHOD SetPluginEventModel(int inEventModel);
NS_IMETHOD GetPluginEventModel(int* outEventModel);
NS_IMETHOD SetPluginDrawingModel(int inDrawingModel);
NS_IMETHOD StartComplexTextInputForCurrentEvent();
@@ -441,7 +443,6 @@ protected:
PRPackedBool mVisible;
PRPackedBool mDrawing;
PRPackedBool mPluginDrawing;
PRPackedBool mPluginIsCG; // true if this is a CoreGraphics plugin
PRPackedBool mIsDispatchPaint; // Is a paint event being dispatched
NP_CGContext mPluginCGContext;

View File

@@ -176,7 +176,9 @@ PRUint32 nsChildView::sLastInputEventCount = 0;
- (void)setIsPluginView:(BOOL)aIsPlugin;
- (BOOL)isPluginView;
- (void)setPluginEventModel:(NPEventModel)eventModel;
- (void)setPluginDrawingModel:(NPDrawingModel)drawingModel;
- (NPEventModel)pluginEventModel;
- (NPDrawingModel)pluginDrawingModel;
- (BOOL)isRectObscuredBySubview:(NSRect)inRect;
@@ -470,7 +472,6 @@ nsChildView::nsChildView() : nsBaseWidget()
, mVisible(PR_FALSE)
, mDrawing(PR_FALSE)
, mPluginDrawing(PR_FALSE)
, mPluginIsCG(PR_FALSE)
, mIsDispatchPaint(PR_FALSE)
, mPluginInstanceOwner(nsnull)
{
@@ -732,22 +733,18 @@ void* nsChildView::GetNativeData(PRUint32 aDataType)
case NS_NATIVE_PLUGIN_PORT_QD:
case NS_NATIVE_PLUGIN_PORT_CG:
{
#ifdef NP_NO_QUICKDRAW
aDataType = NS_NATIVE_PLUGIN_PORT_CG;
#endif
mPluginIsCG = (aDataType == NS_NATIVE_PLUGIN_PORT_CG);
// The NP_CGContext pointer should always be NULL in the Cocoa event model.
if ([(ChildView*)mView pluginEventModel] == NPEventModelCocoa)
return nsnull;
UpdatePluginPort();
if (mPluginIsCG)
retVal = (void*)&mPluginCGContext;
#ifndef NP_NO_QUICKDRAW
else
if (aDataType != NS_NATIVE_PLUGIN_PORT_CG) {
retVal = (void*)&mPluginQDPort;
break;
}
#endif
retVal = (void*)&mPluginCGContext;
break;
}
}
@@ -810,7 +807,9 @@ void nsChildView::HidePlugin()
NS_ASSERTION(mWindowType == eWindowType_plugin,
"HidePlugin called on non-plugin view");
if (mPluginInstanceOwner && !mPluginIsCG) {
#ifndef NP_NO_QUICKDRAW
if (mPluginInstanceOwner && mView &&
[(ChildView*)mView pluginDrawingModel] == NPDrawingModelQuickDraw) {
NPWindow* window;
mPluginInstanceOwner->GetWindow(window);
nsCOMPtr<nsIPluginInstance> instance;
@@ -823,6 +822,7 @@ void nsChildView::HidePlugin()
instance->SetWindow(window);
}
}
#endif
}
void nsChildView::UpdatePluginPort()
@@ -835,7 +835,11 @@ void nsChildView::UpdatePluginPort()
WindowRef carbonWindow = cocoaWindow ? (WindowRef)[cocoaWindow windowRef] : NULL;
#endif
if (mPluginIsCG) {
if (!mView
#ifndef NP_NO_QUICKDRAW
|| [(ChildView*)mView pluginDrawingModel] != NPDrawingModelQuickDraw
#endif
) {
// [NSGraphicsContext currentContext] is supposed to "return the
// current graphics context of the current thread." But sometimes
// (when called while mView isn't focused for drawing) it returns a
@@ -1252,7 +1256,8 @@ NS_IMETHODIMP nsChildView::StartDrawPlugin()
// without regressing bug 409615. See bug 435041. (StartDrawPlugin() and
// EndDrawPlugin() wrap every call to nsIPluginInstance::HandleEvent() --
// not just calls that "draw" or paint.)
if (!mPluginIsCG || mIsDispatchPaint) {
PRBool isQDPlugin = [(ChildView*)mView pluginDrawingModel] == NPDrawingModelQuickDraw;
if (isQDPlugin || mIsDispatchPaint) {
if (mPluginDrawing)
return NS_ERROR_FAILURE;
}
@@ -1267,8 +1272,9 @@ NS_IMETHODIMP nsChildView::StartDrawPlugin()
// 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 (!mPluginIsCG)
if (isQDPlugin) {
port = mPluginQDPort.port;
}
RgnHandle pluginRegion = ::NewRgn();
if (pluginRegion) {
@@ -1341,6 +1347,12 @@ NS_IMETHODIMP nsChildView::GetPluginEventModel(int* outEventModel)
return NS_OK;
}
NS_IMETHODIMP nsChildView::SetPluginDrawingModel(int inDrawingModel)
{
[(ChildView*)mView setPluginDrawingModel:(NPDrawingModel)inDrawingModel];
return NS_OK;
}
NS_IMETHODIMP nsChildView::StartComplexTextInputForCurrentEvent()
{
[(ChildView*)mView pluginRequestsComplexTextInputForCurrentEvent];
@@ -2103,6 +2115,11 @@ NSEvent* gLastDragMouseDownEvent = nil;
mPluginEventModel = NPEventModelCarbon;
#else
mPluginEventModel = NPEventModelCocoa;
#endif
#ifndef NP_NO_QUICKDRAW
mPluginDrawingModel = NPDrawingModelQuickDraw;
#else
mPluginDrawingModel = NPDrawingModelCoreGraphics;
#endif
mCurKeyEvent = nil;
mKeyDownHandled = PR_FALSE;
@@ -2368,11 +2385,21 @@ NSEvent* gLastDragMouseDownEvent = nil;
mPluginEventModel = eventModel;
}
- (void)setPluginDrawingModel:(NPDrawingModel)drawingModel
{
mPluginDrawingModel = drawingModel;
}
- (NPEventModel)pluginEventModel;
{
return mPluginEventModel;
}
- (NPDrawingModel)pluginDrawingModel;
{
return mPluginDrawingModel;
}
- (void)sendFocusEvent:(PRUint32)eventType
{
if (!mGeckoChild)