Bug 1005268 - Remove "datetime" UI from Fennec and fix capitalization issue r=jchen
authorRob Wu <rob@robwu.nl>
Tue, 16 Oct 2018 15:57:26 +0000
changeset 441484 f992e8a4e7e61a599e8007bf6dfdcb15a3b132f8
parent 441483 12fcdbe6ef8d97441fe879432bd664bf1c048ba4
child 441485 6fc4224069b26bb408ee1b835a74fe1df9c676ed
push id34866
push usershindli@mozilla.com
push dateWed, 17 Oct 2018 00:54:47 +0000
treeherdermozilla-central@d4fe026dee75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjchen
bugs1005268
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
mobile/android/base/java/org/mozilla/gecko/prompts/PromptInput.java
mobile/android/locales/en-US/chrome/browser.properties
mobile/android/modules/InputWidgetHelper.jsm
--- a/mobile/android/base/java/org/mozilla/gecko/prompts/PromptInput.java
+++ b/mobile/android/base/java/org/mozilla/gecko/prompts/PromptInput.java
@@ -173,17 +173,16 @@ public abstract class PromptInput {
     }
 
     public static class DateTimeInput extends PromptInput {
         public static final String[] INPUT_TYPES = new String[] {
             "date",
             "week",
             "time",
             "datetime-local",
-            "datetime",
             "month"
         };
 
         public DateTimeInput(GeckoBundle obj) {
             super(obj);
         }
 
         // Will use platform's DatePicker and TimePicker to let users input date and time using the fancy widgets.
@@ -236,17 +235,17 @@ public abstract class PromptInput {
                 if (!TextUtils.isEmpty(mValue)) {
                     try {
                         calendar.setTime(new SimpleDateFormat("HH:mm").parse(mValue));
                     } catch (Exception e) { }
                 }
                 input.setCurrentHour(calendar.get(GregorianCalendar.HOUR_OF_DAY));
                 input.setCurrentMinute(calendar.get(GregorianCalendar.MINUTE));
                 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",
                                                           formatDateTimeSeconds(mValue),
                                                           mSecondEnabled ? DateTimePicker.PickersState.DATETIME_WITH_SECOND : DateTimePicker.PickersState.DATETIME,
                                                           formatDateTimeSeconds(mMinValue),
                                                           formatDateTimeSeconds(mMaxValue));
                 mView = (View)input;
             } else if (mType.equals("month")) {
                 DateTimePicker input = new DateTimePicker(context, "yyyy-MM", mValue,
@@ -262,19 +261,16 @@ public abstract class PromptInput {
 
             return mView;
         }
 
         private static String formatDateTimeSeconds(String dateString) {
             // Reformat the datetime value so that it can be parsed by
             // 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".
             if (i == -1) {
                 // Unparseable input.
                 return dateString;
             }
 
             i = dateString.indexOf(":", i + 1); // Separator in "mm:ss".
             if (i == -1) {
@@ -314,20 +310,16 @@ public abstract class PromptInput {
                 calendar.setTimeInMillis(dp.getTimeInMillis());
                 if (mType.equals("week")) {
                     return formatDateString("yyyy-'W'ww", calendar);
                 } else if (mType.equals("datetime-local")) {
                     if (mSecondEnabled) {
                         return formatDateString("yyyy-MM-dd'T'HH:mm:ss", 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")) {
                     return formatDateString("yyyy-MM", calendar);
                 }
             }
             return super.getValue();
         }
     }
 
--- a/mobile/android/locales/en-US/chrome/browser.properties
+++ b/mobile/android/locales/en-US/chrome/browser.properties
@@ -339,17 +339,16 @@ contextmenu.paste=Paste
 
 contextmenu.call=Call
 
 # Select UI
 selectHelper.closeMultipleSelectDialog=Done
 
 #Input widgets UI
 inputWidgetHelper.date=Pick a date
-inputWidgetHelper.datetime=Pick a date and a time
 inputWidgetHelper.datetime-local=Pick a date and a time
 inputWidgetHelper.time=Pick a time
 inputWidgetHelper.week=Pick a week
 inputWidgetHelper.month=Pick a month
 inputWidgetHelper.cancel=Cancel
 inputWidgetHelper.set=Set
 inputWidgetHelper.clear=Clear
 
--- a/mobile/android/modules/InputWidgetHelper.jsm
+++ b/mobile/android/modules/InputWidgetHelper.jsm
@@ -34,20 +34,20 @@ var InputWidgetHelper = {
       return;
 
     this._uiBusy = true;
     this.show(aTarget);
     this._uiBusy = false;
   },
 
   show: function(aElement) {
-    let type = aElement.getAttribute("type");
+    let type = aElement.type;
     new Prompt({
       window: aElement.ownerGlobal,
-      title: this.strings().GetStringFromName("inputWidgetHelper." + aElement.getAttribute("type")),
+      title: this.strings().GetStringFromName("inputWidgetHelper." + type),
       buttons: [
         this.strings().GetStringFromName("inputWidgetHelper.set"),
         this.strings().GetStringFromName("inputWidgetHelper.clear"),
         this.strings().GetStringFromName("inputWidgetHelper.cancel")
       ],
     }).addDatePicker({
       value: aElement.value,
       type: type,
@@ -80,18 +80,18 @@ var InputWidgetHelper = {
     });
   },
 
   hasInputWidget: function(aElement) {
     let win = aElement.ownerGlobal;
     if (!(aElement instanceof win.HTMLInputElement))
       return false;
 
-    let type = aElement.getAttribute("type");
-    if (type == "date" || type == "datetime" || type == "datetime-local" ||
+    let type = aElement.type;
+    if (type == "date" || type == "datetime-local" ||
         type == "week" || type == "month" || type == "time") {
       return true;
     }
 
     return false;
   },
 
   fireOnChange: function(aElement) {