mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1205983 - Remove all observer code from nsEditor. r=ehsan
This commit is contained in:
parent
0a2a158744
commit
28555691e6
@ -636,13 +636,6 @@ nsEditorSpellCheck::SetCurrentDictionary(const nsAString& aDictionary)
|
|||||||
return mSpellChecker->SetCurrentDictionary(aDictionary);
|
return mSpellChecker->SetCurrentDictionary(aDictionary);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsEditorSpellCheck::CheckCurrentDictionary()
|
|
||||||
{
|
|
||||||
mSpellChecker->CheckCurrentDictionary();
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsEditorSpellCheck::UninitSpellChecker()
|
nsEditorSpellCheck::UninitSpellChecker()
|
||||||
{
|
{
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
#include "PlaceholderTxn.h" // for PlaceholderTxn
|
#include "PlaceholderTxn.h" // for PlaceholderTxn
|
||||||
#include "SplitNodeTxn.h" // for SplitNodeTxn
|
#include "SplitNodeTxn.h" // for SplitNodeTxn
|
||||||
#include "mozFlushType.h" // for mozFlushType::Flush_Frames
|
#include "mozFlushType.h" // for mozFlushType::Flush_Frames
|
||||||
#include "mozISpellCheckingEngine.h"
|
|
||||||
#include "mozInlineSpellChecker.h" // for mozInlineSpellChecker
|
#include "mozInlineSpellChecker.h" // for mozInlineSpellChecker
|
||||||
#include "mozilla/CheckedInt.h" // for CheckedInt
|
#include "mozilla/CheckedInt.h" // for CheckedInt
|
||||||
#include "mozilla/IMEStateManager.h" // for IMEStateManager
|
#include "mozilla/IMEStateManager.h" // for IMEStateManager
|
||||||
@ -79,7 +78,6 @@
|
|||||||
#include "nsIInlineSpellChecker.h" // for nsIInlineSpellChecker, etc
|
#include "nsIInlineSpellChecker.h" // for nsIInlineSpellChecker, etc
|
||||||
#include "nsNameSpaceManager.h" // for kNameSpaceID_None, etc
|
#include "nsNameSpaceManager.h" // for kNameSpaceID_None, etc
|
||||||
#include "nsINode.h" // for nsINode, etc
|
#include "nsINode.h" // for nsINode, etc
|
||||||
#include "nsIObserverService.h" // for nsIObserverService
|
|
||||||
#include "nsIPlaintextEditor.h" // for nsIPlaintextEditor, etc
|
#include "nsIPlaintextEditor.h" // for nsIPlaintextEditor, etc
|
||||||
#include "nsIPresShell.h" // for nsIPresShell
|
#include "nsIPresShell.h" // for nsIPresShell
|
||||||
#include "nsISelectionController.h" // for nsISelectionController, etc
|
#include "nsISelectionController.h" // for nsISelectionController, etc
|
||||||
@ -148,7 +146,6 @@ nsEditor::nsEditor()
|
|||||||
, mDispatchInputEvent(true)
|
, mDispatchInputEvent(true)
|
||||||
, mIsInEditAction(false)
|
, mIsInEditAction(false)
|
||||||
, mHidingCaret(false)
|
, mHidingCaret(false)
|
||||||
, mObservingDictionaryUpdates(false)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,7 +201,6 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsEditor)
|
|||||||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||||
NS_INTERFACE_MAP_ENTRY(nsIEditorIMESupport)
|
NS_INTERFACE_MAP_ENTRY(nsIEditorIMESupport)
|
||||||
NS_INTERFACE_MAP_ENTRY(nsIEditor)
|
NS_INTERFACE_MAP_ENTRY(nsIEditor)
|
||||||
NS_INTERFACE_MAP_ENTRY(nsIObserver)
|
|
||||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIEditor)
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIEditor)
|
||||||
NS_INTERFACE_MAP_END
|
NS_INTERFACE_MAP_END
|
||||||
|
|
||||||
@ -304,13 +300,6 @@ nsEditor::PostCreate()
|
|||||||
// update the UI with our state
|
// update the UI with our state
|
||||||
NotifyDocumentListeners(eDocumentCreated);
|
NotifyDocumentListeners(eDocumentCreated);
|
||||||
NotifyDocumentListeners(eDocumentStateChanged);
|
NotifyDocumentListeners(eDocumentStateChanged);
|
||||||
|
|
||||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
|
||||||
if (obs) {
|
|
||||||
obs->AddObserver(this,
|
|
||||||
SPELLCHECK_DICTIONARY_REMOVE_NOTIFICATION,
|
|
||||||
false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// update nsTextStateManager and caret if we have focus
|
// update nsTextStateManager and caret if we have focus
|
||||||
@ -448,14 +437,6 @@ nsEditor::PreDestroy(bool aDestroyingFrames)
|
|||||||
|
|
||||||
IMEStateManager::OnEditorDestroying(this);
|
IMEStateManager::OnEditorDestroying(this);
|
||||||
|
|
||||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
|
||||||
if (obs) {
|
|
||||||
obs->RemoveObserver(this,
|
|
||||||
SPELLCHECK_DICTIONARY_UPDATE_NOTIFICATION);
|
|
||||||
obs->RemoveObserver(this,
|
|
||||||
SPELLCHECK_DICTIONARY_REMOVE_NOTIFICATION);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Let spellchecker clean up its observers etc. It is important not to
|
// Let spellchecker clean up its observers etc. It is important not to
|
||||||
// actually free the spellchecker here, since the spellchecker could have
|
// actually free the spellchecker here, since the spellchecker could have
|
||||||
// caused flush notifications, which could have gotten here if a textbox
|
// caused flush notifications, which could have gotten here if a textbox
|
||||||
@ -1314,35 +1295,6 @@ NS_IMETHODIMP nsEditor::GetInlineSpellChecker(bool autoCreate,
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsEditor::Observe(nsISupports* aSubj, const char *aTopic,
|
|
||||||
const char16_t *aData)
|
|
||||||
{
|
|
||||||
NS_ASSERTION(!strcmp(aTopic,
|
|
||||||
SPELLCHECK_DICTIONARY_UPDATE_NOTIFICATION) ||
|
|
||||||
!strcmp(aTopic,
|
|
||||||
SPELLCHECK_DICTIONARY_REMOVE_NOTIFICATION),
|
|
||||||
"Unexpected observer topic");
|
|
||||||
|
|
||||||
// When mozInlineSpellChecker::CanEnableInlineSpellChecking changes
|
|
||||||
SyncRealTimeSpell();
|
|
||||||
|
|
||||||
// When nsIEditorSpellCheck::GetCurrentDictionary changes
|
|
||||||
if (mInlineSpellChecker) {
|
|
||||||
// Do the right thing in the spellchecker, if the dictionary is no longer
|
|
||||||
// available. This will not set a new dictionary.
|
|
||||||
nsCOMPtr<nsIEditorSpellCheck> editorSpellCheck;
|
|
||||||
mInlineSpellChecker->GetSpellChecker(getter_AddRefs(editorSpellCheck));
|
|
||||||
if (editorSpellCheck) {
|
|
||||||
editorSpellCheck->CheckCurrentDictionary();
|
|
||||||
}
|
|
||||||
|
|
||||||
// update the inline spell checker to reflect the new current dictionary
|
|
||||||
mInlineSpellChecker->SpellCheckRange(nullptr); // causes recheck
|
|
||||||
}
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP nsEditor::SyncRealTimeSpell()
|
NS_IMETHODIMP nsEditor::SyncRealTimeSpell()
|
||||||
{
|
{
|
||||||
bool enable = GetDesiredSpellCheckState();
|
bool enable = GetDesiredSpellCheckState();
|
||||||
@ -5206,29 +5158,6 @@ nsEditor::OnFocus(nsIDOMEventTarget* aFocusEventTarget)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
nsEditor::StartWatchingDictionaryChanges()
|
|
||||||
{
|
|
||||||
if (!mObservingDictionaryUpdates) {
|
|
||||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
|
||||||
if (obs) {
|
|
||||||
obs->AddObserver(this, SPELLCHECK_DICTIONARY_UPDATE_NOTIFICATION, false);
|
|
||||||
}
|
|
||||||
mObservingDictionaryUpdates = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
nsEditor::StopWatchingDictionaryChanges()
|
|
||||||
{
|
|
||||||
// Removing an observer that wasn't added doesn't cause any harm.
|
|
||||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
|
||||||
if (obs) {
|
|
||||||
obs->RemoveObserver(this, SPELLCHECK_DICTIONARY_UPDATE_NOTIFICATION);
|
|
||||||
}
|
|
||||||
mObservingDictionaryUpdates = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsEditor::GetSuppressDispatchingInputEvent(bool *aSuppressed)
|
nsEditor::GetSuppressDispatchingInputEvent(bool *aSuppressed)
|
||||||
{
|
{
|
||||||
|
@ -140,7 +140,6 @@ inline bool operator!(const EditAction& aOp)
|
|||||||
class nsEditor : public nsIEditor,
|
class nsEditor : public nsIEditor,
|
||||||
public nsIEditorIMESupport,
|
public nsIEditorIMESupport,
|
||||||
public nsSupportsWeakReference,
|
public nsSupportsWeakReference,
|
||||||
public nsIObserver,
|
|
||||||
public nsIPhonetic
|
public nsIPhonetic
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -188,9 +187,6 @@ public:
|
|||||||
/* ------------ nsIEditorIMESupport methods -------------- */
|
/* ------------ nsIEditorIMESupport methods -------------- */
|
||||||
NS_DECL_NSIEDITORIMESUPPORT
|
NS_DECL_NSIEDITORIMESUPPORT
|
||||||
|
|
||||||
/* ------------ nsIObserver methods -------------- */
|
|
||||||
NS_DECL_NSIOBSERVER
|
|
||||||
|
|
||||||
// nsIPhonetic
|
// nsIPhonetic
|
||||||
NS_DECL_NSIPHONETIC
|
NS_DECL_NSIPHONETIC
|
||||||
|
|
||||||
@ -249,9 +245,6 @@ public:
|
|||||||
|
|
||||||
void SwitchTextDirectionTo(uint32_t aDirection);
|
void SwitchTextDirectionTo(uint32_t aDirection);
|
||||||
|
|
||||||
void StartWatchingDictionaryChanges();
|
|
||||||
void StopWatchingDictionaryChanges();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
nsresult DetermineCurrentDirection();
|
nsresult DetermineCurrentDirection();
|
||||||
void FireInputEvent();
|
void FireInputEvent();
|
||||||
@ -894,7 +887,6 @@ protected:
|
|||||||
bool mDispatchInputEvent;
|
bool mDispatchInputEvent;
|
||||||
bool mIsInEditAction; // true while the instance is handling an edit action
|
bool mIsInEditAction; // true while the instance is handling an edit action
|
||||||
bool mHidingCaret; // whether caret is hidden forcibly.
|
bool mHidingCaret; // whether caret is hidden forcibly.
|
||||||
bool mObservingDictionaryUpdates; // whether the editor is observing dictionary changes.
|
|
||||||
|
|
||||||
friend bool NSCanUnload(nsISupports* serviceMgr);
|
friend bool NSCanUnload(nsISupports* serviceMgr);
|
||||||
friend class nsAutoTxnsConserveSelection;
|
friend class nsAutoTxnsConserveSelection;
|
||||||
|
@ -1114,8 +1114,6 @@ nsEditorEventListener::Focus(nsIDOMEvent* aEvent)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mEditor->StartWatchingDictionaryChanges();
|
|
||||||
|
|
||||||
mEditor->OnFocus(target);
|
mEditor->OnFocus(target);
|
||||||
|
|
||||||
nsCOMPtr<nsIPresShell> ps = GetPresShell();
|
nsCOMPtr<nsIPresShell> ps = GetPresShell();
|
||||||
@ -1132,8 +1130,6 @@ nsEditorEventListener::Blur(nsIDOMEvent* aEvent)
|
|||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(aEvent, NS_OK);
|
NS_ENSURE_TRUE(aEvent, NS_OK);
|
||||||
|
|
||||||
mEditor->StopWatchingDictionaryChanges();
|
|
||||||
|
|
||||||
// check if something else is focused. If another element is focused, then
|
// check if something else is focused. If another element is focused, then
|
||||||
// we should not change the selection.
|
// we should not change the selection.
|
||||||
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
|
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
|
||||||
|
@ -9,16 +9,10 @@ interface nsIEditor;
|
|||||||
interface nsITextServicesFilter;
|
interface nsITextServicesFilter;
|
||||||
interface nsIEditorSpellCheckCallback;
|
interface nsIEditorSpellCheckCallback;
|
||||||
|
|
||||||
[scriptable, uuid(dd32ef3b-a7d8-43d1-9617-5f2dddbe29eb)]
|
[scriptable, uuid(a171c25f-e4a8-4d08-adef-b797e6377bdc)]
|
||||||
interface nsIEditorSpellCheck : nsISupports
|
interface nsIEditorSpellCheck : nsISupports
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
|
||||||
* Call this on any change in installed dictionaries to ensure that the spell
|
|
||||||
* checker is not using a current dictionary which is no longer available.
|
|
||||||
*/
|
|
||||||
void checkCurrentDictionary();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if we can enable spellchecking. If there are no available
|
* Returns true if we can enable spellchecking. If there are no available
|
||||||
* dictionaries, this will return false.
|
* dictionaries, this will return false.
|
||||||
|
@ -114,12 +114,6 @@ public:
|
|||||||
* empty string, spellchecker will be disabled.
|
* empty string, spellchecker will be disabled.
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD SetCurrentDictionary(const nsAString &aDictionary) = 0;
|
NS_IMETHOD SetCurrentDictionary(const nsAString &aDictionary) = 0;
|
||||||
|
|
||||||
/**
|
|
||||||
* Call this on any change in installed dictionaries to ensure that the spell
|
|
||||||
* checker is not using a current dictionary which is no longer available.
|
|
||||||
*/
|
|
||||||
NS_IMETHOD CheckCurrentDictionary() = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsISpellChecker, NS_ISPELLCHECKER_IID)
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsISpellChecker, NS_ISPELLCHECKER_IID)
|
||||||
|
@ -160,12 +160,6 @@ NS_IMETHODIMP mozHunspell::SetDictionary(const char16_t *aDictionary)
|
|||||||
mDecoder = nullptr;
|
mDecoder = nullptr;
|
||||||
mEncoder = nullptr;
|
mEncoder = nullptr;
|
||||||
|
|
||||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
|
||||||
if (obs) {
|
|
||||||
obs->NotifyObservers(nullptr,
|
|
||||||
SPELLCHECK_DICTIONARY_UPDATE_NOTIFICATION,
|
|
||||||
nullptr);
|
|
||||||
}
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,13 +220,6 @@ NS_IMETHODIMP mozHunspell::SetDictionary(const char16_t *aDictionary)
|
|||||||
else
|
else
|
||||||
mLanguage = Substring(mDictionary, 0, pos);
|
mLanguage = Substring(mDictionary, 0, pos);
|
||||||
|
|
||||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
|
||||||
if (obs) {
|
|
||||||
obs->NotifyObservers(nullptr,
|
|
||||||
SPELLCHECK_DICTIONARY_UPDATE_NOTIFICATION,
|
|
||||||
nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -604,11 +591,19 @@ NS_IMETHODIMP mozHunspell::RemoveDirectory(nsIFile *aDir)
|
|||||||
{
|
{
|
||||||
mDynamicDirectories.RemoveObject(aDir);
|
mDynamicDirectories.RemoveObject(aDir);
|
||||||
LoadDictionaryList(true);
|
LoadDictionaryList(true);
|
||||||
|
|
||||||
|
#ifdef MOZ_THUNDERBIRD
|
||||||
|
/*
|
||||||
|
* This notification is needed for Thunderbird. Thunderbird derives the dictionary
|
||||||
|
* from the document's "lang" attribute. If a dictionary is removed,
|
||||||
|
* we need to change the "lang" attribute.
|
||||||
|
*/
|
||||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||||
if (obs) {
|
if (obs) {
|
||||||
obs->NotifyObservers(nullptr,
|
obs->NotifyObservers(nullptr,
|
||||||
SPELLCHECK_DICTIONARY_REMOVE_NOTIFICATION,
|
SPELLCHECK_DICTIONARY_REMOVE_NOTIFICATION,
|
||||||
nullptr);
|
nullptr);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -102,8 +102,6 @@ interface mozISpellCheckingEngine : nsISupports {
|
|||||||
#define DICTIONARY_SEARCH_DIRECTORY "DictD"
|
#define DICTIONARY_SEARCH_DIRECTORY "DictD"
|
||||||
#define DICTIONARY_SEARCH_DIRECTORY_LIST "DictDL"
|
#define DICTIONARY_SEARCH_DIRECTORY_LIST "DictDL"
|
||||||
|
|
||||||
#define SPELLCHECK_DICTIONARY_UPDATE_NOTIFICATION \
|
|
||||||
"spellcheck-dictionary-update"
|
|
||||||
#define SPELLCHECK_DICTIONARY_REMOVE_NOTIFICATION \
|
#define SPELLCHECK_DICTIONARY_REMOVE_NOTIFICATION \
|
||||||
"spellcheck-dictionary-remove"
|
"spellcheck-dictionary-remove"
|
||||||
%}
|
%}
|
||||||
|
@ -2021,10 +2021,8 @@ nsresult mozInlineSpellChecker::CurrentDictionaryUpdated()
|
|||||||
currentDictionary.Truncate();
|
currentDictionary.Truncate();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mPreviousDictionary.Equals(currentDictionary)) {
|
nsresult rv = SpellCheckRange(nullptr);
|
||||||
nsresult rv = SpellCheckRange(nullptr);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
}
|
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -428,31 +428,6 @@ mozSpellChecker::SetCurrentDictionary(const nsAString &aDictionary)
|
|||||||
return NS_ERROR_NOT_AVAILABLE;
|
return NS_ERROR_NOT_AVAILABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
mozSpellChecker::CheckCurrentDictionary()
|
|
||||||
{
|
|
||||||
// If the current dictionary has been uninstalled, we need to stop using it.
|
|
||||||
// This happens when there is a current engine, but that engine has no
|
|
||||||
// current dictionary.
|
|
||||||
|
|
||||||
if (!mSpellCheckingEngine) {
|
|
||||||
// We didn't have a current dictionary
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsXPIDLString dictname;
|
|
||||||
mSpellCheckingEngine->GetDictionary(getter_Copies(dictname));
|
|
||||||
|
|
||||||
if (!dictname.IsEmpty()) {
|
|
||||||
// We still have a current dictionary
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We had a current dictionary, but it has gone, so we cannot use it anymore.
|
|
||||||
mSpellCheckingEngine = nullptr;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
mozSpellChecker::SetupDoc(int32_t *outBlockOffset)
|
mozSpellChecker::SetupDoc(int32_t *outBlockOffset)
|
||||||
{
|
{
|
||||||
|
@ -48,7 +48,6 @@ public:
|
|||||||
NS_IMETHOD GetDictionaryList(nsTArray<nsString> *aDictionaryList) override;
|
NS_IMETHOD GetDictionaryList(nsTArray<nsString> *aDictionaryList) override;
|
||||||
NS_IMETHOD GetCurrentDictionary(nsAString &aDictionary) override;
|
NS_IMETHOD GetCurrentDictionary(nsAString &aDictionary) override;
|
||||||
NS_IMETHOD SetCurrentDictionary(const nsAString &aDictionary) override;
|
NS_IMETHOD SetCurrentDictionary(const nsAString &aDictionary) override;
|
||||||
NS_IMETHOD CheckCurrentDictionary() override;
|
|
||||||
|
|
||||||
void DeleteRemoteEngine() {
|
void DeleteRemoteEngine() {
|
||||||
mEngine = nullptr;
|
mEngine = nullptr;
|
||||||
|
Loading…
Reference in New Issue
Block a user