Chromium HTML5 新的 Input 类型date 对应c++
一、Input 类型: date
date 类型允许你从一个日期选择器选择一个日期。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>test</title>
</head>
<body>
<form action="demo-form.php">
生日: <input type="date" name="bday">
<input type="submit">
</form>
</body>
</html>
二、c++定义:
third_party\blink\renderer\core\html\forms\date_input_type.h
third_party\blink\renderer\core\html\forms\date_input_type.cc
namespace blink {
class DateInputType final : public BaseTemporalInputType {
public:
explicit DateInputType(HTMLInputElement&);
private:
void CountUsage() override;
StepRange CreateStepRange(AnyStepHandling) const override;
bool ParseToDateComponentsInternal(const String&,
DateComponents*) const override;
bool SetMillisecondToDateComponents(double, DateComponents*) const override;
void WarnIfValueIsInvalid(const String&) const override;
// BaseTemporalInputType functions
String FormatDateTimeFieldsState(const DateTimeFieldsState&) const override;
void SetupLayoutParameters(DateTimeEditElement::LayoutParameters&,
const DateComponents&) const override;
bool IsValidFormat(bool has_year,
bool has_month,
bool has_week,
bool has_day,
bool has_ampm,
bool has_hour,
bool has_minute,
bool has_second) const override;
String AriaLabelForPickerIndicator() const override;
};
template <>
struct DowncastTraits<DateInputType> {
static bool AllowFrom(const InputType& type) {
return type.IsDateInputType();
}
};
} // namespace blink