From 29f215877ad4591bc2c0380f246733f632e463ed Mon Sep 17 00:00:00 2001 From: Oleg Romashin Date: Thu, 27 Feb 2014 16:13:05 -0800 Subject: [PATCH] Bug 977695 - Update bubbles/cancelable attribute for pointer events. r=smaug --- dom/events/test/test_bug822898.html | 4 ++++ dom/events/test/test_bug967796.html | 4 ++-- dom/webidl/EventHandler.webidl | 2 ++ layout/base/tests/bug970964_inner.html | 16 ++++++++++++++++ widget/MouseEvents.h | 6 ++++++ widget/TouchEvents.h | 2 ++ 6 files changed, 32 insertions(+), 2 deletions(-) diff --git a/dom/events/test/test_bug822898.html b/dom/events/test/test_bug822898.html index f6e71cc0f602..36f1c6555a6a 100644 --- a/dom/events/test/test_bug822898.html +++ b/dom/events/test/test_bug822898.html @@ -198,6 +198,7 @@ function testOnPointerProperty() iframeBody.onpointerover = function (e) { gOnPointerPropHandled["pointerover"] = true; } iframeBody.onpointerenter = function (e) { gOnPointerPropHandled["pointerenter"] = true; } iframeBody.onpointerleave = function (e) { gOnPointerPropHandled["pointerleave"] = true; } + iframeBody.onpointercancel = function (e) { gOnPointerPropHandled["pointercancel"] = true; } iframeBody.dispatchEvent(getDefaultArgEvent("pointerdown")); is(gOnPointerPropHandled['pointerdown'], true, "pointerdown property is performed"); @@ -220,6 +221,9 @@ function testOnPointerProperty() iframeBody.dispatchEvent(getDefaultArgEvent("pointerleave")); is(gOnPointerPropHandled['pointerleave'], true, "pointerleave property is performed"); + iframeBody.dispatchEvent(getDefaultArgEvent("pointercancel")); + is(gOnPointerPropHandled['pointercancel'], true, "pointercancel property is performed"); + nextTest(); } diff --git a/dom/events/test/test_bug967796.html b/dom/events/test/test_bug967796.html index c27d4ed01293..7f75db8c8858 100644 --- a/dom/events/test/test_bug967796.html +++ b/dom/events/test/test_bug967796.html @@ -166,7 +166,7 @@ function penter(evt) { is(evt.target.id, t, "Wrong event target!"); } is(evt.bubbles, false, evt.type + " should not bubble!"); - is(evt.cancelable, true, evt.type + " is cancelable!"); + is(evt.cancelable, false, evt.type + " is cancelable!"); is(evt.target, evt.currentTarget, "Wrong event target!"); ok(!evt.relatedTarget || evt.target.ownerDocument == evt.relatedTarget.ownerDocument, "Leaking nodes to another document?"); @@ -183,7 +183,7 @@ function pleave(evt) { is(evt.target.id, t, "Wrong event target!"); } is(evt.bubbles, false, evt.type + " should not bubble!"); - is(evt.cancelable, true, evt.type + " is cancelable!"); + is(evt.cancelable, false, evt.type + " is cancelable!"); is(evt.target, evt.currentTarget, "Wrong event target!"); ok(!evt.relatedTarget || evt.target.ownerDocument == evt.relatedTarget.ownerDocument, "Leaking nodes to another document?"); diff --git a/dom/webidl/EventHandler.webidl b/dom/webidl/EventHandler.webidl index ee3c0eda44b0..6eceffc4a533 100644 --- a/dom/webidl/EventHandler.webidl +++ b/dom/webidl/EventHandler.webidl @@ -90,6 +90,8 @@ interface GlobalEventHandlers { // Pointer events handlers [Pref="dom.w3c_pointer_events.enabled"] + attribute EventHandler onpointercancel; + [Pref="dom.w3c_pointer_events.enabled"] attribute EventHandler onpointerdown; [Pref="dom.w3c_pointer_events.enabled"] attribute EventHandler onpointerup; diff --git a/layout/base/tests/bug970964_inner.html b/layout/base/tests/bug970964_inner.html index 24c3e1625e49..a9cba2916052 100644 --- a/layout/base/tests/bug970964_inner.html +++ b/layout/base/tests/bug970964_inner.html @@ -134,6 +134,8 @@ function runTests() { d0.addEventListener("pointercancel", function(ev) { d0.removeEventListener("pointercancel", arguments.callee, false); is(ev.pointerId, 0, "Correct default pointerId"); + is(ev.bubbles, true, "bubbles should be true"); + is(ev.cancelable, false, "pointercancel cancelable should be false "); pointerCancelTriggered = 1; is(touchCancelTriggered, 0, "Pointer event must be triggered before touch event!"); }, false); @@ -159,6 +161,8 @@ function runTests() { var pointerEnterTriggered = 0; d2.onpointerenter = function(e) { pointerEnterTriggered = 1; + is(e.bubbles, false, "bubbles should be false"); + is(e.cancelable, false, "cancelable should be false"); is(mouseEnterTriggered, 0, "Pointer event must be triggered before mouse event!"); }; d2.onmouseenter = function(e) { @@ -189,26 +193,38 @@ function runTests() { d1.onpointerenter = function(e) { ++d1enterCount; + is(e.bubbles, false, "bubbles should be false"); + is(e.cancelable, false, "cancelable should be false"); checkPointerType(e.pointerType); }; d2.onpointerenter = function(e) { ++d2enterCount; + is(e.bubbles, false, "bubbles should be false"); + is(e.cancelable, false, "cancelable should be false"); checkPointerType(e.pointerType); }; d3.onpointerenter = function(e) { ++d3enterCount; + is(e.bubbles, false, "bubbles should be false"); + is(e.cancelable, false, "cancelable should be false"); checkPointerType(e.pointerType); }; d1.onpointerleave = function(e) { ++d1leaveCount; + is(e.bubbles, false, "bubbles should be false"); + is(e.cancelable, false, "cancelable should be false"); checkPointerType(e.pointerType); }; d2.onpointerleave = function(e) { ++d2leaveCount; + is(e.bubbles, false, "bubbles should be false"); + is(e.cancelable, false, "cancelable should be false"); checkPointerType(e.pointerType); }; d3.onpointerleave = function(e) { ++d3leaveCount; + is(e.bubbles, false, "bubbles should be false"); + is(e.cancelable, false, "cancelable should be false"); checkPointerType(e.pointerType); }; diff --git a/widget/MouseEvents.h b/widget/MouseEvents.h index 828d45f794b3..a5c9f19aa9cf 100644 --- a/widget/MouseEvents.h +++ b/widget/MouseEvents.h @@ -576,6 +576,12 @@ public: case NS_POINTER_ENTER: case NS_POINTER_LEAVE: mFlags.mBubbles = false; + mFlags.mCancelable = false; + break; + case NS_POINTER_CANCEL: + case NS_POINTER_GOT_CAPTURE: + case NS_POINTER_LOST_CAPTURE: + mFlags.mCancelable = false; break; default: break; diff --git a/widget/TouchEvents.h b/widget/TouchEvents.h index 2b1be1c4edc4..33375a9973ee 100644 --- a/widget/TouchEvents.h +++ b/widget/TouchEvents.h @@ -149,6 +149,7 @@ public: modifiers = aOther.modifiers; time = aOther.time; touches.AppendElements(aOther.touches); + mFlags.mCancelable = message != NS_TOUCH_CANCEL; MOZ_COUNT_CTOR(WidgetTouchEvent); } @@ -156,6 +157,7 @@ public: WidgetInputEvent(aIsTrusted, aMessage, aWidget, NS_TOUCH_EVENT) { MOZ_COUNT_CTOR(WidgetTouchEvent); + mFlags.mCancelable = message != NS_TOUCH_CANCEL; } virtual ~WidgetTouchEvent()