一、HTML 表单input输入类型 对应c++总的定义在:
third_party\blink\renderer\core\html\forms\input_type.h
third_party\blink\renderer\core\html\forms\input_type.cc
二、截取定义部分:
class CORE_EXPORT InputType : public GarbageCollected<InputType> {
public:
// The type attribute of HTMLInputElement is an enumerated attribute:
// https://html.spec.whatwg.org/multipage/input.html#attr-input-type
// These values are a subset of the `FormControlType` enum. They have the same
// binary representation so that FormControlType() reduces to a type cast.
enum class Type : std::underlying_type_t<mojom::blink::FormControlType> {
kButton = base::to_underlying(mojom::blink::FormControlType::kInputButton),
kColor = base::to_underlying(mojom::blink::FormControlType::kInputColor),
kFile = base::to_underlying(mojom::blink::FormControlType::kInputFile),
kHidden = base::to_underlying(mojom::blink::FormControlType::kInputHidden),
kImage = base::to_underlying(mojom::blink::FormControlType::kInputImage),
kNumber = base::to_underlying(mojom::blink::FormControlType::kInputNumber),
kRange = base::to_underlying(mojom::blink::FormControlType::kInputRange),
kReset = base::to_underlying(mojom::blink::FormControlType::kInputReset),
kSubmit = base::to_underlying(mojom::blink::FormControlType::kInputSubmit),
// BaseCheckable
kRadio = base::to_underlying(mojom::blink::FormControlType::kInputRadio),
kCheckbox =
base::to_underlying(mojom::blink::FormControlType::kInputCheckbox),
// BaseTemporal
kDate = base::to_underlying(mojom::blink::FormControlType::kInputDate),
kDateTimeLocal =
base::to_underlying(mojom::blink::FormControlType::kInputDatetimeLocal),
kMonth = base::to_underlying(mojom::blink::FormControlType::kInputMonth),
kTime = base::to_underlying(mojom::blink::FormControlType::kInputTime),
kWeek = base::to_underlying(mojom::blink::FormControlType::kInputWeek),
// BaseText
kEmail = base::to_underlying(mojom::blink::FormControlType::kInputEmail),
kPassword =
base::to_underlying(mojom::blink::FormControlType::kInputPassword),
kSearch = base::to_underlying(mojom::blink::FormControlType::kInputSearch),
kTelephone =
base::to_underlying(mojom::blink::FormControlType::kInputTelephone),
kURL = base::to_underlying(mojom::blink::FormControlType::kInputUrl),
kText = base::to_underlying(mojom::blink::FormControlType::kInputText),
};
..................................................
};
三、类型定义form_control_type.mojom
third_party\blink\public\mojom\forms\form_control_type.mojom
module blink.mojom;
// An enum representation of the values of the `type` attribute of form control
// elements. This list is exhaustive.
enum FormControlType {
// https://html.spec.whatwg.org/multipage/form-elements.html#attr-button-type
kButtonButton,
kButtonSubmit,
kButtonReset,
kButtonSelectList,
// https://html.spec.whatwg.org/multipage/form-elements.html#dom-fieldset-type
kFieldset,
// https://html.spec.whatwg.org/multipage/input.html#attr-input-type
kInputButton,
kInputCheckbox,
kInputColor,
kInputDate,
kInputDatetimeLocal,
kInputEmail,
kInputFile,
kInputHidden,
kInputImage,
kInputMonth,
kInputNumber,
kInputPassword,
kInputRadio,
kInputRange,
kInputReset,
kInputSearch,
kInputSubmit,
kInputTelephone,
kInputText,
kInputTime,
kInputUrl,
kInputWeek,
// https://html.spec.whatwg.org/multipage/form-elements.html#dom-output-type
kOutput,
// https://html.spec.whatwg.org/multipage/form-elements.html#dom-select-type
kSelectOne,
kSelectMultiple,
kSelectList,
// https://html.spec.whatwg.org/multipage/form-elements.html#dom-textarea-type
kTextArea,
};