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