diff --git a/b2g/app/b2g.js b/b2g/app/b2g.js index 0fe4804e343d..be954a9e5c4a 100644 --- a/b2g/app/b2g.js +++ b/b2g/app/b2g.js @@ -750,3 +750,6 @@ pref("dom.promise.enabled", false); // (only applies when marionette is disabled) // 0 disables the timer. pref("b2g.adb.timeout-hours", 12); + +// InputMethod so we can do soft keyboards +pref("dom.mozInputMethod.enabled", true); diff --git a/b2g/chrome/content/shell.js b/b2g/chrome/content/shell.js index a0479a2b267c..40eb6a27fbb8 100644 --- a/b2g/chrome/content/shell.js +++ b/b2g/chrome/content/shell.js @@ -462,35 +462,21 @@ var shell = { } break; case 'mozbrowserloadstart': - if (content.document.location == 'about:blank') + if (content.document.location == 'about:blank') { + this.contentBrowser.addEventListener('mozbrowserlocationchange', this, true); return; + } - this.contentBrowser.removeEventListener('mozbrowserloadstart', this, true); - - this.reportCrash(true); - - Cu.import('resource://gre/modules/Webapps.jsm'); - DOMApplicationRegistry.allAppsLaunchable = true; - - this.sendEvent(window, 'ContentStart'); - - content.addEventListener('load', function shell_homeLoaded() { - content.removeEventListener('load', shell_homeLoaded); - shell.isHomeLoaded = true; - -#ifdef MOZ_WIDGET_GONK - libcutils.property_set('sys.boot_completed', '1'); -#endif - - Services.obs.notifyObservers(null, "browser-ui-startup-complete", ""); - - if ('pendingChromeEvents' in shell) { - shell.pendingChromeEvents.forEach((shell.sendChromeEvent).bind(shell)); - } - delete shell.pendingChromeEvents; - }); - + this.notifyContentStart(); break; + case 'mozbrowserlocationchange': + if (content.document.location == 'about:blank') { + return; + } + + this.notifyContentStart(); + break; + case 'MozApplicationManifest': try { if (!Services.prefs.getBoolPref('browser.cache.offline.enable')) @@ -592,6 +578,36 @@ var shell = { sender.sendAsyncMessage(activity.response, { success: false }); } } + }, + + notifyContentStart: function shell_notifyContentStart() { + this.contentBrowser.removeEventListener('mozbrowserloadstart', this, true); + this.contentBrowser.removeEventListener('mozbrowserlocationchange', this, true); + + let content = this.contentBrowser.contentWindow; + + this.reportCrash(true); + + Cu.import('resource://gre/modules/Webapps.jsm'); + DOMApplicationRegistry.allAppsLaunchable = true; + + this.sendEvent(window, 'ContentStart'); + + content.addEventListener('load', function shell_homeLoaded() { + content.removeEventListener('load', shell_homeLoaded); + shell.isHomeLoaded = true; + +#ifdef MOZ_WIDGET_GONK + libcutils.property_set('sys.boot_completed', '1'); +#endif + + Services.obs.notifyObservers(null, "browser-ui-startup-complete", ""); + + if ('pendingChromeEvents' in shell) { + shell.pendingChromeEvents.forEach((shell.sendChromeEvent).bind(shell)); + } + delete shell.pendingChromeEvents; + }); } }; diff --git a/b2g/components/B2GComponents.manifest b/b2g/components/B2GComponents.manifest index 07bf3fe11ad4..5198a35cfcab 100644 --- a/b2g/components/B2GComponents.manifest +++ b/b2g/components/B2GComponents.manifest @@ -15,14 +15,6 @@ component {88b3eb21-d072-4e3b-886d-f89d8c49fe59} UpdatePrompt.js contract @mozilla.org/updates/update-prompt;1 {88b3eb21-d072-4e3b-886d-f89d8c49fe59} #endif -# MozKeyboard.js -component {397a7fdf-2254-47be-b74e-76625a1a66d5} MozKeyboard.js -contract @mozilla.org/b2g-keyboard;1 {397a7fdf-2254-47be-b74e-76625a1a66d5} -category JavaScript-navigator-property mozKeyboard @mozilla.org/b2g-keyboard;1 - -component {4607330d-e7d2-40a4-9eb8-43967eae0142} MozKeyboard.js -contract @mozilla.org/b2g-inputmethod;1 {4607330d-e7d2-40a4-9eb8-43967eae0142} - # DirectoryProvider.js component {9181eb7c-6f87-11e1-90b1-4f59d80dd2e5} DirectoryProvider.js contract @mozilla.org/browser/directory-provider;1 {9181eb7c-6f87-11e1-90b1-4f59d80dd2e5} diff --git a/b2g/components/moz.build b/b2g/components/moz.build index 915bac5a93e1..78d7b30739ae 100644 --- a/b2g/components/moz.build +++ b/b2g/components/moz.build @@ -20,7 +20,6 @@ EXTRA_COMPONENTS += [ 'ContentPermissionPrompt.js', 'FilePicker.js', 'MailtoProtocolHandler.js', - 'MozKeyboard.js', 'PaymentGlue.js', 'ProcessGlobal.js', 'SmsProtocolHandler.js', @@ -41,7 +40,6 @@ if CONFIG['MOZ_UPDATER']: EXTRA_JS_MODULES += [ 'ErrorPage.jsm', - 'Keyboard.jsm', 'SignInToWebsite.jsm', 'TelURIParser.jsm', ] diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index a4fdc0797f7c..0e209668769f 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "b0d3052513341e467a178ce82b372aba9783fe91", + "revision": "2f7fa802679f9ebfcd2021865aaf2ece4adae34f", "repo_path": "/integration/gaia-central" } diff --git a/dom/inputmethod/InputMethod.manifest b/dom/inputmethod/InputMethod.manifest new file mode 100644 index 000000000000..77fd07313b34 --- /dev/null +++ b/dom/inputmethod/InputMethod.manifest @@ -0,0 +1,6 @@ +component {397a7fdf-2254-47be-b74e-76625a1a66d5} MozKeyboard.js +contract @mozilla.org/b2g-keyboard;1 {397a7fdf-2254-47be-b74e-76625a1a66d5} +category JavaScript-navigator-property mozKeyboard @mozilla.org/b2g-keyboard;1 + +component {4607330d-e7d2-40a4-9eb8-43967eae0142} MozKeyboard.js +contract @mozilla.org/b2g-inputmethod;1 {4607330d-e7d2-40a4-9eb8-43967eae0142} diff --git a/b2g/components/Keyboard.jsm b/dom/inputmethod/Keyboard.jsm similarity index 100% rename from b2g/components/Keyboard.jsm rename to dom/inputmethod/Keyboard.jsm diff --git a/b2g/components/MozKeyboard.js b/dom/inputmethod/MozKeyboard.js similarity index 100% rename from b2g/components/MozKeyboard.js rename to dom/inputmethod/MozKeyboard.js diff --git a/dom/inputmethod/moz.build b/dom/inputmethod/moz.build new file mode 100644 index 000000000000..c91a56051aa0 --- /dev/null +++ b/dom/inputmethod/moz.build @@ -0,0 +1,14 @@ +# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# 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/. + +EXTRA_COMPONENTS += [ + 'MozKeyboard.js', + 'InputMethod.manifest', +] + +EXTRA_JS_MODULES += [ + 'Keyboard.jsm', +] diff --git a/dom/webidl/InputMethod.webidl b/dom/webidl/InputMethod.webidl index a87c6d2b7efe..ca71620b362d 100644 --- a/dom/webidl/InputMethod.webidl +++ b/dom/webidl/InputMethod.webidl @@ -5,7 +5,8 @@ */ [JSImplementation="@mozilla.org/b2g-inputmethod;1", - NavigatorProperty="mozInputMethod"] + NavigatorProperty="mozInputMethod", + Pref="dom.mozInputMethod.enabled"] interface MozInputMethod : EventTarget { // Input Method Manager contain a few global methods expose to apps readonly attribute MozInputMethodManager mgmt; @@ -27,7 +28,8 @@ interface MozInputMethod : EventTarget { // Manages the list of IMEs, enables/disables IME and switches to an // IME. -[JSImplementation="@mozilla.org/b2g-imm;1"] +[JSImplementation="@mozilla.org/b2g-imm;1", + Pref="dom.mozInputMethod.enabled"] interface MozInputMethodManager { // Ask the OS to show a list of available IMEs for users to switch from. // OS should ignore this request if the app is currently not the active one. @@ -55,7 +57,8 @@ interface MozInputMethodManager { // It also hosts the methods available to the keyboard app to mutate the input field represented. // An "input context" gets void when the app is no longer allowed to interact with the text field, // e.g., the text field does no longer exist, the app is being switched to background, and etc. -[JSImplementation="@mozilla.org/b2g-inputcontext;1"] +[JSImplementation="@mozilla.org/b2g-inputcontext;1", + Pref="dom.mozInputMethod.enabled"] interface MozInputContext: EventTarget { // The tag name of input field, which is enum of "input", "textarea", or "contenteditable" readonly attribute DOMString? type; @@ -82,6 +85,10 @@ interface MozInputContext: EventTarget { readonly attribute long selectionStart; readonly attribute long selectionEnd; + // The start and stop position of the selection. + readonly attribute DOMString? textBeforeCursor; + readonly attribute DOMString? textAfterCursor; + /* * Set the selection range of the the editable text. * Note: This method cannot be used to move the cursor during composition. Calling this diff --git a/dom/webidl/WebIDL.mk b/dom/webidl/WebIDL.mk index f2670ce0e72b..8c29c81ee80b 100644 --- a/dom/webidl/WebIDL.mk +++ b/dom/webidl/WebIDL.mk @@ -180,6 +180,7 @@ webidl_files = \ IDBVersionChangeEvent.webidl \ ImageData.webidl \ ImageDocument.webidl \ + InputMethod.webidl \ InspectorUtils.webidl \ KeyboardEvent.webidl \ KeyEvent.webidl \ @@ -534,9 +535,3 @@ test_webidl_files := \ else test_webidl_files := $(NULL) endif - -ifdef MOZ_B2G -webidl_files += \ - InputMethod.webidl \ - $(NULL) -endif diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index bb67644f792d..30ad371117f3 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -4372,3 +4372,6 @@ pref("dom.forms.inputmode", false); #else pref("dom.forms.inputmode", true); #endif + +// InputMethods for soft keyboards in B2G +pref("dom.mozInputMethod.enabled", false);