一、Input 类型: range
range 类型用于应该包含一定范围内数字值的输入域。
range 类型显示为滑动条。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>test</title>
</head>
<body><form action="demo-form.php" method="get">
Points: <input type="range" name="points" min="1" max="10">
<input type="submit">
</form><p><b>注意:</b> Internet Explorer 9 及更早 IE 版本不支持 type="range"。</p></body>
</html>
二、c++定义:
third_party\blink\renderer\core\html\forms\range_input_type.h
third_party\blink\renderer\core\html\forms\range_input_type.cc
namespace blink {class ExceptionState;
class SliderThumbElement;class RangeInputType final : public InputType, public InputTypeView {public:explicit RangeInputType(HTMLInputElement&);void Trace(Visitor*) const override;using InputType::GetElement;bool TypeMismatchFor(const String&) const;private:InputTypeView* CreateView() override;ValueMode GetValueMode() const override;void CountUsage() override;double ValueAsDouble() const override;void SetValueAsDouble(double,TextFieldEventBehavior,ExceptionState&) const override;bool SupportsRequired() const override;StepRange CreateStepRange(AnyStepHandling) const override;void HandleMouseDownEvent(MouseEvent&) override;void HandleKeydownEvent(KeyboardEvent&) override;LayoutObject* CreateLayoutObject(const ComputedStyle&) const override;void CreateShadowSubtree() override;Decimal ParseToNumber(const String&, const Decimal&) const override;String Serialize(const Decimal&) const override;void AccessKeyAction(SimulatedClickCreationScope creation_scope) override;void SanitizeValueInResponseToMinOrMaxAttributeChange() override;void StepAttributeChanged() override;void WarnIfValueIsInvalid(const String&) const override;String RangeOverflowText(const Decimal& maxmum) const override;String RangeUnderflowText(const Decimal& minimum) const override;String RangeInvalidText(const Decimal& minimum,const Decimal& maximum) const override;void DidSetValue(const String&, bool value_changed) override;String SanitizeValue(const String& proposed_value) const override;bool ShouldRespectListAttribute() override;void DisabledAttributeChanged() override;void ListAttributeTargetChanged() override;Decimal FindClosestTickMarkValue(const Decimal&) override;SliderThumbElement* GetSliderThumbElement() const;Element* SliderTrackElement() const;void UpdateTickMarkValues();// InputTypeView function:ControlPart AutoAppearance() const override;void UpdateView() override;void ValueAttributeChanged() override;bool IsDraggedSlider() const override;bool tick_mark_values_dirty_;Vector<Decimal> tick_mark_values_;
};template <>
struct DowncastTraits<RangeInputType> {static bool AllowFrom(const InputType& type) {return type.IsRangeInputType();}
};} // namespace blink