layout/xul/nsXULTooltipListener.h

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     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/. */
     6 #ifndef nsXULTooltipListener_h__
     7 #define nsXULTooltipListener_h__
     9 #include "nsIDOMEventListener.h"
    10 #include "nsIDOMMouseEvent.h"
    11 #include "nsIDOMElement.h"
    12 #include "nsITimer.h"
    13 #include "nsCOMPtr.h"
    14 #include "nsString.h"
    15 #ifdef MOZ_XUL
    16 #include "nsITreeBoxObject.h"
    17 #include "nsITreeColumns.h"
    18 #endif
    19 #include "nsWeakPtr.h"
    20 #include "mozilla/Attributes.h"
    22 class nsIContent;
    24 class nsXULTooltipListener MOZ_FINAL : public nsIDOMEventListener
    25 {
    26 public:
    27   NS_DECL_ISUPPORTS
    28   NS_DECL_NSIDOMEVENTLISTENER
    30   void MouseOut(nsIDOMEvent* aEvent);
    31   void MouseMove(nsIDOMEvent* aEvent);
    33   nsresult AddTooltipSupport(nsIContent* aNode);
    34   nsresult RemoveTooltipSupport(nsIContent* aNode);
    35   static nsXULTooltipListener* GetInstance() {
    36     if (!mInstance)
    37       mInstance = new nsXULTooltipListener();
    38     return mInstance;
    39   }
    40   static void ClearTooltipCache() { mInstance = nullptr; }
    42 protected:
    44   nsXULTooltipListener();
    45   ~nsXULTooltipListener();
    47   // pref callback for when the "show tooltips" pref changes
    48   static bool sShowTooltips;
    49   static uint32_t sTooltipListenerCount;
    51   void KillTooltipTimer();
    53 #ifdef MOZ_XUL
    54   void CheckTreeBodyMove(nsIDOMMouseEvent* aMouseEvent);
    55   nsresult GetSourceTreeBoxObject(nsITreeBoxObject** aBoxObject);
    56 #endif
    58   nsresult ShowTooltip();
    59   void LaunchTooltip();
    60   nsresult HideTooltip();
    61   nsresult DestroyTooltip();
    62   // This method tries to find a tooltip for aTarget.
    63   nsresult FindTooltip(nsIContent* aTarget, nsIContent** aTooltip);
    64   // This method calls FindTooltip and checks that the tooltip
    65   // can be really used (i.e. tooltip is not a menu).
    66   nsresult GetTooltipFor(nsIContent* aTarget, nsIContent** aTooltip);
    68   static nsXULTooltipListener* mInstance;
    69   static void ToolbarTipsPrefChanged(const char *aPref, void *aClosure);
    71   nsWeakPtr mSourceNode;
    72   nsWeakPtr mTargetNode;
    73   nsWeakPtr mCurrentTooltip;
    75   // a timer for showing the tooltip
    76   nsCOMPtr<nsITimer> mTooltipTimer;
    77   static void sTooltipCallback (nsITimer* aTimer, void* aListener);
    79   // screen coordinates of the last mousemove event, stored so that the
    80   // tooltip can be opened at this location.
    81   int32_t mMouseScreenX, mMouseScreenY;
    83   // various constants for tooltips
    84   enum {
    85     kTooltipMouseMoveTolerance = 7     // 7 pixel tolerance for mousemove event
    86   };
    88   // flag specifying if the tooltip has already been displayed by a MouseMove
    89   // event. The flag is reset on MouseOut so that the tooltip will display
    90   // the next time the mouse enters the node (bug #395668).
    91   bool mTooltipShownOnce;
    93 #ifdef MOZ_XUL
    94   // special members for handling trees
    95   bool mIsSourceTree;
    96   bool mNeedTitletip;
    97   int32_t mLastTreeRow;
    98   nsCOMPtr<nsITreeColumn> mLastTreeCol;
    99 #endif
   100 };
   102 #endif // nsXULTooltipListener

mercurial