Bug 197152 AccDoAction failed with menuitem that has command (not oncommand) attribute

r=bryner, sr=jag
move command tag support from individual frames to nsXULElement
This commit is contained in:
kyle.yuan%sun.com 2003-03-25 03:15:37 +00:00
Родитель c3dd3441f6
Коммит 9c0b9d7fec
3 изменённых файлов: 21 добавлений и 35 удалений

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

@ -3145,6 +3145,25 @@ nsXULElement::HandleDOMEvent(nsIPresContext* aPresContext,
nsIDOMEvent* domEvent = nsnull;
if (NS_EVENT_FLAG_INIT & aFlags) {
if (aEvent->message == NS_XUL_COMMAND) {
// See if we have a command elt. If so, we execute on the command instead
// of on our content element.
nsAutoString command;
GetAttr(kNameSpaceID_None, nsXULAtoms::command, command);
if (!command.IsEmpty()) {
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(mDocument));
nsCOMPtr<nsIDOMElement> commandElt;
domDoc->GetElementById(command, getter_AddRefs(commandElt));
nsCOMPtr<nsIContent> commandContent(do_QueryInterface(commandElt));
if (commandContent) {
return commandContent->HandleDOMEvent(aPresContext, aEvent, nsnull, NS_EVENT_FLAG_INIT, aEventStatus);
}
else {
NS_WARNING("A XUL element is attached to a command that doesn't exist!\n");
return NS_ERROR_FAILURE;
}
}
}
if (aDOMEvent) {
if (*aDOMEvent)
externalDOMEvent = PR_TRUE;

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

@ -181,21 +181,6 @@ nsButtonBoxFrame::MouseClicked (nsIPresContext* aPresContext, nsGUIEvent* aEvent
nsCOMPtr<nsIPresShell> shell;
rv = aPresContext->GetShell(getter_AddRefs(shell));
if (NS_SUCCEEDED(rv) && shell) {
// See if we have a command elt. If so, we execute on the command instead
// of on our content element.
nsAutoString command;
mContent->GetAttr(kNameSpaceID_None, nsXULAtoms::command, command);
if (!command.IsEmpty()) {
nsCOMPtr<nsIDocument> doc;
mContent->GetDocument(*getter_AddRefs(doc));
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(doc));
nsCOMPtr<nsIDOMElement> commandElt;
domDoc->GetElementById(command, getter_AddRefs(commandElt));
nsCOMPtr<nsIContent> commandContent(do_QueryInterface(commandElt));
if (commandContent)
shell->HandleDOMEventWithTarget(commandContent, &event, &status);
}
else
shell->HandleDOMEventWithTarget(mContent, &event, &status);
shell->HandleDOMEventWithTarget(mContent, &event, &status);
}
}

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

@ -1713,25 +1713,7 @@ nsMenuFrame::Execute(nsGUIEvent *aEvent)
nsIFrame* me = this;
if (NS_SUCCEEDED(result) && shell) {
shell->GetViewManager(getter_AddRefs(kungFuDeathGrip));
// See if we have a command elt. If so, we execute on the command instead
// of on our content element.
nsAutoString command;
mContent->GetAttr(kNameSpaceID_None, nsXULAtoms::command, command);
if (!command.IsEmpty()) {
nsCOMPtr<nsIDocument> doc;
mContent->GetDocument(*getter_AddRefs(doc));
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(doc));
nsCOMPtr<nsIDOMElement> commandElt;
domDoc->GetElementById(command, getter_AddRefs(commandElt));
nsCOMPtr<nsIContent> commandContent(do_QueryInterface(commandElt));
if (commandContent)
shell->HandleDOMEventWithTarget(commandContent, &event, &status);
else
NS_ASSERTION(PR_FALSE, "A XUL <menuitem> is attached to a command that doesn't exist! Unable to execute menu item!\n");
}
else
shell->HandleDOMEventWithTarget(mContent, &event, &status);
shell->HandleDOMEventWithTarget(mContent, &event, &status);
}
// XXX HACK. Just gracefully exit if the node has been removed, e.g., window.close()