Bug 436059: work around dblclick events not firing on the n810, and fix zoomToElement while panned, r=stuart
authorGavin Sharp <gavin@mozilla.com>
Fri, 11 Jul 2008 21:22:12 -0400
changeset 54 cc6f9da463bd
parent 53 beb56c6cafc7
child 55 e1c51f010542
push id41
push usergsharp@mozilla.com
push date2008-07-12 01:23 +0000
reviewersstuart
bugs436059
Bug 436059: work around dblclick events not firing on the n810, and fix zoomToElement while panned, r=stuart
chrome/content/deckbrowser.xml
--- a/chrome/content/deckbrowser.xml
+++ b/chrome/content/deckbrowser.xml
@@ -29,17 +29,18 @@
 
         // panning
         this._stack.addEventListener("mousedown", this.stackEventHandler, true);
         // need mouseup handled on the window to catch mouseups on e.g. the toolbar
         window.addEventListener("mouseup", this.stackEventHandler, true);
         this._stack.addEventListener("mousemove", this.stackEventHandler, true);
 
         // zoom
-        this._stack.addEventListener("dblclick", this.stackEventHandler, true);
+        // FIXME: dblclicks don't work on the device
+        // this._stack.addEventListener("dblclick", this.stackEventHandler, true);
         this._stack.addEventListener("DOMMouseScroll", this.stackEventHandler, true);
 
         this._dragStartTimeout = -1;
       </constructor>
 
       <field name="dragData">
         ({
           dragging: false,
@@ -152,17 +153,18 @@
         <parameter name="aX"/>
         <parameter name="aY"/>
         <body><![CDATA[
           var cdoc = this.browser.contentDocument;
 
           // Need to adjust for the toolbar height, etc.
           var browserTop = this.browser.getBoundingClientRect().top;
 
-          return cdoc.elementFromPoint(aX, aY - browserTop);
+          return cdoc.elementFromPoint((aX / this._zoomLevel) + this.dragData.pageX,
+                                       (aY / this._zoomLevel) + this.dragData.pageY - browserTop);
         ]]></body>
       </method>
 
       <method name="zoomToElement">
         <parameter name="aElement"/>
         <body><![CDATA[
           const margin = 0;
 
@@ -394,16 +396,28 @@
               // cancel scrollStart timer
               clearTimeout(this.deckbrowser._dragStartTimeout);
               this.deckbrowser._dragStartTimeout = -1;
 
               // send mousedown & mouseup
               this.deckbrowser._redispatchMouseEvent(this._lastMouseDown);
               this._lastMouseDown = null;
               this.deckbrowser._redispatchMouseEvent(aEvent);
+
+              // FIXME: dblclick events don't fire on the n810, check to see if
+              // we should treat this as a double-click
+              if (this._lastMouseUp &&
+                  (aEvent.timeStamp - this._lastMouseUp.timeStamp) < 400 &&
+                  Math.abs(aEvent.clientX - this._lastMouseUp.clientX) < 30 &&
+                  Math.abs(aEvent.clientY - this._lastMouseUp.clientY) < 30) {
+                this.dblclick(aEvent);
+                return;
+              }
+
+              this._lastMouseUp = aEvent;
             }
           },
 
           mousemove: function seh_mousemove(aEvent) {
             if (!this.deckbrowser.dragData.dragging) {
               // If we've moved more than N pixels lets go ahead and assume we're dragging
               // and not wait for the timeout to complete.
               if (this.deckbrowser._dragStartTimeout != -1 &&