summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBasilisk-Dev <basiliskdev@protonmail.com>2023-10-16 10:13:10 -0400
committerBasilisk-Dev <basiliskdev@protonmail.com>2023-10-16 10:13:10 -0400
commit2b1281f2c91acdcba4d3499d537633607daa7966 (patch)
tree2c22248e4e7d54ff1ffea413ba9032e6b65c3e56
parent087febcc4b017a0af4ec82b1283341c8d979a17e (diff)
downloaduxp-2b1281f2c91acdcba4d3499d537633607daa7966.tar.gz
Backport of Mozilla tooltip bugs:
Bug 148624 - only show tooltip when document has focus Partial Bug 1857513 - Use window activeness rather than document.hasFocus() to display chrome-only tooltips
-rw-r--r--layout/xul/nsXULTooltipListener.cpp81
1 files changed, 42 insertions, 39 deletions
diff --git a/layout/xul/nsXULTooltipListener.cpp b/layout/xul/nsXULTooltipListener.cpp
index eefeec3599..484919f1f3 100644
--- a/layout/xul/nsXULTooltipListener.cpp
+++ b/layout/xul/nsXULTooltipListener.cpp
@@ -376,49 +376,52 @@ nsXULTooltipListener::ShowTooltip()
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(tooltipNode->GetComposedDoc());
- if (xulDoc) {
- // Make sure the target node is still attached to some document.
- // It might have been deleted.
- if (sourceNode->IsInComposedDoc()) {
- if (!mIsSourceTree) {
- mLastTreeRow = -1;
- mLastTreeCol = nullptr;
- }
+ // Make sure the document still has focus.
+ nsIDocument* doc = tooltipNode->GetComposedDoc();
+ if (!doc || !nsContentUtils::IsChromeDoc(doc) ||
+ doc->GetDocumentState().HasState(NS_DOCUMENT_STATE_WINDOW_INACTIVE)) {
+ return NS_OK;
+ }
- mCurrentTooltip = do_GetWeakReference(tooltipNode);
- LaunchTooltip();
- mTargetNode = nullptr;
+ // Make sure the target node is still attached to some document.
+ // It might have been deleted.
+ if (sourceNode->IsInComposedDoc()) {
+ if (!mIsSourceTree) {
+ mLastTreeRow = -1;
+ mLastTreeCol = nullptr;
+ }
- nsCOMPtr<nsIContent> currentTooltip = do_QueryReferent(mCurrentTooltip);
- if (!currentTooltip)
- return NS_OK;
+ mCurrentTooltip = do_GetWeakReference(tooltipNode);
+ LaunchTooltip();
+ mTargetNode = nullptr;
- // listen for popuphidden on the tooltip node, so that we can
- // be sure DestroyPopup is called even if someone else closes the tooltip
- currentTooltip->AddSystemEventListener(NS_LITERAL_STRING("popuphiding"),
- this, false, false);
-
- // listen for mousedown, mouseup, keydown, and DOMMouseScroll events at document level
- nsIDocument* doc = sourceNode->GetComposedDoc();
- if (doc) {
- // Probably, we should listen to untrusted events for hiding tooltips
- // on content since tooltips might disturb something of web
- // applications. If we don't specify the aWantsUntrusted of
- // AddSystemEventListener(), the event target sets it to TRUE if the
- // target is in content.
- doc->AddSystemEventListener(NS_LITERAL_STRING("DOMMouseScroll"),
- this, true);
- doc->AddSystemEventListener(NS_LITERAL_STRING("mousedown"),
- this, true);
- doc->AddSystemEventListener(NS_LITERAL_STRING("mouseup"),
- this, true);
- doc->AddSystemEventListener(NS_LITERAL_STRING("keydown"),
- this, true);
- }
- mSourceNode = nullptr;
+ nsCOMPtr<nsIContent> currentTooltip = do_QueryReferent(mCurrentTooltip);
+ if (!currentTooltip)
+ return NS_OK;
+
+ // listen for popuphidden on the tooltip node, so that we can
+ // be sure DestroyPopup is called even if someone else closes the tooltip
+ currentTooltip->AddSystemEventListener(NS_LITERAL_STRING("popuphiding"),
+ this, false, false);
+
+ // listen for mousedown, mouseup, keydown, and DOMMouseScroll events at document level
+ doc = sourceNode->GetComposedDoc();
+ if (doc) {
+ // Probably, we should listen to untrusted events for hiding tooltips
+ // on content since tooltips might disturb something of web
+ // applications. If we don't specify the aWantsUntrusted of
+ // AddSystemEventListener(), the event target sets it to TRUE if the
+ // target is in content.
+ doc->AddSystemEventListener(NS_LITERAL_STRING("DOMMouseScroll"),
+ this, true);
+ doc->AddSystemEventListener(NS_LITERAL_STRING("mousedown"),
+ this, true);
+ doc->AddSystemEventListener(NS_LITERAL_STRING("mouseup"),
+ this, true);
+ doc->AddSystemEventListener(NS_LITERAL_STRING("keydown"),
+ this, true);
}
+ mSourceNode = nullptr;
}
return NS_OK;