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/. */
|
2004-08-20 22:09:19 +04:00
|
|
|
|
2014-02-28 18:58:43 +04:00
|
|
|
#ifndef mozilla_dom_UIEvent_h_
|
|
|
|
#define mozilla_dom_UIEvent_h_
|
2004-08-20 22:09:19 +04:00
|
|
|
|
2013-05-30 00:43:41 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2014-03-05 04:37:43 +04:00
|
|
|
#include "mozilla/dom/Event.h"
|
2019-01-02 16:26:56 +03:00
|
|
|
#include "mozilla/dom/Nullable.h"
|
2014-03-05 04:37:43 +04:00
|
|
|
#include "mozilla/dom/UIEventBinding.h"
|
2019-01-02 16:26:56 +03:00
|
|
|
#include "mozilla/dom/WindowProxyHolder.h"
|
2014-03-05 04:37:43 +04:00
|
|
|
#include "nsDeviceContext.h"
|
2019-01-02 16:29:18 +03:00
|
|
|
#include "nsDocShell.h"
|
2020-11-23 19:21:38 +03:00
|
|
|
#include "nsIContent.h"
|
2013-09-23 15:55:35 +04:00
|
|
|
#include "nsPresContext.h"
|
2004-08-20 22:09:19 +04:00
|
|
|
|
2013-10-01 01:26:04 +04:00
|
|
|
class nsINode;
|
|
|
|
|
2014-02-28 18:58:43 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2018-03-26 21:53:03 +03:00
|
|
|
class UIEvent : public Event {
|
2004-08-20 22:09:19 +04:00
|
|
|
public:
|
2014-02-28 18:58:43 +04:00
|
|
|
UIEvent(EventTarget* aOwner, nsPresContext* aPresContext,
|
|
|
|
WidgetGUIEvent* aEvent);
|
2004-08-20 22:09:19 +04:00
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2014-03-05 04:37:43 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(UIEvent, Event)
|
2004-08-20 22:09:19 +04:00
|
|
|
|
2018-04-20 19:55:31 +03:00
|
|
|
void DuplicatePrivateData() override;
|
|
|
|
void Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType) override;
|
|
|
|
bool Deserialize(const IPC::Message* aMsg, PickleIterator* aIter) override;
|
2012-04-12 01:55:21 +04:00
|
|
|
|
2014-02-28 18:58:43 +04:00
|
|
|
static already_AddRefed<UIEvent> Constructor(const GlobalObject& aGlobal,
|
|
|
|
const nsAString& aType,
|
2019-09-11 17:35:28 +03:00
|
|
|
const UIEventInit& aParam);
|
2013-03-14 00:02:32 +04:00
|
|
|
|
2018-02-09 19:17:09 +03:00
|
|
|
virtual JSObject* WrapObjectInternal(
|
|
|
|
JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override {
|
2018-06-26 00:20:54 +03:00
|
|
|
return UIEvent_Binding::Wrap(aCx, this, aGivenProto);
|
2013-03-14 00:02:32 +04:00
|
|
|
}
|
|
|
|
|
2018-03-26 21:53:03 +03:00
|
|
|
UIEvent* AsUIEvent() override { return this; }
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
void InitUIEvent(const nsAString& typeArg, bool canBubbleArg,
|
2017-11-07 01:52:14 +03:00
|
|
|
bool cancelableArg, nsGlobalWindowInner* viewArg,
|
2016-01-30 20:05:36 +03:00
|
|
|
int32_t detailArg);
|
|
|
|
|
2019-01-02 16:26:56 +03:00
|
|
|
Nullable<WindowProxyHolder> GetView() const {
|
|
|
|
if (!mView) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2019-01-02 16:27:05 +03:00
|
|
|
return WindowProxyHolder(mView->GetBrowsingContext());
|
2019-01-02 16:26:56 +03:00
|
|
|
}
|
2013-03-14 00:02:32 +04:00
|
|
|
|
2013-05-10 11:13:45 +04:00
|
|
|
int32_t Detail() const { return mDetail; }
|
2013-03-14 00:02:32 +04:00
|
|
|
|
|
|
|
int32_t LayerX() const { return GetLayerPoint().x; }
|
|
|
|
|
|
|
|
int32_t LayerY() const { return GetLayerPoint().y; }
|
|
|
|
|
2018-02-21 00:51:00 +03:00
|
|
|
virtual uint32_t Which(CallerType aCallerType = CallerType::System) {
|
2014-08-04 09:28:48 +04:00
|
|
|
MOZ_ASSERT(mEvent->mClass != eKeyboardEventClass,
|
2013-05-05 11:03:16 +04:00
|
|
|
"Key events should override Which()");
|
2014-08-04 09:28:50 +04:00
|
|
|
MOZ_ASSERT(mEvent->mClass != eMouseEventClass,
|
2013-05-05 11:03:16 +04:00
|
|
|
"Mouse events should override Which()");
|
|
|
|
return 0;
|
2013-03-14 00:02:32 +04:00
|
|
|
}
|
|
|
|
|
2020-01-17 04:23:12 +03:00
|
|
|
/**
|
|
|
|
* GetRangeParent() should be used only by JS. C++ callers should use
|
|
|
|
* GetRangeParentContent() or GetRangeParentContentAndOffset() instead.
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT already_AddRefed<nsINode> GetRangeParent() {
|
|
|
|
return GetRangeParentContent();
|
|
|
|
}
|
|
|
|
MOZ_CAN_RUN_SCRIPT already_AddRefed<nsIContent> GetRangeParentContent() {
|
|
|
|
return GetRangeParentContentAndOffset(nullptr);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* aOffset is optional (i.e., can be nullptr), but when you call this with
|
|
|
|
* nullptr, you should use GetRangeParentContent() instead.
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT already_AddRefed<nsIContent>
|
2020-06-03 06:08:58 +03:00
|
|
|
GetRangeParentContentAndOffset(int32_t* aOffset) const;
|
2020-01-17 04:23:12 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If you also need to compute range parent in C++ code, you should use
|
|
|
|
* GetRangeParentContentAndOffset() instead.
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT int32_t RangeOffset() const;
|
2013-03-14 00:02:32 +04:00
|
|
|
|
2011-08-26 11:43:49 +04:00
|
|
|
protected:
|
2020-02-20 18:56:28 +03:00
|
|
|
~UIEvent() = default;
|
2014-07-09 01:23:17 +04:00
|
|
|
|
2004-08-20 22:09:19 +04:00
|
|
|
// Internal helper functions
|
2012-04-12 01:55:21 +04:00
|
|
|
nsIntPoint GetMovementPoint();
|
2013-05-10 11:13:45 +04:00
|
|
|
nsIntPoint GetLayerPoint() const;
|
2011-08-26 11:43:49 +04:00
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
nsCOMPtr<nsPIDOMWindowOuter> mView;
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t mDetail;
|
2013-07-10 13:55:05 +04:00
|
|
|
CSSIntPoint mClientPoint;
|
2016-04-18 17:09:02 +03:00
|
|
|
// Screenpoint is mEvent->mRefPoint.
|
2009-01-15 06:27:09 +03:00
|
|
|
nsIntPoint mLayerPoint;
|
2013-07-10 13:55:05 +04:00
|
|
|
CSSIntPoint mPagePoint;
|
2012-05-10 02:54:18 +04:00
|
|
|
nsIntPoint mMovementPoint;
|
2012-04-12 01:55:21 +04:00
|
|
|
bool mIsPointerLocked;
|
2013-07-10 13:55:05 +04:00
|
|
|
CSSIntPoint mLastClientPoint;
|
2012-04-25 07:00:01 +04:00
|
|
|
|
|
|
|
static Modifiers ComputeModifierState(const nsAString& aModifiersList);
|
|
|
|
bool GetModifierStateInternal(const nsAString& aKey);
|
2015-04-13 10:16:13 +03:00
|
|
|
void InitModifiers(const EventModifierInit& aParam);
|
2004-08-20 22:09:19 +04:00
|
|
|
};
|
|
|
|
|
2014-02-28 18:58:43 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2015-08-12 14:39:31 +03:00
|
|
|
already_AddRefed<mozilla::dom::UIEvent> NS_NewDOMUIEvent(
|
|
|
|
mozilla::dom::EventTarget* aOwner, nsPresContext* aPresContext,
|
|
|
|
mozilla::WidgetGUIEvent* aEvent);
|
|
|
|
|
2014-02-28 18:58:43 +04:00
|
|
|
#endif // mozilla_dom_UIEvent_h_
|