2017-10-27 20:33:53 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
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/. */
|
2001-12-05 02:45:22 +03:00
|
|
|
|
|
|
|
#ifndef nsXULTooltipListener_h__
|
|
|
|
#define nsXULTooltipListener_h__
|
|
|
|
|
2011-07-01 01:19:40 +04:00
|
|
|
#include "nsIDOMEventListener.h"
|
2001-12-05 02:45:22 +03:00
|
|
|
#include "nsITimer.h"
|
2001-12-08 03:24:23 +03:00
|
|
|
#include "nsCOMPtr.h"
|
2001-12-05 02:45:22 +03:00
|
|
|
#include "nsString.h"
|
2003-04-11 04:56:27 +04:00
|
|
|
#ifdef MOZ_XUL
|
2018-12-04 19:25:30 +03:00
|
|
|
# include "XULTreeElement.h"
|
2003-04-11 04:56:27 +04:00
|
|
|
#endif
|
2018-10-31 23:39:03 +03:00
|
|
|
#include "nsIWeakReferenceUtils.h"
|
2012-06-19 07:26:34 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2001-12-05 02:45:22 +03:00
|
|
|
|
2013-03-22 04:05:20 +04:00
|
|
|
class nsIContent;
|
2018-06-06 06:01:36 +03:00
|
|
|
class nsTreeColumn;
|
2013-03-22 04:05:20 +04:00
|
|
|
|
2018-03-20 07:16:05 +03:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2018-04-20 07:49:29 +03:00
|
|
|
class Event;
|
2018-03-20 07:16:05 +03:00
|
|
|
class MouseEvent;
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsXULTooltipListener final : public nsIDOMEventListener {
|
2001-12-05 02:45:22 +03:00
|
|
|
public:
|
2008-02-20 22:00:10 +03:00
|
|
|
NS_DECL_ISUPPORTS
|
2011-07-01 01:19:40 +04:00
|
|
|
NS_DECL_NSIDOMEVENTLISTENER
|
2001-12-05 02:45:22 +03:00
|
|
|
|
2018-04-20 07:49:29 +03:00
|
|
|
void MouseOut(mozilla::dom::Event* aEvent);
|
|
|
|
void MouseMove(mozilla::dom::Event* aEvent);
|
2001-12-05 02:45:22 +03:00
|
|
|
|
2018-02-23 21:25:34 +03:00
|
|
|
void AddTooltipSupport(nsIContent* aNode);
|
|
|
|
void RemoveTooltipSupport(nsIContent* aNode);
|
2007-04-13 00:59:01 +04:00
|
|
|
static nsXULTooltipListener* GetInstance() {
|
2018-02-23 21:25:34 +03:00
|
|
|
if (!sInstance) sInstance = new nsXULTooltipListener();
|
|
|
|
return sInstance;
|
2007-04-13 00:59:01 +04:00
|
|
|
}
|
2001-12-05 02:45:22 +03:00
|
|
|
|
|
|
|
protected:
|
2007-04-13 00:59:01 +04:00
|
|
|
nsXULTooltipListener();
|
|
|
|
~nsXULTooltipListener();
|
|
|
|
|
2001-12-05 02:45:22 +03:00
|
|
|
// pref callback for when the "show tooltips" pref changes
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool sShowTooltips;
|
2001-12-05 02:45:22 +03:00
|
|
|
|
|
|
|
void KillTooltipTimer();
|
|
|
|
|
2003-04-11 04:56:27 +04:00
|
|
|
#ifdef MOZ_XUL
|
2018-03-20 07:16:05 +03:00
|
|
|
void CheckTreeBodyMove(mozilla::dom::MouseEvent* aMouseEvent);
|
2018-12-04 19:25:30 +03:00
|
|
|
mozilla::dom::XULTreeElement* GetSourceTree();
|
2003-04-11 04:56:27 +04:00
|
|
|
#endif
|
2001-12-05 02:45:22 +03:00
|
|
|
|
|
|
|
nsresult ShowTooltip();
|
2007-04-17 03:22:34 +04:00
|
|
|
void LaunchTooltip();
|
2001-12-05 02:45:22 +03:00
|
|
|
nsresult HideTooltip();
|
|
|
|
nsresult DestroyTooltip();
|
2006-08-02 12:24:21 +04:00
|
|
|
// This method tries to find a tooltip for aTarget.
|
|
|
|
nsresult FindTooltip(nsIContent* aTarget, nsIContent** aTooltip);
|
|
|
|
// This method calls FindTooltip and checks that the tooltip
|
|
|
|
// can be really used (i.e. tooltip is not a menu).
|
2001-12-05 02:45:22 +03:00
|
|
|
nsresult GetTooltipFor(nsIContent* aTarget, nsIContent** aTooltip);
|
|
|
|
|
2018-02-23 21:25:34 +03:00
|
|
|
static nsXULTooltipListener* sInstance;
|
2013-12-11 03:10:01 +04:00
|
|
|
static void ToolbarTipsPrefChanged(const char* aPref, void* aClosure);
|
2004-04-30 03:34:19 +04:00
|
|
|
|
2008-02-20 22:00:10 +03:00
|
|
|
nsWeakPtr mSourceNode;
|
|
|
|
nsWeakPtr mTargetNode;
|
|
|
|
nsWeakPtr mCurrentTooltip;
|
2001-12-05 02:45:22 +03:00
|
|
|
|
|
|
|
// a timer for showing the tooltip
|
|
|
|
nsCOMPtr<nsITimer> mTooltipTimer;
|
|
|
|
static void sTooltipCallback(nsITimer* aTimer, void* aListener);
|
2008-02-20 23:16:55 +03:00
|
|
|
|
|
|
|
// screen coordinates of the last mousemove event, stored so that the
|
|
|
|
// tooltip can be opened at this location.
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t mMouseScreenX, mMouseScreenY;
|
2008-02-20 23:16:55 +03:00
|
|
|
|
2009-04-12 22:06:22 +04:00
|
|
|
// various constants for tooltips
|
2001-12-05 02:45:22 +03:00
|
|
|
enum {
|
2011-12-20 07:46:39 +04:00
|
|
|
kTooltipMouseMoveTolerance = 7 // 7 pixel tolerance for mousemove event
|
2001-12-05 02:45:22 +03:00
|
|
|
};
|
|
|
|
|
2009-04-12 22:06:22 +04:00
|
|
|
// flag specifying if the tooltip has already been displayed by a MouseMove
|
|
|
|
// event. The flag is reset on MouseOut so that the tooltip will display
|
|
|
|
// the next time the mouse enters the node (bug #395668).
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mTooltipShownOnce;
|
2009-04-12 22:06:22 +04:00
|
|
|
|
2003-04-11 04:56:27 +04:00
|
|
|
#ifdef MOZ_XUL
|
2002-03-29 05:46:01 +03:00
|
|
|
// special members for handling trees
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mIsSourceTree;
|
|
|
|
bool mNeedTitletip;
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t mLastTreeRow;
|
2018-06-06 06:01:36 +03:00
|
|
|
RefPtr<nsTreeColumn> mLastTreeCol;
|
2003-04-11 04:56:27 +04:00
|
|
|
#endif
|
2001-12-05 02:45:22 +03:00
|
|
|
};
|
|
|
|
|
2001-12-05 08:19:53 +03:00
|
|
|
#endif // nsXULTooltipListener
|