Bug 525351: Form Fill Assistant zooms in on wrong form on msn.com [r=mark.finkle]
authorVivien Nicolas <21@vingtetun.org>
Thu, 12 Nov 2009 00:15:56 -0500
changeset 65783 112e15957941405aae8ac6c61d10404d737a5b34
parent 65782 7477f754d9d99d4107acc1e1ac31a7e92a044f1f
child 65784 9da6707288079393eb5002ea9542d0da0c21540c
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
bugs525351
Bug 525351: Form Fill Assistant zooms in on wrong form on msn.com [r=mark.finkle]
mobile/chrome/content/browser-ui.js
--- a/mobile/chrome/content/browser-ui.js
+++ b/mobile/chrome/content/browser-ui.js
@@ -1046,40 +1046,39 @@ var FormHelper = {
       SelectHelper.close();
     }
   },
 
   _isValidElement: function(aElement) {
     if (aElement.disabled)
       return false;
 
-    if (aElement instanceof HTMLSelectElement || aElement instanceof HTMLTextAreaElement) {
-      let rect = aElement.getBoundingClientRect();
-      let isVisible = (rect.height != 0 || rect.width != 0);
-      return isVisible;
-    }
+    if (aElement instanceof HTMLSelectElement || aElement instanceof HTMLTextAreaElement)
+      return this._isElementVisible(aElement);
     
     if (aElement instanceof HTMLInputElement) {
       let ignoreInputElements = ["checkbox", "radio", "hidden", "reset", "button"];
       let isValidElement = (ignoreInputElements.indexOf(aElement.type) == -1);
       if (!isValidElement)
        return false;
  
-      let rect = aElement.getBoundingClientRect();
-      let isVisible = (rect.height != 0 || rect.width != 0);
-      return isVisible;
+      return this._isElementVisible(aElement);
     }
 
     return false;
   },
 
   _isValidSelectElement: function(aElement) {
     return (aElement instanceof HTMLSelectElement) || (aElement instanceof Ci.nsIDOMXULMenuListElement);
   },
 
+  _isElementVisible: function(aElement) {
+    let rect = aElement.getBoundingClientRect();
+    return (rect.height != 0 || rect.width != 0);
+  },
 
   _nsResolver: function(aPrefix) {
     var ns = {
       "xhtml" : "http://www.w3.org/1999/xhtml"
     };
     return ns[aPrefix] || null;
   },
 
@@ -1139,17 +1138,17 @@ var FormHelper = {
         if (labels[i].getAttribute("for") == aElement.id)
           associatedLabels.push(labels[i]);
       }
     }
 
     if (aElement.parentNode instanceof HTMLLabelElement)
       associatedLabels.push(aElement.parentNode);
 
-    return associatedLabels;
+    return associatedLabels.filter(this._isElementVisible);
   },
 
   _currentElement: null,
   getCurrentElement: function() {
     return this._currentElement;
   },
 
   setCurrentElement: function(aElement) {