Bug 1867190 - Initialise the PHC allocate delay later r=glandium
[gecko.git] / layout / xul / nsXULTooltipListener.h
blob1a665cfb337548d019758f48959507f3e532b095
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef nsXULTooltipListener_h__
8 #define nsXULTooltipListener_h__
10 #include "nsIDOMEventListener.h"
11 #include "nsITimer.h"
12 #include "nsCOMPtr.h"
13 #include "nsString.h"
14 #include "Units.h"
15 #include "nsIWeakReferenceUtils.h"
16 #include "mozilla/Attributes.h"
18 class nsIContent;
19 class nsTreeColumn;
21 namespace mozilla {
22 namespace dom {
23 class Event;
24 class MouseEvent;
25 class XULTreeElement;
26 } // namespace dom
27 class WidgetKeyboardEvent;
28 } // namespace mozilla
30 class nsXULTooltipListener final : public nsIDOMEventListener {
31 public:
32 NS_DECL_ISUPPORTS
33 NS_DECL_NSIDOMEVENTLISTENER
35 void MouseOut(mozilla::dom::Event* aEvent);
36 void MouseMove(mozilla::dom::Event* aEvent);
38 void AddTooltipSupport(nsIContent* aNode);
39 void RemoveTooltipSupport(nsIContent* aNode);
40 static nsXULTooltipListener* GetInstance() {
41 if (!sInstance) sInstance = new nsXULTooltipListener();
42 return sInstance;
45 static bool KeyEventHidesTooltip(const mozilla::WidgetKeyboardEvent&);
46 static bool ShowTooltips();
48 protected:
49 nsXULTooltipListener();
50 ~nsXULTooltipListener();
52 void KillTooltipTimer();
54 void CheckTreeBodyMove(mozilla::dom::MouseEvent* aMouseEvent);
55 mozilla::dom::XULTreeElement* GetSourceTree();
57 nsresult ShowTooltip();
58 void LaunchTooltip();
59 nsresult HideTooltip();
60 nsresult DestroyTooltip();
61 // This method tries to find a tooltip for aTarget.
62 nsresult FindTooltip(nsIContent* aTarget, nsIContent** aTooltip);
63 // This method calls FindTooltip and checks that the tooltip
64 // can be really used (i.e. tooltip is not a menu).
65 nsresult GetTooltipFor(nsIContent* aTarget, nsIContent** aTooltip);
67 static nsXULTooltipListener* sInstance;
69 nsWeakPtr mSourceNode;
70 nsWeakPtr mTargetNode;
71 nsWeakPtr mCurrentTooltip;
72 nsWeakPtr mPreviousMouseMoveTarget;
74 // a timer for showing the tooltip
75 nsCOMPtr<nsITimer> mTooltipTimer;
76 static void sTooltipCallback(nsITimer* aTimer, void* aListener);
78 // Screen coordinates of the last mousemove event, stored so that the tooltip
79 // can be opened at this location.
81 // TODO(emilio): This duplicates a lot of code with ChromeTooltipListener.
82 mozilla::LayoutDeviceIntPoint mMouseScreenPoint;
84 // Tolerance for mousemove event
85 static constexpr mozilla::LayoutDeviceIntCoord kTooltipMouseMoveTolerance = 7;
87 // flag specifying if the tooltip has already been displayed by a MouseMove
88 // event. The flag is reset on MouseOut so that the tooltip will display
89 // the next time the mouse enters the node (bug #395668).
90 bool mTooltipShownOnce;
92 // special members for handling trees
93 bool mIsSourceTree;
94 bool mNeedTitletip;
95 int32_t mLastTreeRow;
96 RefPtr<nsTreeColumn> mLastTreeCol;
99 #endif // nsXULTooltipListener