Bug 865452 - Don't capture scripted mouse events. r=yzen
authorEitan Isaacson <eitan@monotonous.org>
Thu, 25 Apr 2013 12:39:16 -0700
changeset 129954 38cac63b52b382b318500dab23c437388b3fcc33
parent 129953 866cf655cfd1efa43ac754d28da956294df09234
child 129955 81ed682e7724256d3effe7e9591727a9bf966c2a
push id1552
push userttaubert@mozilla.com
push dateSat, 27 Apr 2013 15:33:29 +0000
treeherderfx-team@40dafc376794 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersyzen
bugs865452
milestone23.0a1
Bug 865452 - Don't capture scripted mouse events. r=yzen
accessible/src/jsat/TouchAdapter.jsm
accessible/src/jsat/content-script.js
--- a/accessible/src/jsat/TouchAdapter.jsm
+++ b/accessible/src/jsat/TouchAdapter.jsm
@@ -101,16 +101,20 @@ this.TouchAdapter = {
 
   handleEvent: function TouchAdapter_handleEvent(aEvent) {
     // Don't bother with chrome mouse events.
     if (Utils.MozBuildApp == 'browser' &&
         aEvent.view.top instanceof Ci.nsIDOMChromeWindow) {
       return;
     }
 
+    if (aEvent.mozInputSource == Ci.nsIDOMMouseEvent.MOZ_SOURCE_UNKNOWN) {
+      return;
+    }
+
     if (this._delayedEvent) {
       Utils.win.clearTimeout(this._delayedEvent);
       delete this._delayedEvent;
     }
 
     let changedTouches = aEvent.changedTouches || [aEvent];
 
     // XXX: Until bug 77992 is resolved, on desktop we get microseconds
--- a/accessible/src/jsat/content-script.js
+++ b/accessible/src/jsat/content-script.js
@@ -116,20 +116,27 @@ function activateCurrent(aMessage) {
       docAcc.getBounds(docX, docY, docW, docH);
 
       let objX = {}, objY = {}, objW = {}, objH = {};
       aAccessible.getBounds(objX, objY, objW, objH);
 
       let x = Math.round((objX.value - docX.value) + objW.value / 2);
       let y = Math.round((objY.value - docY.value) + objH.value / 2);
 
-      let cwu = content.QueryInterface(Ci.nsIInterfaceRequestor).
-        getInterface(Ci.nsIDOMWindowUtils);
-      cwu.sendMouseEventToWindow('mousedown', x, y, 0, 1, 0, false);
-      cwu.sendMouseEventToWindow('mouseup', x, y, 0, 1, 0, false);
+      let node = aAccessible.DOMNode || aAccessible.parent.DOMNode;
+
+      function dispatchMouseEvent(aEventType) {
+        let evt = content.document.createEvent("MouseEvents");
+        evt.initMouseEvent(aEventType, true, true, content,
+                           x, y, 0, 0, 0, false, false, false, false, 0, null);
+        node.dispatchEvent(evt);
+      }
+
+      dispatchMouseEvent("mousedown");
+      dispatchMouseEvent("mouseup");
     }
   }
 
   let vc = Utils.getVirtualCursor(content.document);
   if (!forwardMessage(vc, aMessage))
     activateAccessible(vc.position);
 }