INPUT_MULTIPLE_FIELDS_UI: Incomplete datetime format should fallback to default

https://bugs.webkit.org/show_bug.cgi?id=113005

Patch by Kunihiko Sakamoto <ksakamoto@chromium.org> on 2013-03-22
Reviewed by Kent Tamura.

Source/WebCore:

Use fallback format when datetime format from locale is not complete.

Tests: fast/forms/date-multiple-fields/date-multiple-fields-fallback-format.html
       fast/forms/datetime-multiple-fields/datetime-multiple-fields-fallback-format.html
       fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-fallback-format.html
       fast/forms/month-multiple-fields/month-multiple-fields-fallback-format.html
       fast/forms/time-multiple-fields/time-multiple-fields-fallback-format.html
       fast/forms/week-multiple-fields/week-multiple-fields-fallback-format.html

* html/BaseMultipleFieldsDateAndTimeInputType.cpp:
(DateTimeFormatValidator): A helper class that parses datetime format and tests existence of fields.
(WebCore::DateTimeFormatValidator::DateTimeFormatValidator):
(WebCore::DateTimeFormatValidator::visitField):
(WebCore::DateTimeFormatValidator::validateFormat): Parses datetime format and validates by calling BaseMultipleFieldsDateAndTimeInputType::isValidFormat.
(WebCore::BaseMultipleFieldsDateAndTimeInputType::updateInnerTextValue): Checks if dateTimeFormat is valid, and uses fallback format if not.
* html/BaseMultipleFieldsDateAndTimeInputType.h:
(BaseMultipleFieldsDateAndTimeInputType): Declare isValidFormat.
* html/DateInputType.cpp:
(WebCore::DateInputType::isValidFormat): Added.
* html/DateInputType.h:
(DateInputType):
* html/DateTimeInputType.cpp:
(WebCore::DateTimeInputType::isValidFormat): Added.
* html/DateTimeInputType.h:
(DateTimeInputType):
* html/DateTimeLocalInputType.cpp:
(WebCore::DateTimeLocalInputType::isValidFormat): Added.
* html/DateTimeLocalInputType.h:
(DateTimeLocalInputType):
* html/MonthInputType.cpp:
(WebCore::MonthInputType::isValidFormat): Added.
* html/MonthInputType.h:
(MonthInputType):
* html/TimeInputType.cpp:
(WebCore::TimeInputType::isValidFormat): Added.
* html/TimeInputType.h:
(TimeInputType):
* html/WeekInputType.cpp:
(WebCore::WeekInputType::isValidFormat): Added.
* html/WeekInputType.h:
(WeekInputType):

LayoutTests:

* fast/forms/date-multiple-fields/date-multiple-fields-fallback-format-expected.txt: Added.
* fast/forms/date-multiple-fields/date-multiple-fields-fallback-format.html: Added.
* fast/forms/datetime-multiple-fields/datetime-multiple-fields-fallback-format-expected.txt: Added.
* fast/forms/datetime-multiple-fields/datetime-multiple-fields-fallback-format.html: Added.
* fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-fallback-format-expected.txt: Added.
* fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-fallback-format.html: Added.
* fast/forms/month-multiple-fields/month-multiple-fields-fallback-format-expected.txt: Added.
* fast/forms/month-multiple-fields/month-multiple-fields-fallback-format.html: Added.
* fast/forms/time-multiple-fields/time-multiple-fields-fallback-format-expected.txt: Added.
* fast/forms/time-multiple-fields/time-multiple-fields-fallback-format.html: Added.
* fast/forms/week-multiple-fields/week-multiple-fields-fallback-format-expected.txt: Added.
* fast/forms/week-multiple-fields/week-multiple-fields-fallback-format.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@146584 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 321d20ac
2013-03-22 Kunihiko Sakamoto <ksakamoto@chromium.org>
INPUT_MULTIPLE_FIELDS_UI: Incomplete datetime format should fallback to default
https://bugs.webkit.org/show_bug.cgi?id=113005
Reviewed by Kent Tamura.
* fast/forms/date-multiple-fields/date-multiple-fields-fallback-format-expected.txt: Added.
* fast/forms/date-multiple-fields/date-multiple-fields-fallback-format.html: Added.
* fast/forms/datetime-multiple-fields/datetime-multiple-fields-fallback-format-expected.txt: Added.
* fast/forms/datetime-multiple-fields/datetime-multiple-fields-fallback-format.html: Added.
* fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-fallback-format-expected.txt: Added.
* fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-fallback-format.html: Added.
* fast/forms/month-multiple-fields/month-multiple-fields-fallback-format-expected.txt: Added.
* fast/forms/month-multiple-fields/month-multiple-fields-fallback-format.html: Added.
* fast/forms/time-multiple-fields/time-multiple-fields-fallback-format-expected.txt: Added.
* fast/forms/time-multiple-fields/time-multiple-fields-fallback-format.html: Added.
* fast/forms/week-multiple-fields/week-multiple-fields-fallback-format-expected.txt: Added.
* fast/forms/week-multiple-fields/week-multiple-fields-fallback-format.html: Added.
2013-03-22 Hajime Morrita <morrita@google.com>
Custom Elements: "readyCallback" lifecycle callback should be called.
Checks incomplete datetime formats are rejected.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Valid format
PASS getUserAgentShadowTextContent(input) is "31-07-1999"
Invalid format, fallback to yyyy-MM-dd
PASS getUserAgentShadowTextContent(input) is "1999-07-31"
PASS getUserAgentShadowTextContent(input) is "1999-07-31"
PASS getUserAgentShadowTextContent(input) is "1999-07-31"
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<script src="../../js/resources/js-test-pre.js"></script>
<script src="../resources/common.js"></script>
</head>
<body>
<script>
description('Checks incomplete datetime formats are rejected.');
var input = document.createElement('input');
input.type = 'date';
document.body.appendChild(input);
function setDateTimeFormat(pattern) {
var value = input.value;
getElementByPseudoId(internals.youngestShadowRoot(input), '-webkit-datetime-edit').setAttribute('pattern', pattern);
input.value = ''; // Updates the element for new format
input.value = value;
}
input.value = '1999-07-31';
debug('Valid format');
setDateTimeFormat("dd-MM-yyyy");
shouldBeEqualToString('getUserAgentShadowTextContent(input)', '31-07-1999');
debug("Invalid format, fallback to yyyy-MM-dd");
setDateTimeFormat('yyyy-MM');
shouldBeEqualToString('getUserAgentShadowTextContent(input)', '1999-07-31');
setDateTimeFormat('MM/dd');
shouldBeEqualToString('getUserAgentShadowTextContent(input)', '1999-07-31');
setDateTimeFormat('dd-yyyy');
shouldBeEqualToString('getUserAgentShadowTextContent(input)', '1999-07-31');
</script>
<script src="../../js/resources/js-test-post.js"></script>
</body>
</html>
Checks incomplete datetime formats are rejected.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Valid format
PASS getUserAgentShadowTextContent(input) is "1999-07-31 11:59 PM"
Invalid format, fallback to yyyy-MM-dd'T'HH:mm
PASS getUserAgentShadowTextContent(input) is "1999-07-31T23:59"
PASS getUserAgentShadowTextContent(input) is "1999-07-31T23:59"
PASS getUserAgentShadowTextContent(input) is "1999-07-31T23:59"
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<script src="../../js/resources/js-test-pre.js"></script>
<script src="../resources/common.js"></script>
</head>
<body>
<script>
description('Checks incomplete datetime formats are rejected.');
var input = document.createElement('input');
input.type = 'datetime-local';
document.body.appendChild(input);
function setDateTimeFormat(pattern) {
var value = input.value;
getElementByPseudoId(internals.youngestShadowRoot(input), '-webkit-datetime-edit').setAttribute('pattern', pattern);
input.value = ''; // Updates the element for new format
input.value = value;
}
input.value = '1999-07-31T23:59';
debug('Valid format');
setDateTimeFormat("yyyy-MM-dd hh:mm a");
shouldBeEqualToString('getUserAgentShadowTextContent(input)', '1999-07-31 11:59 PM');
debug("Invalid format, fallback to yyyy-MM-dd'T'HH:mm");
setDateTimeFormat('yyyy-MM-dd');
shouldBeEqualToString('getUserAgentShadowTextContent(input)', '1999-07-31T23:59');
setDateTimeFormat('HH:mm');
shouldBeEqualToString('getUserAgentShadowTextContent(input)', '1999-07-31T23:59');
setDateTimeFormat("yyyy-MM-dd'T'hh:mm");
shouldBeEqualToString('getUserAgentShadowTextContent(input)', '1999-07-31T23:59');
</script>
<script src="../../js/resources/js-test-post.js"></script>
</body>
</html>
Checks incomplete datetime formats are rejected.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Valid format
PASS getUserAgentShadowTextContent(input) is "1999-07-31 11:59 PM"
Invalid format, fallback to yyyy-MM-dd'T'HH:mm
PASS getUserAgentShadowTextContent(input) is "1999-07-31T23:59"
PASS getUserAgentShadowTextContent(input) is "1999-07-31T23:59"
PASS getUserAgentShadowTextContent(input) is "1999-07-31T23:59"
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<script src="../../js/resources/js-test-pre.js"></script>
<script src="../resources/common.js"></script>
</head>
<body>
<script>
description('Checks incomplete datetime formats are rejected.');
var input = document.createElement('input');
input.type = 'datetime-local';
document.body.appendChild(input);
function setDateTimeFormat(pattern) {
var value = input.value;
getElementByPseudoId(internals.youngestShadowRoot(input), '-webkit-datetime-edit').setAttribute('pattern', pattern);
input.value = ''; // Updates the element for new format
input.value = value;
}
input.value = '1999-07-31T23:59';
debug('Valid format');
setDateTimeFormat("yyyy-MM-dd hh:mm a");
shouldBeEqualToString('getUserAgentShadowTextContent(input)', '1999-07-31 11:59 PM');
debug("Invalid format, fallback to yyyy-MM-dd'T'HH:mm");
setDateTimeFormat('yyyy-MM-dd');
shouldBeEqualToString('getUserAgentShadowTextContent(input)', '1999-07-31T23:59');
setDateTimeFormat('HH:mm');
shouldBeEqualToString('getUserAgentShadowTextContent(input)', '1999-07-31T23:59');
setDateTimeFormat("yyyy-MM-dd'T'hh:mm");
shouldBeEqualToString('getUserAgentShadowTextContent(input)', '1999-07-31T23:59');
</script>
<script src="../../js/resources/js-test-post.js"></script>
</body>
</html>
Checks incomplete datetime formats are rejected.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Valid format
PASS getUserAgentShadowTextContent(input) is "07-1999"
Invalid format, fallback to yyyy-MM
PASS getUserAgentShadowTextContent(input) is "1999-07"
PASS getUserAgentShadowTextContent(input) is "1999-07"
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<script src="../../js/resources/js-test-pre.js"></script>
<script src="../resources/common.js"></script>
</head>
<body>
<script>
description('Checks incomplete datetime formats are rejected.');
var input = document.createElement('input');
input.type = 'month';
document.body.appendChild(input);
function setDateTimeFormat(pattern) {
var value = input.value;
getElementByPseudoId(internals.youngestShadowRoot(input), '-webkit-datetime-edit').setAttribute('pattern', pattern);
input.value = ''; // Updates the element for new format
input.value = value;
}
input.value = '1999-07';
debug('Valid format');
setDateTimeFormat('MM-yyyy');
shouldBeEqualToString('getUserAgentShadowTextContent(input)', '07-1999');
debug('Invalid format, fallback to yyyy-MM');
setDateTimeFormat('mm-yyyy');
shouldBeEqualToString('getUserAgentShadowTextContent(input)', '1999-07');
setDateTimeFormat('M');
shouldBeEqualToString('getUserAgentShadowTextContent(input)', '1999-07');
</script>
<script src="../../js/resources/js-test-post.js"></script>
</body>
</html>
Checks incomplete datetime formats are rejected.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Valid format
PASS getUserAgentShadowTextContent(input) is "01.234:59:11 PM"
PASS getUserAgentShadowTextContent(input) is "01.234:59:23"
PASS getUserAgentShadowTextContent(input) is "01.234:59:23 PM"
Invalid format, fallback to HH:mm:ss
PASS getUserAgentShadowTextContent(input) is "23:59:01.234"
PASS getUserAgentShadowTextContent(input) is "23:59:01.234"
PASS getUserAgentShadowTextContent(input) is "23:59:01.234"
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<script src="../../js/resources/js-test-pre.js"></script>
<script src="../resources/common.js"></script>
</head>
<body>
<script>
description('Checks incomplete datetime formats are rejected.');
var input = document.createElement('input');
input.type = 'time';
document.body.appendChild(input);
function setDateTimeFormat(pattern) {
var value = input.value;
getElementByPseudoId(internals.youngestShadowRoot(input), '-webkit-datetime-edit').setAttribute('pattern', pattern);
input.value = ''; // Updates the element for new format
input.value = value;
}
input.value = '23:59:01.234';
debug('Valid format');
setDateTimeFormat('ss:mm:hh a');
shouldBeEqualToString('getUserAgentShadowTextContent(input)', '01.234:59:11 PM');
setDateTimeFormat('ss:mm:HH');
shouldBeEqualToString('getUserAgentShadowTextContent(input)', '01.234:59:23');
setDateTimeFormat('ss:mm:HH a');
shouldBeEqualToString('getUserAgentShadowTextContent(input)', '01.234:59:23 PM');
debug('Invalid format, fallback to HH:mm:ss');
setDateTimeFormat('HH');
shouldBeEqualToString('getUserAgentShadowTextContent(input)', '23:59:01.234');
setDateTimeFormat('mm:ss');
shouldBeEqualToString('getUserAgentShadowTextContent(input)', '23:59:01.234');
setDateTimeFormat('hh:mm:ss');
shouldBeEqualToString('getUserAgentShadowTextContent(input)', '23:59:01.234');
</script>
<script src="../../js/resources/js-test-post.js"></script>
</body>
</html>
Checks incomplete datetime formats are rejected.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Valid format
PASS getUserAgentShadowTextContent(input) is "Week09 1999"
Invalid format, fallback to yyyy-'W'ww
PASS getUserAgentShadowTextContent(input) is "1999-W09"
PASS getUserAgentShadowTextContent(input) is "1999-W09"
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<script src="../../js/resources/js-test-pre.js"></script>
<script src="../resources/common.js"></script>
</head>
<body>
<script>
description('Checks incomplete datetime formats are rejected.');
var input = document.createElement('input');
input.type = 'week';
document.body.appendChild(input);
function setDateTimeFormat(pattern) {
var value = input.value;
getElementByPseudoId(internals.youngestShadowRoot(input), '-webkit-datetime-edit').setAttribute('pattern', pattern);
input.value = ''; // Updates the element for new format
input.value = value;
}
input.value = '1999-W09';
debug('Valid format');
setDateTimeFormat("'Week'ww yyyy");
shouldBeEqualToString('getUserAgentShadowTextContent(input)', 'Week09 1999');
debug("Invalid format, fallback to yyyy-'W'ww");
setDateTimeFormat('ww');
shouldBeEqualToString('getUserAgentShadowTextContent(input)', '1999-W09');
setDateTimeFormat('yyyy');
shouldBeEqualToString('getUserAgentShadowTextContent(input)', '1999-W09');
</script>
<script src="../../js/resources/js-test-post.js"></script>
</body>
</html>
2013-03-22 Kunihiko Sakamoto <ksakamoto@chromium.org>
INPUT_MULTIPLE_FIELDS_UI: Incomplete datetime format should fallback to default
https://bugs.webkit.org/show_bug.cgi?id=113005
Reviewed by Kent Tamura.
Use fallback format when datetime format from locale is not complete.
Tests: fast/forms/date-multiple-fields/date-multiple-fields-fallback-format.html
fast/forms/datetime-multiple-fields/datetime-multiple-fields-fallback-format.html
fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-fallback-format.html
fast/forms/month-multiple-fields/month-multiple-fields-fallback-format.html
fast/forms/time-multiple-fields/time-multiple-fields-fallback-format.html
fast/forms/week-multiple-fields/week-multiple-fields-fallback-format.html
* html/BaseMultipleFieldsDateAndTimeInputType.cpp:
(DateTimeFormatValidator): A helper class that parses datetime format and tests existence of fields.
(WebCore::DateTimeFormatValidator::DateTimeFormatValidator):
(WebCore::DateTimeFormatValidator::visitField):
(WebCore::DateTimeFormatValidator::validateFormat): Parses datetime format and validates by calling BaseMultipleFieldsDateAndTimeInputType::isValidFormat.
(WebCore::BaseMultipleFieldsDateAndTimeInputType::updateInnerTextValue): Checks if dateTimeFormat is valid, and uses fallback format if not.
* html/BaseMultipleFieldsDateAndTimeInputType.h:
(BaseMultipleFieldsDateAndTimeInputType): Declare isValidFormat.
* html/DateInputType.cpp:
(WebCore::DateInputType::isValidFormat): Added.
* html/DateInputType.h:
(DateInputType):
* html/DateTimeInputType.cpp:
(WebCore::DateTimeInputType::isValidFormat): Added.
* html/DateTimeInputType.h:
(DateTimeInputType):
* html/DateTimeLocalInputType.cpp:
(WebCore::DateTimeLocalInputType::isValidFormat): Added.
* html/DateTimeLocalInputType.h:
(DateTimeLocalInputType):
* html/MonthInputType.cpp:
(WebCore::MonthInputType::isValidFormat): Added.
* html/MonthInputType.h:
(MonthInputType):
* html/TimeInputType.cpp:
(WebCore::TimeInputType::isValidFormat): Added.
* html/TimeInputType.h:
(TimeInputType):
* html/WeekInputType.cpp:
(WebCore::WeekInputType::isValidFormat): Added.
* html/WeekInputType.h:
(WeekInputType):
2013-03-22 Hajime Morrita <morrita@google.com>
Custom Elements: "readyCallback" lifecycle callback should be called.
......@@ -35,6 +35,7 @@
#include "CSSValueKeywords.h"
#include "DateComponents.h"
#include "DateTimeFieldsState.h"
#include "DateTimeFormat.h"
#include "ElementShadow.h"
#include "FocusController.h"
#include "FormController.h"
......@@ -53,6 +54,80 @@
namespace WebCore {
class DateTimeFormatValidator : public DateTimeFormat::TokenHandler {
public:
DateTimeFormatValidator()
: m_hasYear(false)
, m_hasMonth(false)
, m_hasWeek(false)
, m_hasDay(false)
, m_hasAMPM(false)
, m_hasHour(false)
, m_hasMinute(false)
, m_hasSecond(false) { }
virtual void visitField(DateTimeFormat::FieldType, int) OVERRIDE FINAL;
virtual void visitLiteral(const String&) OVERRIDE FINAL { }
bool validateFormat(const String& format, const BaseMultipleFieldsDateAndTimeInputType&);
private:
bool m_hasYear;
bool m_hasMonth;
bool m_hasWeek;
bool m_hasDay;
bool m_hasAMPM;
bool m_hasHour;
bool m_hasMinute;
bool m_hasSecond;
};
void DateTimeFormatValidator::visitField(DateTimeFormat::FieldType fieldType, int)
{
switch (fieldType) {
case DateTimeFormat::FieldTypeYear:
m_hasYear = true;
break;
case DateTimeFormat::FieldTypeMonth: // Fallthrough.
case DateTimeFormat::FieldTypeMonthStandAlone:
m_hasMonth = true;
break;
case DateTimeFormat::FieldTypeWeekOfYear:
m_hasWeek = true;
break;
case DateTimeFormat::FieldTypeDayOfMonth:
m_hasDay = true;
break;
case DateTimeFormat::FieldTypePeriod:
m_hasAMPM = true;
break;
case DateTimeFormat::FieldTypeHour11: // Fallthrough.
case DateTimeFormat::FieldTypeHour12:
m_hasHour = true;
break;
case DateTimeFormat::FieldTypeHour23: // Fallthrough.
case DateTimeFormat::FieldTypeHour24:
m_hasHour = true;
m_hasAMPM = true;
break;
case DateTimeFormat::FieldTypeMinute:
m_hasMinute = true;
break;
case DateTimeFormat::FieldTypeSecond:
m_hasSecond = true;
break;
default:
break;
}
}
bool DateTimeFormatValidator::validateFormat(const String& format, const BaseMultipleFieldsDateAndTimeInputType& inputType)
{
if (!DateTimeFormat::parse(format, *this))
return false;
return inputType.isValidFormat(m_hasYear, m_hasMonth, m_hasWeek, m_hasDay, m_hasAMPM, m_hasHour, m_hasMinute, m_hasSecond);
}
void BaseMultipleFieldsDateAndTimeInputType::didBlurFromControl()
{
// We don't need to call blur(). This function is called when control
......@@ -410,6 +485,9 @@ void BaseMultipleFieldsDateAndTimeInputType::updateInnerTextValue()
if (!pattern.isEmpty())
layoutParameters.dateTimeFormat = pattern;
if (!DateTimeFormatValidator().validateFormat(layoutParameters.dateTimeFormat, *this))
layoutParameters.dateTimeFormat = layoutParameters.fallbackDateTimeFormat;
if (hasValue)
m_dateTimeEditElement->setValueAsDate(layoutParameters, date);
else
......
......@@ -49,6 +49,9 @@ class BaseMultipleFieldsDateAndTimeInputType
, protected PickerIndicatorElement::PickerIndicatorOwner
, protected SpinButtonElement::SpinButtonOwner
, protected ClearButtonElement::ClearButtonOwner {
public:
virtual bool isValidFormat(bool hasYear, bool hasMonth, bool hasWeek, bool hasDay, bool hasAMPM, bool hasHour, bool hasMinute, bool hasSecond) const = 0;
protected:
BaseMultipleFieldsDateAndTimeInputType(HTMLInputElement*);
virtual ~BaseMultipleFieldsDateAndTimeInputType();
......
......@@ -126,6 +126,11 @@ void DateInputType::setupLayoutParameters(DateTimeEditElement::LayoutParameters&
layoutParameters.placeholderForMonth = placeholderForMonthField();
layoutParameters.placeholderForYear = placeholderForYearField();
}
bool DateInputType::isValidFormat(bool hasYear, bool hasMonth, bool hasWeek, bool hasDay, bool hasAMPM, bool hasHour, bool hasMinute, bool hasSecond) const
{
return hasYear && hasMonth && hasDay;
}
#endif
} // namespace WebCore
......
......@@ -64,6 +64,7 @@ private:
// BaseMultipleFieldsDateAndTimeInputType functions
virtual String formatDateTimeFieldsState(const DateTimeFieldsState&) const OVERRIDE;
virtual void setupLayoutParameters(DateTimeEditElement::LayoutParameters&, const DateComponents&) const OVERRIDE;
virtual bool isValidFormat(bool hasYear, bool hasMonth, bool hasWeek, bool hasDay, bool hasAMPM, bool hasHour, bool hasMinute, bool hasSecond) const;
#endif
};
......
......@@ -164,6 +164,11 @@ void DateTimeInputType::setupLayoutParameters(DateTimeEditElement::LayoutParamet
layoutParameters.placeholderForMonth = placeholderForMonthField();
layoutParameters.placeholderForYear = placeholderForYearField();
}
bool DateTimeInputType::isValidFormat(bool hasYear, bool hasMonth, bool hasWeek, bool hasDay, bool hasAMPM, bool hasHour, bool hasMinute, bool hasSecond) const
{
return hasYear && hasMonth && hasDay && hasAMPM && hasHour && hasMinute;
}
#endif
String DateTimeInputType::sanitizeValue(const String& proposedValue) const
......
......@@ -64,6 +64,7 @@ private:
// BaseMultipleFieldsDateAndTimeInputType functions
virtual String formatDateTimeFieldsState(const DateTimeFieldsState&) const OVERRIDE FINAL;
virtual void setupLayoutParameters(DateTimeEditElement::LayoutParameters&, const DateComponents&) const OVERRIDE FINAL;
virtual bool isValidFormat(bool hasYear, bool hasMonth, bool hasWeek, bool hasDay, bool hasAMPM, bool hasHour, bool hasMinute, bool hasSecond) const;
#endif
};
......
......@@ -170,6 +170,11 @@ void DateTimeLocalInputType::setupLayoutParameters(DateTimeEditElement::LayoutPa
layoutParameters.placeholderForMonth = placeholderForMonthField();
layoutParameters.placeholderForYear = placeholderForYearField();
}
bool DateTimeLocalInputType::isValidFormat(bool hasYear, bool hasMonth, bool hasWeek, bool hasDay, bool hasAMPM, bool hasHour, bool hasMinute, bool hasSecond) const
{
return hasYear && hasMonth && hasDay && hasAMPM && hasHour && hasMinute;
}
#endif
} // namespace WebCore
......
......@@ -63,6 +63,7 @@ private:
// BaseMultipleFieldsDateAndTimeInputType functions
virtual String formatDateTimeFieldsState(const DateTimeFieldsState&) const OVERRIDE FINAL;
virtual void setupLayoutParameters(DateTimeEditElement::LayoutParameters&, const DateComponents&) const OVERRIDE FINAL;
virtual bool isValidFormat(bool hasYear, bool hasMonth, bool hasWeek, bool hasDay, bool hasAMPM, bool hasHour, bool hasMinute, bool hasSecond) const;
#endif
};
......
......@@ -167,6 +167,11 @@ void MonthInputType::setupLayoutParameters(DateTimeEditElement::LayoutParameters
layoutParameters.placeholderForMonth = "--";
layoutParameters.placeholderForYear = "----";