Bug 1795723 - Unified extensions UI should support High Contrast Mode. r=ayeddi,deskt...
[gecko.git] / dom / html / HTMLOutputElement.h
blob5fa4cfa5a4b47fd8a9707fcd61d2936de2300393
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_HTMLOutputElement_h
8 #define mozilla_dom_HTMLOutputElement_h
10 #include "mozilla/Attributes.h"
11 #include "mozilla/dom/ConstraintValidation.h"
12 #include "nsGenericHTMLElement.h"
13 #include "nsStubMutationObserver.h"
15 namespace mozilla::dom {
17 class FormData;
19 class HTMLOutputElement final : public nsGenericHTMLFormControlElement,
20 public nsStubMutationObserver,
21 public ConstraintValidation {
22 public:
23 using ConstraintValidation::GetValidationMessage;
25 explicit HTMLOutputElement(
26 already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
27 FromParser aFromParser = NOT_FROM_PARSER);
29 // nsISupports
30 NS_DECL_ISUPPORTS_INHERITED
32 // nsIFormControl
33 NS_IMETHOD Reset() override;
34 // The output element is not submittable.
35 NS_IMETHOD SubmitNamesValues(FormData* aFormData) override { return NS_OK; }
37 nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
39 virtual bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
40 const nsAString& aValue,
41 nsIPrincipal* aMaybeScriptedPrincipal,
42 nsAttrValue& aResult) override;
44 virtual void DoneAddingChildren(bool aHaveNotified) override;
46 virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
48 // This function is called when a callback function from nsIMutationObserver
49 // has to be used to update the defaultValue attribute.
50 void DescendantsChanged();
52 // nsIMutationObserver
53 NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED
54 NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
55 NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
56 NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
58 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLOutputElement,
59 nsGenericHTMLFormControlElement)
61 virtual JSObject* WrapNode(JSContext* aCx,
62 JS::Handle<JSObject*> aGivenProto) override;
64 // WebIDL
65 nsDOMTokenList* HtmlFor();
67 void GetName(nsAString& aName) { GetHTMLAttr(nsGkAtoms::name, aName); }
69 void SetName(const nsAString& aName, ErrorResult& aRv) {
70 SetHTMLAttr(nsGkAtoms::name, aName, aRv);
73 void GetType(nsAString& aType) { aType.AssignLiteral("output"); }
75 void GetDefaultValue(nsAString& aDefaultValue) {
76 aDefaultValue = mDefaultValue;
79 void SetDefaultValue(const nsAString& aDefaultValue, ErrorResult& aRv);
81 void GetValue(nsAString& aValue) const;
82 void SetValue(const nsAString& aValue, ErrorResult& aRv);
84 // nsIConstraintValidation::WillValidate is fine.
85 // nsIConstraintValidation::Validity() is fine.
86 // nsIConstraintValidation::GetValidationMessage() is fine.
87 // nsIConstraintValidation::CheckValidity() is fine.
88 void SetCustomValidity(const nsAString& aError);
90 protected:
91 virtual ~HTMLOutputElement();
93 enum ValueModeFlag { eModeDefault, eModeValue };
95 ValueModeFlag mValueModeFlag;
96 bool mIsDoneAddingChildren;
97 nsString mDefaultValue;
98 RefPtr<nsDOMTokenList> mTokenList;
101 } // namespace mozilla::dom
103 #endif // mozilla_dom_HTMLOutputElement_h