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-26 03:38:41 +08:00
Родитель 0b82ee5016
Коммит 54abab3203
16 изменённых файлов: 134 добавлений и 89 удалений

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

@ -794,6 +794,9 @@ pref("dom.inter-app-communication-api.enabled", true);
// 0 disables the timer.
pref("b2g.adb.timeout-hours", 12);
// InputMethod so we can do soft keyboards
pref("dom.mozInputMethod.enabled", true);
// Absolute path to the devtool unix domain socket file used
// to communicate with a usb cable via adb forward
pref("devtools.debugger.unix-domain-socket", "/data/local/debugger-socket");

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

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

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

@ -4,77 +4,9 @@
#include "domstubs.idl"
interface nsIDOMDOMRequest;
[scriptable, uuid(3615a616-571d-4194-bf54-ccf546067b14)]
interface nsIB2GCameraContent : nsISupports
{
/* temporary solution, waiting for getUserMedia */
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',
'FilePicker.js',
'MailtoProtocolHandler.js',
'MozKeyboard.js',
'PaymentGlue.js',
'ProcessGlobal.js',
'SmsProtocolHandler.js',
@ -42,7 +41,6 @@ if CONFIG['MOZ_UPDATER']:
EXTRA_JS_MODULES += [
'ErrorPage.jsm',
'Keyboard.jsm',
'SignInToWebsite.jsm',
'TelURIParser.jsm',
'WebappsUpdater.jsm',

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

@ -190,6 +190,7 @@
@BINPATH@/components/dom_notification.xpt
@BINPATH@/components/dom_html.xpt
@BINPATH@/components/dom_indexeddb.xpt
@BINPATH@/components/dom_inputmethod.xpt
@BINPATH@/components/dom_offline.xpt
@BINPATH@/components/dom_payment.xpt
@BINPATH@/components/dom_json.xpt
@ -547,6 +548,10 @@
@BINPATH@/components/PaymentRequestInfo.js
@BINPATH@/components/Payment.manifest
; InputMethod API
@BINPATH@/components/MozKeyboard.js
@BINPATH@/components/InputMethod.manifest
; Modules
@BINPATH@/modules/*
@ -748,7 +753,6 @@ bin/components/@DLL_PREFIX@nkgnomevfs@DLL_SUFFIX@
@BINPATH@/components/UpdatePrompt.js
#endif
@BINPATH@/components/WebappsUpdateTimer.js
@BINPATH@/components/MozKeyboard.js
@BINPATH@/components/DirectoryProvider.js
@BINPATH@/components/ActivitiesGlue.js
@BINPATH@/components/ProcessGlobal.js

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

@ -200,6 +200,7 @@
@BINPATH@/components/dom_notification.xpt
@BINPATH@/components/dom_html.xpt
@BINPATH@/components/dom_indexeddb.xpt
@BINPATH@/components/dom_inputmethod.xpt
@BINPATH@/components/dom_offline.xpt
@BINPATH@/components/dom_json.xpt
@BINPATH@/components/dom_power.xpt
@ -556,6 +557,10 @@
@BINPATH@/components/dom_webspeechsynth.xpt
#endif
; InputMethod API
@BINPATH@/components/MozKeyboard.js
@BINPATH@/components/InputMethod.manifest
; Modules
@BINPATH@/browser/modules/*
@BINPATH@/modules/*

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

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

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

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

@ -331,7 +331,7 @@ MozInputMethod.prototype = {
if (perm != Ci.nsIPermissionManager.ALLOW_ACTION) {
dump("No permission to use the keyboard API for " +
principal.origin + "\n");
return null;
return;
}
}

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

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

@ -74,6 +74,7 @@ PARALLEL_DIRS += [
'promise',
'wappush',
'telephony',
'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;
@ -31,7 +32,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.
@ -59,7 +61,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;
@ -86,6 +89,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

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

@ -186,6 +186,7 @@ WEBIDL_FILES = [
'IDBVersionChangeEvent.webidl',
'ImageData.webidl',
'ImageDocument.webidl',
'InputMethod.webidl',
'InspectorUtils.webidl',
'InterAppConnection.webidl',
'InterAppConnectionRequest.webidl',
@ -532,11 +533,6 @@ if CONFIG['ENABLE_TESTS']:
'TestJSImplGen.webidl',
]
if CONFIG['MOZ_B2G']:
WEBIDL_FILES += [
'InputMethod.webidl',
]
GENERATED_EVENTS_WEBIDL_FILES = [
'BlobEvent.webidl',
'DeviceLightEvent.webidl',

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

@ -4424,6 +4424,9 @@ pref("dom.forms.inputmode", false);
pref("dom.forms.inputmode", true);
#endif
// InputMethods for soft keyboards in B2G
pref("dom.mozInputMethod.enabled", false);
// Telephony API
pref("dom.telephony.enabled", false);

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

@ -1,6 +1,7 @@
"use strict";
const isB2G = ("@mozilla.org/b2g-keyboard;1" in Components.classes);
const isB2G = ("@mozilla.org/b2g-process-global;1" in Cc);
do_get_profile(); // must be called before getting nsIX509CertDB
const certdb = Cc["@mozilla.org/security/x509certdb;1"].getService(Ci.nsIX509CertDB);