--- a/browser/base/content/browser-places.js
+++ b/browser/base/content/browser-places.js
@@ -210,37 +210,37 @@ var StarUI = {
}, delay);
this._autoCloseTimerEnabled = true;
}
break;
}
},
_bookmarkPopupInitialized: false,
- async showEditBookmarkPopup(aNode, aAnchorElement, aPosition, aIsNewBookmark, aUrl) {
+ async showEditBookmarkPopup(aNode, aAnchorElement, aPosition, aIsNewBookmark, aUrl, aIsCurrentBrowser = true) {
// Slow double-clicks (not true double-clicks) shouldn't
// cause the panel to flicker.
if (this.panel.state == "showing" ||
this.panel.state == "open") {
return;
}
this._isNewBookmark = aIsNewBookmark;
this._itemGuids = null;
if (this._bookmarkPopupInitialized) {
- await this._doShowEditBookmarkPanel(aNode, aAnchorElement, aPosition, aUrl);
+ await this._doShowEditBookmarkPanel(aNode, aAnchorElement, aPosition, aUrl, aIsCurrentBrowser);
return;
}
this._bookmarkPopupInitialized = true;
- await this._doShowEditBookmarkPanel(aNode, aAnchorElement, aPosition, aUrl);
+ await this._doShowEditBookmarkPanel(aNode, aAnchorElement, aPosition, aUrl, aIsCurrentBrowser);
},
- async _doShowEditBookmarkPanel(aNode, aAnchorElement, aPosition, aUrl) {
+ async _doShowEditBookmarkPanel(aNode, aAnchorElement, aPosition, aUrl, aIsCurrentBrowser) {
if (this.panel.state != "closed")
return;
this._blockCommands(); // un-done in the popuphidden handler
this._element("editBookmarkPanelTitle").value =
this._isNewBookmark ?
gNavigatorBundle.getString("editBookmarkPanel.newBookmarkTitle") :
@@ -266,16 +266,18 @@ var StarUI = {
let forms = gNavigatorBundle.getString("editBookmark.removeBookmarks.label");
let label = PluralForm.get(bookmarksCount, forms)
.replace("#1", bookmarksCount);
removeButton.label = label;
removeButton.setAttribute("accesskey",
gNavigatorBundle.getString("editBookmark.removeBookmarks.accesskey"));
}
+ this._setIconAndPreviewImage(aIsCurrentBrowser);
+
this.beginBatch();
if (aAnchorElement && aAnchorElement.closest("#urlbar")) {
this._anchorToolbarButton = aAnchorElement;
aAnchorElement.setAttribute("open", "true");
} else {
this._anchorToolbarButton = null;
}
@@ -285,26 +287,50 @@ var StarUI = {
if (target.parentNode) {
// By targeting the panel's parent and using a capturing listener, we
// can have our listener called before others waiting for the panel to
// be shown (which probably expect the panel to be fully initialized)
target = target.parentNode;
}
target.addEventListener("popupshown", function(event) {
fn();
- }, {"capture": true, "once": true});
+ }, {capture: true, once: true});
};
gEditItemOverlay.initPanel({ node: aNode,
onPanelReady,
hiddenRows: ["location",
"loadInSidebar", "keyword"],
focusedElement: "preferred"});
+
this.panel.openPopup(aAnchorElement, aPosition);
},
+ _setIconAndPreviewImage(aIsCurrentBrowser) {
+ let faviconImage = this._element("editBookmarkPanelFavicon");
+ faviconImage.removeAttribute("iconloadingprincipal");
+ faviconImage.removeAttribute("src");
+
+ document.mozSetImageElement("editBookmarkPanelImageCanvas", null);
+
+ if (!aIsCurrentBrowser) {
+ return;
+ }
+
+ let tab = gBrowser.selectedTab;
+ if (tab.hasAttribute("image") && !tab.hasAttribute("busy")) {
+ faviconImage.setAttribute("iconloadingprincipal",
+ tab.getAttribute("iconloadingprincipal"));
+ faviconImage.setAttribute("src", tab.getAttribute("image"));
+ }
+
+ let canvas = PageThumbs.createCanvas(window);
+ PageThumbs.captureToCanvas(gBrowser.selectedBrowser, canvas);
+ document.mozSetImageElement("editBookmarkPanelImageCanvas", canvas);
+ },
+
panelShown:
function SU_panelShown(aEvent) {
if (aEvent.target == this.panel) {
if (this._element("editBookmarkPanelContent").hidden) {
// Note this isn't actually used anymore, we should remove this
// once we decide not to bring back the page bookmarked notification
this.panel.focus();
}
@@ -392,16 +418,17 @@ var PlacesCommandHook = {
* Option to provide a URL to bookmark rather than the current page
* @param [optional] aTitle
* Option to provide a title for a bookmark to use rather than the
* getting the current page's title
*/
async bookmarkPage(aBrowser, aShowEditUI, aUrl = null, aTitle = null) {
// If aUrl is provided, we want to bookmark that url rather than the
// the current page
+ let isCurrentBrowser = !aUrl;
let url = aUrl ? new URL(aUrl) : new URL(aBrowser.currentURI.spec);
let info = await PlacesUtils.bookmarks.fetch({ url });
let isNewBookmark = !info;
if (!info) {
let parentGuid = PlacesUtils.bookmarks.unfiledGuid;
info = { url, parentGuid };
// Bug 1148838 - Make this code work for full page plugins.
let charset = null;
@@ -447,23 +474,23 @@ var PlacesCommandHook = {
if (!aShowEditUI)
return;
let node = await PlacesUIUtils.promiseNodeLikeFromFetchInfo(info);
let anchor = BookmarkingUI.anchor;
if (anchor) {
await StarUI.showEditBookmarkPopup(node, anchor, "bottomcenter topright",
- isNewBookmark, url);
+ isNewBookmark, url, isCurrentBrowser);
return;
}
// Fall back to showing the panel over the content area.
await StarUI.showEditBookmarkPopup(node, aBrowser, "overlap", isNewBookmark,
- url);
+ url, isCurrentBrowser);
},
/**
* Adds a bookmark to the page targeted by a link.
* @param parentId
* The folder in which to create a new bookmark if aURL isn't
* bookmarked.
* @param url (string)