Bug 1147329 - Handle in-process case for Cut/Copy/Paste feature. r=kanru
authorJeremy Chen <jeremychen@mozilla.com>
Mon, 27 Jul 2015 11:56:04 +0800
changeset 254631 201523ca96581b32b3fc5c7774df187616450543
parent 254630 5f2e5a9fb54da77c775a924e5696b80bfcae1e99
child 254632 c5e6edadb0d123e55d4a1fc095847d3d5e67ec0c
push id29108
push userryanvm@gmail.com
push dateMon, 27 Jul 2015 14:12:01 +0000
treeherdermozilla-central@27ae736ef960 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskanru
bugs1147329
milestone42.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1147329 - Handle in-process case for Cut/Copy/Paste feature. r=kanru
dom/browser-element/BrowserElementChild.js
dom/browser-element/BrowserElementCopyPaste.js
--- a/dom/browser-element/BrowserElementChild.js
+++ b/dom/browser-element/BrowserElementChild.js
@@ -36,17 +36,25 @@ function isTopBrowserElement(docShell) {
 if (!('BrowserElementIsPreloaded' in this)) {
   if (isTopBrowserElement(docShell)) {
     if (Services.prefs.getBoolPref("dom.mozInputMethod.enabled")) {
       try {
         Services.scriptloader.loadSubScript("chrome://global/content/forms.js");
       } 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");
   }
 
   if (Services.prefs.getIntPref("dom.w3c_touch_events.enabled") == 1) {
     if (docShell.asyncPanZoomEnabled === false) {
       Services.scriptloader.loadSubScript("chrome://global/content/BrowserElementPanningAPZDisabled.js");
       ContentPanningAPZDisabled.init();
     }
--- a/dom/browser-element/BrowserElementCopyPaste.js
+++ b/dom/browser-element/BrowserElementCopyPaste.js
@@ -3,16 +3,18 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 dump("###################################### BrowserElementCopyPaste.js loaded\n");
 
+let { classes: Cc, interfaces: Ci, results: Cr, utils: Cu }  = Components;
+
 let CopyPasteAssistent = {
   COMMAND_MAP: {
     'cut': 'cmd_cut',
     'copy': 'cmd_copyAndCollapseToEnd',
     'paste': 'cmd_paste',
     'selectall': 'cmd_selectAll'
   },
 
@@ -76,15 +78,22 @@ let CopyPasteAssistent = {
     let currentWindow = e.target.defaultView;
     while (currentWindow.realFrameElement) {
       let currentRect = currentWindow.realFrameElement.getBoundingClientRect();
       detail.rect.top += currentRect.top;
       detail.rect.bottom += currentRect.top;
       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);
   },
 };
 
 CopyPasteAssistent.init();