Skip to content

Commit

Permalink
Changing api uses in editor, rdf, and xpfe to match DOM2 api name/par…
Browse files Browse the repository at this point in the history
…am changes.
  • Loading branch information
joki%netscape.com committed Mar 28, 1999
1 parent 8e25fcd commit e39e13c
Show file tree
Hide file tree
Showing 24 changed files with 203 additions and 77 deletions.
62 changes: 50 additions & 12 deletions content/xul/content/src/nsXULElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,17 @@ class RDFElementImpl : public nsIDOMXULElement,
NS_IMETHOD SetNameSpaceID(PRInt32 aNameSpaceID);

// nsIDOMEventReceiver
NS_IMETHOD AddEventListener(nsIDOMEventListener *aListener, const nsIID& aIID);
NS_IMETHOD RemoveEventListener(nsIDOMEventListener *aListener, const nsIID& aIID);
NS_IMETHOD AddEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID);
NS_IMETHOD RemoveEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID);
NS_IMETHOD GetListenerManager(nsIEventListenerManager** aInstancePtrResult);
NS_IMETHOD GetNewListenerManager(nsIEventListenerManager **aInstancePtrResult);

// nsIDOMEventTarget interface
NS_IMETHOD AddEventListener(const nsString& aType, nsIDOMEventListener* aListener,
PRBool aPostProcess, PRBool aUseCapture);
NS_IMETHOD RemoveEventListener(const nsString& aType, nsIDOMEventListener* aListener,
PRBool aPostProcess, PRBool aUseCapture);


// nsIJSScriptObject
virtual PRBool AddProperty(JSContext *aContext, jsval aID, jsval *aVp);
Expand Down Expand Up @@ -1022,28 +1028,59 @@ RDFElementImpl::SetNameSpaceID(PRInt32 aNameSpaceID)
// nsIDOMEventReceiver interface

NS_IMETHODIMP
RDFElementImpl::AddEventListener(nsIDOMEventListener *aListener, const nsIID& aIID)
RDFElementImpl::AddEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID)
{
nsIEventListenerManager *manager;

if (NS_OK == GetListenerManager(&manager)) {
manager->AddEventListener(aListener, aIID);
manager->AddEventListenerByIID(aListener, aIID, NS_EVENT_FLAG_BUBBLE);
NS_RELEASE(manager);
return NS_OK;
}
return NS_ERROR_FAILURE;
}

NS_IMETHODIMP
RDFElementImpl::RemoveEventListener(nsIDOMEventListener *aListener, const nsIID& aIID)
RDFElementImpl::RemoveEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID)
{
if (nsnull != mListenerManager) {
mListenerManager->RemoveEventListener(aListener, aIID);
mListenerManager->RemoveEventListenerByIID(aListener, aIID, NS_EVENT_FLAG_BUBBLE);
return NS_OK;
}
return NS_ERROR_FAILURE;
}

NS_IMETHODIMP
RDFElementImpl::AddEventListener(const nsString& aType, nsIDOMEventListener* aListener,
PRBool aPostProcess, PRBool aUseCapture)
{
nsIEventListenerManager *manager;

if (NS_OK == GetListenerManager(&manager)) {
PRInt32 flags = (aPostProcess ? NS_EVENT_FLAG_POST_PROCESS : NS_EVENT_FLAG_NONE) |
(aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE);

manager->AddEventListenerByType(aListener, aType, flags);
NS_RELEASE(manager);
return NS_OK;
}
return NS_ERROR_FAILURE;
}

NS_IMETHODIMP
RDFElementImpl::RemoveEventListener(const nsString& aType, nsIDOMEventListener* aListener,
PRBool aPostProcess, PRBool aUseCapture)
{
if (nsnull != mListenerManager) {
PRInt32 flags = (aPostProcess ? NS_EVENT_FLAG_POST_PROCESS : NS_EVENT_FLAG_NONE) |
(aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE);

mListenerManager->RemoveEventListenerByType(aListener, aType, flags);
return NS_OK;
}
return NS_ERROR_FAILURE;
}

NS_IMETHODIMP
RDFElementImpl::GetListenerManager(nsIEventListenerManager** aResult)
{
Expand Down Expand Up @@ -2111,7 +2148,7 @@ RDFElementImpl::HandleDOMEvent(nsIPresContext& aPresContext,
nsresult ret = NS_OK;

nsIDOMEvent* domEvent = nsnull;
if (DOM_EVENT_INIT == aFlags) {
if (NS_EVENT_FLAG_INIT == aFlags) {
aDOMEvent = &domEvent;
// In order for the event to have a proper target for menus (which have no corresponding
// frame target in the visual model), we have to explicitly set the target of the
Expand All @@ -2134,19 +2171,20 @@ RDFElementImpl::HandleDOMEvent(nsIPresContext& aPresContext,
}

//Capturing stage
//XXX Nees impl. Talk to [email protected] for help.

//Local handling stage
if (nsnull != mListenerManager) {
mListenerManager->HandleEvent(aPresContext, aEvent, aDOMEvent, aEventStatus);
mListenerManager->HandleEvent(aPresContext, aEvent, aDOMEvent, aFlags, aEventStatus);
}

//Bubbling stage
if ((DOM_EVENT_CAPTURE != aFlags) && (mParent != nsnull)) {
if ((NS_EVENT_FLAG_CAPTURE != aFlags) && (mParent != nsnull)) {
ret = mParent->HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
DOM_EVENT_BUBBLE, aEventStatus);
NS_EVENT_FLAG_BUBBLE, aEventStatus);
}

if (DOM_EVENT_INIT == aFlags) {
if (NS_EVENT_FLAG_INIT == aFlags) {
// We're leaving the DOM event loop so if we created a DOM event,
// release here.
if (nsnull != *aDOMEvent) {
Expand Down Expand Up @@ -2412,7 +2450,7 @@ RDFElementImpl::ExecuteJSCode(nsIDOMElement* anElement)
nsEvent event;
event.eventStructType = NS_EVENT;
event.message = NS_FORM_CHANGE; // XXX: I feel dirty and evil for subverting this.
content->HandleDOMEvent(*aPresContext, &event, nsnull, DOM_EVENT_INIT, status);
content->HandleDOMEvent(*aPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, status);
}

return NS_OK;
Expand Down
2 changes: 1 addition & 1 deletion docshell/base/nsWebShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2085,7 +2085,7 @@ nsWebShell::OnConnectionsComplete()
nsMouseEvent event;
event.eventStructType = NS_EVENT;
event.message = NS_PAGE_LOAD;
rv = mScriptGlobal->HandleDOMEvent(*presContext, &event, nsnull, DOM_EVENT_INIT, status);
rv = mScriptGlobal->HandleDOMEvent(*presContext, &event, nsnull, NS_EVENT_FLAG_INIT, status);

NS_RELEASE(presContext);
}
Expand Down
8 changes: 4 additions & 4 deletions editor/base/nsEditorEventListeners.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ nsTextEditorKeyListener::QueryInterface(REFNSIID aIID, void** aInstancePtr)


nsresult
nsTextEditorKeyListener::ProcessEvent(nsIDOMEvent* aEvent)
nsTextEditorKeyListener::HandleEvent(nsIDOMEvent* aEvent)
{
return NS_OK;
}
Expand Down Expand Up @@ -480,7 +480,7 @@ nsTextEditorMouseListener::QueryInterface(REFNSIID aIID, void** aInstancePtr)


nsresult
nsTextEditorMouseListener::ProcessEvent(nsIDOMEvent* aEvent)
nsTextEditorMouseListener::HandleEvent(nsIDOMEvent* aEvent)
{
return NS_OK;
}
Expand Down Expand Up @@ -617,7 +617,7 @@ nsTextEditorTextListener::QueryInterface(REFNSIID aIID, void** aInstancePtr)
}

nsresult
nsTextEditorTextListener::ProcessEvent(nsIDOMEvent* aEvent)
nsTextEditorTextListener::HandleEvent(nsIDOMEvent* aEvent)
{
return NS_OK;
}
Expand Down Expand Up @@ -690,7 +690,7 @@ nsTextEditorDragListener::QueryInterface(REFNSIID aIID, void** aInstancePtr)


nsresult
nsTextEditorDragListener::ProcessEvent(nsIDOMEvent* aEvent)
nsTextEditorDragListener::HandleEvent(nsIDOMEvent* aEvent)
{
return NS_OK;
}
Expand Down
8 changes: 4 additions & 4 deletions editor/base/nsEditorEventListeners.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class nsTextEditorKeyListener : public nsIDOMKeyListener {
/*BEGIN interfaces in to the keylister base interface. must be supplied to handle pure virtual interfaces
see the nsIDOMKeyListener interface implementation for details
*/
virtual nsresult ProcessEvent(nsIDOMEvent* aEvent);
virtual nsresult HandleEvent(nsIDOMEvent* aEvent);
virtual nsresult KeyDown(nsIDOMEvent* aKeyEvent);
virtual nsresult KeyUp(nsIDOMEvent* aKeyEvent);
virtual nsresult KeyPress(nsIDOMEvent* aKeyEvent);
Expand Down Expand Up @@ -87,7 +87,7 @@ class nsTextEditorTextListener : public nsIDOMTextListener
NS_DECL_ISUPPORTS

/*BEGIN implementations of textevent handler interface*/
virtual nsresult ProcessEvent(nsIDOMEvent* aEvent);
virtual nsresult HandleEvent(nsIDOMEvent* aEvent);
public:
virtual nsresult HandleText(nsIDOMEvent* aTextEvent);
/*END implementations of textevent handler interface*/
Expand Down Expand Up @@ -120,7 +120,7 @@ class nsTextEditorMouseListener : public nsIDOMMouseListener
NS_DECL_ISUPPORTS

/*BEGIN implementations of mouseevent handler interface*/
virtual nsresult ProcessEvent(nsIDOMEvent* aEvent);
virtual nsresult HandleEvent(nsIDOMEvent* aEvent);
public:
virtual nsresult MouseDown(nsIDOMEvent* aMouseEvent);
virtual nsresult MouseUp(nsIDOMEvent* aMouseEvent);
Expand Down Expand Up @@ -157,7 +157,7 @@ class nsTextEditorDragListener : public nsIDOMDragListener
NS_DECL_ISUPPORTS

/*BEGIN implementations of mouseevent handler interface*/
virtual nsresult ProcessEvent(nsIDOMEvent* aEvent);
virtual nsresult HandleEvent(nsIDOMEvent* aEvent);
public:
virtual nsresult DragStart(nsIDOMEvent* aDragEvent);
virtual nsresult DragDrop(nsIDOMEvent* aDragEvent);
Expand Down
16 changes: 8 additions & 8 deletions editor/base/nsTextEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,18 @@ nsTextEditor::~nsTextEditor()
if (NS_SUCCEEDED(result) && erP)
{
if (mKeyListenerP) {
erP->RemoveEventListener(mKeyListenerP, kIDOMKeyListenerIID);
erP->RemoveEventListenerByIID(mKeyListenerP, kIDOMKeyListenerIID);
}
if (mMouseListenerP) {
erP->RemoveEventListener(mMouseListenerP, kIDOMMouseListenerIID);
erP->RemoveEventListenerByIID(mMouseListenerP, kIDOMMouseListenerIID);
}

if (mTextListenerP) {
erP->RemoveEventListener(mTextListenerP, kIDOMTextListenerIID);
erP->RemoveEventListenerByIID(mTextListenerP, kIDOMTextListenerIID);
}

if (mDragListenerP) {
erP->RemoveEventListener(mDragListenerP, kIDOMDragListenerIID);
erP->RemoveEventListenerByIID(mDragListenerP, kIDOMDragListenerIID);
}

}
Expand Down Expand Up @@ -216,11 +216,11 @@ NS_IMETHODIMP nsTextEditor::Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell)
return result;
}
//cmanske: Shouldn't we check result from this?
erP->AddEventListener(mKeyListenerP, kIDOMKeyListenerIID);
//erP->AddEventListener(mDragListenerP, kIDOMDragListenerIID);
//erP->AddEventListener(mMouseListenerP, kIDOMMouseListenerIID);
erP->AddEventListenerByIID(mKeyListenerP, kIDOMKeyListenerIID);
//erP->AddEventListenerByIID(mDragListenerP, kIDOMDragListenerIID);
//erP->AddEventListenerByIID(mMouseListenerP, kIDOMMouseListenerIID);

erP->AddEventListener(mTextListenerP,kIDOMTextListenerIID);
erP->AddEventListenerByIID(mTextListenerP,kIDOMTextListenerIID);

// instantiate the rules for this text editor
// XXX: we should be told which set of rules to instantiate
Expand Down
8 changes: 4 additions & 4 deletions editor/libeditor/text/nsEditorEventListeners.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ nsTextEditorKeyListener::QueryInterface(REFNSIID aIID, void** aInstancePtr)


nsresult
nsTextEditorKeyListener::ProcessEvent(nsIDOMEvent* aEvent)
nsTextEditorKeyListener::HandleEvent(nsIDOMEvent* aEvent)
{
return NS_OK;
}
Expand Down Expand Up @@ -480,7 +480,7 @@ nsTextEditorMouseListener::QueryInterface(REFNSIID aIID, void** aInstancePtr)


nsresult
nsTextEditorMouseListener::ProcessEvent(nsIDOMEvent* aEvent)
nsTextEditorMouseListener::HandleEvent(nsIDOMEvent* aEvent)
{
return NS_OK;
}
Expand Down Expand Up @@ -617,7 +617,7 @@ nsTextEditorTextListener::QueryInterface(REFNSIID aIID, void** aInstancePtr)
}

nsresult
nsTextEditorTextListener::ProcessEvent(nsIDOMEvent* aEvent)
nsTextEditorTextListener::HandleEvent(nsIDOMEvent* aEvent)
{
return NS_OK;
}
Expand Down Expand Up @@ -690,7 +690,7 @@ nsTextEditorDragListener::QueryInterface(REFNSIID aIID, void** aInstancePtr)


nsresult
nsTextEditorDragListener::ProcessEvent(nsIDOMEvent* aEvent)
nsTextEditorDragListener::HandleEvent(nsIDOMEvent* aEvent)
{
return NS_OK;
}
Expand Down
8 changes: 4 additions & 4 deletions editor/libeditor/text/nsEditorEventListeners.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class nsTextEditorKeyListener : public nsIDOMKeyListener {
/*BEGIN interfaces in to the keylister base interface. must be supplied to handle pure virtual interfaces
see the nsIDOMKeyListener interface implementation for details
*/
virtual nsresult ProcessEvent(nsIDOMEvent* aEvent);
virtual nsresult HandleEvent(nsIDOMEvent* aEvent);
virtual nsresult KeyDown(nsIDOMEvent* aKeyEvent);
virtual nsresult KeyUp(nsIDOMEvent* aKeyEvent);
virtual nsresult KeyPress(nsIDOMEvent* aKeyEvent);
Expand Down Expand Up @@ -87,7 +87,7 @@ class nsTextEditorTextListener : public nsIDOMTextListener
NS_DECL_ISUPPORTS

/*BEGIN implementations of textevent handler interface*/
virtual nsresult ProcessEvent(nsIDOMEvent* aEvent);
virtual nsresult HandleEvent(nsIDOMEvent* aEvent);
public:
virtual nsresult HandleText(nsIDOMEvent* aTextEvent);
/*END implementations of textevent handler interface*/
Expand Down Expand Up @@ -120,7 +120,7 @@ class nsTextEditorMouseListener : public nsIDOMMouseListener
NS_DECL_ISUPPORTS

/*BEGIN implementations of mouseevent handler interface*/
virtual nsresult ProcessEvent(nsIDOMEvent* aEvent);
virtual nsresult HandleEvent(nsIDOMEvent* aEvent);
public:
virtual nsresult MouseDown(nsIDOMEvent* aMouseEvent);
virtual nsresult MouseUp(nsIDOMEvent* aMouseEvent);
Expand Down Expand Up @@ -157,7 +157,7 @@ class nsTextEditorDragListener : public nsIDOMDragListener
NS_DECL_ISUPPORTS

/*BEGIN implementations of mouseevent handler interface*/
virtual nsresult ProcessEvent(nsIDOMEvent* aEvent);
virtual nsresult HandleEvent(nsIDOMEvent* aEvent);
public:
virtual nsresult DragStart(nsIDOMEvent* aDragEvent);
virtual nsresult DragDrop(nsIDOMEvent* aDragEvent);
Expand Down
Loading

0 comments on commit e39e13c

Please sign in to comment.