Bug 345428 - No spellcheck on focus out, second try, r=Olli.Pettay, r=brettw, a=dsicore

This commit is contained in:
martijn.martijn@gmail.com 2007-09-27 04:40:30 -07:00
Родитель 06caf23005
Коммит 1448f8b07e
3 изменённых файлов: 42 добавлений и 3 удалений

Просмотреть файл

@ -54,6 +54,7 @@ REQUIRES = xpcom \
string \
editor \
content \
gfx \
layout \
dom \
necko \

Просмотреть файл

@ -96,6 +96,8 @@
#include "nsUnicharUtils.h"
#include "nsIContent.h"
#include "nsIEventStateManager.h"
#include "nsIEventListenerManager.h"
#include "nsGUIEvent.h"
// Set to spew messages to the console about what is happening.
//#define DEBUG_INLINESPELL
@ -504,6 +506,7 @@ public:
NS_INTERFACE_MAP_BEGIN(mozInlineSpellChecker)
NS_INTERFACE_MAP_ENTRY(nsIInlineSpellChecker)
NS_INTERFACE_MAP_ENTRY(nsIEditActionListener)
NS_INTERFACE_MAP_ENTRY(nsIDOMFocusListener)
NS_INTERFACE_MAP_ENTRY(nsIDOMMouseListener)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMKeyListener)
@ -624,10 +627,19 @@ mozInlineSpellChecker::RegisterEventListeners()
nsCOMPtr<nsIDOMDocument> doc;
nsresult rv = editor->GetDocument(getter_AddRefs(doc));
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsPIDOMEventTarget> piTarget = do_QueryInterface(doc, &rv);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIEventListenerManager> elmP;
piTarget->GetListenerManager(PR_TRUE, getter_AddRefs(elmP));
if (elmP) {
// Focus event doesn't bubble so adding the listener to capturing phase
elmP->AddEventListenerByIID(static_cast<nsIDOMFocusListener *>(this),
NS_GET_IID(nsIDOMFocusListener),
NS_EVENT_FLAG_CAPTURE);
}
piTarget->AddEventListenerByIID(static_cast<nsIDOMMouseListener*>(this),
NS_GET_IID(nsIDOMMouseListener));
@ -654,6 +666,14 @@ mozInlineSpellChecker::UnregisterEventListeners()
nsCOMPtr<nsPIDOMEventTarget> piTarget = do_QueryInterface(doc);
NS_ENSURE_TRUE(piTarget, NS_ERROR_NULL_POINTER);
nsCOMPtr<nsIEventListenerManager> elmP;
piTarget->GetListenerManager(PR_TRUE, getter_AddRefs(elmP));
if (elmP) {
elmP->RemoveEventListenerByIID(static_cast<nsIDOMFocusListener *>(this),
NS_GET_IID(nsIDOMFocusListener),
NS_EVENT_FLAG_CAPTURE);
}
piTarget->RemoveEventListenerByIID(static_cast<nsIDOMMouseListener*>(this),
NS_GET_IID(nsIDOMMouseListener));
piTarget->RemoveEventListenerByIID(static_cast<nsIDOMKeyListener*>(this),
@ -1651,6 +1671,18 @@ NS_IMETHODIMP mozInlineSpellChecker::HandleEvent(nsIDOMEvent* aEvent)
return NS_OK;
}
NS_IMETHODIMP mozInlineSpellChecker::Focus(nsIDOMEvent* aEvent)
{
return NS_OK;
}
NS_IMETHODIMP mozInlineSpellChecker::Blur(nsIDOMEvent* aEvent)
{
// force spellcheck on blur, for instance when tabbing out of a textbox
HandleNavigationEvent(aEvent, PR_TRUE);
return NS_OK;
}
NS_IMETHODIMP mozInlineSpellChecker::MouseClick(nsIDOMEvent *aMouseEvent)
{
nsCOMPtr<nsIDOMMouseEvent>mouseEvent = do_QueryInterface(aMouseEvent);

Просмотреть файл

@ -48,6 +48,7 @@
#include "nsIDOMTreeWalker.h"
#include "nsWeakReference.h"
#include "nsIEditor.h"
#include "nsIDOMFocusListener.h"
#include "nsIDOMMouseListener.h"
#include "nsIDOMKeyListener.h"
#include "nsWeakReference.h"
@ -138,7 +139,7 @@ protected:
nsIDOMRange** aRange);
};
class mozInlineSpellChecker : public nsIInlineSpellChecker, nsIEditActionListener, nsIDOMMouseListener, nsIDOMKeyListener,
class mozInlineSpellChecker : public nsIInlineSpellChecker, nsIEditActionListener, nsIDOMFocusListener, nsIDOMMouseListener, nsIDOMKeyListener,
nsSupportsWeakReference
{
private:
@ -224,6 +225,11 @@ public:
// returns true if it looks likely that we can enable real-time spell checking
static PRBool CanEnableInlineSpellChecking();
/*BEGIN implementations of focus event handler interface*/
NS_IMETHOD Focus(nsIDOMEvent* aEvent);
NS_IMETHOD Blur(nsIDOMEvent* aEvent);
/*END implementations of focus event handler interface*/
/*BEGIN implementations of mouseevent handler interface*/
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
NS_IMETHOD MouseDown(nsIDOMEvent* aMouseEvent);