一、Input 类型: search
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