Eliminating warning for non-compliant XBL event handlers.

This commit is contained in:
hyatt%netscape.com 2000-09-02 02:39:06 +00:00
Родитель 489a678c11
Коммит 3b60037bfe
7 изменённых файлов: 238 добавлений и 45 удалений

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

@ -614,14 +614,7 @@ nsXBLBinding::InstallEventHandlers(nsIContent* aBoundElement, nsIXBLBinding** aB
else
GetEventHandlerIID(eventAtom, &iid, &found);
if (found || special) {
// Add an event listener for mouse and key events only.
PRBool mouse = IsMouseHandler(type);
PRBool key = IsKeyHandler(type);
PRBool focus = IsFocusHandler(type);
PRBool xul = IsXULHandler(type);
PRBool scroll = IsScrollHandler(type);
if (found || special) {
nsCOMPtr<nsIDOMEventReceiver> receiver = do_QueryInterface(mBoundElement);
nsAutoString attachType;
child->GetAttribute(kNameSpaceID_None, kAttachToAtom, attachType);
@ -646,7 +639,29 @@ nsXBLBinding::InstallEventHandlers(nsIContent* aBoundElement, nsIXBLBinding** aB
receiver = do_QueryInterface(otherElement);
}
if (mouse || key || focus || xul || scroll || special) {
// Add an event listener for mouse and key events only.
PRBool mouse, key, focus, xul, scroll, form;
mouse = key = focus = xul = scroll = form = PR_FALSE;
if (!special) {
mouse = IsMouseHandler(type);
if (!mouse) {
key = IsKeyHandler(type);
if (!key) {
focus = IsFocusHandler(type);
if (!focus) {
xul = IsXULHandler(type);
if (!xul) {
scroll = IsScrollHandler(type);
if (!scroll)
form = IsFormHandler(type);
}
}
}
}
}
if (mouse || key || focus || xul || scroll || form || special) {
// Create a new nsXBLEventHandler.
nsXBLEventHandler* handler;
NS_NewXBLEventHandler(receiver, curr, type, &handler);
@ -678,6 +693,8 @@ nsXBLBinding::InstallEventHandlers(nsIContent* aBoundElement, nsIXBLBinding** aB
receiver->AddEventListener(type, (nsIDOMMenuListener*)handler, useCapture);
else if (scroll)
receiver->AddEventListener(type, (nsIDOMScrollListener*)handler, useCapture);
else if (form)
receiver->AddEventListener(type, (nsIDOMFormListener*)handler, useCapture);
if (!special) // Let the listener manager hold on to the handler.
NS_RELEASE(handler);
@ -1653,6 +1670,16 @@ nsXBLBinding::IsScrollHandler(const nsString& aName)
aName == NS_LITERAL_STRING("overflowchanged"));
}
PRBool
nsXBLBinding::IsFormHandler(const nsString& aName)
{
return (aName == NS_LITERAL_STRING("submit") ||
aName == NS_LITERAL_STRING("reset") ||
aName == NS_LITERAL_STRING("change") ||
aName == NS_LITERAL_STRING("input") ||
aName == NS_LITERAL_STRING("select"));
}
NS_IMETHODIMP
nsXBLBinding::AddScriptEventListener(nsIContent* aElement, nsIAtom* aName, const nsString& aValue, REFNSIID aIID)
{

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

@ -145,6 +145,7 @@ public:
static PRBool IsFocusHandler(const nsString& aName);
static PRBool IsXULHandler(const nsString& aName);
static PRBool IsScrollHandler(const nsString& aName);
static PRBool IsFormHandler(const nsString& aName);
static nsFixedSizeAllocator kPool;

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

@ -104,7 +104,8 @@ nsXBLEventHandler::~nsXBLEventHandler()
}
}
NS_IMPL_ISUPPORTS5(nsXBLEventHandler, nsIDOMKeyListener, nsIDOMMouseListener, nsIDOMMenuListener, nsIDOMFocusListener, nsIDOMScrollListener)
NS_IMPL_ISUPPORTS6(nsXBLEventHandler, nsIDOMKeyListener, nsIDOMMouseListener, nsIDOMMenuListener,
nsIDOMFocusListener, nsIDOMScrollListener, nsIDOMFormListener)
NS_IMETHODIMP
nsXBLEventHandler::BindingAttached()
@ -391,6 +392,51 @@ nsresult nsXBLEventHandler::Destroy(nsIDOMEvent* aEvent)
return NS_OK;
}
nsresult nsXBLEventHandler::Submit(nsIDOMEvent* aEvent)
{
if (mEventName != NS_LITERAL_STRING("submit"))
return NS_OK;
ExecuteHandler(NS_LITERAL_STRING("submit"), aEvent);
return NS_OK;
}
nsresult nsXBLEventHandler::Reset(nsIDOMEvent* aEvent)
{
if (mEventName != NS_LITERAL_STRING("reset"))
return NS_OK;
ExecuteHandler(NS_LITERAL_STRING("reset"), aEvent);
return NS_OK;
}
nsresult nsXBLEventHandler::Select(nsIDOMEvent* aEvent)
{
if (mEventName != NS_LITERAL_STRING("select"))
return NS_OK;
ExecuteHandler(NS_LITERAL_STRING("select"), aEvent);
return NS_OK;
}
nsresult nsXBLEventHandler::Change(nsIDOMEvent* aEvent)
{
if (mEventName != NS_LITERAL_STRING("change"))
return NS_OK;
ExecuteHandler(NS_LITERAL_STRING("change"), aEvent);
return NS_OK;
}
nsresult nsXBLEventHandler::Input(nsIDOMEvent* aEvent)
{
if (mEventName != NS_LITERAL_STRING("input"))
return NS_OK;
ExecuteHandler(NS_LITERAL_STRING("input"), aEvent);
return NS_OK;
}
NS_IMETHODIMP
nsXBLEventHandler::ExecuteHandler(const nsAReadableString & aEventName, nsIDOMEvent* aEvent)
@ -566,22 +612,40 @@ nsXBLEventHandler::RemoveEventHandlers()
// Figure out our type.
PRBool mouse = nsXBLBinding::IsMouseHandler(type);
PRBool key = nsXBLBinding::IsKeyHandler(type);
PRBool focus = nsXBLBinding::IsFocusHandler(type);
PRBool xul = nsXBLBinding::IsXULHandler(type);
PRBool scroll = nsXBLBinding::IsScrollHandler(type);
// Remove the event listener.
if (mouse)
if (mouse) {
mEventReceiver->RemoveEventListener(type, (nsIDOMMouseListener*)this, useCapture);
else if(key)
return;
}
PRBool key = nsXBLBinding::IsKeyHandler(type);
if (key) {
mEventReceiver->RemoveEventListener(type, (nsIDOMKeyListener*)this, useCapture);
else if(focus)
return;
}
PRBool focus = nsXBLBinding::IsFocusHandler(type);
if (focus) {
mEventReceiver->RemoveEventListener(type, (nsIDOMFocusListener*)this, useCapture);
else if(scroll)
mEventReceiver->RemoveEventListener(type, (nsIDOMScrollListener*)this, useCapture);
else if (xul)
return;
}
PRBool xul = nsXBLBinding::IsXULHandler(type);
if (xul) {
mEventReceiver->RemoveEventListener(type, (nsIDOMMenuListener*)this, useCapture);
return;
}
PRBool scroll = nsXBLBinding::IsScrollHandler(type);
if (scroll) {
mEventReceiver->RemoveEventListener(type, (nsIDOMScrollListener*)this, useCapture);
return;
}
PRBool form = nsXBLBinding::IsFormHandler(type);
if (form) {
mEventReceiver->RemoveEventListener(type, (nsIDOMFormListener*)this, useCapture);
return;
}
}
/// Helpers that are relegated to the end of the file /////////////////////////////

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

@ -31,6 +31,7 @@
#include "nsIDOMMenuListener.h"
#include "nsIDOMFocusListener.h"
#include "nsIDOMScrollListener.h"
#include "nsIDOMFormListener.h"
class nsIXBLBinding;
class nsIDOMEvent;
@ -46,7 +47,8 @@ class nsXBLEventHandler : public nsIDOMKeyListener,
public nsIDOMMouseListener,
public nsIDOMMenuListener,
public nsIDOMFocusListener,
public nsIDOMScrollListener
public nsIDOMScrollListener,
public nsIDOMFormListener
{
public:
nsXBLEventHandler(nsIDOMEventReceiver* aReceiver, nsIXBLPrototypeHandler* aHandler, const nsString& aEventName);
@ -85,6 +87,13 @@ public:
NS_IMETHOD Underflow(nsIDOMEvent* aEvent);
NS_IMETHOD OverflowChanged(nsIDOMEvent* aEvent);
// form
virtual nsresult Submit(nsIDOMEvent* aEvent);
virtual nsresult Reset(nsIDOMEvent* aEvent);
virtual nsresult Change(nsIDOMEvent* aEvent);
virtual nsresult Select(nsIDOMEvent* aEvent);
virtual nsresult Input(nsIDOMEvent* aEvent);
NS_DECL_ISUPPORTS
public:

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

@ -614,14 +614,7 @@ nsXBLBinding::InstallEventHandlers(nsIContent* aBoundElement, nsIXBLBinding** aB
else
GetEventHandlerIID(eventAtom, &iid, &found);
if (found || special) {
// Add an event listener for mouse and key events only.
PRBool mouse = IsMouseHandler(type);
PRBool key = IsKeyHandler(type);
PRBool focus = IsFocusHandler(type);
PRBool xul = IsXULHandler(type);
PRBool scroll = IsScrollHandler(type);
if (found || special) {
nsCOMPtr<nsIDOMEventReceiver> receiver = do_QueryInterface(mBoundElement);
nsAutoString attachType;
child->GetAttribute(kNameSpaceID_None, kAttachToAtom, attachType);
@ -646,7 +639,29 @@ nsXBLBinding::InstallEventHandlers(nsIContent* aBoundElement, nsIXBLBinding** aB
receiver = do_QueryInterface(otherElement);
}
if (mouse || key || focus || xul || scroll || special) {
// Add an event listener for mouse and key events only.
PRBool mouse, key, focus, xul, scroll, form;
mouse = key = focus = xul = scroll = form = PR_FALSE;
if (!special) {
mouse = IsMouseHandler(type);
if (!mouse) {
key = IsKeyHandler(type);
if (!key) {
focus = IsFocusHandler(type);
if (!focus) {
xul = IsXULHandler(type);
if (!xul) {
scroll = IsScrollHandler(type);
if (!scroll)
form = IsFormHandler(type);
}
}
}
}
}
if (mouse || key || focus || xul || scroll || form || special) {
// Create a new nsXBLEventHandler.
nsXBLEventHandler* handler;
NS_NewXBLEventHandler(receiver, curr, type, &handler);
@ -678,6 +693,8 @@ nsXBLBinding::InstallEventHandlers(nsIContent* aBoundElement, nsIXBLBinding** aB
receiver->AddEventListener(type, (nsIDOMMenuListener*)handler, useCapture);
else if (scroll)
receiver->AddEventListener(type, (nsIDOMScrollListener*)handler, useCapture);
else if (form)
receiver->AddEventListener(type, (nsIDOMFormListener*)handler, useCapture);
if (!special) // Let the listener manager hold on to the handler.
NS_RELEASE(handler);
@ -1653,6 +1670,16 @@ nsXBLBinding::IsScrollHandler(const nsString& aName)
aName == NS_LITERAL_STRING("overflowchanged"));
}
PRBool
nsXBLBinding::IsFormHandler(const nsString& aName)
{
return (aName == NS_LITERAL_STRING("submit") ||
aName == NS_LITERAL_STRING("reset") ||
aName == NS_LITERAL_STRING("change") ||
aName == NS_LITERAL_STRING("input") ||
aName == NS_LITERAL_STRING("select"));
}
NS_IMETHODIMP
nsXBLBinding::AddScriptEventListener(nsIContent* aElement, nsIAtom* aName, const nsString& aValue, REFNSIID aIID)
{

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

@ -145,6 +145,7 @@ public:
static PRBool IsFocusHandler(const nsString& aName);
static PRBool IsXULHandler(const nsString& aName);
static PRBool IsScrollHandler(const nsString& aName);
static PRBool IsFormHandler(const nsString& aName);
static nsFixedSizeAllocator kPool;

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

@ -104,7 +104,8 @@ nsXBLEventHandler::~nsXBLEventHandler()
}
}
NS_IMPL_ISUPPORTS5(nsXBLEventHandler, nsIDOMKeyListener, nsIDOMMouseListener, nsIDOMMenuListener, nsIDOMFocusListener, nsIDOMScrollListener)
NS_IMPL_ISUPPORTS6(nsXBLEventHandler, nsIDOMKeyListener, nsIDOMMouseListener, nsIDOMMenuListener,
nsIDOMFocusListener, nsIDOMScrollListener, nsIDOMFormListener)
NS_IMETHODIMP
nsXBLEventHandler::BindingAttached()
@ -391,6 +392,51 @@ nsresult nsXBLEventHandler::Destroy(nsIDOMEvent* aEvent)
return NS_OK;
}
nsresult nsXBLEventHandler::Submit(nsIDOMEvent* aEvent)
{
if (mEventName != NS_LITERAL_STRING("submit"))
return NS_OK;
ExecuteHandler(NS_LITERAL_STRING("submit"), aEvent);
return NS_OK;
}
nsresult nsXBLEventHandler::Reset(nsIDOMEvent* aEvent)
{
if (mEventName != NS_LITERAL_STRING("reset"))
return NS_OK;
ExecuteHandler(NS_LITERAL_STRING("reset"), aEvent);
return NS_OK;
}
nsresult nsXBLEventHandler::Select(nsIDOMEvent* aEvent)
{
if (mEventName != NS_LITERAL_STRING("select"))
return NS_OK;
ExecuteHandler(NS_LITERAL_STRING("select"), aEvent);
return NS_OK;
}
nsresult nsXBLEventHandler::Change(nsIDOMEvent* aEvent)
{
if (mEventName != NS_LITERAL_STRING("change"))
return NS_OK;
ExecuteHandler(NS_LITERAL_STRING("change"), aEvent);
return NS_OK;
}
nsresult nsXBLEventHandler::Input(nsIDOMEvent* aEvent)
{
if (mEventName != NS_LITERAL_STRING("input"))
return NS_OK;
ExecuteHandler(NS_LITERAL_STRING("input"), aEvent);
return NS_OK;
}
NS_IMETHODIMP
nsXBLEventHandler::ExecuteHandler(const nsAReadableString & aEventName, nsIDOMEvent* aEvent)
@ -566,22 +612,40 @@ nsXBLEventHandler::RemoveEventHandlers()
// Figure out our type.
PRBool mouse = nsXBLBinding::IsMouseHandler(type);
PRBool key = nsXBLBinding::IsKeyHandler(type);
PRBool focus = nsXBLBinding::IsFocusHandler(type);
PRBool xul = nsXBLBinding::IsXULHandler(type);
PRBool scroll = nsXBLBinding::IsScrollHandler(type);
// Remove the event listener.
if (mouse)
if (mouse) {
mEventReceiver->RemoveEventListener(type, (nsIDOMMouseListener*)this, useCapture);
else if(key)
return;
}
PRBool key = nsXBLBinding::IsKeyHandler(type);
if (key) {
mEventReceiver->RemoveEventListener(type, (nsIDOMKeyListener*)this, useCapture);
else if(focus)
return;
}
PRBool focus = nsXBLBinding::IsFocusHandler(type);
if (focus) {
mEventReceiver->RemoveEventListener(type, (nsIDOMFocusListener*)this, useCapture);
else if(scroll)
mEventReceiver->RemoveEventListener(type, (nsIDOMScrollListener*)this, useCapture);
else if (xul)
return;
}
PRBool xul = nsXBLBinding::IsXULHandler(type);
if (xul) {
mEventReceiver->RemoveEventListener(type, (nsIDOMMenuListener*)this, useCapture);
return;
}
PRBool scroll = nsXBLBinding::IsScrollHandler(type);
if (scroll) {
mEventReceiver->RemoveEventListener(type, (nsIDOMScrollListener*)this, useCapture);
return;
}
PRBool form = nsXBLBinding::IsFormHandler(type);
if (form) {
mEventReceiver->RemoveEventListener(type, (nsIDOMFormListener*)this, useCapture);
return;
}
}
/// Helpers that are relegated to the end of the file /////////////////////////////