Bug 891882 - Fix OOP touch events support on b2g desktop. r=vingtetun
authorFabrice Desré <fabrice@mozilla.com>
Wed, 15 Jan 2014 09:28:04 -0500
changeset 163554 539b03915ad71679d2594c4887941af3c3a448af
parent 163553 16494b084901f84486f811a726a74a5f55112856
child 163555 469a0feafe5fff72db0d3471177f6e793eecd6d1
push id26000
push userryanvm@gmail.com
push dateWed, 15 Jan 2014 19:25:40 +0000
treeherdermozilla-central@dc057466d219 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvingtetun
bugs891882
milestone29.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 891882 - Fix OOP touch events support on b2g desktop. r=vingtetun
toolkit/devtools/touch-events.js
--- a/toolkit/devtools/touch-events.js
+++ b/toolkit/devtools/touch-events.js
@@ -173,16 +173,36 @@ function TouchEventHandler (window) {
       let timeout = content.setTimeout((function contextMenu() {
         target.dispatchEvent(evt);
         this.cancelClick = true;
       }).bind(this), delay);
 
       return timeout;
     },
     sendTouchEvent: function teh_sendTouchEvent(evt, target, name) {
+      // When running OOP b2g desktop, we need to send the touch events
+      // using the mozbrowser api on the unwrapped frame.
+      if (target.localName == "iframe" && target.mozbrowser === true) {
+        if (name == "touchstart") {
+          this.touchstartTime = Date.now();
+        } else if (name == "touchend") {
+          // If we have a 'fast' tap, don't send a click as both will be turned
+          // into a click and that breaks eg. checkboxes.
+          if (Date.now() - this.touchstartTime < delay) {
+            this.cancelClick = true;
+          }
+        }
+        let unwraped = XPCNativeWrapper.unwrap(target);
+        unwraped.sendTouchEvent(name, [0],                    // event type, id
+                                [evt.clientX], [evt.clientY], // x, y
+                                [1], [1],                     // rx, ry
+                                [0], [0],                     // rotation, force
+                                1);                           // count
+        return;
+      }
       let document = target.ownerDocument;
       let content = this.getContent(target);
 
       let touchEvent = document.createEvent('touchevent');
       let point = document.createTouch(content, target, 0,
                                        evt.pageX, evt.pageY,
                                        evt.screenX, evt.screenY,
                                        evt.clientX, evt.clientY,