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 XULMenuBarElement_h__
8 #define XULMenuBarElement_h__
10 #include "mozilla/Attributes.h"
11 #include "mozilla/dom/NameSpaceConstants.h"
13 #include "nsISupports.h"
14 #include "XULMenuParentElement.h"
16 namespace mozilla::dom
{
19 class XULButtonElement
;
20 class MenuBarListener
;
22 nsXULElement
* NS_NewXULMenuBarElement(
23 already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
);
25 class XULMenuBarElement final
: public XULMenuParentElement
{
27 NS_DECL_ISUPPORTS_INHERITED
28 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XULMenuBarElement
,
30 NS_IMPL_FROMNODE_WITH_TAG(XULMenuBarElement
, kNameSpaceID_XUL
, menubar
)
32 explicit XULMenuBarElement(already_AddRefed
<class NodeInfo
>&&);
34 MOZ_CAN_RUN_SCRIPT
void SetActive(bool);
35 bool IsActive() const { return mIsActive
; }
37 void SetActiveByKeyboard() { mActiveByKeyboard
= true; }
38 bool IsActiveByKeyboard() const { return mActiveByKeyboard
; }
40 nsresult
BindToTree(BindContext
&, nsINode
& aParent
) override
;
41 void UnbindFromTree(bool aNullParent
) override
;
44 ~XULMenuBarElement() override
;
46 // Whether or not the menu bar is active (a menu item is highlighted or
48 bool mIsActive
= false;
50 // Whether the menubar was made active via the keyboard.
51 bool mActiveByKeyboard
= false;
53 // The event listener that listens to document key presses and so on.
54 RefPtr
<MenuBarListener
> mListener
;
57 } // namespace mozilla::dom
59 #endif // XULMenuBarElement_h