Bug 1278738 - Add 'week' to the list of valid types attributes for <input>. r=smaug

This commit is contained in:
Jessica Jong
2016-08-15 23:15:00 -04:00
parent 5e03ee3d5c
commit e854e57b5b
32 changed files with 187 additions and 65 deletions

View File

@@ -177,6 +177,7 @@ static const nsAttrValue::EnumTable kInputTypeTable[] = {
{ "text", NS_FORM_INPUT_TEXT },
{ "time", NS_FORM_INPUT_TIME },
{ "url", NS_FORM_INPUT_URL },
{ "week", NS_FORM_INPUT_WEEK },
{ 0 }
};
@@ -2122,7 +2123,8 @@ HTMLInputElement::ConvertNumberToString(Decimal aValue,
Nullable<Date>
HTMLInputElement::GetValueAsDate(ErrorResult& aRv)
{
if (!IsDateTimeInputType(mType)) {
// TODO: this is temporary until bug 888316 is fixed.
if (!IsDateTimeInputType(mType) || mType == NS_FORM_INPUT_WEEK) {
return Nullable<Date>();
}
@@ -2176,7 +2178,8 @@ HTMLInputElement::GetValueAsDate(ErrorResult& aRv)
void
HTMLInputElement::SetValueAsDate(Nullable<Date> aDate, ErrorResult& aRv)
{
if (!IsDateTimeInputType(mType)) {
// TODO: this is temporary until bug 888316 is fixed.
if (!IsDateTimeInputType(mType) || mType == NS_FORM_INPUT_WEEK) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
}
@@ -2424,9 +2427,10 @@ HTMLInputElement::IsExperimentalMobileType(uint8_t aType)
bool
HTMLInputElement::IsDateTimeInputType(uint8_t aType)
{
return aType == NS_FORM_INPUT_DATE || aType == NS_FORM_INPUT_TIME ||
aType == NS_FORM_INPUT_MONTH;
return aType == NS_FORM_INPUT_DATE ||
aType == NS_FORM_INPUT_TIME ||
aType == NS_FORM_INPUT_MONTH ||
aType == NS_FORM_INPUT_WEEK;
}
NS_IMETHODIMP
@@ -5258,7 +5262,8 @@ IsDateTimeEnabled(int32_t aNewType)
(aNewType == NS_FORM_INPUT_TIME &&
(Preferences::GetBool("dom.forms.datetime", false) ||
Preferences::GetBool("dom.experimental_forms", false))) ||
(aNewType == NS_FORM_INPUT_MONTH &&
((aNewType == NS_FORM_INPUT_MONTH ||
aNewType == NS_FORM_INPUT_WEEK) &&
Preferences::GetBool("dom.forms.datetime", false));
}
@@ -6744,6 +6749,7 @@ HTMLInputElement::GetValueMode() const
case NS_FORM_INPUT_TIME:
case NS_FORM_INPUT_COLOR:
case NS_FORM_INPUT_MONTH:
case NS_FORM_INPUT_WEEK:
return VALUE_MODE_VALUE;
default:
NS_NOTYETIMPLEMENTED("Unexpected input type in GetValueMode()");
@@ -6790,6 +6796,7 @@ HTMLInputElement::DoesReadOnlyApply() const
case NS_FORM_INPUT_DATE:
case NS_FORM_INPUT_TIME:
case NS_FORM_INPUT_MONTH:
case NS_FORM_INPUT_WEEK:
return true;
default:
NS_NOTYETIMPLEMENTED("Unexpected input type in DoesReadOnlyApply()");
@@ -6828,6 +6835,7 @@ HTMLInputElement::DoesRequiredApply() const
case NS_FORM_INPUT_DATE:
case NS_FORM_INPUT_TIME:
case NS_FORM_INPUT_MONTH:
case NS_FORM_INPUT_WEEK:
return true;
default:
NS_NOTYETIMPLEMENTED("Unexpected input type in DoesRequiredApply()");
@@ -6870,6 +6878,7 @@ HTMLInputElement::DoesMinMaxApply() const
case NS_FORM_INPUT_TIME:
case NS_FORM_INPUT_RANGE:
case NS_FORM_INPUT_MONTH:
case NS_FORM_INPUT_WEEK:
// TODO:
// All date/time types.
return true;
@@ -6918,6 +6927,7 @@ HTMLInputElement::DoesAutocompleteApply() const
case NS_FORM_INPUT_RANGE:
case NS_FORM_INPUT_COLOR:
case NS_FORM_INPUT_MONTH:
case NS_FORM_INPUT_WEEK:
return true;
#ifdef DEBUG
case NS_FORM_INPUT_RESET:
@@ -7101,7 +7111,8 @@ HTMLInputElement::HasPatternMismatch() const
bool
HTMLInputElement::IsRangeOverflow() const
{
if (!DoesMinMaxApply()) {
// TODO: this is temporary until bug 888316 is fixed.
if (!DoesMinMaxApply() || mType == NS_FORM_INPUT_WEEK) {
return false;
}
@@ -7121,7 +7132,8 @@ HTMLInputElement::IsRangeOverflow() const
bool
HTMLInputElement::IsRangeUnderflow() const
{
if (!DoesMinMaxApply()) {
// TODO: this is temporary until bug 888316 is fixed.
if (!DoesMinMaxApply() || mType == NS_FORM_INPUT_WEEK) {
return false;
}
@@ -8092,7 +8104,8 @@ HTMLInputElement::UpdateHasRange()
mHasRange = false;
if (!DoesMinMaxApply()) {
// TODO: this is temporary until bug 888316 is fixed.
if (!DoesMinMaxApply() || mType == NS_FORM_INPUT_WEEK) {
return;
}