зеркало из https://github.com/mozilla/gecko-dev.git
Bug 482235 - instead of exposing bookmarklets attribute, expose scheme in uri nodes, r=mak77
This commit is contained in:
Родитель
16fcc5b1e2
Коммит
b2868dca86
|
@ -821,10 +821,7 @@
|
|||
PlacesUIUtils.ensureLivemarkStatusMenuItem(menuitem.firstChild);
|
||||
}
|
||||
else if (PlacesUtils.nodeIsURI(aNode)) {
|
||||
if (aNode.uri.lastIndexOf("javascript:", 0) == 0)
|
||||
menuitem.setAttribute("bookmarklet", "true");
|
||||
else
|
||||
menuitem.removeAttribute("bookmarklet");
|
||||
menuitem.setAttribute("scheme", PlacesUIUtils.guessUrlSchemeForUI(aNode.uri))
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -220,10 +220,7 @@
|
|||
domNode: popup });
|
||||
}
|
||||
else if (PlacesUtils.nodeIsURI(aChild)) {
|
||||
if (aChild.uri.lastIndexOf("javascript:", 0) == 0)
|
||||
button.setAttribute("bookmarklet", "true");
|
||||
else
|
||||
button.removeAttribute("bookmarklet");
|
||||
button.setAttribute("scheme", PlacesUIUtils.guessUrlSchemeForUI(aChild.uri))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -645,10 +642,7 @@
|
|||
PlacesUIUtils.ensureLivemarkStatusMenuItem(element.firstChild);
|
||||
}
|
||||
else if (PlacesUtils.nodeIsURI(aNode)) {
|
||||
if (aNode.uri.lastIndexOf("javascript:", 0) == 0)
|
||||
element.setAttribute("bookmarklet", "true");
|
||||
else
|
||||
element.removeAttribute("bookmarklet");
|
||||
element.setAttribute("scheme", PlacesUIUtils.guessUrlSchemeForUI(aNode.uri))
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -925,12 +925,11 @@ PlacesTreeView.prototype = {
|
|||
}
|
||||
else if (nodeType == Ci.nsINavHistoryResultNode.RESULT_TYPE_SEPARATOR)
|
||||
properties.push(this._getAtomFor("separator"));
|
||||
else if (itemId != -1) { // bookmark nodes
|
||||
if (PlacesUtils.nodeIsLivemarkContainer(node.parent))
|
||||
properties.push(this._getAtomFor("livemarkItem"));
|
||||
else if (PlacesUtils.nodeIsURI(node)) {
|
||||
if (node.uri.lastIndexOf("javascript:", 0) == 0)
|
||||
properties.push(this._getAtomFor("bookmarklet"));
|
||||
else if (PlacesUtils.nodeIsURI(node)) {
|
||||
properties.push(this._getAtomFor(PlacesUIUtils.guessUrlSchemeForUI(node.uri)));
|
||||
if (itemId != -1) {
|
||||
if (PlacesUtils.nodeIsLivemarkContainer(node.parent))
|
||||
properties.push(this._getAtomFor("livemarkItem"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -981,6 +981,20 @@ var PlacesUIUtils = {
|
|||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Helper for guessing scheme from an url string.
|
||||
* Used to avoid nsIURI overhead in frequently called UI functions.
|
||||
*
|
||||
* @param aUrlString the url to guess the scheme from.
|
||||
*
|
||||
* @return guessed scheme for this url string.
|
||||
*
|
||||
* @note this is not supposed be perfect, so use it only for UI purposes.
|
||||
*/
|
||||
guessUrlSchemeForUI: function PUU_guessUrlSchemeForUI(aUrlString) {
|
||||
return aUrlString.substr(0, aUrlString.indexOf(":"));
|
||||
},
|
||||
|
||||
/**
|
||||
* Helper for the toolbar and menu views
|
||||
*/
|
||||
|
@ -999,9 +1013,7 @@ var PlacesUIUtils = {
|
|||
if (PlacesUtils.uriTypes.indexOf(type) != -1) {
|
||||
element = document.createElement("menuitem");
|
||||
element.className = "menuitem-iconic bookmark-item";
|
||||
|
||||
if (aNode.uri.lastIndexOf("javascript:", 0) == 0)
|
||||
element.setAttribute("bookmarklet", "true");
|
||||
element.setAttribute("scheme", this.guessUrlSchemeForUI(aNode.uri))
|
||||
}
|
||||
else if (PlacesUtils.containerTypes.indexOf(type) != -1) {
|
||||
element = document.createElement("menu");
|
||||
|
|
Загрузка…
Ссылка в новой задаче