зеркало из https://github.com/mozilla/gecko-dev.git
Backout 032a3ba018db, It breaks <select> form element interactions (bug 961489, bug 961662)
This commit is contained in:
Родитель
f2985f811e
Коммит
ea326f6cdf
|
@ -170,25 +170,18 @@ public class Prompt implements OnClickListener, OnCancelListener, OnItemClickLis
|
|||
|
||||
/* Adds to a result value from the lists that can be shown in dialogs.
|
||||
* Will set the selected value(s) to the button attribute of the
|
||||
* object that's passed in. If this is a multi-select dialog, sets a
|
||||
* selected attribute to an array of booleans.
|
||||
* object that's passed in. If this is a multi-select dialog, can set
|
||||
* the button attribute to an array.
|
||||
*/
|
||||
private void addListResult(final JSONObject result, int which) {
|
||||
try {
|
||||
if (mSelected != null) {
|
||||
JSONArray selected = new JSONArray();
|
||||
for (int i = 0; i < mSelected.length; i++) {
|
||||
if (mSelected[i]) {
|
||||
selected.put(i);
|
||||
}
|
||||
selected.put(mSelected[i]);
|
||||
}
|
||||
result.put("list", selected);
|
||||
result.put("button", selected);
|
||||
} else {
|
||||
// Mirror the selected array from multi choice for consistency.
|
||||
JSONArray selected = new JSONArray();
|
||||
selected.put(which);
|
||||
result.put("list", selected);
|
||||
// Make the button be the index of the select item.
|
||||
result.put("button", which);
|
||||
}
|
||||
} catch(JSONException ex) { }
|
||||
|
@ -229,12 +222,12 @@ public class Prompt implements OnClickListener, OnCancelListener, OnItemClickLis
|
|||
JSONObject ret = new JSONObject();
|
||||
try {
|
||||
ListView list = mDialog.getListView();
|
||||
addButtonResult(ret, which);
|
||||
addInputValues(ret);
|
||||
|
||||
if (list != null || mSelected != null) {
|
||||
addListResult(ret, which);
|
||||
} else {
|
||||
addButtonResult(ret, which);
|
||||
}
|
||||
addInputValues(ret);
|
||||
} catch(Exception ex) {
|
||||
Log.i(LOGTAG, "Error building return: " + ex);
|
||||
}
|
||||
|
|
|
@ -37,25 +37,32 @@ var SelectHelper = {
|
|||
}
|
||||
|
||||
p.show((function(data) {
|
||||
let selected = data.list;
|
||||
let selected = data.button;
|
||||
if (selected == -1)
|
||||
return;
|
||||
|
||||
if (aElement instanceof Ci.nsIDOMXULMenuListElement) {
|
||||
if (aElement.selectedIndex != selected[0]) {
|
||||
aElement.selectedIndex = selected[0];
|
||||
if (aElement.selectedIndex != selected) {
|
||||
aElement.selectedIndex = selected;
|
||||
this.fireOnCommand(aElement);
|
||||
}
|
||||
} else if (aElement instanceof HTMLSelectElement) {
|
||||
let changed = false;
|
||||
if (!Array.isArray(selected)) {
|
||||
let temp = [];
|
||||
for (let i = 0; i <= list.length; i++) {
|
||||
temp[i] = (i == selected);
|
||||
}
|
||||
selected = temp;
|
||||
}
|
||||
|
||||
let i = 0;
|
||||
this.forOptions(aElement, function(aNode) {
|
||||
if (aNode.selected == (selected.indexOf(i) == -1)) {
|
||||
if (aNode.selected != selected[i]) {
|
||||
changed = true;
|
||||
aNode.selected = false;
|
||||
} else if (!aNode.selected == (selected.indexOf(i) != -1)) {
|
||||
changed = true;
|
||||
aNode.selected = true;
|
||||
aNode.selected = selected[i];
|
||||
}
|
||||
i++;
|
||||
i++
|
||||
});
|
||||
|
||||
if (changed)
|
||||
|
|
Загрузка…
Ссылка в новой задаче