2015-05-03 15:32:37 -04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 12:12:37 +01: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/. */
|
2000-01-26 10:06:30 +00:00
|
|
|
|
|
|
|
#ifndef nsXBLEventHandler_h__
|
|
|
|
#define nsXBLEventHandler_h__
|
|
|
|
|
2013-05-29 13:43:41 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2002-01-09 02:16:17 +00:00
|
|
|
#include "nsCOMPtr.h"
|
2003-09-11 12:25:06 +00:00
|
|
|
#include "nsIDOMEventListener.h"
|
2009-03-20 09:15:35 +01:00
|
|
|
#include "nsTArray.h"
|
2000-01-26 10:06:30 +00:00
|
|
|
|
2017-10-03 09:05:19 +11:00
|
|
|
class nsAtom;
|
2008-04-14 21:16:24 -07:00
|
|
|
class nsIDOMKeyEvent;
|
2003-09-11 12:25:06 +00:00
|
|
|
class nsXBLPrototypeHandler;
|
2000-01-26 10:06:30 +00:00
|
|
|
|
2014-12-12 21:17:37 +09:00
|
|
|
namespace mozilla {
|
|
|
|
struct IgnoreModifierState;
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2003-09-11 12:25:06 +00:00
|
|
|
class nsXBLEventHandler : public nsIDOMEventListener
|
2000-01-26 10:06:30 +00:00
|
|
|
{
|
|
|
|
public:
|
2014-09-01 20:49:25 -04:00
|
|
|
explicit nsXBLEventHandler(nsXBLPrototypeHandler* aHandler);
|
2003-09-11 12:25:06 +00:00
|
|
|
|
2000-01-26 10:06:30 +00:00
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
2003-09-11 12:25:06 +00:00
|
|
|
NS_DECL_NSIDOMEVENTLISTENER
|
2000-06-22 00:36:19 +00:00
|
|
|
|
2003-09-11 12:25:06 +00:00
|
|
|
protected:
|
2014-06-23 15:56:07 -04:00
|
|
|
virtual ~nsXBLEventHandler();
|
2003-09-11 12:25:06 +00:00
|
|
|
nsXBLPrototypeHandler* mProtoHandler;
|
2000-06-22 00:36:19 +00:00
|
|
|
|
2003-09-11 12:25:06 +00:00
|
|
|
private:
|
|
|
|
nsXBLEventHandler();
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool EventMatched(nsIDOMEvent* aEvent)
|
2003-09-11 12:25:06 +00:00
|
|
|
{
|
2011-10-17 10:59:28 -04:00
|
|
|
return true;
|
2000-08-16 08:14:01 +00:00
|
|
|
}
|
2003-09-11 12:25:06 +00:00
|
|
|
};
|
2000-08-16 08:14:01 +00:00
|
|
|
|
2003-09-11 12:25:06 +00:00
|
|
|
class nsXBLMouseEventHandler : public nsXBLEventHandler
|
|
|
|
{
|
|
|
|
public:
|
2014-09-01 20:49:25 -04:00
|
|
|
explicit nsXBLMouseEventHandler(nsXBLPrototypeHandler* aHandler);
|
2003-09-11 12:25:06 +00:00
|
|
|
virtual ~nsXBLMouseEventHandler();
|
2000-01-26 10:06:30 +00:00
|
|
|
|
2003-09-11 12:25:06 +00:00
|
|
|
private:
|
2015-03-21 12:28:04 -04:00
|
|
|
bool EventMatched(nsIDOMEvent* aEvent) override;
|
2003-09-11 12:25:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class nsXBLKeyEventHandler : public nsIDOMEventListener
|
|
|
|
{
|
2017-06-05 18:24:35 -05:00
|
|
|
typedef mozilla::IgnoreModifierState IgnoreModifierState;
|
2014-12-12 21:17:37 +09:00
|
|
|
|
2003-09-11 12:25:06 +00:00
|
|
|
public:
|
2017-10-03 09:05:19 +11:00
|
|
|
nsXBLKeyEventHandler(nsAtom* aEventType, uint8_t aPhase, uint8_t aType);
|
2003-09-11 12:25:06 +00:00
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
2000-08-17 00:09:16 +00:00
|
|
|
|
2003-09-11 12:25:06 +00:00
|
|
|
NS_DECL_NSIDOMEVENTLISTENER
|
2003-02-24 15:41:41 +00:00
|
|
|
|
2003-09-11 12:25:06 +00:00
|
|
|
void AddProtoHandler(nsXBLPrototypeHandler* aProtoHandler)
|
2003-02-24 15:41:41 +00:00
|
|
|
{
|
2003-09-11 12:25:06 +00:00
|
|
|
mProtoHandlers.AppendElement(aProtoHandler);
|
2003-02-24 15:41:41 +00:00
|
|
|
}
|
|
|
|
|
2017-10-03 09:05:19 +11:00
|
|
|
bool Matches(nsAtom* aEventType, uint8_t aPhase, uint8_t aType) const
|
2003-02-24 15:41:41 +00:00
|
|
|
{
|
2003-09-11 12:25:06 +00:00
|
|
|
return (mEventType == aEventType && mPhase == aPhase && mType == aType);
|
2003-02-24 15:41:41 +00:00
|
|
|
}
|
|
|
|
|
2003-09-11 12:25:06 +00:00
|
|
|
void GetEventName(nsAString& aString) const
|
2003-02-24 15:41:41 +00:00
|
|
|
{
|
2003-09-11 12:25:06 +00:00
|
|
|
mEventType->ToString(aString);
|
2003-02-24 15:41:41 +00:00
|
|
|
}
|
2003-09-11 12:25:06 +00:00
|
|
|
|
2012-08-22 11:56:38 -04:00
|
|
|
uint8_t GetPhase() const
|
2003-09-11 12:25:06 +00:00
|
|
|
{
|
|
|
|
return mPhase;
|
|
|
|
}
|
|
|
|
|
2012-08-22 11:56:38 -04:00
|
|
|
uint8_t GetType() const
|
2003-09-11 12:25:06 +00: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 15:31:58 +01:00
|
|
|
|
2014-06-02 18:04:21 -07:00
|
|
|
void SetUsingContentXBLScope(bool aUsingContentXBLScope)
|
2013-11-01 15:31:58 +01:00
|
|
|
{
|
2014-06-02 18:04:21 -07:00
|
|
|
mUsingContentXBLScope = aUsingContentXBLScope;
|
2013-11-01 15:31:58 +01:00
|
|
|
}
|
|
|
|
|
2003-09-11 12:25:06 +00:00
|
|
|
private:
|
|
|
|
nsXBLKeyEventHandler();
|
2014-06-23 15:56:07 -04:00
|
|
|
virtual ~nsXBLKeyEventHandler();
|
|
|
|
|
2012-08-22 11:56:38 -04:00
|
|
|
bool ExecuteMatchedHandlers(nsIDOMKeyEvent* aEvent, uint32_t aCharCode,
|
2014-12-12 21:17:37 +09:00
|
|
|
const IgnoreModifierState& aIgnoreModifierState);
|
2003-09-11 12:25:06 +00:00
|
|
|
|
2009-03-20 09:15:35 +01:00
|
|
|
nsTArray<nsXBLPrototypeHandler*> mProtoHandlers;
|
2017-10-03 09:05:19 +11:00
|
|
|
RefPtr<nsAtom> mEventType;
|
2012-08-22 11:56:38 -04: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;
|
2000-01-26 10:06:30 +00:00
|
|
|
};
|
|
|
|
|
2015-01-30 10:55:11 -08:00
|
|
|
already_AddRefed<nsXBLEventHandler>
|
2003-09-11 12:25:06 +00:00
|
|
|
NS_NewXBLEventHandler(nsXBLPrototypeHandler* aHandler,
|
2017-10-03 09:05:19 +11:00
|
|
|
nsAtom* aEventType);
|
2003-09-11 12:25:06 +00:00
|
|
|
|
2000-01-26 10:06:30 +00:00
|
|
|
#endif
|