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/. */
|
1998-06-07 11:55:55 +04:00
|
|
|
|
2014-03-05 04:37:43 +04:00
|
|
|
#ifndef mozilla_dom_Event_h_
|
|
|
|
#define mozilla_dom_Event_h_
|
1998-06-07 11:55:55 +04:00
|
|
|
|
2013-05-30 00:43:41 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-09-25 15:21:22 +04:00
|
|
|
#include "mozilla/BasicEvents.h"
|
1998-06-07 11:55:55 +04:00
|
|
|
#include "nsISupports.h"
|
2003-03-04 04:51:16 +03:00
|
|
|
#include "nsCOMPtr.h"
|
2004-09-04 23:28:46 +04:00
|
|
|
#include "nsPIDOMWindow.h"
|
1998-06-07 11:55:55 +04:00
|
|
|
#include "nsPoint.h"
|
2007-06-26 12:21:42 +04:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2016-11-16 22:10:22 +03:00
|
|
|
#include "mozilla/dom/BindingDeclarations.h"
|
2013-03-09 15:34:29 +04:00
|
|
|
#include "mozilla/dom/EventBinding.h"
|
2018-12-16 12:21:16 +03:00
|
|
|
#include "mozilla/dom/PopupBlocker.h"
|
2013-03-09 15:34:29 +04:00
|
|
|
#include "nsIScriptGlobalObject.h"
|
2013-07-10 13:55:05 +04:00
|
|
|
#include "Units.h"
|
2013-08-28 06:59:14 +04:00
|
|
|
#include "js/TypeDecls.h"
|
2015-02-23 18:03:40 +03:00
|
|
|
#include "nsIGlobalObject.h"
|
2003-03-04 04:51:16 +03:00
|
|
|
|
1998-06-24 01:53:02 +04:00
|
|
|
class nsIContent;
|
2010-04-11 00:10:12 +04:00
|
|
|
class nsPresContext;
|
2018-04-20 19:55:31 +03:00
|
|
|
class PickleIterator;
|
|
|
|
|
|
|
|
namespace IPC {
|
|
|
|
class Message;
|
|
|
|
} // namespace IPC
|
2013-03-09 15:34:29 +04:00
|
|
|
|
2013-08-19 14:15:55 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2014-03-05 04:37:43 +04:00
|
|
|
|
2018-02-09 19:17:08 +03:00
|
|
|
class BeforeUnloadEvent;
|
2018-03-26 21:53:51 +03:00
|
|
|
class CustomEvent;
|
2018-03-13 23:23:59 +03:00
|
|
|
class DragEvent;
|
2013-08-19 14:15:55 +04:00
|
|
|
class EventTarget;
|
2016-02-02 21:03:49 +03:00
|
|
|
class EventMessageAutoOverride;
|
2018-01-27 00:08:59 +03:00
|
|
|
// ExtendableEvent is a ServiceWorker event that is not
|
|
|
|
// autogenerated since it has some extra methods.
|
|
|
|
class ExtendableEvent;
|
2018-02-09 19:17:09 +03:00
|
|
|
class KeyboardEvent;
|
2018-03-20 07:16:05 +03:00
|
|
|
class MouseEvent;
|
2018-02-05 05:31:43 +03:00
|
|
|
class TimeEvent;
|
2018-03-26 21:53:03 +03:00
|
|
|
class UIEvent;
|
2014-10-15 18:48:04 +04:00
|
|
|
class WantsPopupControlCheck;
|
2018-03-19 22:50:37 +03:00
|
|
|
class XULCommandEvent;
|
2015-01-10 14:46:41 +03:00
|
|
|
#define GENERATED_EVENT(EventClass_) class EventClass_;
|
|
|
|
#include "mozilla/dom/GeneratedEventList.h"
|
|
|
|
#undef GENERATED_EVENT
|
2013-08-19 14:15:55 +04:00
|
|
|
|
2018-04-20 19:55:31 +03:00
|
|
|
// IID for Event
|
|
|
|
#define NS_EVENT_IID \
|
2018-11-30 13:46:48 +03:00
|
|
|
{ \
|
2018-04-20 19:55:31 +03:00
|
|
|
0x71139716, 0x4d91, 0x4dee, { \
|
|
|
|
0xba, 0xf9, 0xe3, 0x3b, 0x80, 0xc1, 0x61, 0x61 \
|
|
|
|
} \
|
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-04-20 19:55:31 +03:00
|
|
|
class Event : public nsISupports, public nsWrapperCache {
|
2013-06-20 18:13:52 +04:00
|
|
|
public:
|
2018-04-20 19:55:31 +03:00
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_EVENT_IID)
|
|
|
|
|
2014-03-05 04:37:43 +04:00
|
|
|
Event(EventTarget* aOwner, nsPresContext* aPresContext, WidgetEvent* aEvent);
|
2016-01-30 20:05:36 +03:00
|
|
|
explicit Event(nsPIDOMWindowInner* aWindow);
|
2014-06-23 23:56:07 +04:00
|
|
|
|
|
|
|
protected:
|
2014-03-05 04:37:43 +04:00
|
|
|
virtual ~Event();
|
|
|
|
|
2013-05-08 04:55:21 +04:00
|
|
|
private:
|
2014-03-05 04:37:43 +04:00
|
|
|
void ConstructorInit(EventTarget* aOwner, nsPresContext* aPresContext,
|
|
|
|
WidgetEvent* aEvent);
|
|
|
|
|
1998-07-23 06:55:33 +04:00
|
|
|
public:
|
2007-06-26 12:21:42 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2014-03-05 04:37:43 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Event)
|
2013-03-09 15:34:29 +04:00
|
|
|
|
2015-02-23 18:03:40 +03:00
|
|
|
nsIGlobalObject* GetParentObject() { return mOwner; }
|
2013-03-09 15:34:29 +04:00
|
|
|
|
2018-02-09 08:22:43 +03:00
|
|
|
JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) final;
|
2014-10-18 03:16:58 +04: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 17:13:33 +03:00
|
|
|
virtual JSObject* WrapObjectInternal(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto);
|
1998-06-07 11:55:55 +04:00
|
|
|
|
2015-01-10 14:46:41 +03:00
|
|
|
#define GENERATED_EVENT(EventClass_) \
|
|
|
|
virtual EventClass_* As##EventClass_() { return nullptr; }
|
|
|
|
#include "mozilla/dom/GeneratedEventList.h"
|
|
|
|
#undef GENERATED_EVENT
|
2014-06-04 02:52:36 +04:00
|
|
|
|
2015-04-21 04:47:13 +03:00
|
|
|
// ExtendableEvent is a ServiceWorker event that is not
|
|
|
|
// autogenerated since it has some extra methods.
|
2018-01-27 00:08:59 +03:00
|
|
|
virtual ExtendableEvent* AsExtendableEvent() { return nullptr; }
|
2014-12-19 16:01:53 +03:00
|
|
|
|
2018-02-05 05:31:43 +03:00
|
|
|
virtual TimeEvent* AsTimeEvent() { return nullptr; }
|
|
|
|
|
2018-02-09 19:17:08 +03:00
|
|
|
// BeforeUnloadEvent is not autogenerated because it has a setter.
|
|
|
|
virtual BeforeUnloadEvent* AsBeforeUnloadEvent() { return nullptr; }
|
|
|
|
|
2018-02-09 19:17:09 +03:00
|
|
|
// KeyboardEvent has all sorts of non-autogeneratable bits so far.
|
|
|
|
virtual KeyboardEvent* AsKeyboardEvent() { return nullptr; }
|
|
|
|
|
2018-03-13 23:23:59 +03:00
|
|
|
// DragEvent has a non-autogeneratable initDragEvent.
|
|
|
|
virtual DragEvent* AsDragEvent() { return nullptr; }
|
|
|
|
|
2018-03-19 22:50:37 +03:00
|
|
|
// XULCommandEvent has a non-autogeneratable initCommandEvent.
|
|
|
|
virtual XULCommandEvent* AsXULCommandEvent() { return nullptr; }
|
|
|
|
|
2018-03-20 07:16:05 +03:00
|
|
|
// MouseEvent has a non-autogeneratable initMouseEvent and other
|
|
|
|
// non-autogeneratable methods.
|
|
|
|
virtual MouseEvent* AsMouseEvent() { return nullptr; }
|
|
|
|
|
2018-03-26 21:53:03 +03:00
|
|
|
// UIEvent has a non-autogeneratable initUIEvent.
|
|
|
|
virtual UIEvent* AsUIEvent() { return nullptr; }
|
|
|
|
|
2018-03-26 21:53:51 +03:00
|
|
|
// CustomEvent has a non-autogeneratable initCustomEvent.
|
|
|
|
virtual CustomEvent* AsCustomEvent() { return nullptr; }
|
|
|
|
|
2018-04-20 19:55:31 +03:00
|
|
|
void InitEvent(const nsAString& aEventTypeArg, bool aCanBubble,
|
2018-06-25 19:23:50 +03:00
|
|
|
bool aCancelable) {
|
|
|
|
InitEvent(aEventTypeArg, aCanBubble ? CanBubble::eYes : CanBubble::eNo,
|
|
|
|
aCancelable ? Cancelable::eYes : Cancelable::eNo);
|
|
|
|
}
|
|
|
|
|
|
|
|
void InitEvent(const nsAString& aEventTypeArg, mozilla::CanBubble,
|
2018-09-14 03:05:39 +03:00
|
|
|
mozilla::Cancelable,
|
|
|
|
mozilla::Composed = mozilla::Composed::eDefault);
|
2018-06-25 19:23:50 +03:00
|
|
|
|
2018-04-20 19:55:31 +03:00
|
|
|
void SetTarget(EventTarget* aTarget);
|
|
|
|
virtual void DuplicatePrivateData();
|
|
|
|
bool IsDispatchStopped();
|
|
|
|
WidgetEvent* WidgetEventPtr();
|
|
|
|
virtual void Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType);
|
|
|
|
virtual bool Deserialize(const IPC::Message* aMsg, PickleIterator* aIter);
|
|
|
|
void SetOwner(EventTarget* aOwner);
|
|
|
|
void StopCrossProcessForwarding();
|
|
|
|
void SetTrusted(bool aTrusted);
|
|
|
|
|
2011-12-14 23:53:48 +04:00
|
|
|
void InitPresContextData(nsPresContext* aPresContext);
|
|
|
|
|
2013-03-14 00:02:32 +04:00
|
|
|
// Returns true if the event should be trusted.
|
2014-03-05 04:37:43 +04:00
|
|
|
bool Init(EventTarget* aGlobal);
|
2013-03-14 00:02:32 +04:00
|
|
|
|
2015-08-26 15:56:59 +03:00
|
|
|
static const char* GetEventName(EventMessage aEventType);
|
2014-03-05 04:37:43 +04:00
|
|
|
static CSSIntPoint GetClientCoords(nsPresContext* aPresContext,
|
|
|
|
WidgetEvent* aEvent,
|
|
|
|
LayoutDeviceIntPoint aPoint,
|
|
|
|
CSSIntPoint aDefaultPoint);
|
|
|
|
static CSSIntPoint GetPageCoords(nsPresContext* aPresContext,
|
|
|
|
WidgetEvent* aEvent,
|
|
|
|
LayoutDeviceIntPoint aPoint,
|
|
|
|
CSSIntPoint aDefaultPoint);
|
2015-11-10 19:32:40 +03:00
|
|
|
static CSSIntPoint GetScreenCoords(nsPresContext* aPresContext,
|
|
|
|
WidgetEvent* aEvent,
|
|
|
|
LayoutDeviceIntPoint aPoint);
|
2019-04-13 15:43:57 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
2015-03-13 14:50:10 +03:00
|
|
|
static CSSIntPoint GetOffsetCoords(nsPresContext* aPresContext,
|
|
|
|
WidgetEvent* aEvent,
|
|
|
|
LayoutDeviceIntPoint aPoint,
|
|
|
|
CSSIntPoint aDefaultPoint);
|
2014-03-05 04:37:43 +04:00
|
|
|
|
2017-01-28 17:39:24 +03:00
|
|
|
static already_AddRefed<Event> Constructor(EventTarget* aEventTarget,
|
|
|
|
const nsAString& aType,
|
|
|
|
const EventInit& aParam);
|
|
|
|
|
2014-03-05 04:37:43 +04:00
|
|
|
static already_AddRefed<Event> Constructor(const GlobalObject& aGlobal,
|
|
|
|
const nsAString& aType,
|
2019-09-11 17:35:28 +03:00
|
|
|
const EventInit& aParam);
|
2013-03-09 15:34:29 +04:00
|
|
|
|
2018-04-20 19:55:31 +03:00
|
|
|
void GetType(nsAString& aType) const;
|
2013-03-09 15:34:29 +04:00
|
|
|
|
2014-03-05 04:37:43 +04:00
|
|
|
EventTarget* GetTarget() const;
|
|
|
|
EventTarget* GetCurrentTarget() const;
|
2013-03-09 15:34:29 +04:00
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
// This method returns the document which is associated with the event target.
|
|
|
|
already_AddRefed<Document> GetDocument() const;
|
2018-10-09 14:55:43 +03:00
|
|
|
|
2017-12-18 19:07:36 +03:00
|
|
|
void ComposedPath(nsTArray<RefPtr<EventTarget>>& aPath);
|
|
|
|
|
2013-03-17 11:55:17 +04:00
|
|
|
uint16_t EventPhase() const;
|
2013-03-09 15:34:29 +04:00
|
|
|
|
2018-04-20 19:55:31 +03:00
|
|
|
void StopPropagation();
|
2013-03-09 15:34:29 +04:00
|
|
|
|
2018-04-20 19:55:31 +03:00
|
|
|
void StopImmediatePropagation();
|
2013-03-09 15:34:29 +04:00
|
|
|
|
2013-03-17 11:55:17 +04:00
|
|
|
bool Bubbles() const { return mEvent->mFlags.mBubbles; }
|
2013-03-09 15:34:29 +04:00
|
|
|
|
2013-03-17 11:55:17 +04:00
|
|
|
bool Cancelable() const { return mEvent->mFlags.mCancelable; }
|
2013-03-09 15:34:29 +04:00
|
|
|
|
2016-08-31 06:16:11 +03:00
|
|
|
bool Composed() const { return mEvent->mFlags.mComposed; }
|
|
|
|
|
2016-11-29 05:28:21 +03:00
|
|
|
bool CancelBubble() const { return mEvent->PropagationStopped(); }
|
2018-04-20 19:55:31 +03:00
|
|
|
void SetCancelBubble(bool aCancelBubble) {
|
|
|
|
if (aCancelBubble) {
|
|
|
|
mEvent->StopPropagation();
|
|
|
|
}
|
|
|
|
}
|
2016-11-29 05:28:21 +03:00
|
|
|
|
2018-04-20 19:55:31 +03:00
|
|
|
// For C++ consumers only!
|
|
|
|
void PreventDefault();
|
2013-03-09 15:34:29 +04:00
|
|
|
|
2016-11-16 22:10:22 +03:00
|
|
|
// You MUST NOT call PreventDefault(JSContext*, CallerType) from C++ code. A
|
|
|
|
// call of this method always sets Event.defaultPrevented true for web
|
|
|
|
// contents. If default action handler calls this, web applications see wrong
|
2013-12-08 19:51:16 +04:00
|
|
|
// defaultPrevented value.
|
2016-11-16 22:10:22 +03:00
|
|
|
virtual void PreventDefault(JSContext* aCx, CallerType aCallerType);
|
2013-12-08 19:51:16 +04:00
|
|
|
|
2016-11-16 22:10:22 +03:00
|
|
|
// You MUST NOT call DefaultPrevented(CallerType) from C++ code. This may
|
2013-12-08 19:51:16 +04:00
|
|
|
// return false even if PreventDefault() has been called.
|
2016-11-16 22:10:22 +03:00
|
|
|
// See comments in its implementation for the details.
|
|
|
|
bool DefaultPrevented(CallerType aCallerType) const;
|
2013-12-08 19:51:16 +04:00
|
|
|
|
2016-03-22 10:47:52 +03:00
|
|
|
bool DefaultPrevented() const { return mEvent->DefaultPrevented(); }
|
2013-03-09 15:34:29 +04:00
|
|
|
|
2016-03-15 08:45:23 +03:00
|
|
|
bool DefaultPreventedByChrome() const {
|
|
|
|
return mEvent->mFlags.mDefaultPreventedByChrome;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DefaultPreventedByContent() const {
|
|
|
|
return mEvent->mFlags.mDefaultPreventedByContent;
|
|
|
|
}
|
|
|
|
|
2019-01-22 10:28:55 +03:00
|
|
|
void PreventMultipleActions() {
|
|
|
|
mEvent->mFlags.mMultipleActionsPrevented = true;
|
|
|
|
}
|
|
|
|
|
2013-03-17 11:55:17 +04:00
|
|
|
bool MultipleActionsPrevented() const {
|
2013-03-12 15:28:17 +04:00
|
|
|
return mEvent->mFlags.mMultipleActionsPrevented;
|
|
|
|
}
|
|
|
|
|
2018-08-28 09:28:56 +03:00
|
|
|
bool ReturnValue(CallerType aCallerType) const;
|
|
|
|
|
|
|
|
void SetReturnValue(bool aReturnValue, CallerType aCallerType);
|
|
|
|
|
2016-03-17 10:01:30 +03:00
|
|
|
bool IsTrusted() const { return mEvent->IsTrusted(); }
|
2013-03-09 15:34:29 +04:00
|
|
|
|
2014-01-15 18:28:04 +04:00
|
|
|
bool IsSynthesized() const { return mEvent->mFlags.mIsSynthesizedForTests; }
|
|
|
|
|
2018-07-24 08:51:32 +03:00
|
|
|
bool IsSafeToBeDispatchedAsynchronously() const {
|
|
|
|
// If mEvent is not created by dom::Event nor its subclasses, its lifetime
|
|
|
|
// is not guaranteed. So, only when mEventIsInternal is true, it's safe
|
|
|
|
// to be dispatched asynchronously.
|
|
|
|
return mEventIsInternal;
|
|
|
|
}
|
|
|
|
|
2018-03-09 19:00:23 +03:00
|
|
|
double TimeStamp();
|
2013-03-09 15:34:29 +04:00
|
|
|
|
2014-03-05 04:37:43 +04:00
|
|
|
EventTarget* GetOriginalTarget() const;
|
|
|
|
EventTarget* GetExplicitOriginalTarget() const;
|
2015-01-23 14:55:46 +03:00
|
|
|
EventTarget* GetComposedTarget() const;
|
2013-03-09 15:34:29 +04:00
|
|
|
|
2014-03-21 21:46:15 +04:00
|
|
|
/**
|
|
|
|
* @param aCalledByDefaultHandler Should be true when this is called by
|
|
|
|
* C++ or Chrome. Otherwise, e.g., called
|
|
|
|
* by a call of Event.preventDefault() in
|
|
|
|
* content script, false.
|
|
|
|
*/
|
2017-07-10 11:42:01 +03:00
|
|
|
void PreventDefaultInternal(bool aCalledByDefaultHandler,
|
|
|
|
nsIPrincipal* aPrincipal = nullptr);
|
2014-03-21 21:46:15 +04:00
|
|
|
|
|
|
|
bool IsMainThreadEvent() { return mIsMainThreadEvent; }
|
|
|
|
|
2016-07-29 19:45:52 +03:00
|
|
|
void MarkUninitialized() {
|
|
|
|
mEvent->mMessage = eVoidEvent;
|
|
|
|
mEvent->mSpecifiedEventTypeString.Truncate();
|
|
|
|
mEvent->mSpecifiedEventType = nullptr;
|
|
|
|
}
|
|
|
|
|
2017-03-22 23:44:00 +03:00
|
|
|
/**
|
|
|
|
* For WidgetEvent, return it's type in string.
|
|
|
|
*
|
|
|
|
* @param aEvent is a WidgetEvent to get its type.
|
|
|
|
* @param aType is a string where to return the type.
|
|
|
|
*/
|
|
|
|
static void GetWidgetEventType(WidgetEvent* aEvent, nsAString& aType);
|
|
|
|
|
1998-06-07 11:55:55 +04:00
|
|
|
protected:
|
2004-08-20 22:09:19 +04:00
|
|
|
// Internal helper functions
|
2012-07-18 14:36:08 +04:00
|
|
|
void SetEventType(const nsAString& aEventTypeArg);
|
2010-06-11 15:10:51 +04:00
|
|
|
already_AddRefed<nsIContent> GetTargetFromFrame();
|
2000-05-05 18:47:37 +04:00
|
|
|
|
2016-02-02 21:03:49 +03:00
|
|
|
friend class EventMessageAutoOverride;
|
2018-12-16 12:21:16 +03:00
|
|
|
friend class PopupBlocker;
|
2014-10-15 18:48:04 +04:00
|
|
|
friend class WantsPopupControlCheck;
|
|
|
|
void SetWantsPopupControlCheck(bool aCheck) {
|
|
|
|
mWantsPopupControlCheck = aCheck;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GetWantsPopupControlCheck() {
|
|
|
|
return IsTrusted() && mWantsPopupControlCheck;
|
|
|
|
}
|
|
|
|
|
2016-08-31 06:16:11 +03:00
|
|
|
void SetComposed(bool aComposed) { mEvent->SetComposed(aComposed); }
|
|
|
|
|
2016-12-19 14:36:48 +03:00
|
|
|
already_AddRefed<EventTarget> EnsureWebAccessibleRelatedTarget(
|
|
|
|
EventTarget* aRelatedTarget);
|
|
|
|
|
2013-10-02 07:46:04 +04:00
|
|
|
mozilla::WidgetEvent* mEvent;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsPresContext> mPresContext;
|
2014-03-05 04:37:43 +04:00
|
|
|
nsCOMPtr<EventTarget> mExplicitOriginalTarget;
|
2015-02-23 18:03:40 +03:00
|
|
|
nsCOMPtr<nsIGlobalObject> mOwner;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mEventIsInternal;
|
|
|
|
bool mPrivateDataDuplicated;
|
2013-08-16 14:06:24 +04:00
|
|
|
bool mIsMainThreadEvent;
|
2014-10-15 18:48:04 +04:00
|
|
|
// True when popup control check should rely on event.type, not
|
2015-08-22 04:34:51 +03:00
|
|
|
// WidgetEvent.mMessage.
|
2014-10-15 18:48:04 +04:00
|
|
|
bool mWantsPopupControlCheck;
|
|
|
|
};
|
|
|
|
|
2016-02-02 21:03:49 +03:00
|
|
|
/**
|
|
|
|
* RAII helper-class to override an event's message (i.e. its DOM-exposed
|
|
|
|
* type), for as long as the object is alive. Restores the original
|
|
|
|
* EventMessage when destructed.
|
|
|
|
*
|
|
|
|
* Notable requirements:
|
|
|
|
* - The original & overriding messages must be known (not eUnidentifiedEvent).
|
|
|
|
* - The original & overriding messages must be different.
|
2018-04-20 19:55:30 +03:00
|
|
|
* - The passed-in Event must outlive this RAII helper.
|
2016-02-02 21:03:49 +03:00
|
|
|
*/
|
|
|
|
class MOZ_RAII EventMessageAutoOverride {
|
|
|
|
public:
|
2018-04-20 19:55:30 +03:00
|
|
|
explicit EventMessageAutoOverride(Event* aEvent,
|
2016-02-02 21:03:49 +03:00
|
|
|
EventMessage aOverridingMessage)
|
|
|
|
: mEvent(aEvent), mOrigMessage(mEvent->mEvent->mMessage) {
|
|
|
|
MOZ_ASSERT(aOverridingMessage != mOrigMessage,
|
|
|
|
"Don't use this class if you're not actually overriding");
|
|
|
|
MOZ_ASSERT(aOverridingMessage != eUnidentifiedEvent,
|
|
|
|
"Only use this class with a valid overriding EventMessage");
|
|
|
|
MOZ_ASSERT(mOrigMessage != eUnidentifiedEvent &&
|
2016-04-18 18:10:17 +03:00
|
|
|
mEvent->mEvent->mSpecifiedEventTypeString.IsEmpty(),
|
2016-02-02 21:03:49 +03:00
|
|
|
"Only use this class on events whose overridden type is "
|
|
|
|
"known (so we can restore it properly)");
|
|
|
|
|
|
|
|
mEvent->mEvent->mMessage = aOverridingMessage;
|
|
|
|
}
|
|
|
|
|
|
|
|
~EventMessageAutoOverride() { mEvent->mEvent->mMessage = mOrigMessage; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// Non-owning ref, which should be safe since we're a stack-allocated object
|
|
|
|
// with limited lifetime. Whoever creates us should keep mEvent alive.
|
|
|
|
Event* const MOZ_NON_OWNING_REF mEvent;
|
|
|
|
const EventMessage mOrigMessage;
|
|
|
|
};
|
|
|
|
|
2014-10-15 18:48:04 +04:00
|
|
|
class MOZ_STACK_CLASS WantsPopupControlCheck {
|
|
|
|
public:
|
2018-04-20 19:55:30 +03:00
|
|
|
explicit WantsPopupControlCheck(Event* aEvent) : mEvent(aEvent) {
|
2014-10-15 18:48:04 +04:00
|
|
|
mOriginalWantsPopupControlCheck = mEvent->GetWantsPopupControlCheck();
|
|
|
|
mEvent->SetWantsPopupControlCheck(mEvent->IsTrusted());
|
|
|
|
}
|
|
|
|
|
|
|
|
~WantsPopupControlCheck() {
|
|
|
|
mEvent->SetWantsPopupControlCheck(mOriginalWantsPopupControlCheck);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
Event* mEvent;
|
|
|
|
bool mOriginalWantsPopupControlCheck;
|
1998-06-07 11:55:55 +04:00
|
|
|
};
|
1998-07-23 06:55:33 +04:00
|
|
|
|
2018-04-20 19:55:31 +03:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(Event, NS_EVENT_IID)
|
|
|
|
|
2014-03-05 04:37:43 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2015-08-12 14:39:31 +03:00
|
|
|
already_AddRefed<mozilla::dom::Event> NS_NewDOMEvent(
|
|
|
|
mozilla::dom::EventTarget* aOwner, nsPresContext* aPresContext,
|
|
|
|
mozilla::WidgetEvent* aEvent);
|
|
|
|
|
2014-03-05 04:37:43 +04:00
|
|
|
#endif // mozilla_dom_Event_h_
|