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;
|
|
|
|
|
2014-12-12 04:17:37 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
struct IgnoreModifierState;
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsXBLEventHandler : public nsIDOMEventListener
|
|
|
|
{
|
|
|
|
public:
|
2014-09-01 17:49:25 -07:00
|
|
|
explicit nsXBLEventHandler(nsXBLPrototypeHandler* aHandler);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
NS_DECL_NSIDOMEVENTLISTENER
|
|
|
|
|
|
|
|
protected:
|
2014-06-23 12:56:07 -07:00
|
|
|
virtual ~nsXBLEventHandler();
|
2007-03-22 10:30:00 -07:00
|
|
|
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:
|
2014-09-01 17:49:25 -07:00
|
|
|
explicit nsXBLMouseEventHandler(nsXBLPrototypeHandler* aHandler);
|
2007-03-22 10:30:00 -07:00
|
|
|
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
|
|
|
|
{
|
2014-12-12 04:17:37 -08:00
|
|
|
typedef mozilla::dom::IgnoreModifierState IgnoreModifierState;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
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
|
|
|
|
|
|
|
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
|
|
|
|
2014-06-02 18:04:21 -07:00
|
|
|
void SetUsingContentXBLScope(bool aUsingContentXBLScope)
|
2013-11-01 07:31:58 -07:00
|
|
|
{
|
2014-06-02 18:04:21 -07:00
|
|
|
mUsingContentXBLScope = aUsingContentXBLScope;
|
2013-11-01 07:31:58 -07:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
private:
|
|
|
|
nsXBLKeyEventHandler();
|
2014-06-23 12:56:07 -07:00
|
|
|
virtual ~nsXBLKeyEventHandler();
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
bool ExecuteMatchedHandlers(nsIDOMKeyEvent* aEvent, uint32_t aCharCode,
|
2014-12-12 04:17:37 -08:00
|
|
|
const IgnoreModifierState& aIgnoreModifierState);
|
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;
|
2014-06-02 18:04:21 -07:00
|
|
|
bool mUsingContentXBLScope;
|
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
|