Line data Source code
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/Attributes.h"
11 : #include "nsGenericHTMLElement.h"
12 : #include "nsStubMutationObserver.h"
13 : #include "nsIConstraintValidation.h"
14 :
15 : namespace mozilla {
16 : namespace dom {
17 :
18 : class HTMLFormSubmission;
19 :
20 : class HTMLOutputElement final : public nsGenericHTMLFormElement,
21 : public nsStubMutationObserver,
22 : public nsIConstraintValidation
23 : {
24 : public:
25 : using nsIConstraintValidation::GetValidationMessage;
26 :
27 : explicit HTMLOutputElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
28 : FromParser aFromParser = NOT_FROM_PARSER);
29 :
30 : // nsISupports
31 : NS_DECL_ISUPPORTS_INHERITED
32 :
33 : // nsIFormControl
34 : NS_IMETHOD Reset() override;
35 : NS_IMETHOD SubmitNamesValues(HTMLFormSubmission* aFormSubmission) override;
36 :
37 0 : virtual bool IsDisabled() const override { return false; }
38 :
39 : nsresult Clone(mozilla::dom::NodeInfo* aNodeInfo, nsINode** aResult,
40 : bool aPreallocateChildren) const override;
41 :
42 : bool ParseAttribute(int32_t aNamespaceID, nsIAtom* aAttribute,
43 : const nsAString& aValue, nsAttrValue& aResult) override;
44 :
45 : virtual void DoneAddingChildren(bool aHaveNotified) override;
46 :
47 : EventStates IntrinsicState() const override;
48 :
49 : virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
50 : nsIContent* aBindingParent,
51 : bool aCompileEventHandlers) override;
52 :
53 : // This function is called when a callback function from nsIMutationObserver
54 : // has to be used to update the defaultValue attribute.
55 : void DescendantsChanged();
56 :
57 : // nsIMutationObserver
58 : NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED
59 : NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
60 : NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
61 : NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
62 :
63 0 : NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLOutputElement,
64 : nsGenericHTMLFormElement)
65 :
66 : virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
67 :
68 : // WebIDL
69 : nsDOMTokenList* HtmlFor();
70 : // nsGenericHTMLFormElement::GetForm is fine.
71 0 : void GetName(nsAString& aName)
72 : {
73 0 : GetHTMLAttr(nsGkAtoms::name, aName);
74 0 : }
75 :
76 0 : void SetName(const nsAString& aName, ErrorResult& aRv)
77 : {
78 0 : SetHTMLAttr(nsGkAtoms::name, aName, aRv);
79 0 : }
80 :
81 0 : void GetType(nsAString& aType)
82 : {
83 0 : aType.AssignLiteral("output");
84 0 : }
85 :
86 0 : void GetDefaultValue(nsAString& aDefaultValue)
87 : {
88 0 : aDefaultValue = mDefaultValue;
89 0 : }
90 :
91 : void SetDefaultValue(const nsAString& aDefaultValue, ErrorResult& aRv);
92 :
93 : void GetValue(nsAString& aValue);
94 : void SetValue(const nsAString& aValue, ErrorResult& aRv);
95 :
96 : // nsIConstraintValidation::WillValidate is fine.
97 : // nsIConstraintValidation::Validity() is fine.
98 : // nsIConstraintValidation::GetValidationMessage() is fine.
99 : // nsIConstraintValidation::CheckValidity() is fine.
100 : void SetCustomValidity(const nsAString& aError);
101 :
102 : protected:
103 : virtual ~HTMLOutputElement();
104 :
105 : enum ValueModeFlag {
106 : eModeDefault,
107 : eModeValue
108 : };
109 :
110 : ValueModeFlag mValueModeFlag;
111 : bool mIsDoneAddingChildren;
112 : nsString mDefaultValue;
113 : RefPtr<nsDOMTokenList> mTokenList;
114 : };
115 :
116 : } // namespace dom
117 : } // namespace mozilla
118 :
119 : #endif // mozilla_dom_HTMLOutputElement_h
|