Bug 663829 Checkboxes are difficult to check on Gmail r=wesj
authorBenjamin Stover <bstover@mozilla.com>
Thu, 23 Jun 2011 18:51:02 -0700
changeset 71614 daf896f89f39cbe8c2e55cdda39381f9e4ba4f5d
parent 71613 4ab18b537543e945f6c272a4ae49fe1c0840ab09
child 71615 fc9192d3a551be57edad8a9f9385d9d38cdbd9c0
push id213
push userbstover@mozilla.com
push dateFri, 24 Jun 2011 01:53:46 +0000
treeherdermozilla-inbound@fc9192d3a551 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswesj
bugs663829
milestone7.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 663829 Checkboxes are difficult to check on Gmail r=wesj
mobile/chrome/content/content.js
--- a/mobile/chrome/content/content.js
+++ b/mobile/chrome/content/content.js
@@ -616,30 +616,35 @@ let Content = {
 
   _cancelTapHighlight: function _cancelTapHighlight(aElement) {
     gDOMUtils.setContentState(content.document.documentElement, kStateActive);
     this._highlightElement = null;
   },
 
   _sendMouseEvent: function _sendMouseEvent(aName, aElement, aX, aY, aButton) {
     // the element can be out of the aX/aY point because of the touch radius
+    // if outside, we gracefully move the touch point to the center of the element
     if (!(aElement instanceof HTMLHtmlElement)) {
       let isTouchClick = true;
       let rects = getContentClientRects(aElement);
       for (let i = 0; i < rects.length; i++) {
         let rect = rects[i];
-        if ((aX > rect.left && aX < (rect.left + rect.width)) &&
-            (aY > rect.top && aY < (rect.top + rect.height))) {
+        // We might be able to deal with fractional pixels, but mouse events won't.
+        // Deflate the bounds in by 1 pixel to deal with any fractional scroll offset issues.
+        let inBounds = 
+          (aX > rect.left + 1 && aX < (rect.left + rect.width - 1)) &&
+          (aY > rect.top + 1 && aY < (rect.top + rect.height - 1));
+        if (inBounds) {
           isTouchClick = false;
           break;
         }
       }
 
       if (isTouchClick) {
-        let rect = new Rect(rects[0]);
+        let rect = new Rect(rects[0].left, rects[0].top, rects[0].width, rects[0].height);
         if (rect.isEmpty())
           return;
 
         let point = rect.center();
         aX = point.x;
         aY = point.y;
       }
     }