Bug 532766 - tapping 'manage' in bookmark list scrolls you to the very first bookmark [r=mark.finkle]
authorMark Finkle <mfinkle@mozilla.com>
Thu, 10 Dec 2009 19:08:10 -0500
changeset 65903 69d3a216938a0523e0c4ecec655fdcd2040011ab
parent 65902 fc11fc20b5f8c3b8adac28d8cd7f11df73f6ed3d
child 65904 d65ef1fb4e7e7c511484a60a7d5b6b1c069ed408
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
bugs532766
Bug 532766 - tapping 'manage' in bookmark list scrolls you to the very first bookmark [r=mark.finkle]
mobile/chrome/content/bindings.xml
--- a/mobile/chrome/content/bindings.xml
+++ b/mobile/chrome/content/bindings.xml
@@ -699,30 +699,48 @@
           ]]>
         </getter>
         <setter>
           <![CDATA[
             if (this._manageUI != val) {
               this._manageUI = val;
               if (this._manageUI) {
                 this.setAttribute("ui", "manage");
-                if (this.getAttribute("autoedit") == "true" && this._children.hasChildNodes())
-                  this._children.firstChild.startEditing();
+                if (this.getAttribute("autoedit") == "true" && this._children.hasChildNodes()) {
+                  let first = this._getFirstVisibleChild();
+                  if (first)
+                    first.startEditing();
+                }
               }
               else {
                 if (this._activeItem && this._activeItem.isEditing)
                   this._activeItem.stopEditing();
                 this.removeAttribute("ui");
               }
             }
             return val;
           ]]>
         </setter>
       </property>
 
+      <method name="_getFirstVisibleChild">
+        <body>
+          <![CDATA[
+            let children = this._children.childNodes;
+            for (let i = 0; i < children.length; i++) {
+              let rect = children[i].getBoundingClientRect();
+              let position = rect.top - rect.height;
+              if (position > 0)
+                return children[i];
+            }
+            return null;
+          ]]>
+        </body>
+      </method>
+
       <method name="_getChildren">
         <parameter name="aFolder"/>
         <body>
           <![CDATA[
             let items = [];
 
             let options = PlacesUtils.history.getNewQueryOptions();
             options.queryType = (this._type == "bookmarks" ? options.QUERY_TYPE_BOOKMARKS : options.QUERY_TYPE_HISTORY);