2004-08-20 22:09:19 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
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-27 14:51:15 +04:00
|
|
|
#include "mozilla/dom/MouseEvent.h"
|
|
|
|
#include "mozilla/MouseEvents.h"
|
2004-08-20 22:09:19 +04:00
|
|
|
#include "nsContentUtils.h"
|
2014-02-27 14:51:15 +04:00
|
|
|
#include "nsIContent.h"
|
2013-07-03 19:56:26 +04:00
|
|
|
#include "prtime.h"
|
2004-08-20 22:09:19 +04:00
|
|
|
|
2014-02-27 14:51:15 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2012-04-25 07:00:01 +04:00
|
|
|
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::MouseEvent(EventTarget* aOwner,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
WidgetMouseEventBase* aEvent)
|
2014-02-28 18:58:43 +04:00
|
|
|
: UIEvent(aOwner, aPresContext,
|
|
|
|
aEvent ? aEvent : new WidgetMouseEvent(false, 0, nullptr,
|
|
|
|
WidgetMouseEvent::eReal))
|
2004-08-20 22:09:19 +04:00
|
|
|
{
|
2013-10-01 11:23:02 +04:00
|
|
|
// There's no way to make this class' ctor allocate an WidgetMouseScrollEvent.
|
2004-08-20 22:09:19 +04:00
|
|
|
// It's not that important, though, since a scroll event is not a real
|
|
|
|
// DOM event.
|
2013-10-22 12:55:20 +04:00
|
|
|
|
|
|
|
WidgetMouseEvent* mouseEvent = mEvent->AsMouseEvent();
|
2004-08-20 22:09:19 +04:00
|
|
|
if (aEvent) {
|
2011-10-17 18:59:28 +04:00
|
|
|
mEventIsInternal = false;
|
2004-08-20 22:09:19 +04:00
|
|
|
}
|
|
|
|
else {
|
2011-10-17 18:59:28 +04:00
|
|
|
mEventIsInternal = true;
|
2004-08-20 22:09:19 +04:00
|
|
|
mEvent->time = PR_Now();
|
2005-08-23 07:57:07 +04:00
|
|
|
mEvent->refPoint.x = mEvent->refPoint.y = 0;
|
2013-10-22 12:55:20 +04:00
|
|
|
mouseEvent->inputSource = nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
|
2004-08-20 22:09:19 +04:00
|
|
|
}
|
|
|
|
|
2013-10-22 12:55:20 +04:00
|
|
|
if (mouseEvent) {
|
|
|
|
MOZ_ASSERT(mouseEvent->reason != WidgetMouseEvent::eSynthesized,
|
|
|
|
"Don't dispatch DOM events from synthesized mouse events");
|
|
|
|
mDetail = mouseEvent->clickCount;
|
2004-08-20 22:09:19 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-28 18:58:43 +04:00
|
|
|
NS_IMPL_ADDREF_INHERITED(MouseEvent, UIEvent)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(MouseEvent, UIEvent)
|
2004-08-20 22:09:19 +04:00
|
|
|
|
2014-02-27 14:51:15 +04:00
|
|
|
NS_INTERFACE_MAP_BEGIN(MouseEvent)
|
2004-08-20 22:09:19 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMMouseEvent)
|
2014-02-28 18:58:43 +04:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(UIEvent)
|
2004-08-20 22:09:19 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::InitMouseEvent(const nsAString& aType,
|
|
|
|
bool aCanBubble,
|
|
|
|
bool aCancelable,
|
|
|
|
nsIDOMWindow* 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,
|
|
|
|
nsIDOMEventTarget* aRelatedTarget)
|
2004-08-20 22:09:19 +04:00
|
|
|
{
|
2014-02-28 18:58:43 +04:00
|
|
|
nsresult rv =
|
|
|
|
UIEvent::InitUIEvent(aType, aCanBubble, aCancelable, aView, aDetail);
|
2004-08-20 22:09:19 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2008-12-19 17:58:47 +03:00
|
|
|
|
2014-08-04 09:28:46 +04:00
|
|
|
switch(mEvent->mClass) {
|
2014-08-04 09:28:50 +04:00
|
|
|
case eMouseEventClass:
|
2014-08-04 09:28:51 +04:00
|
|
|
case eMouseScrollEventClass:
|
2014-08-04 09:28:51 +04:00
|
|
|
case eWheelEventClass:
|
2014-08-04 09:28:50 +04:00
|
|
|
case eDragEventClass:
|
2014-08-04 09:28:52 +04:00
|
|
|
case ePointerEventClass:
|
2014-08-04 09:28:53 +04:00
|
|
|
case eSimpleGestureEventClass: {
|
2013-10-18 10:10:26 +04:00
|
|
|
WidgetMouseEventBase* mouseEventBase = mEvent->AsMouseEventBase();
|
|
|
|
mouseEventBase->relatedTarget = aRelatedTarget;
|
|
|
|
mouseEventBase->button = aButton;
|
|
|
|
mouseEventBase->InitBasicModifiers(aCtrlKey, aAltKey, aShiftKey, aMetaKey);
|
|
|
|
mClientPoint.x = aClientX;
|
|
|
|
mClientPoint.y = aClientY;
|
|
|
|
mouseEventBase->refPoint.x = aScreenX;
|
|
|
|
mouseEventBase->refPoint.y = aScreenY;
|
|
|
|
|
2013-10-22 12:55:20 +04:00
|
|
|
WidgetMouseEvent* mouseEvent = mEvent->AsMouseEvent();
|
|
|
|
if (mouseEvent) {
|
2013-10-18 10:10:26 +04:00
|
|
|
mouseEvent->clickCount = aDetail;
|
|
|
|
}
|
|
|
|
break;
|
2004-08-20 22:09:19 +04:00
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-04-25 07:00:01 +04:00
|
|
|
nsresult
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::InitMouseEvent(const nsAString& aType,
|
|
|
|
bool aCanBubble,
|
|
|
|
bool aCancelable,
|
|
|
|
nsIDOMWindow* aView,
|
|
|
|
int32_t aDetail,
|
|
|
|
int32_t aScreenX,
|
|
|
|
int32_t aScreenY,
|
|
|
|
int32_t aClientX,
|
|
|
|
int32_t aClientY,
|
|
|
|
int16_t aButton,
|
|
|
|
nsIDOMEventTarget* aRelatedTarget,
|
|
|
|
const nsAString& aModifiersList)
|
2012-04-25 07:00:01 +04:00
|
|
|
{
|
|
|
|
Modifiers modifiers = ComputeModifierState(aModifiersList);
|
|
|
|
|
|
|
|
nsresult rv = InitMouseEvent(aType, aCanBubble, aCancelable, aView,
|
|
|
|
aDetail, aScreenX, aScreenY, aClientX, aClientY,
|
2013-09-14 06:39:41 +04:00
|
|
|
(modifiers & MODIFIER_CONTROL) != 0,
|
|
|
|
(modifiers & MODIFIER_ALT) != 0,
|
|
|
|
(modifiers & MODIFIER_SHIFT) != 0,
|
|
|
|
(modifiers & MODIFIER_META) != 0,
|
2012-04-25 07:00:01 +04:00
|
|
|
aButton, aRelatedTarget);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2014-08-04 09:28:46 +04:00
|
|
|
switch(mEvent->mClass) {
|
2014-08-04 09:28:50 +04:00
|
|
|
case eMouseEventClass:
|
2014-08-04 09:28:51 +04:00
|
|
|
case eMouseScrollEventClass:
|
2014-08-04 09:28:51 +04:00
|
|
|
case eWheelEventClass:
|
2014-08-04 09:28:50 +04:00
|
|
|
case eDragEventClass:
|
2014-08-04 09:28:52 +04:00
|
|
|
case ePointerEventClass:
|
2014-08-04 09:28:53 +04:00
|
|
|
case eSimpleGestureEventClass:
|
2013-10-18 10:10:26 +04:00
|
|
|
mEvent->AsInputEvent()->modifiers = modifiers;
|
2012-04-25 07:00:01 +04:00
|
|
|
return NS_OK;
|
|
|
|
default:
|
2013-06-29 05:38:30 +04:00
|
|
|
MOZ_CRASH("There is no space to store the modifiers");
|
2012-04-25 07:00:01 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-27 14:51:15 +04:00
|
|
|
already_AddRefed<MouseEvent>
|
|
|
|
MouseEvent::Constructor(const GlobalObject& aGlobal,
|
|
|
|
const nsAString& aType,
|
|
|
|
const MouseEventInit& aParam,
|
|
|
|
ErrorResult& aRv)
|
2013-03-14 19:30:47 +04:00
|
|
|
{
|
2014-02-27 14:51:15 +04:00
|
|
|
nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
|
|
|
|
nsRefPtr<MouseEvent> e = new MouseEvent(t, nullptr, nullptr);
|
2013-03-14 19:30:47 +04:00
|
|
|
bool trusted = e->Init(t);
|
|
|
|
e->InitMouseEvent(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,
|
|
|
|
aRv);
|
|
|
|
e->SetTrusted(trusted);
|
|
|
|
|
2014-08-04 09:28:46 +04:00
|
|
|
switch (e->mEvent->mClass) {
|
2014-08-04 09:28:50 +04:00
|
|
|
case eMouseEventClass:
|
2014-08-04 09:28:51 +04:00
|
|
|
case eMouseScrollEventClass:
|
2014-08-04 09:28:51 +04:00
|
|
|
case eWheelEventClass:
|
2014-08-04 09:28:50 +04:00
|
|
|
case eDragEventClass:
|
2014-08-04 09:28:52 +04:00
|
|
|
case ePointerEventClass:
|
2014-08-04 09:28:53 +04:00
|
|
|
case eSimpleGestureEventClass:
|
2013-10-18 10:10:26 +04:00
|
|
|
e->mEvent->AsMouseEventBase()->buttons = aParam.mButtons;
|
2013-03-14 19:30:47 +04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return e.forget();
|
|
|
|
}
|
|
|
|
|
2008-12-12 02:55:15 +03:00
|
|
|
NS_IMETHODIMP
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::InitNSMouseEvent(const nsAString& aType,
|
|
|
|
bool aCanBubble,
|
|
|
|
bool aCancelable,
|
|
|
|
nsIDOMWindow* 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,
|
|
|
|
nsIDOMEventTarget* aRelatedTarget,
|
|
|
|
float aPressure,
|
|
|
|
uint16_t aInputSource)
|
|
|
|
{
|
|
|
|
nsresult rv = MouseEvent::InitMouseEvent(aType, aCanBubble, aCancelable,
|
|
|
|
aView, aDetail, aScreenX, aScreenY,
|
|
|
|
aClientX, aClientY,
|
|
|
|
aCtrlKey, aAltKey, aShiftKey,
|
|
|
|
aMetaKey, aButton, aRelatedTarget);
|
2008-12-12 02:55:15 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2013-10-18 10:10:26 +04:00
|
|
|
WidgetMouseEventBase* mouseEventBase = mEvent->AsMouseEventBase();
|
|
|
|
mouseEventBase->pressure = aPressure;
|
|
|
|
mouseEventBase->inputSource = aInputSource;
|
2008-12-12 02:55:15 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2004-08-20 22:09:19 +04:00
|
|
|
NS_IMETHODIMP
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::GetButton(int16_t* aButton)
|
2004-08-20 22:09:19 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aButton);
|
2013-03-14 19:30:47 +04:00
|
|
|
*aButton = Button();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-02-20 22:38:13 +04:00
|
|
|
int16_t
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::Button()
|
2013-03-14 19:30:47 +04:00
|
|
|
{
|
2014-08-04 09:28:46 +04:00
|
|
|
switch(mEvent->mClass) {
|
2014-08-04 09:28:50 +04:00
|
|
|
case eMouseEventClass:
|
2014-08-04 09:28:51 +04:00
|
|
|
case eMouseScrollEventClass:
|
2014-08-04 09:28:51 +04:00
|
|
|
case eWheelEventClass:
|
2014-08-04 09:28:50 +04:00
|
|
|
case eDragEventClass:
|
2014-08-04 09:28:52 +04:00
|
|
|
case ePointerEventClass:
|
2014-08-04 09:28:53 +04:00
|
|
|
case eSimpleGestureEventClass:
|
2013-10-18 10:10:26 +04:00
|
|
|
return mEvent->AsMouseEventBase()->button;
|
2004-08-20 22:09:19 +04:00
|
|
|
default:
|
2006-11-17 00:35:39 +03:00
|
|
|
NS_WARNING("Tried to get mouse button for non-mouse event!");
|
2013-10-02 10:38:27 +04:00
|
|
|
return WidgetMouseEvent::eLeftButton;
|
2004-08-20 22:09:19 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-25 07:00:01 +04:00
|
|
|
NS_IMETHODIMP
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::GetButtons(uint16_t* aButtons)
|
2012-04-25 07:00:01 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aButtons);
|
2013-03-14 19:30:47 +04:00
|
|
|
*aButtons = Buttons();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint16_t
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::Buttons()
|
2013-03-14 19:30:47 +04:00
|
|
|
{
|
2014-08-04 09:28:46 +04:00
|
|
|
switch(mEvent->mClass) {
|
2014-08-04 09:28:50 +04:00
|
|
|
case eMouseEventClass:
|
2014-08-04 09:28:51 +04:00
|
|
|
case eMouseScrollEventClass:
|
2014-08-04 09:28:51 +04:00
|
|
|
case eWheelEventClass:
|
2014-08-04 09:28:50 +04:00
|
|
|
case eDragEventClass:
|
2014-08-04 09:28:52 +04:00
|
|
|
case ePointerEventClass:
|
2014-08-04 09:28:53 +04:00
|
|
|
case eSimpleGestureEventClass:
|
2013-10-18 10:10:26 +04:00
|
|
|
return mEvent->AsMouseEventBase()->buttons;
|
2012-04-25 07:00:01 +04:00
|
|
|
default:
|
2013-06-29 05:38:30 +04:00
|
|
|
MOZ_CRASH("Tried to get mouse buttons for non-mouse event!");
|
2012-04-25 07:00:01 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-20 22:09:19 +04:00
|
|
|
NS_IMETHODIMP
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::GetRelatedTarget(nsIDOMEventTarget** aRelatedTarget)
|
2004-08-20 22:09:19 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aRelatedTarget);
|
2014-03-15 23:00:15 +04:00
|
|
|
*aRelatedTarget = GetRelatedTarget().take();
|
2013-03-14 19:30:47 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-02-27 14:51:15 +04:00
|
|
|
already_AddRefed<EventTarget>
|
|
|
|
MouseEvent::GetRelatedTarget()
|
2013-03-14 19:30:47 +04:00
|
|
|
{
|
2014-02-27 14:51:15 +04:00
|
|
|
nsCOMPtr<EventTarget> relatedTarget;
|
2014-08-04 09:28:46 +04:00
|
|
|
switch(mEvent->mClass) {
|
2014-08-04 09:28:50 +04:00
|
|
|
case eMouseEventClass:
|
2014-08-04 09:28:51 +04:00
|
|
|
case eMouseScrollEventClass:
|
2014-08-04 09:28:51 +04:00
|
|
|
case eWheelEventClass:
|
2014-08-04 09:28:50 +04:00
|
|
|
case eDragEventClass:
|
2014-08-04 09:28:52 +04:00
|
|
|
case ePointerEventClass:
|
2014-08-04 09:28:53 +04:00
|
|
|
case eSimpleGestureEventClass:
|
2013-10-18 10:10:26 +04:00
|
|
|
relatedTarget =
|
|
|
|
do_QueryInterface(mEvent->AsMouseEventBase()->relatedTarget);
|
2006-07-13 11:51:54 +04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2004-08-20 22:09:19 +04:00
|
|
|
}
|
|
|
|
|
2006-07-13 11:51:54 +04:00
|
|
|
if (relatedTarget) {
|
2009-06-28 23:46:52 +04:00
|
|
|
nsCOMPtr<nsIContent> content = do_QueryInterface(relatedTarget);
|
2014-08-27 07:19:56 +04:00
|
|
|
nsCOMPtr<nsIContent> currentTarget = do_QueryInterface(mEvent->currentTarget);
|
|
|
|
|
|
|
|
nsIContent* shadowRelatedTarget = GetShadowRelatedTarget(currentTarget, content);
|
|
|
|
if (shadowRelatedTarget) {
|
|
|
|
relatedTarget = shadowRelatedTarget;
|
|
|
|
}
|
|
|
|
|
2012-10-10 23:04:42 +04:00
|
|
|
if (content && content->ChromeOnlyAccess() &&
|
2009-06-28 23:46:52 +04:00
|
|
|
!nsContentUtils::CanAccessNativeAnon()) {
|
2013-03-14 19:30:47 +04:00
|
|
|
relatedTarget = do_QueryInterface(content->FindFirstNonChromeOnlyAccessContent());
|
2009-06-28 23:46:52 +04:00
|
|
|
}
|
|
|
|
|
2013-03-14 19:30:47 +04:00
|
|
|
if (relatedTarget) {
|
|
|
|
relatedTarget = relatedTarget->GetTargetForDOMEvent();
|
|
|
|
}
|
|
|
|
return relatedTarget.forget();
|
2004-08-20 22:09:19 +04:00
|
|
|
}
|
2013-03-14 19:30:47 +04:00
|
|
|
return nullptr;
|
2004-08-20 22:09:19 +04:00
|
|
|
}
|
|
|
|
|
2014-04-27 02:32:00 +04:00
|
|
|
void
|
|
|
|
MouseEvent::GetRegion(nsAString& aRegion)
|
|
|
|
{
|
|
|
|
SetDOMStringToNull(aRegion);
|
2014-05-20 08:54:00 +04:00
|
|
|
WidgetMouseEventBase* mouseEventBase = mEvent->AsMouseEventBase();
|
|
|
|
if (mouseEventBase) {
|
|
|
|
aRegion = mouseEventBase->region;
|
|
|
|
}
|
2014-04-27 02:32:00 +04:00
|
|
|
}
|
|
|
|
|
2012-04-12 01:55:21 +04:00
|
|
|
NS_IMETHODIMP
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::GetMozMovementX(int32_t* aMovementX)
|
2012-04-12 01:55:21 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aMovementX);
|
2013-03-14 19:30:47 +04:00
|
|
|
*aMovementX = MozMovementX();
|
2012-04-12 01:55:21 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::GetMozMovementY(int32_t* aMovementY)
|
2012-04-12 01:55:21 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aMovementY);
|
2013-03-14 19:30:47 +04:00
|
|
|
*aMovementY = MozMovementY();
|
2012-04-12 01:55:21 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-02-27 14:51:15 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
MouseEvent::GetScreenX(int32_t* aScreenX)
|
2004-08-20 22:09:19 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aScreenX);
|
2013-03-14 19:30:47 +04:00
|
|
|
*aScreenX = ScreenX();
|
2004-08-20 22:09:19 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-03-14 19:30:47 +04:00
|
|
|
int32_t
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::ScreenX()
|
2013-03-14 19:30:47 +04:00
|
|
|
{
|
2014-03-05 04:37:43 +04:00
|
|
|
return Event::GetScreenCoords(mPresContext, mEvent, mEvent->refPoint).x;
|
2013-03-14 19:30:47 +04:00
|
|
|
}
|
|
|
|
|
2004-08-20 22:09:19 +04:00
|
|
|
NS_IMETHODIMP
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::GetScreenY(int32_t* aScreenY)
|
2004-08-20 22:09:19 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aScreenY);
|
2013-03-14 19:30:47 +04:00
|
|
|
*aScreenY = ScreenY();
|
2004-08-20 22:09:19 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-03-14 19:30:47 +04:00
|
|
|
int32_t
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::ScreenY()
|
2013-03-14 19:30:47 +04:00
|
|
|
{
|
2014-03-05 04:37:43 +04:00
|
|
|
return Event::GetScreenCoords(mPresContext, mEvent, mEvent->refPoint).y;
|
2013-03-14 19:30:47 +04:00
|
|
|
}
|
|
|
|
|
2004-08-20 22:09:19 +04:00
|
|
|
|
2014-02-27 14:51:15 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
MouseEvent::GetClientX(int32_t* aClientX)
|
2004-08-20 22:09:19 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aClientX);
|
2013-03-14 19:30:47 +04:00
|
|
|
*aClientX = ClientX();
|
2004-08-20 22:09:19 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-03-14 19:30:47 +04:00
|
|
|
int32_t
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::ClientX()
|
2013-03-14 19:30:47 +04:00
|
|
|
{
|
2014-03-05 04:37:43 +04:00
|
|
|
return Event::GetClientCoords(mPresContext, mEvent, mEvent->refPoint,
|
|
|
|
mClientPoint).x;
|
2013-03-14 19:30:47 +04:00
|
|
|
}
|
|
|
|
|
2004-08-20 22:09:19 +04:00
|
|
|
NS_IMETHODIMP
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::GetClientY(int32_t* aClientY)
|
2004-08-20 22:09:19 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aClientY);
|
2013-03-14 19:30:47 +04:00
|
|
|
*aClientY = ClientY();
|
2004-08-20 22:09:19 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-03-14 19:30:47 +04:00
|
|
|
int32_t
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::ClientY()
|
2013-03-14 19:30:47 +04:00
|
|
|
{
|
2014-03-05 04:37:43 +04:00
|
|
|
return Event::GetClientCoords(mPresContext, mEvent, mEvent->refPoint,
|
|
|
|
mClientPoint).y;
|
2013-03-14 19:30:47 +04:00
|
|
|
}
|
|
|
|
|
2013-10-18 10:10:26 +04:00
|
|
|
bool
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::AltKey()
|
2013-10-18 10:10:26 +04:00
|
|
|
{
|
|
|
|
return mEvent->AsInputEvent()->IsAlt();
|
|
|
|
}
|
|
|
|
|
2004-08-20 22:09:19 +04:00
|
|
|
NS_IMETHODIMP
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::GetAltKey(bool* aIsDown)
|
2004-08-20 22:09:19 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aIsDown);
|
2013-03-14 19:30:47 +04:00
|
|
|
*aIsDown = AltKey();
|
2004-08-20 22:09:19 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-10-18 10:10:26 +04:00
|
|
|
bool
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::CtrlKey()
|
2013-10-18 10:10:26 +04:00
|
|
|
{
|
|
|
|
return mEvent->AsInputEvent()->IsControl();
|
|
|
|
}
|
|
|
|
|
2004-08-20 22:09:19 +04:00
|
|
|
NS_IMETHODIMP
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::GetCtrlKey(bool* aIsDown)
|
2004-08-20 22:09:19 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aIsDown);
|
2013-03-14 19:30:47 +04:00
|
|
|
*aIsDown = CtrlKey();
|
2004-08-20 22:09:19 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-10-18 10:10:26 +04:00
|
|
|
bool
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::ShiftKey()
|
2013-10-18 10:10:26 +04:00
|
|
|
{
|
|
|
|
return mEvent->AsInputEvent()->IsShift();
|
|
|
|
}
|
|
|
|
|
2004-08-20 22:09:19 +04:00
|
|
|
NS_IMETHODIMP
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::GetShiftKey(bool* aIsDown)
|
2004-08-20 22:09:19 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aIsDown);
|
2013-03-14 19:30:47 +04:00
|
|
|
*aIsDown = ShiftKey();
|
2004-08-20 22:09:19 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-10-18 10:10:26 +04:00
|
|
|
bool
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::MetaKey()
|
2013-10-18 10:10:26 +04:00
|
|
|
{
|
|
|
|
return mEvent->AsInputEvent()->IsMeta();
|
|
|
|
}
|
|
|
|
|
2004-08-20 22:09:19 +04:00
|
|
|
NS_IMETHODIMP
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::GetMetaKey(bool* aIsDown)
|
2004-08-20 22:09:19 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aIsDown);
|
2013-03-14 19:30:47 +04:00
|
|
|
*aIsDown = MetaKey();
|
2004-08-20 22:09:19 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-04-25 07:00:02 +04:00
|
|
|
NS_IMETHODIMP
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::GetModifierState(const nsAString& aKey,
|
2012-04-25 07:00:02 +04:00
|
|
|
bool* aState)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aState);
|
|
|
|
|
2013-03-14 19:30:47 +04:00
|
|
|
*aState = GetModifierState(aKey);
|
2012-04-25 07:00:02 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-10-18 10:10:26 +04:00
|
|
|
float
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::MozPressure() const
|
2013-10-18 10:10:26 +04:00
|
|
|
{
|
|
|
|
return mEvent->AsMouseEventBase()->pressure;
|
|
|
|
}
|
|
|
|
|
2008-12-12 02:55:15 +03:00
|
|
|
NS_IMETHODIMP
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::GetMozPressure(float* aPressure)
|
2008-12-12 02:55:15 +03:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aPressure);
|
2013-03-14 19:30:47 +04:00
|
|
|
*aPressure = MozPressure();
|
2008-12-12 02:55:15 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-11-24 17:33:06 +03:00
|
|
|
bool
|
|
|
|
MouseEvent::HitCluster() const
|
|
|
|
{
|
|
|
|
return mEvent->AsMouseEventBase()->hitCluster;
|
|
|
|
}
|
|
|
|
|
2013-10-18 10:10:26 +04:00
|
|
|
uint16_t
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::MozInputSource() const
|
2013-10-18 10:10:26 +04:00
|
|
|
{
|
|
|
|
return mEvent->AsMouseEventBase()->inputSource;
|
|
|
|
}
|
|
|
|
|
2010-04-06 16:59:24 +04:00
|
|
|
NS_IMETHODIMP
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent::GetMozInputSource(uint16_t* aInputSource)
|
2010-04-06 16:59:24 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aInputSource);
|
2013-03-14 19:30:47 +04:00
|
|
|
*aInputSource = MozInputSource();
|
2010-04-06 16:59:24 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-02-27 14:51:15 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::dom;
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
NS_NewDOMMouseEvent(nsIDOMEvent** aInstancePtrResult,
|
|
|
|
EventTarget* aOwner,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
WidgetMouseEvent* aEvent)
|
2004-08-20 22:09:19 +04:00
|
|
|
{
|
2014-02-27 14:51:15 +04:00
|
|
|
MouseEvent* it = new MouseEvent(aOwner, aPresContext, aEvent);
|
2014-03-18 00:00:11 +04:00
|
|
|
NS_ADDREF(it);
|
|
|
|
*aInstancePtrResult = static_cast<Event*>(it);
|
|
|
|
return NS_OK;
|
2004-08-20 22:09:19 +04:00
|
|
|
}
|