b=574583 Extend X11 windowless Flash Player drawing offset workaround to handle clips also r=roc

This commit is contained in:
Karl Tomlinson 2010-07-02 15:59:38 +12:00
Родитель 9b43663e20
Коммит 7867669e48
1 изменённых файлов: 56 добавлений и 21 удалений

Просмотреть файл

@ -408,6 +408,21 @@ public:
return "";
}
#ifdef MOZ_X11
void GetPluginDescription(nsACString& aDescription)
{
aDescription.Truncate();
if (mInstance && mPluginHost) {
nsCOMPtr<nsIPluginTag> pluginTag;
mPluginHost->GetPluginTagForInstance(mInstance,
getter_AddRefs(pluginTag));
if (pluginTag) {
pluginTag->GetDescription(aDescription);
}
}
}
#endif
PRBool SendNativeEvents()
{
#ifdef XP_WIN
@ -462,7 +477,13 @@ private:
PRUint32 mLastEventloopNestingLevel;
PRPackedBool mContentFocused;
PRPackedBool mWidgetVisible; // used on Mac to store our widget's visible state
#ifdef XP_MACOSX
PRPackedBool mPluginPortChanged;
#endif
#ifdef MOZ_X11
// Used with windowless plugins only, initialized in CreateWidget().
PRPackedBool mFlash10Quirks;
#endif
// If true, destroy the widget on destruction. Used when plugin stop
// is being delayed to a safer point in time.
@ -496,25 +517,25 @@ private:
#if defined(MOZ_WIDGET_GTK2)
class Renderer : public gfxGdkNativeRenderer {
public:
Renderer(NPWindow* aWindow, nsIPluginInstance* aInstance,
Renderer(NPWindow* aWindow, nsPluginInstanceOwner* aInstanceOwner,
const nsIntSize& aPluginSize, const nsIntRect& aDirtyRect)
: mWindow(aWindow), mInstance(aInstance),
: mWindow(aWindow), mInstanceOwner(aInstanceOwner),
mPluginSize(aPluginSize), mDirtyRect(aDirtyRect)
{}
virtual nsresult NativeDraw(GdkDrawable * drawable, short offsetX,
short offsetY, GdkRectangle * clipRects, PRUint32 numClipRects);
private:
NPWindow* mWindow;
nsIPluginInstance* mInstance;
nsPluginInstanceOwner* mInstanceOwner;
const nsIntSize& mPluginSize;
const nsIntRect& mDirtyRect;
};
#elif defined(MOZ_WIDGET_QT)
class Renderer : public gfxQtNativeRenderer {
public:
Renderer(NPWindow* aWindow, nsIPluginInstance* aInstance,
Renderer(NPWindow* aWindow, nsPluginInstanceOwner* aInstanceOwner,
const nsIntSize& aPluginSize, const nsIntRect& aDirtyRect)
: mWindow(aWindow), mInstance(aInstance),
: mWindow(aWindow), mInstanceOwner(aInstanceOwner),
mPluginSize(aPluginSize), mDirtyRect(aDirtyRect)
{}
virtual nsresult NativeDraw(gfxXlibSurface* xsurface, Colormap colormap,
@ -522,7 +543,7 @@ private:
QRect * clipRects, PRUint32 numClipRects);
private:
NPWindow* mWindow;
nsIPluginInstance* mInstance;
nsPluginInstanceOwner* mInstanceOwner;
const nsIntSize& mPluginSize;
const nsIntRect& mDirtyRect;
};
@ -2492,10 +2513,10 @@ nsPluginInstanceOwner::nsPluginInstanceOwner()
mInCGPaintLevel = 0;
mSentInitialTopLevelWindowEvent = PR_FALSE;
mIOSurface = nsnull;
mPluginPortChanged = PR_FALSE;
#endif
mContentFocused = PR_FALSE;
mWidgetVisible = PR_TRUE;
mPluginPortChanged = PR_FALSE;
mNumCachedAttrs = 0;
mNumCachedParams = 0;
mCachedAttrParamNames = nsnull;
@ -5137,11 +5158,12 @@ void nsPluginInstanceOwner::Paint(gfxContext* aContext,
NPWindow* window;
GetWindow(window);
PRUint32 rendererFlags =
Renderer::DRAW_SUPPORTS_OFFSET |
Renderer::DRAW_SUPPORTS_CLIP_RECT |
Renderer::DRAW_SUPPORTS_NONDEFAULT_VISUAL |
Renderer::DRAW_SUPPORTS_ALTERNATE_SCREEN;
PRUint32 rendererFlags = Renderer::DRAW_SUPPORTS_OFFSET;
if (!mFlash10Quirks) {
rendererFlags |=
Renderer::DRAW_SUPPORTS_CLIP_RECT |
Renderer::DRAW_SUPPORTS_NONDEFAULT_VISUAL;
}
PRBool transparent;
mInstance->IsTransparent(&transparent);
@ -5152,7 +5174,7 @@ void nsPluginInstanceOwner::Paint(gfxContext* aContext,
gfxContextAutoSaveRestore autoSR(aContext);
aContext->Translate(pluginRect.pos);
Renderer renderer(window, mInstance, pluginSize, pluginDirtyRect);
Renderer renderer(window, this, pluginSize, pluginDirtyRect);
renderer.Draw(aContext, window->width, window->height,
rendererFlags, nsnull);
}
@ -5462,6 +5484,11 @@ nsPluginInstanceOwner::Renderer::NativeDraw(gfxXlibSurface * xsurface,
Screen *screen = cairo_xlib_surface_get_screen(xsurface->CairoSurface());
#endif
#endif
nsIPluginInstance *instance = mInstanceOwner->mInstance;
if (!instance)
return NS_ERROR_FAILURE;
// See if the plugin must be notified of new window parameters.
PRBool doupdatewindow = PR_FALSE;
@ -5533,17 +5560,20 @@ nsPluginInstanceOwner::Renderer::NativeDraw(gfxXlibSurface * xsurface,
#endif
{
if (doupdatewindow)
mInstance->SetWindow(mWindow);
instance->SetWindow(mWindow);
}
#ifdef MOZ_X11
// Translate the dirty rect to drawable coordinates,
// and work around a bug in Flash up to 10.1 d51 at least, where expose
// event top left coordinates within the plugin-rect and not at the drawable
// origin are misinterpreted. (We can move the top left coordinate provided
// if it is within the clipRect.)
nsIntRect dirtyRect(offsetX, offsetY,
// Translate the dirty rect to drawable coordinates.
nsIntRect dirtyRect = mDirtyRect + nsIntPoint(offsetX, offsetY);
if (mInstanceOwner->mFlash10Quirks) {
// Work around a bug in Flash up to 10.1 d51 at least, where expose event
// top left coordinates within the plugin-rect and not at the drawable
// origin are misinterpreted. (We can move the top left coordinate
// provided it is within the clipRect.)
dirtyRect.SetRect(offsetX, offsetY,
mDirtyRect.XMost(), mDirtyRect.YMost());
}
// Intersect the dirty rect with the clip rect to ensure that it lies within
// the drawable.
if (!dirtyRect.IntersectRect(dirtyRect, clipRect))
@ -5574,7 +5604,7 @@ nsPluginInstanceOwner::Renderer::NativeDraw(gfxXlibSurface * xsurface,
exposeEvent.major_code = 0;
exposeEvent.minor_code = 0;
mInstance->HandleEvent(&pluginEvent, nsnull);
instance->HandleEvent(&pluginEvent, nsnull);
#ifdef MOZ_COMPOSITED_PLUGINS
}
else {
@ -5809,6 +5839,11 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void)
else {
ws_info->display = DefaultXDisplay();
}
nsCAutoString description;
GetPluginDescription(description);
NS_NAMED_LITERAL_CSTRING(flash10Head, "Shockwave Flash 10.");
mFlash10Quirks = StringBeginsWith(description, flash10Head);
#endif
} else if (mWidget) {
mWidget->Resize(mPluginWindow->width, mPluginWindow->height,