2015-05-03 12:32:37 -07: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 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
|
|
|
|
2014-02-28 06:58:43 -08:00
|
|
|
#ifndef mozilla_dom_UIEvent_h_
|
|
|
|
#define mozilla_dom_UIEvent_h_
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-05-29 13:43:41 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2014-03-04 16:37:43 -08:00
|
|
|
#include "mozilla/dom/Event.h"
|
|
|
|
#include "mozilla/dom/UIEventBinding.h"
|
|
|
|
#include "nsDeviceContext.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIDOMUIEvent.h"
|
2012-04-11 14:55:21 -07:00
|
|
|
#include "nsLayoutUtils.h"
|
2013-09-23 04:55:35 -07:00
|
|
|
#include "nsPresContext.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-09-30 14:26:04 -07:00
|
|
|
class nsINode;
|
|
|
|
|
2014-02-28 06:58:43 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2014-03-04 16:37:43 -08:00
|
|
|
class UIEvent : public Event,
|
2014-02-28 06:58:43 -08:00
|
|
|
public nsIDOMUIEvent
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
2014-02-28 06:58:43 -08:00
|
|
|
UIEvent(EventTarget* aOwner,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
WidgetGUIEvent* aEvent);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2014-03-04 16:37:43 -08:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(UIEvent, Event)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// nsIDOMUIEvent Interface
|
|
|
|
NS_DECL_NSIDOMUIEVENT
|
2014-02-28 06:58:43 -08:00
|
|
|
|
2014-03-04 16:37:43 -08:00
|
|
|
// Forward to Event
|
|
|
|
NS_FORWARD_TO_EVENT_NO_SERIALIZATION_NO_DUPLICATION
|
2015-03-21 09:28:04 -07:00
|
|
|
NS_IMETHOD DuplicatePrivateData() override;
|
|
|
|
NS_IMETHOD_(void) Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType) override;
|
|
|
|
NS_IMETHOD_(bool) Deserialize(const IPC::Message* aMsg, void** aIter) override;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-04-11 14:55:21 -07:00
|
|
|
|
2014-02-28 06:58:43 -08:00
|
|
|
static already_AddRefed<UIEvent> Constructor(const GlobalObject& aGlobal,
|
|
|
|
const nsAString& aType,
|
|
|
|
const UIEventInit& aParam,
|
|
|
|
ErrorResult& aRv);
|
2013-03-13 13:02:32 -07:00
|
|
|
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual JSObject* WrapObjectInternal(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override
|
2013-03-13 13:02:32 -07:00
|
|
|
{
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 07:13:33 -07:00
|
|
|
return UIEventBinding::Wrap(aCx, this, aGivenProto);
|
2013-03-13 13:02:32 -07:00
|
|
|
}
|
|
|
|
|
2013-05-10 00:13:45 -07:00
|
|
|
nsIDOMWindow* GetView() const
|
2013-03-13 13:02:32 -07:00
|
|
|
{
|
2013-05-10 00:13:45 -07:00
|
|
|
return mView;
|
2013-03-13 13:02:32 -07:00
|
|
|
}
|
|
|
|
|
2013-05-10 00:13:45 -07:00
|
|
|
int32_t Detail() const
|
2013-03-13 13:02:32 -07:00
|
|
|
{
|
|
|
|
return mDetail;
|
|
|
|
}
|
|
|
|
|
2013-05-10 00:13:45 -07:00
|
|
|
int32_t LayerX() const
|
2013-03-13 13:02:32 -07:00
|
|
|
{
|
|
|
|
return GetLayerPoint().x;
|
|
|
|
}
|
|
|
|
|
2013-05-10 00:13:45 -07:00
|
|
|
int32_t LayerY() const
|
2013-03-13 13:02:32 -07:00
|
|
|
{
|
|
|
|
return GetLayerPoint().y;
|
|
|
|
}
|
|
|
|
|
2013-05-10 00:13:45 -07:00
|
|
|
int32_t PageX() const;
|
|
|
|
int32_t PageY() const;
|
2013-03-13 13:02:32 -07:00
|
|
|
|
2013-04-20 16:48:55 -07:00
|
|
|
virtual uint32_t Which()
|
2013-03-13 13:02:32 -07:00
|
|
|
{
|
2014-08-03 22:28:48 -07:00
|
|
|
MOZ_ASSERT(mEvent->mClass != eKeyboardEventClass,
|
2013-05-05 00:03:16 -07:00
|
|
|
"Key events should override Which()");
|
2014-08-03 22:28:50 -07:00
|
|
|
MOZ_ASSERT(mEvent->mClass != eMouseEventClass,
|
2013-05-05 00:03:16 -07:00
|
|
|
"Mouse events should override Which()");
|
|
|
|
return 0;
|
2013-03-13 13:02:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<nsINode> GetRangeParent();
|
|
|
|
|
2013-05-10 00:13:45 -07:00
|
|
|
int32_t RangeOffset() const;
|
2013-03-13 13:02:32 -07:00
|
|
|
|
2013-05-10 00:13:45 -07:00
|
|
|
bool CancelBubble() const
|
2013-03-13 13:02:32 -07:00
|
|
|
{
|
|
|
|
return mEvent->mFlags.mPropagationStopped;
|
|
|
|
}
|
|
|
|
|
2013-05-10 00:13:45 -07:00
|
|
|
bool IsChar() const;
|
2013-03-13 13:02:32 -07:00
|
|
|
|
2011-08-26 00:43:49 -07:00
|
|
|
protected:
|
2014-07-08 14:23:17 -07:00
|
|
|
~UIEvent() {}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Internal helper functions
|
2012-04-11 14:55:21 -07:00
|
|
|
nsIntPoint GetMovementPoint();
|
2013-05-10 00:13:45 -07:00
|
|
|
nsIntPoint GetLayerPoint() const;
|
2011-08-26 00:43:49 -07:00
|
|
|
|
2011-04-23 23:54:25 -07:00
|
|
|
nsCOMPtr<nsIDOMWindow> mView;
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t mDetail;
|
2013-07-10 02:55:05 -07:00
|
|
|
CSSIntPoint mClientPoint;
|
2007-11-12 04:53:06 -08:00
|
|
|
// Screenpoint is mEvent->refPoint.
|
2009-01-14 19:27:09 -08:00
|
|
|
nsIntPoint mLayerPoint;
|
2013-07-10 02:55:05 -07:00
|
|
|
CSSIntPoint mPagePoint;
|
2012-05-09 15:54:18 -07:00
|
|
|
nsIntPoint mMovementPoint;
|
2012-04-11 14:55:21 -07:00
|
|
|
bool mIsPointerLocked;
|
2013-07-10 02:55:05 -07:00
|
|
|
CSSIntPoint mLastClientPoint;
|
2012-04-24 20:00:01 -07:00
|
|
|
|
|
|
|
static Modifiers ComputeModifierState(const nsAString& aModifiersList);
|
|
|
|
bool GetModifierStateInternal(const nsAString& aKey);
|
2015-04-13 00:16:13 -07:00
|
|
|
void InitModifiers(const EventModifierInit& aParam);
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
2014-02-28 06:58:43 -08:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#define NS_FORWARD_TO_UIEVENT \
|
|
|
|
NS_FORWARD_NSIDOMUIEVENT(UIEvent::) \
|
2014-03-04 16:37:43 -08:00
|
|
|
NS_FORWARD_TO_EVENT_NO_SERIALIZATION_NO_DUPLICATION \
|
2015-03-27 11:52:19 -07:00
|
|
|
NS_IMETHOD DuplicatePrivateData() override \
|
2012-06-10 16:44:50 -07:00
|
|
|
{ \
|
2014-02-28 06:58:43 -08:00
|
|
|
return UIEvent::DuplicatePrivateData(); \
|
2012-06-10 16:44:50 -07:00
|
|
|
} \
|
|
|
|
NS_IMETHOD_(void) Serialize(IPC::Message* aMsg, \
|
|
|
|
bool aSerializeInterfaceType) \
|
2015-03-27 11:52:19 -07:00
|
|
|
override \
|
2012-06-10 16:44:50 -07:00
|
|
|
{ \
|
2014-02-28 06:58:43 -08:00
|
|
|
UIEvent::Serialize(aMsg, aSerializeInterfaceType); \
|
2012-06-10 16:44:50 -07:00
|
|
|
} \
|
|
|
|
NS_IMETHOD_(bool) Deserialize(const IPC::Message* aMsg, \
|
2015-03-27 11:52:19 -07:00
|
|
|
void** aIter) override \
|
2012-06-10 16:44:50 -07:00
|
|
|
{ \
|
2014-02-28 06:58:43 -08:00
|
|
|
return UIEvent::Deserialize(aMsg, aIter); \
|
2012-06-10 16:44:50 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2015-08-12 04:39:31 -07:00
|
|
|
already_AddRefed<mozilla::dom::UIEvent>
|
|
|
|
NS_NewDOMUIEvent(mozilla::dom::EventTarget* aOwner,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
mozilla::WidgetGUIEvent* aEvent);
|
|
|
|
|
2014-02-28 06:58:43 -08:00
|
|
|
#endif // mozilla_dom_UIEvent_h_
|