--- a/editor/libeditor/base/Makefile.in
+++ b/editor/libeditor/base/Makefile.in
@@ -53,16 +53,17 @@ LIBXUL_LIBRARY = 1
# Internal header files, needed by other editor sublibs:
INTERNAL_HDR_DIR = ../internal
CPPSRCS = \
nsEditor.cpp \
nsEditorCommands.cpp \
nsEditorController.cpp \
+ nsEditorEventListener.cpp \
nsEditorUtils.cpp \
nsSelectionState.cpp \
$(NULL)
# Transactions: we'd like to split these off,
# but currently they and nsEditor are too intertwined!
CPPSRCS += \
EditTxn.cpp \
--- a/editor/libeditor/base/nsEditor.cpp
+++ b/editor/libeditor/base/nsEditor.cpp
@@ -101,16 +101,17 @@
#include "SplitElementTxn.h"
#include "JoinElementTxn.h"
#include "nsStyleSheetTxns.h"
#include "IMETextTxn.h"
#include "nsString.h"
#include "nsEditor.h"
#include "nsEditorUtils.h"
+#include "nsEditorEventListener.h"
#include "nsISelectionDisplay.h"
#include "nsIInlineSpellChecker.h"
#include "nsINameSpaceManager.h"
#include "nsIHTMLDocument.h"
#include "nsIParserService.h"
#include "nsITransferable.h"
@@ -175,40 +176,30 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ns
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mInlineSpellChecker)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mTxnMgr)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mIMETextRangeList)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mIMETextNode)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMARRAY(mActionListeners)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMARRAY(mEditorObservers)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMARRAY(mDocStateListeners)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mEventTarget)
- NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mKeyListenerP)
- NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mMouseListenerP)
- NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mTextListenerP)
- NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mCompositionListenerP)
- NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mDragListenerP)
- NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mFocusListenerP)
+ NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mEventListener)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsEditor)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mRootElement)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mInlineSpellChecker)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mTxnMgr)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mIMETextRangeList)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mIMETextNode)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMARRAY(mActionListeners)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMARRAY(mEditorObservers)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMARRAY(mDocStateListeners)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mEventTarget)
- NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mKeyListenerP)
- NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mMouseListenerP)
- NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mTextListenerP)
- NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mCompositionListenerP)
- NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mDragListenerP)
- NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mFocusListenerP)
+ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mEventListener)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsEditor)
NS_INTERFACE_MAP_ENTRY(nsIMutationObserver)
NS_INTERFACE_MAP_ENTRY(nsIPhonetic)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY(nsIEditorIMESupport)
NS_INTERFACE_MAP_ENTRY(nsIEditor)
@@ -312,21 +303,29 @@ nsEditor::PostCreate()
// update the UI with our state
NotifyDocumentListeners(eDocumentCreated);
NotifyDocumentListeners(eDocumentStateChanged);
return NS_OK;
}
nsresult
+nsEditor::CreateEventListeners()
+{
+ NS_ENSURE_TRUE(!mEventListener, NS_ERROR_ALREADY_INITIALIZED);
+ mEventListener = do_QueryInterface(
+ static_cast<nsIDOMKeyListener*>(new nsEditorEventListener(this)));
+ NS_ENSURE_TRUE(mEventListener, NS_ERROR_OUT_OF_MEMORY);
+ return NS_OK;
+}
+
+nsresult
nsEditor::InstallEventListeners()
{
- NS_ENSURE_TRUE(mDocWeak && mPresShellWeak && mKeyListenerP &&
- mMouseListenerP && mFocusListenerP && mTextListenerP &&
- mCompositionListenerP && mDragListenerP,
+ NS_ENSURE_TRUE(mDocWeak && mPresShellWeak && mEventListener,
NS_ERROR_NOT_INITIALIZED);
nsCOMPtr<nsPIDOMEventTarget> piTarget = GetPIDOMEventTarget();
if (!piTarget) {
RemoveEventListeners();
return NS_ERROR_FAILURE;
}
@@ -335,126 +334,118 @@ nsEditor::InstallEventListeners()
// register the event listeners with the listener manager
nsCOMPtr<nsIDOMEventGroup> sysGroup;
piTarget->GetSystemEventGroup(getter_AddRefs(sysGroup));
nsIEventListenerManager* elmP = piTarget->GetListenerManager(PR_TRUE);
if (sysGroup && elmP)
{
- rv = elmP->AddEventListenerByType(mKeyListenerP,
+ rv = elmP->AddEventListenerByType(mEventListener,
NS_LITERAL_STRING("keypress"),
NS_EVENT_FLAG_BUBBLE |
NS_PRIV_EVENT_UNTRUSTED_PERMITTED,
sysGroup);
NS_ASSERTION(NS_SUCCEEDED(rv),
"failed to register key listener in system group");
}
- rv |= piTarget->AddEventListenerByIID(mMouseListenerP,
+ rv |= piTarget->AddEventListenerByIID(mEventListener,
NS_GET_IID(nsIDOMMouseListener));
if (elmP) {
// Focus event doesn't bubble so adding the listener to capturing phase.
// Make sure this works after bug 235441 gets fixed.
- rv |= elmP->AddEventListenerByIID(mFocusListenerP,
+ rv |= elmP->AddEventListenerByIID(mEventListener,
NS_GET_IID(nsIDOMFocusListener),
NS_EVENT_FLAG_CAPTURE);
}
- rv |= piTarget->AddEventListenerByIID(mTextListenerP,
+ rv |= piTarget->AddEventListenerByIID(mEventListener,
NS_GET_IID(nsIDOMTextListener));
- rv |= piTarget->AddEventListenerByIID(mCompositionListenerP,
+ rv |= piTarget->AddEventListenerByIID(mEventListener,
NS_GET_IID(nsIDOMCompositionListener));
nsCOMPtr<nsIDOMEventTarget> target(do_QueryInterface(piTarget));
if (target) {
// See bug 455215, we cannot use the standard dragstart event yet
- rv |= target->AddEventListener(NS_LITERAL_STRING("draggesture"), mDragListenerP, PR_FALSE);
- rv |= target->AddEventListener(NS_LITERAL_STRING("dragenter"), mDragListenerP, PR_FALSE);
- rv |= target->AddEventListener(NS_LITERAL_STRING("dragover"), mDragListenerP, PR_FALSE);
- rv |= target->AddEventListener(NS_LITERAL_STRING("dragleave"), mDragListenerP, PR_FALSE);
- rv |= target->AddEventListener(NS_LITERAL_STRING("drop"), mDragListenerP, PR_FALSE);
+ rv |= target->AddEventListener(NS_LITERAL_STRING("draggesture"),
+ mEventListener, PR_FALSE);
+ rv |= target->AddEventListener(NS_LITERAL_STRING("dragenter"),
+ mEventListener, PR_FALSE);
+ rv |= target->AddEventListener(NS_LITERAL_STRING("dragover"),
+ mEventListener, PR_FALSE);
+ rv |= target->AddEventListener(NS_LITERAL_STRING("dragleave"),
+ mEventListener, PR_FALSE);
+ rv |= target->AddEventListener(NS_LITERAL_STRING("drop"),
+ mEventListener, PR_FALSE);
}
if (NS_FAILED(rv))
{
NS_ERROR("failed to register some event listeners");
RemoveEventListeners();
}
return rv;
}
void
nsEditor::RemoveEventListeners()
{
- if (!mDocWeak)
+ if (!mDocWeak || !mEventListener)
{
return;
}
nsCOMPtr<nsPIDOMEventTarget> piTarget = GetPIDOMEventTarget();
if (piTarget)
{
// unregister the event listeners with the DOM event target
nsCOMPtr<nsIEventListenerManager> elmP =
piTarget->GetListenerManager(PR_TRUE);
- if (mKeyListenerP)
- {
- nsCOMPtr<nsIDOMEventGroup> sysGroup;
- piTarget->GetSystemEventGroup(getter_AddRefs(sysGroup));
- if (sysGroup && elmP)
- {
- elmP->RemoveEventListenerByType(mKeyListenerP,
- NS_LITERAL_STRING("keypress"),
- NS_EVENT_FLAG_BUBBLE |
- NS_PRIV_EVENT_UNTRUSTED_PERMITTED,
- sysGroup);
- }
- }
-
- if (mMouseListenerP)
- {
- piTarget->RemoveEventListenerByIID(mMouseListenerP,
- NS_GET_IID(nsIDOMMouseListener));
- }
-
- if (mFocusListenerP && elmP)
+ nsCOMPtr<nsIDOMEventGroup> sysGroup;
+ piTarget->GetSystemEventGroup(getter_AddRefs(sysGroup));
+ if (sysGroup && elmP)
{
- elmP->RemoveEventListenerByIID(mFocusListenerP,
- NS_GET_IID(nsIDOMFocusListener),
- NS_EVENT_FLAG_CAPTURE);
- }
-
- if (mTextListenerP)
- {
- piTarget->RemoveEventListenerByIID(mTextListenerP,
- NS_GET_IID(nsIDOMTextListener));
+ elmP->RemoveEventListenerByType(mEventListener,
+ NS_LITERAL_STRING("keypress"),
+ NS_EVENT_FLAG_BUBBLE |
+ NS_PRIV_EVENT_UNTRUSTED_PERMITTED,
+ sysGroup);
}
- if (mCompositionListenerP)
- {
- piTarget->RemoveEventListenerByIID(mCompositionListenerP,
- NS_GET_IID(nsIDOMCompositionListener));
- }
-
- if (mDragListenerP)
- {
- nsCOMPtr<nsIDOMEventTarget> target(do_QueryInterface(piTarget));
- if (target) {
- target->RemoveEventListener(NS_LITERAL_STRING("draggesture"), mDragListenerP, PR_FALSE);
- target->RemoveEventListener(NS_LITERAL_STRING("dragenter"), mDragListenerP, PR_FALSE);
- target->RemoveEventListener(NS_LITERAL_STRING("dragover"), mDragListenerP, PR_FALSE);
- target->RemoveEventListener(NS_LITERAL_STRING("dragleave"), mDragListenerP, PR_FALSE);
- target->RemoveEventListener(NS_LITERAL_STRING("drop"), mDragListenerP, PR_FALSE);
- }
+ piTarget->RemoveEventListenerByIID(mEventListener,
+ NS_GET_IID(nsIDOMMouseListener));
+
+ elmP->RemoveEventListenerByIID(mEventListener,
+ NS_GET_IID(nsIDOMFocusListener),
+ NS_EVENT_FLAG_CAPTURE);
+
+ piTarget->RemoveEventListenerByIID(mEventListener,
+ NS_GET_IID(nsIDOMTextListener));
+
+ piTarget->RemoveEventListenerByIID(mEventListener,
+ NS_GET_IID(nsIDOMCompositionListener));
+
+ nsCOMPtr<nsIDOMEventTarget> target(do_QueryInterface(piTarget));
+ if (target) {
+ target->RemoveEventListener(NS_LITERAL_STRING("draggesture"),
+ mEventListener, PR_FALSE);
+ target->RemoveEventListener(NS_LITERAL_STRING("dragenter"),
+ mEventListener, PR_FALSE);
+ target->RemoveEventListener(NS_LITERAL_STRING("dragover"),
+ mEventListener, PR_FALSE);
+ target->RemoveEventListener(NS_LITERAL_STRING("dragleave"),
+ mEventListener, PR_FALSE);
+ target->RemoveEventListener(NS_LITERAL_STRING("drop"),
+ mEventListener, PR_FALSE);
}
}
}
PRBool
nsEditor::GetDesiredSpellCheckState()
{
// Check user override on this element
--- a/editor/libeditor/base/nsEditor.h
+++ b/editor/libeditor/base/nsEditor.h
@@ -343,17 +343,17 @@ protected:
// Get nsIWidget interface
nsresult GetWidget(nsIWidget **aWidget);
// install the event listeners for the editor
nsresult InstallEventListeners();
- virtual nsresult CreateEventListeners() = 0;
+ virtual nsresult CreateEventListeners();
// unregister and release our event listeners
virtual void RemoveEventListeners();
/**
* Return true if spellchecking should be enabled for this editor.
*/
PRBool GetDesiredSpellCheckState();
@@ -633,22 +633,17 @@ protected:
PRInt8 mDocDirtyState; // -1 = not initialized
nsWeakPtr mDocWeak; // weak reference to the nsIDOMDocument
// The form field as an event receiver
nsCOMPtr<nsPIDOMEventTarget> mEventTarget;
nsString* mPhonetic;
- nsCOMPtr<nsIDOMEventListener> mKeyListenerP;
- nsCOMPtr<nsIDOMEventListener> mMouseListenerP;
- nsCOMPtr<nsIDOMEventListener> mTextListenerP;
- nsCOMPtr<nsIDOMEventListener> mCompositionListenerP;
- nsCOMPtr<nsIDOMEventListener> mDragListenerP;
- nsCOMPtr<nsIDOMEventListener> mFocusListenerP;
+ nsCOMPtr<nsIDOMEventListener> mEventListener;
friend PRBool NSCanUnload(nsISupports* serviceMgr);
friend class nsAutoTxnsConserveSelection;
friend class nsAutoSelectionReset;
friend class nsAutoRules;
friend class nsRangeUpdater;
};
rename from editor/libeditor/text/nsEditorEventListeners.cpp
rename to editor/libeditor/base/nsEditorEventListener.cpp
--- a/editor/libeditor/text/nsEditorEventListeners.cpp
+++ b/editor/libeditor/base/nsEditorEventListener.cpp
@@ -17,32 +17,34 @@
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Pierre Phaneuf <pp@ludusdesign.com>
+ * Masayuki Nakano <masayuki@d-toybox.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
-#include "nsEditorEventListeners.h"
+#include "nsEditorEventListener.h"
#include "nsEditor.h"
+#include "nsIPlaintextEditor.h"
#include "nsIDOMEvent.h"
#include "nsIDOMNSEvent.h"
#include "nsIDOMDocument.h"
#include "nsIDocument.h"
#include "nsIPresShell.h"
#include "nsISelection.h"
#include "nsISelectionController.h"
@@ -69,61 +71,97 @@
#include "nsEditorUtils.h"
#include "nsIDOMEventTarget.h"
#include "nsIEventStateManager.h"
#include "nsISelectionPrivate.h"
#include "nsIDOMDragEvent.h"
#include "nsIFocusManager.h"
#include "nsIDOMWindow.h"
-//#define DEBUG_IME
+nsEditorEventListener::nsEditorEventListener(nsEditor* aEditor) :
+ mEditor(aEditor), mCaretDrawn(PR_FALSE), mCommitText(PR_FALSE),
+ mInTransaction(PR_FALSE)
+{
+}
-/*
- * nsTextEditorKeyListener implementation
- */
-
-NS_IMPL_ISUPPORTS2(nsTextEditorKeyListener, nsIDOMEventListener, nsIDOMKeyListener)
-
-
-nsTextEditorKeyListener::nsTextEditorKeyListener()
+nsEditorEventListener::~nsEditorEventListener()
{
}
-
-
-nsTextEditorKeyListener::~nsTextEditorKeyListener()
+already_AddRefed<nsIPresShell>
+nsEditorEventListener::GetPresShell()
{
+ NS_ENSURE_TRUE(mEditor, nsnull);
+ // mEditor is nsEditor or its inherited class.
+ // This is guaranteed by constructor.
+ nsCOMPtr<nsIPresShell> ps;
+ static_cast<nsEditor*>(mEditor)->GetPresShell(getter_AddRefs(ps));
+ return ps.forget();
}
+/**
+ * nsISupports implementation
+ */
-nsresult
-nsTextEditorKeyListener::HandleEvent(nsIDOMEvent* aEvent)
+NS_IMPL_ADDREF(nsEditorEventListener)
+NS_IMPL_RELEASE(nsEditorEventListener)
+
+NS_INTERFACE_MAP_BEGIN(nsEditorEventListener)
+ NS_INTERFACE_MAP_ENTRY(nsIDOMKeyListener)
+ NS_INTERFACE_MAP_ENTRY(nsIDOMTextListener)
+ NS_INTERFACE_MAP_ENTRY(nsIDOMCompositionListener)
+ NS_INTERFACE_MAP_ENTRY(nsIDOMMouseListener)
+ NS_INTERFACE_MAP_ENTRY(nsIDOMFocusListener)
+ NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIDOMEventListener, nsIDOMKeyListener)
+ NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMKeyListener)
+NS_INTERFACE_MAP_END
+
+/**
+ * nsIDOMEventListener implementation
+ */
+
+NS_IMETHODIMP
+nsEditorEventListener::HandleEvent(nsIDOMEvent* aEvent)
+{
+ nsCOMPtr<nsIDOMDragEvent> dragEvent = do_QueryInterface(aEvent);
+ if (dragEvent) {
+ nsAutoString eventType;
+ aEvent->GetType(eventType);
+ if (eventType.EqualsLiteral("draggesture"))
+ return DragGesture(dragEvent);
+ if (eventType.EqualsLiteral("dragenter"))
+ return DragEnter(dragEvent);
+ if (eventType.EqualsLiteral("dragover"))
+ return DragOver(dragEvent);
+ if (eventType.EqualsLiteral("dragleave"))
+ return DragLeave(dragEvent);
+ if (eventType.EqualsLiteral("drop"))
+ return Drop(dragEvent);
+ }
+ return NS_OK;
+}
+
+/**
+ * nsIDOMKeyListener implementation
+ */
+
+NS_IMETHODIMP
+nsEditorEventListener::KeyDown(nsIDOMEvent* aKeyEvent)
{
return NS_OK;
}
-// individual key handlers return NS_OK to indicate NOT consumed
-// by default, an error is returned indicating event is consumed
-// joki is fixing this interface.
-nsresult
-nsTextEditorKeyListener::KeyDown(nsIDOMEvent* aKeyEvent)
+NS_IMETHODIMP
+nsEditorEventListener::KeyUp(nsIDOMEvent* aKeyEvent)
{
return NS_OK;
}
-
-nsresult
-nsTextEditorKeyListener::KeyUp(nsIDOMEvent* aKeyEvent)
-{
- return NS_OK;
-}
-
-
-nsresult
-nsTextEditorKeyListener::KeyPress(nsIDOMEvent* aKeyEvent)
+NS_IMETHODIMP
+nsEditorEventListener::KeyPress(nsIDOMEvent* aKeyEvent)
{
// DOM event handling happens in two passes, the client pass and the system
// pass. We do all of our processing in the system pass, to allow client
// handlers the opportunity to cancel events and prevent typing in the editor.
// If the client pass cancelled the event, defaultPrevented will be true
// below.
nsCOMPtr<nsIDOMNSUIEvent> nsUIEvent = do_QueryInterface(aKeyEvent);
@@ -253,43 +291,22 @@ nsTextEditorKeyListener::KeyPress(nsIDOM
return NS_OK;
}
}
textEditor->HandleKeyPress(keyEvent);
return NS_OK; // we don't PreventDefault() here or keybindings like control-x won't work
}
-
-/*
- * nsTextEditorMouseListener implementation
+/**
+ * nsIDOMMouseListener implementation
*/
-NS_IMPL_ISUPPORTS2(nsTextEditorMouseListener, nsIDOMEventListener, nsIDOMMouseListener)
-
-
-nsTextEditorMouseListener::nsTextEditorMouseListener()
-{
-}
-
-
-
-nsTextEditorMouseListener::~nsTextEditorMouseListener()
-{
-}
-
-
-nsresult
-nsTextEditorMouseListener::HandleEvent(nsIDOMEvent* aEvent)
-{
- return NS_OK;
-}
-
-nsresult
-nsTextEditorMouseListener::MouseClick(nsIDOMEvent* aMouseEvent)
+NS_IMETHODIMP
+nsEditorEventListener::MouseClick(nsIDOMEvent* aMouseEvent)
{
nsCOMPtr<nsIDOMMouseEvent> mouseEvent = do_QueryInterface(aMouseEvent);
nsCOMPtr<nsIDOMNSEvent> nsevent = do_QueryInterface(aMouseEvent);
PRBool isTrusted = PR_FALSE;
if (!mouseEvent || !nsevent ||
NS_FAILED(nsevent->GetIsTrusted(&isTrusted)) || !isTrusted) {
// Non-ui or non-trusted event passed in. Bad things.
return NS_OK;
@@ -372,91 +389,57 @@ nsTextEditorMouseListener::MouseClick(ns
// We processed the event, whether drop/paste succeeded or not
return NS_OK;
}
}
}
return NS_OK;
}
-nsresult
-nsTextEditorMouseListener::MouseDown(nsIDOMEvent* aMouseEvent)
+NS_IMETHODIMP
+nsEditorEventListener::MouseDown(nsIDOMEvent* aMouseEvent)
{
nsCOMPtr<nsIEditorIMESupport> imeEditor = do_QueryInterface(mEditor);
if (!imeEditor)
return NS_OK;
imeEditor->ForceCompositionEnd();
return NS_OK;
}
-nsresult
-nsTextEditorMouseListener::MouseUp(nsIDOMEvent* aMouseEvent)
-{
- return NS_OK;
-}
-
-
-nsresult
-nsTextEditorMouseListener::MouseDblClick(nsIDOMEvent* aMouseEvent)
+NS_IMETHODIMP
+nsEditorEventListener::MouseUp(nsIDOMEvent* aMouseEvent)
{
return NS_OK;
}
-
-
-nsresult
-nsTextEditorMouseListener::MouseOver(nsIDOMEvent* aMouseEvent)
-{
- return NS_OK;
-}
-
-
-
-nsresult
-nsTextEditorMouseListener::MouseOut(nsIDOMEvent* aMouseEvent)
+NS_IMETHODIMP
+nsEditorEventListener::MouseDblClick(nsIDOMEvent* aMouseEvent)
{
return NS_OK;
}
-
-/*
- * nsTextEditorTextListener implementation
- */
-
-NS_IMPL_ISUPPORTS2(nsTextEditorTextListener, nsIDOMEventListener, nsIDOMTextListener)
-
-
-nsTextEditorTextListener::nsTextEditorTextListener()
-: mCommitText(PR_FALSE),
- mInTransaction(PR_FALSE)
+NS_IMETHODIMP
+nsEditorEventListener::MouseOver(nsIDOMEvent* aMouseEvent)
{
-}
-
-
-nsTextEditorTextListener::~nsTextEditorTextListener()
-{
-}
-
-nsresult
-nsTextEditorTextListener::HandleEvent(nsIDOMEvent* aEvent)
-{
-#ifdef DEBUG_IME
- printf("nsTextEditorTextListener::HandleEvent\n");
-#endif
return NS_OK;
}
-
+NS_IMETHODIMP
+nsEditorEventListener::MouseOut(nsIDOMEvent* aMouseEvent)
+{
+ return NS_OK;
+}
-nsresult
-nsTextEditorTextListener::HandleText(nsIDOMEvent* aTextEvent)
+/**
+ * nsIDOMTextListener implementation
+ */
+
+NS_IMETHODIMP
+nsEditorEventListener::HandleText(nsIDOMEvent* aTextEvent)
{
-#ifdef DEBUG_IME
- printf("nsTextEditorTextListener::HandleText\n");
-#endif
nsCOMPtr<nsIPrivateTextEvent> textEvent = do_QueryInterface(aTextEvent);
if (!textEvent) {
//non-ui event passed in. bad things.
return NS_OK;
}
nsAutoString composedText;
nsresult result;
@@ -468,87 +451,47 @@ nsTextEditorTextListener::HandleText(nsI
textEventReply = textEvent->GetEventReply();
nsCOMPtr<nsIEditorIMESupport> imeEditor = do_QueryInterface(mEditor, &result);
if (imeEditor) {
PRUint32 flags;
// if we are readonly or disabled, then do nothing.
if (NS_SUCCEEDED(mEditor->GetFlags(&flags))) {
if (flags & nsIPlaintextEditor::eEditorReadonlyMask ||
flags & nsIPlaintextEditor::eEditorDisabledMask) {
-#if DEBUG_IME
- printf("nsTextEditorTextListener::HandleText, Readonly or Disabled\n");
-#endif
return NS_OK;
}
}
result = imeEditor->SetCompositionString(composedText,textRangeList,textEventReply);
}
return result;
}
-/*
- * nsTextEditorDragListener implementation
+/**
+ * Drag event implementation
*/
-nsTextEditorDragListener::nsTextEditorDragListener()
-: mEditor(nsnull)
-, mPresShell(nsnull)
-, mCaretDrawn(PR_FALSE)
-{
-}
-
-nsTextEditorDragListener::~nsTextEditorDragListener()
-{
-}
-
-NS_IMPL_ISUPPORTS1(nsTextEditorDragListener, nsIDOMEventListener)
-
nsresult
-nsTextEditorDragListener::HandleEvent(nsIDOMEvent* aEvent)
-{
- // make sure it's a drag event
- nsCOMPtr<nsIDOMDragEvent> dragEvent = do_QueryInterface(aEvent);
- if (dragEvent) {
- nsAutoString eventType;
- aEvent->GetType(eventType);
- if (eventType.EqualsLiteral("draggesture"))
- return DragGesture(dragEvent);
- if (eventType.EqualsLiteral("dragenter"))
- return DragEnter(dragEvent);
- if (eventType.EqualsLiteral("dragover"))
- return DragOver(dragEvent);
- if (eventType.EqualsLiteral("dragleave"))
- return DragLeave(dragEvent);
- if (eventType.EqualsLiteral("drop"))
- return Drop(dragEvent);
- }
- return NS_OK;
-}
-
-
-nsresult
-nsTextEditorDragListener::DragGesture(nsIDOMDragEvent* aDragEvent)
+nsEditorEventListener::DragGesture(nsIDOMDragEvent* aDragEvent)
{
if ( !mEditor )
return NS_ERROR_NULL_POINTER;
// ...figure out if a drag should be started...
PRBool canDrag;
nsresult rv = mEditor->CanDrag(aDragEvent, &canDrag);
if ( NS_SUCCEEDED(rv) && canDrag )
rv = mEditor->DoDrag(aDragEvent);
return rv;
}
-
nsresult
-nsTextEditorDragListener::DragEnter(nsIDOMDragEvent* aDragEvent)
+nsEditorEventListener::DragEnter(nsIDOMDragEvent* aDragEvent)
{
- nsCOMPtr<nsIPresShell> presShell = do_QueryReferent(mPresShell);
+ nsCOMPtr<nsIPresShell> presShell = GetPresShell();
if (!presShell)
return NS_OK;
if (!mCaret)
{
NS_NewCaret(getter_AddRefs(mCaret));
if (mCaret)
{
@@ -558,19 +501,18 @@ nsTextEditorDragListener::DragEnter(nsID
mCaretDrawn = PR_FALSE;
}
presShell->SetCaret(mCaret);
return DragOver(aDragEvent);
}
-
nsresult
-nsTextEditorDragListener::DragOver(nsIDOMDragEvent* aDragEvent)
+nsEditorEventListener::DragOver(nsIDOMDragEvent* aDragEvent)
{
// XXX cache this between drag events?
nsresult rv;
nsCOMPtr<nsIDragService> dragService = do_GetService("@mozilla.org/widget/dragservice;1", &rv);
if (!dragService) return rv;
// does the drag have flavors we can accept?
nsCOMPtr<nsIDragSession> dragSession;
@@ -620,48 +562,45 @@ nsTextEditorDragListener::DragOver(nsIDO
mCaret->EraseCaret();
mCaretDrawn = PR_FALSE;
}
}
return NS_OK;
}
-
nsresult
-nsTextEditorDragListener::DragLeave(nsIDOMDragEvent* aDragEvent)
+nsEditorEventListener::DragLeave(nsIDOMDragEvent* aDragEvent)
{
if (mCaret && mCaretDrawn)
{
mCaret->EraseCaret();
mCaretDrawn = PR_FALSE;
}
- nsCOMPtr<nsIPresShell> presShell = do_QueryReferent(mPresShell);
+ nsCOMPtr<nsIPresShell> presShell = GetPresShell();
if (presShell)
presShell->RestoreCaret();
return NS_OK;
}
-
-
nsresult
-nsTextEditorDragListener::Drop(nsIDOMDragEvent* aMouseEvent)
+nsEditorEventListener::Drop(nsIDOMDragEvent* aMouseEvent)
{
if (mCaret)
{
if (mCaretDrawn)
{
mCaret->EraseCaret();
mCaretDrawn = PR_FALSE;
}
mCaret->SetCaretVisible(PR_FALSE); // hide it, so that it turns off its timer
- nsCOMPtr<nsIPresShell> presShell = do_QueryReferent(mPresShell);
+ nsCOMPtr<nsIPresShell> presShell = GetPresShell();
if (presShell)
{
presShell->RestoreCaret();
}
}
if (!mEditor)
return NS_ERROR_FAILURE;
@@ -699,20 +638,18 @@ nsTextEditorDragListener::Drop(nsIDOMDra
aMouseEvent->StopPropagation();
aMouseEvent->PreventDefault();
// Beware! This may flush notifications via synchronous
// ScrollSelectionIntoView.
return mEditor->InsertFromDrop(aMouseEvent);
}
-
-
PRBool
-nsTextEditorDragListener::CanDrop(nsIDOMDragEvent* aEvent)
+nsEditorEventListener::CanDrop(nsIDOMDragEvent* aEvent)
{
// if the target doc is read-only, we can't drop
PRUint32 flags;
if (NS_FAILED(mEditor->GetFlags(&flags)))
return PR_FALSE;
if ((flags & nsIPlaintextEditor::eEditorDisabledMask) ||
(flags & nsIPlaintextEditor::eEditorReadonlyMask)) {
@@ -801,188 +738,47 @@ nsTextEditorDragListener::CanDrop(nsIDOM
return PR_FALSE; //okay, now you can bail, we are over the orginal selection
}
}
}
return PR_TRUE;
}
-
-nsTextEditorCompositionListener::nsTextEditorCompositionListener()
-{
-}
+/**
+ * nsIDOMCompositionListener implementation
+ */
-nsTextEditorCompositionListener::~nsTextEditorCompositionListener()
-{
-}
-
-NS_IMPL_ISUPPORTS2(nsTextEditorCompositionListener, nsIDOMEventListener, nsIDOMCompositionListener)
-
-nsresult
-nsTextEditorCompositionListener::HandleEvent(nsIDOMEvent* aEvent)
+NS_IMETHODIMP
+nsEditorEventListener::HandleStartComposition(nsIDOMEvent* aCompositionEvent)
{
-#ifdef DEBUG_IME
- printf("nsTextEditorCompositionListener::HandleEvent\n");
-#endif
- return NS_OK;
-}
-
-void nsTextEditorCompositionListener::SetEditor(nsIEditor *aEditor)
-{
- nsCOMPtr<nsIEditorIMESupport> imeEditor = do_QueryInterface(aEditor);
- if (!imeEditor) return; // should return an error here!
-
- // note that we don't hold an extra reference here.
- mEditor = imeEditor;
-}
-
-nsresult
-nsTextEditorCompositionListener::HandleStartComposition(nsIDOMEvent* aCompositionEvent)
-{
-#ifdef DEBUG_IME
- printf("nsTextEditorCompositionListener::HandleStartComposition\n");
-#endif
nsCOMPtr<nsIPrivateCompositionEvent> pCompositionEvent = do_QueryInterface(aCompositionEvent);
if (!pCompositionEvent) return NS_ERROR_FAILURE;
-
+
nsTextEventReply* eventReply;
nsresult rv = pCompositionEvent->GetCompositionReply(&eventReply);
if (NS_FAILED(rv)) return rv;
- return mEditor->BeginComposition(eventReply);
-}
-
-nsresult
-nsTextEditorCompositionListener::HandleEndComposition(nsIDOMEvent* aCompositionEvent)
-{
-#ifdef DEBUG_IME
- printf("nsTextEditorCompositionListener::HandleEndComposition\n");
-#endif
- return mEditor->EndComposition();
-}
-
-/*
- * Factory functions
- */
-
-
-
-nsresult
-NS_NewEditorKeyListener(nsIDOMEventListener ** aInstancePtrResult,
- nsIEditor *aEditor)
-{
- nsTextEditorKeyListener* it = new nsTextEditorKeyListener();
- if (nsnull == it) {
- return NS_ERROR_OUT_OF_MEMORY;
- }
-
- it->SetEditor(aEditor);
-
- return it->QueryInterface(NS_GET_IID(nsIDOMEventListener), (void **) aInstancePtrResult);
-}
-
-
-
-nsresult
-NS_NewEditorMouseListener(nsIDOMEventListener ** aInstancePtrResult,
- nsIEditor *aEditor)
-{
- nsTextEditorMouseListener* it = new nsTextEditorMouseListener();
- if (nsnull == it) {
- return NS_ERROR_OUT_OF_MEMORY;
- }
-
- it->SetEditor(aEditor);
-
- return it->QueryInterface(NS_GET_IID(nsIDOMEventListener), (void **) aInstancePtrResult);
-}
-
-
-nsresult
-NS_NewEditorTextListener(nsIDOMEventListener** aInstancePtrResult, nsIEditor* aEditor)
-{
- nsTextEditorTextListener* it = new nsTextEditorTextListener();
- if (nsnull==it) {
- return NS_ERROR_OUT_OF_MEMORY;
- }
-
- it->SetEditor(aEditor);
-
- return it->QueryInterface(NS_GET_IID(nsIDOMEventListener), (void **) aInstancePtrResult);
+ nsCOMPtr<nsIEditorIMESupport> imeEditor = do_QueryInterface(mEditor);
+ NS_ASSERTION(imeEditor, "The editor doesn't support IME?");
+ return imeEditor->BeginComposition(eventReply);
}
-
-
-nsresult
-NS_NewEditorDragListener(nsIDOMEventListener ** aInstancePtrResult, nsIPresShell* aPresShell,
- nsIEditor *aEditor)
+NS_IMETHODIMP
+nsEditorEventListener::HandleEndComposition(nsIDOMEvent* aCompositionEvent)
{
- nsTextEditorDragListener* it = new nsTextEditorDragListener();
- if (nsnull == it) {
- return NS_ERROR_OUT_OF_MEMORY;
- }
-
- it->SetEditor(aEditor);
- it->SetPresShell(aPresShell);
-
- return it->QueryInterface(NS_GET_IID(nsIDOMEventListener), (void **) aInstancePtrResult);
-}
-
-nsresult
-NS_NewEditorCompositionListener(nsIDOMEventListener** aInstancePtrResult, nsIEditor* aEditor)
-{
- nsTextEditorCompositionListener* it = new nsTextEditorCompositionListener();
- if (nsnull==it) {
- return NS_ERROR_OUT_OF_MEMORY;
- }
- it->SetEditor(aEditor);
- return it->QueryInterface(NS_GET_IID(nsIDOMEventListener), (void **) aInstancePtrResult);
+ nsCOMPtr<nsIEditorIMESupport> imeEditor = do_QueryInterface(mEditor);
+ NS_ASSERTION(imeEditor, "The editor doesn't support IME?");
+ return imeEditor->EndComposition();
}
-nsresult
-NS_NewEditorFocusListener(nsIDOMEventListener ** aInstancePtrResult,
- nsIEditor *aEditor,
- nsIPresShell *aPresShell)
-{
- nsTextEditorFocusListener* it =
- new nsTextEditorFocusListener(aEditor, aPresShell);
- if (!it) {
- return NS_ERROR_OUT_OF_MEMORY;
- }
-
- return CallQueryInterface(it, aInstancePtrResult);
-}
-
-
-
-/*
- * nsTextEditorFocusListener implementation
+/**
+ * nsIDOMFocusListener implementation
*/
-NS_IMPL_ISUPPORTS2(nsTextEditorFocusListener, nsIDOMEventListener, nsIDOMFocusListener)
-
-
-nsTextEditorFocusListener::nsTextEditorFocusListener(nsIEditor *aEditor,
- nsIPresShell *aShell)
- : mEditor(aEditor),
- mPresShell(do_GetWeakReference(aShell))
-{
-}
-
-nsTextEditorFocusListener::~nsTextEditorFocusListener()
-{
-}
-
-nsresult
-nsTextEditorFocusListener::HandleEvent(nsIDOMEvent* aEvent)
-{
- return NS_OK;
-}
-
static already_AddRefed<nsIContent>
FindSelectionRoot(nsIEditor *aEditor, nsIContent *aContent)
{
PRUint32 flags;
aEditor->GetFlags(&flags);
nsIDocument *document = aContent->GetCurrentDoc();
if (!document) {
@@ -1020,18 +816,18 @@ FindSelectionRoot(nsIEditor *aEditor, ns
content = parent;
}
NS_IF_ADDREF(content);
return content;
}
-nsresult
-nsTextEditorFocusListener::Focus(nsIDOMEvent* aEvent)
+NS_IMETHODIMP
+nsEditorEventListener::Focus(nsIDOMEvent* aEvent)
{
NS_ENSURE_ARG(aEvent);
nsCOMPtr<nsIDOMEventTarget> target;
aEvent->GetTarget(getter_AddRefs(target));
// turn on selection and caret
if (mEditor)
@@ -1067,17 +863,17 @@ nsTextEditorFocusListener::Focus(nsIDOME
nsCOMPtr<nsISelectionController> selCon;
mEditor->GetSelectionController(getter_AddRefs(selCon));
if (selCon && (targetIsEditableDoc || editableRoot))
{
nsCOMPtr<nsISelection> selection;
selCon->GetSelection(nsISelectionController::SELECTION_NORMAL,
getter_AddRefs(selection));
- nsCOMPtr<nsIPresShell> presShell = do_QueryReferent(mPresShell);
+ nsCOMPtr<nsIPresShell> presShell = GetPresShell();
if (presShell) {
nsRefPtr<nsCaret> caret;
presShell->GetCaret(getter_AddRefs(caret));
if (caret) {
caret->SetIgnoreUserModify(PR_FALSE);
if (selection) {
caret->SetCaretDOMSelection(selection);
}
@@ -1105,18 +901,18 @@ nsTextEditorFocusListener::Focus(nsIDOME
}
}
}
}
}
return NS_OK;
}
-nsresult
-nsTextEditorFocusListener::Blur(nsIDOMEvent* aEvent)
+NS_IMETHODIMP
+nsEditorEventListener::Blur(nsIDOMEvent* aEvent)
{
// check if something else is focused. If another element is focused, then
// we should not change the selection.
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
NS_ENSURE_TRUE(fm, NS_OK);
nsCOMPtr<nsIDOMElement> element;
fm->GetFocusedElement(getter_AddRefs(element));
@@ -1139,17 +935,17 @@ nsTextEditorFocusListener::Blur(nsIDOMEv
getter_AddRefs(selection));
nsCOMPtr<nsISelectionPrivate> selectionPrivate =
do_QueryInterface(selection);
if (selectionPrivate) {
selectionPrivate->SetAncestorLimiter(nsnull);
}
- nsCOMPtr<nsIPresShell> presShell = do_QueryReferent(mPresShell);
+ nsCOMPtr<nsIPresShell> presShell = GetPresShell();
if (presShell) {
nsRefPtr<nsCaret> caret;
presShell->GetCaret(getter_AddRefs(caret));
if (caret) {
caret->SetIgnoreUserModify(PR_TRUE);
}
}
rename from editor/libeditor/text/nsEditorEventListeners.h
rename to editor/libeditor/base/nsEditorEventListener.h
--- a/editor/libeditor/text/nsEditorEventListeners.h
+++ b/editor/libeditor/base/nsEditorEventListener.h
@@ -15,277 +15,97 @@
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
+ * Masayuki Nakano <masayuki@d-toybox.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
-#ifndef editorInterfaces_h__
-#define editorInterfaces_h__
+#ifndef nsEditorEventListener_h__
+#define nsEditorEventListener_h__
#include "nsCOMPtr.h"
#include "nsIDOMEvent.h"
#include "nsIDOMKeyListener.h"
#include "nsIDOMMouseListener.h"
#include "nsIDOMTextListener.h"
#include "nsIDOMCompositionListener.h"
#include "nsIDOMFocusListener.h"
-#include "nsIEditor.h"
-#include "nsIPlaintextEditor.h"
#include "nsCaret.h"
-#include "nsIPresShell.h"
-#include "nsWeakPtr.h"
-#include "nsIWeakReferenceUtils.h"
+
+class nsEditor;
+class nsIDOMDragEvent;
+class nsPIDOMEventTarget;
-class nsIDOMDragEvent;
-
-/** The nsTextEditorKeyListener public nsIDOMKeyListener
- * This class will delegate events to its editor according to the translation
- * it is responsible for. i.e. 'c' becomes a keydown, but 'ESC' becomes nothing.
- */
-class nsTextEditorKeyListener : public nsIDOMKeyListener {
+class nsEditorEventListener : public nsIDOMKeyListener,
+ public nsIDOMTextListener,
+ public nsIDOMCompositionListener,
+ public nsIDOMMouseListener,
+ public nsIDOMFocusListener
+{
public:
- /** the default constructor
- */
- nsTextEditorKeyListener();
- /** the default destructor. virtual due to the possibility of derivation.
- */
- virtual ~nsTextEditorKeyListener();
+ nsEditorEventListener(nsEditor* aEditor);
+ virtual ~nsEditorEventListener();
- /** SetEditor gives an address to the editor that will be accessed
- * @param aEditor the editor this listener calls for editing operations
- */
- void SetEditor(nsIEditor *aEditor){mEditor = aEditor;}
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSIDOMEVENTLISTENER
-/*interfaces for addref and release and queryinterface*/
- NS_DECL_ISUPPORTS
-
-/*BEGIN interfaces in to the keylistener base interface. must be supplied to handle pure virtual interfaces
- see the nsIDOMKeyListener interface implementation for details
- */
- NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
+ // nsIDOMKeyListener
NS_IMETHOD KeyDown(nsIDOMEvent* aKeyEvent);
NS_IMETHOD KeyUp(nsIDOMEvent* aKeyEvent);
NS_IMETHOD KeyPress(nsIDOMEvent* aKeyEvent);
-/*END interfaces from nsIDOMKeyListener*/
-
-protected:
- nsIEditor* mEditor; // weak reference
-};
-
-
-/** editor Implementation of the TextListener interface
- */
-class nsTextEditorTextListener : public nsIDOMTextListener
-{
-public:
- /** default constructor
- */
- nsTextEditorTextListener();
- /** default destructor
- */
- virtual ~nsTextEditorTextListener();
-
- /** SetEditor gives an address to the editor that will be accessed
- * @param aEditor the editor this listener calls for editing operations
- */
- void SetEditor(nsIEditor *aEditor){mEditor = aEditor;}
-
-/*interfaces for addref and release and queryinterface*/
- NS_DECL_ISUPPORTS
-/*BEGIN implementations of textevent handler interface*/
- NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
- NS_IMETHOD HandleText(nsIDOMEvent* aTextEvent);
-/*END implementations of textevent handler interface*/
-
-protected:
- nsIEditor* mEditor; // weak reference
- PRBool mCommitText;
- PRBool mInTransaction;
-};
-
-
-class nsIEditorIMESupport;
+ // nsIDOMTextListener
+ NS_IMETHOD HandleText(nsIDOMEvent* aTextEvent);
-class nsTextEditorCompositionListener : public nsIDOMCompositionListener
-{
-public:
- /** default constructor
- */
- nsTextEditorCompositionListener();
- /** default destructor
- */
- virtual ~nsTextEditorCompositionListener();
-
- /** SetEditor gives an address to the editor that will be accessed
- * @param aEditor the editor this listener calls for editing operations
- */
- void SetEditor(nsIEditor *aEditor);
-
-/*interfaces for addref and release and queryinterface*/
- NS_DECL_ISUPPORTS
-
-/*BEGIN implementations of textevent handler interface*/
- NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
+ // nsIDOMCompositionListener
NS_IMETHOD HandleStartComposition(nsIDOMEvent* aCompositionEvent);
NS_IMETHOD HandleEndComposition(nsIDOMEvent* aCompositionEvent);
-/*END implementations of textevent handler interface*/
-protected:
- nsIEditorIMESupport* mEditor; // weak reference
-};
-
-
-/** editor Implementation of the MouseListener interface
- */
-class nsTextEditorMouseListener : public nsIDOMMouseListener
-{
-public:
- /** default constructor
- */
- nsTextEditorMouseListener();
- /** default destructor
- */
- virtual ~nsTextEditorMouseListener();
-
- /** SetEditor gives an address to the editor that will be accessed
- * @param aEditor the editor this listener calls for editing operations
- */
- void SetEditor(nsIEditor *aEditor){mEditor = aEditor;}
-
-/*interfaces for addref and release and queryinterface*/
- NS_DECL_ISUPPORTS
-
-/*BEGIN implementations of mouseevent handler interface*/
- NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
+ // nsIDOMMouseListener
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*/
+
+ // nsIDOMFocusListener
+ NS_IMETHOD Focus(nsIDOMEvent* aEvent);
+ NS_IMETHOD Blur(nsIDOMEvent* aEvent);
protected:
- nsIEditor* mEditor; // weak reference
-
-};
-
-
-/** editor Implementation of the DragListener interface
- */
-class nsTextEditorDragListener : public nsIDOMEventListener
-{
-public:
- /** default constructor
- */
- nsTextEditorDragListener();
- /** default destructor
- */
- virtual ~nsTextEditorDragListener();
-
- /** SetEditor gives an address to the editor that will be accessed
- * @param aEditor the editor this listener calls for editing operations
- */
- void SetEditor(nsIEditor *aEditor) { mEditor = aEditor; }
- void SetPresShell(nsIPresShell *aPresShell) {
- mPresShell = do_GetWeakReference(aPresShell);
- }
-
-/*interfaces for addref and release and queryinterface*/
- NS_DECL_ISUPPORTS
-
- NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
-
-protected:
-
- PRBool CanDrop(nsIDOMDragEvent* aEvent);
+ PRBool CanDrop(nsIDOMDragEvent* aEvent);
nsresult DragEnter(nsIDOMDragEvent* aDragEvent);
nsresult DragOver(nsIDOMDragEvent* aDragEvent);
nsresult DragLeave(nsIDOMDragEvent* aDragEvent);
nsresult Drop(nsIDOMDragEvent* aDragEvent);
nsresult DragGesture(nsIDOMDragEvent* aDragEvent);
-
-protected:
- nsIEditor* mEditor;
- nsWeakPtr mPresShell;
-
- nsRefPtr<nsCaret> mCaret;
- PRBool mCaretDrawn;
-};
-
-/** editor Implementation of the FocusListener interface
- */
-class nsTextEditorFocusListener : public nsIDOMFocusListener
-{
-public:
- /** default constructor
- */
- nsTextEditorFocusListener(nsIEditor *aEditor, nsIPresShell *aPresShell);
- /** default destructor
- */
- virtual ~nsTextEditorFocusListener();
-
-/*interfaces for addref and release and queryinterface*/
- NS_DECL_ISUPPORTS
-
-/*BEGIN implementations of focus event handler interface*/
- NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
- NS_IMETHOD Focus(nsIDOMEvent* aEvent);
- NS_IMETHOD Blur(nsIDOMEvent* aEvent);
-/*END implementations of focus event handler interface*/
+ already_AddRefed<nsIPresShell> GetPresShell();
protected:
- nsIEditor* mEditor; // weak reference
- nsWeakPtr mPresShell;
+ nsIEditor* mEditor; // weak
+ nsRefPtr<nsCaret> mCaret;
+ PRPackedBool mCaretDrawn;
+ PRPackedBool mCommitText;
+ PRPackedBool mInTransaction;
};
-
-
-/** factory for the editor key listener
- */
-extern nsresult NS_NewEditorKeyListener(nsIDOMEventListener ** aInstancePtrResult, nsIEditor *aEditor);
-
-/** factory for the editor mouse listener
- */
-extern nsresult NS_NewEditorMouseListener(nsIDOMEventListener ** aInstancePtrResult, nsIEditor *aEditor);
-
-/** factory for the editor text listener
- */
-extern nsresult NS_NewEditorTextListener(nsIDOMEventListener** aInstancePtrResult, nsIEditor *aEditor);
-
-/** factory for the editor drag listener
- */
-extern nsresult NS_NewEditorDragListener(nsIDOMEventListener ** aInstancePtrResult, nsIPresShell* aPresShell,
- nsIEditor *aEditor);
-
-/** factory for the editor composition listener
- */
-extern nsresult NS_NewEditorCompositionListener(nsIDOMEventListener** aInstancePtrResult, nsIEditor *aEditor);
-
-/** factory for the editor composition listener
- */
-extern nsresult
-NS_NewEditorFocusListener(nsIDOMEventListener** aInstancePtrResult,
- nsIEditor *aEditor, nsIPresShell *aPresShell);
-
-#endif //editorInterfaces_h__
-
+#endif // nsEditorEventListener_h__
--- a/editor/libeditor/html/Makefile.in
+++ b/editor/libeditor/html/Makefile.in
@@ -59,17 +59,17 @@ CPPSRCS = \
nsHTMLAnonymousUtils.cpp \
nsHTMLDataTransfer.cpp \
nsHTMLCSSUtils.cpp \
nsHTMLEditor.cpp \
nsHTMLEditorStyle.cpp \
nsHTMLEditRules.cpp \
nsHTMLEditUtils.cpp \
nsHTMLObjectResizer.cpp \
- nsHTMLEditorMouseListener.cpp \
+ nsHTMLEditorEventListener.cpp \
nsHTMLInlineTableEditor.cpp \
nsHTMLURIRefObject.cpp \
nsTableEditor.cpp \
nsWSRunObject.cpp \
TypeInState.cpp \
TextEditorTest.cpp \
$(NULL)
--- a/editor/libeditor/html/nsHTMLAbsPosition.cpp
+++ b/editor/libeditor/html/nsHTMLAbsPosition.cpp
@@ -267,17 +267,18 @@ nsHTMLEditor::CreateGrabber(nsIDOMNode *
PR_FALSE,
aReturn);
if (!*aReturn)
return NS_ERROR_FAILURE;
// add the mouse listener so we can detect a click on a resizer
nsCOMPtr<nsIDOMEventTarget> evtTarget(do_QueryInterface(*aReturn));
- evtTarget->AddEventListener(NS_LITERAL_STRING("mousedown"), mMouseListenerP, PR_FALSE);
+ evtTarget->AddEventListener(NS_LITERAL_STRING("mousedown"),
+ mEventListener, PR_FALSE);
return res;
}
NS_IMETHODIMP
nsHTMLEditor::RefreshGrabber()
{
NS_ENSURE_TRUE(mAbsolutelyPositionedObject, NS_ERROR_NULL_POINTER);
--- a/editor/libeditor/html/nsHTMLDataTransfer.cpp
+++ b/editor/libeditor/html/nsHTMLDataTransfer.cpp
@@ -38,18 +38,16 @@
#include "nsHTMLEditor.h"
#include "nsHTMLEditRules.h"
#include "nsTextEditUtils.h"
#include "nsHTMLEditUtils.h"
#include "nsWSRunObject.h"
-#include "nsEditorEventListeners.h"
-
#include "nsIDOMText.h"
#include "nsIDOMNodeList.h"
#include "nsIDOMDocument.h"
#include "nsIDOMAttr.h"
#include "nsIDocument.h"
#include "nsIDOMEventTarget.h"
#include "nsIDOMNSEvent.h"
#include "nsIDOMKeyEvent.h"
--- a/editor/libeditor/html/nsHTMLEditor.cpp
+++ b/editor/libeditor/html/nsHTMLEditor.cpp
@@ -41,18 +41,17 @@
#include "nsReadableUtils.h"
#include "nsUnicharUtils.h"
#include "nsHTMLEditor.h"
#include "nsHTMLEditRules.h"
#include "nsTextEditUtils.h"
#include "nsHTMLEditUtils.h"
-#include "nsEditorEventListeners.h"
-#include "nsHTMLEditorMouseListener.h"
+#include "nsHTMLEditorEventListener.h"
#include "TypeInState.h"
#include "nsHTMLURIRefObject.h"
#include "nsIDOMText.h"
#include "nsIDOMNodeList.h"
#include "nsIDOMDocument.h"
#include "nsIDOMAttr.h"
@@ -332,30 +331,21 @@ nsHTMLEditor::Init(nsIDOMDocument *aDoc,
if (NS_FAILED(rulesRes)) return rulesRes;
return result;
}
nsresult
nsHTMLEditor::CreateEventListeners()
{
- nsresult rv = NS_OK;
-
- if (!mMouseListenerP)
- {
- // get a mouse listener
- rv = NS_NewHTMLEditorMouseListener(getter_AddRefs(mMouseListenerP), this);
-
- if (NS_FAILED(rv))
- {
- return rv;
- }
- }
-
- return nsPlaintextEditor::CreateEventListeners();
+ NS_ENSURE_TRUE(!mEventListener, NS_ERROR_ALREADY_INITIALIZED);
+ mEventListener = do_QueryInterface(
+ static_cast<nsIDOMKeyListener*>(new nsHTMLEditorEventListener(this)));
+ NS_ENSURE_TRUE(mEventListener, NS_ERROR_OUT_OF_MEMORY);
+ return NS_OK;
}
void
nsHTMLEditor::RemoveEventListeners()
{
if (!mDocWeak)
{
return;
rename from editor/libeditor/html/nsHTMLEditorMouseListener.cpp
rename to editor/libeditor/html/nsHTMLEditorEventListener.cpp
--- a/editor/libeditor/html/nsHTMLEditorMouseListener.cpp
+++ b/editor/libeditor/html/nsHTMLEditorEventListener.cpp
@@ -17,31 +17,32 @@
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Charles Manske (cmanske@netscape.com)
* Daniel Glazman (glazman@netscape.com)
+ * Masayuki Nakano <masayuki@d-toybox.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
-#include "nsHTMLEditorMouseListener.h"
+#include "nsHTMLEditorEventListener.h"
#include "nsString.h"
#include "nsIDOMEvent.h"
#include "nsIDOMNSEvent.h"
#include "nsIDOMElement.h"
#include "nsIDOMMouseEvent.h"
#include "nsISelection.h"
#include "nsIDOMRange.h"
@@ -56,36 +57,24 @@
#include "nsIHTMLEditor.h"
#include "nsIHTMLObjectResizer.h"
#include "nsEditProperty.h"
#include "nsTextEditUtils.h"
#include "nsHTMLEditUtils.h"
#include "nsIHTMLInlineTableEditor.h"
/*
- * nsHTMLEditorMouseListener implementation
+ * nsHTMLEditorEventListener implementation
*
* The only reason we need this is so a context mouse-click
* moves the caret or selects an element as it does for normal click
*/
-nsHTMLEditorMouseListener::nsHTMLEditorMouseListener(nsHTMLEditor *aHTMLEditor)
- : mHTMLEditor(aHTMLEditor)
-{
- SetEditor(mHTMLEditor); // Tell the base class about the editor.
-}
-
-nsHTMLEditorMouseListener::~nsHTMLEditorMouseListener()
-{
-}
-
-NS_IMPL_ISUPPORTS_INHERITED1(nsHTMLEditorMouseListener, nsTextEditorMouseListener, nsIDOMMouseListener)
-
-nsresult
-nsHTMLEditorMouseListener::MouseUp(nsIDOMEvent* aMouseEvent)
+NS_IMETHODIMP
+nsHTMLEditorEventListener::MouseUp(nsIDOMEvent* aMouseEvent)
{
nsCOMPtr<nsIDOMMouseEvent> mouseEvent ( do_QueryInterface(aMouseEvent) );
if (!mouseEvent) {
//non-ui event passed in. bad things.
return NS_OK;
}
// Don't do anything special if not an HTML editor
@@ -100,21 +89,21 @@ nsHTMLEditorMouseListener::MouseUp(nsIDO
nsCOMPtr<nsIHTMLObjectResizer> objectResizer = do_QueryInterface(htmlEditor);
PRInt32 clientX, clientY;
mouseEvent->GetClientX(&clientX);
mouseEvent->GetClientY(&clientY);
objectResizer->MouseUp(clientX, clientY, element);
}
- return nsTextEditorMouseListener::MouseUp(aMouseEvent);
+ return nsEditorEventListener::MouseUp(aMouseEvent);
}
-nsresult
-nsHTMLEditorMouseListener::MouseDown(nsIDOMEvent* aMouseEvent)
+NS_IMETHODIMP
+nsHTMLEditorEventListener::MouseDown(nsIDOMEvent* aMouseEvent)
{
nsCOMPtr<nsIDOMMouseEvent> mouseEvent ( do_QueryInterface(aMouseEvent) );
if (!mouseEvent) {
//non-ui event passed in. bad things.
return NS_OK;
}
// Don't do anything special if not an HTML editor
@@ -221,17 +210,19 @@ nsHTMLEditorMouseListener::MouseDown(nsI
if (linkElement)
element = linkElement;
}
}
// Select entire element clicked on if NOT within an existing selection
// and not the entire body, or table-related elements
if (element)
{
- nsCOMPtr<nsIDOMNode> selectAllNode = mHTMLEditor->FindUserSelectAllNode(element);
+ // mEditor must be nsHTMLEditor, see the constructor.
+ nsCOMPtr<nsIDOMNode> selectAllNode =
+ reinterpret_cast<nsHTMLEditor*>(mEditor)->FindUserSelectAllNode(element);
if (selectAllNode)
{
nsCOMPtr<nsIDOMElement> newElement = do_QueryInterface(selectAllNode);
if (newElement)
{
node = selectAllNode;
element = newElement;
@@ -274,21 +265,21 @@ nsHTMLEditorMouseListener::MouseDown(nsI
nsCOMPtr<nsIHTMLObjectResizer> objectResizer = do_QueryInterface(htmlEditor);
PRInt32 clientX, clientY;
mouseEvent->GetClientX(&clientX);
mouseEvent->GetClientY(&clientY);
objectResizer->MouseDown(clientX, clientY, element, aMouseEvent);
}
}
- return nsTextEditorMouseListener::MouseDown(aMouseEvent);
+ return nsEditorEventListener::MouseDown(aMouseEvent);
}
-nsresult
-nsHTMLEditorMouseListener::MouseClick(nsIDOMEvent* aMouseEvent)
+NS_IMETHODIMP
+nsHTMLEditorEventListener::MouseClick(nsIDOMEvent* aMouseEvent)
{
nsCOMPtr<nsIDOMMouseEvent> mouseEvent ( do_QueryInterface(aMouseEvent) );
if (!mouseEvent) {
//non-ui event passed in. bad things.
return NS_OK;
}
// Don't do anything special if not an HTML inline table editor
@@ -299,21 +290,10 @@ nsHTMLEditorMouseListener::MouseClick(ns
nsresult res = aMouseEvent->GetTarget(getter_AddRefs(target));
if (NS_FAILED(res)) return res;
if (!target) return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(target);
inlineTableEditing->DoInlineTableEditingAction(element);
}
- return nsTextEditorMouseListener::MouseClick(aMouseEvent);
+ return nsEditorEventListener::MouseClick(aMouseEvent);
}
-
-nsresult
-NS_NewHTMLEditorMouseListener(nsIDOMEventListener ** aInstancePtrResult,
- nsHTMLEditor *aHTMLEditor)
-{
- nsHTMLEditorMouseListener* listener = new nsHTMLEditorMouseListener(aHTMLEditor);
- if (!listener)
- return NS_ERROR_OUT_OF_MEMORY;
-
- return listener->QueryInterface(NS_GET_IID(nsIDOMEventListener), (void **) aInstancePtrResult);
-}
rename from editor/libeditor/html/nsHTMLEditorMouseListener.h
rename to editor/libeditor/html/nsHTMLEditorEventListener.h
--- a/editor/libeditor/html/nsHTMLEditorMouseListener.h
+++ b/editor/libeditor/html/nsHTMLEditorEventListener.h
@@ -32,54 +32,33 @@
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
-#ifndef htmlEditorMouseListener_h__
-#define htmlEditorMouseListener_h__
+#ifndef nsHTMLEditorEventListener_h__
+#define nsHTMLEditorEventListener_h__
-#include "nsCOMPtr.h"
-#include "nsIDOMEvent.h"
-#include "nsIDOMMouseListener.h"
-#include "nsIEditor.h"
-#include "nsIPlaintextEditor.h"
-#include "nsIHTMLEditor.h"
-#include "nsEditorEventListeners.h"
+#include "nsEditorEventListener.h"
#include "nsHTMLEditor.h"
-class nsString;
-
-class nsHTMLEditorMouseListener : public nsTextEditorMouseListener
+class nsHTMLEditorEventListener : public nsEditorEventListener
{
public:
- /** default constructor
- */
- nsHTMLEditorMouseListener(nsHTMLEditor *aHTMLEditor);
- /** default destructor
- */
- virtual ~nsHTMLEditorMouseListener();
+ nsHTMLEditorEventListener(nsHTMLEditor* aEditor) :
+ nsEditorEventListener(aEditor)
+ {
+ }
-// void SetEditor(nsIEditor *aEditor){mEditor = aEditor;}
+ virtual ~nsHTMLEditorEventListener()
+ {
+ }
-/*interfaces for addref and release and queryinterface*/
- NS_DECL_ISUPPORTS_INHERITED
-
-/*BEGIN implementations of mouseevent handler interface*/
NS_IMETHOD MouseDown(nsIDOMEvent* aMouseEvent);
NS_IMETHOD MouseUp(nsIDOMEvent* aMouseEvent);
NS_IMETHOD MouseClick(nsIDOMEvent* aMouseEvent);
-/*END implementations of mouseevent handler interface*/
-
-protected:
-
- nsHTMLEditor *mHTMLEditor; // un-addref'd weak pointer
};
-/** factory for the mouse listener
- */
-extern nsresult NS_NewHTMLEditorMouseListener(nsIDOMEventListener ** aInstancePtrResult, nsHTMLEditor *aHTMLEditor);
+#endif // nsHTMLEditorEventListener_h__
-#endif //htmlEditorMouseListener_h__
-
--- a/editor/libeditor/html/nsHTMLInlineTableEditor.cpp
+++ b/editor/libeditor/html/nsHTMLInlineTableEditor.cpp
@@ -206,26 +206,30 @@ nsHTMLEditor::DoInlineTableEditingAction
return NS_OK;
}
void
nsHTMLEditor::AddMouseClickListener(nsIDOMElement * aElement)
{
nsCOMPtr<nsIDOMEventTarget> evtTarget(do_QueryInterface(aElement));
- if (evtTarget)
- evtTarget->AddEventListener(NS_LITERAL_STRING("click"), mMouseListenerP, PR_TRUE);
+ if (evtTarget) {
+ evtTarget->AddEventListener(NS_LITERAL_STRING("click"),
+ mEventListener, PR_TRUE);
+ }
}
void
nsHTMLEditor::RemoveMouseClickListener(nsIDOMElement * aElement)
{
nsCOMPtr<nsIDOMEventTarget> evtTarget(do_QueryInterface(aElement));
- if (evtTarget)
- evtTarget->RemoveEventListener(NS_LITERAL_STRING("click"), mMouseListenerP, PR_TRUE);
+ if (evtTarget) {
+ evtTarget->RemoveEventListener(NS_LITERAL_STRING("click"),
+ mEventListener, PR_TRUE);
+ }
}
NS_IMETHODIMP
nsHTMLEditor::RefreshInlineTableEditingUI()
{
nsCOMPtr<nsIDOMNSHTMLElement> nsElement = do_QueryInterface(mInlineEditedCell);
if (!nsElement) {return NS_ERROR_NULL_POINTER; }
--- a/editor/libeditor/html/nsHTMLObjectResizer.cpp
+++ b/editor/libeditor/html/nsHTMLObjectResizer.cpp
@@ -189,17 +189,18 @@ nsHTMLEditor::CreateResizer(nsIDOMElemen
aReturn);
if (NS_FAILED(res)) return res;
if (!*aReturn)
return NS_ERROR_FAILURE;
// add the mouse listener so we can detect a click on a resizer
nsCOMPtr<nsIDOMEventTarget> evtTarget(do_QueryInterface(*aReturn));
- evtTarget->AddEventListener(NS_LITERAL_STRING("mousedown"), mMouseListenerP, PR_TRUE);
+ evtTarget->AddEventListener(NS_LITERAL_STRING("mousedown"), mEventListener,
+ PR_TRUE);
nsAutoString locationStr;
switch (aLocation) {
case nsIHTMLObjectResizer::eTopLeft:
locationStr = kTopLeft;
break;
case nsIHTMLObjectResizer::eTop:
locationStr = kTop;
@@ -448,53 +449,53 @@ nsHTMLEditor::HideResizers(void)
if (mTopLeftHandle) {
res = mTopLeftHandle->GetParentNode(getter_AddRefs(parentNode));
NS_ENSURE_SUCCESS(res, res);
parentContent = do_QueryInterface(parentNode);
}
NS_NAMED_LITERAL_STRING(mousedown, "mousedown");
- RemoveListenerAndDeleteRef(mousedown, mMouseListenerP, PR_TRUE,
+ RemoveListenerAndDeleteRef(mousedown, mEventListener, PR_TRUE,
mTopLeftHandle, parentContent, ps);
mTopLeftHandle = nsnull;
- RemoveListenerAndDeleteRef(mousedown, mMouseListenerP, PR_TRUE,
+ RemoveListenerAndDeleteRef(mousedown, mEventListener, PR_TRUE,
mTopHandle, parentContent, ps);
mTopHandle = nsnull;
- RemoveListenerAndDeleteRef(mousedown, mMouseListenerP, PR_TRUE,
+ RemoveListenerAndDeleteRef(mousedown, mEventListener, PR_TRUE,
mTopRightHandle, parentContent, ps);
mTopRightHandle = nsnull;
- RemoveListenerAndDeleteRef(mousedown, mMouseListenerP, PR_TRUE,
+ RemoveListenerAndDeleteRef(mousedown, mEventListener, PR_TRUE,
mLeftHandle, parentContent, ps);
mLeftHandle = nsnull;
- RemoveListenerAndDeleteRef(mousedown, mMouseListenerP, PR_TRUE,
+ RemoveListenerAndDeleteRef(mousedown, mEventListener, PR_TRUE,
mRightHandle, parentContent, ps);
mRightHandle = nsnull;
- RemoveListenerAndDeleteRef(mousedown, mMouseListenerP, PR_TRUE,
+ RemoveListenerAndDeleteRef(mousedown, mEventListener, PR_TRUE,
mBottomLeftHandle, parentContent, ps);
mBottomLeftHandle = nsnull;
- RemoveListenerAndDeleteRef(mousedown, mMouseListenerP, PR_TRUE,
+ RemoveListenerAndDeleteRef(mousedown, mEventListener, PR_TRUE,
mBottomHandle, parentContent, ps);
mBottomHandle = nsnull;
- RemoveListenerAndDeleteRef(mousedown, mMouseListenerP, PR_TRUE,
+ RemoveListenerAndDeleteRef(mousedown, mEventListener, PR_TRUE,
mBottomRightHandle, parentContent, ps);
mBottomRightHandle = nsnull;
- RemoveListenerAndDeleteRef(mousedown, mMouseListenerP, PR_TRUE,
+ RemoveListenerAndDeleteRef(mousedown, mEventListener, PR_TRUE,
mResizingShadow, parentContent, ps);
mResizingShadow = nsnull;
- RemoveListenerAndDeleteRef(mousedown, mMouseListenerP, PR_TRUE,
+ RemoveListenerAndDeleteRef(mousedown, mEventListener, PR_TRUE,
mResizingInfo, parentContent, ps);
mResizingInfo = nsnull;
if (mActivatedHandle) {
mActivatedHandle->RemoveAttribute(NS_LITERAL_STRING("_moz_activated"));
mActivatedHandle = nsnull;
}
--- a/editor/libeditor/text/Makefile.in
+++ b/editor/libeditor/text/Makefile.in
@@ -51,17 +51,16 @@ LIBRARY_NAME = texteditor_s
LIBXUL_LIBRARY = 1
CPPSRCS = \
nsPlaintextDataTransfer.cpp \
nsPlaintextEditor.cpp \
nsTextEditUtils.cpp \
nsTextEditRules.cpp \
- nsEditorEventListeners.cpp \
nsInternetCiter.cpp \
nsTextEditRulesBidi.cpp \
$(NULL)
# don't want the shared lib; force the creation of a static lib.
FORCE_STATIC_LIB = 1
include $(topsrcdir)/config/rules.mk
--- a/editor/libeditor/text/nsPlaintextEditor.cpp
+++ b/editor/libeditor/text/nsPlaintextEditor.cpp
@@ -37,17 +37,16 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsPlaintextEditor.h"
#include "nsCaret.h"
#include "nsTextEditUtils.h"
#include "nsTextEditRules.h"
-#include "nsEditorEventListeners.h"
#include "nsIEditActionListener.h"
#include "nsIDOMNodeList.h"
#include "nsIDOMDocument.h"
#include "nsIDocument.h"
#include "nsIDOMEventTarget.h"
#include "nsIDOM3EventTarget.h"
#include "nsIDOMKeyEvent.h"
#include "nsIDOMMouseListener.h"
@@ -301,59 +300,16 @@ nsPlaintextEditor::SetDocumentCharacterS
}
}
}
}
return result;
}
-nsresult
-nsPlaintextEditor::CreateEventListeners()
-{
- nsresult rv = NS_OK;
-
- if (!mMouseListenerP) {
- // get a mouse listener
- rv |= NS_NewEditorMouseListener(getter_AddRefs(mMouseListenerP), this);
- }
-
- if (!mKeyListenerP) {
- // get a key listener
- rv |= NS_NewEditorKeyListener(getter_AddRefs(mKeyListenerP), this);
- }
-
- if (!mTextListenerP) {
- // get a text listener
- rv |= NS_NewEditorTextListener(getter_AddRefs(mTextListenerP), this);
- }
-
- if (!mCompositionListenerP) {
- // get a composition listener
- rv |=
- NS_NewEditorCompositionListener(getter_AddRefs(mCompositionListenerP),
- this);
- }
-
- nsCOMPtr<nsIPresShell> presShell = do_QueryReferent(mPresShellWeak);
- if (!mDragListenerP) {
- // get a drag listener
- rv |= NS_NewEditorDragListener(getter_AddRefs(mDragListenerP), presShell,
- this);
- }
-
- if (!mFocusListenerP) {
- // get a focus listener
- rv |= NS_NewEditorFocusListener(getter_AddRefs(mFocusListenerP),
- this, presShell);
- }
-
- return rv;
-}
-
NS_IMETHODIMP
nsPlaintextEditor::GetFlags(PRUint32 *aFlags)
{
if (!mRules || !aFlags) { return NS_ERROR_NULL_POINTER; }
return mRules->GetFlags(aFlags);
}
--- a/editor/libeditor/text/nsPlaintextEditor.h
+++ b/editor/libeditor/text/nsPlaintextEditor.h
@@ -180,19 +180,16 @@ public:
PRInt32 &aCaretStyle);
protected:
NS_IMETHOD InitRules();
void BeginEditorInit();
nsresult EndEditorInit();
- // Create the event listeners for the editor to install.
- virtual nsresult CreateEventListeners();
-
// Helpers for output routines
NS_IMETHOD GetAndInitDocEncoder(const nsAString& aFormatType,
PRUint32 aFlags,
const nsACString& aCharset,
nsIDocumentEncoder** encoder);
// key event helpers
NS_IMETHOD CreateBR(nsIDOMNode *aNode, PRInt32 aOffset,