Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 : /* This Source Code Form is subject to the terms of the Mozilla Public
4 : * License, v. 2.0. If a copy of the MPL was not distributed with this
5 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : #ifndef mozilla_dom_HTMLMeterElement_h
8 : #define mozilla_dom_HTMLMeterElement_h
9 :
10 : #include "mozilla/Attributes.h"
11 : #include "nsGenericHTMLElement.h"
12 : #include "nsAttrValue.h"
13 : #include "nsAttrValueInlines.h"
14 : #include "nsAlgorithm.h"
15 : #include <algorithm>
16 :
17 : namespace mozilla {
18 : namespace dom {
19 :
20 : class HTMLMeterElement final : public nsGenericHTMLElement
21 : {
22 : public:
23 : explicit HTMLMeterElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
24 :
25 : virtual EventStates IntrinsicState() const override;
26 :
27 : nsresult Clone(mozilla::dom::NodeInfo* aNodeInfo, nsINode** aResult,
28 : bool aPreallocateChildren) const override;
29 :
30 : bool ParseAttribute(int32_t aNamespaceID, nsIAtom* aAttribute,
31 : const nsAString& aValue, nsAttrValue& aResult) override;
32 :
33 : // WebIDL
34 :
35 : /* @return the value */
36 : double Value() const;
37 0 : void SetValue(double aValue, ErrorResult& aRv)
38 : {
39 0 : SetDoubleAttr(nsGkAtoms::value, aValue, aRv);
40 0 : }
41 :
42 : /* @return the minimum value */
43 : double Min() const;
44 0 : void SetMin(double aValue, ErrorResult& aRv)
45 : {
46 0 : SetDoubleAttr(nsGkAtoms::min, aValue, aRv);
47 0 : }
48 :
49 : /* @return the maximum value */
50 : double Max() const;
51 0 : void SetMax(double aValue, ErrorResult& aRv)
52 : {
53 0 : SetDoubleAttr(nsGkAtoms::max, aValue, aRv);
54 0 : }
55 :
56 : /* @return the low value */
57 : double Low() const;
58 0 : void SetLow(double aValue, ErrorResult& aRv)
59 : {
60 0 : SetDoubleAttr(nsGkAtoms::low, aValue, aRv);
61 0 : }
62 :
63 : /* @return the high value */
64 : double High() const;
65 0 : void SetHigh(double aValue, ErrorResult& aRv)
66 : {
67 0 : SetDoubleAttr(nsGkAtoms::high, aValue, aRv);
68 0 : }
69 :
70 : /* @return the optimum value */
71 : double Optimum() const;
72 0 : void SetOptimum(double aValue, ErrorResult& aRv)
73 : {
74 0 : SetDoubleAttr(nsGkAtoms::optimum, aValue, aRv);
75 0 : }
76 :
77 : protected:
78 : virtual ~HTMLMeterElement();
79 :
80 : virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
81 :
82 : private:
83 :
84 : static const double kDefaultValue;
85 : static const double kDefaultMin;
86 : static const double kDefaultMax;
87 :
88 : /**
89 : * Returns the optimum state of the element.
90 : * NS_EVENT_STATE_OPTIMUM if the actual value is in the optimum region.
91 : * NS_EVENT_STATE_SUB_OPTIMUM if the actual value is in the sub-optimal region.
92 : * NS_EVENT_STATE_SUB_SUB_OPTIMUM if the actual value is in the sub-sub-optimal region.
93 : *
94 : * @return the optimum state of the element.
95 : */
96 : EventStates GetOptimumState() const;
97 : };
98 :
99 : } // namespace dom
100 : } // namespace mozilla
101 :
102 : #endif // mozilla_dom_HTMLMeterElement_h
|