зеркало из https://github.com/mozilla/pjs.git
r=danm, sr=dveditz Extend ConfirmEx to allow setting the default button - change default button for script security to no
This commit is contained in:
Родитель
a162e9bcb1
Коммит
18d9c2feaa
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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++) {
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче