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_HTMLMenuElement_h
8 #define mozilla_dom_HTMLMenuElement_h
10 #include "mozilla/Attributes.h"
11 #include "nsGenericHTMLElement.h"
18 class HTMLMenuElement final
: public nsGenericHTMLElement
{
20 explicit HTMLMenuElement(
21 already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
);
23 NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLMenuElement
, menu
)
26 NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLMenuElement
, nsGenericHTMLElement
)
28 virtual nsresult
AfterSetAttr(int32_t aNamespaceID
, nsAtom
* aName
,
29 const nsAttrValue
* aValue
,
30 const nsAttrValue
* aOldValue
,
31 nsIPrincipal
* aSubjectPrincipal
,
32 bool aNotify
) override
;
33 virtual bool ParseAttribute(int32_t aNamespaceID
, nsAtom
* aAttribute
,
34 const nsAString
& aValue
,
35 nsIPrincipal
* aMaybeScriptedPrincipal
,
36 nsAttrValue
& aResult
) override
;
38 virtual nsresult
Clone(dom::NodeInfo
*, nsINode
** aResult
) const override
;
40 uint8_t GetType() const { return mType
; }
44 void GetType(nsAString
& aValue
) { GetHTMLAttr(nsGkAtoms::type
, aValue
); }
45 void SetType(const nsAString
& aType
, ErrorResult
& aError
) {
46 SetHTMLAttr(nsGkAtoms::type
, aType
, aError
);
49 void GetLabel(nsAString
& aValue
) { GetHTMLAttr(nsGkAtoms::label
, aValue
); }
50 void SetLabel(const nsAString
& aLabel
, ErrorResult
& aError
) {
51 SetHTMLAttr(nsGkAtoms::label
, aLabel
, aError
);
54 bool Compact() const { return GetBoolAttr(nsGkAtoms::compact
); }
55 void SetCompact(bool aCompact
, ErrorResult
& aError
) {
56 SetHTMLBoolAttr(nsGkAtoms::compact
, aCompact
, aError
);
61 already_AddRefed
<nsIMenuBuilder
> CreateBuilder();
63 void Build(nsIMenuBuilder
* aBuilder
);
66 virtual ~HTMLMenuElement();
68 virtual JSObject
* WrapNode(JSContext
* aCx
,
69 JS::Handle
<JSObject
*> aGivenProto
) override
;
72 static bool CanLoadIcon(nsIContent
* aContent
, const nsAString
& aIcon
);
74 void BuildSubmenu(const nsAString
& aLabel
, nsIContent
* aContent
,
75 nsIMenuBuilder
* aBuilder
);
77 void TraverseContent(nsIContent
* aContent
, nsIMenuBuilder
* aBuilder
,
80 void AddSeparator(nsIMenuBuilder
* aBuilder
, int8_t& aSeparator
);
86 } // namespace mozilla
88 #endif // mozilla_dom_HTMLMenuElement_h