Bug 880399 - Move star button out from URL bar into the bookmarks-menu-button. r=mak.

This commit is contained in:
Mike Conley 2013-06-07 14:46:53 -04:00
parent 14b435f616
commit 64cd9db990
13 changed files with 147 additions and 124 deletions

View File

@ -994,8 +994,7 @@ let PlacesToolbarHelper = {
//// BookmarkingUI
/**
* Handles the bookmarks star button in the URL bar, as well as the bookmark
* menu button.
* Handles the bookmarks menu-button in the toolbar.
*/
let BookmarkingUI = {
@ -1007,18 +1006,22 @@ let BookmarkingUI = {
},
get star() {
if (!this._star) {
this._star = document.getElementById("star-button");
if (!this._star && this.button) {
this._star = document.getAnonymousElementByAttribute(this.button,
"anonid",
"button");
}
return this._star;
},
get anchor() {
if (this.star && isElementVisible(this.star)) {
if (!this._anchor && this.star && isElementVisible(this.star)) {
// Anchor to the icon, so the panel looks more natural.
return this.star;
this._anchor = document.getAnonymousElementByAttribute(this.star,
"class",
"toolbarbutton-icon");
}
return null;
return this._anchor;
},
STATUS_UPDATING: -1,
@ -1027,9 +1030,9 @@ let BookmarkingUI = {
get status() {
if (this._pendingStmt)
return this.STATUS_UPDATING;
return this.star &&
this.star.hasAttribute("starred") ? this.STATUS_STARRED
: this.STATUS_UNSTARRED;
return this.button &&
this.button.hasAttribute("starred") ? this.STATUS_STARRED
: this.STATUS_UNSTARRED;
},
get _starredTooltip()
@ -1098,11 +1101,12 @@ let BookmarkingUI = {
if (aState == "invalid") {
this.star.setAttribute("disabled", "true");
this.star.removeAttribute("starred");
this.button.removeAttribute("starred");
}
else {
this.star.removeAttribute("disabled");
}
this._updateToolbarStyle();
},
_updateToolbarStyle: function BUI__updateToolbarStyle() {
@ -1143,6 +1147,8 @@ let BookmarkingUI = {
customizeDone: function BUI_customizeDone() {
delete this._button;
delete this._star;
delete this._anchor;
this.onToolbarVisibilityChange();
this._updateToolbarStyle();
},
@ -1162,7 +1168,7 @@ let BookmarkingUI = {
},
updateStarState: function BUI_updateStarState() {
if (!this.star || (this._uri && gBrowser.currentURI.equals(this._uri))) {
if (!this.button || (this._uri && gBrowser.currentURI.equals(this._uri))) {
return;
}
@ -1211,17 +1217,17 @@ let BookmarkingUI = {
},
_updateStar: function BUI__updateStar() {
if (!this.star) {
if (!this.button) {
return;
}
if (this._itemIds.length > 0) {
this.star.setAttribute("starred", "true");
this.star.setAttribute("tooltiptext", this._starredTooltip);
this.button.setAttribute("starred", "true");
this.button.setAttribute("tooltiptext", this._starredTooltip);
}
else {
this.star.removeAttribute("starred");
this.star.setAttribute("tooltiptext", this._unstarredTooltip);
this.button.removeAttribute("starred");
this.button.setAttribute("tooltiptext", this._unstarredTooltip);
}
},
@ -1238,6 +1244,10 @@ let BookmarkingUI = {
// nsINavBookmarkObserver
onItemAdded: function BUI_onItemAdded(aItemId, aParentId, aIndex, aItemType,
aURI) {
if (!this.button) {
return;
}
if (aURI && aURI.equals(this._uri)) {
// If a new bookmark has been added to the tracked uri, register it.
if (this._itemIds.indexOf(aItemId) == -1) {
@ -1248,6 +1258,10 @@ let BookmarkingUI = {
},
onItemRemoved: function BUI_onItemRemoved(aItemId) {
if (!this.button) {
return;
}
let index = this._itemIds.indexOf(aItemId);
// If one of the tracked bookmarks has been removed, unregister it.
if (index != -1) {
@ -1258,6 +1272,10 @@ let BookmarkingUI = {
onItemChanged: function BUI_onItemChanged(aItemId, aProperty,
aIsAnnotationProperty, aNewValue) {
if (!this.button) {
return;
}
if (aProperty == "uri") {
let index = this._itemIds.indexOf(aItemId);
// If the changed bookmark was tracked, check if it is now pointing to

View File

@ -314,18 +314,20 @@ toolbarbutton.bookmark-item {
max-width: 13em;
}
%ifdef MENUBAR_CAN_AUTOHIDE
#toolbar-menubar:not([autohide="true"]) ~ toolbar > #bookmarks-menu-button,
#toolbar-menubar:not([autohide="true"]) > #bookmarks-menu-button {
display: none;
}
%endif
#editBMPanel_tagsSelector {
/* override default listbox width from xul.css */
width: auto;
}
/* The star doesn't make sense as text */
toolbar[mode="text"] #bookmarks-menu-button > .toolbarbutton-menubutton-button > .toolbarbutton-icon {
display: -moz-box !important;
}
toolbar[mode="text"] #bookmarks-menu-button > .toolbarbutton-menubutton-button > .toolbarbutton-text,
toolbar[mode="full"] #bookmarks-menu-button.bookmark-item > .toolbarbutton-menubutton-button > .toolbarbutton-text {
display: none;
}
menupopup[emptyplacesresult="true"] > .hide-if-empty-places-result {
display: none;
}

View File

@ -668,9 +668,6 @@
hidden="true"
tooltiptext="&pageReportIcon.tooltip;"
onclick="gPopupBlockerObserver.onReportButtonClick(event);"/>
<image id="star-button"
class="urlbar-icon"
onclick="BookmarkingUI.onCommand(event);"/>
<image id="go-button"
class="urlbar-icon"
tooltiptext="&goEndCap.tooltip;"
@ -877,13 +874,14 @@
class="toolbarbutton-1 chromeclass-toolbar-additional"
persist="class"
removable="true"
type="menu"
type="menu-button"
label="&bookmarksMenuButton.label;"
tooltiptext="&bookmarksMenuButton.tooltip;"
ondragenter="PlacesMenuDNDHandler.onDragEnter(event);"
ondragover="PlacesMenuDNDHandler.onDragOver(event);"
ondragleave="PlacesMenuDNDHandler.onDragLeave(event);"
ondrop="PlacesMenuDNDHandler.onDrop(event);">
ondrop="PlacesMenuDNDHandler.onDrop(event);"
oncommand="BookmarkingUI.onCommand(event);">
<menupopup id="BMB_bookmarksPopup"
placespopup="true"
context="placesContext"
@ -906,13 +904,6 @@
command="Browser:ShowAllBookmarks"
key="manBookmarkKb"/>
<menuseparator/>
<menuitem id="BMB_bookmarkThisPage"
#ifndef XP_MACOSX
class="menuitem-iconic"
#endif
label="&bookmarkThisPageCmd.label;"
command="Browser:AddBookmarkAs"
key="addBookmarkAsKb"/>
<menuitem id="BMB_subscribeToPageMenuitem"
#ifndef XP_MACOSX
class="menuitem-iconic"

View File

@ -11,10 +11,10 @@ function test() {
tab.linkedBrowser.addEventListener("load", (function(event) {
tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
is(BookmarkingUI.star.getAttribute("tooltiptext"),
is(BookmarkingUI.button.getAttribute("tooltiptext"),
BookmarkingUI._unstarredTooltip,
"Star icon should have the unstarred tooltip text");
gBrowser.removeCurrentTab();
finish();
}), true);

View File

@ -1179,7 +1179,7 @@ BrowserGlue.prototype = {
},
_migrateUI: function BG__migrateUI() {
const UI_VERSION = 15;
const UI_VERSION = 16;
const BROWSER_DOCURL = "chrome://browser/content/browser.xul#";
let currentUIVersion = 0;
try {
@ -1397,6 +1397,33 @@ BrowserGlue.prototype = {
}
}
// Insert the bookmarks-menu-button into the nav-bar if it isn't already
// there.
if (currentUIVersion < 16) {
let currentsetResource = this._rdf.GetResource("currentset");
let toolbarResource = this._rdf.GetResource(BROWSER_DOCURL + "nav-bar");
let currentset = this._getPersist(toolbarResource, currentsetResource);
// Need to migrate only if toolbar is customized.
if (currentset) {
if (!currentset.contains("bookmarks-menu-button")) {
// The button isn't in the nav-bar, so let's look for an appropriate
// place to put it.
if (currentset.contains("downloads-button")) {
currentset = currentset.replace(/(^|,)downloads-button($|,)/,
"$1bookmarks-menu-button,downloads-button$2");
} else if (currentset.contains("home-button")) {
currentset = currentset.replace(/(^|,)home-button($|,)/,
"$1bookmarks-menu-button,home-button$2");
} else {
// Just append.
currentset = currentset.replace(/(^|,)window-controls($|,)/,
"$1bookmarks-menu-button,window-controls$2")
}
this._setPersist(toolbarResource, currentsetResource, currentset);
}
}
}
if (this._dirty)
this._dataSource.QueryInterface(Ci.nsIRDFRemoteDataSource).Flush();

View File

@ -478,10 +478,6 @@ menuitem:not([type]):not(.menuitem-tooltip):not(.menuitem-iconic-tooltip) {
list-style-image: url("chrome://browser/skin/places/bookmarksToolbar.png");
}
#BMB_bookmarkThisPage {
list-style-image: url("chrome://browser/skin/places/starPage.png");
}
#BMB_unsortedBookmarks {
list-style-image: url("chrome://browser/skin/places/unsortedBookmarks.png");
}
@ -644,18 +640,10 @@ toolbar > .customization-target > toolbarpaletteitem > #history-panelmenu {
-moz-image-region: rect(0px 48px 24px 24px);
}
#bookmarks-menu-button {
#bookmarks-button {
-moz-image-region: rect(0px 72px 24px 48px);
}
#bookmarks-menu-button.bookmark-item {
list-style-image: url("chrome://browser/skin/Toolbar-small.png");
}
#bookmarks-menu-button.toolbarbutton-1 {
-moz-box-orient: horizontal;
}
#print-button {
list-style-image: url("moz-icon://stock/gtk-print?size=toolbar");
}
@ -808,8 +796,7 @@ toolbar[iconsize="small"] #webrtc-status-button /* temporary placeholder (bug 82
-moz-image-region: rect(0px 32px 16px 16px);
}
toolbar[iconsize="small"] #bookmarks-menu-button,
#bookmarks-menu-button.bookmark-item {
toolbar[iconsize="small"] #bookmarks-button {
-moz-image-region: rect(0px 48px 16px 32px);
}
@ -1508,17 +1495,28 @@ richlistitem[type~="action"][actiontype="switchtab"] > .ac-url-box > .ac-action-
-moz-image-region: rect(0, 16px, 16px, 0);
}
/* Star button */
#star-button {
list-style-image: url("chrome://browser/skin/places/starPage.png");
}
#star-button[starred="true"] {
list-style-image: url("chrome://browser/skin/places/pageStarred.png");
}
/* bookmarks menu-button */
#bookmarks-menu-button {
list-style-image: url("chrome://browser/skin/Toolbar.png");
-moz-image-region: rect(0px 216px 24px 192px);
}
#bookmarks-menu-button[starred] {
-moz-image-region: rect(24px 216px 48px 192px);
}
toolbar[iconsize="small"] #bookmarks-menu-button,
#bookmarks-menu-button.bookmark-item {
list-style-image: url("chrome://browser/skin/Toolbar-small.png");
-moz-image-region: rect(0px 144px 16px 128px);
}
toolbar[iconsize="small"] #bookmarks-menu-button[starred],
#bookmarks-menu-button.bookmark-item[starred] {
-moz-image-region: rect(16px 144px 32px 128px);
}
#bookmarks-menu-button[disabled] > .toolbarbutton-icon,
#bookmarks-menu-button[disabled] > .toolbarbutton-menu-dropmarker,
#bookmarks-menu-button[disabled] > .toolbarbutton-menubutton-dropmarker,

View File

@ -91,7 +91,6 @@ browser.jar:
skin/classic/browser/places/calendar.png (places/calendar.png)
* skin/classic/browser/places/editBookmarkOverlay.css (places/editBookmarkOverlay.css)
skin/classic/browser/places/livemark-item.png (places/livemark-item.png)
skin/classic/browser/places/pageStarred.png (places/pageStarred.png)
skin/classic/browser/places/star-icons.png (places/star-icons.png)
skin/classic/browser/places/starred48.png (places/starred48.png)
skin/classic/browser/places/unstarred48.png (places/unstarred48.png)
@ -99,7 +98,6 @@ browser.jar:
skin/classic/browser/places/organizer.css (places/organizer.css)
skin/classic/browser/places/organizer.xml (places/organizer.xml)
skin/classic/browser/places/query.png (places/query.png)
skin/classic/browser/places/starPage.png (places/starPage.png)
skin/classic/browser/places/tag.png (places/tag.png)
skin/classic/browser/places/toolbarDropMarker.png (places/toolbarDropMarker.png)
skin/classic/browser/places/unsortedBookmarks.png (places/unsortedBookmarks.png)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 767 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 723 B

View File

@ -886,32 +886,14 @@ toolbar > .customization-target > toolbarpaletteitem > #history-panelmenu {
/* bookmark sidebar & menu buttons */
#bookmarks-menu-button {
#bookmarks-button {
-moz-image-region: rect(0, 180px, 20px, 160px);
}
#bookmarks-menu-button.bookmark-item {
-moz-image-region: rect(2px, 178px, 18px, 162px);
list-style-image: url("chrome://browser/skin/Toolbar.png");
}
@media (min-resolution: 2dppx) {
#bookmarks-menu-button {
#bookmarks-button {
-moz-image-region: rect(0, 360px, 40px, 320px);
}
#bookmarks-menu-button.bookmark-item {
-moz-image-region: rect(4px, 356px, 36px, 324px);
list-style-image: url("chrome://browser/skin/Toolbar@2x.png");
}
#bookmarks-menu-button.bookmark-item > .toolbarbutton-icon {
width: 16px;
}
}
#bookmarks-menu-button.toolbarbutton-1 {
-moz-box-orient: horizontal;
}
/* print button */
@ -1727,35 +1709,50 @@ richlistitem[type~="action"][actiontype="switchtab"][selected="true"] > .ac-url-
-moz-image-region: rect(0, 16px, 16px, 0);
}
/* Star button */
#star-button {
/* bookmarks menu-button */
#bookmarks-menu-button {
-moz-image-region: rect(0px 500px 20px 480px);
}
#bookmarks-menu-button[starred] {
-moz-image-region: rect(20px 500px 40px 480px);
}
#bookmarks-menu-button.bookmark-item {
list-style-image: url("chrome://browser/skin/places/star-icons.png");
-moz-image-region: rect(0, 16px, 16px, 0);
-moz-image-region: rect(0px 16px 16px 0px);
}
#star-button:hover:active,
#star-button[starred="true"] {
-moz-image-region: rect(0, 32px, 16px, 16px);
#bookmarks-menu-button.bookmark-item[starred] {
-moz-image-region: rect(0px 32px 16px 16px);
}
#star-button:hover:active[starred="true"] {
-moz-image-region: rect(0, 48px, 16px, 32px);
#bookmarks-menu-button.bookmark-item > .toolbarbutton-menubutton-button {
padding: 0;
}
@media (min-resolution: 2dppx) {
#star-button {
#bookmarks-menu-button {
-moz-image-region: rect(0px, 1000px, 40px, 960px);
}
#bookmarks-menu-button[starred] {
-moz-image-region: rect(40px, 1000px, 80px, 960px);
}
#bookmarks-menu-button.bookmark-item {
list-style-image: url("chrome://browser/skin/places/star-icons@2x.png");
-moz-image-region: rect(0, 32px, 32px, 0);
width: 22px;
-moz-image-region: rect(0px 32px 32px 0px);
}
#star-button:hover:active,
#star-button[starred="true"] {
-moz-image-region: rect(0, 64px, 32px, 32px);
#bookmarks-menu-button.bookmark-item[starred] {
-moz-image-region: rect(0px 64px 32px 32px);
}
#star-button:hover:active[starred="true"] {
-moz-image-region: rect(0, 96px, 32px, 64px);
#bookmarks-menu-button.bookmark-item > .toolbarbutton-menubutton-button > .toolbarbutton-icon {
width: 16px;
}
}

View File

@ -217,7 +217,7 @@ toolbarbutton.bookmark-item[open="true"] {
-moz-padding-end: 2px;
}
.bookmark-item:not(#bookmarks-menu-button) > .toolbarbutton-icon {
.bookmark-item > .toolbarbutton-icon {
width: 16px;
height: 16px;
}
@ -691,18 +691,10 @@ toolbar > .customization-target > toolbarpaletteitem > #history-panelmenu {
-moz-image-region: rect(0, 126px, 18px, 108px);
}
#bookmarks-menu-button {
#bookmarks-button {
-moz-image-region: rect(0, 144px, 18px, 126px);
}
#bookmarks-menu-button.bookmark-item {
list-style-image: url("chrome://browser/skin/Toolbar.png");
}
#bookmarks-menu-button.bookmark-item:-moz-lwtheme-brighttext {
list-style-image: url("chrome://browser/skin/Toolbar-inverted.png");
}
#print-button {
-moz-image-region: rect(0, 162px, 18px, 144px);
}
@ -1416,25 +1408,27 @@ richlistitem[type~="action"][actiontype="switchtab"] > .ac-url-box > .ac-action-
-moz-image-region: rect(0, 16px, 16px, 0);
}
/* star button */
/* bookmarks menu-button */
#star-button {
#bookmarks-menu-button {
-moz-image-region: rect(0px 378px 18px 360px);
}
#bookmarks-menu-button[starred] {
-moz-image-region: rect(18px 378px 36px 360px);
}
#bookmarks-menu-button.bookmark-item {
list-style-image: url("chrome://browser/skin/places/bookmark.png");
-moz-image-region: rect(0px 16px 16px 0px);
}
#star-button:hover {
background-image: radial-gradient(circle closest-side, hsla(45,100%,73%,.3), hsla(45,100%,73%,0));
-moz-image-region: rect(0px 32px 16px 16px);
}
#star-button:hover:active {
background-image: radial-gradient(circle closest-side, hsla(45,100%,73%,.1), hsla(45,100%,73%,0));
#bookmarks-menu-button.bookmark-item[starred] {
-moz-image-region: rect(0px 48px 16px 32px);
}
#star-button[starred] {
list-style-image: url("chrome://browser/skin/places/editBookmark.png");
#bookmarks-menu-button.bookmark-item > .toolbarbutton-menubutton-button> .toolbarbutton-icon {
-moz-margin-start: 5px;
}
/* bookmarking panel */

View File

@ -102,7 +102,6 @@ browser.jar:
skin/classic/browser/newtab/noise.png (newtab/noise.png)
skin/classic/browser/places/places.css (places/places.css)
* skin/classic/browser/places/organizer.css (places/organizer.css)
skin/classic/browser/places/editBookmark.png (places/editBookmark.png)
skin/classic/browser/places/bookmark.png (places/bookmark.png)
skin/classic/browser/places/query.png (places/query.png)
skin/classic/browser/places/bookmarksMenu.png (places/bookmarksMenu.png)
@ -371,7 +370,6 @@ browser.jar:
* skin/classic/aero/browser/places/places.css (places/places-aero.css)
* skin/classic/aero/browser/places/organizer.css (places/organizer-aero.css)
skin/classic/aero/browser/places/bookmark.png (places/bookmark.png)
skin/classic/aero/browser/places/editBookmark.png (places/editBookmark.png)
skin/classic/aero/browser/places/query.png (places/query-aero.png)
skin/classic/aero/browser/places/bookmarksMenu.png (places/bookmarksMenu-aero.png)
skin/classic/aero/browser/places/bookmarksToolbar.png (places/bookmarksToolbar-aero.png)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB