diff --git a/mozilla/caps/src/nsScriptSecurityManager.cpp b/mozilla/caps/src/nsScriptSecurityManager.cpp index 9d37c056fb7..491dd7c2034 100644 --- a/mozilla/caps/src/nsScriptSecurityManager.cpp +++ b/mozilla/caps/src/nsScriptSecurityManager.cpp @@ -2141,6 +2141,7 @@ nsScriptSecurityManager::CheckConfirmDialog(JSContext* cx, nsIPrincipal* aPrinci PRInt32 buttonPressed = 1; // If the user exits by clicking the close box, assume No (button 1) rv = prompter->ConfirmEx(title.get(), message.get(), + (nsIPrompt::BUTTON_POS_1_DEFAULT) + (nsIPrompt::BUTTON_TITLE_YES * nsIPrompt::BUTTON_POS_0) + (nsIPrompt::BUTTON_TITLE_NO * nsIPrompt::BUTTON_POS_1), nsnull, nsnull, nsnull, check.get(), checkValue, &buttonPressed); diff --git a/mozilla/embedding/components/windowwatcher/public/nsIPromptService.idl b/mozilla/embedding/components/windowwatcher/public/nsIPromptService.idl index 5daeeaef625..bf85da3bb4e 100644 --- a/mozilla/embedding/components/windowwatcher/public/nsIPromptService.idl +++ b/mozilla/embedding/components/windowwatcher/public/nsIPromptService.idl @@ -130,7 +130,11 @@ interface nsIPromptService : nsISupports const unsigned long BUTTON_TITLE_REVERT = 7; const unsigned long BUTTON_TITLE_IS_STRING = 127; - + + const unsigned long BUTTON_POS_0_DEFAULT = 0 << 24; + const unsigned long BUTTON_POS_1_DEFAULT = 1 << 24; + const unsigned long BUTTON_POS_2_DEFAULT = 2 << 24; + const unsigned long STD_OK_CANCEL_BUTTONS = (BUTTON_TITLE_OK * BUTTON_POS_0) + (BUTTON_TITLE_CANCEL * BUTTON_POS_1); diff --git a/mozilla/embedding/components/windowwatcher/public/nsPIPromptService.idl b/mozilla/embedding/components/windowwatcher/public/nsPIPromptService.idl index 6c687142b7d..28ecc6560b9 100644 --- a/mozilla/embedding/components/windowwatcher/public/nsPIPromptService.idl +++ b/mozilla/embedding/components/windowwatcher/public/nsPIPromptService.idl @@ -52,7 +52,7 @@ interface nsPIPromptService : nsISupports eButton0Text=8, eButton1Text=9, eButton2Text=10, eButton3Text=11, eDialogTitle=12}; enum {eButtonPressed=0, eCheckboxState=1, eNumberButtons=2, - eNumberEditfields=3, eEditField1Password=4}; + eNumberEditfields=3, eEditField1Password=4, eDefaultButton=5}; %} void doDialog(in nsIDOMWindow aParent, in nsIDialogParamBlock aParamBlock, in string aChromeURL); diff --git a/mozilla/embedding/components/windowwatcher/src/nsPromptService.cpp b/mozilla/embedding/components/windowwatcher/src/nsPromptService.cpp index 243b0f94015..22042f95a9d 100644 --- a/mozilla/embedding/components/windowwatcher/src/nsPromptService.cpp +++ b/mozilla/embedding/components/windowwatcher/src/nsPromptService.cpp @@ -287,7 +287,10 @@ nsPromptService::ConfirmEx(nsIDOMWindow *parent, int buttonIDs[] = { eButton0Text, eButton1Text, eButton2Text }; const PRUnichar* buttonStrings[] = { button0Title, button1Title, button2Title }; - + +#define BUTTON_DEFAULT_MASK 0x03000000 + + block->SetInt(eDefaultButton, (buttonFlags & BUTTON_DEFAULT_MASK) >> 24); PRInt32 numberButtons = 0; for (int i = 0; i < 3; i++) { diff --git a/mozilla/netwerk/base/public/nsIPrompt.idl b/mozilla/netwerk/base/public/nsIPrompt.idl index 116f2c5f9e7..d5087c7b2d2 100644 --- a/mozilla/netwerk/base/public/nsIPrompt.idl +++ b/mozilla/netwerk/base/public/nsIPrompt.idl @@ -84,6 +84,10 @@ interface nsIPrompt : nsISupports const unsigned long BUTTON_TITLE_REVERT = 7; const unsigned long BUTTON_TITLE_IS_STRING = 127; + + const unsigned long BUTTON_POS_0_DEFAULT = 0 << 24; + const unsigned long BUTTON_POS_1_DEFAULT = 1 << 24; + const unsigned long BUTTON_POS_2_DEFAULT = 2 << 24; const unsigned long STD_OK_CANCEL_BUTTONS = (BUTTON_TITLE_OK * BUTTON_POS_0) + (BUTTON_TITLE_CANCEL * BUTTON_POS_1); diff --git a/mozilla/xpfe/global/resources/content/commonDialog.js b/mozilla/xpfe/global/resources/content/commonDialog.js index 6e738cee1cb..eae83751020 100644 --- a/mozilla/xpfe/global/resources/content/commonDialog.js +++ b/mozilla/xpfe/global/resources/content/commonDialog.js @@ -135,7 +135,6 @@ function commonDialogOnLoad() iconClass = "message-icon"; iconElement.setAttribute("class", iconElement.getAttribute("class") + " " + iconClass); - var firstButton = document.documentElement.getButton("accept"); switch (nButtons) { case 4: setLabelForNode(document.documentElement.getButton("extra2"), gCommonDialogParam.GetString(11)); @@ -152,7 +151,7 @@ function commonDialogOnLoad() case 1: string = gCommonDialogParam.GetString(8); if (string) - setLabelForNode(firstButton, string); + setLabelForNode(document.documentElement.getButton("accept"), string); break; } @@ -163,7 +162,24 @@ function commonDialogOnLoad() setCheckbox(gCommonDialogParam.GetString(1), gCommonDialogParam.GetInt(1)); if (gCommonDialogParam.GetInt(3) == 0) // If no text fields - firstButton.focus(); // Don't focus checkbox, focus first button instead + { + var defaultButton = gCommonDialogParam.GetInt(5); + switch (defaultButton) { + case 3: + document.documentElement.getButton("extra2").focus(); + break; + case 2: + document.documentElement.getButton("extra1").focus(); + break; + case 1: + document.documentElement.getButton("cancel").focus(); + break; + default: + case 0: + document.documentElement.getButton("accept").focus(); + break; + } + } getAttention(); }