Bug 672193 Support some actions of WM_APPCOMMAND such as New, Open, Close, Save, Find, Help, SendMail, ReplyToMail and ForwardMail r=gavin+jimm

This commit is contained in:
Masayuki Nakano 2012-12-31 09:33:49 +09:00
parent f063b6ba6a
commit fbeff841fd
3 changed files with 86 additions and 9 deletions

View File

@ -1750,7 +1750,6 @@ var nonBrowserWindowShutdown = gBrowserInit.nonBrowserWindowShutdown.bind(
function HandleAppCommandEvent(evt) {
evt.stopPropagation();
switch (evt.command) {
case "Back":
BrowserBack();
@ -1774,9 +1773,35 @@ function HandleAppCommandEvent(evt) {
case "Home":
BrowserHome();
break;
default:
case "New":
BrowserOpenTab();
break;
case "Close":
BrowserCloseTabOrWindow();
break;
case "Find":
gFindBar.onFindCommand();
break;
case "Help":
openHelpLink('firefox-help');
break;
case "Open":
BrowserOpenFileWindow();
break;
case "Print":
PrintUtils.print();
break;
case "Save":
saveDocument(window.content.document);
break;
case "SendMail":
MailIntegration.sendLinkForWindow(window.content);
break;
default:
return;
}
evt.stopPropagation();
evt.preventDefault();
}
function gotoHistoryIndex(aEvent) {

View File

@ -2014,6 +2014,16 @@ GK_ATOM(Clear, "Clear")
GK_ATOM(VolumeUp, "VolumeUp")
GK_ATOM(VolumeDown, "VolumeDown")
GK_ATOM(Menu, "Menu")
GK_ATOM(New, "New")
GK_ATOM(Open, "Open")
GK_ATOM(Close, "Close")
GK_ATOM(Save, "Save")
GK_ATOM(Find, "Find")
GK_ATOM(Help, "Help")
GK_ATOM(Print, "Print")
GK_ATOM(SendMail, "SendMail")
GK_ATOM(ForwardMail, "ForwardMail")
GK_ATOM(ReplyToMail, "ReplyToMail")
// Smooth scroll events origins
GK_ATOM(mouseWheel, "mouseWheel") // For discrete wheel events (e.g. not OSX magic mouse)

View File

@ -3687,15 +3687,43 @@ bool nsWindow::DispatchCommandEvent(uint32_t aEventCommand)
case APPCOMMAND_BROWSER_HOME:
command = nsGkAtoms::Home;
break;
case APPCOMMAND_CLOSE:
command = nsGkAtoms::Close;
break;
case APPCOMMAND_FIND:
command = nsGkAtoms::Find;
break;
case APPCOMMAND_HELP:
command = nsGkAtoms::Help;
break;
case APPCOMMAND_NEW:
command = nsGkAtoms::New;
break;
case APPCOMMAND_OPEN:
command = nsGkAtoms::Open;
break;
case APPCOMMAND_PRINT:
command = nsGkAtoms::Print;
break;
case APPCOMMAND_SAVE:
command = nsGkAtoms::Save;
break;
case APPCOMMAND_FORWARD_MAIL:
command = nsGkAtoms::ForwardMail;
break;
case APPCOMMAND_REPLY_TO_MAIL:
command = nsGkAtoms::ReplyToMail;
break;
case APPCOMMAND_SEND_MAIL:
command = nsGkAtoms::SendMail;
break;
default:
return false;
}
nsCommandEvent event(true, nsGkAtoms::onAppCommand, command, this);
InitEvent(event);
DispatchWindowEvent(&event);
return true;
return DispatchWindowEvent(&event);
}
// Recursively dispatch synchronous paints for nsIWidget
@ -5028,10 +5056,24 @@ bool nsWindow::ProcessMessage(UINT msg, WPARAM &wParam, LPARAM &lParam,
case APPCOMMAND_BROWSER_SEARCH:
case APPCOMMAND_BROWSER_FAVORITES:
case APPCOMMAND_BROWSER_HOME:
DispatchCommandEvent(appCommand);
// tell the driver that we handled the event
*aRetValue = 1;
result = true;
case APPCOMMAND_CLOSE:
case APPCOMMAND_FIND:
case APPCOMMAND_HELP:
case APPCOMMAND_NEW:
case APPCOMMAND_OPEN:
case APPCOMMAND_PRINT:
case APPCOMMAND_SAVE:
case APPCOMMAND_FORWARD_MAIL:
case APPCOMMAND_REPLY_TO_MAIL:
case APPCOMMAND_SEND_MAIL:
// We shouldn't consume the message always because if we don't handle
// the message, the sender (typically, utility of keyboard or mouse)
// may send other key messages which indicate well known shortcut key.
if (DispatchCommandEvent(appCommand)) {
// tell the driver that we handled the event
*aRetValue = 1;
result = true;
}
break;
}
// default = false - tell the driver that the event was not handled