Bug 516958: Remove folder creation from bookmark system, r=vivien
authorMark Finkle <mfinkle@mozilla.com>
Thu, 17 Sep 2009 09:20:27 -0400
changeset 65569 21906276612fae59ad3f7ac1fe81a6b8c6d78fdc
parent 65568 2cabffd9a78816a32d01c18ce64beb778b6ac994
child 65570 6ea0f6a9f7d7a63fb71c4d4ea5c8397ec73930cc
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)
reviewersvivien
bugs516958
Bug 516958: Remove folder creation from bookmark system, r=vivien
mobile/chrome/content/bindings.xml
mobile/chrome/content/browser-ui.js
mobile/chrome/content/browser.css
mobile/chrome/content/browser.xul
mobile/locales/en-US/chrome/browser.dtd
mobile/locales/en-US/chrome/browser.properties
mobile/themes/hildon/browser.css
mobile/themes/wince/browser-high.css
mobile/themes/wince/browser-low.css
mobile/themes/wince/browser.css
--- a/mobile/chrome/content/bindings.xml
+++ b/mobile/chrome/content/bindings.xml
@@ -594,31 +594,16 @@
               this.control.removeItem(this);
 
             let event = document.createEvent("Events");
             event.initEvent("BookmarkRemove", true, false);
             this.dispatchEvent(event);
           ]]>
         </body>
       </method>
-      <method name="move">
-        <body>
-          <![CDATA[
-            if (this.control)
-              this.control.activeItem = this;
-
-            let control = this.control || this;
-            let code = control.getAttribute("onmove");
-            if (code) {
-              let func = new Function(code);
-              func.call(control);
-            }
-          ]]>
-        </body>
-      </method>
       <method name="updateFields">
         <body>
           <![CDATA[
             // implemented by sub classes
           ]]>
         </body>
       </method>
     </implementation>
@@ -642,18 +627,16 @@
             <xul:textbox anonid="name" xbl:inherits="value=title"/>
             <xul:textbox anonid="uri" xbl:inherits="value=uri"/>
             <xul:textbox anonid="tags" xbl:inherits="value=tags" emptytext="&editBookmarkTags.label;"/>
           </xul:vbox>
         
           <xul:hbox anonid="bookmark-manage-controls" align="center" class="bookmark-manage-controls" hidden="true">
             <xul:button anonid="close-button" class="bookmark-close-button"
                         label="&editBookmarkRemove.label;" oncommand="document.getBindingParent(this).remove()"/>
-            <xul:button anonid="folder-button" class="bookmark-folder-button" 
-                        label="&editBookmarkMove.label;" oncommand="document.getBindingParent(this).move()"/>
             <xul:spacer flex="1"/>
             <xul:button anonid="done-button" label="&editBookmarkDone.label;"
                         oncommand="document.getBindingParent(this).stopEditing(true)"/>
           </xul:hbox>
         </xul:vbox>
       </xul:hbox>
     </content>
 
@@ -845,42 +828,16 @@
 
             children.scrollBoxObject.scrollTo(0, 0);
 
             let childItems = this._getChildren(aRootFolder);
             for (let i=0; i<childItems.length; i++) {
               let node = childItems[i];
               children.appendChild(this.createItem(node));
             }
-
-            // Add the "<new folder>" item
-            let newFolder = document.createElementNS(XULNS, "button");
-            newFolder.setAttribute("class", "bookmark-folder-new");
-            newFolder.setAttribute("label", this._bundle.GetStringFromName("editBookmarkAddFolder"));
-            children.appendChild(newFolder);
-
-            // XXX Fix me - use <handler>?
-            newFolder.addEventListener("click", function(e) { self.addFolder(); }, false);
-          ]]>
-        </body>
-      </method>
-
-      <method name="addFolder">
-        <body>
-          <![CDATA[
-            let parents = this._parents;
-            let parent = parents.lastChild;
-            if ("itemId" in parent) {
-              let children = this._children;
-              let title = this._bundle.GetStringFromName("editBookmarkNewFolder");
-              let newId = PlacesUtils.bookmarks.createFolder(parent.itemId, title, PlacesUtils.bookmarks.DEFAULT_INDEX);
-              let child = this.createItem({ itemId: newId, title: title, type: Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER });
-              children.insertBefore(child, children.lastChild);
-              child.startEditing(true);
-            }
           ]]>
         </body>
       </method>
 
       <method name="createItem">
         <parameter name="aItem"/>
         <body>
           <![CDATA[
@@ -942,143 +899,16 @@
               func.call(this, event);
             }
           ]]>
         </body>
       </method>
     </implementation>
   </binding>
 
-  <binding id="place-tree">
-    <content orient="vertical" flex="1">
-      <xul:richlistbox anonid="items" class="place-tree-items" flex="1"/>
-    </content>
-    <implementation>
-      <constructor>
-        <![CDATA[
-          this._type = this.getAttribute("type");
-          this._mode = this.getAttribute("mode");
-        ]]>
-      </constructor>
-      <field name="_type"/>
-      <field name="_mode"/>
-      <field name="_items">
-        document.getAnonymousElementByAttribute(this, "anonid", "items");
-      </field>
-
-      <property name="scrollBoxObject" readonly="true" onget="return this._items.scrollBoxObject;"/>
-
-      <property name="selectedItem" readonly="true">
-        <getter>
-          <![CDATA[
-            return this._items.selectedItem;
-          ]]>
-        </getter>
-      </property>
-
-      <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);
-            let query = PlacesUtils.history.getNewQuery();
-
-            if (aFolder)
-              query.setFolders([aFolder], 1);
-            let result = PlacesUtils.history.executeQuery(query, options);
-            let rootNode = result.root;
-            rootNode.containerOpen = true;
-            let cc = rootNode.childCount;
-
-            for (var i=0; i<cc; ++i) {
-              var node = rootNode.getChild(i);
-              if (this._mode == "folders" && node.type == node.RESULT_TYPE_FOLDER) {
-                items.push(node);
-              }
-              else if (this._mode == "") {
-                items.push(node);
-              }
-            }
-            rootNode.containerOpen = false;
-            return items;
-          ]]>
-        </body>
-      </method>
-
-      <method name="openFolder">
-        <parameter name="aRootFolder"/>
-        <parameter name="aLevel"/>
-        <body>
-          <![CDATA[
-            aRootFolder = aRootFolder || PlacesUtils.bookmarks.unfiledBookmarksFolder;
-            aLevel = aLevel || 0;
-
-            let items = this._items;
-            if (!aLevel) {
-              while (items.firstChild)
-                items.removeChild(items.firstChild);
-
-              let node = { itemId: aRootFolder, title: PlacesUtils.bookmarks.getItemTitle(aRootFolder), type: Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER };
-              items.appendChild(this.createItem(node, aLevel));
-              aLevel += 24;
-            }
-
-            let childItems = this._getChildren(aRootFolder);
-            for (let i=0; i<childItems.length; i++) {
-              let node = childItems[i];
-              items.appendChild(this.createItem(node, aLevel));
-
-              this.openFolder(node.itemId, aLevel + 24);
-            }
-          ]]>
-        </body>
-      </method>
-
-      <method name="createItem">
-        <parameter name="aItem"/>
-        <parameter name="aLevel"/>
-        <body>
-          <![CDATA[
-            const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
-
-            let child = document.createElementNS(XULNS, "placelabel");
-            child.setAttribute("type", "folder");
-            child.setAttribute("itemid", aItem.itemId);
-            child.setAttribute("title", aItem.title);
-            child.setAttribute("indent", aLevel);
-
-            // XXX make a <handler>
-            var self = this;
-            child.addEventListener("click", function(e) { self._fireSelect(e, child); }, false);
-
-            return child;
-          ]]>
-        </body>
-      </method>
-
-      <method name="_fireSelect">
-        <parameter name="aEvent"/>
-        <parameter name="aItem"/>
-        <body>
-          <![CDATA[
-            // Force the item to be selected
-            this._items.selectedItem = aItem;
-
-            // the richlistbox will fire an onselect event, which will bubble to
-            // the placetree onselect handler. We don't need to explicitly fire
-            // anything here.
-          ]]>
-        </body>
-      </method>
-    </implementation>
-  </binding>
-
   <binding id="richlistitem" extends="chrome://global/content/bindings/richlistbox.xml#richlistitem">
     <handlers>
       <handler event="mousedown" phase="capturing">
         <![CDATA[
           event.stopPropagation();
         ]]>
       </handler>
     </handlers>
--- a/mobile/chrome/content/browser-ui.js
+++ b/mobile/chrome/content/browser-ui.js
@@ -875,17 +875,16 @@ var BookmarkHelper = {
     this._editor = document.createElement("placeitem");
     this._editor.setAttribute("id", "bookmark-item");
     this._editor.setAttribute("flex", "1");
     this._editor.setAttribute("type", "bookmark");
     this._editor.setAttribute("ui", "manage");
     this._editor.setAttribute("title", title);
     this._editor.setAttribute("uri", aURI.spec);
     this._editor.setAttribute("tags", tags.join(", "));
-    this._editor.setAttribute("onmove", "FolderPicker.show(this);");
     this._editor.setAttribute("onclose", "BookmarkHelper.close()");
     document.getElementById("bookmark-form").appendChild(this._editor);
 
     let toolbar = document.getElementById("toolbar-main");
     let top = toolbar.top + toolbar.boxObject.height;
 
     this._panel = document.getElementById("bookmark-container");
     this._panel.top = (top < 0 ? 0 : top);
@@ -944,51 +943,16 @@ var BookmarkList = {
   },
 
   openBookmark: function() {
     let item = this._bookmarks.activeItem;
     if (item.spec) {
       this.close();
       BrowserUI.goToURI(item.spec);
     }
-  },
-};
-
-var FolderPicker = {
-  _control: null,
-  _panel: null,
-
-  show: function(aControl) {
-    this._panel = document.getElementById("folder-container");
-    this._panel.width = window.innerWidth;
-    this._panel.height = window.innerHeight;
-    this._panel.hidden = false;
-    BrowserUI.pushDialog(this);
-
-    this._control = aControl;
-
-    let folders = document.getElementById("folder-items");
-    folders.openFolder();
-  },
-
-  close: function() {
-    this._panel.hidden = true;
-    BrowserUI.popDialog();
-  },
-
-  moveItem: function() {
-    let folders = document.getElementById("folder-items");
-    let itemId = (this._control.activeItem ? this._control.activeItem.itemId : this._control.itemId);
-    let folderId = PlacesUtils.bookmarks.getFolderIdForItem(itemId);
-    if (folders.selectedItem.itemId != folderId) {
-      PlacesUtils.bookmarks.moveItem(itemId, folders.selectedItem.itemId, PlacesUtils.bookmarks.DEFAULT_INDEX);
-      if (this._control.removeItem)
-        this._control.removeItem(this._control.activeItem);
-    }
-    this.close();
   }
 };
 
 var SelectHelper = {
   _panel: null,
   _list: null,
   _control: null,
   _selectedIndexes: [],
--- a/mobile/chrome/content/browser.css
+++ b/mobile/chrome/content/browser.css
@@ -66,20 +66,16 @@ placeitem {
 placeitem[type="folder"] {
   -moz-binding: url("chrome://browser/content/bindings.xml#place-folder");
 }
 
 placelist {
   -moz-binding: url("chrome://browser/content/bindings.xml#place-list");
 }
 
-placetree {
-  -moz-binding: url("chrome://browser/content/bindings.xml#place-tree");
-}
-
 placelabel {
   -moz-binding: url("chrome://browser/content/bindings.xml#place-label");
 }
 
 radio {
   -moz-binding: url("chrome://global/content/bindings/radio.xml#radio");
 }
 
--- a/mobile/chrome/content/browser.xul
+++ b/mobile/chrome/content/browser.xul
@@ -421,27 +421,17 @@
 
     <vbox id="bookmarklist-container" class="panel-dark" hidden="true" top="0" left="0">
       <hbox id="bookmarklist-header">
         <description flex="1">&bookmarksHeader.label;</description>
         <toolbarbutton id="tool-bookmarks-manage" class="urlbar-button show-text button-dark" type="checkbox" autocheck="true"
                        label="&bookmarksManage.label;" oncommand="BookmarkList.toggleManage();"/>
         <toolbarbutton id="tool-bookmarks-close" class="urlbar-button button-image" command="cmd_close"/>
       </hbox>
-      <placelist id="bookmark-items" type="bookmarks" flex="1"
-                 onmove="FolderPicker.show(this);"
-                 onopen="BookmarkList.openBookmark();"/>
-    </vbox>
-
-    <vbox id="folder-container" class="panel-dark" hidden="true" top="0" left="0">
-      <hbox id="folder-header">
-        <description flex="1">&foldersHeader.label;</description>
-        <toolbarbutton id="tool-folders-close" class="urlbar-button button-image" command="cmd_close"/>
-      </hbox>
-      <placetree id="folder-items" type="bookmarks" mode="folders" flex="1" onselect="FolderPicker.moveItem();"/>
+      <placelist id="bookmark-items" type="bookmarks" flex="1" onopen="BookmarkList.openBookmark();"/>
     </vbox>
 
     <vbox id="helperapp-container" class="dialog-dark" hidden="true" align="center" top="0" left="0">
       <label id="helperapp-prompt" value="&helperApp.prompt;"/>
       <label id="helperapp-target" value="" crop="center"/>
       <separator/>
       <hbox pack="center">
         <button id="helperapp-open" class="button-dark" label="&helperApp.open;" oncommand="HelperAppDialog.open();"/>
--- a/mobile/locales/en-US/chrome/browser.dtd
+++ b/mobile/locales/en-US/chrome/browser.dtd
@@ -16,20 +16,18 @@
 <!ENTITY paste.label           "Paste">
 <!ENTITY delete.label          "Delete">
 <!ENTITY selectAll.label       "Select All">
 <!ENTITY noSuggestions.label   "(No suggestions)">
 <!ENTITY addToDictionary.label "Add to Dictionary">
 
 <!ENTITY bookmarksHeader.label     "Bookmarks">
 <!ENTITY bookmarksManage.label     "Manage">
-<!ENTITY foldersHeader.label       "Folders">
 
 <!ENTITY editBookmarkRemove.label  "Remove">
-<!ENTITY editBookmarkMove.label    "Move">
 <!ENTITY editBookmarkDone.label    "Done">
 <!ENTITY editBookmarkTags.label    "Add tags here">
 
 <!ENTITY helperApp.prompt          "What would you like to do with">
 <!ENTITY helperApp.open            "Open">
 <!ENTITY helperApp.save            "Save">
 <!ENTITY helperApp.nothing         "Nothing">
 
--- a/mobile/locales/en-US/chrome/browser.properties
+++ b/mobile/locales/en-US/chrome/browser.properties
@@ -1,12 +1,8 @@
-# Bookmarks
-editBookmarkAddFolder=Add a new folder
-editBookmarkNewFolder=New folder
-
 # Add-on Manager
 addonsRestart=Restart to complete changes
 addonsRestartButton.label=Restart
 addonsLocalNone.label=No add-ons installed
 addonsSearchStart.label=Searching for add-ons…
 addonsSearchStart.button=Cancel
 addonsSearchNone.label=No matches found
 addonsSearchFail.label=%S couldn't retrieve add-ons
--- a/mobile/themes/hildon/browser.css
+++ b/mobile/themes/hildon/browser.css
@@ -400,39 +400,34 @@ toolbarbutton.page-button {
 @media (orientation: portrait) {
   #console-filter-warnings,
   #console-filter-messages {
     visibility: collapse;
   }
 }
 
 /* URL List and autocomplete navigation popup ------------------------------ */
-#tool-bookmarks-close,
-#tool-folders-close {
+#tool-bookmarks-close {
   min-height: 0 !important;
   min-width: 0 !important;
   margin-top: -40px; /* keep pixels */
   list-style-image: url("chrome://browser/skin/images/fullscreen-up-40.png");
 }
 
 #bookmarklist-container {
   padding: 0;
 }
 
-#bookmarklist-header, #folder-header {
+#bookmarklist-header {
   color: rgb(255,255,255);
   -moz-box-align: center;
   padding: 2.2mm; /* core spacing */
 }
 
-#folder-header {
-  height: 21.4mm; /* fake the height of the URLbar: 17mm + 2.2mm + 2.2mm */
-}
-
-#bookmark-items, #folder-items {
+#bookmark-items {
   -moz-appearance: none !important;
   background-color: rgb(255,255,255);
   padding: 0;
 }
 
 .place-list-parents {
   background-color: rgb(207,207,207);
 }
@@ -496,45 +491,36 @@ placeitem[selected] .bookmark-item-image
 }
 
 placelabel.bookmark-folder {
   border-bottom: 0.1mm solid rgb(255,255,255);
   background: url(chrome://browser/skin/images/arrowup-16.png) no-repeat 98% 50%;
 }
 
 /* folders have a fixed image */
-placeitem[type=folder] .bookmark-item-image {
+placeitem[type="folder"] .bookmark-item-image {
   list-style-image: url("chrome://browser/skin/images/folder-30.png");
 }
 
 placeitem[type="folder"] {
   background: url(chrome://browser/skin/images/arrowright-16.png) no-repeat 98% 50%;
 }
 
 /* hide the unuseful fields for folder */
-placeitem[type=folder] .bookmark-item-uri,
-placeitem[type=folder] .bookmark-item-tags {
+placeitem[type="folder"] .bookmark-item-uri,
+placeitem[type="folder"] .bookmark-item-tags {
   visibility: hidden;
 }
 
 /* control the manage controls */
-.bookmark-folder-new {
-  visibility: collapse;
-}
-
-placelist[ui="manage"] .bookmark-folder-new {
-  visibility: visible;
-}
-
 placelist[ui="manage"] placeitem[type="folder"] {
   background-image: none;
 }
 
 placeitem[ui="manage"] .bookmark-close-button,
-placeitem[ui="manage"] .bookmark-folder-button,
 placeitem[ui="manage"] .bookmark-item-image {
   visibility: collapse;
 }
 
 /* be consistent with the size of placeitem */
 placelabel {
   min-height: 14.4mm; /* row size */
   -moz-box-align: center;
--- a/mobile/themes/wince/browser-high.css
+++ b/mobile/themes/wince/browser-high.css
@@ -228,26 +228,25 @@
 }
 
 #tool-console:hover:active,
 #tool-console[checked="true"] {
   list-style-image: url("chrome://browser/skin/images/console-active-64.png");
 }
 
 /* URL List and autocomplete navigation popup ------------------------------ */
-#tool-bookmarks-close,
-#tool-folders-close {
+#tool-bookmarks-close {
   min-height: 0 !important;
   min-width: 0 !important;
   margin-top: -40px; /* keep pixels */
   list-style-image: url("chrome://browser/skin/images/fullscreen-up-40.png");
 }
 
 /* folders have a fixed image */
-placeitem[type=folder] .bookmark-item-image {
+placeitem[type="folder"] .bookmark-item-image {
   list-style-image: url("chrome://browser/skin/images/folder-30.png");
 }
 
 .close-button {
   -moz-appearance: none;
   border: none;
   margin: 0;
   padding: 0;
--- a/mobile/themes/wince/browser-low.css
+++ b/mobile/themes/wince/browser-low.css
@@ -227,26 +227,25 @@
 }
 
 #tool-console:hover:active,
 #tool-console[checked="true"] {
   list-style-image: url("chrome://browser/skin/images/console-active-36.png");
 }
 
 /* URL List and autocomplete navigation popup ------------------------------ */
-#tool-bookmarks-close,
-#tool-folders-close {
+#tool-bookmarks-close {
   min-height: 0 !important;
   min-width: 0 !important;
   margin-top: -18px; /* keep pixels */
   list-style-image: url("chrome://browser/skin/images/fullscreen-up-24.png");
 }
 
 /* folders have a fixed image */
-placeitem[type=folder] .bookmark-item-image {
+placeitem[type="folder"] .bookmark-item-image {
   list-style-image: url("chrome://browser/skin/images/folder-24.png");
 }
 
 .close-button {
   -moz-appearance: none;
   border: none;
   margin: 0;
   padding: 0;
--- a/mobile/themes/wince/browser.css
+++ b/mobile/themes/wince/browser.css
@@ -199,27 +199,23 @@ toolbarbutton.page-button {
   }
 }
 
 /* bookmark list panel UI   ------------------------------------------------ */
 #bookmarklist-container {
   padding: 0;
 }
 
-#bookmarklist-header, #folder-header {
+#bookmarklist-header {
   color: rgb(255,255,255);
   -moz-box-align: center;
   padding: 1.1mm; /* core spacing */
 }
 
-#folder-header {
-  height: 10.7mm; /* fake the height of the URLbar: 8.5mm + 1.1mm + 1.1mm */
-}
-
-#bookmark-items, #folder-items {
+#bookmark-items {
   -moz-appearance: none !important;
   background-color: rgb(255,255,255);
   padding: 0;
 }
 
 .place-list-parents {
   background-color: rgb(207,207,207);
 }
@@ -287,36 +283,27 @@ placelabel.bookmark-folder {
   background: url(chrome://browser/skin/images/arrowup-16.png) no-repeat 98% 50%;
 }
 
 placeitem[type="folder"] {
   background: url(chrome://browser/skin/images/arrowright-16.png) no-repeat 98% 50%;
 }
 
 /* hide the unuseful fields for folder */
-placeitem[type=folder] .bookmark-item-uri,
-placeitem[type=folder] .bookmark-item-tags {
+placeitem[type="folder"] .bookmark-item-uri,
+placeitem[type="folder"] .bookmark-item-tags {
   visibility: hidden;
 }
 
 /* control the manage controls */
-.bookmark-folder-new {
-  visibility: collapse;
-}
-
-placelist[ui="manage"] .bookmark-folder-new {
-  visibility: visible;
-}
-
 placelist[ui="manage"] placeitem[type="folder"] {
   background-image: none;
 }
 
 placeitem[ui="manage"] .bookmark-close-button,
-placeitem[ui="manage"] .bookmark-folder-button,
 placeitem[ui="manage"] .bookmark-item-image {
   visibility: collapse;
 }
 
 /* be consistent with the size of placeitem */
 placelabel {
   min-height: 7.2mm; /* row size */
   -moz-box-align: center;