File: MouseEvent.cpp

package info (click to toggle)
firefox 143.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,617,328 kB
  • sloc: cpp: 7,478,492; javascript: 6,417,157; ansic: 3,720,058; python: 1,396,372; xml: 627,523; asm: 438,677; java: 186,156; sh: 63,477; makefile: 19,171; objc: 13,059; perl: 12,983; yacc: 4,583; cs: 3,846; pascal: 3,405; lex: 1,720; ruby: 1,003; exp: 762; php: 436; lisp: 258; awk: 247; sql: 66; sed: 53; csh: 10
file content (492 lines) | stat: -rw-r--r-- 19,502 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */

#include "MouseEvent.h"

#include "mozilla/BasePrincipal.h"
#include "mozilla/EventForwards.h"
#include "mozilla/MouseEvents.h"
#include "mozilla/PresShell.h"
#include "mozilla/StaticPrefs_dom.h"
#include "mozilla/ViewportUtils.h"
#include "nsContentUtils.h"
#include "nsIFrame.h"
#include "nsIScreenManager.h"
#include "nsLayoutUtils.h"

namespace mozilla::dom {

static nsIntPoint DevPixelsToCSSPixels(const LayoutDeviceIntPoint& aPoint,
                                       nsPresContext* aContext) {
  return nsIntPoint(aContext->DevPixelsToIntCSSPixels(aPoint.x),
                    aContext->DevPixelsToIntCSSPixels(aPoint.y));
}

MouseEvent::MouseEvent(EventTarget* aOwner, nsPresContext* aPresContext,
                       WidgetMouseEventBase* aEvent)
    : UIEvent(aOwner, aPresContext,
              aEvent ? aEvent
                     : new WidgetMouseEvent(false, eVoidEvent, nullptr,
                                            WidgetMouseEvent::eReal)) {
  // There's no way to make this class' ctor allocate an WidgetMouseScrollEvent.
  // It's not that important, though, since a scroll event is not a real
  // DOM event.

  WidgetMouseEventBase* const mouseEventBase = mEvent->AsMouseEventBase();
  MOZ_ASSERT(mouseEventBase);
  if (aEvent) {
    mEventIsInternal = false;
  } else {
    mEventIsInternal = true;
    mEvent->mRefPoint = LayoutDeviceIntPoint(0, 0);
    mouseEventBase->mInputSource = MouseEvent_Binding::MOZ_SOURCE_UNKNOWN;
  }

  mUseFractionalCoords = mouseEventBase->DOMEventShouldUseFractionalCoords();
  mWidgetOrScreenRelativePoint = mEvent->mRefPoint;

  if (const WidgetMouseEvent* mouseEvent = mouseEventBase->AsMouseEvent()) {
    MOZ_ASSERT(mouseEvent->mReason != WidgetMouseEvent::eSynthesized,
               "Don't dispatch DOM events from synthesized mouse events");
    mDetail = static_cast<int32_t>(mouseEvent->mClickCount);
  }
}

void MouseEvent::InitMouseEventInternal(
    const nsAString& aType, bool aCanBubble, bool aCancelable,
    nsGlobalWindowInner* aView, int32_t aDetail, double aScreenX,
    double aScreenY, double aClientX, double aClientY, bool aCtrlKey,
    bool aAltKey, bool aShiftKey, bool aMetaKey, uint16_t aButton,
    EventTarget* aRelatedTarget) {
  NS_ENSURE_TRUE_VOID(!mEvent->mFlags.mIsBeingDispatched);

  UIEvent::InitUIEvent(aType, aCanBubble, aCancelable, aView, aDetail);

  switch (mEvent->mClass) {
    case eMouseEventClass:
    case eMouseScrollEventClass:
    case eWheelEventClass:
    case eDragEventClass:
    case ePointerEventClass:
    case eSimpleGestureEventClass: {
      WidgetMouseEventBase* mouseEventBase = mEvent->AsMouseEventBase();
      mouseEventBase->mRelatedTarget = aRelatedTarget;
      mouseEventBase->mButton = aButton;
      mouseEventBase->InitBasicModifiers(aCtrlKey, aAltKey, aShiftKey,
                                         aMetaKey);
      mDefaultClientPoint = CSSDoublePoint(aClientX, aClientY);
      mWidgetOrScreenRelativePoint =
          LayoutDeviceDoublePoint(aScreenX, aScreenY);
      mouseEventBase->mRefPoint =
          LayoutDeviceIntPoint::Floor(mWidgetOrScreenRelativePoint);

      WidgetMouseEvent* mouseEvent = mEvent->AsMouseEvent();
      if (mouseEvent) {
        mouseEvent->mClickCount = aDetail;
      }

      mUseFractionalCoords =
          mouseEventBase->DOMEventShouldUseFractionalCoords();
      if (!mUseFractionalCoords) {
        // If we should not use fractional coordinates for this event, we need
        // to drop the fractional part as defined for the backward compatibility
        // when we treated the input values are integer coordinates.  These
        // values will be exposed as screenX, screenY, clientX and clientY as-is
        // too.  That matches with the Pointer Events spec definitions too.
        // https://w3c.github.io/pointerevents/#event-coordinates
        mDefaultClientPoint = CSSIntPoint::Floor(mDefaultClientPoint);
        mWidgetOrScreenRelativePoint =
            LayoutDeviceIntPoint::Floor(mWidgetOrScreenRelativePoint);
      }
      break;
    }
    default:
      break;
  }
}

void MouseEvent::InitMouseEventInternal(
    const nsAString& aType, bool aCanBubble, bool aCancelable,
    nsGlobalWindowInner* aView, int32_t aDetail, double aScreenX,
    double aScreenY, double aClientX, double aClientY, int16_t aButton,
    EventTarget* aRelatedTarget, const nsAString& aModifiersList) {
  NS_ENSURE_TRUE_VOID(!mEvent->mFlags.mIsBeingDispatched);

  Modifiers modifiers = ComputeModifierState(aModifiersList);

  InitMouseEventInternal(
      aType, aCanBubble, aCancelable, aView, aDetail, aScreenX, aScreenY,
      aClientX, aClientY, (modifiers & MODIFIER_CONTROL) != 0,
      (modifiers & MODIFIER_ALT) != 0, (modifiers & MODIFIER_SHIFT) != 0,
      (modifiers & MODIFIER_META) != 0, aButton, aRelatedTarget);

  switch (mEvent->mClass) {
    case eMouseEventClass:
    case eMouseScrollEventClass:
    case eWheelEventClass:
    case eDragEventClass:
    case ePointerEventClass:
    case eSimpleGestureEventClass:
      mEvent->AsInputEvent()->mModifiers = modifiers;
      return;
    default:
      MOZ_CRASH("There is no space to store the modifiers");
  }
}

void MouseEvent::InitializeExtraMouseEventDictionaryMembers(
    const MouseEventInit& aParam) {
  InitModifiers(aParam);
  mEvent->AsMouseEventBase()->mButtons = aParam.mButtons;
  mMovementPoint.x = aParam.mMovementX;
  mMovementPoint.y = aParam.mMovementY;
}

already_AddRefed<MouseEvent> MouseEvent::Constructor(
    const GlobalObject& aGlobal, const nsAString& aType,
    const MouseEventInit& aParam) {
  nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
  RefPtr<MouseEvent> e = new MouseEvent(t, nullptr, nullptr);
  bool trusted = e->Init(t);
  e->InitMouseEventInternal(
      aType, aParam.mBubbles, aParam.mCancelable, aParam.mView, aParam.mDetail,
      aParam.mScreenX, aParam.mScreenY, aParam.mClientX, aParam.mClientY,
      aParam.mCtrlKey, aParam.mAltKey, aParam.mShiftKey, aParam.mMetaKey,
      aParam.mButton, aParam.mRelatedTarget);
  e->InitializeExtraMouseEventDictionaryMembers(aParam);
  e->SetTrusted(trusted);
  e->SetComposed(aParam.mComposed);
  MOZ_ASSERT(!trusted || !IsPointerEventMessage(e->mEvent->mMessage),
             "Please use PointerEvent constructor!");
  return e.forget();
}

void MouseEvent::InitNSMouseEvent(const nsAString& aType, bool aCanBubble,
                                  bool aCancelable, nsGlobalWindowInner* aView,
                                  int32_t aDetail, int32_t aScreenX,
                                  int32_t aScreenY, int32_t aClientX,
                                  int32_t aClientY, bool aCtrlKey, bool aAltKey,
                                  bool aShiftKey, bool aMetaKey,
                                  uint16_t aButton, EventTarget* aRelatedTarget,
                                  float aPressure, uint16_t aInputSource) {
  NS_ENSURE_TRUE_VOID(!mEvent->mFlags.mIsBeingDispatched);

  InitMouseEventInternal(aType, aCanBubble, aCancelable, aView, aDetail,
                         aScreenX, aScreenY, aClientX, aClientY, aCtrlKey,
                         aAltKey, aShiftKey, aMetaKey, aButton, aRelatedTarget);

  WidgetMouseEventBase* mouseEventBase = mEvent->AsMouseEventBase();
  mouseEventBase->mPressure = aPressure;
  mouseEventBase->mInputSource = aInputSource;
}

void MouseEvent::DuplicatePrivateData() {
  // If this is a event not created from WidgetMouseEventBase or its subclasses
  // (i.e., created by JS), mDefaultClientPoint and mMovementPoint are
  // initialized as expected values.  Therefore, we don't need to recompute it.
  if (!mEventIsInternal) {
    mDefaultClientPoint = ClientPoint();
    mMovementPoint = GetMovementPoint();
  }
  // However, mPagePoint needs to include the scroll position.  Therefore, we
  // need to compute here.
  mPagePoint = PagePoint();

  // mEvent->mRefPoint is computed by UIEvent::DuplicatePrivateData() with
  // the device pixel scale, but if we need to store fractional values to
  // mWidgetRelativePoint, we need to do same thing by ourselves.
  Maybe<const CSSDoublePoint> maybeScreenPoint;
  if (mUseFractionalCoords) {
    maybeScreenPoint.emplace(ScreenPoint(CallerType::System));
  }
  {
    // mPresContext will be cleared by Event::DuplicatePrivateData(), but we
    // need it after a call of it.  So, we need to grab it.
    RefPtr<nsPresContext> presContext = mPresContext.get();
    UIEvent::DuplicatePrivateData();
    mPresContext = presContext.get();
  }
  // Starting from here, mWidgetOrScreenRelativePoint (and
  // WidgetGUIEvent::mWidget) stores a screen point because we're now don't
  // store widget in mEvent.  Therefore, we cannot compute a screen point from
  // widget relative point without the widget.
  if (maybeScreenPoint.isSome()) {
    // ScreenPoint() has already computed it with the scale of mPresContext.
    // Therefore, we don't need to take care of it again.
    MOZ_ASSERT(!mEvent || !mEvent->AsGUIEvent()->mWidget);
    mWidgetOrScreenRelativePoint =
        maybeScreenPoint.ref() * CSSToLayoutDeviceScale(1);
  } else {
    // As mentioned above, mEvent->mRefPoint is already computed by UIEvent, so,
    // do not need to compute the scale.
    mWidgetOrScreenRelativePoint = mEvent->mRefPoint;
  }
}

void MouseEvent::PreventClickEvent() {
  if (WidgetMouseEvent* mouseEvent = mEvent->AsMouseEvent()) {
    mouseEvent->mClickEventPrevented = true;
  }
}

bool MouseEvent::ClickEventPrevented() {
  if (WidgetMouseEvent* mouseEvent = mEvent->AsMouseEvent()) {
    return mouseEvent->mClickEventPrevented;
  }
  return false;
}

already_AddRefed<Event> MouseEvent::GetTriggerEvent() const {
  if (WidgetMouseEvent* mouseEvent = mEvent->AsMouseEvent()) {
    NS_WARNING_ASSERTION(
        mouseEvent->mMessage == eXULPopupShowing,
        "triggerEvent is supported for popupshowing event only");
    RefPtr<Event> e = mouseEvent->mTriggerEvent;
    return e.forget();
  }
  return nullptr;
}

int16_t MouseEvent::Button() {
  switch (mEvent->mClass) {
    case eMouseEventClass:
    case eMouseScrollEventClass:
    case eWheelEventClass:
    case eDragEventClass:
    case ePointerEventClass:
    case eSimpleGestureEventClass:
      return mEvent->AsMouseEventBase()->mButton;
    default:
      NS_WARNING("Tried to get mouse mButton for non-mouse event!");
      return MouseButton::ePrimary;
  }
}

uint16_t MouseEvent::Buttons() const {
  switch (mEvent->mClass) {
    case eMouseEventClass:
    case eMouseScrollEventClass:
    case eWheelEventClass:
    case eDragEventClass:
    case ePointerEventClass:
    case eSimpleGestureEventClass:
      return mEvent->AsMouseEventBase()->mButtons;
    default:
      MOZ_CRASH("Tried to get mouse buttons for non-mouse event!");
  }
}

already_AddRefed<EventTarget> MouseEvent::GetRelatedTarget() {
  nsCOMPtr<EventTarget> relatedTarget;
  switch (mEvent->mClass) {
    case eMouseEventClass:
    case eMouseScrollEventClass:
    case eWheelEventClass:
    case eDragEventClass:
    case ePointerEventClass:
    case eSimpleGestureEventClass:
      relatedTarget = mEvent->AsMouseEventBase()->mRelatedTarget;
      break;
    default:
      break;
  }

  return EnsureWebAccessibleRelatedTarget(relatedTarget);
}

CSSDoublePoint MouseEvent::ScreenPoint(CallerType aCallerType) const {
  if (mEvent->mFlags.mIsPositionless) {
    return {};
  }

  // If this is a trusted event, mWidgetRelativeOffset is a copy of
  // mEvent->mRefPoint, so, the values are integer.
  // If this is an untrusted event, mWidgetRelativeOffset should be floored when
  // it's initialized.
  MOZ_ASSERT_IF(!mUseFractionalCoords,
                mWidgetOrScreenRelativePoint ==
                    LayoutDeviceIntPoint::Floor(mWidgetOrScreenRelativePoint));
  if (nsContentUtils::ShouldResistFingerprinting(
          aCallerType, GetParentObject(), RFPTarget::MouseEventScreenPoint)) {
    // Sanitize to something sort of like client coords, but not quite
    // (defaulting to (0,0) instead of our pre-specified client coords).
    const CSSDoublePoint clientPoint = Event::GetClientCoords(
        mPresContext, mEvent, mWidgetOrScreenRelativePoint,
        CSSDoublePoint{0, 0});
    return mUseFractionalCoords ? clientPoint : RoundedToInt(clientPoint);
  }

  const CSSDoublePoint screenPoint =
      Event::GetScreenCoords(mPresContext, mEvent, mWidgetOrScreenRelativePoint)
          .extract();
  return mUseFractionalCoords ? screenPoint : RoundedToInt(screenPoint);
}

LayoutDeviceIntPoint MouseEvent::ScreenPointLayoutDevicePix() const {
  const CSSDoublePoint point = ScreenPoint(CallerType::System);
  auto scale = mPresContext ? mPresContext->CSSToDevPixelScale()
                            : CSSToLayoutDeviceScale();
  return LayoutDeviceIntPoint::Round(point * scale);
}

DesktopIntPoint MouseEvent::ScreenPointDesktopPix() const {
  const CSSDoublePoint point = ScreenPoint(CallerType::System);
  auto scale =
      mPresContext
          ? mPresContext->CSSToDevPixelScale() /
                mPresContext->DeviceContext()->GetDesktopToDeviceScale()
          : CSSToDesktopScale();
  return DesktopIntPoint::Round(point * scale);
}

already_AddRefed<nsIScreen> MouseEvent::GetScreen() {
  nsCOMPtr<nsIScreenManager> screenMgr =
      do_GetService("@mozilla.org/gfx/screenmanager;1");
  if (!screenMgr) {
    return nullptr;
  }
  return screenMgr->ScreenForRect(
      DesktopIntRect(ScreenPointDesktopPix(), DesktopIntSize(1, 1)));
}

CSSDoublePoint MouseEvent::PagePoint() const {
  if (mEvent->mFlags.mIsPositionless) {
    return {};
  }

  if (mPrivateDataDuplicated) {
    // mPagePoint should be floored when it started to cache the values after
    // the propagation.
    MOZ_ASSERT_IF(!mUseFractionalCoords,
                  mPagePoint == CSSIntPoint::Floor(mPagePoint));
    return mPagePoint;
  }

  // If this is a trusted event, mWidgetRelativeOffset is a copy of
  // mEvent->mRefPoint, so, the values are integer.
  // If this is an untrusted event, mWidgetRelativeOffset should be floored when
  // it's initialized.
  MOZ_ASSERT_IF(!mUseFractionalCoords,
                mWidgetOrScreenRelativePoint ==
                    LayoutDeviceIntPoint::Floor(mWidgetOrScreenRelativePoint));
  // If this is a trusted event, mDefaultClientPoint should be floored when
  // it started to cache the values after the propagation.
  // If this is an untrusted event, mDefaultClientPoint should be floored when
  // it's initialized.
  MOZ_ASSERT_IF(!mUseFractionalCoords,
                mDefaultClientPoint == CSSIntPoint::Floor(mDefaultClientPoint));
  const CSSDoublePoint pagePoint = Event::GetPageCoords(
      mPresContext, mEvent, mWidgetOrScreenRelativePoint, mDefaultClientPoint);
  return mUseFractionalCoords ? pagePoint : RoundedToInt(pagePoint);
}

CSSDoublePoint MouseEvent::ClientPoint() const {
  if (mEvent->mFlags.mIsPositionless) {
    return {};
  }

  // If this is a trusted event, mWidgetRelativeOffset is a copy of
  // mEvent->mRefPoint, so, the values are integer.
  // If this is an untrusted event, mWidgetRelativeOffset should be floored when
  // it's initialized.
  MOZ_ASSERT_IF(!mUseFractionalCoords,
                mWidgetOrScreenRelativePoint ==
                    LayoutDeviceIntPoint::Floor(mWidgetOrScreenRelativePoint));
  // If this is a trusted event, mDefaultClientPoint should be floored when
  // it started to cache the values after the propagation.
  // If this is an untrusted event, mDefaultClientPoint should be floored when
  // it's initialized.
  MOZ_ASSERT_IF(!mUseFractionalCoords,
                mDefaultClientPoint == CSSIntPoint::Floor(mDefaultClientPoint));
  const CSSDoublePoint clientPoint = Event::GetClientCoords(
      mPresContext, mEvent, mWidgetOrScreenRelativePoint, mDefaultClientPoint);
  return mUseFractionalCoords ? clientPoint : RoundedToInt(clientPoint);
}

CSSDoublePoint MouseEvent::OffsetPoint() const {
  if (mEvent->mFlags.mIsPositionless) {
    return {};
  }

  // If this is a trusted event, mWidgetRelativeOffset is a copy of
  // mEvent->mRefPoint, so, the values are integer.
  // If this is an untrusted event, mWidgetRelativeOffset should be floored when
  // it's initialized.
  MOZ_ASSERT_IF(!mUseFractionalCoords,
                mWidgetOrScreenRelativePoint ==
                    LayoutDeviceIntPoint::Floor(mWidgetOrScreenRelativePoint));
  // If this is a trusted event, mDefaultClientPoint should be floored when
  // it started to cache the values after the propagation.
  // If this is an untrusted event, mDefaultClientPoint should be floored when
  // it's initialized.
  MOZ_ASSERT_IF(!mUseFractionalCoords,
                mDefaultClientPoint == CSSIntPoint::Floor(mDefaultClientPoint));
  RefPtr<nsPresContext> presContext(mPresContext);
  const CSSDoublePoint offsetPoint = Event::GetOffsetCoords(
      presContext, mEvent, mWidgetOrScreenRelativePoint, mDefaultClientPoint);
  return mUseFractionalCoords ? offsetPoint : RoundedToInt(offsetPoint);
}

nsIntPoint MouseEvent::GetMovementPoint() const {
  if (mEvent->mFlags.mIsPositionless) {
    return nsIntPoint(0, 0);
  }

  if (mPrivateDataDuplicated || mEventIsInternal) {
    return mMovementPoint;
  }

  if (!mEvent || !mEvent->AsGUIEvent()->mWidget ||
      (mEvent->mMessage != eMouseMove && mEvent->mMessage != ePointerMove)) {
    // Pointer Lock spec defines that movementX/Y must be zero for all mouse
    // events except mousemove.
    return nsIntPoint(0, 0);
  }

  // Calculate the delta between the last screen point and the current one.
  nsIntPoint current = DevPixelsToCSSPixels(mEvent->mRefPoint, mPresContext);
  nsIntPoint last = DevPixelsToCSSPixels(mEvent->mLastRefPoint, mPresContext);
  return current - last;
}

bool MouseEvent::AltKey() { return mEvent->AsInputEvent()->IsAlt(); }

bool MouseEvent::CtrlKey() { return mEvent->AsInputEvent()->IsControl(); }

bool MouseEvent::ShiftKey() { return mEvent->AsInputEvent()->IsShift(); }

bool MouseEvent::MetaKey() { return mEvent->AsInputEvent()->IsMeta(); }

float MouseEvent::MozPressure(CallerType aCallerType) const {
  if (nsContentUtils::ShouldResistFingerprinting(aCallerType, GetParentObject(),
                                                 RFPTarget::PointerEvents)) {
    // Use the spoofed value from PointerEvent::Pressure
    return Buttons() == 0 ? 0.0f : 0.5f;
  }

  return mEvent->AsMouseEventBase()->mPressure;
}

uint16_t MouseEvent::InputSource(CallerType aCallerType) const {
  if (nsContentUtils::ShouldResistFingerprinting(aCallerType, GetParentObject(),
                                                 RFPTarget::PointerEvents)) {
    return MouseEvent_Binding::MOZ_SOURCE_MOUSE;
  }

  return mEvent->AsMouseEventBase()->mInputSource;
}

}  // namespace mozilla::dom

using namespace mozilla;
using namespace mozilla::dom;

already_AddRefed<MouseEvent> NS_NewDOMMouseEvent(EventTarget* aOwner,
                                                 nsPresContext* aPresContext,
                                                 WidgetMouseEvent* aEvent) {
  RefPtr<MouseEvent> it = new MouseEvent(aOwner, aPresContext, aEvent);
  return it.forget();
}