layout/xul/nsXULTooltipListener.h

Wed, 31 Dec 2014 07:16:47 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:16:47 +0100
branch
TOR_BUG_9701
changeset 3
141e0f1194b1
permissions
-rw-r--r--

Revert simplistic fix pending revisit of Mozilla integration attempt.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef nsXULTooltipListener_h__
michael@0 7 #define nsXULTooltipListener_h__
michael@0 8
michael@0 9 #include "nsIDOMEventListener.h"
michael@0 10 #include "nsIDOMMouseEvent.h"
michael@0 11 #include "nsIDOMElement.h"
michael@0 12 #include "nsITimer.h"
michael@0 13 #include "nsCOMPtr.h"
michael@0 14 #include "nsString.h"
michael@0 15 #ifdef MOZ_XUL
michael@0 16 #include "nsITreeBoxObject.h"
michael@0 17 #include "nsITreeColumns.h"
michael@0 18 #endif
michael@0 19 #include "nsWeakPtr.h"
michael@0 20 #include "mozilla/Attributes.h"
michael@0 21
michael@0 22 class nsIContent;
michael@0 23
michael@0 24 class nsXULTooltipListener MOZ_FINAL : public nsIDOMEventListener
michael@0 25 {
michael@0 26 public:
michael@0 27 NS_DECL_ISUPPORTS
michael@0 28 NS_DECL_NSIDOMEVENTLISTENER
michael@0 29
michael@0 30 void MouseOut(nsIDOMEvent* aEvent);
michael@0 31 void MouseMove(nsIDOMEvent* aEvent);
michael@0 32
michael@0 33 nsresult AddTooltipSupport(nsIContent* aNode);
michael@0 34 nsresult RemoveTooltipSupport(nsIContent* aNode);
michael@0 35 static nsXULTooltipListener* GetInstance() {
michael@0 36 if (!mInstance)
michael@0 37 mInstance = new nsXULTooltipListener();
michael@0 38 return mInstance;
michael@0 39 }
michael@0 40 static void ClearTooltipCache() { mInstance = nullptr; }
michael@0 41
michael@0 42 protected:
michael@0 43
michael@0 44 nsXULTooltipListener();
michael@0 45 ~nsXULTooltipListener();
michael@0 46
michael@0 47 // pref callback for when the "show tooltips" pref changes
michael@0 48 static bool sShowTooltips;
michael@0 49 static uint32_t sTooltipListenerCount;
michael@0 50
michael@0 51 void KillTooltipTimer();
michael@0 52
michael@0 53 #ifdef MOZ_XUL
michael@0 54 void CheckTreeBodyMove(nsIDOMMouseEvent* aMouseEvent);
michael@0 55 nsresult GetSourceTreeBoxObject(nsITreeBoxObject** aBoxObject);
michael@0 56 #endif
michael@0 57
michael@0 58 nsresult ShowTooltip();
michael@0 59 void LaunchTooltip();
michael@0 60 nsresult HideTooltip();
michael@0 61 nsresult DestroyTooltip();
michael@0 62 // This method tries to find a tooltip for aTarget.
michael@0 63 nsresult FindTooltip(nsIContent* aTarget, nsIContent** aTooltip);
michael@0 64 // This method calls FindTooltip and checks that the tooltip
michael@0 65 // can be really used (i.e. tooltip is not a menu).
michael@0 66 nsresult GetTooltipFor(nsIContent* aTarget, nsIContent** aTooltip);
michael@0 67
michael@0 68 static nsXULTooltipListener* mInstance;
michael@0 69 static void ToolbarTipsPrefChanged(const char *aPref, void *aClosure);
michael@0 70
michael@0 71 nsWeakPtr mSourceNode;
michael@0 72 nsWeakPtr mTargetNode;
michael@0 73 nsWeakPtr mCurrentTooltip;
michael@0 74
michael@0 75 // a timer for showing the tooltip
michael@0 76 nsCOMPtr<nsITimer> mTooltipTimer;
michael@0 77 static void sTooltipCallback (nsITimer* aTimer, void* aListener);
michael@0 78
michael@0 79 // screen coordinates of the last mousemove event, stored so that the
michael@0 80 // tooltip can be opened at this location.
michael@0 81 int32_t mMouseScreenX, mMouseScreenY;
michael@0 82
michael@0 83 // various constants for tooltips
michael@0 84 enum {
michael@0 85 kTooltipMouseMoveTolerance = 7 // 7 pixel tolerance for mousemove event
michael@0 86 };
michael@0 87
michael@0 88 // flag specifying if the tooltip has already been displayed by a MouseMove
michael@0 89 // event. The flag is reset on MouseOut so that the tooltip will display
michael@0 90 // the next time the mouse enters the node (bug #395668).
michael@0 91 bool mTooltipShownOnce;
michael@0 92
michael@0 93 #ifdef MOZ_XUL
michael@0 94 // special members for handling trees
michael@0 95 bool mIsSourceTree;
michael@0 96 bool mNeedTitletip;
michael@0 97 int32_t mLastTreeRow;
michael@0 98 nsCOMPtr<nsITreeColumn> mLastTreeCol;
michael@0 99 #endif
michael@0 100 };
michael@0 101
michael@0 102 #endif // nsXULTooltipListener

mercurial