зеркало из https://github.com/mozilla/gecko-dev.git
Bug 345428 - No spellcheck on focus out, r=sspitzer, r=brettw, a=dsicore
This commit is contained in:
Родитель
08fe601d31
Коммит
f705d4afa1
|
@ -73,6 +73,7 @@
|
|||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMDocumentRange.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
#include "nsPIDOMEventTarget.h"
|
||||
#include "nsIDOMKeyEvent.h"
|
||||
|
@ -503,6 +504,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)
|
||||
|
@ -623,11 +625,24 @@ mozInlineSpellChecker::RegisterEventListeners()
|
|||
|
||||
nsCOMPtr<nsIDOMDocument> doc;
|
||||
nsresult rv = editor->GetDocument(getter_AddRefs(doc));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDocument> doc2 = do_QueryInterface(doc);
|
||||
NS_ENSURE_TRUE(doc2, nsnull);
|
||||
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(doc2->GetWindow());
|
||||
nsPIDOMEventTarget* chromeEventHandler = nsnull;
|
||||
if (win)
|
||||
chromeEventHandler = win->GetChromeEventHandler();
|
||||
|
||||
nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(chromeEventHandler, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsPIDOMEventTarget> piTarget = do_QueryInterface(doc, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
target->AddEventListener(NS_LITERAL_STRING("blur"),
|
||||
static_cast<nsIDOMFocusListener *>(this),
|
||||
PR_TRUE);
|
||||
piTarget->AddEventListenerByIID(static_cast<nsIDOMMouseListener*>(this),
|
||||
NS_GET_IID(nsIDOMMouseListener));
|
||||
piTarget->AddEventListenerByIID(static_cast<nsIDOMKeyListener*>(this),
|
||||
|
@ -653,6 +668,20 @@ mozInlineSpellChecker::UnregisterEventListeners()
|
|||
nsCOMPtr<nsPIDOMEventTarget> piTarget = do_QueryInterface(doc);
|
||||
NS_ENSURE_TRUE(piTarget, NS_ERROR_NULL_POINTER);
|
||||
|
||||
nsCOMPtr<nsIDocument> doc2 = do_QueryInterface(doc);
|
||||
NS_ENSURE_TRUE(doc2, nsnull);
|
||||
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(doc2->GetWindow());
|
||||
nsPIDOMEventTarget* chromeEventHandler = nsnull;
|
||||
if (win)
|
||||
chromeEventHandler = win->GetChromeEventHandler();
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(chromeEventHandler, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
target->RemoveEventListener(NS_LITERAL_STRING("blur"),
|
||||
static_cast<nsIDOMFocusListener *>(this),
|
||||
PR_TRUE);
|
||||
piTarget->RemoveEventListenerByIID(static_cast<nsIDOMMouseListener*>(this),
|
||||
NS_GET_IID(nsIDOMMouseListener));
|
||||
piTarget->RemoveEventListenerByIID(static_cast<nsIDOMKeyListener*>(this),
|
||||
|
@ -1650,6 +1679,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)
|
||||
{
|
||||
// ignore any errors from HandleNavigationEvent as we don't want to prevent
|
||||
|
|
|
@ -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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче