Bug 822898 - Implement pointer events. Basic handling of Pointer Events. r=smaug

This commit is contained in:
Oleg Romashin 2013-11-20 13:05:41 -08:00
parent 4f81ba4a69
commit e4ee1caecb
6 changed files with 31 additions and 0 deletions

View File

@ -145,6 +145,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDOMEvent)
case NS_MOUSE_SCROLL_EVENT:
case NS_WHEEL_EVENT:
case NS_SIMPLE_GESTURE_EVENT:
case NS_POINTER_EVENT:
tmp->mEvent->AsMouseEventBase()->relatedTarget = nullptr;
break;
case NS_DRAG_EVENT: {
@ -182,6 +183,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsDOMEvent)
case NS_MOUSE_SCROLL_EVENT:
case NS_WHEEL_EVENT:
case NS_SIMPLE_GESTURE_EVENT:
case NS_POINTER_EVENT:
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mEvent->relatedTarget");
cb.NoteXPCOMChild(tmp->mEvent->AsMouseEventBase()->relatedTarget);
break;
@ -738,6 +740,21 @@ nsDOMEvent::DuplicatePrivateData()
newEvent = touchEvent;
break;
}
case NS_POINTER_EVENT:
{
WidgetPointerEvent* oldPointerEvent = mEvent->AsPointerEvent();
WidgetPointerEvent* pointerEvent =
new WidgetPointerEvent(false, msg, nullptr,
oldPointerEvent->pointerId,
oldPointerEvent->width,
oldPointerEvent->height,
oldPointerEvent->tiltX,
oldPointerEvent->tiltY,
oldPointerEvent->isPrimary);
pointerEvent->buttons = oldPointerEvent->buttons;
newEvent = pointerEvent;
break;
}
default:
{
NS_WARNING("Unknown event type!!!");
@ -1022,6 +1039,7 @@ nsDOMEvent::GetScreenCoords(nsPresContext* aPresContext,
(aEvent->eventStructType != NS_MOUSE_EVENT &&
aEvent->eventStructType != NS_MOUSE_SCROLL_EVENT &&
aEvent->eventStructType != NS_WHEEL_EVENT &&
aEvent->eventStructType != NS_POINTER_EVENT &&
aEvent->eventStructType != NS_TOUCH_EVENT &&
aEvent->eventStructType != NS_DRAG_EVENT &&
aEvent->eventStructType != NS_SIMPLE_GESTURE_EVENT)) {
@ -1081,6 +1099,7 @@ nsDOMEvent::GetClientCoords(nsPresContext* aPresContext,
aEvent->eventStructType != NS_WHEEL_EVENT &&
aEvent->eventStructType != NS_TOUCH_EVENT &&
aEvent->eventStructType != NS_DRAG_EVENT &&
aEvent->eventStructType != NS_POINTER_EVENT &&
aEvent->eventStructType != NS_SIMPLE_GESTURE_EVENT) ||
!aPresContext ||
!aEvent->AsGUIEvent()->widget) {

View File

@ -62,6 +62,7 @@ nsDOMMouseEvent::InitMouseEvent(const nsAString & aType, bool aCanBubble, bool a
case NS_MOUSE_SCROLL_EVENT:
case NS_WHEEL_EVENT:
case NS_DRAG_EVENT:
case NS_POINTER_EVENT:
case NS_SIMPLE_GESTURE_EVENT: {
WidgetMouseEventBase* mouseEventBase = mEvent->AsMouseEventBase();
mouseEventBase->relatedTarget = aRelatedTarget;
@ -115,6 +116,7 @@ nsDOMMouseEvent::InitMouseEvent(const nsAString& aType,
case NS_MOUSE_SCROLL_EVENT:
case NS_WHEEL_EVENT:
case NS_DRAG_EVENT:
case NS_POINTER_EVENT:
case NS_SIMPLE_GESTURE_EVENT:
mEvent->AsInputEvent()->modifiers = modifiers;
return NS_OK;
@ -145,6 +147,7 @@ nsDOMMouseEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
case NS_MOUSE_SCROLL_EVENT:
case NS_WHEEL_EVENT:
case NS_DRAG_EVENT:
case NS_POINTER_EVENT:
case NS_SIMPLE_GESTURE_EVENT:
e->mEvent->AsMouseEventBase()->buttons = aParam.mButtons;
break;
@ -192,6 +195,7 @@ nsDOMMouseEvent::Button()
case NS_MOUSE_SCROLL_EVENT:
case NS_WHEEL_EVENT:
case NS_DRAG_EVENT:
case NS_POINTER_EVENT:
case NS_SIMPLE_GESTURE_EVENT:
return mEvent->AsMouseEventBase()->button;
default:
@ -217,6 +221,7 @@ nsDOMMouseEvent::Buttons()
case NS_MOUSE_SCROLL_EVENT:
case NS_WHEEL_EVENT:
case NS_DRAG_EVENT:
case NS_POINTER_EVENT:
case NS_SIMPLE_GESTURE_EVENT:
return mEvent->AsMouseEventBase()->buttons;
default:
@ -242,6 +247,7 @@ nsDOMMouseEvent::GetRelatedTarget()
case NS_MOUSE_SCROLL_EVENT:
case NS_WHEEL_EVENT:
case NS_DRAG_EVENT:
case NS_POINTER_EVENT:
case NS_SIMPLE_GESTURE_EVENT:
relatedTarget =
do_QueryInterface(mEvent->AsMouseEventBase()->relatedTarget);

View File

@ -119,6 +119,7 @@ nsDOMUIEvent::GetMovementPoint()
mEvent->eventStructType != NS_MOUSE_SCROLL_EVENT &&
mEvent->eventStructType != NS_WHEEL_EVENT &&
mEvent->eventStructType != NS_DRAG_EVENT &&
mEvent->eventStructType != NS_POINTER_EVENT &&
mEvent->eventStructType != NS_SIMPLE_GESTURE_EVENT) ||
!mEvent->AsGUIEvent()->widget) {
return nsIntPoint(0, 0);
@ -300,6 +301,7 @@ nsDOMUIEvent::GetLayerPoint() const
(mEvent->eventStructType != NS_MOUSE_EVENT &&
mEvent->eventStructType != NS_MOUSE_SCROLL_EVENT &&
mEvent->eventStructType != NS_WHEEL_EVENT &&
mEvent->eventStructType != NS_POINTER_EVENT &&
mEvent->eventStructType != NS_TOUCH_EVENT &&
mEvent->eventStructType != NS_DRAG_EVENT &&
mEvent->eventStructType != NS_SIMPLE_GESTURE_EVENT) ||

View File

@ -46,6 +46,7 @@ public:
aEvent->eventStructType != NS_MOUSE_SCROLL_EVENT &&
aEvent->eventStructType != NS_WHEEL_EVENT &&
aEvent->eventStructType != NS_DRAG_EVENT &&
aEvent->eventStructType != NS_POINTER_EVENT &&
aEvent->eventStructType != NS_SIMPLE_GESTURE_EVENT)) {
return nsIntPoint(0, 0);
}
@ -71,6 +72,7 @@ public:
aEvent->eventStructType != NS_MOUSE_SCROLL_EVENT &&
aEvent->eventStructType != NS_WHEEL_EVENT &&
aEvent->eventStructType != NS_DRAG_EVENT &&
aEvent->eventStructType != NS_POINTER_EVENT &&
aEvent->eventStructType != NS_SIMPLE_GESTURE_EVENT) ||
!aPresContext ||
!aEvent->AsGUIEvent()->widget) {

View File

@ -1469,6 +1469,7 @@ nsLayoutUtils::GetEventCoordinatesRelativeTo(const WidgetEvent* aEvent,
aEvent->eventStructType != NS_WHEEL_EVENT &&
aEvent->eventStructType != NS_DRAG_EVENT &&
aEvent->eventStructType != NS_SIMPLE_GESTURE_EVENT &&
aEvent->eventStructType != NS_POINTER_EVENT &&
aEvent->eventStructType != NS_GESTURENOTIFY_EVENT &&
aEvent->eventStructType != NS_TOUCH_EVENT &&
aEvent->eventStructType != NS_QUERY_CONTENT_EVENT))

View File

@ -216,6 +216,7 @@ WidgetEvent::IsAllowedToDispatchDOMEvent() const
{
switch (eventStructType) {
case NS_MOUSE_EVENT:
case NS_POINTER_EVENT:
// We want synthesized mouse moves to cause mouseover and mouseout
// DOM events (nsEventStateManager::PreHandleEvent), but not mousemove
// DOM events.