Bug 571752 - Add History to the Firefox button menu. r=dao
authorMarco Bonardo <mbonardo@mozilla.com>
Wed, 16 Jun 2010 12:00:31 +0200
changeset 43676 2e666a1a2c7ec9f8a66405d21e07554badba7e01
parent 43675 60a14de5241c9955a0b5e0a2181c1a88f3ee2692
child 43677 053a165000e3c79cd3251a39f72ed3df5806ec3c
push id13850
push usermak77@bonardo.net
push dateWed, 16 Jun 2010 10:01:27 +0000
treeherdermozilla-central@2e666a1a2c7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdao
bugs571752
milestone1.9.3a6pre
first release with
nightly linux32
2e666a1a2c7e / 3.7a6pre / 20100616030029 / files
nightly linux64
2e666a1a2c7e / 3.7a6pre / 20100616030741 / files
nightly mac
2e666a1a2c7e / 3.7a6pre / 20100616030700 / files
nightly win32
2e666a1a2c7e / 3.7a6pre / 20100616035900 / files
nightly win64
2e666a1a2c7e / 3.7a6pre / 20100616034239 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 571752 - Add History to the Firefox button menu. r=dao
browser/base/content/browser-menubar.inc
browser/base/content/browser-places.js
browser/base/content/browser.css
browser/base/content/browser.xul
browser/components/places/content/browserPlacesViews.js
--- a/browser/base/content/browser-menubar.inc
+++ b/browser/base/content/browser-menubar.inc
@@ -450,25 +450,25 @@
                           hidden="true"
                           label="&bidiSwitchPageDirectionItem.label;"
                           accesskey="&bidiSwitchPageDirectionItem.accesskey;"
                           oncommand="SwitchDocumentDirection(window.content)"/>
               </menupopup>
             </menu>
 
             <menu id="history-menu"
-                  oncommand="this._placesView._onCommand(event);"
-                  onclick="checkForMiddleClick(this, event);"
                   label="&historyMenu.label;"
                   accesskey="&historyMenu.accesskey;">
               <menupopup id="goPopup"
 #ifndef XP_MACOSX
                          placespopup="true"
 #endif
-                         onpopupshowing="if (!document.getElementById('history-menu')._placesView)
+                         oncommand="this.parentNode._placesView._onCommand(event);"
+                         onclick="checkForMiddleClick(this, event);"
+                         onpopupshowing="if (!this.parentNode._placesView)
                                            new HistoryMenu(event);"
                          tooltip="bhTooltip"
                          popupsinherittooltip="true">
                 <menuitem id="historyMenuBack"
                           label="&backCmd.label;"
 #ifdef XP_MACOSX
                           key="goBackKb2"
 #else
@@ -492,17 +492,19 @@
                           key="goHome"/>
                 <menuitem id="menu_showAllHistory"
                           label="&showAllHistoryCmd2.label;"
 #ifndef XP_MACOSX
                           key="showAllHistoryKb"
 #endif
                           command="Browser:ShowAllHistory"/>
                 <menuseparator id="startHistorySeparator"/>
-                <menuseparator id="endHistorySeparator" builder="end"/>
+                <menuseparator id="endHistorySeparator"
+                               class="hide-if-empty-places-result"
+                               builder="end"/>
                 <menu id="historyUndoMenu"
                       label="&historyUndoMenu.label;"
                       disabled="true">
                   <menupopup id="historyUndoPopup"
 #ifndef XP_MACOSX
                              placespopup="true"
 #endif
                              onpopupshowing="document.getElementById('history-menu')._placesView.populateUndoSubmenu();"/>
@@ -528,17 +530,17 @@
     <menupopup id="bookmarksMenuPopup"
 #ifndef XP_MACOSX
                placespopup="true"
 #endif
                context="placesContext"
                openInTabs="children"
                oncommand="BookmarksEventHandler.onCommand(event);"
                onclick="BookmarksEventHandler.onClick(event);"
-               onpopupshowing="if (!document.getElementById('bookmarksMenu')._placesView)
+               onpopupshowing="if (!this.parentNode._placesView)
                                  new PlacesMenu(event, 'place:folder=BOOKMARKS_MENU');"
                tooltip="bhTooltip" popupsinherittooltip="true">
       <menuitem id="menu_bookmarkThisPage"
                 label="&bookmarkThisPageCmd.label;"
                 command="Browser:AddBookmarkAs"
                 key="addBookmarkAsKb"/>
       <menuitem id="subscribeToPageMenuitem"
                 label="&subscribeToPageMenuitem.label;"
--- a/browser/base/content/browser-places.js
+++ b/browser/base/content/browser-places.js
@@ -744,21 +744,16 @@ HistoryMenu.prototype = {
 
   _onPopupShowing: function HM__onPopupShowing(aEvent) {
     PlacesMenu.prototype._onPopupShowing.apply(this, arguments);
 
     // Don't handle events for submenus.
     if (aEvent.target != aEvent.currentTarget)
       return;
 
-    let resultNode = this.result.root;
-    resultNode.containerOpen = true;
-    document.getElementById("endHistorySeparator").hidden =
-      resultNode.childCount == 0;
-
     this.toggleRecentlyClosedTabs();
     this.toggleRecentlyClosedWindows();
   },
 
   _onCommand: function HM__onCommand(aEvent) {
     let placesNode = aEvent.target._placesNode;
     if (placesNode) {
       PlacesUIUtils.markPageAsTyped(placesNode.uri);
--- a/browser/base/content/browser.css
+++ b/browser/base/content/browser.css
@@ -187,16 +187,20 @@ toolbarbutton.bookmark-item {
   max-width: 13em;
 }
 
 #editBMPanel_tagsSelector {
   /* override default listbox width from xul.css */
   width: auto;
 }
 
+menupopup[emptyplacesresult="true"] > .hide-if-empty-places-result {
+  display: none;
+}
+
 menuitem.spell-suggestion {
   font-weight: bold;
 }
 
 #sidebar-header > .tabs-closebutton {
   -moz-user-focus: normal;
 }
 
--- a/browser/base/content/browser.xul
+++ b/browser/base/content/browser.xul
@@ -416,16 +416,39 @@
             </menupopup>
           </menu>
         </hbox>
         <menuitem id="appmenu_find"
                   label="&findOnCmd.label;"
                   key="key_find"
                   command="cmd_find"/>
         <menuseparator/>
+        <menu id="appmenu_history"
+              label="&historyMenu.label;">
+          <menupopup id="appmenu_history_popup"
+                     placespopup="true"
+                     oncommand="this.parentNode._placesView._onCommand(event);"
+                     onclick="checkForMiddleClick(this, event);"
+                     onpopupshowing="if (!this.parentNode._placesView)
+                                       new HistoryMenu(event);"
+                     tooltip="bhTooltip"
+                     popupsinherittooltip="true">
+            <menuitem id="appmenu_sanitizeHistory"
+                      label="&clearRecentHistory.label;"
+                      key="key_sanitize"
+                      command="Tools:Sanitize"/>
+            <menuseparator/>
+            <menuitem id="appmenu_showAllHistory"
+                      label="&showAllHistoryCmd2.label;"
+                      key="showAllHistoryKb"
+                      command="Browser:ShowAllHistory"/>
+            <menuseparator class="hide-if-empty-places-result"/>
+          </menupopup>
+        </menu>
+        <menuseparator/>
         <menu id="appmenu_customize"
               label="&appMenuCustomize.label;">
           <menupopup id="appmenu_customizeMenu"
                      onpopupshowing="onViewToolbarsPopupShowing(event);">
             <menuseparator/>
             <menuitem command="cmd_ToggleTabsOnTop"
                       type="checkbox"
                       label="&viewTabsOnTop.label;"/>
--- a/browser/components/places/content/browserPlacesViews.js
+++ b/browser/components/places/content/browserPlacesViews.js
@@ -251,25 +251,27 @@ PlacesViewBase.prototype = {
       this._ensureLivemarkStatusMenuItem(aPopup);
 
     let resultNode = aPopup._placesNode;
     if (!resultNode.containerOpen)
       return;
 
     let cc = resultNode.childCount;
     if (cc > 0) {
+      aPopup.removeAttribute("emptyplacesresult");
       if (aPopup._emptyMenuItem)
         aPopup._emptyMenuItem.hidden = true;
 
       for (let i = 0; i < cc; ++i) {
         let child = resultNode.getChild(i);
         this._insertNewItemToPopup(child, aPopup, null);
       }
     }
     else {
+      aPopup.setAttribute("emptyplacesresult", "true");
       // This menu is empty.  If there is no static content, add
       // an element to show it is empty.
       if (aPopup._startMarker == -1 && aPopup._endMarker == -1)
         this._showEmptyMenuItem(aPopup);
     }
     aPopup._built = true;
   },