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