Bug 906096 - Move InputMethod API behind a pref instead of build option. r=kchen, r=sicking

--HG--
rename : b2g/components/Keyboard.jsm => dom/inputmethod/Keyboard.jsm
rename : b2g/components/MozKeyboard.js => dom/inputmethod/MozKeyboard.js
This commit is contained in:
Jan Jongboom 2013-08-28 07:58:13 -04:00
parent 783f2e33c6
commit 02fd2f56a2
10 changed files with 37 additions and 19 deletions

View File

@ -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);

View File

@ -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}

View File

@ -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',
]

View File

@ -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}

14
dom/inputmethod/moz.build Normal file
View File

@ -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',
]

View File

@ -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

View File

@ -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

View File

@ -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);