From 7e64131458be69896c39583c6b5ceccc78e9d8ef Mon Sep 17 00:00:00 2001 From: "joe.chou%sun.com" Date: Tue, 12 Mar 2002 00:45:23 +0000 Subject: [PATCH] Use patch of 120209 to fix bug 124285, "Script focus control problem in Siebel app", a=jdunn git-svn-id: svn://10.0.0.236/branches/SUN_6_2_1_BRANCH@116357 18797224-902f-48f8-a5cc-f745e15eee43 --- .../events/src/nsEventStateManager.cpp | 58 ++++++++++--------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/mozilla/content/events/src/nsEventStateManager.cpp b/mozilla/content/events/src/nsEventStateManager.cpp index e7e968b43d0..819c28d21e4 100644 --- a/mozilla/content/events/src/nsEventStateManager.cpp +++ b/mozilla/content/events/src/nsEventStateManager.cpp @@ -398,40 +398,46 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext, gLastFocusedDocument->GetScriptGlobalObject(getter_AddRefs(ourGlobal)); nsCOMPtr rootWindow; nsCOMPtr ourWindow = do_QueryInterface(ourGlobal); + PRBool isAlreadySuppressed = PR_FALSE; if(ourWindow) { ourWindow->GetRootFocusController(getter_AddRefs(focusController)); - if (focusController) + if (focusController) { + focusController->GetSuppressFocus(&isAlreadySuppressed); focusController->SetSuppressFocus(PR_TRUE, "NS_GOTFOCUS ESM Suppression"); + } } - gLastFocusedDocument->HandleDOMEvent(gLastFocusedPresContext, &blurevent, nsnull, NS_EVENT_FLAG_INIT, &blurstatus); - if (!mCurrentFocus && gLastFocusedContent) { - // must send it to the element that is losing focus, - // since SendFocusBlur wont be called - gLastFocusedContent->HandleDOMEvent(gLastFocusedPresContext, &blurevent, nsnull, NS_EVENT_FLAG_INIT, &blurstatus); - - nsCOMPtr doc; - gLastFocusedContent->GetDocument(*getter_AddRefs(doc)); - if (doc) { - nsCOMPtr shell; - doc->GetShellAt(0, getter_AddRefs(shell)); - if (shell) { - nsCOMPtr oldPresContext; - shell->GetPresContext(getter_AddRefs(oldPresContext)); - - nsEventStatus status = nsEventStatus_eIgnore; - nsEvent event; - event.eventStructType = NS_EVENT; - event.message = NS_BLUR_CONTENT; - nsCOMPtr esm; - oldPresContext->GetEventStateManager(getter_AddRefs(esm)); - esm->SetFocusedContent(gLastFocusedContent); - gLastFocusedContent->HandleDOMEvent(oldPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status); - esm->SetFocusedContent(nsnull); - NS_IF_RELEASE(gLastFocusedContent); + if (!isAlreadySuppressed) { + gLastFocusedDocument->HandleDOMEvent(gLastFocusedPresContext, &blurevent, nsnull, NS_EVENT_FLAG_INIT, &blurstatus); + if (!mCurrentFocus && gLastFocusedContent) { + // must send it to the element that is losing focus, + // since SendFocusBlur wont be called + gLastFocusedContent->HandleDOMEvent(gLastFocusedPresContext, &blurevent, nsnull, NS_EVENT_FLAG_INIT, &blurstatus); + + nsCOMPtr doc; + gLastFocusedContent->GetDocument(*getter_AddRefs(doc)); + if (doc) { + nsCOMPtr shell; + doc->GetShellAt(0, getter_AddRefs(shell)); + if (shell) { + nsCOMPtr oldPresContext; + shell->GetPresContext(getter_AddRefs(oldPresContext)); + + nsEventStatus status = nsEventStatus_eIgnore; + nsEvent event; + event.eventStructType = NS_EVENT; + event.message = NS_BLUR_CONTENT; + nsCOMPtr esm; + oldPresContext->GetEventStateManager(getter_AddRefs(esm)); + esm->SetFocusedContent(gLastFocusedContent); + gLastFocusedContent->HandleDOMEvent(oldPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status); + esm->SetFocusedContent(nsnull); + NS_IF_RELEASE(gLastFocusedContent); + } } } } + if (focusController) { focusController->SetSuppressFocus(PR_FALSE, "NS_GOTFOCUS ESM Suppression"); }