Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/dom/HTMLButtonElement.h
Line
Count
Source (jump to first uncovered line)
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_HTMLButtonElement_h
8
#define mozilla_dom_HTMLButtonElement_h
9
10
#include "mozilla/Attributes.h"
11
#include "nsGenericHTMLElement.h"
12
#include "nsIConstraintValidation.h"
13
14
namespace mozilla {
15
class EventChainPostVisitor;
16
class EventChainPreVisitor;
17
namespace dom {
18
19
class HTMLButtonElement final : public nsGenericHTMLFormElementWithState,
20
                                public nsIConstraintValidation
21
{
22
public:
23
  using nsIConstraintValidation::GetValidationMessage;
24
25
  explicit HTMLButtonElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
26
                             FromParser aFromParser = NOT_FROM_PARSER);
27
28
  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLButtonElement,
29
                                           nsGenericHTMLFormElementWithState)
30
31
  // nsISupports
32
  NS_DECL_ISUPPORTS_INHERITED
33
34
  virtual int32_t TabIndexDefault() override;
35
36
  NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLButtonElement, button)
37
38
  // Element
39
  virtual bool IsInteractiveHTMLContent(bool aIgnoreTabindex) const override
40
0
  {
41
0
    return true;
42
0
  }
43
44
  // overriden nsIFormControl methods
45
  NS_IMETHOD Reset() override;
46
  NS_IMETHOD SubmitNamesValues(HTMLFormSubmission* aFormSubmission) override;
47
  NS_IMETHOD SaveState() override;
48
  bool RestoreState(PresState* aState) override;
49
  virtual bool IsDisabledForEvents(EventMessage aMessage) override;
50
51
  virtual void FieldSetDisabledChanged(bool aNotify) override;
52
53
  // EventTarget
54
  void GetEventTargetParent(EventChainPreVisitor& aVisitor) override;
55
  virtual nsresult PostHandleEvent(
56
                     EventChainPostVisitor& aVisitor) override;
57
58
  // nsINode
59
  virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
60
  virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
61
62
  // nsIContent
63
  virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
64
                              nsIContent* aBindingParent) override;
65
  virtual void UnbindFromTree(bool aDeep = true,
66
                              bool aNullParent = true) override;
67
  virtual void DoneCreatingElement() override;
68
69
  void UpdateBarredFromConstraintValidation();
70
  // Element
71
  EventStates IntrinsicState() const override;
72
  /**
73
   * Called when an attribute is about to be changed
74
   */
75
  virtual nsresult BeforeSetAttr(int32_t aNameSpaceID, nsAtom* aName,
76
                                 const nsAttrValueOrString* aValue,
77
                                 bool aNotify) override;
78
  /**
79
   * Called when an attribute has just been changed
80
   */
81
  virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsAtom* aName,
82
                                const nsAttrValue* aValue,
83
                                const nsAttrValue* aOldValue,
84
                                nsIPrincipal* aSubjectPrincipal,
85
                                bool aNotify) override;
86
  virtual bool ParseAttribute(int32_t aNamespaceID,
87
                              nsAtom* aAttribute,
88
                              const nsAString& aValue,
89
                              nsIPrincipal* aMaybeScriptedPrincipal,
90
                              nsAttrValue& aResult) override;
91
92
  // nsGenericHTMLElement
93
  virtual bool IsHTMLFocusable(bool aWithMouse,
94
                               bool* aIsFocusable,
95
                               int32_t* aTabIndex) override;
96
97
  // WebIDL
98
  bool Autofocus() const
99
0
  {
100
0
    return GetBoolAttr(nsGkAtoms::autofocus);
101
0
  }
102
  void SetAutofocus(bool aAutofocus, ErrorResult& aError)
103
0
  {
104
0
    SetHTMLBoolAttr(nsGkAtoms::autofocus, aAutofocus, aError);
105
0
  }
106
  bool Disabled() const
107
0
  {
108
0
    return GetBoolAttr(nsGkAtoms::disabled);
109
0
  }
110
  void SetDisabled(bool aDisabled, ErrorResult& aError)
111
0
  {
112
0
    SetHTMLBoolAttr(nsGkAtoms::disabled, aDisabled, aError);
113
0
  }
114
  // nsGenericHTMLFormElement::GetForm is fine.
115
  using nsGenericHTMLFormElement::GetForm;
116
  // GetFormAction implemented in superclass
117
  void SetFormAction(const nsAString& aFormAction, ErrorResult& aRv)
118
0
  {
119
0
    SetHTMLAttr(nsGkAtoms::formaction, aFormAction, aRv);
120
0
  }
121
  void GetFormEnctype(nsAString& aFormEncType);
122
  void SetFormEnctype(const nsAString& aFormEnctype, ErrorResult& aRv)
123
0
  {
124
0
    SetHTMLAttr(nsGkAtoms::formenctype, aFormEnctype, aRv);
125
0
  }
126
  void GetFormMethod(nsAString& aFormMethod);
127
  void SetFormMethod(const nsAString& aFormMethod, ErrorResult& aRv)
128
0
  {
129
0
    SetHTMLAttr(nsGkAtoms::formmethod, aFormMethod, aRv);
130
0
  }
131
  bool FormNoValidate() const
132
0
  {
133
0
    return GetBoolAttr(nsGkAtoms::formnovalidate);
134
0
  }
135
  void SetFormNoValidate(bool aFormNoValidate, ErrorResult& aError)
136
0
  {
137
0
    SetHTMLBoolAttr(nsGkAtoms::formnovalidate, aFormNoValidate, aError);
138
0
  }
139
  void GetFormTarget(DOMString& aFormTarget)
140
0
  {
141
0
    GetHTMLAttr(nsGkAtoms::formtarget, aFormTarget);
142
0
  }
143
  void SetFormTarget(const nsAString& aFormTarget, ErrorResult& aRv)
144
0
  {
145
0
    SetHTMLAttr(nsGkAtoms::formtarget, aFormTarget, aRv);
146
0
  }
147
  void GetName(DOMString& aName)
148
0
  {
149
0
    GetHTMLAttr(nsGkAtoms::name, aName);
150
0
  }
151
  void SetName(const nsAString& aName, ErrorResult& aRv)
152
0
  {
153
0
    SetHTMLAttr(nsGkAtoms::name, aName, aRv);
154
0
  }
155
  void GetType(nsAString& aType);
156
  void SetType(const nsAString& aType, ErrorResult& aRv)
157
0
  {
158
0
    SetHTMLAttr(nsGkAtoms::type, aType, aRv);
159
0
  }
160
  void GetValue(DOMString& aValue)
161
0
  {
162
0
    GetHTMLAttr(nsGkAtoms::value, aValue);
163
0
  }
164
  void SetValue(const nsAString& aValue, ErrorResult& aRv)
165
0
  {
166
0
    SetHTMLAttr(nsGkAtoms::value, aValue, aRv);
167
0
  }
168
169
  // Override SetCustomValidity so we update our state properly when it's called
170
  // via bindings.
171
  void SetCustomValidity(const nsAString& aError);
172
173
protected:
174
  virtual ~HTMLButtonElement();
175
176
  bool mDisabledChanged;
177
  bool mInInternalActivate;
178
  bool mInhibitStateRestoration;
179
};
180
181
} // namespace dom
182
} // namespace mozilla
183
184
#endif // mozilla_dom_HTMLButtonElement_h