Bug 497434 - Tooltips no longer shown for bookmarks in places' menupopups, r=neil, mak

This commit is contained in:
Neil Deakin 2009-09-14 13:06:33 +02:00
Родитель 46c99060e1
Коммит 752031a4ab
5 изменённых файлов: 27 добавлений и 19 удалений

Просмотреть файл

@ -464,7 +464,7 @@
onpopupshowing="HistoryMenu.onPopupShowing(event);"
onpopuphidden="HistoryMenu.onPopupHidden(event);"
place="place:redirectsMode=2&sort=4&maxResults=10"
tooltip="bhTooltip">
tooltip="bhTooltip" popupsinherittooltip="true">
<menuitem id="historyMenuBack"
label="&backCmd.label;"
#ifdef XP_MACOSX
@ -526,7 +526,7 @@
oncommand="BookmarksEventHandler.onCommand(event);"
onclick="BookmarksEventHandler.onClick(event);"
onpopupshowing="BookmarksEventHandler.onPopupShowing(event);"
tooltip="bhTooltip">
tooltip="bhTooltip" popupsinherittooltip="true">
<menuitem id="menu_bookmarkThisPage"
label="&bookmarkThisPageCmd.label;"
command="Browser:AddBookmarkAs"

Просмотреть файл

@ -451,7 +451,7 @@
onclick="BookmarksEventHandler.onClick(event);"
oncommand="BookmarksEventHandler.onCommand(event);"
onpopupshowing="BookmarksEventHandler.onPopupShowing(event);"
tooltip="bhTooltip"/>
tooltip="bhTooltip" popupsinherittooltip="true"/>
</toolbaritem>
<toolbarbutton id="downloads-button" class="toolbarbutton-1 chromeclass-toolbar-additional"

Просмотреть файл

@ -78,6 +78,7 @@
tooltiptext="&bookmarksToolbarChevron.tooltip;"
onpopupshowing="_onChevronPopupShowing(event);">
<xul:menupopup anonid="chevronPopup"
popupsinherittooltip="true"
xbl:inherits="tooltip"
#ifndef XP_MACOSX
context="placesContext"

Просмотреть файл

@ -732,6 +732,7 @@ GK_ATOM(popuplistener, "popuplistener")
GK_ATOM(popupset, "popupset")
GK_ATOM(popupshowing, "popupshowing")
GK_ATOM(popupshown, "popupshown")
GK_ATOM(popupsinherittooltip, "popupsinherittooltip")
GK_ATOM(position, "position")
#ifdef MOZ_MEDIA
GK_ATOM(poster, "poster")

Просмотреть файл

@ -224,10 +224,10 @@ nsXULTooltipListener::MouseMove(nsIDOMEvent* aMouseEvent)
mMouseScreenY = newMouseY;
mCachedMouseEvent = aMouseEvent;
nsCOMPtr<nsIDOMEventTarget> eventTarget;
aMouseEvent->GetCurrentTarget(getter_AddRefs(eventTarget));
nsCOMPtr<nsIDOMEventTarget> currentTarget;
aMouseEvent->GetCurrentTarget(getter_AddRefs(currentTarget));
nsCOMPtr<nsIContent> sourceContent = do_QueryInterface(eventTarget);
nsCOMPtr<nsIContent> sourceContent = do_QueryInterface(currentTarget);
mSourceNode = do_GetWeakReference(sourceContent);
#ifdef MOZ_XUL
mIsSourceTree = sourceContent->Tag() == nsGkAtoms::treechildren;
@ -244,22 +244,28 @@ nsXULTooltipListener::MouseMove(nsIDOMEvent* aMouseEvent)
// showing and the tooltip hasn't been displayed since the mouse entered
// the node, then start the timer to show the tooltip.
if (!currentTooltip && !mTooltipShownOnce) {
// don't show tooltips attached to elements outside of a menu popup
// when hovering over an element inside it.
nsCOMPtr<nsIDOMEventTarget> eventTarget;
aMouseEvent->GetTarget(getter_AddRefs(eventTarget));
nsCOMPtr<nsIContent> targetContent = do_QueryInterface(eventTarget);
while (targetContent && targetContent != sourceContent) {
nsIAtom* tag = targetContent->Tag();
if (targetContent->GetNameSpaceID() == kNameSpaceID_XUL &&
(tag == nsGkAtoms::menupopup ||
tag == nsGkAtoms::panel ||
tag == nsGkAtoms::tooltip)) {
mSourceNode = nsnull;
return NS_OK;
}
targetContent = targetContent->GetParent();
// don't show tooltips attached to elements outside of a menu popup
// when hovering over an element inside it. The popupsinherittooltip
// attribute may be used to disable this behaviour, which is useful for
// large menu hierarchies such as bookmarks.
if (!sourceContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::popupsinherittooltip,
nsGkAtoms::_true, eCaseMatters)) {
nsCOMPtr<nsIContent> targetContent = do_QueryInterface(eventTarget);
while (targetContent && targetContent != sourceContent) {
nsIAtom* tag = targetContent->Tag();
if (targetContent->GetNameSpaceID() == kNameSpaceID_XUL &&
(tag == nsGkAtoms::menupopup ||
tag == nsGkAtoms::panel ||
tag == nsGkAtoms::tooltip)) {
mSourceNode = nsnull;
return NS_OK;
}
targetContent = targetContent->GetParent();
}
}
mTooltipTimer = do_CreateInstance("@mozilla.org/timer;1");