Bug 977695 - Update bubbles/cancelable attribute for pointer events. r=smaug
authorOleg Romashin <oleg.romashin@microsoft.com>
Thu, 27 Feb 2014 16:13:05 -0800
changeset 189498 dd7286173768574b2bf93314a560b492f48c40fc
parent 189497 508848ad378ac7e100f63996709f08081e8d88af
child 189499 39101e03fc13a8b7447b1555881cce5d439ba255
push id474
push userasasaki@mozilla.com
push dateMon, 02 Jun 2014 21:01:02 +0000
treeherdermozilla-release@967f4cf1b31c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs977695
milestone30.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 977695 - Update bubbles/cancelable attribute for pointer events. r=smaug
dom/events/test/test_bug822898.html
dom/events/test/test_bug967796.html
dom/webidl/EventHandler.webidl
layout/base/tests/bug970964_inner.html
widget/MouseEvents.h
widget/TouchEvents.h
--- a/dom/events/test/test_bug822898.html
+++ b/dom/events/test/test_bug822898.html
@@ -193,16 +193,17 @@ function testOnPointerProperty()
 {
   iframeBody.onpointerdown = function (e) { gOnPointerPropHandled["pointerdown"] = true; }
   iframeBody.onpointerup = function (e) { gOnPointerPropHandled["pointerup"] = true; }
   iframeBody.onpointermove = function (e) { gOnPointerPropHandled["pointermove"] = true; }
   iframeBody.onpointerout = function (e) { gOnPointerPropHandled["pointerout"] = true; }
   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");
 
   iframeBody.dispatchEvent(getDefaultArgEvent("pointerup"));
   is(gOnPointerPropHandled['pointerup'], true, "pointerup property is performed");
 
   iframeBody.dispatchEvent(getDefaultArgEvent("pointermove"));
@@ -215,16 +216,19 @@ function testOnPointerProperty()
   is(gOnPointerPropHandled['pointerover'], true, "pointerover property is performed");
 
   iframeBody.dispatchEvent(getDefaultArgEvent("pointerenter"));
   is(gOnPointerPropHandled['pointerenter'], true, "pointerenter property is performed");
 
   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();
 }
 
 function testPointerEventCTORS()
 {
   // TODO: This should go to test_eventctors.html, when PointerEvents enabled by default
   var receivedEvent;
   iframeBody.addEventListener("hello", function(e) { receivedEvent = e; }, true);
--- a/dom/events/test/test_bug967796.html
+++ b/dom/events/test/test_bug967796.html
@@ -161,34 +161,34 @@ function runTests() {
 function penter(evt) {
   ++pointerentercount;
   evt.stopPropagation();
   if (expectedPointerEnterTargets.length) {
     var t = expectedPointerEnterTargets.shift();
     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?");
   if (checkRelatedTarget && evt.target.ownerDocument == document) {
     is(evt.relatedTarget, expectedRelatedEnter, "Wrong related target (pointerenter)");
   }
 }
 
 function pleave(evt) {
   ++pointerleavecount;
   evt.stopPropagation();
   if (expectedPointerLeaveTargets.length) {
     var t = expectedPointerLeaveTargets.shift();
     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?");
   if (checkRelatedTarget && evt.target.ownerDocument == document) {
     is(evt.relatedTarget, expectedRelatedLeave, "Wrong related target (pointerleave)");
   }
 }
 
--- a/dom/webidl/EventHandler.webidl
+++ b/dom/webidl/EventHandler.webidl
@@ -85,16 +85,18 @@ interface GlobalEventHandlers {
            attribute EventHandler onsubmit;
            attribute EventHandler onsuspend;
            attribute EventHandler ontimeupdate;
            attribute EventHandler onvolumechange;
            attribute EventHandler onwaiting;
 
            // 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;
            [Pref="dom.w3c_pointer_events.enabled"]
            attribute EventHandler onpointermove;
            [Pref="dom.w3c_pointer_events.enabled"]
            attribute EventHandler onpointerout;
            [Pref="dom.w3c_pointer_events.enabled"]
--- a/layout/base/tests/bug970964_inner.html
+++ b/layout/base/tests/bug970964_inner.html
@@ -129,16 +129,18 @@ function runTests() {
   d0.onpointerdown = function(e) {
     pointerDownTriggered = 1;
     is(mouseDownTriggered, 0, "Pointer event must be triggered before mouse event!");
     is(touchDownTriggered, 0, "Pointer event must be triggered before touch event!");
   };
   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);
 
   // Test pointer event generated from mouse event
   synthesizeMouse(d1, 3, 3, { type: "mousemove"});
   synthesizeMouse(d1, 3, 3, { type: "mousedown"});
   synthesizeMouse(d1, 3, 3, { type: "mouseup"});
@@ -154,16 +156,18 @@ function runTests() {
   // Test Touch to Pointer Cancel
   sendTouchEvent(cwu, "touchcancel", event1, 0);
 
   // Check Pointer enter/leave from mouse generated event
   var mouseEnterTriggered = 0;
   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) {
     mouseEnterTriggered = 1;
     is(pointerEnterTriggered , 1, "Mouse event must be triggered after pointer event!");
   };
   synthesizeMouse(d2, 3, 3, { type: "mousemove"});
   d2.onmouseenter = function(e) {}
@@ -184,36 +188,48 @@ function runTests() {
       ++mousePointerEnterLeaveCount;
     } else if (pointerType == "touch") {
       ++touchPointerEnterLeaveCount;
     }
   };
 
   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);
   };
 
   synthesizeMouse(d1, 3, 3, { type: "mousemove"});
   sendTouchEvent(cwu, "touchmove", getTouchEventForTarget(d3, cwu, 3), 0);
   is(touchPointerEnterLeaveCount, 1, "Wrong touch enterLeave count for!");
   is(mousePointerEnterLeaveCount, 2, "Wrong mouse enterLeave count for!");
 
--- a/widget/MouseEvents.h
+++ b/widget/MouseEvents.h
@@ -571,16 +571,22 @@ public:
   }
 
   void UpdateFlags()
   {
     switch (message) {
       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;
     }
   }
 
   virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE
   {
--- a/widget/TouchEvents.h
+++ b/widget/TouchEvents.h
@@ -144,23 +144,25 @@ public:
 
   WidgetTouchEvent(const WidgetTouchEvent& aOther) :
     WidgetInputEvent(aOther.mFlags.mIsTrusted, aOther.message, aOther.widget,
                      NS_TOUCH_EVENT)
   {
     modifiers = aOther.modifiers;
     time = aOther.time;
     touches.AppendElements(aOther.touches);
+    mFlags.mCancelable = message != NS_TOUCH_CANCEL;
     MOZ_COUNT_CTOR(WidgetTouchEvent);
   }
 
   WidgetTouchEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget) :
     WidgetInputEvent(aIsTrusted, aMessage, aWidget, NS_TOUCH_EVENT)
   {
     MOZ_COUNT_CTOR(WidgetTouchEvent);
+    mFlags.mCancelable = message != NS_TOUCH_CANCEL;
   }
 
   virtual ~WidgetTouchEvent()
   {
     MOZ_COUNT_DTOR(WidgetTouchEvent);
   }
 
   virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE