Bug 693160 - Cleanup nsWindowRoot::GetControllerForCommand a bit; r=bz

This commit is contained in:
Ms2ger 2011-10-15 09:27:57 +02:00
Родитель 8bc507ae45
Коммит 9325fe1c33
1 изменённых файлов: 20 добавлений и 26 удалений

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

@ -1,6 +1,5 @@
/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
@ -239,39 +238,36 @@ nsWindowRoot::GetControllerForCommand(const char * aCommand,
NS_ENSURE_ARG_POINTER(_retval);
*_retval = nsnull;
nsCOMPtr<nsIControllers> controllers;
nsCOMPtr<nsIController> controller;
GetControllers(getter_AddRefs(controllers));
if (controllers) {
controllers->GetControllerForCommand(aCommand, getter_AddRefs(controller));
if (controller) {
controller.swap(*_retval);
return NS_OK;
{
nsCOMPtr<nsIControllers> controllers;
GetControllers(getter_AddRefs(controllers));
if (controllers) {
nsCOMPtr<nsIController> controller;
controllers->GetControllerForCommand(aCommand, getter_AddRefs(controller));
if (controller) {
controller.forget(_retval);
return NS_OK;
}
}
}
nsCOMPtr<nsPIDOMWindow> focusedWindow;
nsFocusManager::GetFocusedDescendant(mWindow, PR_TRUE, getter_AddRefs(focusedWindow));
while (focusedWindow) {
nsCOMPtr<nsIDOMWindow> domWindow(do_QueryInterface(focusedWindow));
nsCOMPtr<nsIControllers> controllers2;
domWindow->GetControllers(getter_AddRefs(controllers2));
if (controllers2) {
controllers2->GetControllerForCommand(aCommand,
getter_AddRefs(controller));
nsCOMPtr<nsIControllers> controllers;
focusedWindow->GetControllers(getter_AddRefs(controllers));
if (controllers) {
nsCOMPtr<nsIController> controller;
controllers->GetControllerForCommand(aCommand,
getter_AddRefs(controller));
if (controller) {
controller.swap(*_retval);
controller.forget(_retval);
return NS_OK;
}
}
// XXXndeakin P3 is this casting safe?
nsCOMPtr<nsPIDOMWindow> piWindow = do_QueryInterface(focusedWindow);
nsGlobalWindow *win =
static_cast<nsGlobalWindow *>
(static_cast<nsIDOMWindow*>(piWindow));
nsGlobalWindow *win = static_cast<nsGlobalWindow*>(focusedWindow.get());
focusedWindow = win->GetPrivateParent();
}
@ -296,8 +292,6 @@ nsresult
NS_NewWindowRoot(nsPIDOMWindow* aWindow, nsIDOMEventTarget** aResult)
{
*aResult = new nsWindowRoot(aWindow);
if (!*aResult)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*aResult);
return NS_OK;
}