Bug 932151 - Include forms.js in both desktop and b2g build. r=fabrice
☠☠ backed out by f003c386c77a ☠ ☠
authorYuan Xulei <xyuan@mozilla.com>
Thu, 07 Nov 2013 09:02:25 -0500
changeset 154013 f2ed6b24269a48a6bc483e1e0635dbadf36f7659
parent 154012 59b57fd2af615d6ef48ce78ae815736eae259a7d
child 154014 1d765fda880044136b32a9995c3ccddf06811fdc
push id35958
push userryanvm@gmail.com
push dateThu, 07 Nov 2013 19:48:10 +0000
treeherdermozilla-inbound@6ab7c3c97d3b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfabrice
bugs932151
milestone28.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 932151 - Include forms.js in both desktop and b2g build. r=fabrice
b2g/chrome/content/forms.js
b2g/chrome/jar.mn
dom/browser-element/BrowserElementChild.js
dom/inputmethod/Keyboard.jsm
dom/inputmethod/forms.js
dom/inputmethod/jar.mn
dom/ipc/preload.js
--- a/b2g/chrome/jar.mn
+++ b/b2g/chrome/jar.mn
@@ -5,17 +5,16 @@
 
 
 chrome.jar:
 % content branding %content/branding/
 % content browser %content/
 
   content/arrow.svg                     (content/arrow.svg)
 * content/dbg-browser-actors.js         (content/dbg-browser-actors.js)
-  content/forms.js                      (content/forms.js)
 * content/settings.js                   (content/settings.js)
 * content/shell.html                    (content/shell.html)
 * content/shell.js                      (content/shell.js)
 #ifndef ANDROID
   content/screen.js                     (content/screen.js)
   content/runapp.js                     (content/runapp.js)
 #endif
 * content/content.css                   (content/content.css)
--- a/dom/browser-element/BrowserElementChild.js
+++ b/dom/browser-element/BrowserElementChild.js
@@ -19,19 +19,24 @@ docShell.isActive = true;
 
 let infos = sendSyncMessage('browser-element-api:call',
                             { 'msg_name': 'hello' })[0];
 docShell.QueryInterface(Ci.nsIDocShellTreeItem).name = infos.name;
 docShell.setFullscreenAllowed(infos.fullscreenAllowed);
 
 
 if (!('BrowserElementIsPreloaded' in this)) {
+  try {
+    if (Services.prefs.getBoolPref("dom.mozInputMethod.enabled")) {
+      Services.scriptloader.loadSubScript("chrome://global/content/forms.js", global);
+    }
+  } catch (e) {
+  }
   // Those are produc-specific files that's sometimes unavailable.
   try {
-    Services.scriptloader.loadSubScript("chrome://browser/content/forms.js");
     Services.scriptloader.loadSubScript("chrome://browser/content/ErrorPage.js");
   } catch (e) {
   }
   Services.scriptloader.loadSubScript("chrome://global/content/BrowserElementPanning.js");
   Services.scriptloader.loadSubScript("chrome://global/content/BrowserElementChildPreload.js");
 }
 
 var BrowserElementIsReady = true;
--- a/dom/inputmethod/Keyboard.jsm
+++ b/dom/inputmethod/Keyboard.jsm
@@ -4,17 +4,17 @@
 
 'use strict';
 
 this.EXPORTED_SYMBOLS = ['Keyboard'];
 
 const Cu = Components.utils;
 const Cc = Components.classes;
 const Ci = Components.interfaces;
-const kFormsFrameScript = 'chrome://browser/content/forms.js';
+const kFormsFrameScript = 'chrome://global/content/forms.js';
 
 Cu.import('resource://gre/modules/Services.jsm');
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
   "@mozilla.org/parentprocessmessagemanager;1", "nsIMessageBroadcaster");
 
 this.Keyboard = {
@@ -59,37 +59,41 @@ this.Keyboard = {
 
     if (topic == 'oop-frameloader-crashed') {
       if (this.messageManager == mm) {
         // The application has been closed unexpectingly. Let's tell the
         // keyboard app that the focus has been lost.
         ppmm.broadcastAsyncMessage('Keyboard:FocusChange', { 'type': 'blur' });
       }
     } else {
-      mm.addMessageListener('Forms:Input', this);
-      mm.addMessageListener('Forms:SelectionChange', this);
-      mm.addMessageListener('Forms:GetText:Result:OK', this);
-      mm.addMessageListener('Forms:GetText:Result:Error', this);
-      mm.addMessageListener('Forms:SetSelectionRange:Result:OK', this);
-      mm.addMessageListener('Forms:ReplaceSurroundingText:Result:OK', this);
-      mm.addMessageListener('Forms:SendKey:Result:OK', this);
-      mm.addMessageListener('Forms:SequenceError', this);
-      mm.addMessageListener('Forms:GetContext:Result:OK', this);
-      mm.addMessageListener('Forms:SetComposition:Result:OK', this);
-      mm.addMessageListener('Forms:EndComposition:Result:OK', this);
+      this.initFormsFrameScript(mm);
+    }
+  },
 
-      // When not running apps OOP, we need to load forms.js here since this
-      // won't happen from dom/ipc/preload.js
-      try {
-         if (Services.prefs.getBoolPref("dom.ipc.tabs.disabled") === true) {
-           mm.loadFrameScript(kFormsFrameScript, true);
-        }
-      } catch (e) {
-         dump('Error loading ' + kFormsFrameScript + ' as frame script: ' + e + '\n');
+  initFormsFrameScript: function(mm) {
+    mm.addMessageListener('Forms:Input', this);
+    mm.addMessageListener('Forms:SelectionChange', this);
+    mm.addMessageListener('Forms:GetText:Result:OK', this);
+    mm.addMessageListener('Forms:GetText:Result:Error', this);
+    mm.addMessageListener('Forms:SetSelectionRange:Result:OK', this);
+    mm.addMessageListener('Forms:ReplaceSurroundingText:Result:OK', this);
+    mm.addMessageListener('Forms:SendKey:Result:OK', this);
+    mm.addMessageListener('Forms:SequenceError', this);
+    mm.addMessageListener('Forms:GetContext:Result:OK', this);
+    mm.addMessageListener('Forms:SetComposition:Result:OK', this);
+    mm.addMessageListener('Forms:EndComposition:Result:OK', this);
+
+    // When not running apps OOP, we need to load forms.js here since this
+    // won't happen from dom/ipc/preload.js
+    try {
+      if (Services.prefs.getBoolPref("dom.ipc.tabs.disabled") === true) {
+        mm.loadFrameScript(kFormsFrameScript, true);
       }
+    } catch (e) {
+      dump('Error loading ' + kFormsFrameScript + ' as frame script: ' + e + '\n');
     }
   },
 
   receiveMessage: function keyboardReceiveMessage(msg) {
     // If we get a 'Keyboard:XXX' message, check that the sender has the
     // input permission.
     if (msg.name.indexOf("Keyboard:") != -1) {
       if (!this.messageManager) {
rename from b2g/chrome/content/forms.js
rename to dom/inputmethod/forms.js
new file mode 100644
--- /dev/null
+++ b/dom/inputmethod/jar.mn
@@ -0,0 +1,6 @@
+# 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/.
+
+toolkit.jar:
+  content/global/forms.js                      (forms.js)
--- a/dom/ipc/preload.js
+++ b/dom/ipc/preload.js
@@ -82,19 +82,25 @@ const BrowserElementIsPreloaded = true;
 
   try {
     if (Services.prefs.getBoolPref("dom.sysmsg.enabled")) {
       Cc["@mozilla.org/system-message-manager;1"].getService(Ci["nsIDOMNavigatorSystemMessages"]);
     }
   } catch(e) {
   }
 
+  try {
+    if (Services.prefs.getBoolPref("dom.mozInputMethod.enabled")) {
+      Services.scriptloader.loadSubScript("chrome://global/content/forms.js", global);
+    }
+  } catch (e) {
+  }
+
   // Those are produc-specific files that's sometimes unavailable.
   try {
-    Services.scriptloader.loadSubScript("chrome://browser/content/forms.js", global);
     Services.scriptloader.loadSubScript("chrome://browser/content/ErrorPage.js", global);
   } catch (e) {
   }
   Services.scriptloader.loadSubScript("chrome://global/content/BrowserElementPanning.js", global);
   Services.scriptloader.loadSubScript("chrome://global/content/BrowserElementChildPreload.js", global);
 
   Services.io.getProtocolHandler("app");
   Services.io.getProtocolHandler("default");