Bug 1795723 - Unified extensions UI should support High Contrast Mode. r=ayeddi,deskt...
[gecko.git] / dom / html / HTMLMeterElement.h
blobf4057639b256a6d0cf08e03af079d86cd8d96420
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"
15 #include <algorithm>
17 namespace mozilla::dom {
19 class HTMLMeterElement final : public nsGenericHTMLElement {
20 public:
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;
33 // WebIDL
35 /* @return the value */
36 double Value() const;
37 /* Returns the percentage that this element should be filed based on the
38 * min/max/value */
39 double Position() const;
40 void SetValue(double aValue, ErrorResult& aRv) {
41 SetDoubleAttr(nsGkAtoms::value, aValue, aRv);
44 /* @return the minimum value */
45 double Min() const;
46 void SetMin(double aValue, ErrorResult& aRv) {
47 SetDoubleAttr(nsGkAtoms::min, aValue, aRv);
50 /* @return the maximum value */
51 double Max() const;
52 void SetMax(double aValue, ErrorResult& aRv) {
53 SetDoubleAttr(nsGkAtoms::max, aValue, aRv);
56 /* @return the low value */
57 double Low() const;
58 void SetLow(double aValue, ErrorResult& aRv) {
59 SetDoubleAttr(nsGkAtoms::low, aValue, aRv);
62 /* @return the high value */
63 double High() const;
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);
76 protected:
77 virtual ~HTMLMeterElement();
79 virtual JSObject* WrapNode(JSContext* aCx,
80 JS::Handle<JSObject*> aGivenProto) override;
82 private:
83 static const double kDefaultValue;
84 static const double kDefaultMin;
85 static const double kDefaultMax;
87 /**
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
91 * region.
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