mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 545602 Unify the event listeners for editor r=smaug
--HG-- rename : editor/libeditor/text/nsEditorEventListeners.cpp => editor/libeditor/base/nsEditorEventListener.cpp rename : editor/libeditor/text/nsEditorEventListeners.h => editor/libeditor/base/nsEditorEventListener.h rename : editor/libeditor/html/nsHTMLEditorMouseListener.cpp => editor/libeditor/html/nsHTMLEditorEventListener.cpp rename : editor/libeditor/html/nsHTMLEditorMouseListener.h => editor/libeditor/html/nsHTMLEditorEventListener.h
This commit is contained in:
parent
4334111554
commit
8a42231835
@ -58,6 +58,7 @@ CPPSRCS = \
|
||||
nsEditor.cpp \
|
||||
nsEditorCommands.cpp \
|
||||
nsEditorController.cpp \
|
||||
nsEditorEventListener.cpp \
|
||||
nsEditorUtils.cpp \
|
||||
nsSelectionState.cpp \
|
||||
$(NULL)
|
||||
|
@ -106,6 +106,7 @@
|
||||
|
||||
#include "nsEditor.h"
|
||||
#include "nsEditorUtils.h"
|
||||
#include "nsEditorEventListener.h"
|
||||
#include "nsISelectionDisplay.h"
|
||||
#include "nsIInlineSpellChecker.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
@ -180,12 +181,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsEditor)
|
||||
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)
|
||||
@ -198,12 +194,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsEditor)
|
||||
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)
|
||||
@ -316,12 +307,20 @@ nsEditor::PostCreate()
|
||||
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();
|
||||
@ -340,7 +339,7 @@ nsEditor::InstallEventListeners()
|
||||
|
||||
if (sysGroup && elmP)
|
||||
{
|
||||
rv = elmP->AddEventListenerByType(mKeyListenerP,
|
||||
rv = elmP->AddEventListenerByType(mEventListener,
|
||||
NS_LITERAL_STRING("keypress"),
|
||||
NS_EVENT_FLAG_BUBBLE |
|
||||
NS_PRIV_EVENT_UNTRUSTED_PERMITTED,
|
||||
@ -349,31 +348,36 @@ nsEditor::InstallEventListeners()
|
||||
"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))
|
||||
@ -389,7 +393,7 @@ nsEditor::InstallEventListeners()
|
||||
void
|
||||
nsEditor::RemoveEventListeners()
|
||||
{
|
||||
if (!mDocWeak)
|
||||
if (!mDocWeak || !mEventListener)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -401,55 +405,42 @@ nsEditor::RemoveEventListeners()
|
||||
// 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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
elmP->RemoveEventListenerByType(mEventListener,
|
||||
NS_LITERAL_STRING("keypress"),
|
||||
NS_EVENT_FLAG_BUBBLE |
|
||||
NS_PRIV_EVENT_UNTRUSTED_PERMITTED,
|
||||
sysGroup);
|
||||
}
|
||||
|
||||
if (mMouseListenerP)
|
||||
{
|
||||
piTarget->RemoveEventListenerByIID(mMouseListenerP,
|
||||
NS_GET_IID(nsIDOMMouseListener));
|
||||
}
|
||||
piTarget->RemoveEventListenerByIID(mEventListener,
|
||||
NS_GET_IID(nsIDOMMouseListener));
|
||||
|
||||
if (mFocusListenerP && elmP)
|
||||
{
|
||||
elmP->RemoveEventListenerByIID(mFocusListenerP,
|
||||
NS_GET_IID(nsIDOMFocusListener),
|
||||
NS_EVENT_FLAG_CAPTURE);
|
||||
}
|
||||
elmP->RemoveEventListenerByIID(mEventListener,
|
||||
NS_GET_IID(nsIDOMFocusListener),
|
||||
NS_EVENT_FLAG_CAPTURE);
|
||||
|
||||
if (mTextListenerP)
|
||||
{
|
||||
piTarget->RemoveEventListenerByIID(mTextListenerP,
|
||||
NS_GET_IID(nsIDOMTextListener));
|
||||
}
|
||||
piTarget->RemoveEventListenerByIID(mEventListener,
|
||||
NS_GET_IID(nsIDOMTextListener));
|
||||
|
||||
if (mCompositionListenerP)
|
||||
{
|
||||
piTarget->RemoveEventListenerByIID(mCompositionListenerP,
|
||||
NS_GET_IID(nsIDOMCompositionListener));
|
||||
}
|
||||
piTarget->RemoveEventListenerByIID(mEventListener,
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -348,7 +348,7 @@ protected:
|
||||
// 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();
|
||||
@ -638,12 +638,7 @@ protected:
|
||||
|
||||
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;
|
||||
|
@ -22,6 +22,7 @@
|
||||
*
|
||||
* 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"),
|
||||
@ -36,8 +37,9 @@
|
||||
* 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"
|
||||
@ -74,51 +76,87 @@
|
||||
#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
|
||||
nsEditorEventListener::~nsEditorEventListener()
|
||||
{
|
||||
}
|
||||
|
||||
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
|
||||
*/
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsTextEditorKeyListener, nsIDOMEventListener, nsIDOMKeyListener)
|
||||
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
|
||||
|
||||
nsTextEditorKeyListener::nsTextEditorKeyListener()
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
|
||||
nsTextEditorKeyListener::~nsTextEditorKeyListener()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsTextEditorKeyListener::HandleEvent(nsIDOMEvent* aEvent)
|
||||
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
|
||||
@ -258,33 +296,12 @@ nsTextEditorKeyListener::KeyPress(nsIDOMEvent* aKeyEvent)
|
||||
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);
|
||||
@ -377,8 +394,8 @@ nsTextEditorMouseListener::MouseClick(nsIDOMEvent* aMouseEvent)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsTextEditorMouseListener::MouseDown(nsIDOMEvent* aMouseEvent)
|
||||
NS_IMETHODIMP
|
||||
nsEditorEventListener::MouseDown(nsIDOMEvent* aMouseEvent)
|
||||
{
|
||||
nsCOMPtr<nsIEditorIMESupport> imeEditor = do_QueryInterface(mEditor);
|
||||
if (!imeEditor)
|
||||
@ -387,71 +404,37 @@ nsTextEditorMouseListener::MouseDown(nsIDOMEvent* aMouseEvent)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsTextEditorMouseListener::MouseUp(nsIDOMEvent* aMouseEvent)
|
||||
NS_IMETHODIMP
|
||||
nsEditorEventListener::MouseUp(nsIDOMEvent* aMouseEvent)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsTextEditorMouseListener::MouseDblClick(nsIDOMEvent* aMouseEvent)
|
||||
NS_IMETHODIMP
|
||||
nsEditorEventListener::MouseDblClick(nsIDOMEvent* aMouseEvent)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsresult
|
||||
nsTextEditorMouseListener::MouseOver(nsIDOMEvent* aMouseEvent)
|
||||
NS_IMETHODIMP
|
||||
nsEditorEventListener::MouseOver(nsIDOMEvent* aMouseEvent)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsresult
|
||||
nsTextEditorMouseListener::MouseOut(nsIDOMEvent* aMouseEvent)
|
||||
NS_IMETHODIMP
|
||||
nsEditorEventListener::MouseOut(nsIDOMEvent* aMouseEvent)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nsTextEditorTextListener implementation
|
||||
/**
|
||||
* nsIDOMTextListener implementation
|
||||
*/
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsTextEditorTextListener, nsIDOMEventListener, nsIDOMTextListener)
|
||||
|
||||
|
||||
nsTextEditorTextListener::nsTextEditorTextListener()
|
||||
: mCommitText(PR_FALSE),
|
||||
mInTransaction(PR_FALSE)
|
||||
NS_IMETHODIMP
|
||||
nsEditorEventListener::HandleText(nsIDOMEvent* aTextEvent)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
nsTextEditorTextListener::~nsTextEditorTextListener()
|
||||
{
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsTextEditorTextListener::HandleEvent(nsIDOMEvent* aEvent)
|
||||
{
|
||||
#ifdef DEBUG_IME
|
||||
printf("nsTextEditorTextListener::HandleEvent\n");
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsresult
|
||||
nsTextEditorTextListener::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.
|
||||
@ -473,9 +456,6 @@ nsTextEditorTextListener::HandleText(nsIDOMEvent* aTextEvent)
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -484,48 +464,12 @@ nsTextEditorTextListener::HandleText(nsIDOMEvent* aTextEvent)
|
||||
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;
|
||||
@ -539,11 +483,10 @@ nsTextEditorDragListener::DragGesture(nsIDOMDragEvent* 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;
|
||||
|
||||
@ -563,9 +506,8 @@ nsTextEditorDragListener::DragEnter(nsIDOMDragEvent* aDragEvent)
|
||||
return DragOver(aDragEvent);
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsTextEditorDragListener::DragOver(nsIDOMDragEvent* aDragEvent)
|
||||
nsEditorEventListener::DragOver(nsIDOMDragEvent* aDragEvent)
|
||||
{
|
||||
// XXX cache this between drag events?
|
||||
nsresult rv;
|
||||
@ -625,9 +567,8 @@ nsTextEditorDragListener::DragOver(nsIDOMDragEvent* aDragEvent)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsTextEditorDragListener::DragLeave(nsIDOMDragEvent* aDragEvent)
|
||||
nsEditorEventListener::DragLeave(nsIDOMDragEvent* aDragEvent)
|
||||
{
|
||||
if (mCaret && mCaretDrawn)
|
||||
{
|
||||
@ -635,17 +576,15 @@ nsTextEditorDragListener::DragLeave(nsIDOMDragEvent* aDragEvent)
|
||||
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)
|
||||
{
|
||||
@ -656,7 +595,7 @@ nsTextEditorDragListener::Drop(nsIDOMDragEvent* aMouseEvent)
|
||||
}
|
||||
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();
|
||||
@ -704,10 +643,8 @@ nsTextEditorDragListener::Drop(nsIDOMDragEvent* aMouseEvent)
|
||||
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;
|
||||
@ -806,178 +743,37 @@ nsTextEditorDragListener::CanDrop(nsIDOMDragEvent* aEvent)
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* nsIDOMCompositionListener implementation
|
||||
*/
|
||||
|
||||
nsTextEditorCompositionListener::nsTextEditorCompositionListener()
|
||||
NS_IMETHODIMP
|
||||
nsEditorEventListener::HandleStartComposition(nsIDOMEvent* aCompositionEvent)
|
||||
{
|
||||
}
|
||||
|
||||
nsTextEditorCompositionListener::~nsTextEditorCompositionListener()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsTextEditorCompositionListener, nsIDOMEventListener, nsIDOMCompositionListener)
|
||||
|
||||
nsresult
|
||||
nsTextEditorCompositionListener::HandleEvent(nsIDOMEvent* aEvent)
|
||||
{
|
||||
#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);
|
||||
nsCOMPtr<nsIEditorIMESupport> imeEditor = do_QueryInterface(mEditor);
|
||||
NS_ASSERTION(imeEditor, "The editor doesn't support IME?");
|
||||
return imeEditor->BeginComposition(eventReply);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsTextEditorCompositionListener::HandleEndComposition(nsIDOMEvent* aCompositionEvent)
|
||||
NS_IMETHODIMP
|
||||
nsEditorEventListener::HandleEndComposition(nsIDOMEvent* aCompositionEvent)
|
||||
{
|
||||
#ifdef DEBUG_IME
|
||||
printf("nsTextEditorCompositionListener::HandleEndComposition\n");
|
||||
#endif
|
||||
return mEditor->EndComposition();
|
||||
nsCOMPtr<nsIEditorIMESupport> imeEditor = do_QueryInterface(mEditor);
|
||||
NS_ASSERTION(imeEditor, "The editor doesn't support IME?");
|
||||
return imeEditor->EndComposition();
|
||||
}
|
||||
|
||||
/*
|
||||
* Factory functions
|
||||
/**
|
||||
* nsIDOMFocusListener implementation
|
||||
*/
|
||||
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsresult
|
||||
NS_NewEditorDragListener(nsIDOMEventListener ** aInstancePtrResult, nsIPresShell* aPresShell,
|
||||
nsIEditor *aEditor)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
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
|
||||
*/
|
||||
|
||||
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)
|
||||
{
|
||||
@ -1025,8 +821,8 @@ FindSelectionRoot(nsIEditor *aEditor, nsIContent *aContent)
|
||||
return content;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsTextEditorFocusListener::Focus(nsIDOMEvent* aEvent)
|
||||
NS_IMETHODIMP
|
||||
nsEditorEventListener::Focus(nsIDOMEvent* aEvent)
|
||||
{
|
||||
NS_ENSURE_ARG(aEvent);
|
||||
|
||||
@ -1072,7 +868,7 @@ nsTextEditorFocusListener::Focus(nsIDOMEvent* aEvent)
|
||||
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));
|
||||
@ -1110,8 +906,8 @@ nsTextEditorFocusListener::Focus(nsIDOMEvent* aEvent)
|
||||
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.
|
||||
@ -1144,7 +940,7 @@ nsTextEditorFocusListener::Blur(nsIDOMEvent* aEvent)
|
||||
selectionPrivate->SetAncestorLimiter(nsnull);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell = do_QueryReferent(mPresShell);
|
||||
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
|
||||
if (presShell) {
|
||||
nsRefPtr<nsCaret> caret;
|
||||
presShell->GetCaret(getter_AddRefs(caret));
|
111
editor/libeditor/base/nsEditorEventListener.h
Normal file
111
editor/libeditor/base/nsEditorEventListener.h
Normal file
@ -0,0 +1,111 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* 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 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 "nsCaret.h"
|
||||
|
||||
class nsEditor;
|
||||
class nsIDOMDragEvent;
|
||||
class nsPIDOMEventTarget;
|
||||
|
||||
class nsEditorEventListener : public nsIDOMKeyListener,
|
||||
public nsIDOMTextListener,
|
||||
public nsIDOMCompositionListener,
|
||||
public nsIDOMMouseListener,
|
||||
public nsIDOMFocusListener
|
||||
{
|
||||
public:
|
||||
nsEditorEventListener(nsEditor* aEditor);
|
||||
virtual ~nsEditorEventListener();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIDOMEVENTLISTENER
|
||||
|
||||
// nsIDOMKeyListener
|
||||
NS_IMETHOD KeyDown(nsIDOMEvent* aKeyEvent);
|
||||
NS_IMETHOD KeyUp(nsIDOMEvent* aKeyEvent);
|
||||
NS_IMETHOD KeyPress(nsIDOMEvent* aKeyEvent);
|
||||
|
||||
// nsIDOMTextListener
|
||||
NS_IMETHOD HandleText(nsIDOMEvent* aTextEvent);
|
||||
|
||||
// nsIDOMCompositionListener
|
||||
NS_IMETHOD HandleStartComposition(nsIDOMEvent* aCompositionEvent);
|
||||
NS_IMETHOD HandleEndComposition(nsIDOMEvent* aCompositionEvent);
|
||||
|
||||
// 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);
|
||||
|
||||
// nsIDOMFocusListener
|
||||
NS_IMETHOD Focus(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Blur(nsIDOMEvent* aEvent);
|
||||
|
||||
protected:
|
||||
PRBool CanDrop(nsIDOMDragEvent* aEvent);
|
||||
nsresult DragEnter(nsIDOMDragEvent* aDragEvent);
|
||||
nsresult DragOver(nsIDOMDragEvent* aDragEvent);
|
||||
nsresult DragLeave(nsIDOMDragEvent* aDragEvent);
|
||||
nsresult Drop(nsIDOMDragEvent* aDragEvent);
|
||||
nsresult DragGesture(nsIDOMDragEvent* aDragEvent);
|
||||
already_AddRefed<nsIPresShell> GetPresShell();
|
||||
|
||||
protected:
|
||||
nsIEditor* mEditor; // weak
|
||||
nsRefPtr<nsCaret> mCaret;
|
||||
PRPackedBool mCaretDrawn;
|
||||
PRPackedBool mCommitText;
|
||||
PRPackedBool mInTransaction;
|
||||
};
|
||||
|
||||
#endif // nsEditorEventListener_h__
|
@ -64,7 +64,7 @@ CPPSRCS = \
|
||||
nsHTMLEditRules.cpp \
|
||||
nsHTMLEditUtils.cpp \
|
||||
nsHTMLObjectResizer.cpp \
|
||||
nsHTMLEditorMouseListener.cpp \
|
||||
nsHTMLEditorEventListener.cpp \
|
||||
nsHTMLInlineTableEditor.cpp \
|
||||
nsHTMLURIRefObject.cpp \
|
||||
nsTableEditor.cpp \
|
||||
|
@ -272,7 +272,8 @@ nsHTMLEditor::CreateGrabber(nsIDOMNode * aParentNode, nsIDOMElement ** aReturn)
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
@ -43,8 +43,6 @@
|
||||
#include "nsHTMLEditUtils.h"
|
||||
#include "nsWSRunObject.h"
|
||||
|
||||
#include "nsEditorEventListeners.h"
|
||||
|
||||
#include "nsIDOMText.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
|
@ -46,8 +46,7 @@
|
||||
#include "nsTextEditUtils.h"
|
||||
#include "nsHTMLEditUtils.h"
|
||||
|
||||
#include "nsEditorEventListeners.h"
|
||||
#include "nsHTMLEditorMouseListener.h"
|
||||
#include "nsHTMLEditorEventListener.h"
|
||||
#include "TypeInState.h"
|
||||
|
||||
#include "nsHTMLURIRefObject.h"
|
||||
@ -337,20 +336,11 @@ nsHTMLEditor::Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell,
|
||||
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
|
||||
|
@ -22,6 +22,7 @@
|
||||
* 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"),
|
||||
@ -36,7 +37,7 @@
|
||||
* 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"
|
||||
@ -61,26 +62,14 @@
|
||||
#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) {
|
||||
@ -105,11 +94,11 @@ nsHTMLEditorMouseListener::MouseUp(nsIDOMEvent* aMouseEvent)
|
||||
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) {
|
||||
@ -226,7 +215,9 @@ nsHTMLEditorMouseListener::MouseDown(nsIDOMEvent* aMouseEvent)
|
||||
// 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)
|
||||
{
|
||||
@ -279,11 +270,11 @@ nsHTMLEditorMouseListener::MouseDown(nsIDOMEvent* 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) {
|
||||
@ -304,16 +295,5 @@ nsHTMLEditorMouseListener::MouseClick(nsIDOMEvent* aMouseEvent)
|
||||
inlineTableEditing->DoInlineTableEditingAction(element);
|
||||
}
|
||||
|
||||
return nsTextEditorMouseListener::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);
|
||||
return nsEditorEventListener::MouseClick(aMouseEvent);
|
||||
}
|
@ -37,49 +37,28 @@
|
||||
*
|
||||
* ***** 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 //htmlEditorMouseListener_h__
|
||||
#endif // nsHTMLEditorEventListener_h__
|
||||
|
@ -211,16 +211,20 @@ 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
|
||||
|
@ -194,7 +194,8 @@ nsHTMLEditor::CreateResizer(nsIDOMElement ** aReturn, PRInt16 aLocation, nsIDOMN
|
||||
|
||||
// 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) {
|
||||
@ -453,43 +454,43 @@ nsHTMLEditor::HideResizers(void)
|
||||
|
||||
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;
|
||||
|
||||
|
@ -56,7 +56,6 @@ CPPSRCS = \
|
||||
nsPlaintextEditor.cpp \
|
||||
nsTextEditUtils.cpp \
|
||||
nsTextEditRules.cpp \
|
||||
nsEditorEventListeners.cpp \
|
||||
nsInternetCiter.cpp \
|
||||
nsTextEditRulesBidi.cpp \
|
||||
$(NULL)
|
||||
|
@ -1,291 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* 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):
|
||||
*
|
||||
* 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__
|
||||
|
||||
#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 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 {
|
||||
public:
|
||||
/** the default constructor
|
||||
*/
|
||||
nsTextEditorKeyListener();
|
||||
/** the default destructor. virtual due to the possibility of derivation.
|
||||
*/
|
||||
virtual ~nsTextEditorKeyListener();
|
||||
|
||||
/** 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 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);
|
||||
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;
|
||||
|
||||
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);
|
||||
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);
|
||||
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*/
|
||||
|
||||
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);
|
||||
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*/
|
||||
|
||||
protected:
|
||||
nsIEditor* mEditor; // weak reference
|
||||
nsWeakPtr mPresShell;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** 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__
|
||||
|
@ -42,7 +42,6 @@
|
||||
#include "nsCaret.h"
|
||||
#include "nsTextEditUtils.h"
|
||||
#include "nsTextEditRules.h"
|
||||
#include "nsEditorEventListeners.h"
|
||||
#include "nsIEditActionListener.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
@ -306,49 +305,6 @@ nsPlaintextEditor::SetDocumentCharacterSet(const nsACString & characterSet)
|
||||
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)
|
||||
{
|
||||
|
@ -185,9 +185,6 @@ protected:
|
||||
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,
|
||||
|
Loading…
Reference in New Issue
Block a user