Bug 534414 - [Regression] FormFill: Cannot Span direction fields on Google Maps [r=mark.finkle]
authorVivien Nicolas <21@vingtetun.org>
Wed, 16 Dec 2009 13:09:30 -0500
changeset 1238 e5085277903a07eee79a7744b042b52df51711d7
parent 1237 52d3aeb30d936e5d66a2190f50461c2f972dfc23
child 1239 8c6bbd546114ba802be42628b9c4aa0490aaba71
push id1102
push usermfinkle@mozilla.com
push dateWed, 16 Dec 2009 18:10:23 +0000
reviewersmark.finkle
bugs534414
Bug 534414 - [Regression] FormFill: Cannot Span direction fields on Google Maps [r=mark.finkle]
chrome/content/browser-ui.js
--- a/chrome/content/browser-ui.js
+++ b/chrome/content/browser-ui.js
@@ -1175,31 +1175,23 @@ var FormHelper = {
         return b.tabIndex;
 
       return a.tabIndex > b.tabIndex;
     }
     return elements.sort(orderByTabIndex);
   },
 
   _getPrevious: function() {
-    let elements = this._nodes;
-    for (let i = elements.length; i>0; --i) {
-      if (elements[i] == this._currentElement)
-        return elements[--i];
-    }
-   return null;
+    let index = this._nodes.indexOf(this._currentElement);
+    return (index != -1 ? this._nodes[--index] : null);
   },
 
   _getNext: function() {
-    let elements = this._nodes;
-    for (let i = 0; i<elements.length; i++) {
-      if (elements[i] == this._currentElement)
-        return elements[++i];
-    }
-    return null;
+    let index = this._nodes.indexOf(this._currentElement);
+    return (index != -1 ? this._nodes[++index] : null);
   },
 
   getLabelsFor: function(aElement) {
     let associatedLabels = [];
     if (this._isValidElement(aElement)) {
       let labels = aElement.ownerDocument.getElementsByTagName("label");
       for (let i=0; i<labels.length; i++) {
         if (labels[i].getAttribute("for") == aElement.id)
@@ -1248,17 +1240,17 @@ var FormHelper = {
     window.addEventListener("keypress", this, true);
     let bv = Browser._browserView;
     bv.ignorePageScroll(true);
 
     this._container.hidden = false;
     this._helperSpacer.hidden = false;
 
     this._nodes = this._getAll();
-    this.setCurrentElement(aElement);
+    this.setCurrentElement(aElement.wrappedJSObject || aElement);
   },
 
   close: function formHelperHide() {
     if (!this._open)
       return;
 
     this._updateSelect(this._currentElement, null);