Bug 515362: Links are not followed on first click [r=mark.finkle]
authorVivien Nicolas <21@vingtetun.org>
Tue, 15 Sep 2009 13:09:47 -0400
changeset 65562 f5e2c361cdcb69be1b9d92dbfc9f48837e1de188
parent 65561 97ee4e749e55e669f1b7aee36471a916630286f2
child 65563 991969f0cde0aadff8f28faf20d61ed331cbfabf
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmark
bugs515362
Bug 515362: Links are not followed on first click [r=mark.finkle]
mobile/chrome/content/browser.js
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -1483,42 +1483,49 @@ const BrowserSearch = {
       button.engine = engine;
     }
   }
 }
 
 /** Watches for mouse events in chrome and sends them to content. */
 function ContentCustomClicker(browserView) {
   this._browserView = browserView;
+  this._fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
 }
 
 ContentCustomClicker.prototype = {
     /** Dispatch a mouse event with chrome client coordinates. */
     _dispatchMouseEvent: function _dispatchMouseEvent(name, cX, cY) {
       let browser = this._browserView.getBrowser();
       let [x, y] = Browser.transformClientToBrowser(cX, cY);
       let cwu = BrowserView.Util.getBrowserDOMWindowUtils(browser);
       let scrollX = {}, scrollY = {};
       if (browser) {
         cwu.getScrollXY(false, scrollX, scrollY);
         cwu.sendMouseEvent(name, x - scrollX.value, y - scrollY.value, 0, 1, 0, true);
       }
     },
 
     mouseDown: function mouseDown(cX, cY) {
-      this._dispatchMouseEvent("mousedown", cX, cY);
-      // Re-render content after mousedown event has possibly selected something.
+      // if something is targeted by the mousedown, focus it and re-render
+      // the canvas now
+      let [x, y] = Browser.transformClientToBrowser(cX, cY);
+      let element = Browser.elementFromPoint(x, y);
+      if (!element)
+        return;
+
+      this._fm.setFocus(element, Ci.nsIFocusManager.FLAG_NOSCROLL);
       Util.executeSoon(this._browserView.renderNow);
     },
 
     mouseUp: function mouseUp(cX, cY) {
     },
 
     singleClick: function singleClick(cX, cY) {
-      // Send mouseup only once we know it is just one click.
+      this._dispatchMouseEvent("mousedown", cX, cY);
       this._dispatchMouseEvent("mouseup", cX, cY);
     },
 
     doubleClick: function doubleClick(cX1, cY1, cX2, cY2) {
       if (!Browser.zoomToPoint(cX2, cY2))
         Browser.zoomFromPoint(cX2, cY2);
     },