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
相关推荐
wuminyu8 小时前
专家视角看Java字节码加载与存储指令机制
java·linux·c语言·jvm·c++
小码哥_常8 小时前
安卓黑科技:实现多平台商品详情页一键跳转APP
前端
killerbasd8 小时前
还是迷茫 5.3
前端·react.js·前端框架
木喃的井盖8 小时前
无锁队列细节
c++·工程
王老师青少年编程9 小时前
csp信奥赛C++高频考点专项训练之字符串 --【字符串基础】:输出亲朋字符串
c++·字符串·csp·高频考点·信奥赛·专项训练·输出亲朋字符串
不会敲代码19 小时前
TCP/IP 与前端性能:从数据包到首次渲染的底层逻辑
前端·tcp/ip
WBluuue9 小时前
数据结构与算法:莫队(一):普通莫队与带修莫队
c++·算法
kyriewen9 小时前
奥特曼借GPT-5.5干杯,而你的Copilot正按Token收钱
前端·github·openai
AC赳赳老秦9 小时前
投标合规提效:用 OpenClaw 实现标书 / 合同自动审核、关键词校验、格式优化,降低废标风险
开发语言·前端·python·eclipse·emacs·deepseek·openclaw
kyriewen10 小时前
代码写成一锅粥?3个设计模式让你的项目“起死回生”
前端·javascript·设计模式