diff --git a/content/events/src/nsEventStateManager.cpp b/content/events/src/nsEventStateManager.cpp index c016fb0afab4..ef526f77b830 100644 --- a/content/events/src/nsEventStateManager.cpp +++ b/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/layout/events/src/nsEventStateManager.cpp b/layout/events/src/nsEventStateManager.cpp index c016fb0afab4..ef526f77b830 100644 --- a/layout/events/src/nsEventStateManager.cpp +++ b/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); + } } }