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

search 类型用于搜索域,比如站点搜索或 Google 搜索。

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

<form action="demo-form.php">
  Search Google: <input type="search" name="googlesearch"><br>
  <input type="submit">
</form>

</body>
</html>

二、c++定义

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

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

cpp 复制代码
namespace blink {

class SearchInputType final : public BaseTextInputType {
 public:
  explicit SearchInputType(HTMLInputElement&);

  void Trace(Visitor*) const final;

 private:
  void CountUsage() override;
  ControlPart AutoAppearance() const override;
  bool NeedsContainer() const override;
  void CreateShadowSubtree() override;
  void HandleKeydownEvent(KeyboardEvent&) override;
  void DidSetValueByUserEdit() override;
  bool SupportsInputModeAttribute() const override;
  void UpdateView() override;
  void DispatchSearchEvent() override;

  void SearchEventTimerFired(TimerBase*);
  bool SearchEventsShouldBeDispatched() const;
  void StartSearchEventTimer();
  void UpdateCancelButtonVisibility();

  HeapTaskRunnerTimer<SearchInputType> search_event_timer_;
};

template <>
struct DowncastTraits<SearchInputType> {
  static bool AllowFrom(const InputType& type) {
    return type.IsSearchInputType();
  }
};

}  // namespace blink
相关推荐
Swot1 分钟前
产品 RAG 知识库与 AI 顾问 设计与实现
前端·后端
旖旎夜光16 分钟前
【C++ 基础入门】智能指针:RAII、unique_ptr 与 shared_ptr 循环引用
c++·笔记·学习·智能指针
ShineWinsu2 小时前
对于Qt:QSpacerItem常见属性以及方法的解析
开发语言·c++·qt·面试·系统架构·客户端·qspaceritem
htzyl2062 小时前
前端样式-弹窗淡入淡出,为什么你的 `transition` 一直不生效
前端·css·html
Brookty2 小时前
CSS基础知识(二):盒模型、内外边距、外边距折叠与父子元素的布局关系
前端·css
十有八七2 小时前
手搓 Agent(四):长点记性——上下文满了怎么办,怎么记住上一次
前端·人工智能·后端
叫个啥呢3 小时前
第一次写 DSH 插件:跟着自己的喜好实现个简单的代码管理插件
前端
掘金酱3 小时前
AI 带来的新生意|稀土掘金 X-Lab 年度大会招募开启
前端·后端·vibecoding
某哈压力大4 小时前
移动端 rem 适配
前端·vue.js·面试