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 nsresult
Clone(dom::NodeInfo
*, nsINode
** aResult
) const override
;
26 bool ParseAttribute(int32_t aNamespaceID
, nsAtom
* aAttribute
,
27 const nsAString
& aValue
,
28 nsIPrincipal
* aMaybeScriptedPrincipal
,
29 nsAttrValue
& aResult
) override
;
30 void AfterSetAttr(int32_t aNameSpaceID
, nsAtom
* aName
,
31 const nsAttrValue
* aValue
, const nsAttrValue
* aOldValue
,
32 nsIPrincipal
* aSubjectPrincipal
, bool aNotify
) override
;
36 /* @return the value */
38 /* Returns the percentage that this element should be filed based on the
40 double Position() const;
41 void SetValue(double aValue
, ErrorResult
& aRv
) {
42 SetDoubleAttr(nsGkAtoms::value
, aValue
, aRv
);
45 /* @return the minimum value */
47 void SetMin(double aValue
, ErrorResult
& aRv
) {
48 SetDoubleAttr(nsGkAtoms::min
, aValue
, aRv
);
51 /* @return the maximum value */
53 void SetMax(double aValue
, ErrorResult
& aRv
) {
54 SetDoubleAttr(nsGkAtoms::max
, aValue
, aRv
);
57 /* @return the low value */
59 void SetLow(double aValue
, ErrorResult
& aRv
) {
60 SetDoubleAttr(nsGkAtoms::low
, aValue
, aRv
);
63 /* @return the high value */
65 void SetHigh(double aValue
, ErrorResult
& aRv
) {
66 SetDoubleAttr(nsGkAtoms::high
, aValue
, aRv
);
69 /* @return the optimum value */
70 double Optimum() const;
71 void SetOptimum(double aValue
, ErrorResult
& aRv
) {
72 SetDoubleAttr(nsGkAtoms::optimum
, aValue
, aRv
);
75 NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLMeterElement
, meter
);
78 virtual ~HTMLMeterElement();
80 JSObject
* WrapNode(JSContext
*, JS::Handle
<JSObject
*> aGivenProto
) override
;
84 * Returns the optimum state of the element.
85 * ElementState::OPTIMUM if the actual value is in the optimum region.
86 * ElementState::SUB_OPTIMUM if the actual value is in the sub-optimal
88 * ElementState::SUB_SUB_OPTIMUM if the actual value is in the
89 * sub-sub-optimal region.
91 * @return the optimum state of the element.
93 ElementState
GetOptimumState() const;
94 void UpdateOptimumState(bool aNotify
);
97 } // namespace mozilla::dom
99 #endif // mozilla_dom_HTMLMeterElement_h