tor-browser

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

HTMLOutputElement.h (3277B)


      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_HTMLOutputElement_h
      8 #define mozilla_dom_HTMLOutputElement_h
      9 
     10 #include "mozilla/dom/ConstraintValidation.h"
     11 #include "nsGenericHTMLElement.h"
     12 #include "nsStubMutationObserver.h"
     13 
     14 namespace mozilla::dom {
     15 
     16 class FormData;
     17 
     18 class HTMLOutputElement final : public nsGenericHTMLFormControlElement,
     19                                public nsStubMutationObserver,
     20                                public ConstraintValidation {
     21 public:
     22  using ConstraintValidation::GetValidationMessage;
     23 
     24  explicit HTMLOutputElement(
     25      already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
     26      FromParser aFromParser = NOT_FROM_PARSER);
     27 
     28  // nsISupports
     29  NS_DECL_ISUPPORTS_INHERITED
     30 
     31  // nsIFormControl
     32  NS_IMETHOD Reset() override;
     33  // The output element is not submittable.
     34  NS_IMETHOD SubmitNamesValues(FormData* aFormData) override { return NS_OK; }
     35 
     36  nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
     37 
     38  bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
     39                      const nsAString& aValue,
     40                      nsIPrincipal* aMaybeScriptedPrincipal,
     41                      nsAttrValue& aResult) override;
     42 
     43  void DoneAddingChildren(bool aHaveNotified) override;
     44 
     45  // This function is called when a callback function from nsIMutationObserver
     46  // has to be used to update the defaultValue attribute.
     47  void DescendantsChanged();
     48 
     49  // nsIMutationObserver
     50  NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED
     51  NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
     52  NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
     53  NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
     54 
     55  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLOutputElement,
     56                                           nsGenericHTMLFormControlElement)
     57 
     58  JSObject* WrapNode(JSContext*, JS::Handle<JSObject*> aGivenProto) override;
     59 
     60  // WebIDL
     61  nsDOMTokenList* HtmlFor();
     62 
     63  void GetName(nsAString& aName) { GetHTMLAttr(nsGkAtoms::name, aName); }
     64 
     65  void SetName(const nsAString& aName, ErrorResult& aRv) {
     66    SetHTMLAttr(nsGkAtoms::name, aName, aRv);
     67  }
     68 
     69  void GetType(nsAString& aType) { aType.AssignLiteral("output"); }
     70 
     71  void GetDefaultValue(nsAString& aDefaultValue) {
     72    aDefaultValue = mDefaultValue;
     73  }
     74 
     75  void SetDefaultValue(const nsAString& aDefaultValue, ErrorResult& aRv);
     76 
     77  void GetValue(nsAString& aValue) const;
     78  void SetValue(const nsAString& aValue, ErrorResult& aRv);
     79 
     80  // nsIConstraintValidation::WillValidate is fine.
     81  // nsIConstraintValidation::Validity() is fine.
     82  // nsIConstraintValidation::GetValidationMessage() is fine.
     83  // nsIConstraintValidation::CheckValidity() is fine.
     84  void SetCustomValidity(const nsAString& aError);
     85 
     86 protected:
     87  virtual ~HTMLOutputElement();
     88 
     89  enum ValueModeFlag { eModeDefault, eModeValue };
     90 
     91  ValueModeFlag mValueModeFlag;
     92  bool mIsDoneAddingChildren;
     93  nsString mDefaultValue;
     94  RefPtr<nsDOMTokenList> mTokenList;
     95 };
     96 
     97 }  // namespace mozilla::dom
     98 
     99 #endif  // mozilla_dom_HTMLOutputElement_h