2011-04-23 23:54:25 -07:00
|
|
|
/* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
|
2012-05-21 04:12:37 -07: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/. */
|
2011-04-26 05:30:17 -07:00
|
|
|
|
|
|
|
#include "nsDOMTouchEvent.h"
|
|
|
|
#include "nsGUIEvent.h"
|
|
|
|
#include "nsDOMClassInfoID.h"
|
|
|
|
#include "nsIClassInfo.h"
|
|
|
|
#include "nsIXPCScriptable.h"
|
|
|
|
#include "nsContentUtils.h"
|
2011-05-24 23:31:59 -07:00
|
|
|
#include "mozilla/Preferences.h"
|
2011-12-16 16:24:11 -08:00
|
|
|
#include "nsPresContext.h"
|
2011-05-24 23:31:59 -07:00
|
|
|
|
|
|
|
using namespace mozilla;
|
2011-04-26 05:30:17 -07:00
|
|
|
|
2011-04-27 04:58:25 -07:00
|
|
|
DOMCI_DATA(Touch, nsDOMTouch)
|
2011-04-26 05:30:17 -07:00
|
|
|
|
2011-04-27 04:58:25 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_1(nsDOMTouch, mTarget)
|
2011-04-26 05:30:17 -07:00
|
|
|
|
2011-04-27 04:58:25 -07:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDOMTouch)
|
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMTouch)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMTouch)
|
|
|
|
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(Touch)
|
2011-04-26 05:30:17 -07:00
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2011-04-27 04:58:25 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMTouch)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMTouch)
|
2011-04-26 05:30:17 -07:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
nsDOMTouch::GetIdentifier(int32_t* aIdentifier)
|
2011-04-26 05:30:17 -07:00
|
|
|
{
|
|
|
|
*aIdentifier = mIdentifier;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-04-27 04:58:25 -07:00
|
|
|
nsDOMTouch::GetTarget(nsIDOMEventTarget** aTarget)
|
2011-04-26 05:30:17 -07:00
|
|
|
{
|
2012-10-10 12:13:59 -07:00
|
|
|
nsCOMPtr<nsIContent> content = do_QueryInterface(mTarget);
|
|
|
|
if (content && content->ChromeOnlyAccess() &&
|
|
|
|
!nsContentUtils::CanAccessNativeAnon()) {
|
|
|
|
content = content->FindFirstNonChromeOnlyAccessContent();
|
|
|
|
*aTarget = content.forget().get();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2011-04-26 05:30:17 -07:00
|
|
|
NS_IF_ADDREF(*aTarget = mTarget);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
nsDOMTouch::GetScreenX(int32_t* aScreenX)
|
2011-04-26 05:30:17 -07:00
|
|
|
{
|
2011-12-16 16:24:11 -08:00
|
|
|
*aScreenX = mScreenPoint.x;
|
2011-04-26 05:30:17 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
nsDOMTouch::GetScreenY(int32_t* aScreenY)
|
2011-04-26 05:30:17 -07:00
|
|
|
{
|
2011-12-16 16:24:11 -08:00
|
|
|
*aScreenY = mScreenPoint.y;
|
2011-04-26 05:30:17 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
nsDOMTouch::GetClientX(int32_t* aClientX)
|
2011-04-26 05:30:17 -07:00
|
|
|
{
|
2011-12-16 16:24:11 -08:00
|
|
|
*aClientX = mClientPoint.x;
|
2011-04-26 05:30:17 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
nsDOMTouch::GetClientY(int32_t* aClientY)
|
2011-04-26 05:30:17 -07:00
|
|
|
{
|
2011-12-16 16:24:11 -08:00
|
|
|
*aClientY = mClientPoint.y;
|
2011-04-26 05:30:17 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
nsDOMTouch::GetPageX(int32_t* aPageX)
|
2011-04-26 05:30:17 -07:00
|
|
|
{
|
2011-12-16 16:24:11 -08:00
|
|
|
*aPageX = mPagePoint.x;
|
2011-04-26 05:30:17 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
nsDOMTouch::GetPageY(int32_t* aPageY)
|
2011-04-26 05:30:17 -07:00
|
|
|
{
|
2011-12-16 16:24:11 -08:00
|
|
|
*aPageY = mPagePoint.y;
|
2011-04-26 05:30:17 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
nsDOMTouch::GetRadiusX(int32_t* aRadiusX)
|
2011-04-26 05:30:17 -07:00
|
|
|
{
|
2011-12-16 16:24:11 -08:00
|
|
|
*aRadiusX = mRadius.x;
|
2011-04-26 05:30:17 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
nsDOMTouch::GetRadiusY(int32_t* aRadiusY)
|
2011-04-26 05:30:17 -07:00
|
|
|
{
|
2011-12-16 16:24:11 -08:00
|
|
|
*aRadiusY = mRadius.y;
|
2011-04-26 05:30:17 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-04-27 04:58:25 -07:00
|
|
|
nsDOMTouch::GetRotationAngle(float* aRotationAngle)
|
2011-04-26 05:30:17 -07:00
|
|
|
{
|
|
|
|
*aRotationAngle = mRotationAngle;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-04-27 04:58:25 -07:00
|
|
|
nsDOMTouch::GetForce(float* aForce)
|
2011-04-26 05:30:17 -07:00
|
|
|
{
|
|
|
|
*aForce = mForce;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-12-16 16:24:11 -08:00
|
|
|
bool
|
|
|
|
nsDOMTouch::Equals(nsIDOMTouch* aTouch)
|
|
|
|
{
|
|
|
|
float force;
|
|
|
|
float orientation;
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t radiusX, radiusY;
|
2011-12-16 16:24:11 -08:00
|
|
|
aTouch->GetForce(&force);
|
|
|
|
aTouch->GetRotationAngle(&orientation);
|
|
|
|
aTouch->GetRadiusX(&radiusX);
|
|
|
|
aTouch->GetRadiusY(&radiusY);
|
|
|
|
return mRefPoint != aTouch->mRefPoint ||
|
|
|
|
(mForce != force) ||
|
|
|
|
(mRotationAngle != orientation) ||
|
|
|
|
(mRadius.x != radiusX) || (mRadius.y != radiusY);
|
|
|
|
}
|
|
|
|
|
2011-04-26 05:30:17 -07:00
|
|
|
// TouchList
|
2012-08-02 10:41:42 -07:00
|
|
|
nsDOMTouchList::nsDOMTouchList(nsTArray<nsCOMPtr<nsIDOMTouch> > &aTouches)
|
|
|
|
{
|
|
|
|
mPoints.AppendElements(aTouches);
|
|
|
|
}
|
2011-04-26 05:30:17 -07:00
|
|
|
|
|
|
|
DOMCI_DATA(TouchList, nsDOMTouchList)
|
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDOMTouchList)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMTouchList)
|
|
|
|
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(TouchList)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2013-01-12 04:40:33 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_1(nsDOMTouchList, mPoints)
|
2011-04-26 05:30:17 -07:00
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMTouchList)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMTouchList)
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
nsDOMTouchList::GetLength(uint32_t* aLength)
|
2011-04-26 05:30:17 -07:00
|
|
|
{
|
2011-12-16 16:24:11 -08:00
|
|
|
*aLength = mPoints.Length();
|
2011-04-26 05:30:17 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
nsDOMTouchList::Item(uint32_t aIndex, nsIDOMTouch** aRetVal)
|
2011-04-26 05:30:17 -07:00
|
|
|
{
|
2012-08-12 03:43:47 -07:00
|
|
|
NS_IF_ADDREF(*aRetVal = mPoints.SafeElementAt(aIndex, nullptr));
|
2011-04-26 05:30:17 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
nsDOMTouchList::IdentifiedTouch(int32_t aIdentifier, nsIDOMTouch** aRetVal)
|
2011-04-26 05:30:17 -07:00
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
*aRetVal = nullptr;
|
2012-08-22 08:56:38 -07:00
|
|
|
for (uint32_t i = 0; i < mPoints.Length(); ++i) {
|
2011-04-27 04:58:25 -07:00
|
|
|
nsCOMPtr<nsIDOMTouch> point = mPoints[i];
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t identifier;
|
2011-04-26 05:30:17 -07:00
|
|
|
if (point && NS_SUCCEEDED(point->GetIdentifier(&identifier)) &&
|
|
|
|
aIdentifier == identifier) {
|
|
|
|
point.swap(*aRetVal);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TouchEvent
|
|
|
|
|
|
|
|
nsDOMTouchEvent::nsDOMTouchEvent(nsPresContext* aPresContext,
|
2011-12-16 16:24:11 -08:00
|
|
|
nsTouchEvent* aEvent)
|
2011-04-26 05:30:17 -07:00
|
|
|
: nsDOMUIEvent(aPresContext, aEvent ? aEvent :
|
2012-07-30 07:20:58 -07:00
|
|
|
new nsTouchEvent(false, 0, nullptr))
|
2011-04-26 05:30:17 -07:00
|
|
|
{
|
|
|
|
if (aEvent) {
|
2011-10-17 07:59:28 -07:00
|
|
|
mEventIsInternal = false;
|
2011-12-16 16:24:11 -08:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
for (uint32_t i = 0; i < aEvent->touches.Length(); ++i) {
|
2011-12-16 16:24:11 -08:00
|
|
|
nsIDOMTouch *touch = aEvent->touches[i];
|
|
|
|
nsDOMTouch *domtouch = static_cast<nsDOMTouch*>(touch);
|
|
|
|
domtouch->InitializePoints(mPresContext, aEvent);
|
|
|
|
}
|
2011-04-26 05:30:17 -07:00
|
|
|
} else {
|
2011-10-17 07:59:28 -07:00
|
|
|
mEventIsInternal = true;
|
2011-04-26 05:30:17 -07:00
|
|
|
mEvent->time = PR_Now();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsDOMTouchEvent::~nsDOMTouchEvent()
|
|
|
|
{
|
|
|
|
if (mEventIsInternal && mEvent) {
|
2011-12-16 16:24:11 -08:00
|
|
|
delete static_cast<nsTouchEvent*>(mEvent);
|
2012-07-30 07:20:58 -07:00
|
|
|
mEvent = nullptr;
|
2011-04-26 05:30:17 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsDOMTouchEvent, nsDOMUIEvent)
|
2012-11-14 23:32:40 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mTouches)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mTargetTouches)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mChangedTouches)
|
2011-04-26 05:30:17 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsDOMTouchEvent, nsDOMUIEvent)
|
2012-11-14 23:32:40 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTouches)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTargetTouches)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mChangedTouches)
|
2011-04-26 05:30:17 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
|
|
|
|
DOMCI_DATA(TouchEvent, nsDOMTouchEvent)
|
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsDOMTouchEvent)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMTouchEvent)
|
|
|
|
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(TouchEvent)
|
|
|
|
NS_INTERFACE_MAP_END_INHERITING(nsDOMUIEvent)
|
|
|
|
|
|
|
|
NS_IMPL_ADDREF_INHERITED(nsDOMTouchEvent, nsDOMUIEvent)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(nsDOMTouchEvent, nsDOMUIEvent)
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMTouchEvent::InitTouchEvent(const nsAString& aType,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aCanBubble,
|
|
|
|
bool aCancelable,
|
2011-04-23 23:54:25 -07:00
|
|
|
nsIDOMWindow* aView,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aDetail,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aCtrlKey,
|
|
|
|
bool aAltKey,
|
|
|
|
bool aShiftKey,
|
|
|
|
bool aMetaKey,
|
2011-04-26 05:30:17 -07:00
|
|
|
nsIDOMTouchList* aTouches,
|
|
|
|
nsIDOMTouchList* aTargetTouches,
|
|
|
|
nsIDOMTouchList* aChangedTouches)
|
|
|
|
{
|
2011-12-16 16:24:11 -08:00
|
|
|
nsresult rv = nsDOMUIEvent::InitUIEvent(aType,
|
|
|
|
aCanBubble,
|
|
|
|
aCancelable,
|
|
|
|
aView,
|
|
|
|
aDetail);
|
2011-04-26 05:30:17 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2012-04-24 20:00:02 -07:00
|
|
|
static_cast<nsInputEvent*>(mEvent)->InitBasicModifiers(aCtrlKey, aAltKey,
|
|
|
|
aShiftKey, aMetaKey);
|
2011-04-26 05:30:17 -07:00
|
|
|
mTouches = aTouches;
|
|
|
|
mTargetTouches = aTargetTouches;
|
|
|
|
mChangedTouches = aChangedTouches;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMTouchEvent::GetTouches(nsIDOMTouchList** aTouches)
|
|
|
|
{
|
2011-12-16 16:24:11 -08:00
|
|
|
NS_ENSURE_ARG_POINTER(aTouches);
|
|
|
|
NS_ENSURE_STATE(mEvent);
|
|
|
|
nsRefPtr<nsDOMTouchList> t;
|
|
|
|
|
|
|
|
if (mTouches) {
|
|
|
|
return CallQueryInterface(mTouches, aTouches);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(mEvent);
|
|
|
|
if (mEvent->message == NS_TOUCH_END || mEvent->message == NS_TOUCH_CANCEL) {
|
|
|
|
// for touchend events, remove any changed touches from the touches array
|
|
|
|
nsTArray<nsCOMPtr<nsIDOMTouch> > unchangedTouches;
|
2012-11-29 08:14:13 -08:00
|
|
|
const nsTArray<nsCOMPtr<nsIDOMTouch> >& touches = touchEvent->touches;
|
2012-08-22 08:56:38 -07:00
|
|
|
for (uint32_t i = 0; i < touches.Length(); ++i) {
|
2011-12-16 16:24:11 -08:00
|
|
|
if (!touches[i]->mChanged) {
|
|
|
|
unchangedTouches.AppendElement(touches[i]);
|
|
|
|
}
|
|
|
|
}
|
2012-08-02 10:41:42 -07:00
|
|
|
t = new nsDOMTouchList(unchangedTouches);
|
2011-12-16 16:24:11 -08:00
|
|
|
} else {
|
2012-08-02 10:41:42 -07:00
|
|
|
t = new nsDOMTouchList(touchEvent->touches);
|
2011-12-16 16:24:11 -08:00
|
|
|
}
|
|
|
|
mTouches = t;
|
|
|
|
return CallQueryInterface(mTouches, aTouches);
|
2011-04-26 05:30:17 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMTouchEvent::GetTargetTouches(nsIDOMTouchList** aTargetTouches)
|
|
|
|
{
|
2011-12-16 16:24:11 -08:00
|
|
|
NS_ENSURE_ARG_POINTER(aTargetTouches);
|
|
|
|
NS_ENSURE_STATE(mEvent);
|
|
|
|
|
|
|
|
if (mTargetTouches) {
|
|
|
|
return CallQueryInterface(mTargetTouches, aTargetTouches);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsTArray<nsCOMPtr<nsIDOMTouch> > targetTouches;
|
|
|
|
nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(mEvent);
|
2012-11-29 08:14:13 -08:00
|
|
|
const nsTArray<nsCOMPtr<nsIDOMTouch> >& touches = touchEvent->touches;
|
2012-08-22 08:56:38 -07:00
|
|
|
for (uint32_t i = 0; i < touches.Length(); ++i) {
|
2011-12-16 16:24:11 -08:00
|
|
|
// for touchend/cancel events, don't append to the target list if this is a
|
|
|
|
// touch that is ending
|
|
|
|
if ((mEvent->message != NS_TOUCH_END &&
|
|
|
|
mEvent->message != NS_TOUCH_CANCEL) || !touches[i]->mChanged) {
|
|
|
|
nsIDOMEventTarget* targetPtr = touches[i]->GetTarget();
|
2012-10-10 12:13:59 -07:00
|
|
|
if (targetPtr == mEvent->originalTarget) {
|
2011-12-16 16:24:11 -08:00
|
|
|
targetTouches.AppendElement(touches[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-08-02 10:41:42 -07:00
|
|
|
mTargetTouches = new nsDOMTouchList(targetTouches);
|
2011-12-16 16:24:11 -08:00
|
|
|
return CallQueryInterface(mTargetTouches, aTargetTouches);
|
2011-04-26 05:30:17 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMTouchEvent::GetChangedTouches(nsIDOMTouchList** aChangedTouches)
|
|
|
|
{
|
2011-12-16 16:24:11 -08:00
|
|
|
NS_ENSURE_ARG_POINTER(aChangedTouches);
|
|
|
|
NS_ENSURE_STATE(mEvent);
|
|
|
|
|
|
|
|
if (mChangedTouches) {
|
|
|
|
return CallQueryInterface(mChangedTouches, aChangedTouches);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsTArray<nsCOMPtr<nsIDOMTouch> > changedTouches;
|
|
|
|
nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(mEvent);
|
2012-11-29 08:14:13 -08:00
|
|
|
const nsTArray<nsCOMPtr<nsIDOMTouch> >& touches = touchEvent->touches;
|
2012-08-22 08:56:38 -07:00
|
|
|
for (uint32_t i = 0; i < touches.Length(); ++i) {
|
2011-12-16 16:24:11 -08:00
|
|
|
if (touches[i]->mChanged) {
|
|
|
|
changedTouches.AppendElement(touches[i]);
|
|
|
|
}
|
|
|
|
}
|
2012-08-02 10:41:42 -07:00
|
|
|
mChangedTouches = new nsDOMTouchList(changedTouches);
|
2011-12-16 16:24:11 -08:00
|
|
|
return CallQueryInterface(mChangedTouches, aChangedTouches);
|
2011-04-26 05:30:17 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
nsDOMTouchEvent::GetAltKey(bool* aAltKey)
|
2011-04-26 05:30:17 -07:00
|
|
|
{
|
2012-04-24 20:00:02 -07:00
|
|
|
*aAltKey = static_cast<nsInputEvent*>(mEvent)->IsAlt();
|
2011-04-26 05:30:17 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
nsDOMTouchEvent::GetMetaKey(bool* aMetaKey)
|
2011-04-26 05:30:17 -07:00
|
|
|
{
|
2012-04-24 20:00:02 -07:00
|
|
|
*aMetaKey = static_cast<nsInputEvent*>(mEvent)->IsMeta();
|
2011-04-26 05:30:17 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
nsDOMTouchEvent::GetCtrlKey(bool* aCtrlKey)
|
2011-04-26 05:30:17 -07:00
|
|
|
{
|
2012-04-24 20:00:02 -07:00
|
|
|
*aCtrlKey = static_cast<nsInputEvent*>(mEvent)->IsControl();
|
2011-04-26 05:30:17 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
nsDOMTouchEvent::GetShiftKey(bool* aShiftKey)
|
2011-04-26 05:30:17 -07:00
|
|
|
{
|
2012-04-24 20:00:02 -07:00
|
|
|
*aShiftKey = static_cast<nsInputEvent*>(mEvent)->IsShift();
|
2011-04-26 05:30:17 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-10-25 07:57:51 -07:00
|
|
|
#ifdef XP_WIN
|
|
|
|
namespace mozilla {
|
|
|
|
namespace widget {
|
|
|
|
extern int32_t IsTouchDeviceSupportPresent();
|
|
|
|
} }
|
|
|
|
#endif
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2011-04-26 05:30:17 -07:00
|
|
|
nsDOMTouchEvent::PrefEnabled()
|
|
|
|
{
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool sDidCheckPref = false;
|
|
|
|
static bool sPrefValue = false;
|
2011-04-26 05:30:17 -07:00
|
|
|
if (!sDidCheckPref) {
|
2011-10-17 07:59:28 -07:00
|
|
|
sDidCheckPref = true;
|
2012-10-25 07:57:51 -07:00
|
|
|
int32_t flag = 0;
|
|
|
|
if (NS_SUCCEEDED(Preferences::GetInt("dom.w3c_touch_events.enabled",
|
|
|
|
&flag))) {
|
|
|
|
if (flag == 2) {
|
|
|
|
#ifdef XP_WIN
|
|
|
|
// On Windows we auto-detect based on device support.
|
|
|
|
sPrefValue = mozilla::widget::IsTouchDeviceSupportPresent();
|
|
|
|
#else
|
|
|
|
NS_WARNING("dom.w3c_touch_events.enabled=2 not implemented!");
|
|
|
|
sPrefValue = false;
|
|
|
|
#endif
|
|
|
|
} else {
|
|
|
|
sPrefValue = !!flag;
|
|
|
|
}
|
|
|
|
}
|
2011-04-26 05:30:17 -07:00
|
|
|
if (sPrefValue) {
|
|
|
|
nsContentUtils::InitializeTouchEventTable();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sPrefValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
NS_NewDOMTouchEvent(nsIDOMEvent** aInstancePtrResult,
|
|
|
|
nsPresContext* aPresContext,
|
2011-12-16 16:24:11 -08:00
|
|
|
nsTouchEvent *aEvent)
|
2011-04-26 05:30:17 -07:00
|
|
|
{
|
|
|
|
nsDOMTouchEvent* it = new nsDOMTouchEvent(aPresContext, aEvent);
|
|
|
|
|
|
|
|
return CallQueryInterface(it, aInstancePtrResult);
|
|
|
|
}
|