mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Bug 1430982 - part 8: Make EditorBase store inline spell checker as mozInlineSpellChecker rather than nsIInlineSpellChecker r=m_kato
EditorBase::mInlineSpellChecker is always an instance of mozInlineSpellChecker. Fortunately, it's easy to expose mozInlineSpellChecker.h. So, making EditorBase store it as mozInlineSpellChecker directly, EditorBase can access any of mozInlineSpellChecker, EditorSpellCheck, mozSpellChecker and TextServicesDocument with new accessors created by following patch. MozReview-Commit-ID: 2oyS5tPeQcg --HG-- extra : rebase_source : a9ce2e4dbceff7ca800d34d60d56eba184298677
This commit is contained in:
parent
3ccb2b1bbb
commit
04e3a3adfc
@ -35,6 +35,7 @@
|
||||
#include "mozilla/EditTransactionBase.h" // for EditTransactionBase
|
||||
#include "mozilla/FlushType.h" // for FlushType::Frames
|
||||
#include "mozilla/IMEStateManager.h" // for IMEStateManager
|
||||
#include "mozilla/mozInlineSpellChecker.h" // for mozInlineSpellChecker
|
||||
#include "mozilla/Preferences.h" // for Preferences
|
||||
#include "mozilla/RangeBoundary.h" // for RawRangeBoundary, RangeBoundary
|
||||
#include "mozilla/dom/Selection.h" // for Selection, etc.
|
||||
@ -1365,8 +1366,7 @@ EditorBase::GetInlineSpellChecker(bool autoCreate,
|
||||
|
||||
nsresult rv;
|
||||
if (!mInlineSpellChecker && autoCreate) {
|
||||
mInlineSpellChecker = do_CreateInstance(MOZ_INLINESPELLCHECKER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mInlineSpellChecker = new mozInlineSpellChecker();
|
||||
}
|
||||
|
||||
if (mInlineSpellChecker) {
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "nsWeakReference.h" // for nsSupportsWeakReference
|
||||
#include "nscore.h" // for nsresult, nsAString, etc.
|
||||
|
||||
class mozInlineSpellChecker;
|
||||
class nsAtom;
|
||||
class nsIContent;
|
||||
class nsIDOMDocument;
|
||||
@ -44,7 +45,6 @@ class nsIDOMNode;
|
||||
class nsIDocumentStateListener;
|
||||
class nsIEditActionListener;
|
||||
class nsIEditorObserver;
|
||||
class nsIInlineSpellChecker;
|
||||
class nsINode;
|
||||
class nsIPresShell;
|
||||
class nsISupports;
|
||||
@ -1384,7 +1384,7 @@ protected:
|
||||
// MIME type of the doc we are editing.
|
||||
nsCString mContentMIMEType;
|
||||
|
||||
nsCOMPtr<nsIInlineSpellChecker> mInlineSpellChecker;
|
||||
RefPtr<mozInlineSpellChecker> mInlineSpellChecker;
|
||||
|
||||
RefPtr<nsTransactionManager> mTxnMgr;
|
||||
// Cached root node.
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "mozilla/EditAction.h"
|
||||
#include "mozilla/EditorDOMPoint.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/mozInlineSpellChecker.h"
|
||||
#include "mozilla/TextEvents.h"
|
||||
|
||||
#include "nsCRT.h"
|
||||
|
@ -27,6 +27,7 @@ LOCAL_INCLUDES += [
|
||||
'/dom/base',
|
||||
]
|
||||
EXPORTS.mozilla += [
|
||||
'mozInlineSpellChecker.h',
|
||||
'mozSpellChecker.h',
|
||||
]
|
||||
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "mozilla/dom/Selection.h"
|
||||
#include "mozInlineSpellWordUtil.h"
|
||||
#include "mozISpellI18NManager.h"
|
||||
#include "mozISpellI18NUtil.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIDOMNode.h"
|
||||
@ -1872,32 +1873,35 @@ mozInlineSpellChecker::HandleNavigationEvent(bool aForceWordSpellCheck,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP mozInlineSpellChecker::HandleEvent(nsIDOMEvent* aEvent)
|
||||
NS_IMETHODIMP
|
||||
mozInlineSpellChecker::HandleEvent(nsIDOMEvent* aEvent)
|
||||
{
|
||||
nsAutoString eventType;
|
||||
aEvent->GetType(eventType);
|
||||
|
||||
if (eventType.EqualsLiteral("blur")) {
|
||||
return Blur(aEvent);
|
||||
return OnBlur(aEvent);
|
||||
}
|
||||
if (eventType.EqualsLiteral("click")) {
|
||||
return MouseClick(aEvent);
|
||||
return OnMouseClick(aEvent);
|
||||
}
|
||||
if (eventType.EqualsLiteral("keypress")) {
|
||||
return KeyPress(aEvent);
|
||||
return OnKeyPress(aEvent);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult mozInlineSpellChecker::Blur(nsIDOMEvent* aEvent)
|
||||
nsresult
|
||||
mozInlineSpellChecker::OnBlur(nsIDOMEvent* aEvent)
|
||||
{
|
||||
// force spellcheck on blur, for instance when tabbing out of a textbox
|
||||
HandleNavigationEvent(true);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult mozInlineSpellChecker::MouseClick(nsIDOMEvent *aMouseEvent)
|
||||
nsresult
|
||||
mozInlineSpellChecker::OnMouseClick(nsIDOMEvent *aMouseEvent)
|
||||
{
|
||||
nsCOMPtr<nsIDOMMouseEvent>mouseEvent = do_QueryInterface(aMouseEvent);
|
||||
NS_ENSURE_TRUE(mouseEvent, NS_OK);
|
||||
@ -1910,7 +1914,8 @@ nsresult mozInlineSpellChecker::MouseClick(nsIDOMEvent *aMouseEvent)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult mozInlineSpellChecker::KeyPress(nsIDOMEvent* aKeyEvent)
|
||||
nsresult
|
||||
mozInlineSpellChecker::OnKeyPress(nsIDOMEvent* aKeyEvent)
|
||||
{
|
||||
nsCOMPtr<nsIDOMKeyEvent>keyEvent = do_QueryInterface(aKeyEvent);
|
||||
NS_ENSURE_TRUE(keyEvent, NS_OK);
|
||||
|
@ -3,12 +3,8 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef __mozinlinespellchecker_h__
|
||||
#define __mozinlinespellchecker_h__
|
||||
|
||||
#include "mozilla/TextEditor.h"
|
||||
|
||||
#include "mozISpellI18NUtil.h"
|
||||
#ifndef mozilla_mozInlineSpellChecker_h
|
||||
#define mozilla_mozInlineSpellChecker_h
|
||||
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsIDOMEventListener.h"
|
||||
@ -19,20 +15,16 @@
|
||||
#include "nsRange.h"
|
||||
#include "nsWeakReference.h"
|
||||
|
||||
// X.h defines KeyPress
|
||||
#ifdef KeyPress
|
||||
#undef KeyPress
|
||||
#endif
|
||||
|
||||
class InitEditorSpellCheckCallback;
|
||||
class mozInlineSpellWordUtil;
|
||||
class mozInlineSpellChecker;
|
||||
class mozISpellI18NUtil;
|
||||
class mozInlineSpellResume;
|
||||
class InitEditorSpellCheckCallback;
|
||||
class UpdateCurrentDictionaryCallback;
|
||||
class mozInlineSpellResume;
|
||||
|
||||
namespace mozilla {
|
||||
class EditorSpellCheck;
|
||||
class TextEditor;
|
||||
enum class EditAction : int32_t;
|
||||
} // namespace mozilla
|
||||
|
||||
@ -197,9 +189,9 @@ public:
|
||||
// update the cached value whenever the list of available dictionaries changes
|
||||
static void UpdateCanEnableInlineSpellChecking();
|
||||
|
||||
nsresult Blur(nsIDOMEvent* aEvent);
|
||||
nsresult MouseClick(nsIDOMEvent* aMouseEvent);
|
||||
nsresult KeyPress(nsIDOMEvent* aKeyEvent);
|
||||
nsresult OnBlur(nsIDOMEvent* aEvent);
|
||||
nsresult OnMouseClick(nsIDOMEvent* aMouseEvent);
|
||||
nsresult OnKeyPress(nsIDOMEvent* aKeyEvent);
|
||||
|
||||
mozInlineSpellChecker();
|
||||
|
||||
@ -270,4 +262,4 @@ protected:
|
||||
void NotifyObservers(const char* aTopic, mozilla::TextEditor* aTextEditor);
|
||||
};
|
||||
|
||||
#endif /* __mozinlinespellchecker_h__ */
|
||||
#endif // #ifndef mozilla_mozInlineSpellChecker_h
|
||||
|
Loading…
Reference in New Issue
Block a user