Bug 906096 - Move InputMethod API behind a pref instead of build option. r=kanru, 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-09-04 08:29:22 -04:00
Родитель fd9ba8a89b
Коммит 7e289eedd8
14 изменённых файлов: 123 добавлений и 88 удалений

Просмотреть файл

@ -750,3 +750,6 @@ pref("dom.promise.enabled", false);
// (only applies when marionette is disabled) // (only applies when marionette is disabled)
// 0 disables the timer. // 0 disables the timer.
pref("b2g.adb.timeout-hours", 12); pref("b2g.adb.timeout-hours", 12);
// InputMethod so we can do soft keyboards
pref("dom.mozInputMethod.enabled", true);

Просмотреть файл

@ -15,14 +15,6 @@ component {88b3eb21-d072-4e3b-886d-f89d8c49fe59} UpdatePrompt.js
contract @mozilla.org/updates/update-prompt;1 {88b3eb21-d072-4e3b-886d-f89d8c49fe59} contract @mozilla.org/updates/update-prompt;1 {88b3eb21-d072-4e3b-886d-f89d8c49fe59}
#endif #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 # DirectoryProvider.js
component {9181eb7c-6f87-11e1-90b1-4f59d80dd2e5} DirectoryProvider.js component {9181eb7c-6f87-11e1-90b1-4f59d80dd2e5} DirectoryProvider.js
contract @mozilla.org/browser/directory-provider;1 {9181eb7c-6f87-11e1-90b1-4f59d80dd2e5} contract @mozilla.org/browser/directory-provider;1 {9181eb7c-6f87-11e1-90b1-4f59d80dd2e5}

Просмотреть файл

@ -4,77 +4,9 @@
#include "domstubs.idl" #include "domstubs.idl"
interface nsIDOMDOMRequest;
[scriptable, uuid(3615a616-571d-4194-bf54-ccf546067b14)] [scriptable, uuid(3615a616-571d-4194-bf54-ccf546067b14)]
interface nsIB2GCameraContent : nsISupports interface nsIB2GCameraContent : nsISupports
{ {
/* temporary solution, waiting for getUserMedia */ /* temporary solution, waiting for getUserMedia */
DOMString getCameraURI([optional] in jsval options); DOMString getCameraURI([optional] in jsval options);
}; };
[scriptable, uuid(40ad96b2-9efa-41fb-84c7-fbcec9b153f0)]
interface nsIB2GKeyboard : nsISupports
{
void sendKey(in long keyCode, in long charCode);
// Select the <select> option specified by index.
// If this method is called on a <select> that support multiple
// selection, then the option specified by index will be added to
// the selection.
// If this method is called for a select that does not support multiple
// selection the previous element will be unselected.
void setSelectedOption(in jsval index);
// Select the <select> options specified by indexes. All other options
// will be deselected.
// If this method is called for a <select> that does not support multiple
// selection, then the last index specified in indexes will be selected.
void setSelectedOptions(in jsval indexes);
// Set the value on the currently focused element. This has to be used
// for special situations where the value had to be chosen amongst a
// list (type=month) or a widget (type=date, time, etc.).
// If the value passed in parameter isn't valid (in the term of HTML5
// Forms Validation), the value will simply be ignored by the element.
void setValue(in jsval value);
void removeFocus();
attribute nsIDOMEventListener onfocuschange;
// Fires when user moves the cursor, changes the selection, or alters the
// composing text length
attribute nsIDOMEventListener onselectionchange;
// The start position of the selection.
readonly attribute long selectionStart;
// The stop position of the selection.
readonly attribute long selectionEnd;
/*
* Set the selection range of the the editable text.
*
* @param start The beginning of the selected text.
* @param end The end of the selected text.
*
* Note that the start position should be less or equal to the end position.
* To move the cursor, set the start and end position to the same value.
*/
void setSelectionRange(in long start, in long end);
/*
* Replace text around the beginning of the current selection range of the
* editable text.
*
* @param text The string to be replaced with.
* @param beforeLength The number of characters to be deleted before the
* beginning of the current selection range. Defaults to 0.
* @param afterLength The number of characters to be deleted after the
* beginning of the current selection range. Defaults to 0.
*/
void replaceSurroundingText(in DOMString text,
[optional] in long beforeLength,
[optional] in long afterLength);
};

Просмотреть файл

@ -20,7 +20,6 @@ EXTRA_COMPONENTS += [
'ContentPermissionPrompt.js', 'ContentPermissionPrompt.js',
'FilePicker.js', 'FilePicker.js',
'MailtoProtocolHandler.js', 'MailtoProtocolHandler.js',
'MozKeyboard.js',
'PaymentGlue.js', 'PaymentGlue.js',
'ProcessGlobal.js', 'ProcessGlobal.js',
'SmsProtocolHandler.js', 'SmsProtocolHandler.js',
@ -41,7 +40,6 @@ if CONFIG['MOZ_UPDATER']:
EXTRA_JS_MODULES += [ EXTRA_JS_MODULES += [
'ErrorPage.jsm', 'ErrorPage.jsm',
'Keyboard.jsm',
'SignInToWebsite.jsm', 'SignInToWebsite.jsm',
'TelURIParser.jsm', 'TelURIParser.jsm',
] ]

Просмотреть файл

@ -213,6 +213,7 @@
@BINPATH@/components/dom_xpath.xpt @BINPATH@/components/dom_xpath.xpt
@BINPATH@/components/dom_xul.xpt @BINPATH@/components/dom_xul.xpt
@BINPATH@/components/dom_time.xpt @BINPATH@/components/dom_time.xpt
@BINPATH@/components/dom_inputmethod.xpt
@BINPATH@/components/downloads.xpt @BINPATH@/components/downloads.xpt
@BINPATH@/components/editor.xpt @BINPATH@/components/editor.xpt
@BINPATH@/components/embed_base.xpt @BINPATH@/components/embed_base.xpt

Просмотреть файл

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

Просмотреть файл

Просмотреть файл

26
dom/inputmethod/moz.build Normal file
Просмотреть файл

@ -0,0 +1,26 @@
# -*- 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/.
XPIDL_SOURCES += [
'nsIB2GKeyboard.idl',
]
XPIDL_MODULE = 'dom_inputmethod'
MODULE = 'dom'
EXTRA_COMPONENTS += [
'InputMethod.manifest',
'MozKeyboard.js',
]
EXTRA_JS_MODULES += [
'Keyboard.jsm',
]
FAIL_ON_WARNINGS = True
LIBXUL_LIBRARY = True

Просмотреть файл

@ -0,0 +1,71 @@
/* 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/. */
#include "domstubs.idl"
[scriptable, uuid(40ad96b2-9efa-41fb-84c7-fbcec9b153f0)]
interface nsIB2GKeyboard : nsISupports
{
void sendKey(in long keyCode, in long charCode);
// Select the <select> option specified by index.
// If this method is called on a <select> that support multiple
// selection, then the option specified by index will be added to
// the selection.
// If this method is called for a select that does not support multiple
// selection the previous element will be unselected.
void setSelectedOption(in jsval index);
// Select the <select> options specified by indexes. All other options
// will be deselected.
// If this method is called for a <select> that does not support multiple
// selection, then the last index specified in indexes will be selected.
void setSelectedOptions(in jsval indexes);
// Set the value on the currently focused element. This has to be used
// for special situations where the value had to be chosen amongst a
// list (type=month) or a widget (type=date, time, etc.).
// If the value passed in parameter isn't valid (in the term of HTML5
// Forms Validation), the value will simply be ignored by the element.
void setValue(in jsval value);
void removeFocus();
attribute nsIDOMEventListener onfocuschange;
// Fires when user moves the cursor, changes the selection, or alters the
// composing text length
attribute nsIDOMEventListener onselectionchange;
// The start position of the selection.
readonly attribute long selectionStart;
// The stop position of the selection.
readonly attribute long selectionEnd;
/*
* Set the selection range of the the editable text.
*
* @param start The beginning of the selected text.
* @param end The end of the selected text.
*
* Note that the start position should be less or equal to the end position.
* To move the cursor, set the start and end position to the same value.
*/
void setSelectionRange(in long start, in long end);
/*
* Replace text around the beginning of the current selection range of the
* editable text.
*
* @param text The string to be replaced with.
* @param beforeLength The number of characters to be deleted before the
* beginning of the current selection range. Defaults to 0.
* @param afterLength The number of characters to be deleted after the
* beginning of the current selection range. Defaults to 0.
*/
void replaceSurroundingText(in DOMString text,
[optional] in long beforeLength,
[optional] in long afterLength);
};

Просмотреть файл

@ -72,7 +72,8 @@ PARALLEL_DIRS += [
'camera', 'camera',
'audiochannel', 'audiochannel',
'promise', 'promise',
'wappush' 'wappush',
'inputmethod'
] ]
if CONFIG['OS_ARCH'] == 'WINNT': if CONFIG['OS_ARCH'] == 'WINNT':

Просмотреть файл

@ -5,7 +5,8 @@
*/ */
[JSImplementation="@mozilla.org/b2g-inputmethod;1", [JSImplementation="@mozilla.org/b2g-inputmethod;1",
NavigatorProperty="mozInputMethod"] NavigatorProperty="mozInputMethod",
Pref="dom.mozInputMethod.enabled"]
interface MozInputMethod : EventTarget { interface MozInputMethod : EventTarget {
// Input Method Manager contain a few global methods expose to apps // Input Method Manager contain a few global methods expose to apps
readonly attribute MozInputMethodManager mgmt; readonly attribute MozInputMethodManager mgmt;
@ -27,7 +28,8 @@ interface MozInputMethod : EventTarget {
// Manages the list of IMEs, enables/disables IME and switches to an // Manages the list of IMEs, enables/disables IME and switches to an
// IME. // IME.
[JSImplementation="@mozilla.org/b2g-imm;1"] [JSImplementation="@mozilla.org/b2g-imm;1",
Pref="dom.mozInputMethod.enabled"]
interface MozInputMethodManager { interface MozInputMethodManager {
// Ask the OS to show a list of available IMEs for users to switch from. // 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. // 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. // 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, // 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. // 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 { interface MozInputContext: EventTarget {
// The tag name of input field, which is enum of "input", "textarea", or "contenteditable" // The tag name of input field, which is enum of "input", "textarea", or "contenteditable"
readonly attribute DOMString? type; readonly attribute DOMString? type;
@ -82,6 +85,10 @@ interface MozInputContext: EventTarget {
readonly attribute long selectionStart; readonly attribute long selectionStart;
readonly attribute long selectionEnd; 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. * Set the selection range of the the editable text.
* Note: This method cannot be used to move the cursor during composition. Calling this * Note: This method cannot be used to move the cursor during composition. Calling this

Просмотреть файл

@ -180,6 +180,7 @@ webidl_files = \
IDBVersionChangeEvent.webidl \ IDBVersionChangeEvent.webidl \
ImageData.webidl \ ImageData.webidl \
ImageDocument.webidl \ ImageDocument.webidl \
InputMethod.webidl \
InspectorUtils.webidl \ InspectorUtils.webidl \
KeyboardEvent.webidl \ KeyboardEvent.webidl \
KeyEvent.webidl \ KeyEvent.webidl \
@ -541,9 +542,3 @@ test_webidl_files := \
else else
test_webidl_files := $(NULL) test_webidl_files := $(NULL)
endif endif
ifdef MOZ_B2G
webidl_files += \
InputMethod.webidl \
$(NULL)
endif

Просмотреть файл

@ -4380,3 +4380,6 @@ pref("dom.forms.inputmode", false);
#else #else
pref("dom.forms.inputmode", true); pref("dom.forms.inputmode", true);
#endif #endif
// InputMethods for soft keyboards in B2G
pref("dom.mozInputMethod.enabled", false);