一、文本域(Text Fields)
文本域通过 <input type="text"> 标签来设定,当用户要在表单中键入字母、数字等内容时,就会用到文本域。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>test</title>
</head>
<body>
<form action="demo-form.php">
First name: <input type="text" name="firstname"><br>
Last name: <input type="text" name="lastname"><br>
<br><input type="submit">
</form>
</body>
</html>
二、Text Fields c++接口定义:
third_party\blink\renderer\core\html\forms\text_input_type.h
third_party\blink\renderer\core\html\forms\text_input_type.cc
namespace blink {
class TextInputType final : public BaseTextInputType {
public:
TextInputType(HTMLInputElement& element)
: BaseTextInputType(Type::kText, element) {}
private:
void CountUsage() override;
bool SupportsInputModeAttribute() const override;
};
template <>
struct DowncastTraits<TextInputType> {
static bool AllowFrom(const InputType& type) {
return type.IsTextInputType();
}
};
} // namespace blink