diff --git a/dom/plugins/ipc/PluginInstanceChild.cpp b/dom/plugins/ipc/PluginInstanceChild.cpp index 5636892be9f6..cf6583e9104d 100644 --- a/dom/plugins/ipc/PluginInstanceChild.cpp +++ b/dom/plugins/ipc/PluginInstanceChild.cpp @@ -201,6 +201,9 @@ PluginInstanceChild::~PluginInstanceChild() if (mCGLayer) { PluginUtilsOSX::ReleaseCGLayer(mCGLayer); } + if (mDrawingModel == NPDrawingModelCoreAnimation) { + UnscheduleTimer(mCARefreshTimer); + } #endif } @@ -460,6 +463,22 @@ PluginInstanceChild::NPN_GetValue(NPNVariable aVar, } +#ifdef MOZ_WIDGET_COCOA +#define DEFAULT_REFRESH_MS 20 // CoreAnimation: 50 FPS + +void +CAUpdate(NPP npp, uint32_t timerID) { + static_cast(npp->ndata)->Invalidate(); +} + +void +PluginInstanceChild::Invalidate() +{ + NPRect windowRect = {0, 0, mWindow.height, mWindow.width}; + + InvalidateRect(&windowRect); +} +#endif NPError PluginInstanceChild::NPN_SetValue(NPPVariable aVar, void* aValue) @@ -507,6 +526,10 @@ PluginInstanceChild::NPN_SetValue(NPPVariable aVar, void* aValue) return NPERR_GENERIC_ERROR; mDrawingModel = drawingModel; + if (drawingModel == NPDrawingModelCoreAnimation) { + mCARefreshTimer = ScheduleTimer(DEFAULT_REFRESH_MS, true, CAUpdate); + } + PLUGIN_LOG_DEBUG((" Plugin requested drawing model id #%i\n", mDrawingModel)); diff --git a/dom/plugins/ipc/PluginInstanceChild.h b/dom/plugins/ipc/PluginInstanceChild.h index d9fb3fbfec83..53a4a23a15de 100644 --- a/dom/plugins/ipc/PluginInstanceChild.h +++ b/dom/plugins/ipc/PluginInstanceChild.h @@ -236,6 +236,10 @@ public: void InvalidateRect(NPRect* aInvalidRect); +#ifdef MOZ_WIDGET_COCOA + void Invalidate(); +#endif // definied(MOZ_WIDGET_COCOA) + uint32_t ScheduleTimer(uint32_t interval, bool repeat, TimerFunc func); void UnscheduleTimer(uint32_t id); @@ -426,6 +430,9 @@ private: nsCARenderer mCARenderer; void *mCGLayer; + // Core Animation drawing model requires a refresh timer. + uint32_t mCARefreshTimer; + public: const NPCocoaEvent* getCurrentEvent() { return mCurrentEvent; diff --git a/dom/plugins/ipc/PluginInstanceParent.cpp b/dom/plugins/ipc/PluginInstanceParent.cpp index 21ec95841043..22091a2919d8 100644 --- a/dom/plugins/ipc/PluginInstanceParent.cpp +++ b/dom/plugins/ipc/PluginInstanceParent.cpp @@ -96,7 +96,6 @@ PluginInstanceParent::PluginInstanceParent(PluginModuleParent* parent, , mPluginWndProc(NULL) , mNestedEventState(false) #endif // defined(XP_WIN) - , mQuirks(0) #if defined(XP_MACOSX) , mShWidth(0) , mShHeight(0) @@ -104,20 +103,6 @@ PluginInstanceParent::PluginInstanceParent(PluginModuleParent* parent, , mDrawingModel(NPDrawingModelCoreGraphics) #endif { - InitQuirksModes(aMimeType); -} - -void -PluginInstanceParent::InitQuirksModes(const nsCString& aMimeType) -{ -#ifdef MOZ_WIDGET_COCOA - NS_NAMED_LITERAL_CSTRING(flash, "application/x-shockwave-flash"); - // Flash sends us Invalidate events so we will use those - // instead of the refresh timer. - if (!FindInReadable(flash, aMimeType)) { - mQuirks |= COREANIMATION_REFRESH_TIMER; - } -#endif } PluginInstanceParent::~PluginInstanceParent() @@ -135,9 +120,6 @@ PluginInstanceParent::~PluginInstanceParent() } if (mShColorSpace) ::CGColorSpaceRelease(mShColorSpace); - if (mDrawingModel == NPDrawingModelCoreAnimation) { - mParent->RemoveFromRefreshTimer(this); - } #endif } @@ -394,10 +376,6 @@ PluginInstanceParent::AnswerNPN_SetValue_NPPVpluginDrawingModel( mDrawingModel = drawingModel; *result = mNPNIface->setvalue(mNPP, NPPVpluginDrawingModel, (void*)NPDrawingModelCoreGraphics); - if (drawingModel == NPDrawingModelCoreAnimation && - mQuirks & COREANIMATION_REFRESH_TIMER) { - mParent->AddToRefreshTimer(this); - } } else { mDrawingModel = drawingModel; *result = mNPNIface->setvalue(mNPP, NPPVpluginDrawingModel, @@ -1863,12 +1841,3 @@ PluginInstanceParent::AnswerPluginFocusChange(const bool& gotFocus) return false; #endif } - -#ifdef MOZ_WIDGET_COCOA -void -PluginInstanceParent::Invalidate() -{ - NPRect windowRect = {0, 0, mShHeight, mShWidth}; - RecvNPN_InvalidateRect(windowRect); -} -#endif diff --git a/dom/plugins/ipc/PluginInstanceParent.h b/dom/plugins/ipc/PluginInstanceParent.h index 236b4f8d880f..f1238d797e9a 100644 --- a/dom/plugins/ipc/PluginInstanceParent.h +++ b/dom/plugins/ipc/PluginInstanceParent.h @@ -279,10 +279,6 @@ public: virtual bool AnswerPluginFocusChange(const bool& gotFocus); -#ifdef MOZ_WIDGET_COCOA - void Invalidate(); -#endif // definied(MOZ_WIDGET_COCOA) - nsresult AsyncSetWindow(NPWindow* window); nsresult GetImage(mozilla::layers::ImageContainer* aContainer, mozilla::layers::Image** aImage); nsresult GetImageSize(nsIntSize* aSize); @@ -313,16 +309,6 @@ private: virtual bool DeallocPPluginBackgroundDestroyer(PPluginBackgroundDestroyerParent* aActor); - // Quirks mode support for various plugin mime types - enum PluginQuirks { - // OSX: Don't use the refresh timer for plug-ins - // using this quirk. These plug-in most have another - // way to refresh the window. - COREANIMATION_REFRESH_TIMER = 1, - }; - - void InitQuirksModes(const nsCString& aMimeType); - bool InternalGetValueForNPObject(NPNVariable aVariable, PPluginScriptableObjectParent** aValue, NPError* aResult); @@ -332,7 +318,6 @@ private: NPP mNPP; const NPNetscapeFuncs* mNPNIface; NPWindowType mWindowType; - int mQuirks; nsDataHashtable mScriptableObjects; diff --git a/dom/plugins/ipc/PluginModuleParent.cpp b/dom/plugins/ipc/PluginModuleParent.cpp index 1fceef5a97e5..bb4cdb19960f 100644 --- a/dom/plugins/ipc/PluginModuleParent.cpp +++ b/dom/plugins/ipc/PluginModuleParent.cpp @@ -146,12 +146,6 @@ PluginModuleParent::~PluginModuleParent() { NS_ASSERTION(OkToCleanup(), "unsafe destruction"); -#ifdef OS_MACOSX - if (mCATimer) { - mCATimer->Cancel(); - } -#endif - if (!mShutdown) { NS_WARNING("Plugin host deleted the module without shutting down."); NPError err; @@ -1171,52 +1165,6 @@ PluginModuleParent::RecvGetNativeCursorsSupported(bool* supported) #endif } -#ifdef OS_MACOSX -#define DEFAULT_REFRESH_MS 20 // CoreAnimation: 50 FPS - -void -CAUpdate(nsITimer *aTimer, void *aClosure) { - nsTObserverArray *ips = - static_cast *>(aClosure); - nsTObserverArray::ForwardIterator iter(*ips); -#ifdef MOZ_WIDGET_COCOA - while (iter.HasMore()) { - iter.GetNext()->Invalidate(); - } -#endif // MOZ_WIDGET_COCOA -} - -void -PluginModuleParent::AddToRefreshTimer(PluginInstanceParent *aInstance) { - if (mCATimerTargets.Contains(aInstance)) { - return; - } - - mCATimerTargets.AppendElement(aInstance); - if (mCATimerTargets.Length() == 1) { - if (!mCATimer) { - nsresult rv; - nsCOMPtr xpcomTimer = do_CreateInstance(NS_TIMER_CONTRACTID, &rv); - if (NS_FAILED(rv)) { - NS_WARNING("Could not create Core Animation timer for plugin."); - return; - } - mCATimer = xpcomTimer; - } - mCATimer->InitWithFuncCallback(CAUpdate, &mCATimerTargets, DEFAULT_REFRESH_MS, - nsITimer::TYPE_REPEATING_SLACK); - } -} - -void -PluginModuleParent::RemoveFromRefreshTimer(PluginInstanceParent *aInstance) { - bool visibleRemoved = mCATimerTargets.RemoveElement(aInstance); - if (visibleRemoved && mCATimerTargets.IsEmpty()) { - mCATimer->Cancel(); - } -} -#endif - bool PluginModuleParent::RecvNPN_SetException(PPluginScriptableObjectParent* aActor, const nsCString& aMessage) diff --git a/dom/plugins/ipc/PluginModuleParent.h b/dom/plugins/ipc/PluginModuleParent.h index 78b70d7564a6..66bb84e515ea 100644 --- a/dom/plugins/ipc/PluginModuleParent.h +++ b/dom/plugins/ipc/PluginModuleParent.h @@ -61,8 +61,6 @@ #include "nsDataHashtable.h" #include "nsHashKeys.h" #include "nsIFileStreams.h" -#include "nsTObserverArray.h" -#include "nsITimer.h" namespace mozilla { namespace dom { @@ -155,11 +153,6 @@ public: void ProcessRemoteNativeEventsInRPCCall(); -#ifdef OS_MACOSX - void AddToRefreshTimer(PluginInstanceParent *aInstance); - void RemoveFromRefreshTimer(PluginInstanceParent *aInstance); -#endif - protected: NS_OVERRIDE virtual mozilla::ipc::RPCChannel::RacyRPCPolicy @@ -335,11 +328,6 @@ private: nsString mBrowserDumpID; nsString mHangID; -#ifdef OS_MACOSX - nsCOMPtr mCATimer; - nsTObserverArray mCATimerTargets; -#endif - #ifdef MOZ_X11 // Dup of plugin's X socket, used to scope its resources to this // object instead of the plugin process's lifetime