Bug 277067: Mozilla mistimes changing QuickDraw plugin visibility when switching tabs, patch by patch by Matthew Gregan <kinetik@flim.org>, r=josh, sr=roc, a=damon

This commit is contained in:
gavin%gavinsharp.com 2008-04-23 22:56:40 +00:00
Родитель a1c69ef130
Коммит 0aad604c6e
4 изменённых файлов: 75 добавлений и 6 удалений

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

@ -3857,8 +3857,13 @@ nsPluginInstanceOwner::Destroy()
target->RemoveEventListener(NS_LITERAL_STRING("draggesture"), listener, PR_TRUE);
}
if (mDestroyWidget && mWidget) {
mWidget->Destroy();
if (mWidget) {
nsCOMPtr<nsIPluginWidget> pluginWidget = do_QueryInterface(mWidget);
if (pluginWidget)
pluginWidget->SetPluginInstanceOwner(nsnull);
if (mDestroyWidget)
mWidget->Destroy();
}
return NS_OK;
@ -4346,7 +4351,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void)
PR_FALSE);
// mPluginWindow->type is used in |GetPluginPort| so it must
// be initilized first
// be initialized first
mPluginWindow->type = nsPluginWindowType_Window;
mPluginWindow->window = GetPluginPort();
@ -4355,6 +4360,11 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void)
// tell the plugin window about the widget
mPluginWindow->SetPluginWidget(mWidget);
// tell the widget about the current plugin instance owner.
nsCOMPtr<nsIPluginWidget> pluginWidget = do_QueryInterface(mWidget);
if (pluginWidget)
pluginWidget->SetPluginInstanceOwner(this);
}
}
}

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

@ -38,11 +38,11 @@
#include "nsISupports.h"
/* starting interface: nsIPluginWidget */
#define NS_IPLUGINWIDGET_IID_STR "e5576fe7-e25f-11d6-83bd-000393d7254a"
#define NS_IPLUGINWIDGET_IID_STR "d530ce43-8f6e-45c5-a984-35c43da19073"
#define NS_IPLUGINWIDGET_IID \
{0xe5576fe7, 0xe25f, 0x11d6, \
{ 0x83, 0xbd, 0x00, 0x03, 0x93, 0xd7, 0x25, 0x4a }}
{0xd530ce43, 0x8f6e, 0x45c5, \
{ 0xa9, 0x84, 0x35, 0xc4, 0x3d, 0xa1, 0x90, 0x73 }}
struct nsRect;
struct nsPoint;
@ -59,6 +59,7 @@ class NS_NO_VTABLE nsIPluginWidget : public nsISupports
NS_IMETHOD EndDrawPlugin(void) = 0;
NS_IMETHOD SetPluginInstanceOwner(nsIPluginInstanceOwner* pluginInstanceOwner) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIPluginWidget, NS_IPLUGINWIDGET_IID)

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

@ -48,6 +48,7 @@
#include "nsAutoPtr.h"
#include "nsISupports.h"
#include "nsBaseWidget.h"
#include "nsIPluginInstanceOwner.h"
#include "nsIPluginWidget.h"
#include "nsIScrollableView.h"
#include "nsWeakPtr.h"
@ -345,6 +346,7 @@ public:
NS_IMETHOD GetPluginClipRect(nsRect& outClipRect, nsPoint& outOrigin, PRBool& outWidgetVisible);
NS_IMETHOD StartDrawPlugin();
NS_IMETHOD EndDrawPlugin();
NS_IMETHOD SetPluginInstanceOwner(nsIPluginInstanceOwner* aInstanceOwner);
NS_IMETHOD GetHasTransparentBackground(PRBool& aTransparent);
NS_IMETHOD SetHasTransparentBackground(PRBool aTransparent);
@ -366,6 +368,8 @@ public:
NS_IMETHOD BeginSecureKeyboardInput();
NS_IMETHOD EndSecureKeyboardInput();
void HidePlugin();
protected:
PRBool ReportDestroyEvent();
@ -406,6 +410,7 @@ protected:
PRPackedBool mInSetFocus;
nsPluginPort mPluginPort;
nsIPluginInstanceOwner* mPluginInstanceOwner; // [WEAK]
};
void NS_InstallPluginKeyEventsHandler();

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

@ -749,6 +749,49 @@ NS_IMETHODIMP nsChildView::IsVisible(PRBool& outState)
}
void nsChildView::HidePlugin()
{
NS_ASSERTION(mIsPluginView, "HidePlugin called on non-plugin view");
if (mPluginInstanceOwner && !mPluginIsCG) {
nsPluginWindow* window;
mPluginInstanceOwner->GetWindow(window);
nsCOMPtr<nsIPluginInstance> instance;
mPluginInstanceOwner->GetInstance(*getter_AddRefs(instance));
if (window && instance) {
window->clipRect.top = 0;
window->clipRect.left = 0;
window->clipRect.bottom = 0;
window->clipRect.right = 0;
instance->SetWindow(window);
}
}
}
static void HideChildPluginViews(NSView* aView)
{
NSArray* subviews = [aView subviews];
for (unsigned int i = 0; i < [subviews count]; ++i) {
NSView* view = [subviews objectAtIndex: i];
if (![view isKindOfClass:[ChildView class]])
continue;
ChildView* childview = static_cast<ChildView*>(view);
if ([childview isPluginView]) {
nsChildView* widget = static_cast<nsChildView*>([childview widget]);
if (widget) {
widget->HidePlugin();
}
} else {
HideChildPluginViews(view);
}
}
}
// Hide or show this component
NS_IMETHODIMP nsChildView::Show(PRBool aState)
{
@ -757,6 +800,8 @@ NS_IMETHODIMP nsChildView::Show(PRBool aState)
if (aState != mVisible) {
[mView setHidden:!aState];
mVisible = aState;
if (!mVisible)
HideChildPluginViews(mView);
}
return NS_OK;
@ -1183,6 +1228,14 @@ NS_IMETHODIMP nsChildView::EndDrawPlugin()
}
NS_IMETHODIMP nsChildView::SetPluginInstanceOwner(nsIPluginInstanceOwner* aInstanceOwner)
{
mPluginInstanceOwner = aInstanceOwner;
return NS_OK;
}
void nsChildView::LiveResizeStarted()
{
// XXX todo. Use this to disable Java async redraw during resize