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 nsDOMEvent_h__
|
|
|
|
#define nsDOMEvent_h__
|
|
|
|
|
|
|
|
#include "nsIDOMEvent.h"
|
|
|
|
#include "nsISupports.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIDOMEventTarget.h"
|
|
|
|
#include "nsPIDOMWindow.h"
|
|
|
|
#include "nsPoint.h"
|
|
|
|
#include "nsGUIEvent.h"
|
2007-06-26 01:21:42 -07:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2010-04-10 13:10:12 -07:00
|
|
|
#include "nsAutoPtr.h"
|
2011-12-14 11:53:48 -08:00
|
|
|
#include "nsIJSNativeInitializer.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
class nsIContent;
|
2010-04-10 13:10:12 -07:00
|
|
|
class nsPresContext;
|
2011-12-15 00:48:09 -08:00
|
|
|
struct JSContext;
|
2012-12-31 12:40:21 -08:00
|
|
|
class JSObject;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
class nsDOMEvent : public nsIDOMEvent,
|
2011-12-14 11:53:48 -08:00
|
|
|
public nsIJSNativeInitializer
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
nsDOMEvent(nsPresContext* aPresContext, nsEvent* aEvent);
|
|
|
|
virtual ~nsDOMEvent();
|
|
|
|
|
2007-06-26 01:21:42 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsDOMEvent, nsIDOMEvent)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// nsIDOMEvent Interface
|
|
|
|
NS_DECL_NSIDOMEVENT
|
|
|
|
|
2011-12-14 11:53:48 -08:00
|
|
|
// nsIJSNativeInitializer
|
|
|
|
NS_IMETHOD Initialize(nsISupports* aOwner, JSContext* aCx, JSObject* aObj,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aArgc, jsval* aArgv);
|
2011-12-14 11:53:48 -08:00
|
|
|
|
2011-12-23 14:13:46 -08:00
|
|
|
virtual nsresult InitFromCtor(const nsAString& aType,
|
|
|
|
JSContext* aCx, jsval* aVal);
|
2011-12-14 11:53:48 -08:00
|
|
|
|
|
|
|
void InitPresContextData(nsPresContext* aPresContext);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
static PopupControlState GetEventPopupControlState(nsEvent *aEvent);
|
|
|
|
|
|
|
|
static void PopupAllowedEventsChanged();
|
|
|
|
|
|
|
|
static void Shutdown();
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
static const char* GetEventName(uint32_t aEventType);
|
2011-12-16 16:24:11 -08:00
|
|
|
static nsIntPoint GetClientCoords(nsPresContext* aPresContext,
|
|
|
|
nsEvent* aEvent,
|
|
|
|
nsIntPoint aPoint,
|
|
|
|
nsIntPoint aDefaultPoint);
|
|
|
|
static nsIntPoint GetPageCoords(nsPresContext* aPresContext,
|
|
|
|
nsEvent* aEvent,
|
|
|
|
nsIntPoint aPoint,
|
|
|
|
nsIntPoint aDefaultPoint);
|
|
|
|
static nsIntPoint GetScreenCoords(nsPresContext* aPresContext,
|
|
|
|
nsEvent* aEvent,
|
|
|
|
nsIntPoint aPoint);
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
|
|
|
|
|
|
|
// Internal helper functions
|
2012-07-18 03:36:08 -07:00
|
|
|
void SetEventType(const nsAString& aEventTypeArg);
|
2010-06-11 04:10:51 -07:00
|
|
|
already_AddRefed<nsIContent> GetTargetFromFrame();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsEvent* mEvent;
|
2010-03-25 06:17:11 -07:00
|
|
|
nsRefPtr<nsPresContext> mPresContext;
|
2012-02-17 06:16:59 -08:00
|
|
|
nsCOMPtr<nsIDOMEventTarget> mExplicitOriginalTarget;
|
2009-10-24 08:06:01 -07:00
|
|
|
nsString mCachedType;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mEventIsInternal;
|
|
|
|
bool mPrivateDataDuplicated;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#define NS_FORWARD_TO_NSDOMEVENT \
|
|
|
|
NS_FORWARD_NSIDOMEVENT(nsDOMEvent::)
|
|
|
|
|
2012-06-10 11:14:30 -07:00
|
|
|
#define NS_FORWARD_NSIDOMEVENT_NO_SERIALIZATION_NO_DUPLICATION(_to) \
|
|
|
|
NS_IMETHOD GetType(nsAString& aType){ return _to GetType(aType); } \
|
|
|
|
NS_IMETHOD GetTarget(nsIDOMEventTarget * *aTarget) { return _to GetTarget(aTarget); } \
|
|
|
|
NS_IMETHOD GetCurrentTarget(nsIDOMEventTarget * *aCurrentTarget) { return _to GetCurrentTarget(aCurrentTarget); } \
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_IMETHOD GetEventPhase(uint16_t *aEventPhase) { return _to GetEventPhase(aEventPhase); } \
|
2012-06-10 11:14:30 -07:00
|
|
|
NS_IMETHOD GetBubbles(bool *aBubbles) { return _to GetBubbles(aBubbles); } \
|
|
|
|
NS_IMETHOD GetCancelable(bool *aCancelable) { return _to GetCancelable(aCancelable); } \
|
|
|
|
NS_IMETHOD GetTimeStamp(DOMTimeStamp *aTimeStamp) { return _to GetTimeStamp(aTimeStamp); } \
|
|
|
|
NS_IMETHOD StopPropagation(void) { return _to StopPropagation(); } \
|
|
|
|
NS_IMETHOD PreventDefault(void) { return _to PreventDefault(); } \
|
|
|
|
NS_IMETHOD InitEvent(const nsAString & eventTypeArg, bool canBubbleArg, bool cancelableArg) { return _to InitEvent(eventTypeArg, canBubbleArg, cancelableArg); } \
|
|
|
|
NS_IMETHOD GetDefaultPrevented(bool *aDefaultPrevented) { return _to GetDefaultPrevented(aDefaultPrevented); } \
|
|
|
|
NS_IMETHOD StopImmediatePropagation(void) { return _to StopImmediatePropagation(); } \
|
2012-08-04 00:44:00 -07:00
|
|
|
NS_IMETHOD GetOriginalTarget(nsIDOMEventTarget** aOriginalTarget) { return _to GetOriginalTarget(aOriginalTarget); } \
|
|
|
|
NS_IMETHOD GetExplicitOriginalTarget(nsIDOMEventTarget** aExplicitOriginalTarget) { return _to GetExplicitOriginalTarget(aExplicitOriginalTarget); } \
|
|
|
|
NS_IMETHOD PreventBubble() { return _to PreventBubble(); } \
|
|
|
|
NS_IMETHOD PreventCapture() { return _to PreventCapture(); } \
|
|
|
|
NS_IMETHOD GetPreventDefault(bool* aRetval) { return _to GetPreventDefault(aRetval); } \
|
|
|
|
NS_IMETHOD GetIsTrusted(bool* aIsTrusted) { return _to GetIsTrusted(aIsTrusted); } \
|
2012-06-10 11:14:30 -07:00
|
|
|
NS_IMETHOD SetTarget(nsIDOMEventTarget *aTarget) { return _to SetTarget(aTarget); } \
|
|
|
|
NS_IMETHOD_(bool) IsDispatchStopped(void) { return _to IsDispatchStopped(); } \
|
|
|
|
NS_IMETHOD_(nsEvent *) GetInternalNSEvent(void) { return _to GetInternalNSEvent(); } \
|
2012-12-22 00:18:08 -08:00
|
|
|
NS_IMETHOD_(void) SetTrusted(bool aTrusted) { _to SetTrusted(aTrusted); }
|
2012-06-10 11:14:30 -07:00
|
|
|
|
|
|
|
#define NS_FORWARD_TO_NSDOMEVENT_NO_SERIALIZATION_NO_DUPLICATION \
|
|
|
|
NS_FORWARD_NSIDOMEVENT_NO_SERIALIZATION_NO_DUPLICATION(nsDOMEvent::)
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif // nsDOMEvent_h__
|