Bug 1577372, restore copy command via context menu to pageInfo dialog. r=johannh,fluent-reviewers,flod

Differential Revision: https://phabricator.services.mozilla.com/D44084

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Alexander J. Vincent 2019-08-30 17:14:35 +00:00
Родитель 7e52753eda
Коммит 5642dec568
3 изменённых файлов: 56 добавлений и 1 удалений

Просмотреть файл

@ -149,7 +149,10 @@ pageInfoTreeView.prototype = {
return 0;
},
getImageSrc(row, column) {},
getCellValue(row, column) {},
getCellValue(row, column) {
let col = (column != null) ? column : this.copycol;
return (row < 0 || col < 0) ? "" : (this.data[row][col] || "");
},
toggleOpenState(index) {},
cycleHeader(col) {},
selectionChanged() {},
@ -269,6 +272,19 @@ const nsIPermissionManager = Ci.nsIPermissionManager;
const nsICertificateDialogs = Ci.nsICertificateDialogs;
const CERTIFICATEDIALOGS_CONTRACTID = "@mozilla.org/nsCertificateDialogs;1";
// clipboard helper
function getClipboardHelper() {
try {
return Cc["@mozilla.org/widget/clipboardhelper;1"].getService(
Ci.nsIClipboardHelper
);
} catch (e) {
// do nothing, later code will handle the error
return null;
}
}
const gClipboardHelper = getClipboardHelper();
// namespaces, don't need all of these yet...
const XLinkNS = "http://www.w3.org/1999/xlink";
const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
@ -1175,6 +1191,36 @@ function formatDate(datestr, unknown) {
return dateTimeFormatter.format(date);
}
function doCopy() {
if (!gClipboardHelper) {
return;
}
var elem = document.commandDispatcher.focusedElement;
if (elem && elem.localName == "tree") {
var view = elem.view;
var selection = view.selection;
var text = [],
tmp = "";
var min = {},
max = {};
var count = selection.getRangeCount();
for (var i = 0; i < count; i++) {
selection.getRangeAt(i, min, max);
for (var row = min.value; row <= max.value; row++) {
tmp = view.getCellValue(row, null);
if (tmp)
text.push(tmp);
}
}
gClipboardHelper.copyString(text.join("\n"));
}
}
function doSelectAllMedia() {
var tree = document.getElementById("imagetree");

Просмотреть файл

@ -47,6 +47,7 @@
<commandset id="pageInfoCommandSet">
<command id="cmd_close" oncommand="window.close();"/>
<command id="cmd_help" oncommand="doHelpButton();"/>
<command id="cmd_copy" oncommand="doCopy();"/>
<command id="cmd_selectall" oncommand="doSelectAll();"/>
</commandset>
@ -58,12 +59,14 @@
#else
<key keycode="VK_F1" command="cmd_help"/>
#endif
<key data-l10n-id="copy" data-l10n-attrs="key" modifiers="accel" command="cmd_copy"/>
<key data-l10n-id="select-all" data-l10n-attrs="key" modifiers="accel" command="cmd_selectall"/>
<key data-l10n-id="select-all" data-l10n-attrs="key" modifiers="alt" command="cmd_selectall"/>
</keyset>
<menupopup id="picontext">
<menuitem id="menu_selectall" data-l10n-id="menu-select-all" command="cmd_selectall"/>
<menuitem id="menu_copy" data-l10n-id="menu-copy" command="cmd_copy"/>
</menupopup>
<vbox id="topBar">

Просмотреть файл

@ -5,6 +5,12 @@
page-info-window =
.style = width: 600px; min-height: 550px;
copy =
.key = C
menu-copy =
.label = Copy
.accesskey = C
select-all =
.key = A
menu-select-all =