Bug 977695 - Update bubbles/cancelable attribute for pointer events. r=smaug

This commit is contained in:
Oleg Romashin 2014-02-27 16:13:05 -08:00
Родитель f3ddd05d72
Коммит 29f215877a
6 изменённых файлов: 32 добавлений и 2 удалений

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

@ -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();
}

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

@ -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?");

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

@ -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;

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

@ -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);
};

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

@ -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;

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

@ -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()