Bug 1234118 - Delete code for supporting 'do-command' and 'copypaste-docommand'. r=mtseng, r=smaug

These two events are the leftovers for support copy/paste/cut/selectall
operations from old text_selection_dialog.js in Gaia. The code for
handling them can be removed since text_selection_dialog.js was removed
in bug 1221462.
This commit is contained in:
Ting-Yu Lin 2016-01-04 21:45:01 +08:00
parent 3ea4315c52
commit ad85502078
4 changed files with 17 additions and 40 deletions

View File

@ -68,15 +68,6 @@ const OBSERVED_EVENTS = [
'invalid-widget'
];
const COMMAND_MAP = {
'cut': 'cmd_cut',
'copy': 'cmd_copyAndCollapseToEnd',
'copyImage': 'cmd_copyImage',
'copyLink': 'cmd_copyLink',
'paste': 'cmd_paste',
'selectall': 'cmd_selectAll'
};
/**
* The BrowserElementChild implements one half of <iframe mozbrowser>.
* (The other half is, unsurprisingly, BrowserElementParent.)
@ -278,7 +269,6 @@ BrowserElementChild.prototype = {
"activate-next-paint-listener": this._activateNextPaintListener.bind(this),
"set-input-method-active": this._recvSetInputMethodActive.bind(this),
"deactivate-next-paint-listener": this._deactivateNextPaintListener.bind(this),
"do-command": this._recvDoCommand,
"find-all": this._recvFindAll.bind(this),
"find-next": this._recvFindNext.bind(this),
"clear-match": this._recvClearMatch.bind(this),
@ -407,15 +397,6 @@ BrowserElementChild.prototype = {
}
},
_isCommandEnabled: function(cmd) {
let command = COMMAND_MAP[cmd];
if (!command) {
return false;
}
return docShell.isCommandEnabled(command);
},
/**
* Spin in a nested event loop until we receive a unblock-modal-prompt message for
* this window.
@ -1196,14 +1177,16 @@ BrowserElementChild.prototype = {
_recvFireCtxCallback: function(data) {
debug("Received fireCtxCallback message: (" + data.json.menuitem + ")");
let doCommandIfEnabled = (command) => {
if (docShell.isCommandEnabled(command)) {
docShell.doCommand(command);
}
};
if (data.json.menuitem == 'copy-image') {
// Set command
data.json.command = 'copyImage';
this._recvDoCommand(data);
doCommandIfEnabled('cmd_copyImage');
} else if (data.json.menuitem == 'copy-link') {
// Set command
data.json.command = 'copyLink';
this._recvDoCommand(data);
doCommandIfEnabled('cmd_copyLink');
} else if (data.json.menuitem in this._ctxHandlers) {
this._ctxHandlers[data.json.menuitem].click();
this._ctxHandlers = {};
@ -1382,12 +1365,6 @@ BrowserElementChild.prototype = {
docShell.contentViewer.fullZoom = data.json.zoom;
},
_recvDoCommand: function(data) {
if (this._isCommandEnabled(data.json.command)) {
docShell.doCommand(COMMAND_MAP[data.json.command]);
}
},
_recvGetAudioChannelVolume: function(data) {
debug("Received getAudioChannelVolume message: (" + data.json.id + ")");

View File

@ -30,7 +30,7 @@ var CopyPasteAssistent = {
switch (e.data.msg_name) {
case 'copypaste-do-command':
if (this._isCommandEnabled(e.data.command)) {
docShell.doCommand(COMMAND_MAP[e.data.command]);
docShell.doCommand(this.COMMAND_MAP[e.data.command]);
}
break;
}

View File

@ -250,7 +250,6 @@ function BrowserElementParent() {
this._pendingDOMFullscreen = false;
Services.obs.addObserver(this, 'oop-frameloader-crashed', /* ownsWeak = */ true);
Services.obs.addObserver(this, 'copypaste-docommand', /* ownsWeak = */ true);
Services.obs.addObserver(this, 'ask-children-to-execute-copypaste-command', /* ownsWeak = */ true);
Services.obs.addObserver(this, 'back-docommand', /* ownsWeak = */ true);
@ -1295,11 +1294,6 @@ BrowserElementParent.prototype = {
this._fireFatalError();
}
break;
case 'copypaste-docommand':
if (this._isAlive() && this._frameElement.isEqualNode(subject.wrappedJSObject)) {
this._sendAsyncMsg('do-command', { command: data });
}
break;
case 'ask-children-to-execute-copypaste-command':
if (this._isAlive() && this._frameElement == subject.wrappedJSObject) {
this._sendAsyncMsg('copypaste-do-command', { command: data });

View File

@ -86,8 +86,14 @@ function runTest() {
}
function doCommand(cmd) {
Services.obs.notifyObservers({wrappedJSObject: SpecialPowers.unwrap(iframeInner)},
'copypaste-docommand', cmd);
var COMMAND_MAP = {
'cut': 'cmd_cut',
'copy': 'cmd_copyAndCollapseToEnd',
'paste': 'cmd_paste',
'selectall': 'cmd_selectAll'
};
var script = 'data:,docShell.doCommand("' + COMMAND_MAP[cmd] + '");';
mm.loadFrameScript(script, false);
}
function dispatchTest(e) {