Home | History | Annotate | Download | only in c
      1 /* Copyright 2013 The Chromium Authors. All rights reserved.
      2  * Use of this source code is governed by a BSD-style license that can be
      3  * found in the LICENSE file.
      4  */
      5 
      6 /* From ppb_text_input_controller.idl modified Thu Aug  1 09:30:48 2013. */
      7 
      8 #ifndef PPAPI_C_PPB_TEXT_INPUT_CONTROLLER_H_
      9 #define PPAPI_C_PPB_TEXT_INPUT_CONTROLLER_H_
     10 
     11 #include "ppapi/c/pp_bool.h"
     12 #include "ppapi/c/pp_instance.h"
     13 #include "ppapi/c/pp_macros.h"
     14 #include "ppapi/c/pp_point.h"
     15 #include "ppapi/c/pp_rect.h"
     16 #include "ppapi/c/pp_size.h"
     17 #include "ppapi/c/pp_stdint.h"
     18 #include "ppapi/c/pp_var.h"
     19 
     20 #define PPB_TEXTINPUTCONTROLLER_INTERFACE_1_0 "PPB_TextInputController;1.0"
     21 #define PPB_TEXTINPUTCONTROLLER_INTERFACE PPB_TEXTINPUTCONTROLLER_INTERFACE_1_0
     22 
     23 /**
     24  * @file
     25  * This file defines the <code>PPB_TextInputController</code> interface.
     26  */
     27 
     28 
     29 /**
     30  * @addtogroup Enums
     31  * @{
     32  */
     33 /**
     34  * PP_TextInput_Type is used to indicate the status of a plugin in regard to
     35  * text input.
     36  */
     37 typedef enum {
     38   /**
     39    * Input caret is not in an editable mode, no input method shall be used.
     40    */
     41   PP_TEXTINPUT_TYPE_NONE = 0,
     42   /**
     43    * Input caret is in a normal editable mode, any input method can be used.
     44    */
     45   PP_TEXTINPUT_TYPE_TEXT = 1,
     46   /**
     47    * Input caret is in a password box, an input method may be used only if
     48    * it's suitable for password input.
     49    */
     50   PP_TEXTINPUT_TYPE_PASSWORD = 2,
     51   PP_TEXTINPUT_TYPE_SEARCH = 3,
     52   PP_TEXTINPUT_TYPE_EMAIL = 4,
     53   PP_TEXTINPUT_TYPE_NUMBER = 5,
     54   PP_TEXTINPUT_TYPE_TELEPHONE = 6,
     55   PP_TEXTINPUT_TYPE_URL = 7
     56 } PP_TextInput_Type;
     57 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_TextInput_Type, 4);
     58 /**
     59  * @}
     60  */
     61 
     62 /**
     63  * @addtogroup Interfaces
     64  * @{
     65  */
     66 /**
     67  * <code>PPB_TextInputController</code> provides a set of functions for giving
     68  * hints to the browser about the text input status of plugins, and functions
     69  * for controlling input method editors (IMEs).
     70  */
     71 struct PPB_TextInputController_1_0 {
     72   /**
     73    * Informs the browser about the current text input mode of the plugin.
     74    * Typical use of this information in the browser is to properly
     75    * display/suppress tools for supporting text inputs (such as virtual
     76    * keyboards in touch screen based devices, or input method editors often
     77    * used for composing East Asian characters).
     78    */
     79   void (*SetTextInputType)(PP_Instance instance, PP_TextInput_Type type);
     80   /**
     81    * Informs the browser about the coordinates of the text input caret area.
     82    * Typical use of this information in the browser is to layout IME windows
     83    * etc.
     84    */
     85   void (*UpdateCaretPosition)(PP_Instance instance,
     86                               const struct PP_Rect* caret);
     87   /**
     88    * Cancels the current composition in IME.
     89    */
     90   void (*CancelCompositionText)(PP_Instance instance);
     91   /**
     92    * Informs the browser about the current text selection and surrounding
     93    * text. <code>text</code> is a UTF-8 string that contains the current range
     94    * of text selection in the plugin. <code>caret</code> is the byte-index of
     95    * the caret position within <code>text</code>. <code>anchor</code> is the
     96    * byte-index of the anchor position (i.e., if a range of text is selected,
     97    * it is the other edge of selection different from <code>caret</code>. If
     98    * there are no selection, <code>anchor</code> is equal to <code>caret</code>.
     99    *
    100    * Typical use of this information in the browser is to enable "reconversion"
    101    * features of IME that puts back the already committed text into the
    102    * pre-commit composition state. Another use is to improve the precision
    103    * of suggestion of IME by taking the context into account (e.g., if the caret
    104    * looks to be on the beginning of a sentence, suggest capital letters in a
    105    * virtual keyboard).
    106    *
    107    * When the focus is not on text, call this function setting <code>text</code>
    108    * to an empty string and <code>caret</code> and <code>anchor</code> to zero.
    109    * Also, the plugin should send the empty text when it does not want to reveal
    110    * the selection to IME (e.g., when the surrounding text is containing
    111    * password text).
    112    */
    113   void (*UpdateSurroundingText)(PP_Instance instance,
    114                                 struct PP_Var text,
    115                                 uint32_t caret,
    116                                 uint32_t anchor);
    117 };
    118 
    119 typedef struct PPB_TextInputController_1_0 PPB_TextInputController;
    120 /**
    121  * @}
    122  */
    123 
    124 #endif  /* PPAPI_C_PPB_TEXT_INPUT_CONTROLLER_H_ */
    125 
    126