Bug 1732219 - Add API for fetching the preview image. r=geckoview-reviewers,agi,mconley
[gecko.git] / dom / html / HTMLOutputElement.h
blobcede8b381c5d773760e91fdbc2dbdf177b7ec1d3
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 "nsGenericHTMLElement.h"
12 #include "nsStubMutationObserver.h"
13 #include "nsIConstraintValidation.h"
15 namespace mozilla {
16 namespace dom {
18 class FormData;
20 class HTMLOutputElement final : public nsGenericHTMLFormControlElement,
21 public nsStubMutationObserver,
22 public nsIConstraintValidation {
23 public:
24 using nsIConstraintValidation::GetValidationMessage;
26 explicit HTMLOutputElement(
27 already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
28 FromParser aFromParser = NOT_FROM_PARSER);
30 // nsISupports
31 NS_DECL_ISUPPORTS_INHERITED
33 // nsIFormControl
34 NS_IMETHOD Reset() override;
35 // The output element is not submittable.
36 NS_IMETHOD SubmitNamesValues(FormData* aFormData) override { return NS_OK; }
38 nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
40 virtual bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
41 const nsAString& aValue,
42 nsIPrincipal* aMaybeScriptedPrincipal,
43 nsAttrValue& aResult) override;
45 virtual void DoneAddingChildren(bool aHaveNotified) override;
47 EventStates IntrinsicState() const override;
49 virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
51 // This function is called when a callback function from nsIMutationObserver
52 // has to be used to update the defaultValue attribute.
53 void DescendantsChanged();
55 // nsIMutationObserver
56 NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED
57 NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
58 NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
59 NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
61 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLOutputElement,
62 nsGenericHTMLFormControlElement)
64 virtual JSObject* WrapNode(JSContext* aCx,
65 JS::Handle<JSObject*> aGivenProto) override;
67 // WebIDL
68 nsDOMTokenList* HtmlFor();
70 void GetName(nsAString& aName) { GetHTMLAttr(nsGkAtoms::name, aName); }
72 void SetName(const nsAString& aName, ErrorResult& aRv) {
73 SetHTMLAttr(nsGkAtoms::name, aName, aRv);
76 void GetType(nsAString& aType) { aType.AssignLiteral("output"); }
78 void GetDefaultValue(nsAString& aDefaultValue) {
79 aDefaultValue = mDefaultValue;
82 void SetDefaultValue(const nsAString& aDefaultValue, ErrorResult& aRv);
84 void GetValue(nsAString& aValue);
85 void SetValue(const nsAString& aValue, ErrorResult& aRv);
87 // nsIConstraintValidation::WillValidate is fine.
88 // nsIConstraintValidation::Validity() is fine.
89 // nsIConstraintValidation::GetValidationMessage() is fine.
90 // nsIConstraintValidation::CheckValidity() is fine.
91 void SetCustomValidity(const nsAString& aError);
93 protected:
94 virtual ~HTMLOutputElement();
96 enum ValueModeFlag { eModeDefault, eModeValue };
98 ValueModeFlag mValueModeFlag;
99 bool mIsDoneAddingChildren;
100 nsString mDefaultValue;
101 RefPtr<nsDOMTokenList> mTokenList;
104 } // namespace dom
105 } // namespace mozilla
107 #endif // mozilla_dom_HTMLOutputElement_h