Bug 1448362 - Remove some unused code from Places. r=standard8
MozReview-Commit-ID: DQCoYyZIvGD
--- a/browser/base/content/browser-places.js
+++ b/browser/base/content/browser-places.js
@@ -334,24 +334,16 @@ var StarUI = {
return;
this._batchBlockingDeferred.resolve();
this._batchBlockingDeferred = null;
this._batching = false;
}
};
-// Checks if an element is visible without flushing layout changes.
-function isVisible(element) {
- let windowUtils = window.QueryInterface(Ci.nsIInterfaceRequestor)
- .getInterface(Ci.nsIDOMWindowUtils);
- let bounds = windowUtils.getBoundsWithoutFlushing(element);
- return bounds.height > 0 && bounds.width > 0;
-}
-
var PlacesCommandHook = {
/**
* Adds a bookmark to the page loaded in the given browser.
*
* @param aBrowser
* a <browser> element.
* @param [optional] aShowEditUI
* whether or not to show the edit-bookmark UI for the bookmark item
@@ -1567,79 +1559,16 @@ var BookmarkingUI = {
if (event.target != event.currentTarget)
return;
this.updateBookmarkPageMenuItem();
PlacesCommandHook.updateBookmarkAllTabsCommand();
this._initMobileBookmarks(document.getElementById("menu_mobileBookmarks"));
},
- _showBookmarkedNotification: function BUI_showBookmarkedNotification() {
- function getCenteringTransformForRects(rectToPosition, referenceRect) {
- let topDiff = referenceRect.top - rectToPosition.top;
- let leftDiff = referenceRect.left - rectToPosition.left;
- let heightDiff = referenceRect.height - rectToPosition.height;
- let widthDiff = referenceRect.width - rectToPosition.width;
- return [(leftDiff + .5 * widthDiff) + "px", (topDiff + .5 * heightDiff) + "px"];
- }
-
- if (this._notificationTimeout) {
- clearTimeout(this._notificationTimeout);
- }
-
- if (this.notifier.style.transform == "") {
- // Get all the relevant nodes and computed style objects
- let dropmarker = document.getAnonymousElementByAttribute(this.button, "anonid", "dropmarker");
- let dropmarkerIcon = document.getAnonymousElementByAttribute(dropmarker, "class", "dropmarker-icon");
- let dropmarkerStyle = getComputedStyle(dropmarkerIcon);
-
- // Check for RTL and get bounds
- let isRTL = getComputedStyle(this.button).direction == "rtl";
- let buttonRect = this.button.getBoundingClientRect();
- let notifierRect = this.notifier.getBoundingClientRect();
- let dropmarkerRect = dropmarkerIcon.getBoundingClientRect();
- let dropmarkerNotifierRect = this.dropmarkerNotifier.getBoundingClientRect();
-
- // Compute, but do not set, transform for star icon
- let [translateX, translateY] = getCenteringTransformForRects(notifierRect, buttonRect);
- let starIconTransform = "translate(" + translateX + ", " + translateY + ")";
- if (isRTL) {
- starIconTransform += " scaleX(-1)";
- }
-
- // Compute, but do not set, transform for dropmarker
- [translateX, translateY] = getCenteringTransformForRects(dropmarkerNotifierRect, dropmarkerRect);
- let dropmarkerTransform = "translate(" + translateX + ", " + translateY + ")";
-
- // Do all layout invalidation in one go:
- this.notifier.style.transform = starIconTransform;
- this.dropmarkerNotifier.style.transform = dropmarkerTransform;
-
- let dropmarkerAnimationNode = this.dropmarkerNotifier.firstChild;
- dropmarkerAnimationNode.style.listStyleImage = dropmarkerStyle.listStyleImage;
- dropmarkerAnimationNode.style.fill = dropmarkerStyle.fill;
- }
-
- let isInOverflowPanel = this.button.getAttribute("overflowedItem") == "true";
- if (!isInOverflowPanel) {
- this.notifier.setAttribute("notification", "finish");
- this.button.setAttribute("notification", "finish");
- this.dropmarkerNotifier.setAttribute("notification", "finish");
- }
-
- this._notificationTimeout = setTimeout( () => {
- this.notifier.removeAttribute("notification");
- this.dropmarkerNotifier.removeAttribute("notification");
- this.button.removeAttribute("notification");
-
- this.dropmarkerNotifier.style.transform = "";
- this.notifier.style.transform = "";
- }, 1000);
- },
-
showSubView(anchor) {
this._showSubView(null, anchor);
},
_showSubView(event, anchor = document.getElementById(this.BOOKMARK_BUTTON_ID)) {
let view = document.getElementById("PanelUI-bookmarks");
view.addEventListener("ViewShowing", this);
view.addEventListener("ViewHiding", this);
@@ -1724,27 +1653,16 @@ var BookmarkingUI = {
},
onPanelMenuViewHiding: function BUI_onViewHiding(aEvent) {
this._panelMenuView.uninit();
delete this._panelMenuView;
aEvent.target.removeEventListener("ViewHiding", this);
},
- onPanelMenuViewCommand: function BUI_onPanelMenuViewCommand(aEvent) {
- let target = aEvent.originalTarget;
- if (!target._placesNode)
- return;
- if (PlacesUtils.nodeIsContainer(target._placesNode))
- PlacesCommandHook.showPlacesOrganizer([ "BookmarksMenu", target._placesNode.itemId ]);
- else
- PlacesUIUtils.openNodeWithEvent(target._placesNode, aEvent);
- PanelUI.hide();
- },
-
showBookmarkingTools(triggerNode) {
const panelID = "PanelUI-bookmarkingTools";
let viewNode = document.getElementById(panelID);
for (let button of [...viewNode.getElementsByTagName("toolbarbutton")]) {
let update = true;
switch (button.id) {
case "panelMenu_toggleBookmarksMenu":
let placement = CustomizableUI.getPlacementOfWidget(this.BOOKMARK_BUTTON_ID);
--- a/browser/components/places/content/places.js
+++ b/browser/components/places/content/places.js
@@ -624,26 +624,16 @@ var PlacesOrganizer = {
infoBox.removeAttribute("wasminimal");
infoBoxExpanderWrapper.hidden =
this._additionalInfoFields.every(id =>
document.getElementById(id).collapsed);
}
additionalInfoBroadcaster.hidden = infoBox.getAttribute("minimal") == "true";
},
- // NOT YET USED
- updateThumbnailProportions: function PO_updateThumbnailProportions() {
- var previewBox = document.getElementById("previewBox");
- var canvas = document.getElementById("itemThumbnail");
- var height = previewBox.boxObject.height;
- var width = height * (screen.width / screen.height);
- canvas.width = width;
- canvas.height = height;
- },
-
_fillDetailsPane: function PO__fillDetailsPane(aNodeList) {
var infoBox = document.getElementById("infoBox");
var detailsDeck = document.getElementById("detailsDeck");
// Make sure the infoBox UI is visible if we need to use it, we hide it
// below when we don't.
infoBox.hidden = false;
let selectedNode = aNodeList.length == 1 ? aNodeList[0] : null;
@@ -721,38 +711,16 @@ var PlacesOrganizer = {
selectItemDesc.hidden = false;
itemsCountLabel.value =
PlacesUIUtils.getPluralString("detailsPane.itemsCountLabel",
itemsCount, [itemsCount]);
}
}
},
- // NOT YET USED
- _updateThumbnail: function PO__updateThumbnail() {
- var bo = document.getElementById("previewBox").boxObject;
- var width = bo.width;
- var height = bo.height;
-
- var canvas = document.getElementById("itemThumbnail");
- var ctx = canvas.getContext("2d");
- var notAvailableText = canvas.getAttribute("notavailabletext");
- ctx.save();
- ctx.fillStyle = "-moz-Dialog";
- ctx.fillRect(0, 0, width, height);
- ctx.translate(width / 2, height / 2);
-
- ctx.fillStyle = "GrayText";
- ctx.mozTextStyle = "12pt sans serif";
- var len = ctx.mozMeasureText(notAvailableText);
- ctx.translate(-len / 2, 0);
- ctx.mozDrawText(notAvailableText);
- ctx.restore();
- },
-
toggleAdditionalInfoFields: function PO_toggleAdditionalInfoFields() {
var infoBox = document.getElementById("infoBox");
var infoBoxExpander = document.getElementById("infoBoxExpander");
var infoBoxExpanderLabel = document.getElementById("infoBoxExpanderLabel");
var additionalInfoBroadcaster = document.getElementById("additionalInfoBroadcaster");
if (infoBox.getAttribute("minimal") == "true") {
infoBox.removeAttribute("minimal");
--- a/toolkit/components/places/BookmarkHTMLUtils.jsm
+++ b/toolkit/components/places/BookmarkHTMLUtils.jsm
@@ -78,19 +78,16 @@ const Container_Places = 4;
const LOAD_IN_SIDEBAR_ANNO = "bookmarkProperties/loadInSidebar";
const DESCRIPTION_ANNO = "bookmarkProperties/description";
const MICROSEC_PER_SEC = 1000000;
const EXPORT_INDENT = " "; // four spaces
-// Counter used to build fake favicon urls.
-var serialNumber = 0;
-
function base64EncodeString(aString) {
let stream = Cc["@mozilla.org/io/string-input-stream;1"]
.createInstance(Ci.nsIStringInputStream);
stream.setData(aString, aString.length);
let encoder = Cc["@mozilla.org/scriptablebase64encoder;1"]
.createInstance(Ci.nsIScriptableBase64Encoder);
return encoder.encodeToString(stream, aString.length);
}
@@ -753,72 +750,16 @@ BookmarkImporter.prototype = {
}
},
_appendText: function appendText(str) {
this._curFrame.previousText += str;
},
/**
- * data is a string that is a data URI for the favicon. Our job is to
- * decode it and store it in the favicon service.
- *
- * When aIconURI is non-null, we will use that as the URI of the favicon
- * when storing in the favicon service.
- *
- * When aIconURI is null, we have to make up a URI for this favicon so that
- * it can be stored in the service. The real one will be set the next time
- * the user visits the page. Our made up one should get expired when the
- * page no longer references it.
- */
- _setFaviconForURI: function setFaviconForURI(aPageURI, aIconURI, aData) {
- // if the input favicon URI is a chrome: URI, then we just save it and don't
- // worry about data
- if (aIconURI) {
- if (aIconURI.schemeIs("chrome")) {
- PlacesUtils.favicons.setAndFetchFaviconForPage(aPageURI, aIconURI, false,
- PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE, null,
- Services.scriptSecurityManager.getSystemPrincipal());
-
- return;
- }
- }
-
- // some bookmarks have placeholder URIs that contain just "data:"
- // ignore these
- if (aData.length <= 5) {
- return;
- }
-
- let faviconURI;
- if (aIconURI) {
- faviconURI = aIconURI;
- } else {
- // Make up a favicon URI for this page. Later, we'll make sure that this
- // favicon URI is always associated with local favicon data, so that we
- // don't load this URI from the network.
- let faviconSpec = "http://www.mozilla.org/2005/made-up-favicon/"
- + serialNumber
- + "-"
- + new Date().getTime();
- faviconURI = NetUtil.newURI(faviconSpec);
- serialNumber++;
- }
-
- // This could fail if the favicon is bigger than defined limit, in such a
- // case neither the favicon URI nor the favicon data will be saved. If the
- // bookmark is visited again later, the URI and data will be fetched.
- PlacesUtils.favicons.replaceFaviconDataFromDataURL(faviconURI, aData, 0,
- Services.scriptSecurityManager.getSystemPrincipal());
- PlacesUtils.favicons.setAndFetchFaviconForPage(aPageURI, faviconURI, false,
- PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE, null,
- Services.scriptSecurityManager.getSystemPrincipal());
- },
-
- /**
* Converts a string date in seconds to a date object
*/
_convertImportedDateToInternalDate: function convertImportedDateToInternalDate(aDate) {
try {
if (aDate && !isNaN(aDate)) {
return new Date(parseInt(aDate) * 1000); // in bookmarks.html this value is in seconds
}
} catch (ex) {