Bug 1702708 - Hyphenate places context menu attributes r=mak

Differential Revision: https://phabricator.services.mozilla.com/D121583
This commit is contained in:
Nicholas Fason 2021-08-03 14:03:03 +00:00
parent 3d1b4f252f
commit 0c0043f901
3 changed files with 66 additions and 66 deletions

View File

@ -1575,7 +1575,7 @@ var BookmarkingUI = {
// Used by the Places context menu in the Bookmarks Toolbar
// when nothing is selected
menu.setAttribute("selectiontype", "none|single");
menu.setAttribute("selection-type", "none|single");
MozXULElement.insertFTLIfNeeded("browser/toolbarContextMenu.ftl");
let menuItems = [
@ -2353,7 +2353,7 @@ var BookmarkingUI = {
menuItem.setAttribute("toolbarId", "PersonalToolbar");
menuItem.setAttribute("type", "checkbox");
menuItem.setAttribute("checked", SHOW_OTHER_BOOKMARKS);
menuItem.setAttribute("selectiontype", "none|single");
menuItem.setAttribute("selection-type", "none|single");
MozXULElement.insertFTLIfNeeded("browser/toolbarContextMenu.ftl");
document.l10n.setAttributes(

View File

@ -450,14 +450,14 @@ PlacesController.prototype = {
*/
_shouldShowMenuItem(aMenuItem, aMetaData) {
if (
aMenuItem.hasAttribute("hideifprivatebrowsing") &&
aMenuItem.hasAttribute("hide-if-private-browsing") &&
!PrivateBrowsingUtils.enabled
) {
return false;
}
let selectiontype =
aMenuItem.getAttribute("selectiontype") || "single|multiple";
aMenuItem.getAttribute("selection-type") || "single|multiple";
var selectionTypes = selectiontype.split("|");
if (selectionTypes.includes("any")) {
@ -480,7 +480,7 @@ PlacesController.prototype = {
aMetaData = [this._selectionMetadataForNode(this._view.result.root)];
}
let attr = aMenuItem.getAttribute("hideifnodetype");
let attr = aMenuItem.getAttribute("hide-if-node-type");
if (attr) {
let rules = attr.split("|");
if (aMetaData.some(d => rules.some(r => r in d))) {
@ -488,7 +488,7 @@ PlacesController.prototype = {
}
}
attr = aMenuItem.getAttribute("hideifnodetypeisonly");
attr = aMenuItem.getAttribute("hide-if-node-type-is-only");
if (attr) {
let rules = attr.split("|");
if (rules.some(r => aMetaData.every(d => r in d))) {
@ -496,7 +496,7 @@ PlacesController.prototype = {
}
}
attr = aMenuItem.getAttribute("nodetype");
attr = aMenuItem.getAttribute("node-type");
if (!attr) {
return true;
}
@ -519,9 +519,9 @@ PlacesController.prototype = {
* visibility state for each menuitem according to the following rules:
* 1) The visibility state is unchanged if none of the attributes are set.
* 2) Attributes should not be set on menuseparators.
* 3) The boolean `ignoreitem` attribute may be set when this code should
* 3) The boolean `ignore-item` attribute may be set when this code should
* not handle that menuitem.
* 4) The `selectiontype` attribute may be set to:
* 4) The `selection-type` attribute may be set to:
* - `single` if it should be visible only when there is a single node
* selected
* - `multiple` if it should be visible only when multiple nodes are
@ -529,22 +529,22 @@ PlacesController.prototype = {
* - `none` if it should be visible when there are no selected nodes
* - `any` if it should be visible for any kind of selection
* - a `|` separated combination of the above.
* 5) The `nodetype` attribute may be set to values representing the
* 5) The `node-type` attribute may be set to values representing the
* type of the node triggering the context menu. The menuitem will be
* visible when one of the rules (separated by `|`) matches.
* In case of multiple selection, the menuitem is visible only if all of
* the selected nodes match one of the rule.
* 6) The `hideifnodetype` accepts the same rules as `nodetype`, but
* 6) The `hide-if-node-type` accepts the same rules as `node-type`, but
* hides the menuitem if the nodes match at least one of the rules.
* It takes priority over `nodetype`.
* 7) The `hideifnodetypeisonly` accepts the same rules as `nodetype`, but
* 7) The `hide-if-node-type-is-only` accepts the same rules as `node-type`, but
* hides the menuitem if any of the rules match all of the nodes.
* 8) The boolean `hideifnoinsertionpoint` attribute may be set to hide a
* 8) The boolean `hide-if-no-insertion-point` attribute may be set to hide a
* menuitem when there's no insertion point. An insertion point represents
* a point in the view where a new item can be inserted.
* 9) The boolean `hideifprivatebrowsing` attribute may be set to hide a
* 9) The boolean `hide-if-private-browsing` attribute may be set to hide a
* menuitem in private browsing mode
* 10) The boolean `hideifsingleclickopens` attribute may be set to hide a
* 10) The boolean `hide-if-single-click-opens` attribute may be set to hide a
* menuitem in views opening entries with a single click.
*
* @param {object} aPopup
@ -561,21 +561,21 @@ PlacesController.prototype = {
var usableItemCount = 0;
for (var i = 0; i < aPopup.children.length; ++i) {
var item = aPopup.children[i];
if (item.getAttribute("ignoreitem") == "true") {
if (item.getAttribute("ignore-item") == "true") {
continue;
}
if (item.localName != "menuseparator") {
// We allow pasting into tag containers, so special case that.
let hideIfNoIP =
item.getAttribute("hideifnoinsertionpoint") == "true" &&
item.getAttribute("hide-if-no-insertion-point") == "true" &&
noIp &&
!(ip && ip.isTag && item.id == "placesContext_paste");
let hideIfPrivate =
item.getAttribute("hideifprivatebrowsing") == "true" &&
item.getAttribute("hide-if-private-browsing") == "true" &&
PrivateBrowsingUtils.isWindowPrivate(window);
// Hide `Open` if the primary action on click is opening.
let hideIfSingleClickOpens =
item.getAttribute("hideifsingleclickopens") == "true" &&
item.getAttribute("hide-if-single-click-opens") == "true" &&
!PlacesUIUtils.loadBookmarksInBackground &&
!PlacesUIUtils.loadBookmarksInTabs &&
this._view.singleClickOpens;

View File

@ -9,102 +9,102 @@
command="placesCmd_open"
data-l10n-id="places-open"
default="true"
selectiontype="single"
nodetype="link"
hideifsingleclickopens="true"/>
selection-type="single"
node-type="link"
hide-if-single-click-opens="true"/>
<menuitem id="placesContext_openBookmarkContainer:tabs"
oncommand="PlacesUIUtils.openSelectionInTabs(event);"
data-l10n-id="places-open-all-bookmarks"
selectiontype="single|none"
nodetype="folder|query_tag"/>
selection-type="single|none"
node-type="folder|query_tag"/>
<menuitem id="placesContext_openBookmarkLinks:tabs"
oncommand="PlacesUIUtils.openSelectionInTabs(event);"
data-l10n-id="places-open-all-bookmarks"
selectiontype="multiple"
nodetype="link_bookmark"/>
selection-type="multiple"
node-type="link_bookmark"/>
<menuitem id="placesContext_open:newtab"
command="placesCmd_open:tab"
data-l10n-id="places-open-in-tab"
selectiontype="single"
nodetype="link"/>
selection-type="single"
node-type="link"/>
<menuitem id="placesContext_openContainer:tabs"
oncommand="PlacesUIUtils.openSelectionInTabs(event);"
data-l10n-id="places-open-all-in-tabs"
selectiontype="single|none"
nodetype="query"
hideifnodetype="query_tag"/>
selection-type="single|none"
node-type="query"
hide-if-node-type="query_tag"/>
<menuitem id="placesContext_openLinks:tabs"
oncommand="PlacesUIUtils.openSelectionInTabs(event);"
data-l10n-id="places-open-all-in-tabs"
selectiontype="multiple"
nodetype="link"
hideifnodetype="link_bookmark"/>
selection-type="multiple"
node-type="link"
hide-if-node-type="link_bookmark"/>
<menuitem id="placesContext_open:newwindow"
command="placesCmd_open:window"
data-l10n-id="places-open-in-window"
selectiontype="single"
nodetype="link"/>
selection-type="single"
node-type="link"/>
<menuitem id="placesContext_open:newprivatewindow"
command="placesCmd_open:privatewindow"
data-l10n-id="places-open-in-private-window"
selectiontype="single"
nodetype="link"
hideifprivatebrowsing="true"/>
selection-type="single"
node-type="link"
hide-if-private-browsing="true"/>
<menuseparator id="placesContext_openSeparator"/>
<menuitem id="placesContext_show_bookmark:info"
command="placesCmd_show:info"
data-l10n-id="places-edit-bookmark"
nodetype="link_bookmark"/>
node-type="link_bookmark"/>
<menuitem id="placesContext_show:info"
command="placesCmd_show:info"
data-l10n-id="places-edit-generic"
nodetype="query"
hideifnodetype="query_host|query_day"/>
node-type="query"
hide-if-node-type="query_host|query_day"/>
<menuitem id="placesContext_show_folder:info"
command="placesCmd_show:info"
data-l10n-id="places-edit-folder"
nodetype="folder"/>
node-type="folder"/>
<menuitem id="placesContext_deleteBookmark"
data-l10n-id="places-remove-bookmark"
data-l10n-args='{"count":"1"}'
command="placesCmd_delete"
closemenu="single"
nodetype="link_bookmark"/>
node-type="link_bookmark"/>
<menuitem id="placesContext_deleteFolder"
data-l10n-id="places-remove-folder"
data-l10n-args='{"count":"1"}'
command="placesCmd_delete"
nodetype="folder"
node-type="folder"
closemenu="single"/>
<menuitem id="placesContext_delete"
data-l10n-id="text-action-delete"
command="placesCmd_delete"
closemenu="single"
hideifnodetypeisonly="link|folder"/>
hide-if-node-type-is-only="link|folder"/>
<menuitem id="placesContext_delete_history"
command="placesCmd_delete"
closemenu="single"
nodetype="link"
hideifnodetype="link_bookmark"/>
node-type="link"
hide-if-node-type="link_bookmark"/>
<menuitem id="placesContext_deleteHost"
command="placesCmd_deleteDataHost"
data-l10n-id="places-delete-domain-data"
closemenu="single"
nodetype="link|query_host"
selectiontype="single"
hideifnodetype="link_bookmark"/>
node-type="link|query_host"
selection-type="single"
hide-if-node-type="link_bookmark"/>
<menuitem id="placesContext_sortBy:name"
command="placesCmd_sortBy:name"
data-l10n-id="places-sortby-name"
closemenu="single"
nodetype="folder"/>
node-type="folder"/>
<menuseparator id="placesContext_deleteSeparator"/>
<menuitem id="placesContext_cut"
command="placesCmd_cut"
data-l10n-id="text-action-cut"
closemenu="single"
nodetype="link_bookmark|folder|separator|query"
hideifnodetype="link_bookmark_tag|query_host|query_day|query_tag"/>
node-type="link_bookmark|folder|separator|query"
hide-if-node-type="link_bookmark_tag|query_host|query_day|query_tag"/>
<menuitem id="placesContext_copy"
command="placesCmd_copy"
data-l10n-id="text-action-copy"
@ -113,40 +113,40 @@
data-l10n-id="text-action-paste"
command="placesCmd_paste"
closemenu="single"
hideifnoinsertionpoint="true"/>
hide-if-no-insertion-point="true"/>
<menuseparator id="placesContext_editSeparator"/>
<menuitem id="placesContext_new:bookmark"
command="placesCmd_new:bookmark"
data-l10n-id="places-add-bookmark"
selectiontype="any"
hideifnoinsertionpoint="true"/>
selection-type="any"
hide-if-no-insertion-point="true"/>
<menuitem id="placesContext_new:folder"
command="placesCmd_new:folder"
data-l10n-id="places-add-folder-contextmenu"
selectiontype="any"
hideifnoinsertionpoint="true"/>
selection-type="any"
hide-if-no-insertion-point="true"/>
<menuitem id="placesContext_new:separator"
command="placesCmd_new:separator"
data-l10n-id="places-add-separator"
closemenu="single"
selectiontype="any"
hideifnoinsertionpoint="true"/>
selection-type="any"
hide-if-no-insertion-point="true"/>
<menuseparator id="placesContext_newSeparator"/>
<menuitem id="placesContext_paste"
data-l10n-id="text-action-paste"
command="placesCmd_paste"
closemenu="single"
selectiontype="none"
hideifnoinsertionpoint="true"/>
selection-type="none"
hide-if-no-insertion-point="true"/>
<menuseparator id="placesContext_pasteSeparator"/>
<menuitem id="placesContext_createBookmark"
command="placesCmd_createBookmark"
nodetype="link"
hideifnodetype="link_bookmark"/>
node-type="link"
hide-if-node-type="link_bookmark"/>
<menuitem id="placesContext_showAllBookmarks"
data-l10n-id="places-manage-bookmarks"
command="Browser:ShowAllBookmarks"
ignoreitem="true"
ignore-item="true"
hidden="true"/>
</menupopup>