Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : /**
7 : * This is the popup listener implementation for popup menus and context menus.
8 : */
9 :
10 : #ifndef nsXULPopupListener_h___
11 : #define nsXULPopupListener_h___
12 :
13 : #include "nsCOMPtr.h"
14 :
15 : #include "mozilla/dom/Element.h"
16 : #include "nsIDOMElement.h"
17 : #include "nsIDOMMouseEvent.h"
18 : #include "nsIDOMEventListener.h"
19 : #include "nsCycleCollectionParticipant.h"
20 :
21 : class nsXULPopupListener : public nsIDOMEventListener
22 : {
23 : public:
24 : // aElement is the element that the popup is attached to. If aIsContext is
25 : // false, the popup opens on left click on aElement or a descendant. If
26 : // aIsContext is true, the popup is a context menu which opens on a
27 : // context menu event.
28 : nsXULPopupListener(mozilla::dom::Element* aElement, bool aIsContext);
29 :
30 : // nsISupports
31 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
32 150 : NS_DECL_CYCLE_COLLECTION_SKIPPABLE_CLASS(nsXULPopupListener)
33 : NS_DECL_NSIDOMEVENTLISTENER
34 :
35 : protected:
36 : virtual ~nsXULPopupListener(void);
37 :
38 : // open the popup. aEvent is the event that triggered the popup such as
39 : // a mouse click and aTargetContent is the target of this event.
40 : virtual nsresult LaunchPopup(nsIDOMEvent* aEvent, nsIContent* aTargetContent);
41 :
42 : // close the popup when the listener goes away
43 : virtual void ClosePopup();
44 :
45 : private:
46 : #ifndef NS_CONTEXT_MENU_IS_MOUSEUP
47 : // When a context menu is opened, focus the target of the contextmenu event.
48 : nsresult FireFocusOnTargetContent(nsIDOMNode* aTargetNode, bool aIsTouch);
49 : #endif
50 :
51 : // |mElement| is the node to which this listener is attached.
52 : nsCOMPtr<mozilla::dom::Element> mElement;
53 :
54 : // The popup that is getting shown on top of mElement.
55 : nsCOMPtr<nsIContent> mPopupContent;
56 :
57 : // true if a context popup
58 : bool mIsContext;
59 : };
60 :
61 : #endif // nsXULPopupListener_h___
|