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:
@@ -44,6 +44,11 @@ public:
|
||||
bool Selected() const;
|
||||
bool DefaultSelected() const;
|
||||
|
||||
void SetSelectedChanged(bool aValue)
|
||||
{
|
||||
mSelectedChanged = aValue;
|
||||
}
|
||||
|
||||
virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute,
|
||||
int32_t aModType) const override;
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -134,12 +134,16 @@ public:
|
||||
* (for JavaScript)
|
||||
*
|
||||
* NOTIFY whether to notify frames and such
|
||||
*
|
||||
* NO_RESELECT no need to select something after an option is deselected
|
||||
* (for reset)
|
||||
*/
|
||||
enum OptionType {
|
||||
IS_SELECTED = 1 << 0,
|
||||
CLEAR_ALL = 1 << 1,
|
||||
SET_DISABLED = 1 << 2,
|
||||
NOTIFY = 1 << 3
|
||||
NOTIFY = 1 << 3,
|
||||
NO_RESELECT = 1 << 4
|
||||
};
|
||||
|
||||
using nsIConstraintValidation::GetValidationMessage;
|
||||
|
||||
Reference in New Issue
Block a user