Fixing bug 131007, unpaired events cause us to remain in capture and look hung, r=jkeiser sr=bryner

This commit is contained in:
peterlubczynski%netscape.com 2003-03-11 00:54:18 +00:00
Родитель 499b364318
Коммит eccc1a5ed8
5 изменённых файлов: 61 добавлений и 0 удалений

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

@ -704,6 +704,11 @@ nsObjectFrame::Destroy(nsIPresContext* aPresContext)
nsCOMPtr<nsIPluginHost> pluginHost = do_GetService(kCPluginManagerCID);
if(pluginHost)
pluginHost->StopPluginInstance(inst);
// the frame is going away along with its widget
// so tell the window to forget its widget too
if (window)
window->SetPluginWidget(nsnull);
}
}
return nsObjectFrameSuper::Destroy(aPresContext);
@ -4113,6 +4118,9 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void)
// start the idle timer.
StartTimer();
// tell the plugin window about the widget
mPluginWindow->SetPluginWidget(mWidget);
}
}
}

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

@ -704,6 +704,11 @@ nsObjectFrame::Destroy(nsIPresContext* aPresContext)
nsCOMPtr<nsIPluginHost> pluginHost = do_GetService(kCPluginManagerCID);
if(pluginHost)
pluginHost->StopPluginInstance(inst);
// the frame is going away along with its widget
// so tell the window to forget its widget too
if (window)
window->SetPluginWidget(nsnull);
}
}
return nsObjectFrameSuper::Destroy(aPresContext);
@ -4113,6 +4118,9 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void)
// start the idle timer.
StartTimer();
// tell the plugin window about the widget
mPluginWindow->SetPluginWidget(mWidget);
}
}
}

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

@ -45,6 +45,7 @@
#include "nsCOMPtr.h"
#include "nsIPluginInstance.h"
#include "nsplugindefs.h"
#include "nsIWidget.h"
/**
* base class for native plugin window implementations
@ -76,6 +77,15 @@ public:
return NS_OK;
}
nsresult GetPluginWidget(nsIWidget **aWidget) {
NS_IF_ADDREF(*aWidget = mWidget);
return NS_OK;
}
nsresult SetPluginWidget(nsIWidget *aWidget) {
mWidget = aWidget;
return NS_OK;
}
public:
virtual nsresult CallSetWindow(nsCOMPtr<nsIPluginInstance> &aPluginInstance) {
// null aPluginInstance means that we want to call SetWindow(null)
@ -90,6 +100,7 @@ public:
protected:
nsCOMPtr<nsIPluginInstance> mPluginInstance;
nsCOMPtr<nsIWidget> mWidget;
};
nsresult PLUG_NewPluginNativeWindow(nsPluginNativeWindow ** aPluginNativeWindow);

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

@ -192,6 +192,33 @@ static LRESULT CALLBACK PluginWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM
}
}
// Activate/deactivate mouse capture on the plugin widget
// here, before we pass the Windows event to the plugin
// because its possible our widget won't get paired events
// (see bug 131007) and we'll look frozen. Note that this
// is also done in ChildWindow::DispatchMouseEvent.
switch (msg) {
case WM_LBUTTONDOWN:
case WM_MBUTTONDOWN:
case WM_RBUTTONDOWN: {
nsCOMPtr<nsIWidget> widget;
win->GetPluginWidget(getter_AddRefs(widget));
if (widget)
widget->CaptureMouse(PR_TRUE);
break;
}
case WM_MBUTTONUP:
case WM_LBUTTONUP:
case WM_RBUTTONUP: {
nsCOMPtr<nsIWidget> widget;
win->GetPluginWidget(getter_AddRefs(widget));
if (widget)
widget->CaptureMouse(PR_FALSE);
break;
}
}
// Macromedia Flash plugin may flood the message queue with some special messages
// (WM_USER+1) causing 100% CPU consumption and GUI freeze, see mozilla bug 132759;
// we can prevent this from happening by delaying the processing such messages;

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

@ -392,6 +392,10 @@ PluginViewerImpl::CreatePlugin(nsIRequest* request, nsIPluginHost* aHost, const
channel->GetContentType(ct);
if (NS_FAILED(rv)) return rv;
rv = aHost->InstantiateFullPagePlugin(ct.get(), str, aResult, mOwner);
if (NS_SUCCEEDED(rv)) {
NS_STATIC_CAST(nsPluginNativeWindow*, win)->SetPluginWidget(mWindow);
}
}
return rv;
@ -492,6 +496,9 @@ PluginViewerImpl::Destroy(void)
window ? window->CallSetWindow(nullinst) : inst->SetWindow(nsnull);
inst->Stop();
}
if (window)
window->SetPluginWidget(nsnull);
}
}
return NS_OK;