# HG changeset patch # User Jorg K # Parent af7b29ab0d7e11b0348f70ee8e329eed6c16f7bb Bug 1205983 - Filter out events from irrelevant nodes. r=roc diff --git a/editor/composer/test/chrome.ini b/editor/composer/test/chrome.ini --- a/editor/composer/test/chrome.ini +++ b/editor/composer/test/chrome.ini @@ -4,8 +4,9 @@ skip-if = buildapp == 'b2g' || os == 'an [test_async_UpdateCurrentDictionary.html] [test_bug338427.html] [test_bug434998.xul] [test_bug678842.html] [test_bug697981.html] [test_bug717433.html] [test_bug1204147.html] [test_bug1200533.html] +[test_bug1205983.html] diff --git a/editor/composer/test/test_bug1205983.html b/editor/composer/test/test_bug1205983.html new file mode 100644 --- /dev/null +++ b/editor/composer/test/test_bug1205983.html @@ -0,0 +1,117 @@ + + + + + Test for Bug 1205983 + + + + +Mozilla Bug 1205983 +

+ + +
German heute ist ein guter Tag
+ + +
+
+
+ + diff --git a/editor/libeditor/nsEditorEventListener.cpp b/editor/libeditor/nsEditorEventListener.cpp --- a/editor/libeditor/nsEditorEventListener.cpp +++ b/editor/libeditor/nsEditorEventListener.cpp @@ -1109,17 +1109,34 @@ nsEditorEventListener::Focus(nsIDOMEvent nsCOMPtr element; fm->GetFocusedElement(getter_AddRefs(element)); if (!SameCOMIdentity(element, target)) { return NS_OK; } } } - mEditor->StartWatchingDictionaryChanges(); + // Filter out events for irrelevant nodes. + bool startWatch = true; + nsCOMPtr htmlEditor = + do_QueryInterface(static_cast(mEditor)); + if (htmlEditor) { + nsCOMPtr content = do_QueryInterface(node); + if (content) { + nsCOMPtr nodeEditingHost = content->GetEditingHost(); + nsCOMPtr editingHost = htmlEditor->GetActiveEditingHost(); + if (!(editingHost && nodeEditingHost && editingHost == nodeEditingHost)) { + startWatch = false; + } + } + } + + if (startWatch) { + mEditor->StartWatchingDictionaryChanges(); + } mEditor->OnFocus(target); nsCOMPtr ps = GetPresShell(); NS_ENSURE_TRUE(ps, NS_OK); nsCOMPtr focusedContent = mEditor->GetFocusedContentForIME(); IMEStateManager::OnFocusInEditor(ps->GetPresContext(), focusedContent, mEditor); @@ -1127,16 +1144,18 @@ nsEditorEventListener::Focus(nsIDOMEvent return NS_OK; } nsresult nsEditorEventListener::Blur(nsIDOMEvent* aEvent) { NS_ENSURE_TRUE(aEvent, NS_OK); + // Always stop the watch on blur, regardless of whether the node is + // deemed relevant or not. mEditor->StopWatchingDictionaryChanges(); // check if something else is focused. If another element is focused, then // we should not change the selection. nsIFocusManager* fm = nsFocusManager::GetFocusManager(); NS_ENSURE_TRUE(fm, NS_OK); nsCOMPtr element; diff --git a/extensions/spellcheck/hunspell/glue/mozHunspell.cpp b/extensions/spellcheck/hunspell/glue/mozHunspell.cpp --- a/extensions/spellcheck/hunspell/glue/mozHunspell.cpp +++ b/extensions/spellcheck/hunspell/glue/mozHunspell.cpp @@ -178,18 +178,28 @@ NS_IMETHODIMP mozHunspell::SetDictionary // XXX This isn't really good. nsIFile->NativePath isn't safe for all // character sets on Windows. // A better way would be to QI to nsIFile, and get a filehandle // from there. Only problem is that hunspell wants a path nsresult rv = affFile->GetNativePath(affFileName); NS_ENSURE_SUCCESS(rv, rv); - if (mAffixFileName.Equals(affFileName.get())) + if (mAffixFileName.Equals(affFileName.get())) { + // If the dictionary hasn't really changed, we still need to notify the + // observers. Depending on the focus, an observer might have become + // active that wasn't before and whose editor needs updating. + nsCOMPtr obs = mozilla::services::GetObserverService(); + if (obs) { + obs->NotifyObservers(nullptr, + SPELLCHECK_DICTIONARY_UPDATE_NOTIFICATION, + nullptr); + } return NS_OK; + } dictFileName = affFileName; int32_t dotPos = dictFileName.RFindChar('.'); if (dotPos == -1) return NS_ERROR_FAILURE; dictFileName.SetLength(dotPos); dictFileName.AppendLiteral(".dic");