Bug 1147329 - Handle in-process case for Cut/Copy/Paste feature. r=kanru

This commit is contained in:
Jeremy Chen 2015-07-22 03:28:00 -04:00
parent 7fbc2735a5
commit 08678fac2e
2 changed files with 18 additions and 1 deletions

View File

@ -41,7 +41,15 @@ if (!('BrowserElementIsPreloaded' in this)) {
} catch (e) {
}
}
}
if(Services.appinfo.processType == Services.appinfo.PROCESS_TYPE_CONTENT) {
// general content apps
if (isTopBrowserElement(docShell)) {
Services.scriptloader.loadSubScript("chrome://global/content/BrowserElementCopyPaste.js");
}
} else {
// rocketbar in system app and other in-process case (ex. B2G desktop client)
Services.scriptloader.loadSubScript("chrome://global/content/BrowserElementCopyPaste.js");
}

View File

@ -8,6 +8,8 @@
dump("###################################### BrowserElementCopyPaste.js loaded\n");
let { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
let CopyPasteAssistent = {
COMMAND_MAP: {
'cut': 'cmd_cut',
@ -19,7 +21,7 @@ let CopyPasteAssistent = {
init: function() {
addEventListener('mozcaretstatechanged',
this._caretStateChangedHandler.bind(this),
/* useCapture = */ true,
/* useCapture = */ false,
/* wantsUntrusted = */ false);
addMessageListener('browser-element-api:call', this._browserAPIHandler.bind(this));
},
@ -81,6 +83,13 @@ let CopyPasteAssistent = {
detail.rect.left += currentRect.left;
detail.rect.right += currentRect.left;
currentWindow = currentWindow.realFrameElement.ownerDocument.defaultView;
let targetDocShell = currentWindow
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation);
if(targetDocShell.isBrowserOrApp) {
break;
}
}
sendAsyncMsg('caretstatechanged', detail);