Bug 508906. Add experimental MozTouch events. r=smaug,jimm

This commit is contained in:
Felipe Gomes 2010-08-02 15:34:54 +02:00
Родитель 797979e980
Коммит be7e9d6194
32 изменённых файлов: 832 добавлений и 9 удалений

Просмотреть файл

@ -620,6 +620,10 @@ nsContentUtils::InitializeEventTable() {
{ nsGkAtoms::onMozTapGesture, NS_SIMPLE_GESTURE_TAP, EventNameType_None, NS_SIMPLE_GESTURE_EVENT },
{ nsGkAtoms::onMozPressTapGesture, NS_SIMPLE_GESTURE_PRESSTAP, EventNameType_None, NS_SIMPLE_GESTURE_EVENT },
{ nsGkAtoms::onMozTouchDown, NS_MOZTOUCH_DOWN, EventNameType_None, NS_MOZTOUCH_EVENT },
{ nsGkAtoms::onMozTouchMove, NS_MOZTOUCH_MOVE, EventNameType_None, NS_MOZTOUCH_EVENT },
{ nsGkAtoms::onMozTouchUp, NS_MOZTOUCH_UP, EventNameType_None, NS_MOZTOUCH_EVENT },
{ nsGkAtoms::ontransitionend, NS_TRANSITION_END, EventNameType_None, NS_TRANSITION_EVENT }
};

Просмотреть файл

@ -1536,6 +1536,11 @@ GK_ATOM(onMozRotateGesture, "onMozRotateGesture")
GK_ATOM(onMozTapGesture, "onMozTapGesture")
GK_ATOM(onMozPressTapGesture, "onMozPressTapGesture")
// Touch events
GK_ATOM(onMozTouchDown, "onMozTouchDown")
GK_ATOM(onMozTouchMove, "onMozTouchMove")
GK_ATOM(onMozTouchUp, "onMozTouchUp")
// orientation support
GK_ATOM(onMozOrientation, "onMozOrientation")

Просмотреть файл

@ -129,4 +129,6 @@ nsresult
NS_NewDOMTransitionEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, class nsTransitionEvent* aEvent);
nsresult
NS_NewDOMCloseEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, class nsEvent* aEvent);
nsresult
NS_NewDOMMozTouchEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, class nsMozTouchEvent* aEvent);
#endif // nsIPrivateDOMEvent_h__

Просмотреть файл

@ -79,6 +79,7 @@ CPPSRCS = \
nsDOMDataTransfer.cpp \
nsDOMNotifyPaintEvent.cpp \
nsDOMSimpleGestureEvent.cpp \
nsDOMMozTouchEvent.cpp \
nsDOMEventTargetHelper.cpp \
nsDOMScrollAreaEvent.cpp \
nsDOMTransitionEvent.cpp \

Просмотреть файл

@ -100,6 +100,9 @@ static const char* const sEventNames[] = {
"MozRotateGesture",
"MozTapGesture",
"MozPressTapGesture",
"MozTouchDown",
"MozTouchMove",
"MozTouchUp",
"MozScrolledAreaChanged",
"transitionend"
};
@ -192,6 +195,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDOMEvent)
case NS_MOUSE_EVENT:
case NS_MOUSE_SCROLL_EVENT:
case NS_SIMPLE_GESTURE_EVENT:
case NS_MOZTOUCH_EVENT:
static_cast<nsMouseEvent_base*>(tmp->mEvent)->relatedTarget = nsnull;
break;
case NS_DRAG_EVENT:
@ -221,6 +225,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsDOMEvent)
case NS_MOUSE_EVENT:
case NS_MOUSE_SCROLL_EVENT:
case NS_SIMPLE_GESTURE_EVENT:
case NS_MOZTOUCH_EVENT:
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mEvent->relatedTarget");
cb.NoteXPCOMChild(
static_cast<nsMouseEvent_base*>(tmp->mEvent)->relatedTarget);
@ -807,6 +812,14 @@ NS_METHOD nsDOMEvent::DuplicatePrivateData()
NS_ENSURE_TRUE(newEvent, NS_ERROR_OUT_OF_MEMORY);
break;
}
case NS_MOZTOUCH_EVENT:
{
newEvent = new nsMozTouchEvent(PR_FALSE, msg, nsnull,
static_cast<nsMozTouchEvent*>(mEvent)->streamId);
NS_ENSURE_TRUE(newEvent, NS_ERROR_OUT_OF_MEMORY);
isInputEvent = PR_TRUE;
break;
}
default:
{
NS_WARNING("Unknown event type!!!");
@ -1307,6 +1320,12 @@ const char* nsDOMEvent::GetEventName(PRUint32 aEventType)
return sEventNames[eDOMEvents_MozTapGesture];
case NS_SIMPLE_GESTURE_PRESSTAP:
return sEventNames[eDOMEvents_MozPressTapGesture];
case NS_MOZTOUCH_DOWN:
return sEventNames[eDOMEvents_MozTouchDown];
case NS_MOZTOUCH_MOVE:
return sEventNames[eDOMEvents_MozTouchMove];
case NS_MOZTOUCH_UP:
return sEventNames[eDOMEvents_MozTouchUp];
case NS_SCROLLEDAREACHANGED:
return sEventNames[eDOMEvents_MozScrolledAreaChanged];
case NS_TRANSITION_END:

Просмотреть файл

@ -179,6 +179,9 @@ public:
eDOMEvents_MozRotateGesture,
eDOMEvents_MozTapGesture,
eDOMEvents_MozPressTapGesture,
eDOMEvents_MozTouchDown,
eDOMEvents_MozTouchMove,
eDOMEvents_MozTouchUp,
eDOMEvents_MozScrolledAreaChanged,
eDOMEvents_transitionend
};

Просмотреть файл

@ -119,6 +119,7 @@ nsDOMMouseEvent::InitMouseEvent(const nsAString & aType, PRBool aCanBubble, PRBo
case NS_MOUSE_SCROLL_EVENT:
case NS_DRAG_EVENT:
case NS_SIMPLE_GESTURE_EVENT:
case NS_MOZTOUCH_EVENT:
{
static_cast<nsMouseEvent_base*>(mEvent)->relatedTarget = aRelatedTarget;
static_cast<nsMouseEvent_base*>(mEvent)->button = aButton;
@ -174,6 +175,7 @@ nsDOMMouseEvent::GetButton(PRUint16* aButton)
case NS_MOUSE_SCROLL_EVENT:
case NS_DRAG_EVENT:
case NS_SIMPLE_GESTURE_EVENT:
case NS_MOZTOUCH_EVENT:
*aButton = static_cast<nsMouseEvent_base*>(mEvent)->button;
break;
default:
@ -196,6 +198,7 @@ nsDOMMouseEvent::GetRelatedTarget(nsIDOMEventTarget** aRelatedTarget)
case NS_MOUSE_SCROLL_EVENT:
case NS_DRAG_EVENT:
case NS_SIMPLE_GESTURE_EVENT:
case NS_MOZTOUCH_EVENT:
relatedTarget = static_cast<nsMouseEvent_base*>(mEvent)->relatedTarget;
break;
default:

Просмотреть файл

@ -0,0 +1,134 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* the Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Felipe Gomes <felipc@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsDOMMozTouchEvent.h"
#include "nsGUIEvent.h"
#include "nsContentUtils.h"
nsDOMMozTouchEvent::nsDOMMozTouchEvent(nsPresContext* aPresContext, nsMozTouchEvent* aEvent)
: nsDOMMouseEvent(aPresContext, aEvent ? aEvent : new nsMozTouchEvent(PR_FALSE, 0, nsnull, 0))
{
NS_ASSERTION(mEvent->eventStructType == NS_MOZTOUCH_EVENT, "event type mismatch NS_MOZTOUCH_EVENT");
if (aEvent) {
mEventIsInternal = PR_FALSE;
} else {
mEventIsInternal = PR_TRUE;
mEvent->time = PR_Now();
mEvent->refPoint.x = mEvent->refPoint.y = 0;
}
}
nsDOMMozTouchEvent::~nsDOMMozTouchEvent()
{
if (mEventIsInternal) {
delete static_cast<nsMozTouchEvent*>(mEvent);
mEvent = nsnull;
}
}
NS_IMPL_ADDREF_INHERITED(nsDOMMozTouchEvent, nsDOMMouseEvent)
NS_IMPL_RELEASE_INHERITED(nsDOMMozTouchEvent, nsDOMMouseEvent)
DOMCI_DATA(MozTouchEvent, nsDOMMozTouchEvent)
NS_INTERFACE_MAP_BEGIN(nsDOMMozTouchEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMMozTouchEvent)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozTouchEvent)
NS_INTERFACE_MAP_END_INHERITING(nsDOMMouseEvent)
/* readonly attribute unsigned long steramId; */
NS_IMETHODIMP
nsDOMMozTouchEvent::GetStreamId(PRUint32 *aStreamId)
{
NS_ENSURE_ARG_POINTER(aStreamId);
*aStreamId = static_cast<nsMozTouchEvent*>(mEvent)->streamId;
return NS_OK;
}
NS_IMETHODIMP
nsDOMMozTouchEvent::InitMozTouchEvent(const nsAString& aTypeArg,
PRBool aCanBubbleArg,
PRBool aCancelableArg,
nsIDOMAbstractView* aViewArg,
PRInt32 aDetailArg,
PRInt32 aScreenX,
PRInt32 aScreenY,
PRInt32 aClientX,
PRInt32 aClientY,
PRBool aCtrlKeyArg,
PRBool aAltKeyArg,
PRBool aShiftKeyArg,
PRBool aMetaKeyArg,
PRUint16 aButton,
nsIDOMEventTarget* aRelatedTarget,
PRUint32 aStreamId)
{
nsresult rv = nsDOMMouseEvent::InitMouseEvent(aTypeArg,
aCanBubbleArg,
aCancelableArg,
aViewArg,
aDetailArg,
aScreenX,
aScreenY,
aClientX,
aClientY,
aCtrlKeyArg,
aAltKeyArg,
aShiftKeyArg,
aMetaKeyArg,
aButton,
aRelatedTarget);
NS_ENSURE_SUCCESS(rv, rv);
nsMozTouchEvent* mozTouchEvent = static_cast<nsMozTouchEvent*>(mEvent);
mozTouchEvent->streamId = aStreamId;
return NS_OK;
}
nsresult NS_NewDOMMozTouchEvent(nsIDOMEvent** aInstancePtrResult,
nsPresContext* aPresContext,
nsMozTouchEvent *aEvent)
{
nsDOMMozTouchEvent *it = new nsDOMMozTouchEvent(aPresContext, aEvent);
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
return CallQueryInterface(it, aInstancePtrResult);
}

Просмотреть файл

@ -0,0 +1,61 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* the Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Felipe Gomes <felipc@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsDOMMozTouchEvent_h__
#define nsDOMMozTouchEvent_h__
#include "nsIDOMMozTouchEvent.h"
#include "nsDOMMouseEvent.h"
class nsPresContext;
class nsDOMMozTouchEvent : public nsDOMMouseEvent,
public nsIDOMMozTouchEvent
{
public:
nsDOMMozTouchEvent(nsPresContext* aPresCOntext, nsMozTouchEvent* aEvent);
virtual ~nsDOMMozTouchEvent();
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOMMOZTOUCHEVENT
// Forward to base class
NS_FORWARD_TO_NSDOMMOUSEEVENT
};
#endif

Просмотреть файл

@ -132,6 +132,7 @@ nsDOMUIEvent::GetScreenPoint()
(mEvent->eventStructType != NS_MOUSE_EVENT &&
mEvent->eventStructType != NS_POPUP_EVENT &&
mEvent->eventStructType != NS_MOUSE_SCROLL_EVENT &&
mEvent->eventStructType != NS_MOZTOUCH_EVENT &&
mEvent->eventStructType != NS_DRAG_EVENT &&
mEvent->eventStructType != NS_SIMPLE_GESTURE_EVENT)) {
return nsIntPoint(0, 0);
@ -155,6 +156,7 @@ nsDOMUIEvent::GetClientPoint()
(mEvent->eventStructType != NS_MOUSE_EVENT &&
mEvent->eventStructType != NS_POPUP_EVENT &&
mEvent->eventStructType != NS_MOUSE_SCROLL_EVENT &&
mEvent->eventStructType != NS_MOZTOUCH_EVENT &&
mEvent->eventStructType != NS_DRAG_EVENT &&
mEvent->eventStructType != NS_SIMPLE_GESTURE_EVENT) ||
!mPresContext ||
@ -322,6 +324,7 @@ nsDOMUIEvent::GetLayerPoint()
(mEvent->eventStructType != NS_MOUSE_EVENT &&
mEvent->eventStructType != NS_POPUP_EVENT &&
mEvent->eventStructType != NS_MOUSE_SCROLL_EVENT &&
mEvent->eventStructType != NS_MOZTOUCH_EVENT &&
mEvent->eventStructType != NS_DRAG_EVENT &&
mEvent->eventStructType != NS_SIMPLE_GESTURE_EVENT) ||
!mPresContext ||

Просмотреть файл

@ -753,6 +753,9 @@ nsEventDispatcher::CreateEvent(nsPresContext* aPresContext,
case NS_SIMPLE_GESTURE_EVENT:
return NS_NewDOMSimpleGestureEvent(aDOMEvent, aPresContext,
static_cast<nsSimpleGestureEvent*>(aEvent));
case NS_MOZTOUCH_EVENT:
return NS_NewDOMMozTouchEvent(aDOMEvent, aPresContext,
static_cast<nsMozTouchEvent*>(aEvent));
case NS_TRANSITION_EVENT:
return NS_NewDOMTransitionEvent(aDOMEvent, aPresContext,
static_cast<nsTransitionEvent*>(aEvent));
@ -827,6 +830,8 @@ nsEventDispatcher::CreateEvent(nsPresContext* aPresContext,
return NS_NewDOMBeforeUnloadEvent(aDOMEvent, aPresContext, nsnull);
if (aEventType.LowerCaseEqualsLiteral("pagetransition"))
return NS_NewDOMPageTransitionEvent(aDOMEvent, aPresContext, nsnull);
if (aEventType.LowerCaseEqualsLiteral("moztouchevent"))
return NS_NewDOMMozTouchEvent(aDOMEvent, aPresContext, nsnull);
if (aEventType.LowerCaseEqualsLiteral("scrollareaevent"))
return NS_NewDOMScrollAreaEvent(aDOMEvent, aPresContext, nsnull);
// FIXME: Should get spec to say what the right string is here! This

Просмотреть файл

@ -491,6 +491,10 @@ nsEventListenerManager::AddEventListener(nsIDOMEventListener *aListener,
nsPIDOMWindow* window = GetInnerWindowForTarget();
if (window)
window->SetHasOrientationEventListener();
} else if (aType >= NS_MOZTOUCH_DOWN && aType <= NS_MOZTOUCH_UP) {
nsPIDOMWindow* window = GetInnerWindowForTarget();
if (window)
window->SetHasTouchEventListeners();
}
return NS_OK;

Просмотреть файл

@ -84,6 +84,7 @@ _TEST_FILES = \
test_bug493251.html \
test_bug502818.html \
test_bug508479.html \
test_bug508906.html \
test_bug517851.html \
test_bug534833.html \
test_bug545268.html \

Просмотреть файл

@ -0,0 +1,212 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=508906
-->
<head>
<title>Test for Bug 508906</title>
<script type="text/javascript" src="/MochiKit/packed.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=508906">Mozilla Bug 508906</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="application/javascript;version=1.8">
/** Test for Bug 508906 - MozTouch* Events **/
let tests = [], testTarget, parent;
function nextTest() {
if (tests.length)
SimpleTest.executeSoon(tests.shift());
}
function random() {
return Math.floor(Math.random() * 100);
}
function createTestEventValue(name) {
let detail = random();
let screenX = random();
let screenY = random();
let clientX = random();
let clientY = random();
let ctrlKey = random() % 2 ? true : false;
let altKey = random() % 2 ? true : false;
let shiftKey = random() % 2 ? true : false;
let metaKey = random() % 2 ? true : false;
let button = random();
let streamId = random();
return function() {
let event = document.createEvent("MozTouchEvent");
event.initMozTouchEvent(name, true, true, window,
detail, screenX, screenY, clientX, clientY,
ctrlKey, altKey, shiftKey, metaKey, button,
null, streamId);
function check(ev) {
is(ev.detail, detail, "Correct detail");
is(ev.screenX, screenX, "Correct screenX");
is(ev.screenY, screenY, "Correct screenY");
is(ev.clientX, clientX, "Correct clientX");
is(ev.clientY, clientY, "Correct clientY");
is(ev.ctrlKey, ctrlKey, "Correct ctrlKey");
is(ev.altKey, altKey, "Correct altKey");
is(ev.shiftKey, shiftKey, "Correct shiftKey");
is(ev.metaKey, metaKey, "Correct metaKey");
is(ev.button, button, "Correct buttonArg");
is(ev.streamId, streamId, "Correct streamId");
}
for each (let target in [document, window, testTarget, parent])
target.addEventListener(name, check, false);
testTarget.dispatchEvent(event);
for each (let target in [document, window, testTarget, parent])
target.removeEventListener(name, check, false);
nextTest();
}
}
function testDefaultArg() {
let event = document.createEvent("MozTouchEvent");
event.initMouseEvent("MozTouchDown", true, true, window, 0, 0, 0, 0, 0,
false, false, false, false, 0, null);
testTarget.addEventListener("MozTouchDown", function(ev) {
testTarget.removeEventListener("MozTouchDown", arguments.callee, false);
is(ev.streamId, 0, "Correct default streamId");
}, false);
testTarget.dispatchEvent(event);
nextTest();
}
function testStopPropagation() {
let event = document.createEvent("MozTouchEvent");
event.initMozTouchEvent("MozTouchDown", true, true, window, 0, 0, 0, 0, 0,
false, false, false, false, 0, null, 0);
let unreachableListener = function () {
ok(false, "Event should have been stopped");
}
// Capturing phase
let captured = false;
parent.addEventListener("MozTouchDown", function() {
parent.removeEventListener("MozTouchDown", arguments.callee, true);
captured = true;
}, true); // Capturing phase
// Bubbling phase
parent.addEventListener("MozTouchDown", unreachableListener, false);
testTarget.addEventListener("MozTouchDown", function(ev) {
testTarget.removeEventListener("MozTouchDown", arguments.callee, false);
is(captured, true, "Event should have been captured");
ev.stopPropagation();
}, false);
testTarget.dispatchEvent(event);
parent.removeEventListener("MozTouchDown", unreachableListener, false);
nextTest();
}
function testPreventDefault() {
let event = document.createEvent("MozTouchEvent");
event.initMozTouchEvent("MozTouchDown", true, true, window, 0, 0, 0, 0, 0,
false, false, false, false, 0, null, 0);
parent.addEventListener("MozTouchDown", function(ev) {
parent.removeEventListener("MozTouchDown", arguments.callee, false);
is(ev.getPreventDefault(), true, "preventDefault can be called");
nextTest();
}, false);
testTarget.addEventListener("MozTouchDown", function(ev) {
testTarget.removeEventListener("MozTouchDown", arguments.callee, false);
ev.preventDefault();
}, false);
testTarget.dispatchEvent(event);
}
function testBlockPreventDefault() {
let event = document.createEvent("MozTouchEvent");
event.initMozTouchEvent("MozTouchDown", true, false, window, 0, 0, 0, 0, 0,
false, false, false, false, 0, null, 0);
parent.addEventListener("MozTouchDown", function(ev) {
parent.removeEventListener("MozTouchDown", arguments.callee, false);
is(ev.getPreventDefault(), false, "aCancelableArg works");
nextTest();
}, false);
testTarget.addEventListener("MozTouchDown", function(ev) {
testTarget.removeEventListener("MozTouchDown", arguments.callee, false);
ev.preventDefault();
}, false);
testTarget.dispatchEvent(event);
}
function testBlockBubbling() {
let unreachableListener = function () {
ok(false, "aCanBubble doesn't work");
}
let event = document.createEvent("MozTouchEvent");
event.initMozTouchEvent("MozTouchDown", false, true, window, 0, 0, 0, 0, 0,
false, false, false, false, 0, null, 0);
parent.addEventListener("MozTouchDown", unreachableListener, false);
testTarget.dispatchEvent(event);
parent.removeEventListener("MozTouchDown", unreachableListener, false);
nextTest();
}
function doTest() {
testTarget = document.getElementById("testTarget");
parent = testTarget.parentNode;
tests.push(createTestEventValue("MozTouchDown"));
tests.push(createTestEventValue("MozTouchMove"));
tests.push(createTestEventValue("MozTouchUp"));
tests.push(testDefaultArg);
tests.push(testStopPropagation);
tests.push(testPreventDefault);
tests.push(testBlockPreventDefault);
tests.push(testBlockBubbling);
tests.push(function() {
SimpleTest.finish();
});
nextTest();
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(doTest);
</script>
</pre>
<div id="parent">
<span id="testTarget" style="border: 1px solid black;">testTarget</span>
</div>
</body>
</html>

Просмотреть файл

@ -469,6 +469,8 @@
#include "nsIDOMNSMouseEvent.h"
#include "nsIDOMMozTouchEvent.h"
#include "nsIEventListenerService.h"
#include "nsIFrameMessageManager.h"
#include "mozilla/dom/Element.h"
@ -1378,6 +1380,8 @@ static nsDOMClassInfoData sClassInfoData[] = {
NS_DEFINE_CLASSINFO_DATA(SimpleGestureEvent, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(MozTouchEvent, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
#ifdef MOZ_MATHML
NS_DEFINE_CLASSINFO_DATA_WITH_NAME(MathMLElement, Element, nsElementSH,
ELEMENT_SCRIPTABLE_FLAGS)
@ -3879,6 +3883,13 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(MozTouchEvent, nsIDOMMozTouchEvent)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozTouchEvent)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMouseEvent)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSMouseEvent)
DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
DOM_CLASSINFO_MAP_END
#ifdef MOZ_MATHML
DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(MathMLElement, nsIDOMElement)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMElement)

Просмотреть файл

@ -448,6 +448,8 @@ DOMCI_CLASS(NotifyPaintEvent)
DOMCI_CLASS(SimpleGestureEvent)
DOMCI_CLASS(MozTouchEvent)
#ifdef MOZ_MATHML
DOMCI_CLASS(MathMLElement)
#endif

Просмотреть файл

@ -1592,12 +1592,17 @@ nsFocusManager::Focus(nsPIDOMWindow* aWindow,
aIsNewDocument, aFocusChanged, aWindowRaised, aFlags);
#endif
// if this is a new document, update the parent chain of frames so that
// focus can be traversed from the top level down to the newly focused
// window.
if (aIsNewDocument)
if (aIsNewDocument) {
// if this is a new document, update the parent chain of frames so that
// focus can be traversed from the top level down to the newly focused
// window.
AdjustWindowFocus(aWindow, PR_FALSE);
// Update the window touch registration to reflect the state of
// the new document that got focus
aWindow->UpdateTouchState();
}
// indicate that the window has taken focus.
if (aWindow->TakeFocus(PR_TRUE, focusMethod))
aIsNewDocument = PR_TRUE;

Просмотреть файл

@ -643,7 +643,7 @@ nsPIDOMWindow::nsPIDOMWindow(nsPIDOMWindow *aOuterWindow)
: mFrameElement(nsnull), mDocShell(nsnull), mModalStateDepth(0),
mRunningTimeout(nsnull), mMutationBits(0), mIsDocumentLoaded(PR_FALSE),
mIsHandlingResizeEvent(PR_FALSE), mIsInnerWindow(aOuterWindow != nsnull),
mMayHavePaintEventListener(PR_FALSE),
mMayHavePaintEventListener(PR_FALSE), mMayHaveTouchEventListener(PR_FALSE),
mIsModalContentWindow(PR_FALSE), mIsActive(PR_FALSE),
mInnerWindow(nsnull), mOuterWindow(aOuterWindow) {}
@ -6882,6 +6882,35 @@ nsGlobalWindow::SetActive(PRBool aActive)
NotifyDocumentTree(mDoc, nsnull);
}
void nsGlobalWindow::MaybeUpdateTouchState()
{
FORWARD_TO_INNER_VOID(MaybeUpdateTouchState, ());
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
nsCOMPtr<nsIDOMWindow> focusedWindow;
fm->GetFocusedWindow(getter_AddRefs(focusedWindow));
if(this == focusedWindow) {
UpdateTouchState();
}
}
void nsGlobalWindow::UpdateTouchState()
{
FORWARD_TO_INNER_VOID(UpdateTouchState, ());
nsCOMPtr<nsIWidget> mainWidget = GetMainWidget();
if (!mainWidget)
return;
if (mMayHaveTouchEventListener) {
mainWidget->RegisterTouchWindow();
} else {
mainWidget->UnregisterTouchWindow();
}
}
void
nsGlobalWindow::SetChromeEventHandler(nsPIDOMEventTarget* aChromeEventHandler)
{

Просмотреть файл

@ -360,6 +360,8 @@ public:
virtual NS_HIDDEN_(nsresult) ForceClose();
virtual NS_HIDDEN_(void) SetHasOrientationEventListener();
virtual NS_HIDDEN_(void) MaybeUpdateTouchState();
virtual NS_HIDDEN_(void) UpdateTouchState();
// nsIDOMViewCSS
NS_DECL_NSIDOMVIEWCSS

Просмотреть файл

@ -167,6 +167,9 @@ public:
win->mMutationBits |= aType;
}
virtual void MaybeUpdateTouchState() {}
virtual void UpdateTouchState() {}
// GetExtantDocument provides a backdoor to the DOM GetDocument accessor
nsIDOMDocument* GetExtantDocument() const
{
@ -422,6 +425,16 @@ public:
return mMayHavePaintEventListener;
}
/**
* Call this to indicate that some node (this window, its document,
* or content in that document) has a touch event listener.
*/
void SetHasTouchEventListeners()
{
mMayHaveTouchEventListener = PR_TRUE;
MaybeUpdateTouchState();
}
/**
* Initialize window.java and window.Packages.
*/
@ -560,6 +573,7 @@ protected:
PRPackedBool mIsHandlingResizeEvent;
PRPackedBool mIsInnerWindow;
PRPackedBool mMayHavePaintEventListener;
PRPackedBool mMayHaveTouchEventListener;
// This variable is used on both inner and outer windows (and they
// should match).

Просмотреть файл

@ -80,6 +80,7 @@ XPIDLSRCS = \
nsIDOMPaintRequestList.idl \
nsIDOMSimpleGestureEvent.idl \
nsIDOMNSMouseEvent.idl \
nsIDOMMozTouchEvent.idl \
nsIDOMOrientationEvent.idl \
nsIDOMScrollAreaEvent.idl \
nsIDOMTransitionEvent.idl \

Просмотреть файл

@ -0,0 +1,64 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* the Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Felipe Gomes <felipc@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsIDOMMouseEvent.idl"
[scriptable, uuid(9b454391-0190-4313-a070-1e26e9bf6f31)]
interface nsIDOMMozTouchEvent : nsIDOMMouseEvent
{
readonly attribute unsigned long streamId;
void initMozTouchEvent(in DOMString typeArg,
in boolean canBubbleArg,
in boolean cancelableArg,
in nsIDOMAbstractView viewArg,
in long detailArg,
in long screenXArg,
in long screenYArg,
in long clientXArg,
in long clientYArg,
in boolean ctrlKeyArg,
in boolean altKeyArg,
in boolean shiftKeyArg,
in boolean metaKeyArg,
in unsigned short buttonArg,
in nsIDOMEventTarget relatedTargetArg,
in unsigned long streamIdArg);
};

Просмотреть файл

@ -768,6 +768,7 @@ nsLayoutUtils::GetEventCoordinatesRelativeTo(const nsEvent* aEvent, nsIFrame* aF
aEvent->eventStructType != NS_DRAG_EVENT &&
aEvent->eventStructType != NS_SIMPLE_GESTURE_EVENT &&
aEvent->eventStructType != NS_GESTURENOTIFY_EVENT &&
aEvent->eventStructType != NS_MOZTOUCH_EVENT &&
aEvent->eventStructType != NS_QUERY_CONTENT_EVENT))
return nsPoint(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);

Просмотреть файл

@ -95,6 +95,7 @@ class nsMouseScrollEvent;
class nsReconversionEvent;
class nsTooltipEvent;
class nsSimpleGestureEvent;
class nsMozTouchEvent;
class nsContentCommandEvent;
#endif // nsEvent_h__

Просмотреть файл

@ -114,6 +114,7 @@ class nsHashKey;
#define NS_CONTENT_COMMAND_EVENT 39
#define NS_GESTURENOTIFY_EVENT 40
#define NS_UISTATECHANGE_EVENT 41
#define NS_MOZTOUCH_EVENT 42
// These flags are sort of a mess. They're sort of shared between event
// listener flags and event flags, but only some of them. You've been
@ -470,6 +471,11 @@ class nsHashKey;
#define NS_SMIL_REPEAT (NS_SMIL_TIME_EVENT_START + 2)
#endif // MOZ_SMIL
#define NS_MOZTOUCH_EVENT_START 4400
#define NS_MOZTOUCH_DOWN (NS_MOZTOUCH_EVENT_START)
#define NS_MOZTOUCH_MOVE (NS_MOZTOUCH_EVENT_START+1)
#define NS_MOZTOUCH_UP (NS_MOZTOUCH_EVENT_START+2)
/**
* Return status for event processors, nsEventStatus, is defined in
* nsEvent.h.
@ -1268,6 +1274,19 @@ public:
PRPackedBool mIsEnabled; // [out]
};
class nsMozTouchEvent : public nsMouseEvent_base
{
public:
nsMozTouchEvent(PRBool isTrusted, PRUint32 msg, nsIWidget* w,
PRUint32 streamIdArg)
: nsMouseEvent_base(isTrusted, msg, w, NS_MOZTOUCH_EVENT),
streamId(streamIdArg)
{
}
PRUint32 streamId;
};
/**
* Form event
*

Просмотреть файл

@ -111,8 +111,8 @@ typedef nsEventStatus (* EVENT_CALLBACK)(nsGUIEvent *event);
#endif
#define NS_IWIDGET_IID \
{ 0x34b6123e, 0x78d7, 0x4275, \
{ 0xa2, 0xbf, 0x07, 0xd4, 0xbf, 0x3a, 0x34, 0x45 } }
{ 0xeedce486, 0xeb2b, 0x41af, \
{ 0x9a, 0x25, 0x59, 0xd1, 0x0f, 0xd1, 0xd5, 0x6f } }
/*
* Window shadow styles
@ -285,6 +285,8 @@ class nsIWidget : public nsISupports {
*/
NS_IMETHOD SetParent(nsIWidget* aNewParent) = 0;
NS_IMETHOD RegisterTouchWindow() = 0;
NS_IMETHOD UnregisterTouchWindow() = 0;
/**
* Return the parent Widget of this Widget or nsnull if this is a

Просмотреть файл

@ -63,6 +63,12 @@ nsWinGesture::GetGestureConfigPtr nsWinGesture::getGestureConfig = nsnull;
nsWinGesture::BeginPanningFeedbackPtr nsWinGesture::beginPanningFeedback = nsnull;
nsWinGesture::EndPanningFeedbackPtr nsWinGesture::endPanningFeedback = nsnull;
nsWinGesture::UpdatePanningFeedbackPtr nsWinGesture::updatePanningFeedback = nsnull;
nsWinGesture::RegisterTouchWindowPtr nsWinGesture::registerTouchWindow = nsnull;
nsWinGesture::UnregisterTouchWindowPtr nsWinGesture::unregisterTouchWindow = nsnull;
nsWinGesture::GetTouchInputInfoPtr nsWinGesture::getTouchInputInfo = nsnull;
nsWinGesture::CloseTouchInputHandlePtr nsWinGesture::closeTouchInputHandle = nsnull;
static PRBool gEnableSingleFingerPanEvents = PR_FALSE;
nsWinGesture::nsWinGesture() :
@ -99,6 +105,10 @@ PRBool nsWinGesture::InitLibrary()
getGestureExtraArgs = (GetGestureExtraArgsPtr)GetProcAddress(sLibraryHandle, "GetGestureExtraArgs");
setGestureConfig = (SetGestureConfigPtr)GetProcAddress(sLibraryHandle, "SetGestureConfig");
getGestureConfig = (GetGestureConfigPtr)GetProcAddress(sLibraryHandle, "GetGestureConfig");
registerTouchWindow = (RegisterTouchWindowPtr)GetProcAddress(sLibraryHandle, "RegisterTouchWindow");
unregisterTouchWindow = (UnregisterTouchWindowPtr)GetProcAddress(sLibraryHandle, "UnregisterTouchWindow");
getTouchInputInfo = (GetTouchInputInfoPtr)GetProcAddress(sLibraryHandle, "GetTouchInputInfo");
closeTouchInputHandle = (CloseTouchInputHandlePtr)GetProcAddress(sLibraryHandle, "CloseTouchInputHandle");
}
if (!getGestureInfo || !closeGestureInfoHandle || !getGestureExtraArgs ||
@ -110,6 +120,13 @@ PRBool nsWinGesture::InitLibrary()
getGestureConfig = nsnull;
return PR_FALSE;
}
if (!registerTouchWindow || !unregisterTouchWindow || !getTouchInputInfo || !closeTouchInputHandle) {
registerTouchWindow = nsnull;
unregisterTouchWindow = nsnull;
getTouchInputInfo = nsnull;
closeTouchInputHandle = nsnull;
}
// panning feedback interfaces
if (hTheme) {
@ -203,6 +220,38 @@ PRBool nsWinGesture::IsAvailable()
return getGestureInfo != nsnull;
}
PRBool nsWinGesture::RegisterTouchWindow(HWND hWnd)
{
if (!registerTouchWindow)
return PR_FALSE;
return registerTouchWindow(hWnd, TWF_WANTPALM);
}
PRBool nsWinGesture::UnregisterTouchWindow(HWND hWnd)
{
if (!unregisterTouchWindow)
return PR_FALSE;
return unregisterTouchWindow(hWnd);
}
PRBool nsWinGesture::GetTouchInputInfo(HTOUCHINPUT hTouchInput, PRUint32 cInputs, PTOUCHINPUT pInputs)
{
if (!getTouchInputInfo)
return PR_FALSE;
return getTouchInputInfo(hTouchInput, cInputs, pInputs, sizeof(TOUCHINPUT));
}
PRBool nsWinGesture::CloseTouchInputHandle(HTOUCHINPUT hTouchInput)
{
if (!closeTouchInputHandle)
return PR_FALSE;
return closeTouchInputHandle(hTouchInput);
}
PRBool nsWinGesture::GetGestureInfo(HGESTUREINFO hGestureInfo, PGESTUREINFO pGestureInfo)
{
if (!getGestureInfo || !hGestureInfo || !pGestureInfo)

Просмотреть файл

@ -165,6 +165,45 @@ typedef struct tagGESTURENOTIFYSTRUCT {
#endif /* #ifndef HGESTUREINFO */
#ifndef HTOUCHINPUT // needs WINVER >= 0x0601
typedef struct _TOUCHINPUT {
LONG x;
LONG y;
HANDLE hSource;
DWORD dwID;
DWORD dwFlags;
DWORD dwMask;
DWORD dwTime;
ULONG_PTR dwExtraInfo;
DWORD cxContact;
DWORD cyContact;
} TOUCHINPUT, *PTOUCHINPUT;
typedef HANDLE HTOUCHINPUT;
#define WM_TOUCH 0x0240
#define TOUCHEVENTF_MOVE 0x0001
#define TOUCHEVENTF_DOWN 0x0002
#define TOUCHEVENTF_UP 0x0004
#define TOUCHEVENTF_INRANGE 0x0008
#define TOUCHEVENTF_PRIMARY 0x0010
#define TOUCHEVENTF_NOCOALESCE 0x0020
#define TOUCHEVENTF_PEN 0x0040
#define TOUCHEVENTF_PALM 0x0080
#define TOUCHINPUTMASKF_TIMEFROMSYSTEM 0x0001
#define TOUCHINPUTMASKF_EXTRAINFO 0x0002
#define TOUCHINPUTMASKF_CONTACTAREA 0x0004
#define TOUCH_COORD_TO_PIXEL(C) (C/100)
#define TWF_FINETOUCH 0x0001
#define TWF_WANTPALM 0x0002
#endif /* #ifndef HTOUCHINPUT */
class nsPointWin : public nsIntPoint
{
public:
@ -196,6 +235,10 @@ public:
public:
PRBool SetWinGestureSupport(HWND hWnd, nsGestureNotifyEvent::ePanDirection aDirection);
PRBool ShutdownWinGestureSupport();
PRBool RegisterTouchWindow(HWND hWnd);
PRBool UnregisterTouchWindow(HWND hWnd);
PRBool GetTouchInputInfo(HTOUCHINPUT hTouchInput, PRUint32 cInputs, PTOUCHINPUT pInputs);
PRBool CloseTouchInputHandle(HTOUCHINPUT hTouchInput);
PRBool IsAvailable();
// Simple gesture process
@ -233,6 +276,10 @@ private:
typedef BOOL (WINAPI * BeginPanningFeedbackPtr)(HWND hWnd);
typedef BOOL (WINAPI * EndPanningFeedbackPtr)(HWND hWnd, BOOL fAnimateBack);
typedef BOOL (WINAPI * UpdatePanningFeedbackPtr)(HWND hWnd, LONG offsetX, LONG offsetY, BOOL fInInertia);
typedef BOOL (WINAPI * RegisterTouchWindowPtr)(HWND hWnd, ULONG flags);
typedef BOOL (WINAPI * UnregisterTouchWindowPtr)(HWND hWnd);
typedef BOOL (WINAPI * GetTouchInputInfoPtr)(HTOUCHINPUT hTouchInput, PRUint32 cInputs, PTOUCHINPUT pInputs, PRInt32 cbSize);
typedef BOOL (WINAPI * CloseTouchInputHandlePtr)(HTOUCHINPUT hTouchInput);
// Static function pointers
static GetGestureInfoPtr getGestureInfo;
@ -243,6 +290,10 @@ private:
static BeginPanningFeedbackPtr beginPanningFeedback;
static EndPanningFeedbackPtr endPanningFeedback;
static UpdatePanningFeedbackPtr updatePanningFeedback;
static RegisterTouchWindowPtr registerTouchWindow;
static UnregisterTouchWindowPtr unregisterTouchWindow;
static GetTouchInputInfoPtr getTouchInputInfo;
static CloseTouchInputHandlePtr closeTouchInputHandle;
// Delay load info
PRBool InitLibrary();

Просмотреть файл

@ -375,6 +375,7 @@ nsWindow::nsWindow() : nsBaseWidget()
mIsTopWidgetWindow = PR_FALSE;
mUnicodeWidget = PR_TRUE;
mDisplayPanFeedback = PR_FALSE;
mTouchWindow = PR_FALSE;
mCustomNonClient = PR_FALSE;
mCompositorFlag = PR_FALSE;
mHideChrome = PR_FALSE;
@ -1287,6 +1288,49 @@ void nsWindow::SetThemeRegion()
#endif
}
/**************************************************************
*
* SECTION: nsIWidget::RegisterTouchWindow,
* nsIWidget::UnregisterTouchWindow, and helper functions
*
* Used to register the native window to receive touch events
*
**************************************************************/
NS_METHOD nsWindow::RegisterTouchWindow() {
mTouchWindow = PR_TRUE;
#ifndef WINCE
mGesture.RegisterTouchWindow(mWnd);
::EnumChildWindows(mWnd, nsWindow::RegisterTouchForDescendants, NULL);
#endif
return NS_OK;
}
NS_METHOD nsWindow::UnregisterTouchWindow() {
mTouchWindow = PR_FALSE;
#ifndef WINCE
mGesture.UnregisterTouchWindow(mWnd);
::EnumChildWindows(mWnd, nsWindow::UnregisterTouchForDescendants, NULL);
#endif
return NS_OK;
}
#ifndef WINCE
BOOL CALLBACK nsWindow::RegisterTouchForDescendants(HWND aWnd, LPARAM aMsg) {
nsWindow* win = GetNSWindowPtr(aWnd);
if (win)
win->mGesture.RegisterTouchWindow(aWnd);
return TRUE;
}
BOOL CALLBACK nsWindow::UnregisterTouchForDescendants(HWND aWnd, LPARAM aMsg) {
nsWindow* win = GetNSWindowPtr(aWnd);
if (win)
win->mGesture.UnregisterTouchWindow(aWnd);
return TRUE;
}
#endif
/**************************************************************
*
* SECTION: nsIWidget::Move, nsIWidget::Resize,
@ -5226,7 +5270,16 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM &wParam, LPARAM &lParam,
result = PR_TRUE;
*aRetValue = TABLET_ROTATE_GESTURE_ENABLE;
break;
#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_WIN7
case WM_TOUCH:
result = OnTouch(wParam, lParam);
if (result) {
*aRetValue = 0;
}
break;
#endif
case WM_GESTURE:
result = OnGesture(wParam, lParam);
break;
@ -5249,7 +5302,8 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM &wParam, LPARAM &lParam,
nsEventStatus status;
DispatchEvent(&gestureNotifyEvent, status);
mDisplayPanFeedback = gestureNotifyEvent.displayPanFeedback;
mGesture.SetWinGestureSupport(mWnd, gestureNotifyEvent.panDirection);
if (!mTouchWindow)
mGesture.SetWinGestureSupport(mWnd, gestureNotifyEvent.panDirection);
}
result = PR_FALSE; //should always bubble to DefWindowProc
}
@ -6082,6 +6136,45 @@ void nsWindow::UserActivity()
}
}
#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_WIN7
PRBool nsWindow::OnTouch(WPARAM wParam, LPARAM lParam)
{
PRUint32 cInputs = LOWORD(wParam);
PTOUCHINPUT pInputs = new TOUCHINPUT[cInputs];
if (mGesture.GetTouchInputInfo((HTOUCHINPUT)lParam, cInputs, pInputs)) {
for (PRUint32 i = 0; i < cInputs; i++) {
PRUint32 msg;
if (pInputs[i].dwFlags & TOUCHEVENTF_MOVE) {
msg = NS_MOZTOUCH_MOVE;
} else if (pInputs[i].dwFlags & TOUCHEVENTF_DOWN) {
msg = NS_MOZTOUCH_DOWN;
} else if (pInputs[i].dwFlags & TOUCHEVENTF_UP) {
msg = NS_MOZTOUCH_UP;
} else {
continue;
}
nsPointWin touchPoint;
touchPoint.x = TOUCH_COORD_TO_PIXEL(pInputs[i].x);
touchPoint.y = TOUCH_COORD_TO_PIXEL(pInputs[i].y);
touchPoint.ScreenToClient(mWnd);
nsMozTouchEvent touchEvent(PR_TRUE, msg, this, pInputs[i].dwID);
touchEvent.inputSource = nsIDOMNSMouseEvent::MOZ_SOURCE_TOUCH;
touchEvent.refPoint = touchPoint;
nsEventStatus status;
DispatchEvent(&touchEvent, status);
}
}
delete [] pInputs;
mGesture.CloseTouchInputHandle((HTOUCHINPUT)lParam);
return PR_TRUE;
}
#endif
// Gesture event processing. Handles WM_GESTURE events.
#if !defined(WINCE)
PRBool nsWindow::OnGesture(WPARAM wParam, LPARAM lParam)

Просмотреть файл

@ -188,6 +188,8 @@ public:
NS_IMETHOD GetIMEEnabled(PRUint32* aState);
NS_IMETHOD CancelIMEComposition();
NS_IMETHOD GetToggledKeyState(PRUint32 aKeyCode, PRBool* aLEDState);
NS_IMETHOD RegisterTouchWindow();
NS_IMETHOD UnregisterTouchWindow();
#ifdef MOZ_XUL
virtual void SetTransparencyMode(nsTransparencyMode aMode);
virtual nsTransparencyMode GetTransparencyMode();
@ -274,6 +276,10 @@ protected:
static BOOL CALLBACK BroadcastMsgToChildren(HWND aWnd, LPARAM aMsg);
static BOOL CALLBACK BroadcastMsg(HWND aTopWindow, LPARAM aMsg);
static BOOL CALLBACK DispatchStarvedPaints(HWND aTopWindow, LPARAM aMsg);
#if !defined(WINCE)
static BOOL CALLBACK RegisterTouchForDescendants(HWND aTopWindow, LPARAM aMsg);
static BOOL CALLBACK UnregisterTouchForDescendants(HWND aTopWindow, LPARAM aMsg);
#endif
static LRESULT CALLBACK MozSpecialMsgFilter(int code, WPARAM wParam, LPARAM lParam);
static LRESULT CALLBACK MozSpecialWndProc(int code, WPARAM wParam, LPARAM lParam);
static LRESULT CALLBACK MozSpecialMouseProc(int code, WPARAM wParam, LPARAM lParam);
@ -351,6 +357,9 @@ protected:
PRBool *aEventDispatched = nsnull);
virtual PRBool OnScroll(UINT aMsg, WPARAM aWParam, LPARAM aLParam);
PRBool OnGesture(WPARAM wParam, LPARAM lParam);
#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_WIN7
PRBool OnTouch(WPARAM wParam, LPARAM lParam);
#endif
PRBool OnHotKey(WPARAM wParam, LPARAM lParam);
BOOL OnInputLangChange(HKL aHKL);
void OnSettingsChange(WPARAM wParam, LPARAM lParam);
@ -447,6 +456,7 @@ protected:
PRPackedBool mUnicodeWidget;
PRPackedBool mPainting;
PRPackedBool mExitToNonClientArea;
PRPackedBool mTouchWindow;
PRUint32 mBlurSuppressLevel;
nsContentType mContentType;
DWORD_PTR mOldStyle;

Просмотреть файл

@ -926,6 +926,16 @@ nsBaseWidget::GetAcceleratedRendering()
return mUseAcceleratedRendering;
}
NS_METHOD nsBaseWidget::RegisterTouchWindow()
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_METHOD nsBaseWidget::UnregisterTouchWindow()
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsBaseWidget::OverrideSystemMouseScrollSpeed(PRInt32 aOriginalDelta,
PRBool aIsHorizontal,

Просмотреть файл

@ -155,6 +155,8 @@ public:
NS_IMETHOD ResizeClient(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint);
NS_IMETHOD GetNonClientMargins(nsIntMargin &margins);
NS_IMETHOD SetNonClientMargins(nsIntMargin &margins);
NS_IMETHOD RegisterTouchWindow();
NS_IMETHOD UnregisterTouchWindow();
nsPopupLevel PopupLevel() { return mPopupLevel; }