WebAPI/KeboardIME: Difference between revisions

Jump to navigation Jump to search
change Promise<boolean> to Promise<void> and add textBeforeCursor, textAfterCursor properties.
(change Promise<boolean> to Promise<void> and add textBeforeCursor, textAfterCursor properties.)
Line 232: Line 232:
     // 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.
     void <strike>showInputMethodPicker</strike> showAll();
     void showAll();
   
   
     // Ask the OS to switch away from the current active Keyboard app.
     // Ask the OS to switch away from the current active Keyboard app.
     // 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.
     void <strike>switchToNextInputMethod</strike> next();
     void next();
   
   
     // To know if the OS supports IME switching or not.
     // To know if the OS supports IME switching or not.
Line 249: Line 249:
     // This method belong to |mgmt| because we would like to allow Keyboard to access to
     // This method belong to |mgmt| because we would like to allow Keyboard to access to
     // this method w/o a input context.
     // this method w/o a input context.
     void <strike>removeFocus</strike> hide();
     void hide();
   };
   };


Line 268: Line 268:
  //      But I agree that also enabling the keyboard to declare in the manifest which types it supports
  //      But I agree that also enabling the keyboard to declare in the manifest which types it supports
  //      is a good idea.
  //      is a good idea.
  interface <strike>InputMethodConnection</strike> InputContext: EventTarget {
  interface InputContext: 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"
    <strike>// [JS] I think "type" would be better here.</strike>
     readonly DOMString type;
    <strike>// [JS] This should also be 'readonly', right?</strike>
     readonly DOMString <strike>name</strike> type;
   
   
     // The type of the input field, which is enum of text, number, password, url, search, email, and so on.
     // The type of the input field, which is enum of text, number, password, url, search, email, and so on.
     // See http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html#states-of-the-type-attribute
     // See http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html#states-of-the-type-attribute
    <strike>// [JS] and "inputtype" here.</strike>
     readonly DOMString inputType;
    <strike>// [JS] This should also be 'readonly', right?</strike>
     readonly DOMString <strike>type</strike> inputType;
   
   
     /*
     /*
Line 284: Line 280:
     * See http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#input-modalities:-the-inputmode-attribute
     * See http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#input-modalities:-the-inputmode-attribute
     */
     */
    <strike>// [JS] This should be 'readonly', right?</strike>
     readonly DOMString inputMode;
     readonly DOMString inputMode;
   
   
Line 292: Line 287:
     * See http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#htmlelement
     * See http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#htmlelement
     */
     */
    <strike>// [JS] This should be 'readonly', right?</strike>
     readonly DOMString lang;
     readonly DOMString lang;
   
   
Line 304: Line 298:
     readonly attribute long selectionEnd;
     readonly attribute long selectionEnd;
   
   
    // The text before and after the begining of the selected text.
    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.
Line 319: Line 317:
       *      selectionStart and selectionEnd.
       *      selectionStart and selectionEnd.
       */
       */
     Promise<boolean> setSelectionRange(long start, long length);
     <strike>Promise<boolean> setSelectionRange(long start, long length);</strike>
    Promise<void> setSelectionRange(long start, long length);
   
   
     /* User moves the cursor, or changes the selection with other means. If the text around
     /* User moves the cursor, or changes the selection with other means. If the text around
       * cursor has changed, but the cursor has not been moved, the IME won't get notification.
       * cursor has changed, but the cursor has not been moved, the IME won't get notification.
      *
      * [JJ] I would merge this with onsurroundingtextchange to have 1 state event.
      *      in the end, every onselectionchange event will also generate a surrounding
      *      text change event.
       */
       */
     attribute EventHandler onselectionchange;
     attribute EventHandler onselectionchange;
Line 337: Line 332:
       * @param length The length of text to replace. Defaults to 0.
       * @param length The length of text to replace. Defaults to 0.
       */
       */
       Promise<boolean> <strike>commitText</strike> replaceSurroundingText(DOMString text, [optional] long offset, [optional] long length);
       <strike>Promise<boolean> replaceSurroundingText(DOMString text, [optional] long offset, [optional] long length);</strike>
      Promise<void> replaceSurroundingText(DOMString text, [optional] long offset, [optional] long length);
   
   
     /*
     /*
Line 344: Line 340:
       * @param offset The offset from the cursor position where deletion starts.
       * @param offset The offset from the cursor position where deletion starts.
       * @param length The length of text to delete.
       * @param length The length of text to delete.
      * TODO: maybe updateSurroundingText(DOMString beforeText, DOMString afterText); ?
      * [JJ] Rather do a replaceSurroundingText(long offset, long length, optional DOMString text)
      *      If text is null or empty, it behaves the same
       */
       */
     Promise<boolean> deleteSurroundingText(long offset, long length);
     <strike>Promise<boolean> deleteSurroundingText(long offset, long length);</strike>
    Promise<void> deleteSurroundingText(long offset, long length);
   
   
     /*
     /*
Line 354: Line 348:
     * editing or cursor movement. If the cursor has been moved, but the text around has not
     * editing or cursor movement. If the cursor has been moved, but the text around has not
     * changed, the IME won't get notification.
     * changed, the IME won't get notification.
    *
    * The event handler function is specified as:
    * @param beforeString Text before and including cursor position.
    * @param afterString Text after and excluing cursor position.
    * function(DOMString beforeText, DOMString afterText) {
    * ...
    *  }
     */
     */
     // [JS] Can you describe how the cursor can be moved without the surrounding text
     // [JS] Can you describe how the cursor can be moved without the surrounding text
     //      also changing? Is that really something that can happen?
     //      also changing? Is that really something that can happen?
     // [yxl] For example, if the text field is filled with 'a', wherever the cusor movies the surrounding text is always 'aa...'.
     // [yxl] For example, if the text field is filled with 'a', wherever the cusor movies the surrounding text is always 'aa...'. Another exmaple, the selection range is changed, but the cursor isn't and the surrouding text won't be changed.
     attribute SurroundingTextChangeEventHandler onsurroundingtextchange;
     attribute EventHandler onsurroundingtextchange;
   
   
     /*
     /*
Line 373: Line 360:
       * Alternative: sendKey(KeyboardEvent event), but we will likely waste memory for creating the KeyboardEvent object.
       * Alternative: sendKey(KeyboardEvent event), but we will likely waste memory for creating the KeyboardEvent object.
       */
       */
     Promise<boolean> sendKey(long keyCode, long charCode, [optional] long modifiers);
     <strike>Promise<boolean> sendKey(long keyCode, long charCode, [optional] long modifiers);</strike>
    Promise<void> sendKey(long keyCode, long charCode, [optional] long modifiers);
   
   
     /*
     /*
Line 396: Line 384:
       * To finish composition and commit text to current input field, an IME should call |endComposition|.
       * To finish composition and commit text to current input field, an IME should call |endComposition|.
       */
       */
     <strike>// [JS] A more detailed description of how to use these two functions would be great.
     <strike>Promise<boolean> setComposition(DOMString text, [optional] long cursor);</strike>
    //      It's not really obvious to me what either of these two arguments do.</strike>
     Promise<void> setComposition(DOMString text, [optional] long cursor);
     Promise<boolean> setComposition(DOMString text, [optional] long cursor);
   
   
     /*
     /*
Line 410: Line 397:
       * |replaceSurroundingText|, |deleteSurroundingText|, user moving the cursor, changing the focus, etc.
       * |replaceSurroundingText|, |deleteSurroundingText|, user moving the cursor, changing the focus, etc.
       */
       */
     Promise<boolean> endComposition(DOMString text);
     <strike>Promise<boolean> endComposition(DOMString text);</strike>
    Promise<void> endComposition(DOMString text);
  };
  };


Confirmed users
58

edits

Navigation menu