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
相关推荐
拿不拿铁195 分钟前
Vite 5.x 开发模式启动流程分析
前端
hetao173383711 分钟前
2025-11-13~14 hetao1733837的刷题记录
c++·算法
fruge14 分钟前
设计稿还原技巧:解决间距、阴影、字体适配的细节问题
前端·css
hansang_IR21 分钟前
【题解】洛谷 P2476 [SCOI2008] 着色方案 [记搜]
c++·算法·记忆化搜索
BBB努力学习程序设计34 分钟前
了解响应式Web设计:viewport网页可视区域
前端·html
zhangyao94033037 分钟前
uni-app scroll-view特定情况下运用
前端·javascript·uni-app
码农张37 分钟前
从原理到实践,吃透 Lit 响应式系统的核心逻辑
前端
jump68038 分钟前
object和map 和 WeakMap 的区别
前端
打小就很皮...43 分钟前
基于 Dify 实现 AI 流式对话:组件设计思路(React)
前端·react.js·dify·流式对话
AA陈超1 小时前
ASC学习笔记0010:效果被应用时的委托
c++·笔记·学习