Backed out changeset 967b254211be. This was the wrong patch and probably won't compile.

This commit is contained in:
Jonas Sicking 2011-06-24 17:36:06 -07:00
Родитель c41e5a0e1c
Коммит 2a63e793d7
3 изменённых файлов: 195 добавлений и 88 удалений

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

@ -508,12 +508,15 @@ public:
NS_INTERFACE_MAP_BEGIN(mozInlineSpellChecker)
NS_INTERFACE_MAP_ENTRY(nsIInlineSpellChecker)
NS_INTERFACE_MAP_ENTRY(nsIEditActionListener)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY(nsIDOMEventListener)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMEventListener)
NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(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)
NS_INTERFACE_MAP_ENTRY(nsIDOMKeyListener)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIDOMEventListener, nsIDOMKeyListener)
NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(mozInlineSpellChecker)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(mozInlineSpellChecker)
@ -644,12 +647,19 @@ mozInlineSpellChecker::RegisterEventListeners()
nsCOMPtr<nsIDOMEventTarget> piTarget = do_QueryInterface(doc, &rv);
NS_ENSURE_SUCCESS(rv, rv);
piTarget->AddEventListener(NS_LITERAL_STRING("blur"), this,
PR_TRUE, PR_FALSE);
piTarget->AddEventListener(NS_LITERAL_STRING("click"), this,
PR_FALSE, PR_FALSE);
piTarget->AddEventListener(NS_LITERAL_STRING("keypress"), this,
PR_FALSE, PR_FALSE);
nsEventListenerManager* elmP = piTarget->GetListenerManager(PR_TRUE);
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));
piTarget->AddEventListenerByIID(static_cast<nsIDOMKeyListener*>(this),
NS_GET_IID(nsIDOMKeyListener));
return NS_OK;
}
@ -670,9 +680,19 @@ mozInlineSpellChecker::UnregisterEventListeners()
nsCOMPtr<nsIDOMEventTarget> piTarget = do_QueryInterface(doc);
NS_ENSURE_TRUE(piTarget, NS_ERROR_NULL_POINTER);
piTarget->RemoveEventListener(NS_LITERAL_STRING("blur"), this, PR_TRUE);
piTarget->RemoveEventListener(NS_LITERAL_STRING("click"), this, PR_FALSE);
piTarget->RemoveEventListener(NS_LITERAL_STRING("keypress"), this, PR_FALSE);
nsEventListenerManager* elmP =
piTarget->GetListenerManager(PR_TRUE);
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),
NS_GET_IID(nsIDOMKeyListener));
return NS_OK;
}
@ -1637,7 +1657,8 @@ ContentIsDescendantOf(nsINode* aPossibleDescendant,
// DOM_VK_RIGHT and DOM_VK_LEFT cases.
nsresult
mozInlineSpellChecker::HandleNavigationEvent(PRBool aForceWordSpellCheck,
mozInlineSpellChecker::HandleNavigationEvent(nsIDOMEvent* aEvent,
PRBool aForceWordSpellCheck,
PRInt32 aNewPositionOffset)
{
nsresult rv;
@ -1673,30 +1694,22 @@ mozInlineSpellChecker::HandleNavigationEvent(PRBool aForceWordSpellCheck,
NS_IMETHODIMP mozInlineSpellChecker::HandleEvent(nsIDOMEvent* aEvent)
{
nsAutoString eventType;
aEvent->GetType(eventType);
if (eventType.EqualsLiteral("blur")) {
return Blur(aEvent);
}
if (eventType.EqualsLiteral("click")) {
return MouseClick(aEvent);
}
if (eventType.EqualsLiteral("keypress")) {
return KeyPress(aEvent);
}
return NS_OK;
}
nsresult mozInlineSpellChecker::Blur(nsIDOMEvent* aEvent)
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(PR_TRUE);
HandleNavigationEvent(aEvent, PR_TRUE);
return NS_OK;
}
nsresult mozInlineSpellChecker::MouseClick(nsIDOMEvent *aMouseEvent)
NS_IMETHODIMP mozInlineSpellChecker::MouseClick(nsIDOMEvent *aMouseEvent)
{
nsCOMPtr<nsIDOMMouseEvent>mouseEvent = do_QueryInterface(aMouseEvent);
NS_ENSURE_TRUE(mouseEvent, NS_OK);
@ -1705,11 +1718,51 @@ nsresult mozInlineSpellChecker::MouseClick(nsIDOMEvent *aMouseEvent)
// anyone else from seeing this event.
PRUint16 button;
mouseEvent->GetButton(&button);
HandleNavigationEvent(button != 0);
if (button == 0)
HandleNavigationEvent(mouseEvent, PR_FALSE);
else
HandleNavigationEvent(mouseEvent, PR_TRUE);
return NS_OK;
}
nsresult mozInlineSpellChecker::KeyPress(nsIDOMEvent* aKeyEvent)
NS_IMETHODIMP mozInlineSpellChecker::MouseDown(nsIDOMEvent* aMouseEvent)
{
return NS_OK;
}
NS_IMETHODIMP mozInlineSpellChecker::MouseUp(nsIDOMEvent* aMouseEvent)
{
return NS_OK;
}
NS_IMETHODIMP mozInlineSpellChecker::MouseDblClick(nsIDOMEvent* aMouseEvent)
{
return NS_OK;
}
NS_IMETHODIMP mozInlineSpellChecker::MouseOver(nsIDOMEvent* aMouseEvent)
{
return NS_OK;
}
NS_IMETHODIMP mozInlineSpellChecker::MouseOut(nsIDOMEvent* aMouseEvent)
{
return NS_OK;
}
NS_IMETHODIMP mozInlineSpellChecker::KeyDown(nsIDOMEvent* aKeyEvent)
{
return NS_OK;
}
NS_IMETHODIMP mozInlineSpellChecker::KeyUp(nsIDOMEvent* aKeyEvent)
{
return NS_OK;
}
NS_IMETHODIMP mozInlineSpellChecker::KeyPress(nsIDOMEvent* aKeyEvent)
{
nsCOMPtr<nsIDOMKeyEvent>keyEvent = do_QueryInterface(aKeyEvent);
NS_ENSURE_TRUE(keyEvent, NS_OK);
@ -1722,7 +1775,7 @@ nsresult mozInlineSpellChecker::KeyPress(nsIDOMEvent* aKeyEvent)
{
case nsIDOMKeyEvent::DOM_VK_RIGHT:
case nsIDOMKeyEvent::DOM_VK_LEFT:
HandleNavigationEvent(PR_FALSE, keyCode == nsIDOMKeyEvent::DOM_VK_RIGHT ? 1 : -1);
HandleNavigationEvent(aKeyEvent, PR_FALSE, keyCode == nsIDOMKeyEvent::DOM_VK_RIGHT ? 1 : -1);
break;
case nsIDOMKeyEvent::DOM_VK_UP:
case nsIDOMKeyEvent::DOM_VK_DOWN:
@ -1730,7 +1783,7 @@ nsresult mozInlineSpellChecker::KeyPress(nsIDOMEvent* aKeyEvent)
case nsIDOMKeyEvent::DOM_VK_END:
case nsIDOMKeyEvent::DOM_VK_PAGE_UP:
case nsIDOMKeyEvent::DOM_VK_PAGE_DOWN:
HandleNavigationEvent(PR_TRUE /* force a spelling correction */);
HandleNavigationEvent(aKeyEvent, PR_TRUE /* force a spelling correction */);
break;
}

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

@ -48,16 +48,13 @@
#include "nsIDOMTreeWalker.h"
#include "nsWeakReference.h"
#include "nsIEditor.h"
#include "nsIDOMEventListener.h"
#include "nsIDOMFocusListener.h"
#include "nsIDOMMouseListener.h"
#include "nsIDOMKeyListener.h"
#include "nsWeakReference.h"
#include "mozISpellI18NUtil.h"
#include "nsCycleCollectionParticipant.h"
// X.h defines KeyPress
#ifdef KeyPress
#undef KeyPress
#endif
class nsIDOMMouseEventListener;
class mozInlineSpellWordUtil;
class mozInlineSpellChecker;
@ -142,10 +139,8 @@ protected:
nsIDOMRange** aRange);
};
class mozInlineSpellChecker : public nsIInlineSpellChecker,
public nsIEditActionListener,
public nsIDOMEventListener,
public nsSupportsWeakReference
class mozInlineSpellChecker : public nsIInlineSpellChecker, nsIEditActionListener, nsIDOMFocusListener, nsIDOMMouseListener, nsIDOMKeyListener,
nsSupportsWeakReference
{
private:
friend class mozInlineSpellStatus;
@ -226,15 +221,31 @@ public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_NSIEDITACTIONLISTENER
NS_DECL_NSIINLINESPELLCHECKER
NS_DECL_NSIDOMEVENTLISTENER
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(mozInlineSpellChecker, nsIDOMEventListener)
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(mozInlineSpellChecker, nsIDOMKeyListener)
// returns true if it looks likely that we can enable real-time spell checking
static PRBool CanEnableInlineSpellChecking();
nsresult Blur(nsIDOMEvent* aEvent);
nsresult MouseClick(nsIDOMEvent* aMouseEvent);
nsresult KeyPress(nsIDOMEvent* aKeyEvent);
/*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);
NS_IMETHOD MouseUp(nsIDOMEvent* aMouseEvent);
NS_IMETHOD MouseClick(nsIDOMEvent* aMouseEvent);
NS_IMETHOD MouseDblClick(nsIDOMEvent* aMouseEvent);
NS_IMETHOD MouseOver(nsIDOMEvent* aMouseEvent);
NS_IMETHOD MouseOut(nsIDOMEvent* aMouseEvent);
/*END implementations of mouseevent handler interface*/
/* BEGIN interfaces in to the keylistener interface. */
NS_IMETHOD KeyDown(nsIDOMEvent* aKeyEvent);
NS_IMETHOD KeyUp(nsIDOMEvent* aKeyEvent);
NS_IMETHOD KeyPress(nsIDOMEvent* aKeyEvent);
/* END interfaces from nsIDOMKeyListener */
mozInlineSpellChecker();
virtual ~mozInlineSpellChecker();
@ -286,7 +297,7 @@ public:
// DOM and editor event registration helper routines
nsresult RegisterEventListeners();
nsresult UnregisterEventListeners();
nsresult HandleNavigationEvent(PRBool aForceWordSpellCheck, PRInt32 aNewPositionOffset = 0);
nsresult HandleNavigationEvent(nsIDOMEvent * aEvent, PRBool aForceWordSpellCheck, PRInt32 aNewPositionOffset = 0);
nsresult GetSpellCheckSelection(nsISelection ** aSpellCheckSelection);
nsresult SaveCurrentSelectionPosition();

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

@ -66,8 +66,11 @@
#include "nsIDOMEventTarget.h"
#include "nsPIDOMWindow.h"
#include "nsIDOMWindow.h"
#include "nsIDOMKeyListener.h"
#include "nsIDOMCompositionListener.h"
#include "nsIDOMTextListener.h"
#include "nsIDOMMouseMotionListener.h"
#include "nsIDOMMouseListener.h"
#include "nsIDOMMouseEvent.h"
#include "nsIDOMNSEvent.h"
#include "nsIView.h"
@ -95,7 +98,8 @@ static PRBool g_is_scrollable = PR_FALSE;
// TODO auto reload nsWidgetUtils in C.
class nsWidgetUtils : public nsIObserver,
public nsIDOMEventListener,
public nsIDOMMouseMotionListener,
public nsIDOMMouseListener,
public nsIContentPolicy,
public nsSupportsWeakReference
{
@ -103,8 +107,20 @@ public:
nsWidgetUtils();
virtual ~nsWidgetUtils();
// nsIDOMMouseMotionListener
NS_IMETHOD MouseMove(nsIDOMEvent* aDOMEvent);
NS_IMETHOD DragMove(nsIDOMEvent* aMouseEvent);
NS_IMETHOD HandleEvent(nsIDOMEvent* aDOMEvent);
// nsIDOMMouseListener
NS_IMETHOD MouseDown(nsIDOMEvent* aDOMEvent);
NS_IMETHOD MouseUp(nsIDOMEvent* aDOMEvent);
NS_IMETHOD MouseClick(nsIDOMEvent* aDOMEvent);
NS_IMETHOD MouseDblClick(nsIDOMEvent* aDOMEvent);
NS_IMETHOD MouseOver(nsIDOMEvent* aDOMEvent);
NS_IMETHOD MouseOut(nsIDOMEvent* aDOMEvent);
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMEVENTLISTENER
NS_DECL_NSIOBSERVER
NS_DECL_NSICONTENTPOLICY
@ -116,9 +132,6 @@ private:
PRBool IsXULNode(nsIDOMNode *aNode, PRUint32 *aType = 0);
nsresult GetDOMWindowByNode(nsIDOMNode *aNode, nsIDOMWindow * *aDOMWindow);
nsresult UpdateFromEvent(nsIDOMEvent *aDOMEvent);
nsresult MouseDown(nsIDOMEvent* aDOMEvent);
nsresult MouseUp(nsIDOMEvent* aDOMEvent);
nsresult MouseMove(nsIDOMEvent* aDOMEvent);
static void StopPanningCallback(nsITimer *timer, void *closure);
@ -203,7 +216,7 @@ nsWidgetUtils::UpdateFromEvent(nsIDOMEvent *aDOMEvent)
return NS_OK;
}
nsresult
NS_IMETHODIMP
nsWidgetUtils::MouseDown(nsIDOMEvent* aDOMEvent)
{
g_is_scrollable = PR_FALSE;
@ -224,7 +237,7 @@ nsWidgetUtils::StopPanningCallback(nsITimer *timer, void *closure)
g_panning = PR_FALSE;
}
nsresult
NS_IMETHODIMP
nsWidgetUtils::MouseUp(nsIDOMEvent* aDOMEvent)
{
nsCOMPtr <nsIDOMMouseEvent> mouseEvent;
@ -250,7 +263,7 @@ nsWidgetUtils::MouseUp(nsIDOMEvent* aDOMEvent)
return NS_OK;
}
nsresult
NS_IMETHODIMP
nsWidgetUtils::MouseMove(nsIDOMEvent* aDOMEvent)
{
if (!g_is_scrollable) return NS_OK;
@ -334,22 +347,40 @@ nsWidgetUtils::ShouldLoad(PRUint32 aContentType,
return NS_OK;
}
NS_IMETHODIMP
nsWidgetUtils::MouseClick(nsIDOMEvent* aDOMEvent)
{
return NS_OK;
}
NS_IMETHODIMP
nsWidgetUtils::MouseDblClick(nsIDOMEvent* aDOMEvent)
{
return NS_OK;
}
NS_IMETHODIMP
nsWidgetUtils::HandleEvent(nsIDOMEvent* aDOMEvent)
{
nsAutoString eventType;
aEvent->GetType(eventType);
return NS_OK;
}
if (eventType.EqualsLiteral("mousedown")) {
return MouseDown(aEvent);
}
if (eventType.EqualsLiteral("mouseup")) {
return MouseUp(aEvent);
}
if (eventType.EqualsLiteral("mousemove")) {
return MouseMove(aEvent);
}
NS_IMETHODIMP
nsWidgetUtils::MouseOver(nsIDOMEvent* aDOMEvent)
{
return NS_OK;
}
NS_IMETHODIMP
nsWidgetUtils::MouseOut(nsIDOMEvent* aDOMEvent)
{
return NS_OK;
}
NS_IMETHODIMP
nsWidgetUtils::DragMove(nsIDOMEvent* aDOMEvent)
{
return NS_OK;
}
@ -434,12 +465,20 @@ nsWidgetUtils::RemoveWindowListeners(nsIDOMWindow *aDOMWin)
// Use capturing, otherwise the normal find next will get activated when ours should
// Remove DOM Text listener for IME text events
chromeEventHandler->RemoveEventListener(NS_LITERAL_STRING("mousedown"),
this, PR_FALSE);
chromeEventHandler->RemoveEventListener(NS_LITERAL_STRING("mouseup"),
this, PR_FALSE);
chromeEventHandler->RemoveEventListener(NS_LITERAL_STRING("mousemove"),
this, PR_FALSE);
rv = chromeEventHandler->
RemoveEventListenerByIID(static_cast<nsIDOMMouseListener*>(this),
NS_GET_IID(nsIDOMMouseListener));
if (NS_FAILED(rv)) {
NS_WARNING("Failed to add Mouse Motion listener\n");
return;
}
rv = chromeEventHandler->
RemoveEventListenerByIID(static_cast<nsIDOMMouseMotionListener*>(this),
NS_GET_IID(nsIDOMMouseMotionListener));
if (NS_FAILED(rv)) {
NS_WARNING("Failed to add Mouse Motion listener\n");
return;
}
}
void
@ -455,23 +494,27 @@ nsWidgetUtils::AttachWindowListeners(nsIDOMWindow *aDOMWin)
// Use capturing, otherwise the normal find next will get activated when ours should
// Attach menu listeners, this will help us ignore keystrokes meant for menus
chromeEventHandler->AddEventListener(NS_LITERAL_STRING("mousedown"), this,
PR_FALSE, PR_FALSE);
chromeEventHandler->AddEventListener(NS_LITERAL_STRING("mouseup"), this,
PR_FALSE, PR_FALSE);
chromeEventHandler->AddEventListener(NS_LITERAL_STRING("mousemove"), this,
PR_FALSE, PR_FALSE);
rv = chromeEventHandler->
AddEventListenerByIID(static_cast<nsIDOMMouseListener*>(this),
NS_GET_IID(nsIDOMMouseListener));
if (NS_FAILED(rv)) {
NS_WARNING("Failed to add Mouse Motion listener\n");
return;
}
rv = chromeEventHandler->
AddEventListenerByIID(static_cast<nsIDOMMouseMotionListener*>(this),
NS_GET_IID(nsIDOMMouseMotionListener));
if (NS_FAILED(rv)) {
NS_WARNING("Failed to add Mouse Motion listener\n");
return;
}
}
nsWidgetUtils::~nsWidgetUtils()
{
}
NS_IMPL_ISUPPORTS4(nsWidgetUtils,
nsIObserver,
nsIDOMEventListener,
nsIContentPolicy,
nsISupportsWeakReference)
NS_IMPL_ISUPPORTS5(nsWidgetUtils, nsIObserver, nsIDOMMouseMotionListener, nsIDOMMouseListener, nsIContentPolicy, nsISupportsWeakReference)
NS_IMETHODIMP
nsWidgetUtils::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *aData)