Chromium HTML5 新的 Input 类型week对应c++

一、Input 类型: week

week 类型允许你选择周和年。

html 复制代码
<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>test</title> 
</head>

<body>

<form action="demo-form.php">
  选择周: <input type="week" name="year_week">
  <input type="submit">
</form>

</body>
</html>

二、week c++定义:

third_party\blink\renderer\core\html\forms\week_input_type.h

third_party\blink\renderer\core\html\forms\week_input_type.cc

cpp 复制代码
namespace blink {

class WeekInputType final : public BaseTemporalInputType {
 public:
  explicit WeekInputType(HTMLInputElement& element)
      : BaseTemporalInputType(Type::kWeek, element) {}

 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<WeekInputType> {
  static bool AllowFrom(const InputType& type) {
    return type.IsWeekInputType();
  }
};

}  // namespace blink
相关推荐
天才熊猫君几秒前
“破案”笔记:iframe动态加载内容后,打印功能为何失灵?
前端
五月君_17 分钟前
炸裂!Claude Opus 4.6 与 GPT-5.3 同日发布:前端人的“自动驾驶“时刻到了?
前端·gpt
Mr Xu_21 分钟前
前端开发中CSS代码的优化与复用:从公共样式提取到CSS变量的最佳实践
前端·css
凡人叶枫26 分钟前
C++中输入、输出和文件操作详解(Linux实战版)| 从基础到项目落地,避坑指南
linux·服务器·c语言·开发语言·c++
CSDN_RTKLIB27 分钟前
使用三方库头文件未使用导出符号情景
c++
鹏北海-RemHusband1 小时前
从零到一:基于 micro-app 的企业级微前端模板完整实现指南
前端·微服务·架构
LYFlied1 小时前
AI大时代下前端跨端解决方案的现状与演进路径
前端·人工智能
光影少年1 小时前
AI 前端 / 高级前端
前端·人工智能·状态模式
一位搞嵌入式的 genius1 小时前
深入 JavaScript 函数式编程:从基础到实战(含面试题解析)
前端·javascript·函数式
anOnion1 小时前
构建无障碍组件之Alert Dialog Pattern
前端·html·交互设计