Bug 1005268 - Remove "datetime" UI from Fennec and fix capitalization issue r=jchen

`<input type=datetime>` was dropped from the spec many years ago,
and is not supported by the platform. To JS code, it looks like a
regular text input box.

With removed support for "datetime" inputs, we can also fix a bug in the
InputWidgetHelper. Due to the use of getAttribute, if the attribute
value was capitalized, then the special date/time picker UI would not be
shown. This is corrected by using the "type" property instead.

I verified on Android Nougat that all other input types (date,
datetime-local, week, month, time) still work as intended.

Depends on D8668

Differential Revision: https://phabricator.services.mozilla.com/D8666

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Rob Wu 2018-10-16 15:57:26 +00:00
Родитель 273436ab20
Коммит b72d2fe05f
3 изменённых файлов: 5 добавлений и 14 удалений

Просмотреть файл

@ -178,7 +178,6 @@ public abstract class PromptInput {
"week", "week",
"time", "time",
"datetime-local", "datetime-local",
"datetime",
"month" "month"
}; };
@ -241,7 +240,7 @@ public abstract class PromptInput {
input.setCurrentHour(calendar.get(GregorianCalendar.HOUR_OF_DAY)); input.setCurrentHour(calendar.get(GregorianCalendar.HOUR_OF_DAY));
input.setCurrentMinute(calendar.get(GregorianCalendar.MINUTE)); input.setCurrentMinute(calendar.get(GregorianCalendar.MINUTE));
mView = (View)input; mView = (View)input;
} else if (mType.equals("datetime-local") || mType.equals("datetime")) { } else if (mType.equals("datetime-local")) {
DateTimePicker input = new DateTimePicker(context, "yyyy-MM-dd'T'HH:mm:ss", DateTimePicker input = new DateTimePicker(context, "yyyy-MM-dd'T'HH:mm:ss",
formatDateTimeSeconds(mValue), formatDateTimeSeconds(mValue),
mSecondEnabled ? DateTimePicker.PickersState.DATETIME_WITH_SECOND : DateTimePicker.PickersState.DATETIME, mSecondEnabled ? DateTimePicker.PickersState.DATETIME_WITH_SECOND : DateTimePicker.PickersState.DATETIME,
@ -267,9 +266,6 @@ public abstract class PromptInput {
// Reformat the datetime value so that it can be parsed by // Reformat the datetime value so that it can be parsed by
// SimpleDateFormat ending with "HH:mm:ss". // SimpleDateFormat ending with "HH:mm:ss".
// datetime may contain a 'Z' at the end.
dateString = dateString.replace("Z", "");
int i = dateString.indexOf(":"); // Separator in "HH:mm". int i = dateString.indexOf(":"); // Separator in "HH:mm".
if (i == -1) { if (i == -1) {
// Unparseable input. // Unparseable input.
@ -319,10 +315,6 @@ public abstract class PromptInput {
return formatDateString("yyyy-MM-dd'T'HH:mm:ss", calendar); return formatDateString("yyyy-MM-dd'T'HH:mm:ss", calendar);
} }
return formatDateString("yyyy-MM-dd'T'HH:mm", calendar); return formatDateString("yyyy-MM-dd'T'HH:mm", calendar);
} else if (mType.equals("datetime")) {
calendar.set(GregorianCalendar.ZONE_OFFSET, 0);
calendar.setTimeInMillis(dp.getTimeInMillis());
return formatDateString("yyyy-MM-dd'T'HH:mm'Z'", calendar);
} else if (mType.equals("month")) { } else if (mType.equals("month")) {
return formatDateString("yyyy-MM", calendar); return formatDateString("yyyy-MM", calendar);
} }

Просмотреть файл

@ -344,7 +344,6 @@ selectHelper.closeMultipleSelectDialog=Done
#Input widgets UI #Input widgets UI
inputWidgetHelper.date=Pick a date inputWidgetHelper.date=Pick a date
inputWidgetHelper.datetime=Pick a date and a time
inputWidgetHelper.datetime-local=Pick a date and a time inputWidgetHelper.datetime-local=Pick a date and a time
inputWidgetHelper.time=Pick a time inputWidgetHelper.time=Pick a time
inputWidgetHelper.week=Pick a week inputWidgetHelper.week=Pick a week

Просмотреть файл

@ -39,10 +39,10 @@ var InputWidgetHelper = {
}, },
show: function(aElement) { show: function(aElement) {
let type = aElement.getAttribute("type"); let type = aElement.type;
new Prompt({ new Prompt({
window: aElement.ownerGlobal, window: aElement.ownerGlobal,
title: this.strings().GetStringFromName("inputWidgetHelper." + aElement.getAttribute("type")), title: this.strings().GetStringFromName("inputWidgetHelper." + type),
buttons: [ buttons: [
this.strings().GetStringFromName("inputWidgetHelper.set"), this.strings().GetStringFromName("inputWidgetHelper.set"),
this.strings().GetStringFromName("inputWidgetHelper.clear"), this.strings().GetStringFromName("inputWidgetHelper.clear"),
@ -85,8 +85,8 @@ var InputWidgetHelper = {
if (!(aElement instanceof win.HTMLInputElement)) if (!(aElement instanceof win.HTMLInputElement))
return false; return false;
let type = aElement.getAttribute("type"); let type = aElement.type;
if (type == "date" || type == "datetime" || type == "datetime-local" || if (type == "date" || type == "datetime-local" ||
type == "week" || type == "month" || type == "time") { type == "week" || type == "month" || type == "time") {
return true; return true;
} }