Bug 1365395 - Resetting select should reset option dirtiness too. r=smaug

Also added a extra flag NO_RESELECT, to avoid selecting the same option (with
default value false) again after setting it to its default value, and later no
way of deselecting it because it's dirtiness is set to false already.

MozReview-Commit-ID: L35sBMWwi3m
This commit is contained in:
Jessica Jong
2017-05-18 02:44:00 -04:00
parent 4e27fc2a50
commit c78753cd91
3 changed files with 13 additions and 3 deletions

View File

@@ -1072,7 +1072,7 @@ HTMLSelectElement::SetOptionsSelectedByIndex(int32_t aStartIndex,
}
// Make sure something is selected unless we were set to -1 (none)
if (optionsDeselected && aStartIndex != -1) {
if (optionsDeselected && aStartIndex != -1 && !(aOptionsMask & NO_RESELECT)) {
optionsSelected =
CheckSelectSomething(aOptionsMask & NOTIFY) || optionsSelected;
}
@@ -1646,13 +1646,14 @@ HTMLSelectElement::Reset()
// Reset the option to its default value
//
uint32_t mask = SET_DISABLED | NOTIFY;
uint32_t mask = SET_DISABLED | NOTIFY | NO_RESELECT;
if (option->DefaultSelected()) {
mask |= IS_SELECTED;
numSelected++;
}
SetOptionsSelectedByIndex(i, i, mask);
option->SetSelectedChanged(false);
}
}