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
相关推荐
骁的小小站1 小时前
Verilator 和 GTKwave联合仿真
开发语言·c++·经验分享·笔记·学习·fpga开发
林强1812 小时前
前端文件预览docx、pptx和xlsx
前端
像是套了虚弱散5 小时前
DevEco Studio与Web联合开发:打造鸿蒙混合应用的全景指南
开发语言·前端·华为·harmonyos·鸿蒙
旭意5 小时前
C++蓝桥杯之结构体10.15
开发语言·c++
衬衫chenshan5 小时前
【CTF】强网杯2025 Web题目writeup
前端
飞翔的佩奇5 小时前
【完整源码+数据集+部署教程】【天线&水】舰船战舰检测与分类图像分割系统源码&数据集全套:改进yolo11-repvit
前端·python·yolo·计算机视觉·数据集·yolo11·舰船战舰检测与分类图像分割系统
深思慎考6 小时前
调用百度云语音识别服务——实现c++接口识别语音
c++·语音识别·百度云
哆啦A梦15886 小时前
点击Top切换数据
前端·javascript·vue.js
程序猿追7 小时前
Vue组件化开发
前端·html
艾德金的溪7 小时前
redis-7.4.6部署安装
前端·数据库·redis·缓存