Bug 1472338: part 2) Change `clipboard.readText()` to read from the clipboard asynchr...
[gecko.git] / dom / performance / EventCounts.cpp
blobe9baee708242a0b221250693449914d99f547247
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 NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(EventCounts, AddRef)
19 NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(EventCounts, Release)
21 static const EventMessage sQualifiedEventType[36] = {
22 EventMessage::eMouseAuxClick,
23 EventMessage::eMouseClick,
24 EventMessage::eContextMenu,
25 EventMessage::eMouseDoubleClick,
26 EventMessage::eMouseDown,
27 EventMessage::eMouseEnter,
28 EventMessage::eMouseLeave,
29 EventMessage::eMouseOut,
30 EventMessage::eMouseOver,
31 EventMessage::eMouseUp,
32 EventMessage::ePointerOver,
33 EventMessage::ePointerEnter,
34 EventMessage::ePointerDown,
35 EventMessage::ePointerUp,
36 EventMessage::ePointerCancel,
37 EventMessage::ePointerOut,
38 EventMessage::ePointerLeave,
39 EventMessage::ePointerGotCapture,
40 EventMessage::ePointerLostCapture,
41 EventMessage::eTouchStart,
42 EventMessage::eTouchEnd,
43 EventMessage::eTouchCancel,
44 EventMessage::eKeyDown,
45 EventMessage::eKeyPress,
46 EventMessage::eKeyUp,
47 EventMessage::eEditorBeforeInput,
48 EventMessage::eEditorInput,
49 EventMessage::eCompositionStart,
50 EventMessage::eCompositionUpdate,
51 EventMessage::eCompositionEnd,
52 EventMessage::eDragStart,
53 EventMessage::eDragEnd,
54 EventMessage::eDragEnter,
55 EventMessage::eDragLeave,
56 EventMessage::eDragOver,
57 EventMessage::eDrop};
59 EventCounts::EventCounts(nsISupports* aParent) : mParent(aParent) {
60 ErrorResult rv;
62 for (const EventMessage& eventType : sQualifiedEventType) {
63 EventCounts_Binding::MaplikeHelpers::Set(
64 this, nsDependentString(Event::GetEventName(eventType)), 0, rv);
65 if (NS_WARN_IF(rv.Failed())) {
66 rv.SuppressException();
67 #ifdef DEBUG
68 nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetParentObject());
69 if (global) {
70 MOZ_ASSERT(global->IsDying());
72 #endif
73 return;
78 JSObject* EventCounts::WrapObject(JSContext* aCx,
79 JS::Handle<JSObject*> aGivenProto) {
80 return EventCounts_Binding::Wrap(aCx, this, aGivenProto);
82 } // namespace mozilla::dom