summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2023-10-17 14:30:19 +0000
committerMoonchild <moonchild@palemoon.org>2023-10-17 14:30:19 +0000
commit6076431d7c6541cd285a24a34a8bd8f2f554cfb9 (patch)
treef5264a0696609c4356a2c343374d288699231893
parent60b4d804bd8f29582df32db7e862e1e91b221e69 (diff)
parent2b1281f2c91acdcba4d3499d537633607daa7966 (diff)
downloaduxp-6076431d7c6541cd285a24a34a8bd8f2f554cfb9.tar.gz
Merge pull request 'Backport of Mozilla tooltip bugs' (#2347) from Basilisk-Dev/UXP-contrib:master into master
Reviewed-on: https://repo.palemoon.org/MoonchildProductions/UXP/pulls/2347
-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;