1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "nsIGlobalObject.h"
8 #include "EventCounts.h"
9 #include "mozilla/ErrorResult.h"
10 #include "mozilla/dom/Event.h"
11 #include "mozilla/dom/EventCounts.h"
12 #include "mozilla/dom/PerformanceEventTimingBinding.h"
14 namespace mozilla::dom
{
16 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(EventCounts
, mParent
)
18 static const EventMessage sQualifiedEventType
[36] = {
19 EventMessage::eContextMenu
,
20 EventMessage::eMouseDoubleClick
,
21 EventMessage::eMouseDown
,
22 EventMessage::eMouseEnter
,
23 EventMessage::eMouseLeave
,
24 EventMessage::eMouseOut
,
25 EventMessage::eMouseOver
,
26 EventMessage::eMouseUp
,
27 EventMessage::ePointerAuxClick
,
28 EventMessage::ePointerClick
,
29 EventMessage::ePointerOver
,
30 EventMessage::ePointerEnter
,
31 EventMessage::ePointerDown
,
32 EventMessage::ePointerUp
,
33 EventMessage::ePointerCancel
,
34 EventMessage::ePointerOut
,
35 EventMessage::ePointerLeave
,
36 EventMessage::ePointerGotCapture
,
37 EventMessage::ePointerLostCapture
,
38 EventMessage::eTouchStart
,
39 EventMessage::eTouchEnd
,
40 EventMessage::eTouchCancel
,
41 EventMessage::eKeyDown
,
42 EventMessage::eKeyPress
,
44 EventMessage::eEditorBeforeInput
,
45 EventMessage::eEditorInput
,
46 EventMessage::eCompositionStart
,
47 EventMessage::eCompositionUpdate
,
48 EventMessage::eCompositionEnd
,
49 EventMessage::eDragStart
,
50 EventMessage::eDragEnd
,
51 EventMessage::eDragEnter
,
52 EventMessage::eDragLeave
,
53 EventMessage::eDragOver
,
56 EventCounts::EventCounts(nsISupports
* aParent
) : mParent(aParent
) {
59 for (const EventMessage
& eventType
: sQualifiedEventType
) {
60 EventCounts_Binding::MaplikeHelpers::Set(
61 this, nsDependentString(Event::GetEventName(eventType
)), 0, rv
);
62 if (NS_WARN_IF(rv
.Failed())) {
63 rv
.SuppressException();
65 nsCOMPtr
<nsIGlobalObject
> global
= do_QueryInterface(GetParentObject());
67 MOZ_ASSERT(global
->IsDying());
75 JSObject
* EventCounts::WrapObject(JSContext
* aCx
,
76 JS::Handle
<JSObject
*> aGivenProto
) {
77 return EventCounts_Binding::Wrap(aCx
, this, aGivenProto
);
79 } // namespace mozilla::dom