Bug 1056635 Deal with the fallout from bug 559505 r=IanN
authorNeil Rashbrook <neil@parkwaycc.co.uk>
Sun, 31 Aug 2014 19:56:58 +0100
changeset 16546 122b396477d139aea993671a272695cc074e511b
parent 16545 321bb7922713dca3223815b2ed0dbc0fff239208
child 16547 9eff7298d806e437c5a12f2b32ffef84c311ec81
push id1234
push usermbanner@mozilla.com
push dateMon, 13 Oct 2014 17:59:18 +0000
treeherdercomm-esr52@b5a0add9fb18 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersIanN
bugs1056635, 559505
Bug 1056635 Deal with the fallout from bug 559505 r=IanN
suite/common/history/treeView.js
suite/common/history/utils.js
suite/common/places/treeView.js
suite/common/safeMode.js
suite/common/sidebar/sidebarOverlay.js
suite/common/sidebar/sidebarOverlay.xul
suite/common/src/PlacesUIUtils.jsm
suite/installer/Makefile.in
suite/installer/package-manifest.in
suite/installer/removed-files.in
suite/locales/Makefile.in
suite/locales/generic/profile/localstore.rdf
suite/mailnews/commandglue.js
--- a/suite/common/history/treeView.js
+++ b/suite/common/history/treeView.js
@@ -239,36 +239,33 @@ PlacesTreeView.prototype = {
     var cc = aContainer.childCount;
     var newElements = new Array(cc);
     this._rows = this._rows.splice(0, aFirstChildRow)
                            .concat(newElements, this._rows);
 
     if (this._isPlainContainer(aContainer))
       return cc;
 
-    const openLiteral = PlacesUIUtils.RDF.GetResource("http://home.netscape.com/NC-rdf#open");
-    const trueLiteral = PlacesUIUtils.RDF.GetLiteral("true");
     var sortingMode = this._result.sortingMode;
 
     var rowsInserted = 0;
     for (let i = 0; i < cc; i++) {
       var curChild = aContainer.getChild(i);
       var curChildType = curChild.type;
 
       var row = aFirstChildRow + rowsInserted;
 
       this._rows[row] = curChild;
       rowsInserted++;
 
       // recursively do containers
       if (curChild instanceof Components.interfaces.nsINavHistoryContainerResultNode) {
-        var resource = this._getResourceForNode(curChild);
-        var isopen = resource != null &&
-                     PlacesUIUtils.localStore.HasAssertion(resource, openLiteral,
-                                                           trueLiteral, true);
+        NS_ASSERT(curChild.uri, "if there is no uri, we can't persist the open state");
+        var isopen = curChild.uri &&
+                     PlacesUIUtils.xulStore.hasValue(location, curChild.uri, "open");
         if (isopen != curChild.containerOpen)
           aToOpen.push(curChild);
         else if (curChild.containerOpen && curChild.childCount > 0)
           rowsInserted += this._buildVisibleSection(curChild, row + 1, aToOpen);
       }
     }
 
     return rowsInserted;
@@ -843,23 +840,16 @@ PlacesTreeView.prototype = {
     try {
       return this._getRowForNode(aNode, true);
     }
     catch(ex) { }
 
     return Components.interfaces.nsINavHistoryResultTreeViewer.INDEX_INVISIBLE;
   },
 
-  _getResourceForNode: function PTV_getResourceForNode(aNode)
-  {
-    var uri = aNode.uri;
-    NS_ASSERT(uri, "if there is no uri, we can't persist the open state");
-    return uri ? PlacesUIUtils.RDF.GetResource(uri) : null;
-  },
-
   // nsITreeView
   get rowCount() {
     return this._rows.length;
   },
 
   get selection() {
     return this._selection;
   },
@@ -1033,26 +1023,23 @@ PlacesTreeView.prototype = {
     }
   },
 
   toggleOpenState: function PTV_toggleOpenState(aRow) {
     if (!this._result)
       throw Components.results.NS_ERROR_UNEXPECTED;
 
     var node = this._rows[aRow];
+    NS_ASSERT(node.uri, "if there is no uri, we can't persist the open state");
 
-    var resource = this._getResourceForNode(node);
-    if (resource) {
-      const openLiteral = PlacesUIUtils.RDF.GetResource("http://home.netscape.com/NC-rdf#open");
-      const trueLiteral = PlacesUIUtils.RDF.GetLiteral("true");
-
+    if (node.uri) {
       if (node.containerOpen)
-        PlacesUIUtils.localStore.Unassert(resource, openLiteral, trueLiteral);
+        PlacesUIUtils.xulStore.removeValue(location, node.uri, "open");
       else
-        PlacesUIUtils.localStore.Assert(resource, openLiteral, trueLiteral, true);
+        PlacesUIUtils.xulStore.setValue(location, node.uri, "open", "true");
     }
 
     // 474287 Places enforces title sorting for groups, which we don't want.
     if (!node.containerOption && asQuery(node).queryOptions.resultType ==
         Components.interfaces.nsINavHistoryQueryOptions.RESULTS_AS_URI)
       node.queryOptions.sortingMode = this._result.sortingMode;
     node.containerOpen = !node.containerOpen;
   },
--- a/suite/common/history/utils.js
+++ b/suite/common/history/utils.js
@@ -43,25 +43,20 @@ function asFullVisit(aNode){
 function asContainer(aNode){
   return QI_node(aNode, Components.interfaces.nsINavHistoryContainerResultNode);
 }
 function asQuery(aNode)    {
   return QI_node(aNode, Components.interfaces.nsINavHistoryQueryResultNode);
 }
 
 var PlacesUIUtils = {
-  get RDF() {
-    delete this.RDF;
-    return this.RDF = Components.classes["@mozilla.org/rdf/rdf-service;1"]
-                                .getService(Components.interfaces.nsIRDFService);
-  },
-
-  get localStore() {
-    delete this.localStore;
-    return this.localStore = this.RDF.GetDataSource("rdf:local-store");
+  get xulStore() {
+    delete this.xulStore;
+    return this.xulStore = Components.classes["@mozilla.org/xul/xulstore;1"]
+                                     .getService(Components.interfaces.nsIXULStore);
   },
 
   get clipboard() {
     delete this.clipboard;
     return this.clipboard = Components.classes["@mozilla.org/widget/clipboard;1"]
                                       .getService(Components.interfaces.nsIClipboard);
   },
 
--- a/suite/common/places/treeView.js
+++ b/suite/common/places/treeView.js
@@ -258,18 +258,16 @@ PlacesTreeView.prototype = {
     let cc = aContainer.childCount;
     let newElements = new Array(cc);
     this._rows = this._rows.splice(0, aFirstChildRow)
                      .concat(newElements, this._rows);
 
     if (this._isPlainContainer(aContainer))
       return cc;
 
-    const openLiteral = PlacesUIUtils.RDF.GetResource("http://home.netscape.com/NC-rdf#open");
-    const trueLiteral = PlacesUIUtils.RDF.GetLiteral("true");
     let sortingMode = this._result.sortingMode;
 
     let rowsInserted = 0;
     for (let i = 0; i < cc; i++) {
       let curChild = aContainer.getChild(i);
       let curChildType = curChild.type;
 
       let row = aFirstChildRow + rowsInserted;
@@ -287,21 +285,19 @@ PlacesTreeView.prototype = {
 
       this._rows[row] = curChild;
       rowsInserted++;
 
       // Recursively do containers.
       if (!this._flatList &&
           curChild instanceof Components.interfaces.nsINavHistoryContainerResultNode &&
           !this._controller.hasCachedLivemarkInfo(curChild)) {
-        let resource = this._getResourceForNode(curChild);
-        let isopen = resource != null &&
-                     PlacesUIUtils.localStore.HasAssertion(resource,
-                                                           openLiteral,
-                                                           trueLiteral, true);
+        NS_ASSERT(curChild.uri, "if there is no uri, we can't persist the open state");
+        let isopen = curChild.uri &&
+                     PlacesUIUtils.xulStore.hasValue(location, curChild.uri, "open");
         if (isopen != curChild.containerOpen)
           aToOpen.push(curChild);
         else if (curChild.containerOpen && curChild.childCount > 0)
           rowsInserted += this._buildVisibleSection(curChild, row + 1, aToOpen);
       }
     }
 
     return rowsInserted;
@@ -1093,23 +1089,16 @@ PlacesTreeView.prototype = {
     try {
       return this._getRowForNode(aNode, true);
     }
     catch(ex) { }
 
     return Components.interfaces.nsINavHistoryResultTreeViewer.INDEX_INVISIBLE;
   },
 
-  _getResourceForNode: function PTV_getResourceForNode(aNode)
-  {
-    let uri = aNode.uri;
-    NS_ASSERT(uri, "if there is no uri, we can't persist the open state");
-    return uri ? PlacesUIUtils.RDF.GetResource(uri) : null;
-  },
-
   // nsITreeView
   get rowCount() {
     return this._rows.length;
   },
 
   get selection() {
     return this._selection;
   },
@@ -1471,25 +1460,22 @@ PlacesTreeView.prototype = {
     let node = this._rows[aRow];
     if (this._flatList && this._openContainerCallback) {
       this._openContainerCallback(node);
       return;
     }
 
     // Persist container open state, except for livemarks.
     if (!this._controller.hasCachedLivemarkInfo(node)) {
-      let resource = this._getResourceForNode(node);
-      if (resource) {
-        const openLiteral = PlacesUIUtils.RDF.GetResource("http://home.netscape.com/NC-rdf#open");
-        const trueLiteral = PlacesUIUtils.RDF.GetLiteral("true");
-
+      NS_ASSERT(node.uri, "if there is no uri, we can't persist the open state");
+      if (node.uri) {
         if (node.containerOpen)
-          PlacesUIUtils.localStore.Unassert(resource, openLiteral, trueLiteral);
+          PlacesUIUtils.xulStore.removeValue(location, node.uri, "open");
         else
-          PlacesUIUtils.localStore.Assert(resource, openLiteral, trueLiteral, true);
+          PlacesUIUtils.xulStore.setValue(location, node.uri, "open", "true");
       }
     }
 
     node.containerOpen = !node.containerOpen;
   },
 
   cycleHeader: function PTV_cycleHeader(aColumn) {
     if (!this._result)
--- a/suite/common/safeMode.js
+++ b/suite/common/safeMode.js
@@ -31,19 +31,24 @@ function restoreDefaultBookmarks() {
   Services.prefs.setBoolPref("browser.bookmarks.restore_default_bookmarks", true);
 }
 
 function deleteLocalstore() {
   const nsIDirectoryServiceContractID = "@mozilla.org/file/directory_service;1";
   const nsIProperties = Components.interfaces.nsIProperties;
   var directoryService = Components.classes[nsIDirectoryServiceContractID]
                                    .getService(nsIProperties);
+  // Delete the old localstore otherwise it will get imported.
   var localstoreFile = directoryService.get("LStoreS", Components.interfaces.nsIFile);
   if (localstoreFile.exists())
     localstoreFile.remove(false);
+  // Delete the new xulstore file.
+  localstoreFile.leafName = "xulstore.json";
+  if (localstoreFile.exists())
+    localstoreFile.remove(false);
 }
 
 function disableAddons() {
   AddonManager.getAllAddons(function(aAddons) {
     aAddons.forEach(function(aAddon) {
       if (aAddon.type == "theme") {
         // Setting userDisabled to false on the default theme activates it,
         // disables all other themes and deactivates the applied persona, if
--- a/suite/common/sidebar/sidebarOverlay.js
+++ b/suite/common/sidebar/sidebarOverlay.js
@@ -183,17 +183,17 @@ function (panel, force_reload)
 {
   if (!force_reload && panel.is_selected()) {
     return;
   }
   // select(): Open this panel and possibly reload it.
   if (this.node.getAttribute('last-selected-panel') != panel.id) {
     // "last-selected-panel" is used as a global variable.
     // this.update() will reference "last-selected-panel".
-    // This way the value can be persisted in localstore.rdf.
+    // This way the value can be persisted in xulstore.json.
     this.node.setAttribute('last-selected-panel', panel.id);
   }
   this.update(force_reload);
 }
 
 sbPanelList.prototype.exclude =
 function (panel)
 {
@@ -291,17 +291,17 @@ function panel_loader() {
   }
 }
 sbPanelList.prototype.update =
 function (force_reload)
 {
   // This function requires that the attribute 'last-selected-panel'
   // holds the id of a non-excluded panel. If it doesn't, no panel will
   // be selected. The attribute is used instead of a function
-  // parameter to allow the value to be persisted in localstore.rdf.
+  // parameter to allow the value to be persisted in xulstore.json.
   var selected_id = this.node.getAttribute('last-selected-panel');
 
   if (sidebar_is_collapsed()) {
     sidebarObj.collapsed = true;
   } else {
     sidebarObj.collapsed = false;
   }
 
--- a/suite/common/sidebar/sidebarOverlay.xul
+++ b/suite/common/sidebar/sidebarOverlay.xul
@@ -71,17 +71,17 @@
               oncommand="SidebarTogglePanel(document.popupNode);"/>
     <menuseparator/>
     <menuitem id="customize-ctx-item" label="&sidebar.customize.label;" 
               accesskey="&sidebar.customize.accesskey;"
               oncommand="SidebarCustomize();"/>
   </menupopup>
 
   <!-- Overlay the sidebar panels -->
-  <vbox id="sidebar-box" persist="hidden width collapsed">
+  <vbox id="sidebar-box" hidden="true" persist="hidden width collapsed">
     <splitter id="sidebar-panels-splitter" collapse="after" persist="state"
       onmouseup="PersistHeight();" hidden="true">
       <grippy/>
     </splitter>
     <vbox id="sidebar-panels-splitter-box" flex="1" 
       persist="collapsed">
       <sidebarheader id="sidebar-title-box" class="sidebarheader-main"
         label="&sidebar.panels.label;" persist="hidden" type="box"
@@ -130,16 +130,17 @@
         </toolbarbutton>
         <toolbarbutton id="sidebar-close-button" oncommand="SidebarShowHide();"
                        tooltiptext="&sidebar.close.tooltip;"/>
       </sidebarheader>
   
       <vbox id="sidebar-panels"
         datasources="rdf:null"
         ref="urn:sidebar:current-panel-list"
+        last-selected-panel="urn:sidebar:panel:bookmarks"
         persist="last-selected-panel height collapsed" flex="1"
         onclick="return contentAreaClick(event);">
         <template id="sidebar-template">
           <rule>
             <conditions>
               <content uri="?uri"/>
               <triple subject="?uri" object="?panel-list"
                 predicate="http://home.netscape.com/NC-rdf#panel-list" />
@@ -206,17 +207,17 @@
         </hbox>
       </vbox>
     </vbox>
   </vbox>
 
   <!-- Splitter on the right of sidebar -->
   <splitter id="sidebar-splitter" collapse="before" persist="state hidden"
     class="chromeclass-extrachrome sidebar-splitter" align="center"
-    onmouseup="SidebarFinishClick();">
+    hidden="true" onmouseup="SidebarFinishClick();">
     <grippy class="sidebar-splitter-grippy"
       onclick="SidebarCleanUpExpandCollapse();"/>
   </splitter>
 
   <!-- View->Sidebar toggle -->
   <menupopup id="menu_View_Popup">
     <menu id="menu_Toolbars">
       <menupopup id="view_toolbars_popup">
--- a/suite/common/src/PlacesUIUtils.jsm
+++ b/suite/common/src/PlacesUIUtils.jsm
@@ -1165,23 +1165,19 @@ var PlacesUIUtils = {
         if (aItemId == id)
           queryName = name;
       }
     }
     return queryName;
   }
 };
 
-XPCOMUtils.defineLazyServiceGetter(PlacesUIUtils, "RDF",
-                                   "@mozilla.org/rdf/rdf-service;1",
-                                   "nsIRDFService");
-
-XPCOMUtils.defineLazyGetter(PlacesUIUtils, "localStore", function() {
-  return PlacesUIUtils.RDF.GetDataSource("rdf:local-store");
-});
+XPCOMUtils.defineLazyServiceGetter(PlacesUIUtils, "xulStore",
+                                   "@mozilla.org/xul/xulstore;1",
+                                   "nsIXULStore");
 
 XPCOMUtils.defineLazyGetter(PlacesUIUtils, "ellipsis", function() {
   return Services.prefs.getComplexValue("intl.ellipsis",
                                         Components.interfaces.nsIPrefLocalizedString).data;
 });
 
 XPCOMUtils.defineLazyServiceGetter(this, "URIFixup",
                                    "@mozilla.org/docshell/urifixup;1",
--- a/suite/installer/Makefile.in
+++ b/suite/installer/Makefile.in
@@ -130,17 +130,16 @@ ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
 MOZ_PKG_MAC_DSSTORE=branding/dsstore
 MOZ_PKG_MAC_BACKGROUND=branding/background.png
 MOZ_PKG_MAC_ICON=branding/disk.icns
 MOZ_PKG_MAC_EXTRA=--symlink "/Applications:/ "
 endif
 
 NON_OMNIJAR_FILES = \
 	defaults/messenger/mailViews.dat \
-	defaults/profile/localstore.rdf \
 	defaults/profile/panels.rdf \
 	defaults/profile/mimeTypes.rdf \
 	defaults/profile/chrome/userChrome-example.css \
 	defaults/profile/chrome/userContent-example.css \
 	$(NULL)
 
 ifndef LIBXUL_SDK
 INSTALL_SDK = 1
--- a/suite/installer/package-manifest.in
+++ b/suite/installer/package-manifest.in
@@ -29,17 +29,16 @@
 #endif
 
 [@AB_CD@]
 @BINPATH@/chrome/@AB_CD@@JAREXT@
 @BINPATH@/chrome/@AB_CD@.manifest
 @BINPATH@/defaults/messenger/mailViews.dat
 @BINPATH@/defaults/profile/bookmarks.html
 @BINPATH@/defaults/profile/chrome/*
-@BINPATH@/defaults/profile/localstore.rdf
 @BINPATH@/defaults/profile/mimeTypes.rdf
 @BINPATH@/defaults/profile/panels.rdf
 @BINPATH@/dictionaries/*
 @BINPATH@/hyphenation/*
 @BINPATH@/@PREF_DIR@/suite-l10n.js
 @BINPATH@/searchplugins/*
 #ifdef XP_WIN32
 @BINPATH@/uninstall/helper.exe
--- a/suite/installer/removed-files.in
+++ b/suite/installer/removed-files.in
@@ -208,16 +208,17 @@ components/nsFilePicker.js
 #ifdef XP_MACOSX
 crashreporter.app/
 #else
 crashreporter@BIN_SUFFIX@
 crashreporter.ini
 #endif
 #endif
 defaults/pref/reporter.js
+defaults/profile/localstore.rdf
 defaults/profile/search.rdf
 defaults/wallet/DistinguishedSchema.tbl
 defaults/wallet/FieldSchema.tbl
 defaults/wallet/PositionalSchema.tbl
 defaults/wallet/SchemaConcat.tbl
 defaults/wallet/SchemaStrings.tbl
 defaults/wallet/StateSchema.tbl
 defaults/wallet/VcardSchema.tbl
--- a/suite/locales/Makefile.in
+++ b/suite/locales/Makefile.in
@@ -53,34 +53,32 @@ UNINSTALLER_PACKAGE_HOOK = $(RM) -r $(ST
 	cp ../installer/windows/l10ngen/helper.exe $(STAGEDIST)/uninstall; \
 	$(RM) $(_ABS_DIST)/l10n-stage/setup.exe; \
 	cp ../installer/windows/l10ngen/setup.exe $(_ABS_DIST)/l10n-stage; \
 	$(NULL)
 endif
 
 NON_OMNIJAR_FILES = \
 	defaults/messenger/mailViews.dat \
-	defaults/profile/localstore.rdf \
 	defaults/profile/panels.rdf \
 	defaults/profile/mimeTypes.rdf \
 	defaults/profile/chrome/userChrome-example.css \
 	defaults/profile/chrome/userContent-example.css \
 	$(NULL)
 
 include $(topsrcdir)/config/rules.mk
 
 include $(topsrcdir)/mozilla/toolkit/locales/l10n.mk
 
 $(STAGEDIST): $(DIST)/branding
 
 $(DIST)/branding:
 	$(NSINSTALL) -D $@
 
 PROFILE_FILES = \
-	localstore.rdf \
 	mimeTypes.rdf \
 	$(NULL)
 
 PROFILE_CHROME = userChrome-example.css userContent-example.css
 
 NO_JA_JP_MAC_AB_CD := $(if $(filter ja-JP-mac, $(AB_CD)),ja,$(AB_CD))
 
 BOOKMARKS_INC_FILE = $(call MERGE_FILE,profile/bookmarks.inc)
deleted file mode 100644
--- a/suite/locales/generic/profile/localstore.rdf
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0"?>
-<!-- This Source Code Form is subject to the terms of the Mozilla Public
-   - License, v. 2.0. If a copy of the MPL was not distributed with this
-   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
-
-<RDF:RDF
-     xmlns:NC="http://home.netscape.com/NC-rdf#"
-     xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
-  <RDF:Description about="chrome://navigator/content/navigator.xul#sidebar-panels">
-    <last-selected-panel>urn:sidebar:panel:bookmarks</last-selected-panel>
-  </RDF:Description>
-  <RDF:Description about="chrome://navigator/content/navigator.xul#sidebar-box">
-    <hidden>true</hidden>
-  </RDF:Description>
-  <RDF:Description about="chrome://navigator/content/navigator.xul#sidebar-splitter">
-    <hidden>true</hidden>
-  </RDF:Description>
-  <RDF:Description about="chrome://navigator/content/navigator.xul">
-    <NC:persist resource="chrome://navigator/content/navigator.xul#sidebar-panels"/>
-    <NC:persist resource="chrome://navigator/content/navigator.xul#sidebar-box"/>
-    <NC:persist resource="chrome://navigator/content/navigator.xul#sidebar-splitter"/>
-  </RDF:Description>
-</RDF:RDF>
--- a/suite/mailnews/commandglue.js
+++ b/suite/mailnews/commandglue.js
@@ -522,17 +522,17 @@ function UpdateStatusMessageCounts(folde
 
 }
 
 function ConvertSortTypeToColumnID(sortKey)
 {
   var columnID;
 
   // Hack to turn this into an integer, if it was a string.
-  // It would be a string if it came from localStore.rdf
+  // It would be a string if it came from xulstore.json
   sortKey = sortKey - 0;
 
   switch (sortKey) {
     // In the case of None, we default to the date column
     // This appears to be the case in such instances as
     // Global search, so don't complain about it.
     case nsMsgViewSortType.byNone:
     case nsMsgViewSortType.byDate:
@@ -614,17 +614,17 @@ var gCurSortType;
 
 // CreateDBView is called when we have a thread pane. CreateBareDBView is called when there is no
 // tree associated with the view. CreateDBView will call into CreateBareDBView...
 
 function CreateBareDBView(originalView, msgFolder, viewType, viewFlags, sortType, sortOrder)
 {
   var dbviewContractId = "@mozilla.org/messenger/msgdbview;1?type=";
   // hack to turn this into an integer, if it was a string
-  // it would be a string if it came from localStore.rdf
+  // it would be a string if it came from xulstore.json
   viewType = viewType - 0;
 
   switch (viewType) {
       case nsMsgViewType.eShowQuickSearchResults:
           dbviewContractId += "quicksearch";
           break;
       case nsMsgViewType.eShowSearch:
           dbviewContractId += "search";