Bug 1681240 - Make TextControlState::SetValueFlags an enum class r=saschanaz

Using integer as a bit field may cause simple mistake and may not be easy
to read, and we have `EnumSet` class which can treat an `enum class` as
a bit flags so that we should make it an `enum class` and use it with the
`EnumSet` class.

Differential Revision: https://phabricator.services.mozilla.com/D99172
This commit is contained in:
Masayuki Nakano
2020-12-09 23:34:28 +00:00
parent 29715b8fd2
commit fbba4fb0ed
9 changed files with 198 additions and 148 deletions

View File

@@ -117,6 +117,8 @@ class HTMLInputElement final : public TextControlElement,
using nsGenericHTMLFormElementWithState::GetForm;
using nsGenericHTMLFormElementWithState::GetFormAction;
using nsIConstraintValidation::GetValidationMessage;
using ValueSetterOption = TextControlState::ValueSetterOption;
using ValueSetterOptions = TextControlState::ValueSetterOptions;
enum class FromClone { no, yes };
@@ -914,15 +916,14 @@ class HTMLInputElement final : public TextControlElement,
* @param aValue String to set.
* @param aOldValue Previous value before setting aValue.
If previous value is unknown, aOldValue can be nullptr.
* @param aFlags See TextControlState::SetValueFlags.
* @param aOptions See TextControlState::ValueSetterOption.
*/
MOZ_CAN_RUN_SCRIPT
nsresult SetValueInternal(const nsAString& aValue, const nsAString* aOldValue,
uint32_t aFlags);
MOZ_CAN_RUN_SCRIPT
nsresult SetValueInternal(const nsAString& aValue, uint32_t aFlags) {
return SetValueInternal(aValue, nullptr, aFlags);
MOZ_CAN_RUN_SCRIPT nsresult
SetValueInternal(const nsAString& aValue, const nsAString* aOldValue,
const ValueSetterOptions& aOptions);
MOZ_CAN_RUN_SCRIPT nsresult SetValueInternal(
const nsAString& aValue, const ValueSetterOptions& aOptions) {
return SetValueInternal(aValue, nullptr, aOptions);
}
// Generic getter for the value that doesn't do experimental control type