2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef nsXBLEventHandler_h__
|
|
|
|
#define nsXBLEventHandler_h__
|
|
|
|
|
2013-05-29 13:43:41 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIDOMEventListener.h"
|
2009-03-20 01:15:35 -07:00
|
|
|
#include "nsTArray.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
class nsIAtom;
|
2008-04-14 21:16:24 -07:00
|
|
|
class nsIDOMKeyEvent;
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsXBLPrototypeHandler;
|
|
|
|
|
|
|
|
class nsXBLEventHandler : public nsIDOMEventListener
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsXBLEventHandler(nsXBLPrototypeHandler* aHandler);
|
|
|
|
virtual ~nsXBLEventHandler();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
NS_DECL_NSIDOMEVENTLISTENER
|
|
|
|
|
|
|
|
protected:
|
|
|
|
nsXBLPrototypeHandler* mProtoHandler;
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsXBLEventHandler();
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool EventMatched(nsIDOMEvent* aEvent)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class nsXBLMouseEventHandler : public nsXBLEventHandler
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsXBLMouseEventHandler(nsXBLPrototypeHandler* aHandler);
|
|
|
|
virtual ~nsXBLMouseEventHandler();
|
|
|
|
|
|
|
|
private:
|
2013-05-29 13:43:41 -07:00
|
|
|
bool EventMatched(nsIDOMEvent* aEvent) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
class nsXBLKeyEventHandler : public nsIDOMEventListener
|
|
|
|
{
|
|
|
|
public:
|
2012-08-22 08:56:38 -07:00
|
|
|
nsXBLKeyEventHandler(nsIAtom* aEventType, uint8_t aPhase, uint8_t aType);
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual ~nsXBLKeyEventHandler();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
NS_DECL_NSIDOMEVENTLISTENER
|
|
|
|
|
|
|
|
void AddProtoHandler(nsXBLPrototypeHandler* aProtoHandler)
|
|
|
|
{
|
|
|
|
mProtoHandlers.AppendElement(aProtoHandler);
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
bool Matches(nsIAtom* aEventType, uint8_t aPhase, uint8_t aType) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return (mEventType == aEventType && mPhase == aPhase && mType == aType);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GetEventName(nsAString& aString) const
|
|
|
|
{
|
|
|
|
mEventType->ToString(aString);
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t GetPhase() const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return mPhase;
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t GetType() const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return mType;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
void SetIsBoundToChrome(bool aIsBoundToChrome)
|
2007-04-15 09:28:53 -07:00
|
|
|
{
|
|
|
|
mIsBoundToChrome = aIsBoundToChrome;
|
|
|
|
}
|
2013-11-01 07:31:58 -07:00
|
|
|
|
|
|
|
void SetUsingXBLScope(bool aUsingXBLScope)
|
|
|
|
{
|
|
|
|
mUsingXBLScope = aUsingXBLScope;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
private:
|
|
|
|
nsXBLKeyEventHandler();
|
2012-08-22 08:56:38 -07:00
|
|
|
bool ExecuteMatchedHandlers(nsIDOMKeyEvent* aEvent, uint32_t aCharCode,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aIgnoreShiftKey);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-03-20 01:15:35 -07:00
|
|
|
nsTArray<nsXBLPrototypeHandler*> mProtoHandlers;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIAtom> mEventType;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t mPhase;
|
|
|
|
uint8_t mType;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mIsBoundToChrome;
|
2013-11-01 07:31:58 -07:00
|
|
|
bool mUsingXBLScope;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
NS_NewXBLEventHandler(nsXBLPrototypeHandler* aHandler,
|
|
|
|
nsIAtom* aEventType,
|
|
|
|
nsXBLEventHandler** aResult);
|
|
|
|
|
|
|
|
nsresult
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_NewXBLKeyEventHandler(nsIAtom* aEventType, uint8_t aPhase,
|
|
|
|
uint8_t aType, nsXBLKeyEventHandler** aResult);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#endif
|