From 0f2b50816adece2e430fd48eb7af23ea3510efca Mon Sep 17 00:00:00 2001 From: "hyatt%netscape.com" Date: Wed, 9 Jun 1999 01:07:31 +0000 Subject: [PATCH] Fix that makes the blur handler ultra-paranoid. It sanity checks its target before closing the window. (I'm having to do this since focus/blur events bubble. @#$@#$%#) git-svn-id: svn://10.0.0.236/trunk@34339 18797224-902f-48f8-a5cc-f745e15eee43 --- .../content/xul/content/src/nsXULPopupListener.cpp | 11 +++++++++-- mozilla/rdf/content/src/nsXULPopupListener.cpp | 11 +++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/mozilla/content/xul/content/src/nsXULPopupListener.cpp b/mozilla/content/xul/content/src/nsXULPopupListener.cpp index a207f0f8873..e038c160ac2 100644 --- a/mozilla/content/xul/content/src/nsXULPopupListener.cpp +++ b/mozilla/content/xul/content/src/nsXULPopupListener.cpp @@ -300,7 +300,10 @@ XULPopupListenerImpl::Blur(nsIDOMEvent* aMouseEvent) } // Blur events don't bubble, so this means our window lost focus. - // Close up, baby. + // Let's check just to make sure. + nsCOMPtr eventTarget; + aMouseEvent->GetTarget(getter_AddRefs(eventTarget)); + // We have some popup content. Obtain our window. nsIScriptContextOwner* owner = document->GetScriptContextOwner(); nsCOMPtr context; @@ -309,7 +312,11 @@ XULPopupListenerImpl::Blur(nsIDOMEvent* aMouseEvent) if (global) { // Get the DOM window nsCOMPtr domWindow = do_QueryInterface(global); - domWindow->Close(); + + // Close, but only if we are the same target. + nsCOMPtr windowNode = do_QueryInterface(domWindow); + if (windowNode.get() == eventTarget.get()) + domWindow->Close(); } } diff --git a/mozilla/rdf/content/src/nsXULPopupListener.cpp b/mozilla/rdf/content/src/nsXULPopupListener.cpp index a207f0f8873..e038c160ac2 100644 --- a/mozilla/rdf/content/src/nsXULPopupListener.cpp +++ b/mozilla/rdf/content/src/nsXULPopupListener.cpp @@ -300,7 +300,10 @@ XULPopupListenerImpl::Blur(nsIDOMEvent* aMouseEvent) } // Blur events don't bubble, so this means our window lost focus. - // Close up, baby. + // Let's check just to make sure. + nsCOMPtr eventTarget; + aMouseEvent->GetTarget(getter_AddRefs(eventTarget)); + // We have some popup content. Obtain our window. nsIScriptContextOwner* owner = document->GetScriptContextOwner(); nsCOMPtr context; @@ -309,7 +312,11 @@ XULPopupListenerImpl::Blur(nsIDOMEvent* aMouseEvent) if (global) { // Get the DOM window nsCOMPtr domWindow = do_QueryInterface(global); - domWindow->Close(); + + // Close, but only if we are the same target. + nsCOMPtr windowNode = do_QueryInterface(domWindow); + if (windowNode.get() == eventTarget.get()) + domWindow->Close(); } }