diff --git a/dom/plugins/PluginInstanceChild.cpp b/dom/plugins/PluginInstanceChild.cpp index 398192b30c60..63510bd99605 100644 --- a/dom/plugins/PluginInstanceChild.cpp +++ b/dom/plugins/PluginInstanceChild.cpp @@ -143,6 +143,7 @@ PluginInstanceChild::PluginInstanceChild(const NPPluginFuncs* aPluginIface) , mCurrentAsyncSetWindowTask(nsnull) , mPendingPluginCall(false) , mDoAlphaExtraction(false) + , mHasPainted(false) , mSurfaceDifferenceRect(0,0,0,0) #if (MOZ_PLATFORM_MAEMO == 5) || (MOZ_PLATFORM_MAEMO == 6) , mMaemoImageRendering(PR_FALSE) @@ -2558,7 +2559,8 @@ PluginInstanceChild::UpdateWindowAttributes(bool aForceSetWindow) WINDOWPOS winpos = { 0, 0, mWindow.x, mWindow.y, - mWindow.width, mWindow.height + mWindow.width, mWindow.height, + 0 }; NPEvent pluginEvent = { WM_WINDOWPOSCHANGED, 0, @@ -2571,15 +2573,20 @@ PluginInstanceChild::UpdateWindowAttributes(bool aForceSetWindow) if (mPluginIface->setwindow) { mPluginIface->setwindow(&mData, &mWindow); } - - return; } void PluginInstanceChild::PaintRectToPlatformSurface(const nsIntRect& aRect, gfxASurface* aSurface) { + bool temporarilyMakeVisible = !IsVisible() && !mHasPainted; + if (temporarilyMakeVisible) { + mWindow.clipRect.right = mWindow.width; + mWindow.clipRect.bottom = mWindow.height; + } + UpdateWindowAttributes(); + #ifdef MOZ_X11 #if (MOZ_PLATFORM_MAEMO == 5) || (MOZ_PLATFORM_MAEMO == 6) // On maemo5 we do support Image rendering NPAPI @@ -2618,32 +2625,30 @@ PluginInstanceChild::PaintRectToPlatformSurface(const nsIntRect& aRect, exposeEvent.major_code = 0; exposeEvent.minor_code = 0; mPluginIface->event(&mData, reinterpret_cast(&exposeEvent)); - return; + } else +#endif + { + NS_ASSERTION(aSurface->GetType() == gfxASurface::SurfaceTypeXlib, + "Non supported platform surface type"); + + NPEvent pluginEvent; + XGraphicsExposeEvent& exposeEvent = pluginEvent.xgraphicsexpose; + exposeEvent.type = GraphicsExpose; + exposeEvent.display = mWsInfo.display; + exposeEvent.drawable = static_cast(aSurface)->XDrawable(); + exposeEvent.x = aRect.x; + exposeEvent.y = aRect.y; + exposeEvent.width = aRect.width; + exposeEvent.height = aRect.height; + exposeEvent.count = 0; + // information not set: + exposeEvent.serial = 0; + exposeEvent.send_event = False; + exposeEvent.major_code = 0; + exposeEvent.minor_code = 0; + mPluginIface->event(&mData, reinterpret_cast(&exposeEvent)); } -#endif - NS_ASSERTION(aSurface->GetType() == gfxASurface::SurfaceTypeXlib, - "Non supported platform surface type"); - - NPEvent pluginEvent; - XGraphicsExposeEvent& exposeEvent = pluginEvent.xgraphicsexpose; - exposeEvent.type = GraphicsExpose; - exposeEvent.display = mWsInfo.display; - exposeEvent.drawable = static_cast(aSurface)->XDrawable(); - exposeEvent.x = aRect.x; - exposeEvent.y = aRect.y; - exposeEvent.width = aRect.width; - exposeEvent.height = aRect.height; - exposeEvent.count = 0; - // information not set: - exposeEvent.serial = 0; - exposeEvent.send_event = False; - exposeEvent.major_code = 0; - exposeEvent.minor_code = 0; - mPluginIface->event(&mData, reinterpret_cast(&exposeEvent)); - return; -#endif - -#ifdef XP_WIN +#elif defined(XP_WIN) NS_ASSERTION(SharedDIBSurface::IsSharedDIBSurface(aSurface), "Expected (SharedDIB) image surface."); @@ -2663,10 +2668,17 @@ PluginInstanceChild::PaintRectToPlatformSurface(const nsIntRect& aRect, ::SetViewportOrgEx((HDC) mWindow.window, -mWindow.x, -mWindow.y, NULL); mPluginIface->event(&mData, reinterpret_cast(&paintEvent)); - return; +#else + NS_RUNTIMEABORT("Surface type not implemented."); #endif - NS_RUNTIMEABORT("Surface type not implemented."); + if (temporarilyMakeVisible) { + mWindow.clipRect.right = mWindow.clipRect.bottom = 0; + + if (mPluginIface->setwindow) { + mPluginIface->setwindow(&mData, &mWindow); + } + } } void @@ -2800,6 +2812,7 @@ PluginInstanceChild::ShowPluginFrame() } else { PaintRectToSurface(rect, mCurrentSurface, gfxRGBA(0.0, 0.0, 0.0, 0.0)); } + mHasPainted = true; NPRect r = { (uint16_t)rect.y, (uint16_t)rect.x, (uint16_t)rect.YMost(), (uint16_t)rect.XMost() }; @@ -2897,7 +2910,7 @@ PluginInstanceChild::InvalidateRectDelayed(void) } mCurrentInvalidateTask = nsnull; - if (mAccumulatedInvalidRect.IsEmpty() || !IsVisible()) { + if (mAccumulatedInvalidRect.IsEmpty() || (mHasPainted && !IsVisible())) { return; } @@ -2909,7 +2922,7 @@ PluginInstanceChild::InvalidateRectDelayed(void) void PluginInstanceChild::AsyncShowPluginFrame(void) { - if (mCurrentInvalidateTask || !IsVisible()) { + if (mCurrentInvalidateTask || (mHasPainted && !IsVisible())) { return; } diff --git a/dom/plugins/PluginInstanceChild.h b/dom/plugins/PluginInstanceChild.h index 93bd93df9506..13593c184997 100644 --- a/dom/plugins/PluginInstanceChild.h +++ b/dom/plugins/PluginInstanceChild.h @@ -501,6 +501,11 @@ private: // supports NPPVpluginTransparentAlphaBool (which is not part of NPAPI yet) bool mDoAlphaExtraction; + // true when the plugin has painted at least once. We use this to ensure + // that we ask a plugin to paint at least once even if it's invisible; + // some plugin (instances) rely on this in order to work properly. + bool mHasPainted; + // Cached rectangle rendered to previous surface(mBackSurface) // Used for reading back to current surface and syncing data, // in plugin coordinates.