Bug 974138 - Dispatch PointerEnter on PointerDown. r=smaug
authorOleg Romashin <oleg.romashin@microsoft.com>
Thu, 20 Feb 2014 20:06:07 -0800
changeset 170176 e36575f8b202d030e542dda38afd2a2c54eed8fa
parent 170175 e7349662e30535552cf7573a94bc8b46c5b4eb31
child 170177 7710a7b9f8409930aef6a06d875ec64313799236
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewerssmaug
bugs974138
milestone30.0a1
Bug 974138 - Dispatch PointerEnter on PointerDown. r=smaug
dom/events/nsEventStateManager.cpp
dom/events/test/test_bug967796.html
--- a/dom/events/nsEventStateManager.cpp
+++ b/dom/events/nsEventStateManager.cpp
@@ -1107,16 +1107,17 @@ nsEventStateManager::PreHandleEvent(nsPr
       // then fall through...
     } else {
       GenerateMouseEnterExit(mouseEvent);
       //This is a window level mouse exit event and should stop here
       aEvent->message = 0;
       break;
     }
   case NS_MOUSE_MOVE:
+  case NS_POINTER_DOWN:
   case NS_POINTER_MOVE: {
     // on the Mac, GenerateDragGesture() may not return until the drag
     // has completed and so |aTargetFrame| may have been deleted (moving
     // a bookmark, for example).  If this is the case, however, we know
     // that ClearFrameRefs() has been called and it cleared out
     // |mCurrentTarget|. As a result, we should pass |mCurrentTarget|
     // into UpdateCursor().
     GenerateDragGesture(aPresContext, mouseEvent);
@@ -4418,16 +4419,17 @@ nsEventStateManager::GenerateMouseEnterE
         aMouseEvent->lastRefPoint = sLastRefPoint;
       }
 
       // Update the last known refPoint with the current refPoint.
       sLastRefPoint = aMouseEvent->refPoint;
 
     }
   case NS_POINTER_MOVE:
+  case NS_POINTER_DOWN:
     {
       // Get the target content target (mousemove target == mouseover target)
       nsCOMPtr<nsIContent> targetElement = GetEventTargetContent(aMouseEvent);
       if (!targetElement) {
         // We're always over the document root, even if we're only
         // over dead space in a page (whose frame is not associated with
         // any content) or in print preview dead space
         targetElement = mDocument->GetRootElement();
--- a/dom/events/test/test_bug967796.html
+++ b/dom/events/test/test_bug967796.html
@@ -129,16 +129,35 @@ function runTests() {
   synthesizePointer(iframe.contentDocument.body, r.width / 2, r.height - (r.height / 4), {type: "pointermove"},
                     iframe.contentWindow);
   is(pointerentercount, 7, "Unexpected pointerenter event count!");
   expectedRelatedEnter = iframe;
   expectedRelatedLeave = outside;
   sendPointerEvent("pointermove", outside);
   is(pointerleavecount, 7, "Unexpected pointerleave event count!");
 
+  // pointerdown must produce pointerenter event
+  expectedRelatedEnter = outside;
+  expectedRelatedLeave = iframe;
+  // Move pointer inside the iframe.
+  synthesizePointer(iframe.contentDocument.body, r.width / 2, r.height / 4, {type: "pointerdown"},
+                    iframe.contentWindow);
+  synthesizePointer(iframe.contentDocument.body, r.width / 2, r.height - (r.height / 4), {type: "pointerdown"},
+                    iframe.contentWindow);
+  is(pointerentercount, 10, "Unexpected pointerenter event count!");
+
+  // pointerdown + pointermove must produce single pointerenter event
+  expectedRelatedEnter = outside;
+  expectedRelatedLeave = iframe;
+  synthesizePointer(iframe.contentDocument.body, r.width / 2, r.height / 4, {type: "pointerdown"},
+                    iframe.contentWindow);
+  synthesizePointer(iframe.contentDocument.body, r.width / 2 + 1, r.height / 4 + 1, {type: "pointermove"},
+                    iframe.contentWindow);
+  is(pointerentercount, 11, "Unexpected pointerenter event count!");
+
   SpecialPowers.clearUserPref("dom.w3c_pointer_events.enabled");      // Disable Pointer Events
 
   SimpleTest.finish();
 }
 
 function penter(evt) {
   ++pointerentercount;
   evt.stopPropagation();