tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

HTMLMeterElement.h (3055B)


      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 "nsAttrValue.h"
     11 #include "nsAttrValueInlines.h"
     12 #include "nsGenericHTMLElement.h"
     13 
     14 namespace mozilla::dom {
     15 
     16 class HTMLMeterElement final : public nsGenericHTMLElement {
     17 public:
     18  explicit HTMLMeterElement(
     19      already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
     20 
     21  nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
     22 
     23  bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
     24                      const nsAString& aValue,
     25                      nsIPrincipal* aMaybeScriptedPrincipal,
     26                      nsAttrValue& aResult) override;
     27  void AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
     28                    const nsAttrValue* aValue, const nsAttrValue* aOldValue,
     29                    nsIPrincipal* aSubjectPrincipal, bool aNotify) override;
     30 
     31  // WebIDL
     32 
     33  /* @return the value */
     34  double Value() const;
     35  /* Returns the percentage that this element should be filed based on the
     36   * min/max/value */
     37  double Position() const;
     38  void SetValue(double aValue, ErrorResult& aRv) {
     39    SetDoubleAttr(nsGkAtoms::value, aValue, aRv);
     40  }
     41 
     42  /* @return the minimum value */
     43  double Min() const;
     44  void SetMin(double aValue, ErrorResult& aRv) {
     45    SetDoubleAttr(nsGkAtoms::min, aValue, aRv);
     46  }
     47 
     48  /* @return the maximum value */
     49  double Max() const;
     50  void SetMax(double aValue, ErrorResult& aRv) {
     51    SetDoubleAttr(nsGkAtoms::max, aValue, aRv);
     52  }
     53 
     54  /* @return the low value */
     55  double Low() const;
     56  void SetLow(double aValue, ErrorResult& aRv) {
     57    SetDoubleAttr(nsGkAtoms::low, aValue, aRv);
     58  }
     59 
     60  /* @return the high value */
     61  double High() const;
     62  void SetHigh(double aValue, ErrorResult& aRv) {
     63    SetDoubleAttr(nsGkAtoms::high, aValue, aRv);
     64  }
     65 
     66  /* @return the optimum value */
     67  double Optimum() const;
     68  void SetOptimum(double aValue, ErrorResult& aRv) {
     69    SetDoubleAttr(nsGkAtoms::optimum, aValue, aRv);
     70  }
     71 
     72  NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLMeterElement, meter);
     73 
     74 protected:
     75  virtual ~HTMLMeterElement();
     76 
     77  JSObject* WrapNode(JSContext*, JS::Handle<JSObject*> aGivenProto) override;
     78 
     79 private:
     80  /**
     81   * Returns the optimum state of the element.
     82   * ElementState::OPTIMUM if the actual value is in the optimum region.
     83   * ElementState::SUB_OPTIMUM if the actual value is in the sub-optimal
     84   *                            region.
     85   * ElementState::SUB_SUB_OPTIMUM if the actual value is in the
     86   *                                sub-sub-optimal region.
     87   *
     88   * @return the optimum state of the element.
     89   */
     90  ElementState GetOptimumState() const;
     91  void UpdateOptimumState(bool aNotify);
     92 };
     93 
     94 }  // namespace mozilla::dom
     95 
     96 #endif  // mozilla_dom_HTMLMeterElement_h