From 5f8de423f190bbb79a62f804151bc24824fa32d8 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 2 Feb 2018 04:16:08 -0500 Subject: Add m-esr52 at 52.6.0 --- dom/webidl/InputMethod.webidl | 738 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 738 insertions(+) create mode 100644 dom/webidl/InputMethod.webidl (limited to 'dom/webidl/InputMethod.webidl') diff --git a/dom/webidl/InputMethod.webidl b/dom/webidl/InputMethod.webidl new file mode 100644 index 0000000000..ca22dcc1b6 --- /dev/null +++ b/dom/webidl/InputMethod.webidl @@ -0,0 +1,738 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ + +/** + * InputMethod API implements a bridge between the web content hosting an input + * element and the input content (a.k.a. input app, virtual keyboard app, + * or IME). This API is input content facing in order for it to interact with + * the remote input element. + * The API also contains a few Gaia System app only methods + * (marked with "input-manage" permission) for Gaia System app to interact with + * some types of inputs and to regulate the input apps. + */ +[JSImplementation="@mozilla.org/b2g-inputmethod;1", + NavigatorProperty="mozInputMethod", + Pref="dom.mozInputMethod.enabled", + ChromeOnly] +interface MozInputMethod : EventTarget { + /** + * Activate or decactive current API instance. + * Gaia System app call this method via BrowserElement#setInputMethodActive. + */ + [ChromeOnly] + void setActive(boolean isActive); + + /** + * InputMethodManager contain a few global methods expose to input apps. + */ + readonly attribute MozInputMethodManager mgmt; + + /** + * Fired when the input context changes, include changes from and to null. + * The new InputContext instance will be available in the event + * object under |inputcontext| property. When it changes to null it + * means the app (the user of this API) no longer has the control of + * the original focused input field. + * Note that if the app saves the original context, it might get + * void; implementation decides when to void the input context. + */ + attribute EventHandler oninputcontextchange; + + /** + * An "input context" is mapped to a text field that the app is + * allow to mutate. This attribute should be null when there is no + * text field currently focused. + */ + readonly attribute MozInputContext? inputcontext; + + /** + * Add a dynamically declared input. + * + * The id must not be the same with any statically declared input in the app + * manifest. If an input of the same id is already declared, the info of that + * input will be updated. + */ + Promise addInput(DOMString inputId, + MozInputMethodInputManifest inputManifest); + + /** + * Remove a dynamically declared input. + * + * The id must not be the same with any statically declared input in the app + * manifest. Silently resolves if the input is not previously declared; + * rejects if attempt to remove a statically declared input. + */ + Promise removeInput(DOMString id); + + /** + * Remove focus from the current input, usable by Gaia System app, globally, + * regardless of the current focus state. + */ + void removeFocus(); + + /** + * The following are internal methods for Firefox OS System app only, + * for handling the "option" group inputs. + */ + + /** + * 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(DOMString value); + + /** + * Select the 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(long index); + + /** + * Select the that does not support multiple + * selection, then the last index specified in indexes will be selected. + */ + void setSelectedOptions(sequence indexes); +}; + +/** + * InputMethodManager contains a few of the global methods for the input app. + */ +[JSImplementation="@mozilla.org/b2g-imm;1", + Pref="dom.mozInputMethod.enabled", + ChromeOnly] +interface MozInputMethodManager : EventTarget { + /** + * Ask the OS to show a list of available inputs for users to switch from. + * OS should sliently ignore this request if the app is currently not the + * active one. + */ + void showAll(); + + /** + * Ask the OS to switch away from the current active input app. + * OS should sliently ignore this request if the app is currently not the + * active one. + */ + void next(); + + /** + * If this method returns true, it is recommended that the input app provides + * a shortcut that would invoke the next() method above, for easy switching + * between inputs -- i.e. show a "global" button on screen if the input app + * implements an on-screen virtual keyboard. + * + * The returning value is depend on the inputType of the current input context. + */ + boolean supportsSwitching(); + + /** + * Ask the OS to remove the input focus, will cause the lost of input context. + * OS should sliently ignore this request if the app is currently not the + * active one. + */ + void hide(); + + /** + * Update Gecko with information on the input types which supportsSwitching() + * should return ture. + * + * @param types Array of input types in which supportsSwitching() should + * return true. + */ + void setSupportsSwitchingTypes(sequence types); + + /** + * CustomEvent dispatches to System when there is an input to handle. + * If the API consumer failed to handle and call preventDefault(), + * there will be a message printed on the console. + * + * evt.detail is defined by MozInputContextFocusEventDetail. + */ + attribute EventHandler oninputcontextfocus; + + /** + * Event dispatches to System when there is no longer an input to handle. + * If the API consumer failed to handle and call preventDefault(), + * there will be a message printed on the console. + */ + attribute EventHandler oninputcontextblur; + + /** + * Event dispatches to System when there is a showAll() call. + * If the API consumer failed to handle and call preventDefault(), + * there will be a message printed on the console. + */ + attribute EventHandler onshowallrequest; + + /** + * Event dispatches to System when there is a next() call. + * If the API consumer failed to handle and call preventDefault(), + * there will be a message printed on the console. + */ + attribute EventHandler onnextrequest; + + /** + * Event dispatches to System when there is a addInput() call. + * The API consumer must call preventDefault() to indicate the event is + * consumed, otherwise the request is not considered handled even if + * waitUntil() was called. + * + * evt.detail is defined by MozInputRegistryEventDetail. + */ + attribute EventHandler onaddinputrequest; + + /** + * Event dispatches to System when there is a removeInput() call. + * The API consumer must call preventDefault() to indicate the event is + * consumed, otherwise the request is not considered handled even if + * waitUntil() was called. + * + * evt.detail is defined by MozInputRegistryEventDetail. + */ + attribute EventHandler onremoveinputrequest; +}; + +/** + * Detail of the inputcontextfocus event. + */ +[JSImplementation="@mozilla.org/b2g-imm-focus;1", + Pref="dom.mozInputMethod.enabled", + ChromeOnly] +interface MozInputContextFocusEventDetail { + /** + * The type of the focused input. + */ + readonly attribute MozInputMethodInputContextTypes type; + /** + * The input type of the focused input. + */ + readonly attribute MozInputMethodInputContextInputTypes inputType; + + /** + * The following is only needed for rendering and handling "option" input types, + * in System app. + */ + + /** + * Current value of the input. + */ + readonly attribute DOMString? value; + /** + * An object representing all the and