mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-27 01:27:30 +09:00
ported from mozilla:
- Bug 148624 - only show tooltip when document has focus. r=emilio (8ae372dc88d1) - Bug 1857513 - Use window activeness rather than document.hasFocus() to display chrome-only tooltips. r=smaug (4cbf370b4e16)
This commit is contained in:
parent
e90473bdda
commit
f3deac5f5f
1 changed files with 42 additions and 39 deletions
|
|
@ -390,51 +390,54 @@ nsXULTooltipListener::ShowTooltip()
|
||||||
return NS_ERROR_FAILURE; // the target node doesn't need a tooltip
|
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
|
// set the node in the document that triggered the tooltip and show it
|
||||||
nsCOMPtr<nsIDOMXULDocument> xulDoc =
|
// Make sure the document still has focus.
|
||||||
do_QueryInterface(tooltipNode->GetComposedDoc());
|
nsIDocument* doc = tooltipNode->GetComposedDoc();
|
||||||
if (xulDoc) {
|
if (!doc || !nsContentUtils::IsChromeDoc(doc) ||
|
||||||
// Make sure the target node is still attached to some document.
|
doc->GetDocumentState().HasState(NS_DOCUMENT_STATE_WINDOW_INACTIVE)) {
|
||||||
// It might have been deleted.
|
return NS_OK;
|
||||||
if (sourceNode->IsInComposedDoc()) {
|
}
|
||||||
|
|
||||||
|
// Make sure the target node is still attached to some document.
|
||||||
|
// It might have been deleted.
|
||||||
|
if (sourceNode->IsInComposedDoc()) {
|
||||||
#ifdef MOZ_XUL
|
#ifdef MOZ_XUL
|
||||||
if (!mIsSourceTree) {
|
if (!mIsSourceTree) {
|
||||||
mLastTreeRow = -1;
|
mLastTreeRow = -1;
|
||||||
mLastTreeCol = nullptr;
|
mLastTreeCol = nullptr;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mCurrentTooltip = do_GetWeakReference(tooltipNode);
|
mCurrentTooltip = do_GetWeakReference(tooltipNode);
|
||||||
LaunchTooltip();
|
LaunchTooltip();
|
||||||
mTargetNode = nullptr;
|
mTargetNode = nullptr;
|
||||||
|
|
||||||
nsCOMPtr<nsIContent> currentTooltip = do_QueryReferent(mCurrentTooltip);
|
nsCOMPtr<nsIContent> currentTooltip = do_QueryReferent(mCurrentTooltip);
|
||||||
if (!currentTooltip)
|
if (!currentTooltip)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
||||||
// listen for popuphidden on the tooltip node, so that we can
|
// listen for popuphidden on the tooltip node, so that we can
|
||||||
// be sure DestroyPopup is called even if someone else closes the tooltip
|
// be sure DestroyPopup is called even if someone else closes the tooltip
|
||||||
currentTooltip->AddSystemEventListener(NS_LITERAL_STRING("popuphiding"),
|
currentTooltip->AddSystemEventListener(NS_LITERAL_STRING("popuphiding"),
|
||||||
this, false, false);
|
this, false, false);
|
||||||
|
|
||||||
// listen for mousedown, mouseup, keydown, and DOMMouseScroll events at document level
|
// listen for mousedown, mouseup, keydown, and DOMMouseScroll events at document level
|
||||||
nsIDocument* doc = sourceNode->GetComposedDoc();
|
doc = sourceNode->GetComposedDoc();
|
||||||
if (doc) {
|
if (doc) {
|
||||||
// Probably, we should listen to untrusted events for hiding tooltips
|
// Probably, we should listen to untrusted events for hiding tooltips
|
||||||
// on content since tooltips might disturb something of web
|
// on content since tooltips might disturb something of web
|
||||||
// applications. If we don't specify the aWantsUntrusted of
|
// applications. If we don't specify the aWantsUntrusted of
|
||||||
// AddSystemEventListener(), the event target sets it to TRUE if the
|
// AddSystemEventListener(), the event target sets it to TRUE if the
|
||||||
// target is in content.
|
// target is in content.
|
||||||
doc->AddSystemEventListener(NS_LITERAL_STRING("DOMMouseScroll"),
|
doc->AddSystemEventListener(NS_LITERAL_STRING("DOMMouseScroll"),
|
||||||
this, true);
|
this, true);
|
||||||
doc->AddSystemEventListener(NS_LITERAL_STRING("mousedown"),
|
doc->AddSystemEventListener(NS_LITERAL_STRING("mousedown"),
|
||||||
this, true);
|
this, true);
|
||||||
doc->AddSystemEventListener(NS_LITERAL_STRING("mouseup"),
|
doc->AddSystemEventListener(NS_LITERAL_STRING("mouseup"),
|
||||||
this, true);
|
this, true);
|
||||||
doc->AddSystemEventListener(NS_LITERAL_STRING("keydown"),
|
doc->AddSystemEventListener(NS_LITERAL_STRING("keydown"),
|
||||||
this, true);
|
this, true);
|
||||||
}
|
|
||||||
mSourceNode = nullptr;
|
|
||||||
}
|
}
|
||||||
|
mSourceNode = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue