Source code

Revision control

Other Tools

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 "nsIDOMEventListener.h"
17
#include "nsCycleCollectionParticipant.h"
18
19
namespace mozilla {
20
namespace dom {
21
class MouseEvent;
22
} // namespace dom
23
} // namespace mozilla
24
25
class nsXULPopupListener : public nsIDOMEventListener {
26
public:
27
// aElement is the element that the popup is attached to. If aIsContext is
28
// false, the popup opens on left click on aElement or a descendant. If
29
// aIsContext is true, the popup is a context menu which opens on a
30
// context menu event.
31
nsXULPopupListener(mozilla::dom::Element* aElement, bool aIsContext);
32
33
// nsISupports
34
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
35
NS_DECL_CYCLE_COLLECTION_SKIPPABLE_CLASS(nsXULPopupListener)
36
NS_DECL_NSIDOMEVENTLISTENER
37
38
protected:
39
virtual ~nsXULPopupListener(void);
40
41
// open the popup. aEvent is the event that triggered the popup such as
42
// a mouse click and aTargetContent is the target of this event.
43
virtual nsresult LaunchPopup(mozilla::dom::MouseEvent* aEvent);
44
45
// close the popup when the listener goes away
46
virtual void ClosePopup();
47
48
private:
49
#ifndef NS_CONTEXT_MENU_IS_MOUSEUP
50
// When a context menu is opened, focus the target of the contextmenu event.
51
nsresult FireFocusOnTargetContent(nsIContent* aTargetContent, bool aIsTouch);
52
#endif
53
54
// |mElement| is the node to which this listener is attached.
55
RefPtr<mozilla::dom::Element> mElement;
56
57
// The popup that is getting shown on top of mElement.
58
RefPtr<mozilla::dom::Element> mPopupContent;
59
60
// true if a context popup
61
bool mIsContext;
62
};
63
64
#endif // nsXULPopupListener_h___