WebAPI/KeboardIME: Difference between revisions

Jump to navigation Jump to search
(→‎Proposed API: Update proposed API to the latest one posted on dev-webapi)
Line 48: Line 48:


  partial interface Navigator {
  partial interface Navigator {
     readonly attribute InputMethodManager mozInputMethodManager;
     readonly attribute InputMethod inputMethod;
    readonly attribute InputMethodConnection mozInputMethodConnection;
};
 
dictionary InputMethodInfo {
    url: 'XXX',
    name: 'IME name',
    locale: 'en-US',
  };
  };


  // Manages the list of IMEs, enables/disables IME and switches to an IME.
  // Manages the list of IMEs, enables/disables IME and switches to an IME.
  interface InputMethodManager {
  interface InputMethodManager {
     // Show a (system) menu for all enabled input methods that allow user to select.
     // Ask the OS to show a list of available IMEs for users to switch from.
    void showInputMethodPicker();
     // OS should ignore this request if we are currently not the active one.
     void showAll();
    // Get a list of all installed IMEs.
    Promise<InputMethodInfo[]> getAll();
    // Get a list of all enabled IMEs.
    Promise<InputMethodInfo[]> getEnabled();
    // Get input method info of the caller IME.
    Promise<InputMethodInfo> getSelf();
    // Switch to the given IME.
     // Privileged API. Only the system app and current IME can switch IME.
     Promise<boolean> setCurrentInputMethod(InputMethodInfo info);
   
   
     // Switch to next IME.
     // Ask the OS to switch away from the current active Keyboard app.
    // We may not need this method and use setCurrentInputMethod instead.
     // OS should ignore this request if we are currently not the active one.
    Promise<boolean> switchToNextInputMethod();
     void next();
    // Get current IME.
    Promise<InputMethodInfo> getCurrentInputMethod();
    // Enable an IME.
    // Privileged API. Only the system app can eanble an IME.
    Promise<boolean> enable(InputMethodInfo info);
    // Disable an IME.
     // Privileged API. Only the system app can disable an IME.
     Promise<boolean> disable(InputMethodInfo info);
   };
   };


  // The input context, which are attributes and information of current input field.
  // The input context, which consists of attributes and information of current input field.
  dictionary InputMethodContext {
  // An "input context" gets void when the app is no longer allowed to interact with the text field,
    // This is used to specify the target of input field operations. This ID becomes invalid as soon as user leaves input field and blur event is sent.
// e.g., the text field does no longer exist, the app is being switched to background, and etc.
    long contextId;
  interface InputContext {
   
     // 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"
     DOMString name;
     DOMString name;
Line 121: Line 90:
  };
  };


  interface InputMethodConnection: EventTarget {
  interface InputMethod: EventTarget {
     // It informs the IME that text input has started in an input field. If the IME is activated, this event is sent when focus enters a new input field. Otherwise this event is sent when user switches to the IME and activates it.
     // It informs the IME that text input has started in an input field. If the IME is activated, this event is sent when focus enters a new input field. Otherwise this event is sent when user switches to the IME and activates it.
     attribute EventHandler onstart;
     attribute EventHandler onstart;
Line 128: Line 97:
     attribute EventHandler onfinish;
     attribute EventHandler onfinish;
   
   
     // This event is sent when the attributes of input context has changed, such as type, but focus has not.
     // Fired when the input context changes, include changes from and to null.
     attribute EventHandler oncontextchange;
     attribute EventHandler oncontextchange;
   
   
Line 149: Line 118:
   
   
     // TODO: maybe the parameters could be simpler?
     // TODO: maybe the parameters could be simpler?
     Promise<boolean> sendKey(long contextId, long keyCode, long charCode, long modifiers);
     Promise<boolean> sendKey(long keyCode, long charCode, long modifiers);
     // Or Promise<boolean> sendKey(long contextId, KeyboardEvent event)
     // Or Promise<boolean> sendKey(KeyboardEvent event)
   
   
     /*
     /*
     *  Get the whole text content of the input field.
     *  Get the whole text content of the input field.
     */
     */
     Promise<DOMString> getText(long contextId);
     Promise<DOMString> getText();
   
   
     /*
     /*
Line 164: Line 133:
     * @param length The length of text to replace. Defaults to 0.
     * @param length The length of text to replace. Defaults to 0.
     */
     */
     Promise<boolean> commitText(long contextId, DOMString text, [optional] long offset, [optional] long length);
     Promise<boolean> commitText(DOMString text, [optional] long offset, [optional] long length);
   
   
     /*
     /*
Line 188: Line 157:
       * To move the cursor, set the start and end position to the same value.
       * To move the cursor, set the start and end position to the same value.
       */
       */
     Promise<boolean> setSelectionRange(long contextId, long start, long length);
     Promise<boolean> setSelectionRange(long start, long length);
   
   
     /*
     /*
Line 194: Line 163:
       * @param cursor Position in the text of the cursor.
       * @param cursor Position in the text of the cursor.
       */
       */
     Promise<boolean> setComposition(long contextId, DOMString text, long cursor);
     Promise<boolean> setComposition(DOMString text, long cursor);
   
   
     /*
     /*
Line 200: Line 169:
       * Use commitText to end composition and commit text.
       * Use commitText to end composition and commit text.
       */
       */
     Promise<boolean> clearComposition(long contextId);
     Promise<boolean> clearComposition();
   
   
     // Clear the focus of the current input field and hide the keyboard.
     // Clear the focus of the current input field and hide the keyboard.
     Promise<boolean> removeFocus(long contextId);
     Promise<boolean> removeFocus();
   
   
     // The input method context
     // The input method context
     readonly attribute InputMethodContext elementInfo;
    // 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 InputContext? inputcontext;
  };
  };


  [TreatNonCallableAsNull]
  [TreatNonCallableAsNull]
  callback SurroundingTextChangeEventHandlerNonNull = void (long contextId, DOMString beforeText, DOMString afterText);
  callback SurroundingTextChangeEventHandlerNonNull = void (DOMString beforeText, DOMString afterText);
  typedef SurroundingTextChangeEventHandlerNonNull? SurroundingTextChangeEventHandler;
  typedef SurroundingTextChangeEventHandlerNonNull? SurroundingTextChangeEventHandler;


Confirmed users
58

edits

Navigation menu