diff --git a/mozilla/content/events/src/nsEventStateManager.cpp b/mozilla/content/events/src/nsEventStateManager.cpp index c016fb0afab..ef526f77b83 100644 --- a/mozilla/content/events/src/nsEventStateManager.cpp +++ b/mozilla/content/events/src/nsEventStateManager.cpp @@ -330,7 +330,32 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext, blurevent.message = NS_BLUR_CONTENT; if(gLastFocusedPresContext) { + nsCOMPtr commandDispatcher; + nsCOMPtr ourGlobal; + gLastFocusedDocument->GetScriptGlobalObject(getter_AddRefs(ourGlobal)); + nsCOMPtr rootWindow; + nsCOMPtr ourWindow = do_QueryInterface(ourGlobal); + if(ourWindow) { + ourWindow->GetPrivateRoot(getter_AddRefs(rootWindow)); + if(rootWindow) { + nsCOMPtr rootDocument; + rootWindow->GetDocument(getter_AddRefs(rootDocument)); + + nsCOMPtr xulDoc = do_QueryInterface(rootDocument); + if(xulDoc) { + xulDoc->GetCommandDispatcher(getter_AddRefs(commandDispatcher)); + if (commandDispatcher) { + commandDispatcher->SetSuppressFocus(PR_TRUE); + } + } + } + } + gLastFocusedDocument->HandleDOMEvent(gLastFocusedPresContext, &blurevent, nsnull, NS_EVENT_FLAG_INIT, &blurstatus); + + if (commandDispatcher) { + commandDispatcher->SetSuppressFocus(PR_FALSE); + } } } diff --git a/mozilla/layout/events/src/nsEventStateManager.cpp b/mozilla/layout/events/src/nsEventStateManager.cpp index c016fb0afab..ef526f77b83 100644 --- a/mozilla/layout/events/src/nsEventStateManager.cpp +++ b/mozilla/layout/events/src/nsEventStateManager.cpp @@ -330,7 +330,32 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext, blurevent.message = NS_BLUR_CONTENT; if(gLastFocusedPresContext) { + nsCOMPtr commandDispatcher; + nsCOMPtr ourGlobal; + gLastFocusedDocument->GetScriptGlobalObject(getter_AddRefs(ourGlobal)); + nsCOMPtr rootWindow; + nsCOMPtr ourWindow = do_QueryInterface(ourGlobal); + if(ourWindow) { + ourWindow->GetPrivateRoot(getter_AddRefs(rootWindow)); + if(rootWindow) { + nsCOMPtr rootDocument; + rootWindow->GetDocument(getter_AddRefs(rootDocument)); + + nsCOMPtr xulDoc = do_QueryInterface(rootDocument); + if(xulDoc) { + xulDoc->GetCommandDispatcher(getter_AddRefs(commandDispatcher)); + if (commandDispatcher) { + commandDispatcher->SetSuppressFocus(PR_TRUE); + } + } + } + } + gLastFocusedDocument->HandleDOMEvent(gLastFocusedPresContext, &blurevent, nsnull, NS_EVENT_FLAG_INIT, &blurstatus); + + if (commandDispatcher) { + commandDispatcher->SetSuppressFocus(PR_FALSE); + } } }