Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes
nsXULTooltipListener Class Reference

#include <nsXULTooltipListener.h>

Inheritance diagram for nsXULTooltipListener:
Inheritance graph
[legend]
Collaboration diagram for nsXULTooltipListener:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsXULTooltipListener ()
virtual ~nsXULTooltipListener ()
NS_DECL_ISUPPORTS NS_IMETHOD MouseDown (nsIDOMEvent *aMouseEvent)
 Processes a mouse down event.
NS_IMETHOD MouseUp (nsIDOMEvent *aMouseEvent)
 Processes a mouse up event.
NS_IMETHOD MouseClick (nsIDOMEvent *aMouseEvent)
 Processes a mouse click event.
NS_IMETHOD MouseDblClick (nsIDOMEvent *aMouseEvent)
 Processes a mouse click event.
NS_IMETHOD MouseOver (nsIDOMEvent *aMouseEvent)
 Processes a mouse enter event.
NS_IMETHOD MouseOut (nsIDOMEvent *aMouseEvent)
 Processes a mouse leave event.
NS_IMETHOD DragMove (nsIDOMEvent *aMouseEvent)
 Processes a drag move event.
NS_IMETHOD MouseMove (nsIDOMEvent *aMouseEvent)
 Processes a mouse move event.
NS_IMETHOD KeyDown (nsIDOMEvent *aKeyEvent)
 Processes a key pressed event.
NS_IMETHOD KeyUp (nsIDOMEvent *aKeyEvent)
 Processes a key release event.
NS_IMETHOD KeyPress (nsIDOMEvent *aKeyEvent)
 Processes a key typed event.
NS_IMETHOD PopupShowing (nsIDOMEvent *aEvent)
NS_IMETHOD PopupShown (nsIDOMEvent *aEvent)
NS_IMETHOD PopupHiding (nsIDOMEvent *aEvent)
NS_IMETHOD PopupHidden (nsIDOMEvent *aEvent)
NS_IMETHOD Close (nsIDOMEvent *aEvent)
NS_IMETHOD Command (nsIDOMEvent *aEvent)
NS_IMETHOD Broadcast (nsIDOMEvent *aEvent)
NS_IMETHOD CommandUpdate (nsIDOMEvent *aEvent)
NS_IMETHOD HandleEvent (nsIDOMEvent *aEvent)
nsresult Init (nsIContent *aSourceNode, nsIRootBox *aRootBox)
nsresult SetDefaultTooltip (nsIContent *aDefaultTooltip)
nsresult GetDefaultTooltip (nsIContent **aDefaultTooltip)
nsresult AddTooltipSupport (nsIContent *aNode)
nsresult RemoveTooltipSupport (nsIContent *aNode)
void handleEvent (in nsIDOMEvent event)
 This method is called whenever an event occurs of the type for which the EventListener interface was registered.

Protected Types

enum  { kTooltipAutoHideTime = 5000, kTooltipShowTime = 500 }

Protected Member Functions

void KillTooltipTimer ()
void CreateAutoHideTimer ()
nsresult ShowTooltip ()
nsresult LaunchTooltip (nsIContent *aTarget, PRInt32 aX, PRInt32 aY)
nsresult HideTooltip ()
nsresult DestroyTooltip ()
nsresult GetTooltipFor (nsIContent *aTarget, nsIContent **aTooltip)

Static Protected Member Functions

static int sTooltipPrefChanged (const char *aPref, void *aData)
static int ToolbarTipsPrefChanged (const char *aPref, void *aClosure)
static void sTooltipCallback (nsITimer *aTimer, void *aListener)
static void sAutoHideCallback (nsITimer *aTimer, void *aListener)

Protected Attributes

nsIRootBoxmRootBox
nsIContentmSourceNode
nsCOMPtr< nsIContentmTargetNode
nsCOMPtr< nsIContentmCurrentTooltip
nsCOMPtr< nsITimermTooltipTimer
PRInt32 mMouseClientX
PRInt32 mMouseClientY
nsCOMPtr< nsITimermAutoHideTimer

Static Protected Attributes

static PRBool sShowTooltips = PR_FALSE
static PRUint32 sTooltipListenerCount = 0

Detailed Description

Definition at line 57 of file nsXULTooltipListener.h.


Member Enumeration Documentation

anonymous enum [protected]
Enumerator:
kTooltipAutoHideTime 
kTooltipShowTime 

Definition at line 144 of file nsXULTooltipListener.h.

       {
    kTooltipAutoHideTime = 5000,       // 5000ms = 5 seconds
    kTooltipShowTime = 500             // 500ms = 0.5 seconds
  };

Constructor & Destructor Documentation

Definition at line 66 of file nsXULTooltipListener.cpp.

  : mSourceNode(nsnull)
  , mTargetNode(nsnull)
  , mCurrentTooltip(nsnull)
  , mMouseClientX(0)
  , mMouseClientY(0)
#ifdef MOZ_XUL
  , mIsSourceTree(PR_FALSE)
  , mNeedTitletip(PR_FALSE)
  , mLastTreeRow(-1)
#endif
{
  if (sTooltipListenerCount++ == 0) {
    // register the callback so we get notified of updates
    nsContentUtils::RegisterPrefCallback("browser.chrome.toolbar_tips",
                                         ToolbarTipsPrefChanged, nsnull);

    // Call the pref callback to initialize our state.
    ToolbarTipsPrefChanged("browser.chrome.toolbar_tips", nsnull);
  }
}

Here is the call graph for this function:

Definition at line 88 of file nsXULTooltipListener.cpp.

{
  HideTooltip();

  if (--sTooltipListenerCount == 0) {
    // Unregister our pref observer
    nsContentUtils::UnregisterPrefCallback("browser.chrome.toolbar_tips",
                                           ToolbarTipsPrefChanged, nsnull);
  }
}

Here is the call graph for this function:


Member Function Documentation

Definition at line 304 of file nsXULTooltipListener.cpp.

{
  if (!aNode)
    return NS_ERROR_NULL_POINTER;

  nsCOMPtr<nsIDOMEventTarget> evtTarget(do_QueryInterface(aNode));
  evtTarget->AddEventListener(NS_LITERAL_STRING("mouseout"), (nsIDOMMouseListener*)this, PR_FALSE);
  evtTarget->AddEventListener(NS_LITERAL_STRING("mousemove"), (nsIDOMMouseListener*)this, PR_FALSE);
  
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHOD nsXULTooltipListener::Broadcast ( nsIDOMEvent aEvent) [inline, virtual]

Implements nsIDOMXULListener.

Definition at line 94 of file nsXULTooltipListener.h.

{ return NS_OK; };
NS_IMETHOD nsXULTooltipListener::Close ( nsIDOMEvent aEvent) [inline, virtual]

Implements nsIDOMXULListener.

Definition at line 92 of file nsXULTooltipListener.h.

{ return NS_OK; };
NS_IMETHOD nsXULTooltipListener::Command ( nsIDOMEvent aEvent) [inline, virtual]

Implements nsIDOMXULListener.

Definition at line 93 of file nsXULTooltipListener.h.

{ return NS_OK; };

Implements nsIDOMXULListener.

Definition at line 95 of file nsXULTooltipListener.h.

{ return NS_OK; };

Definition at line 697 of file nsXULTooltipListener.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 647 of file nsXULTooltipListener.cpp.

{
  nsCOMPtr<nsIDOMMouseListener> kungFuDeathGrip(this);
  if (mCurrentTooltip) {
    // clear out the tooltip node on the document
    nsCOMPtr<nsIDocument> doc = mCurrentTooltip->GetDocument();
    if (doc) {
      nsCOMPtr<nsIDOMXULDocument> xulDoc(do_QueryInterface(doc));
      if (xulDoc)
        xulDoc->SetTooltipNode(nsnull);

      // remove the mousedown and keydown listener from document
      nsCOMPtr<nsIDOMEventTarget> evtTarget(do_QueryInterface(doc));
      evtTarget->RemoveEventListener(NS_LITERAL_STRING("DOMMouseScroll"), (nsIDOMMouseListener*)this, PR_TRUE);
      evtTarget->RemoveEventListener(NS_LITERAL_STRING("mousedown"), (nsIDOMMouseListener*)this, PR_TRUE);
      evtTarget->RemoveEventListener(NS_LITERAL_STRING("mouseup"), (nsIDOMMouseListener*)this, PR_TRUE);
      evtTarget->RemoveEventListener(NS_LITERAL_STRING("keydown"), (nsIDOMMouseListener*)this, PR_TRUE);
    }

    // remove the popuphidden listener from tooltip
    nsCOMPtr<nsIDOMEventTarget> evtTarget(do_QueryInterface(mCurrentTooltip));

    // release tooltip before removing listener to prevent our destructor from
    // being called recursively (bug 120863)
    mCurrentTooltip = nsnull;

    evtTarget->RemoveEventListener(NS_LITERAL_STRING("popuphiding"), (nsIDOMMouseListener*)this, PR_FALSE);
  }
  
  // kill any ongoing timers
  KillTooltipTimer();
  if (mAutoHideTimer) {
    mAutoHideTimer->Cancel();
    mAutoHideTimer = nsnull;
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHOD nsXULTooltipListener::DragMove ( nsIDOMEvent aMouseEvent) [inline, virtual]

Processes a drag move event.

Parameters:
aMouseEvent
See also:
nsIDOMEvent.h
Returns:
whether the event was consumed or ignored.
See also:
nsresult

Implements nsIDOMMouseMotionListener.

Definition at line 79 of file nsXULTooltipListener.h.

{ return NS_OK; };
nsresult nsXULTooltipListener::GetTooltipFor ( nsIContent aTarget,
nsIContent **  aTooltip 
) [protected]

Definition at line 564 of file nsXULTooltipListener.cpp.

{
  if (!aTarget)
    return NS_ERROR_NULL_POINTER;

  nsCOMPtr<nsIDOMElement> targetEl(do_QueryInterface(aTarget));
  if (!targetEl)
    return NS_ERROR_FAILURE; // could be a text node or something

  // before we go on, make sure that target node still has a window
  nsCOMPtr<nsIDocument> document = aTarget->GetDocument();
  if (!document) {
    NS_ERROR("Unable to retrieve the tooltip node document.");
    return NS_ERROR_FAILURE;
  }
  nsIScriptGlobalObject *global = document->GetScriptGlobalObject();
  if (global) {
    nsIScriptContext *context = global->GetContext();

    if (context) {
      nsCOMPtr<nsIDOMWindowInternal> domWindow = do_QueryInterface(global);
      if (!domWindow)
        return NS_ERROR_FAILURE;
      else {
        PRBool needTooltip;
        targetEl->HasAttribute(NS_LITERAL_STRING("tooltiptext"), &needTooltip);
        if (needTooltip) {
          // specifying tooltiptext means we will always use the default tooltip
           mRootBox->GetDefaultTooltip(aTooltip);
           NS_IF_ADDREF(*aTooltip);
           return NS_OK;
        } else {
          nsAutoString tooltipId;
          targetEl->GetAttribute(NS_LITERAL_STRING("tooltip"), tooltipId);

          // if tooltip == _child, look for first <tooltip> child
          if (tooltipId.EqualsLiteral("_child")) {
            GetImmediateChild(aTarget, nsXULAtoms::tooltip, aTooltip);
            return NS_OK;
          } else {
            if (!tooltipId.IsEmpty()) {
              // tooltip must be an id, use getElementById to find it
              nsCOMPtr<nsIDOMDocument> domDocument =
                do_QueryInterface(document);
              if (!domDocument) {
                return NS_ERROR_FAILURE;
              }

              nsCOMPtr<nsIDOMElement> tooltipEl;
              domDocument->GetElementById(tooltipId,
                                          getter_AddRefs(tooltipEl));

              if (tooltipEl) {
#ifdef MOZ_XUL
                mNeedTitletip = PR_FALSE;
#endif

                nsCOMPtr<nsIContent> tooltipContent(do_QueryInterface(tooltipEl));
                *aTooltip = tooltipContent;
                NS_IF_ADDREF(*aTooltip);

                return NS_OK;
              }
            }
          }
        }

#ifdef MOZ_XUL
        // titletips should just use the default tooltip
        if (mIsSourceTree && mNeedTitletip) {
          mRootBox->GetDefaultTooltip(aTooltip);
          NS_IF_ADDREF(*aTooltip);
          return NS_OK;
        }
#endif
      }
    }
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

This method is called whenever an event occurs of the type for which the EventListener interface was registered.

Parameters:
evtThe Event contains contextual information about the event. It also contains the stopPropagation and preventDefault methods which are used in determining the event's flow and default action.

Definition at line 250 of file nsXULTooltipListener.cpp.

{
  nsAutoString type;
  aEvent->GetType(type);
  if (type.EqualsLiteral("DOMMouseScroll"))
    HideTooltip();
  return NS_OK;
}

Here is the call graph for this function:

Definition at line 528 of file nsXULTooltipListener.cpp.

{
  if (mCurrentTooltip) {
    // hide the popup through its box object
    nsCOMPtr<nsIDOMXULElement> tooltipEl(do_QueryInterface(mCurrentTooltip));
    nsCOMPtr<nsIBoxObject> boxObject;
    if (tooltipEl)
      tooltipEl->GetBoxObject(getter_AddRefs(boxObject));
    nsCOMPtr<nsIPopupBoxObject> popupObject(do_QueryInterface(boxObject));
    if (popupObject)
      popupObject->HidePopup();
  }

  DestroyTooltip();
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsXULTooltipListener::Init ( nsIContent aSourceNode,
nsIRootBox aRootBox 
)

Definition at line 288 of file nsXULTooltipListener.cpp.

{
  mRootBox = aRootBox;
  mSourceNode = aSourceNode;
  AddTooltipSupport(aSourceNode);
  
#ifdef MOZ_XUL
  // if the target is an treechildren, we may have some special
  // case handling to do
  mIsSourceTree = mSourceNode->Tag() == nsXULAtoms::treechildren;
#endif

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Processes a key pressed event.

Parameters:
aKeyEvent
See also:
nsIDOMEvent.h
Returns:
whether the event was consumed or ignored.
See also:
nsresult

Implements nsIDOMKeyListener.

Definition at line 239 of file nsXULTooltipListener.cpp.

{
  HideTooltip();
  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHOD nsXULTooltipListener::KeyPress ( nsIDOMEvent aKeyEvent) [inline, virtual]

Processes a key typed event.

Parameters:
aKeyEvent
See also:
nsIDOMEvent.h
Returns:
whether the event was consumed or ignored.
See also:
nsresult

Implements nsIDOMKeyListener.

Definition at line 85 of file nsXULTooltipListener.h.

{ return NS_OK; };
NS_IMETHOD nsXULTooltipListener::KeyUp ( nsIDOMEvent aKeyEvent) [inline, virtual]

Processes a key release event.

Parameters:
aKeyEvent
See also:
nsIDOMEvent.h
Returns:
whether the event was consumed or ignored.
See also:
nsresult

Implements nsIDOMKeyListener.

Definition at line 84 of file nsXULTooltipListener.h.

{ return NS_OK; };

Definition at line 687 of file nsXULTooltipListener.cpp.

Here is the caller graph for this function:

nsresult nsXULTooltipListener::LaunchTooltip ( nsIContent aTarget,
PRInt32  aX,
PRInt32  aY 
) [protected]

Definition at line 485 of file nsXULTooltipListener.cpp.

{
  if (!mCurrentTooltip)
    return NS_OK;

  nsCOMPtr<nsIBoxObject> popupBox;
  nsCOMPtr<nsIDOMXULElement> xulTooltipEl(do_QueryInterface(mCurrentTooltip));
  if (!xulTooltipEl) {
    NS_ERROR("tooltip isn't a XUL element!");
    return NS_ERROR_FAILURE;
  }

  xulTooltipEl->GetBoxObject(getter_AddRefs(popupBox));
  nsCOMPtr<nsIPopupBoxObject> popupBoxObject(do_QueryInterface(popupBox));
  if (popupBoxObject) {
    PRInt32 x = aX;
    PRInt32 y = aY;
#ifdef MOZ_XUL
    if (mNeedTitletip) {
      nsCOMPtr<nsITreeBoxObject> obx;
      GetSourceTreeBoxObject(getter_AddRefs(obx));
#ifdef DEBUG_crap
      GetTreeCellCoords(obx, mSourceNode,
                        mLastTreeRow, mLastTreeCol, &x, &y);
#endif

      SetTitletipLabel(obx, mCurrentTooltip, mLastTreeRow, mLastTreeCol);
      mCurrentTooltip->SetAttr(nsnull, nsXULAtoms::titletip, NS_LITERAL_STRING("true"), PR_TRUE);
    } else
      mCurrentTooltip->UnsetAttr(nsnull, nsXULAtoms::titletip, PR_TRUE);
#endif

    nsCOMPtr<nsIDOMElement> targetEl(do_QueryInterface(aTarget));
    popupBoxObject->ShowPopup(targetEl, xulTooltipEl, x, y,
                              NS_LITERAL_STRING("tooltip").get(),
                              NS_LITERAL_STRING("none").get(),
                              NS_LITERAL_STRING("topleft").get());
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHOD nsXULTooltipListener::MouseClick ( nsIDOMEvent aMouseEvent) [inline, virtual]

Processes a mouse click event.

Parameters:
aMouseEvent
See also:
nsIDOMEvent.h
Returns:
whether the event was consumed or ignored.
See also:
nsresult

Implements nsIDOMMouseListener.

Definition at line 73 of file nsXULTooltipListener.h.

{ return NS_OK; };
NS_IMETHOD nsXULTooltipListener::MouseDblClick ( nsIDOMEvent aMouseEvent) [inline, virtual]

Processes a mouse click event.

Parameters:
aMouseEvent
See also:
nsIDOMEvent.h
Returns:
whether the event was consumed or ignored.
See also:
nsresult

Implements nsIDOMMouseListener.

Definition at line 74 of file nsXULTooltipListener.h.

{ return NS_OK; };

Processes a mouse down event.

Parameters:
aMouseEvent
See also:
nsIDOMEvent.h
Returns:
whether the event was consumed or ignored.
See also:
nsresult

Implements nsIDOMMouseListener.

Definition at line 115 of file nsXULTooltipListener.cpp.

{
  HideTooltip();

  return NS_OK;
}

Processes a mouse move event.

Parameters:
aMouseEvent
See also:
nsIDOMEvent.h
Returns:
whether the event was consumed or ignored.
See also:
nsresult

Implements nsIDOMMouseMotionListener.

Definition at line 183 of file nsXULTooltipListener.cpp.

{
  if (!sShowTooltips)
    return NS_OK;

  // stash the coordinates of the event so that we can still get back to it from within the 
  // timer callback. On win32, we'll get a MouseMove event even when a popup goes away --
  // even when the mouse doesn't change position! To get around this, we make sure the
  // mouse has really moved before proceeding.
  nsCOMPtr<nsIDOMMouseEvent> mouseEvent(do_QueryInterface(aMouseEvent));
  PRInt32 newMouseX, newMouseY;
  mouseEvent->GetClientX(&newMouseX);
  mouseEvent->GetClientY(&newMouseY);
  if (mMouseClientX == newMouseX && mMouseClientY == newMouseY)
    return NS_OK;
  mMouseClientX = newMouseX;
  mMouseClientY = newMouseY;

#ifdef MOZ_XUL
  if (mIsSourceTree)
    CheckTreeBodyMove(mouseEvent);
#endif

  // as the mouse moves, we want to make sure we reset the timer to show it, 
  // so that the delay is from when the mouse stops moving, not when it enters
  // the node.
  KillTooltipTimer();
    
  // If the mouse moves while the tooltip is up, don't do anything. We make it
  // go away only if it times out or leaves the target node. If nothing is
  // showing, though, we have to do the work.
  if (!mCurrentTooltip) {
    mTooltipTimer = do_CreateInstance("@mozilla.org/timer;1");
    if (mTooltipTimer) {
      nsCOMPtr<nsIDOMEventTarget> eventTarget;
      aMouseEvent->GetTarget(getter_AddRefs(eventTarget));
      if (eventTarget) {
        nsCOMPtr<nsIContent> targetContent(do_QueryInterface(eventTarget));
        mTargetNode = targetContent;
      }
      if (mTargetNode) {
        nsresult rv = mTooltipTimer->InitWithFuncCallback(sTooltipCallback, this, 
                                                          kTooltipShowTime, nsITimer::TYPE_ONE_SHOT);
        if (NS_FAILED(rv))
          mTargetNode = nsnull;
      }
    }
  }

  return NS_OK;
}

Here is the call graph for this function:

Processes a mouse leave event.

Parameters:
aMouseEvent
See also:
nsIDOMEvent.h
Returns:
whether the event was consumed or ignored.
See also:
nsresult

Implements nsIDOMMouseListener.

Definition at line 131 of file nsXULTooltipListener.cpp.

{
  // if the timer is running and no tooltip is shown, we
  // have to cancel the timer here so that it doesn't 
  // show the tooltip if we move the mouse out of the window
  if (mTooltipTimer && !mCurrentTooltip) {
    mTooltipTimer->Cancel();
    mTooltipTimer = nsnull;
    return NS_OK;
  }

#ifdef DEBUG_crap
  if (mNeedTitletip)
    return NS_OK;
#endif

  // check to see if the mouse left the targetNode, and if so,
  // hide the tooltip
  if (mCurrentTooltip) {
    // which node did the mouse leave?
    nsCOMPtr<nsIDOMEventTarget> eventTarget;
    aMouseEvent->GetTarget(getter_AddRefs(eventTarget));
    nsCOMPtr<nsIDOMNode> targetNode(do_QueryInterface(eventTarget));

    // which node is our tooltip on?
    nsCOMPtr<nsIDOMXULDocument2> xulDoc(do_QueryInterface(mCurrentTooltip->GetDocument()));
    if (!xulDoc)     // remotely possible someone could have 
      return NS_OK;  // removed tooltip from dom while it was open
    nsCOMPtr<nsIDOMNode> tooltipNode;
    xulDoc->TrustedGetTooltipNode (getter_AddRefs(tooltipNode));

    // if they're the same, the mouse left the node the tooltip appeared on,
    // close the tooltip.
    if (tooltipNode == targetNode) {
      HideTooltip();
#ifdef MOZ_XUL
      // reset special tree tracking
      if (mIsSourceTree) {
        mLastTreeRow = -1;
        mLastTreeCol = nsnull;
      }
#endif
    }
  }

  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHOD nsXULTooltipListener::MouseOver ( nsIDOMEvent aMouseEvent) [inline, virtual]

Processes a mouse enter event.

Parameters:
aMouseEvent
See also:
nsIDOMEvent.h
Returns:
whether the event was consumed or ignored.
See also:
nsresult

Implements nsIDOMMouseListener.

Definition at line 75 of file nsXULTooltipListener.h.

{ return NS_OK; };

Processes a mouse up event.

Parameters:
aMouseEvent
See also:
nsIDOMEvent.h
Returns:
whether the event was consumed or ignored.
See also:
nsresult

Implements nsIDOMMouseListener.

Definition at line 123 of file nsXULTooltipListener.cpp.

{
  HideTooltip();

  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHOD nsXULTooltipListener::PopupHidden ( nsIDOMEvent aEvent) [inline, virtual]

Implements nsIDOMXULListener.

Definition at line 91 of file nsXULTooltipListener.h.

{ return NS_OK; };

Implements nsIDOMXULListener.

Definition at line 274 of file nsXULTooltipListener.cpp.

{
  DestroyTooltip();
  return NS_OK;
}

Here is the call graph for this function:

Implements nsIDOMXULListener.

Definition at line 88 of file nsXULTooltipListener.h.

{ return NS_OK; };
NS_IMETHOD nsXULTooltipListener::PopupShown ( nsIDOMEvent aEvent) [inline, virtual]

Implements nsIDOMXULListener.

Definition at line 89 of file nsXULTooltipListener.h.

{ return NS_OK; };

Definition at line 317 of file nsXULTooltipListener.cpp.

{
  if (!aNode)
    return NS_ERROR_NULL_POINTER;

  nsCOMPtr<nsIDOMEventTarget> evtTarget(do_QueryInterface(aNode));
  evtTarget->RemoveEventListener(NS_LITERAL_STRING("mouseout"), (nsIDOMMouseListener*)this, PR_FALSE);
  evtTarget->RemoveEventListener(NS_LITERAL_STRING("mousemove"), (nsIDOMMouseListener*)this, PR_FALSE);

  return NS_OK;
}

Here is the call graph for this function:

void nsXULTooltipListener::sAutoHideCallback ( nsITimer aTimer,
void aListener 
) [static, protected]

Definition at line 719 of file nsXULTooltipListener.cpp.

{
  nsXULTooltipListener* self = NS_STATIC_CAST(nsXULTooltipListener*, aListener);
  if (self) {
    nsCOMPtr<nsIDOMMouseListener> kungFuDeathGrip(self);
    self->HideTooltip();
  }
}

Here is the caller graph for this function:

Definition at line 388 of file nsXULTooltipListener.cpp.

{
  // get the tooltip content designated for the target node 
  GetTooltipFor(mSourceNode, getter_AddRefs(mCurrentTooltip));
  if (!mCurrentTooltip || mSourceNode == mCurrentTooltip)
    return NS_ERROR_FAILURE; // the target node doesn't need a tooltip

  // set the node in the document that triggered the tooltip and show it
  nsCOMPtr<nsIDOMXULDocument> xulDoc(do_QueryInterface(mCurrentTooltip->GetDocument()));
  if (xulDoc) {
    // Make sure the target node is still attached to some document. 
    // It might have been deleted.
    if (mSourceNode->GetDocument()) {
#ifdef MOZ_XUL
      if (!mIsSourceTree) {
        mLastTreeRow = -1;
        mLastTreeCol = nsnull;
      }
#endif

      nsCOMPtr<nsIDOMNode> targetNode(do_QueryInterface(mTargetNode));
      xulDoc->SetTooltipNode(targetNode);
      LaunchTooltip(mSourceNode, mMouseClientX, mMouseClientY);
      mTargetNode = nsnull;

      // at this point, |mCurrentTooltip| holds the content node of
      // the tooltip. If there is an attribute on the popup telling us
      // not to create the auto-hide timer, don't.
      nsCOMPtr<nsIDOMElement> tooltipEl(do_QueryInterface(mCurrentTooltip));
      if (!tooltipEl)
        return NS_ERROR_FAILURE;
      nsAutoString noAutoHide;
      tooltipEl->GetAttribute(NS_LITERAL_STRING("noautohide"), noAutoHide);
      if (!noAutoHide.EqualsLiteral("true"))
        CreateAutoHideTimer();

      // listen for popuphidden on the tooltip node, so that we can
      // be sure DestroyPopup is called even if someone else closes the tooltip
      nsCOMPtr<nsIDOMEventTarget> evtTarget(do_QueryInterface(mCurrentTooltip));
      evtTarget->AddEventListener(NS_LITERAL_STRING("popuphiding"), 
                                  (nsIDOMMouseListener*)this, PR_FALSE);

      // listen for mousedown, mouseup, keydown, and DOMMouseScroll events at document level
      nsIDocument* doc = mSourceNode->GetDocument();
      if (doc) {
        evtTarget = do_QueryInterface(doc);
        evtTarget->AddEventListener(NS_LITERAL_STRING("DOMMouseScroll"), 
                                    (nsIDOMMouseListener*)this, PR_TRUE);
        evtTarget->AddEventListener(NS_LITERAL_STRING("mousedown"), 
                                    (nsIDOMMouseListener*)this, PR_TRUE);
        evtTarget->AddEventListener(NS_LITERAL_STRING("mouseup"), 
                                    (nsIDOMMouseListener*)this, PR_TRUE);                                    
        evtTarget->AddEventListener(NS_LITERAL_STRING("keydown"), 
                                    (nsIDOMMouseListener*)this, PR_TRUE);
      }
    }
  }

  return NS_OK;
}

Here is the call graph for this function:

void nsXULTooltipListener::sTooltipCallback ( nsITimer aTimer,
void aListener 
) [static, protected]

Definition at line 711 of file nsXULTooltipListener.cpp.

{
  nsXULTooltipListener* self = NS_STATIC_CAST(nsXULTooltipListener*, aListener);
  if (self)
    self->ShowTooltip();
}

Here is the caller graph for this function:

static int nsXULTooltipListener::sTooltipPrefChanged ( const char *  aPref,
void aData 
) [static, protected]
int nsXULTooltipListener::ToolbarTipsPrefChanged ( const char *  aPref,
void aClosure 
) [static, protected]

Definition at line 264 of file nsXULTooltipListener.cpp.

{
  sShowTooltips = nsContentUtils::GetBoolPref("browser.chrome.toolbar_tips",
                                              sShowTooltips);

  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 140 of file nsXULTooltipListener.h.

Definition at line 132 of file nsXULTooltipListener.h.

Definition at line 137 of file nsXULTooltipListener.h.

Definition at line 137 of file nsXULTooltipListener.h.

Definition at line 129 of file nsXULTooltipListener.h.

Definition at line 130 of file nsXULTooltipListener.h.

Definition at line 131 of file nsXULTooltipListener.h.

Definition at line 135 of file nsXULTooltipListener.h.

Definition at line 110 of file nsXULTooltipListener.h.

Definition at line 111 of file nsXULTooltipListener.h.


The documentation for this class was generated from the following files: