Bug 546273 - Form Assistant misses focus on profiles.yahoo.com [r=mark.finkle]
authorVivien Nicolas <21@vingtetun.org>
Tue, 02 Mar 2010 11:34:20 -0500
changeset 1364 eed68071299572f7107f13189a2828dcffd75aa6
parent 1363 287767d3c66a9287f757048d05d133f00e68fefd
child 1365 5f9ab7f0740f943d334f610eab8bfffa01017d11
push id1216
push usermfinkle@mozilla.com
push dateTue, 02 Mar 2010 16:34:43 +0000
reviewersmark.finkle
bugs546273
Bug 546273 - Form Assistant misses focus on profiles.yahoo.com [r=mark.finkle]
chrome/content/browser-ui.js
--- a/chrome/content/browser-ui.js
+++ b/chrome/content/browser-ui.js
@@ -1081,25 +1081,30 @@ var FormHelper = {
   },
 
   get _selectContainer() {
     delete this._selectContainer;
     return this._selectContainer = document.getElementById("select-container");
   },
 
   _getRectForElement: function formHelper_getRectForElement(aElement) {
+    const kDistanceMax = 100;
     let elRect = Browser.getBoundingContentRect(aElement);
     let bv = Browser._browserView;
 
     let labels = this.getLabelsFor(aElement);
     for (let i=0; i<labels.length; i++) {
       let labelRect = Browser.getBoundingContentRect(labels[i]);
       if (labelRect.left < elRect.left) {
-        let width = labelRect.width + elRect.width + (elRect.x - labelRect.x - labelRect.width);
-        return new Rect(labelRect.x, labelRect.y, width, elRect.height).expandToIntegers();
+        let isClosed = Math.abs(labelRect.left - elRect.left) - labelRect.width < kDistanceMax &&
+                       Math.abs(labelRect.top - elRect.top) - labelRect.height < kDistanceMax;
+        if (!isClosed) {
+          let width = labelRect.width + elRect.width + (elRect.left - labelRect.left - labelRect.width);
+          return new Rect(labelRect.left, labelRect.top, width, elRect.height).expandToIntegers();
+        }
       }
     }
     return elRect;
   },
 
   _update: function(aPreviousElement, aNewElement) {
     this._updateSelect(aPreviousElement, aNewElement);