2007-07-04 19:49:38 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-07-04 19:49:38 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This is the popup listener implementation for popup menus and context menus.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef nsXULPopupListener_h___
|
|
|
|
#define nsXULPopupListener_h___
|
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
|
2011-06-27 23:25:55 +04:00
|
|
|
#include "nsIDOMEventListener.h"
|
2007-09-04 19:26:35 +04:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2007-07-04 19:49:38 +04:00
|
|
|
|
2020-11-23 19:21:38 +03:00
|
|
|
class nsIContent;
|
|
|
|
|
2018-03-20 07:16:05 +03:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2020-11-23 19:08:40 +03:00
|
|
|
class Element;
|
2018-03-20 07:16:05 +03:00
|
|
|
class MouseEvent;
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2011-06-27 23:25:55 +04:00
|
|
|
class nsXULPopupListener : public nsIDOMEventListener {
|
2007-07-04 19:49:38 +04:00
|
|
|
public:
|
|
|
|
// aElement is the element that the popup is attached to. If aIsContext is
|
|
|
|
// false, the popup opens on left click on aElement or a descendant. If
|
|
|
|
// aIsContext is true, the popup is a context menu which opens on a
|
|
|
|
// context menu event.
|
2012-10-16 16:37:26 +04:00
|
|
|
nsXULPopupListener(mozilla::dom::Element* aElement, bool aIsContext);
|
2007-07-04 19:49:38 +04:00
|
|
|
|
|
|
|
// nsISupports
|
2007-09-04 19:26:35 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2012-10-16 16:37:26 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SKIPPABLE_CLASS(nsXULPopupListener)
|
2011-06-27 23:25:55 +04:00
|
|
|
NS_DECL_NSIDOMEVENTLISTENER
|
2007-07-04 19:49:38 +04:00
|
|
|
|
|
|
|
protected:
|
2014-06-25 06:09:15 +04:00
|
|
|
virtual ~nsXULPopupListener(void);
|
|
|
|
|
2007-07-04 19:49:38 +04:00
|
|
|
// open the popup. aEvent is the event that triggered the popup such as
|
|
|
|
// a mouse click and aTargetContent is the target of this event.
|
2018-05-26 07:23:04 +03:00
|
|
|
virtual nsresult LaunchPopup(mozilla::dom::MouseEvent* aEvent);
|
2007-07-04 19:49:38 +04:00
|
|
|
|
|
|
|
// close the popup when the listener goes away
|
|
|
|
virtual void ClosePopup();
|
|
|
|
|
|
|
|
private:
|
2008-09-30 03:44:28 +04:00
|
|
|
#ifndef NS_CONTEXT_MENU_IS_MOUSEUP
|
2007-07-04 19:49:38 +04:00
|
|
|
// When a context menu is opened, focus the target of the contextmenu event.
|
2020-12-04 01:08:44 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY nsresult
|
|
|
|
FireFocusOnTargetContent(nsIContent* aTargetContent, bool aIsTouch);
|
2008-09-30 03:44:28 +04:00
|
|
|
#endif
|
2007-07-04 19:49:38 +04:00
|
|
|
|
|
|
|
// |mElement| is the node to which this listener is attached.
|
2017-12-07 21:13:50 +03:00
|
|
|
RefPtr<mozilla::dom::Element> mElement;
|
2007-07-04 19:49:38 +04:00
|
|
|
|
|
|
|
// The popup that is getting shown on top of mElement.
|
2017-12-07 21:13:50 +03:00
|
|
|
RefPtr<mozilla::dom::Element> mPopupContent;
|
2007-07-04 19:49:38 +04:00
|
|
|
|
|
|
|
// true if a context popup
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mIsContext;
|
2007-07-04 19:49:38 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsXULPopupListener_h___
|