Bug 1494333 - index crons just like artifacts r=Callek
[gecko.git] / dom / html / HTMLMenuItemElement.h
blob462593c8f97a02bbc76a80711c1a347b34b0f1a2
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_HTMLMenuItemElement_h
8 #define mozilla_dom_HTMLMenuItemElement_h
10 #include "mozilla/Attributes.h"
11 #include "nsGenericHTMLElement.h"
13 namespace mozilla {
15 class EventChainPreVisitor;
17 namespace dom {
19 class Visitor;
21 class HTMLMenuItemElement final : public nsGenericHTMLElement
23 public:
24 using mozilla::dom::Element::GetText;
26 HTMLMenuItemElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
27 mozilla::dom::FromParser aFromParser);
29 NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLMenuItemElement, menuitem)
31 // nsISupports
32 NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLMenuItemElement,
33 nsGenericHTMLElement)
35 void GetEventTargetParent(EventChainPreVisitor& aVisitor) override;
36 virtual nsresult PostHandleEvent(
37 EventChainPostVisitor& aVisitor) override;
39 virtual nsresult BindToTree(nsIDocument* aDocument,
40 nsIContent* aParent,
41 nsIContent* aBindingParent) override;
43 virtual bool ParseAttribute(int32_t aNamespaceID,
44 nsAtom* aAttribute,
45 const nsAString& aValue,
46 nsIPrincipal* aMaybeScriptedPrincipal,
47 nsAttrValue& aResult) override;
49 virtual void DoneCreatingElement() override;
51 virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
53 uint8_t GetType() const { return mType; }
55 /**
56 * Syntax sugar to make it easier to check for checked and checked dirty
58 bool IsChecked() const { return mChecked; }
59 bool IsCheckedDirty() const { return mCheckedDirty; }
61 void GetText(nsAString& aText);
63 // WebIDL
65 void GetType(DOMString& aValue);
66 void SetType(const nsAString& aType, ErrorResult& aError)
68 SetHTMLAttr(nsGkAtoms::type, aType, aError);
71 // nsAString needed for HTMLMenuElement
72 void GetLabel(nsAString& aValue)
74 if (!GetAttr(kNameSpaceID_None, nsGkAtoms::label, aValue)) {
75 GetText(aValue);
78 void SetLabel(const nsAString& aLabel, ErrorResult& aError)
80 SetHTMLAttr(nsGkAtoms::label, aLabel, aError);
83 // nsAString needed for HTMLMenuElement
84 void GetIcon(nsAString& aValue)
86 GetURIAttr(nsGkAtoms::icon, nullptr, aValue);
88 void SetIcon(const nsAString& aIcon, ErrorResult& aError)
90 SetHTMLAttr(nsGkAtoms::icon, aIcon, aError);
93 bool Disabled() const
95 return GetBoolAttr(nsGkAtoms::disabled);
97 void SetDisabled(bool aDisabled, ErrorResult& aError)
99 SetHTMLBoolAttr(nsGkAtoms::disabled, aDisabled, aError);
102 bool Checked() const
104 return mChecked;
106 void SetChecked(bool aChecked);
108 void GetRadiogroup(DOMString& aValue)
110 GetHTMLAttr(nsGkAtoms::radiogroup, aValue);
112 void SetRadiogroup(const nsAString& aRadiogroup, ErrorResult& aError)
114 SetHTMLAttr(nsGkAtoms::radiogroup, aRadiogroup, aError);
117 bool DefaultChecked() const
119 return GetBoolAttr(nsGkAtoms::checked);
121 void SetDefaultChecked(bool aDefault, ErrorResult& aError)
123 SetHTMLBoolAttr(nsGkAtoms::checked, aDefault, aError);
126 protected:
127 virtual ~HTMLMenuItemElement();
129 virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
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;
139 void WalkRadioGroup(Visitor* aVisitor);
141 HTMLMenuItemElement* GetSelectedRadio();
143 void AddedToRadioGroup();
145 void InitChecked();
147 friend class ClearCheckedVisitor;
148 friend class SetCheckedDirtyVisitor;
150 void ClearChecked() { mChecked = false; }
151 void SetCheckedDirty() { mCheckedDirty = true; }
153 private:
154 uint8_t mType : 2;
155 bool mParserCreating : 1;
156 bool mShouldInitChecked : 1;
157 bool mCheckedDirty : 1;
158 bool mChecked : 1;
161 } // namespace dom
162 } // namespace mozilla
164 #endif // mozilla_dom_HTMLMenuItemElement_h