Bug 339649, incorrect script-global used in nsXBLPrototypeHandler::ExecuteHandler (with bustage fix), r=sicking, sr=jst

This commit is contained in:
Olli.Pettay@helsinki.fi 2007-07-06 06:47:50 -07:00
Родитель 3f7d89ed2b
Коммит f4dbc00b25
4 изменённых файлов: 18 добавлений и 13 удалений

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

@ -419,20 +419,14 @@ nsXBLPrototypeHandler::ExecuteHandler(nsPIDOMEventTarget* aTarget,
// Compile the handler and bind it to the element.
nsCOMPtr<nsIScriptGlobalObject> boundGlobal;
nsCOMPtr<nsPIWindowRoot> winRoot(do_QueryInterface(aTarget));
nsCOMPtr<nsIDOMWindowInternal> focusedWin;
nsCOMPtr<nsIDOMWindow> window;
if (winRoot) {
nsCOMPtr<nsIFocusController> focusController;
winRoot->GetFocusController(getter_AddRefs(focusController));
focusController->GetFocusedWindow(getter_AddRefs(focusedWin));
window = winRoot->GetWindow();
}
// if the focused window was found get our script global object from
// that.
if (focusedWin) {
NS_ASSERTION(isXULKey, "We should only use the focused window for "
"XUL key handlers!");
nsCOMPtr<nsPIDOMWindow> piWin(do_QueryInterface(focusedWin));
if (window) {
nsCOMPtr<nsPIDOMWindow> piWin(do_QueryInterface(window));
if (piWin) {
piWin = piWin->GetCurrentInnerWindow();

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

@ -43,18 +43,21 @@
#include "nsISupports.h"
#include "nsPIDOMEventTarget.h"
class nsIDOMWindow;
class nsIFocusController;
// c18dee5a-dcf9-4391-a20c-581e769d095e
// 440f8d32-818d-468a-ac75-5916fa1ea198
#define NS_IWINDOWROOT_IID \
{ 0xc18dee5a, 0xdcf9, 0x4391, \
{ 0xa2, 0x0c, 0x58, 0x1e, 0x76, 0x9d, 0x09, 0x5e } }
{ 0x440f8d32, 0x818d, 0x468a, \
{ 0xac, 0x75, 0x59, 0x16, 0xfa, 0x1e, 0xa1, 0x98 } }
class nsPIWindowRoot : public nsPIDOMEventTarget {
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IWINDOWROOT_IID)
NS_IMETHOD GetFocusController(nsIFocusController** aResult)=0;
virtual nsIDOMWindow* GetWindow()=0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsPIWindowRoot, NS_IWINDOWROOT_IID)

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

@ -264,6 +264,12 @@ nsWindowRoot::GetFocusController(nsIFocusController** aResult)
return NS_OK;
}
nsIDOMWindow*
nsWindowRoot::GetWindow()
{
return mWindow;
}
NS_IMETHODIMP
nsWindowRoot::GetScriptTypeID(PRUint32 *aScriptType)
{

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

@ -87,6 +87,8 @@ public:
// nsPIWindowRoot
NS_IMETHOD GetFocusController(nsIFocusController** aResult);
virtual nsIDOMWindow* GetWindow();
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsWindowRoot, nsIDOMEventTarget)
protected: