Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/fast/events/pointerevents/mouse-pointer-capture.html |
| diff --git a/third_party/WebKit/LayoutTests/fast/events/pointerevents/mouse-pointer-capture.html b/third_party/WebKit/LayoutTests/fast/events/pointerevents/mouse-pointer-capture.html |
| index 09fddcc5c56c2769e4e1a7f77e077a3332768d1a..869b77031ef2d630bc6e469144f31b7aa4c34c9e 100644 |
| --- a/third_party/WebKit/LayoutTests/fast/events/pointerevents/mouse-pointer-capture.html |
| +++ b/third_party/WebKit/LayoutTests/fast/events/pointerevents/mouse-pointer-capture.html |
| @@ -41,6 +41,56 @@ var rect = document.getElementById("blue").getBoundingClientRect(); |
| var x3 = rect.left + 5; |
| var y3 = rect.top + 5; |
| +var lastPointerEvent = null; |
| +var pointereventProperties = [ |
| + "clientX", |
| + "clientY", |
| + "layerX", |
| + "layerY", |
| + "movementX", |
| + "movementY", |
| + "offsetX", |
| + "offsetY", |
| + "pageX", |
| + "pageY", |
| + "screenX", |
| + "screenY", |
| + "x", |
| + "y", |
| + "button", |
| + "buttons", |
| + "pressure", |
| + "tiltX", |
| + "tiltY", |
| + "width", |
| + "height" |
| +]; |
| + |
| +function checkPointerCaptureProperties(lastPointerEvent, currentPointerEvent) { |
| + if (lastPointerEvent == null) |
| + return false; |
| + |
| + var isImmediateRelease = (lastPointerEvent.type == 'pointerup') && |
| + (currentPointerEvent.type == 'lostpointercapture'); |
| + var isDelayedCapture = lastPointerEvent.type.includes('pointercapture'); |
| + var isImplicitReleaseOutside = implicitReleaseOutside && |
| + (currentPointerEvent.type == 'lostpointercapture'); |
| + |
| + if (!isImmediateRelease && !isDelayedCapture && !isImplicitReleaseOutside) |
| + return false; |
|
mustaq
2016/08/04 21:43:05
Can't it be simpler? Why not return false for all
Navid Zolghadr
2016/08/05 14:26:08
I cannot imagine a way to make it simpler. Note th
mustaq
2016/08/05 15:51:22
Does the following miss any cases?
For any curren
Navid Zolghadr
2016/08/05 17:08:03
I removed one of the cases as we discussed offline
|
| + |
| + for (var i = 0; i< pointereventProperties. length; i++) { |
| + var property = pointereventProperties[i]; |
| + if (lastPointerEvent[property] !== currentPointerEvent[property]) { |
| + debug("Capture pointer event attributes are incorrect!"); |
| + return true; |
| + } |
| + } |
| + |
| + debug("Capture pointer event attributes are correct!"); |
| + return true |
| +} |
| + |
| function init() { |
| var eventList = ["mouseenter", "mouseleave", "mouseover", "mouseout", "mousemove", "mousedown", "mouseup", |
| "pointerenter", "pointerleave", "pointerover", "pointerout", "pointermove", "pointerdown", "pointerup", |
| @@ -49,6 +99,7 @@ function init() { |
| document.addEventListener("lostpointercapture", function(event) { |
| if (event.eventPhase == Event.AT_TARGET) { |
| debug("document received " + event.type); |
| + lastPointerEvent = event; |
| } |
| }); |
| ["grey", "green", "blue"].forEach(function(id) { |
| @@ -73,6 +124,12 @@ function init() { |
| removeElement = false; |
| } |
| } |
| + if (checkPointerCaptureProperties(lastPointerEvent, event)) { |
| + lastPointerEvent = null; |
| + } else { |
| + if (event.type.includes('pointer')) |
| + lastPointerEvent = event; |
| + } |
| } |
| }); |
| }); |