зеркало из https://github.com/mozilla/gecko-dev.git
Added DragListener for Drag & Drop (it's not turned on)
This commit is contained in:
Родитель
33e191c63e
Коммит
61cfe9a3d0
|
@ -513,6 +513,82 @@ nsTextEditorMouseListener::MouseOut(nsIDOMEvent* aMouseEvent)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* nsTextEditorDragListener implementation
|
||||
*/
|
||||
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(nsTextEditorDragListener)
|
||||
|
||||
NS_IMPL_RELEASE(nsTextEditorDragListener)
|
||||
|
||||
|
||||
nsTextEditorDragListener::nsTextEditorDragListener()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsTextEditorDragListener::~nsTextEditorDragListener()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsresult
|
||||
nsTextEditorDragListener::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
if (nsnull == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
static NS_DEFINE_IID(kIDOMDragListenerIID, NS_IDOMDRAGLISTENER_IID);
|
||||
static NS_DEFINE_IID(kIDOMEventListenerIID, NS_IDOMEVENTLISTENER_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aInstancePtr = (void*)(nsISupports*)this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIDOMEventListenerIID)) {
|
||||
*aInstancePtr = (void*)(nsIDOMEventListener*)this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIDOMDragListenerIID)) {
|
||||
*aInstancePtr = (void*)(nsIDOMDragListener*)this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsresult
|
||||
nsTextEditorDragListener::ProcessEvent(nsIDOMEvent* aEvent)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsresult
|
||||
nsTextEditorDragListener::DragStart(nsIDOMEvent* aDragEvent)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsresult
|
||||
nsTextEditorDragListener::DragDrop(nsIDOMEvent* aMouseEvent)
|
||||
{
|
||||
mEditor->InsertText(nsAutoString("hello"));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
@ -557,4 +633,20 @@ NS_NewEditorMouseListener(nsIDOMEventListener ** aInstancePtrResult,
|
|||
|
||||
|
||||
|
||||
nsresult
|
||||
NS_NewEditorDragListener(nsIDOMEventListener ** aInstancePtrResult,
|
||||
nsITextEditor *aEditor)
|
||||
{
|
||||
nsTextEditorDragListener* it = new nsTextEditorDragListener();
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
it->SetEditor(aEditor);
|
||||
|
||||
static NS_DEFINE_IID(kIDOMEventListenerIID, NS_IDOMEVENTLISTENER_IID);
|
||||
|
||||
return it->QueryInterface(kIDOMEventListenerIID, (void **) aInstancePtrResult);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "nsIDOMEvent.h"
|
||||
#include "nsIDOMKeyListener.h"
|
||||
#include "nsIDOMMouseListener.h"
|
||||
#include "nsIDOMDragListener.h"
|
||||
#include "nsITextEditor.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
|
@ -100,6 +101,38 @@ protected:
|
|||
|
||||
};
|
||||
|
||||
/** editor Implementation of the MouseListener interface
|
||||
*/
|
||||
class nsTextEditorDragListener : public nsIDOMDragListener
|
||||
{
|
||||
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(nsITextEditor *aEditor){mEditor = do_QueryInterface(aEditor);}
|
||||
|
||||
/*interfaces for addref and release and queryinterface*/
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
/*BEGIN implementations of mouseevent handler interface*/
|
||||
virtual nsresult ProcessEvent(nsIDOMEvent* aEvent);
|
||||
public:
|
||||
virtual nsresult DragStart(nsIDOMEvent* aDragEvent);
|
||||
virtual nsresult DragDrop(nsIDOMEvent* aDragEvent);
|
||||
/*END implementations of mouseevent handler interface*/
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsITextEditor> mEditor;
|
||||
|
||||
};
|
||||
|
||||
/** factory for the editor key listener
|
||||
*/
|
||||
extern nsresult NS_NewEditorKeyListener(nsIDOMEventListener ** aInstancePtrResult, nsITextEditor *aEditor);
|
||||
|
@ -108,5 +141,9 @@ extern nsresult NS_NewEditorKeyListener(nsIDOMEventListener ** aInstancePtrResul
|
|||
*/
|
||||
extern nsresult NS_NewEditorMouseListener(nsIDOMEventListener ** aInstancePtrResult, nsITextEditor *aEditor);
|
||||
|
||||
/** factory for the editor drag listener
|
||||
*/
|
||||
extern nsresult NS_NewEditorDragListener(nsIDOMEventListener ** aInstancePtrResult, nsITextEditor *aEditor);
|
||||
|
||||
#endif //editorInterfaces_h__
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIDOMKeyListener.h"
|
||||
#include "nsIDOMMouseListener.h"
|
||||
#include "nsIDOMDragListener.h"
|
||||
#include "nsIDOMSelection.h"
|
||||
#include "nsIDOMRange.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
|
@ -73,6 +74,7 @@ class nsIFrame;
|
|||
static NS_DEFINE_IID(kIDOMEventReceiverIID, NS_IDOMEVENTRECEIVER_IID);
|
||||
static NS_DEFINE_IID(kIDOMMouseListenerIID, NS_IDOMMOUSELISTENER_IID);
|
||||
static NS_DEFINE_IID(kIDOMKeyListenerIID, NS_IDOMKEYLISTENER_IID);
|
||||
static NS_DEFINE_IID(kIDOMDragListenerIID, NS_IDOMDRAGLISTENER_IID);
|
||||
static NS_DEFINE_IID(kIEditPropertyIID, NS_IEDITPROPERTY_IID);
|
||||
|
||||
static NS_DEFINE_CID(kEditorCID, NS_EDITOR_CID);
|
||||
|
@ -109,6 +111,9 @@ nsTextEditor::~nsTextEditor()
|
|||
if (mMouseListenerP) {
|
||||
erP->RemoveEventListener(mMouseListenerP, kIDOMMouseListenerIID);
|
||||
}
|
||||
if (mDragListenerP) {
|
||||
erP->RemoveEventListener(mDragListenerP, kIDOMDragListenerIID);
|
||||
}
|
||||
}
|
||||
else
|
||||
NS_NOTREACHED("~nsTextEditor");
|
||||
|
@ -168,16 +173,23 @@ NS_IMETHODIMP nsTextEditor::Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell)
|
|||
return result;
|
||||
}
|
||||
|
||||
result = NS_NewEditorDragListener(getter_AddRefs(mDragListenerP), this);
|
||||
if (NS_OK != result) {
|
||||
//return result;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMEventReceiver> erP;
|
||||
result = aDoc->QueryInterface(kIDOMEventReceiverIID, getter_AddRefs(erP));
|
||||
if (NS_OK != result)
|
||||
{
|
||||
mKeyListenerP = do_QueryInterface(0);
|
||||
mMouseListenerP = do_QueryInterface(0); //dont need these if we cant register them
|
||||
mDragListenerP = do_QueryInterface(0); //dont need these if we cant register them
|
||||
return result;
|
||||
}
|
||||
//cmanske: Shouldn't we check result from this?
|
||||
erP->AddEventListener(mKeyListenerP, kIDOMKeyListenerIID);
|
||||
//erP->AddEventListener(mDragListenerP, kIDOMDragListenerIID);
|
||||
//erP->AddEventListener(mMouseListenerP, kIDOMMouseListenerIID);
|
||||
|
||||
// instantiate the rules for this text editor
|
||||
|
|
|
@ -124,6 +124,7 @@ protected:
|
|||
nsTextEditRules* mRules;
|
||||
nsCOMPtr<nsIDOMEventListener> mKeyListenerP;
|
||||
nsCOMPtr<nsIDOMEventListener> mMouseListenerP;
|
||||
nsCOMPtr<nsIDOMEventListener> mDragListenerP;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -513,6 +513,82 @@ nsTextEditorMouseListener::MouseOut(nsIDOMEvent* aMouseEvent)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* nsTextEditorDragListener implementation
|
||||
*/
|
||||
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(nsTextEditorDragListener)
|
||||
|
||||
NS_IMPL_RELEASE(nsTextEditorDragListener)
|
||||
|
||||
|
||||
nsTextEditorDragListener::nsTextEditorDragListener()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsTextEditorDragListener::~nsTextEditorDragListener()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsresult
|
||||
nsTextEditorDragListener::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
if (nsnull == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
static NS_DEFINE_IID(kIDOMDragListenerIID, NS_IDOMDRAGLISTENER_IID);
|
||||
static NS_DEFINE_IID(kIDOMEventListenerIID, NS_IDOMEVENTLISTENER_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aInstancePtr = (void*)(nsISupports*)this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIDOMEventListenerIID)) {
|
||||
*aInstancePtr = (void*)(nsIDOMEventListener*)this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIDOMDragListenerIID)) {
|
||||
*aInstancePtr = (void*)(nsIDOMDragListener*)this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsresult
|
||||
nsTextEditorDragListener::ProcessEvent(nsIDOMEvent* aEvent)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsresult
|
||||
nsTextEditorDragListener::DragStart(nsIDOMEvent* aDragEvent)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsresult
|
||||
nsTextEditorDragListener::DragDrop(nsIDOMEvent* aMouseEvent)
|
||||
{
|
||||
mEditor->InsertText(nsAutoString("hello"));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
@ -557,4 +633,20 @@ NS_NewEditorMouseListener(nsIDOMEventListener ** aInstancePtrResult,
|
|||
|
||||
|
||||
|
||||
nsresult
|
||||
NS_NewEditorDragListener(nsIDOMEventListener ** aInstancePtrResult,
|
||||
nsITextEditor *aEditor)
|
||||
{
|
||||
nsTextEditorDragListener* it = new nsTextEditorDragListener();
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
it->SetEditor(aEditor);
|
||||
|
||||
static NS_DEFINE_IID(kIDOMEventListenerIID, NS_IDOMEVENTLISTENER_IID);
|
||||
|
||||
return it->QueryInterface(kIDOMEventListenerIID, (void **) aInstancePtrResult);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "nsIDOMEvent.h"
|
||||
#include "nsIDOMKeyListener.h"
|
||||
#include "nsIDOMMouseListener.h"
|
||||
#include "nsIDOMDragListener.h"
|
||||
#include "nsITextEditor.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
|
@ -100,6 +101,38 @@ protected:
|
|||
|
||||
};
|
||||
|
||||
/** editor Implementation of the MouseListener interface
|
||||
*/
|
||||
class nsTextEditorDragListener : public nsIDOMDragListener
|
||||
{
|
||||
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(nsITextEditor *aEditor){mEditor = do_QueryInterface(aEditor);}
|
||||
|
||||
/*interfaces for addref and release and queryinterface*/
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
/*BEGIN implementations of mouseevent handler interface*/
|
||||
virtual nsresult ProcessEvent(nsIDOMEvent* aEvent);
|
||||
public:
|
||||
virtual nsresult DragStart(nsIDOMEvent* aDragEvent);
|
||||
virtual nsresult DragDrop(nsIDOMEvent* aDragEvent);
|
||||
/*END implementations of mouseevent handler interface*/
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsITextEditor> mEditor;
|
||||
|
||||
};
|
||||
|
||||
/** factory for the editor key listener
|
||||
*/
|
||||
extern nsresult NS_NewEditorKeyListener(nsIDOMEventListener ** aInstancePtrResult, nsITextEditor *aEditor);
|
||||
|
@ -108,5 +141,9 @@ extern nsresult NS_NewEditorKeyListener(nsIDOMEventListener ** aInstancePtrResul
|
|||
*/
|
||||
extern nsresult NS_NewEditorMouseListener(nsIDOMEventListener ** aInstancePtrResult, nsITextEditor *aEditor);
|
||||
|
||||
/** factory for the editor drag listener
|
||||
*/
|
||||
extern nsresult NS_NewEditorDragListener(nsIDOMEventListener ** aInstancePtrResult, nsITextEditor *aEditor);
|
||||
|
||||
#endif //editorInterfaces_h__
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче