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/. */
7 #ifndef mozilla_dom_HTMLMeterElement_h
8 #define mozilla_dom_HTMLMeterElement_h
10 #include "mozilla/Attributes.h"
11 #include "nsGenericHTMLElement.h"
12 #include "nsAttrValue.h"
13 #include "nsAttrValueInlines.h"
14 #include "nsAlgorithm.h"
17 namespace mozilla::dom
{
19 class HTMLMeterElement final
: public nsGenericHTMLElement
{
21 explicit HTMLMeterElement(
22 already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
);
24 virtual ElementState
IntrinsicState() const override
;
26 nsresult
Clone(dom::NodeInfo
*, nsINode
** aResult
) const override
;
28 virtual bool ParseAttribute(int32_t aNamespaceID
, nsAtom
* aAttribute
,
29 const nsAString
& aValue
,
30 nsIPrincipal
* aMaybeScriptedPrincipal
,
31 nsAttrValue
& aResult
) override
;
35 /* @return the value */
37 /* Returns the percentage that this element should be filed based on the
39 double Position() const;
40 void SetValue(double aValue
, ErrorResult
& aRv
) {
41 SetDoubleAttr(nsGkAtoms::value
, aValue
, aRv
);
44 /* @return the minimum value */
46 void SetMin(double aValue
, ErrorResult
& aRv
) {
47 SetDoubleAttr(nsGkAtoms::min
, aValue
, aRv
);
50 /* @return the maximum value */
52 void SetMax(double aValue
, ErrorResult
& aRv
) {
53 SetDoubleAttr(nsGkAtoms::max
, aValue
, aRv
);
56 /* @return the low value */
58 void SetLow(double aValue
, ErrorResult
& aRv
) {
59 SetDoubleAttr(nsGkAtoms::low
, aValue
, aRv
);
62 /* @return the high value */
64 void SetHigh(double aValue
, ErrorResult
& aRv
) {
65 SetDoubleAttr(nsGkAtoms::high
, aValue
, aRv
);
68 /* @return the optimum value */
69 double Optimum() const;
70 void SetOptimum(double aValue
, ErrorResult
& aRv
) {
71 SetDoubleAttr(nsGkAtoms::optimum
, aValue
, aRv
);
74 NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLMeterElement
, meter
);
77 virtual ~HTMLMeterElement();
79 virtual JSObject
* WrapNode(JSContext
* aCx
,
80 JS::Handle
<JSObject
*> aGivenProto
) override
;
83 static const double kDefaultValue
;
84 static const double kDefaultMin
;
85 static const double kDefaultMax
;
88 * Returns the optimum state of the element.
89 * ElementState::OPTIMUM if the actual value is in the optimum region.
90 * ElementState::SUB_OPTIMUM if the actual value is in the sub-optimal
92 * ElementState::SUB_SUB_OPTIMUM if the actual value is in the
93 * sub-sub-optimal region.
95 * @return the optimum state of the element.
97 ElementState
GetOptimumState() const;
100 } // namespace mozilla::dom
102 #endif // mozilla_dom_HTMLMeterElement_h