diff --git a/content/events/src/nsEventStateManager.cpp b/content/events/src/nsEventStateManager.cpp index 9dad3f04efe..9cb427066fa 100644 --- a/content/events/src/nsEventStateManager.cpp +++ b/content/events/src/nsEventStateManager.cpp @@ -358,7 +358,8 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext, } } - gLastFocusedDocument->HandleDOMEvent(gLastFocusedPresContext, &blurevent, nsnull, NS_EVENT_FLAG_INIT, &blurstatus); + if(gLastFocusedDocument != mDocument) + gLastFocusedDocument->HandleDOMEvent(gLastFocusedPresContext, &blurevent, nsnull, NS_EVENT_FLAG_INIT, &blurstatus); if (commandDispatcher) { commandDispatcher->SetSuppressFocus(PR_FALSE); @@ -372,7 +373,9 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext, if (globalObject) { nsIContent* currentFocus = mCurrentFocus; mCurrentFocus = nsnull; - mDocument->HandleDOMEvent(aPresContext, &focusevent, nsnull, NS_EVENT_FLAG_INIT, &status); + if(gLastFocusedDocument != mDocument) + mDocument->HandleDOMEvent(aPresContext, &focusevent, nsnull, NS_EVENT_FLAG_INIT, &status); + globalObject->HandleDOMEvent(aPresContext, &focusevent, nsnull, NS_EVENT_FLAG_INIT, &status); mCurrentFocus = currentFocus; } @@ -570,7 +573,7 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext, nsCOMPtr globalObject; if(gLastFocusedDocument) { gLastFocusedDocument->GetScriptGlobalObject(getter_AddRefs(globalObject)); - gLastFocusedDocument->HandleDOMEvent(gLastFocusedPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status); + //gLastFocusedDocument->HandleDOMEvent(gLastFocusedPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status); if(globalObject) globalObject->HandleDOMEvent(gLastFocusedPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status); } diff --git a/content/html/content/src/nsHTMLInputElement.cpp b/content/html/content/src/nsHTMLInputElement.cpp index b9fc471d8c0..a93da49d35e 100644 --- a/content/html/content/src/nsHTMLInputElement.cpp +++ b/content/html/content/src/nsHTMLInputElement.cpp @@ -768,7 +768,8 @@ nsHTMLInputElement::HandleDOMEvent(nsIPresContext* aPresContext, return rv; } - // Try script event handlers first + // Try script event handlers first if its not a focus/blur event + //we dont want the doc to get these nsresult ret = mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent, aFlags, aEventStatus); diff --git a/editor/base/nsEditorEventListeners.cpp b/editor/base/nsEditorEventListeners.cpp index 24aa019168f..e5a18c6df9e 100644 --- a/editor/base/nsEditorEventListeners.cpp +++ b/editor/base/nsEditorEventListeners.cpp @@ -1070,6 +1070,7 @@ nsTextEditorFocusListener::Focus(nsIDOMEvent* aEvent) if (mEditor) { PRUint32 flags; + aEvent->PreventBubble(); mEditor->GetFlags(&flags); if (! (flags & nsIHTMLEditor::eEditorDisabledMask)) { // only enable caret and selection if the editor is not disabled @@ -1115,6 +1116,7 @@ nsTextEditorFocusListener::Blur(nsIDOMEvent* aEvent) if (mEditor) { PRUint32 flags; + aEvent->PreventBubble(); mEditor->GetFlags(&flags); nsCOMPtreditor = do_QueryInterface(mEditor); if (editor) diff --git a/editor/libeditor/text/nsEditorEventListeners.cpp b/editor/libeditor/text/nsEditorEventListeners.cpp index 24aa019168f..e5a18c6df9e 100644 --- a/editor/libeditor/text/nsEditorEventListeners.cpp +++ b/editor/libeditor/text/nsEditorEventListeners.cpp @@ -1070,6 +1070,7 @@ nsTextEditorFocusListener::Focus(nsIDOMEvent* aEvent) if (mEditor) { PRUint32 flags; + aEvent->PreventBubble(); mEditor->GetFlags(&flags); if (! (flags & nsIHTMLEditor::eEditorDisabledMask)) { // only enable caret and selection if the editor is not disabled @@ -1115,6 +1116,7 @@ nsTextEditorFocusListener::Blur(nsIDOMEvent* aEvent) if (mEditor) { PRUint32 flags; + aEvent->PreventBubble(); mEditor->GetFlags(&flags); nsCOMPtreditor = do_QueryInterface(mEditor); if (editor) diff --git a/layout/events/src/nsEventStateManager.cpp b/layout/events/src/nsEventStateManager.cpp index 9dad3f04efe..9cb427066fa 100644 --- a/layout/events/src/nsEventStateManager.cpp +++ b/layout/events/src/nsEventStateManager.cpp @@ -358,7 +358,8 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext, } } - gLastFocusedDocument->HandleDOMEvent(gLastFocusedPresContext, &blurevent, nsnull, NS_EVENT_FLAG_INIT, &blurstatus); + if(gLastFocusedDocument != mDocument) + gLastFocusedDocument->HandleDOMEvent(gLastFocusedPresContext, &blurevent, nsnull, NS_EVENT_FLAG_INIT, &blurstatus); if (commandDispatcher) { commandDispatcher->SetSuppressFocus(PR_FALSE); @@ -372,7 +373,9 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext, if (globalObject) { nsIContent* currentFocus = mCurrentFocus; mCurrentFocus = nsnull; - mDocument->HandleDOMEvent(aPresContext, &focusevent, nsnull, NS_EVENT_FLAG_INIT, &status); + if(gLastFocusedDocument != mDocument) + mDocument->HandleDOMEvent(aPresContext, &focusevent, nsnull, NS_EVENT_FLAG_INIT, &status); + globalObject->HandleDOMEvent(aPresContext, &focusevent, nsnull, NS_EVENT_FLAG_INIT, &status); mCurrentFocus = currentFocus; } @@ -570,7 +573,7 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext, nsCOMPtr globalObject; if(gLastFocusedDocument) { gLastFocusedDocument->GetScriptGlobalObject(getter_AddRefs(globalObject)); - gLastFocusedDocument->HandleDOMEvent(gLastFocusedPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status); + //gLastFocusedDocument->HandleDOMEvent(gLastFocusedPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status); if(globalObject) globalObject->HandleDOMEvent(gLastFocusedPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status); } diff --git a/layout/html/content/src/nsHTMLInputElement.cpp b/layout/html/content/src/nsHTMLInputElement.cpp index b9fc471d8c0..a93da49d35e 100644 --- a/layout/html/content/src/nsHTMLInputElement.cpp +++ b/layout/html/content/src/nsHTMLInputElement.cpp @@ -768,7 +768,8 @@ nsHTMLInputElement::HandleDOMEvent(nsIPresContext* aPresContext, return rv; } - // Try script event handlers first + // Try script event handlers first if its not a focus/blur event + //we dont want the doc to get these nsresult ret = mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent, aFlags, aEventStatus);