Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/dom/HTMLMenuItemElement.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_HTMLMenuItemElement_h
8
#define mozilla_dom_HTMLMenuItemElement_h
9
10
#include "mozilla/Attributes.h"
11
#include "nsGenericHTMLElement.h"
12
13
namespace mozilla {
14
15
class EventChainPreVisitor;
16
17
namespace dom {
18
19
class Visitor;
20
21
class HTMLMenuItemElement final : public nsGenericHTMLElement
22
{
23
public:
24
  using mozilla::dom::Element::GetText;
25
26
  HTMLMenuItemElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
27
                      mozilla::dom::FromParser aFromParser);
28
29
  NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLMenuItemElement, menuitem)
30
31
  // nsISupports
32
  NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLMenuItemElement,
33
                                       nsGenericHTMLElement)
34
35
  void GetEventTargetParent(EventChainPreVisitor& aVisitor) override;
36
  virtual nsresult PostHandleEvent(
37
                     EventChainPostVisitor& aVisitor) override;
38
39
  virtual nsresult BindToTree(nsIDocument* aDocument,
40
                              nsIContent* aParent,
41
                              nsIContent* aBindingParent) override;
42
43
  virtual bool ParseAttribute(int32_t aNamespaceID,
44
                                nsAtom* aAttribute,
45
                                const nsAString& aValue,
46
                                nsIPrincipal* aMaybeScriptedPrincipal,
47
                                nsAttrValue& aResult) override;
48
49
  virtual void DoneCreatingElement() override;
50
51
  virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
52
53
0
  uint8_t GetType() const { return mType; }
54
55
  /**
56
   * Syntax sugar to make it easier to check for checked and checked dirty
57
   */
58
0
  bool IsChecked() const { return mChecked; }
59
0
  bool IsCheckedDirty() const { return mCheckedDirty; }
60
61
  void GetText(nsAString& aText);
62
63
  // WebIDL
64
65
  void GetType(DOMString& aValue);
66
  void SetType(const nsAString& aType, ErrorResult& aError)
67
0
  {
68
0
    SetHTMLAttr(nsGkAtoms::type, aType, aError);
69
0
  }
70
71
  // nsAString needed for HTMLMenuElement
72
  void GetLabel(nsAString& aValue)
73
0
  {
74
0
    if (!GetAttr(kNameSpaceID_None, nsGkAtoms::label, aValue)) {
75
0
      GetText(aValue);
76
0
    }
77
0
  }
78
  void SetLabel(const nsAString& aLabel, ErrorResult& aError)
79
0
  {
80
0
    SetHTMLAttr(nsGkAtoms::label, aLabel, aError);
81
0
  }
82
83
  // nsAString needed for HTMLMenuElement
84
  void GetIcon(nsAString& aValue)
85
0
  {
86
0
    GetURIAttr(nsGkAtoms::icon, nullptr, aValue);
87
0
  }
88
  void SetIcon(const nsAString& aIcon, ErrorResult& aError)
89
0
  {
90
0
    SetHTMLAttr(nsGkAtoms::icon, aIcon, aError);
91
0
  }
92
93
  bool Disabled() const
94
0
  {
95
0
    return GetBoolAttr(nsGkAtoms::disabled);
96
0
  }
97
  void SetDisabled(bool aDisabled, ErrorResult& aError)
98
0
  {
99
0
    SetHTMLBoolAttr(nsGkAtoms::disabled, aDisabled, aError);
100
0
  }
101
102
  bool Checked() const
103
0
  {
104
0
    return mChecked;
105
0
  }
106
  void SetChecked(bool aChecked);
107
108
  void GetRadiogroup(DOMString& aValue)
109
0
  {
110
0
    GetHTMLAttr(nsGkAtoms::radiogroup, aValue);
111
0
  }
112
  void SetRadiogroup(const nsAString& aRadiogroup, ErrorResult& aError)
113
0
  {
114
0
    SetHTMLAttr(nsGkAtoms::radiogroup, aRadiogroup, aError);
115
0
  }
116
117
  bool DefaultChecked() const
118
0
  {
119
0
    return GetBoolAttr(nsGkAtoms::checked);
120
0
  }
121
  void SetDefaultChecked(bool aDefault, ErrorResult& aError)
122
0
  {
123
0
    SetHTMLBoolAttr(nsGkAtoms::checked, aDefault, aError);
124
0
  }
125
126
protected:
127
  virtual ~HTMLMenuItemElement();
128
129
  virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
130
131
132
protected:
133
  virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsAtom* aName,
134
                                const nsAttrValue* aValue,
135
                                const nsAttrValue* aOldValue,
136
                                nsIPrincipal* aSubjectPrincipal,
137
                                bool aNotify) override;
138
139
  void WalkRadioGroup(Visitor* aVisitor);
140
141
  HTMLMenuItemElement* GetSelectedRadio();
142
143
  void AddedToRadioGroup();
144
145
  void InitChecked();
146
147
  friend class ClearCheckedVisitor;
148
  friend class SetCheckedDirtyVisitor;
149
150
0
  void ClearChecked() { mChecked = false; }
151
0
  void SetCheckedDirty() { mCheckedDirty = true; }
152
153
private:
154
  uint8_t mType : 2;
155
  bool mParserCreating : 1;
156
  bool mShouldInitChecked : 1;
157
  bool mCheckedDirty : 1;
158
  bool mChecked : 1;
159
};
160
161
} // namespace dom
162
} // namespace mozilla
163
164
#endif // mozilla_dom_HTMLMenuItemElement_h