summaryrefslogtreecommitdiff
path: root/chromium/components/arc/common/ime.mojom
blob: 732a37bcbd4b07074355170da29e2d3b7e7f5612 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Next MinVersion: 10

module arc.mojom;

import "components/arc/common/gfx.mojom";

// Represents the type of text input field currently focused.
[Extensible]
enum TextInputType {
  NONE,
  TEXT,
  PASSWORD,
  SEARCH,
  EMAIL,
  NUMBER,
  TELEPHONE,
  URL,
  DATE,
  TIME,
  DATETIME,
};

// Represents a single segment of text currently composed by IME.
struct CompositionSegment {
  // Start offset of the segment in UTF-16 index.
  uint32 start_offset;
  // End offset of the segment in UTF-16 index.
  uint32 end_offset;
  // Indicates that this segment should be emphasized.
  bool emphasized;
};

// Next method ID: 6
interface ImeHost {
  // Notifies Chrome that the text input focus is changed.
  OnTextInputTypeChanged@0(TextInputType type);

  // Notifies Chrome that the cursor poisition has changed.
  //
  // |rect| describes the coordinates in physical pixels.
  // If |is_screen_coordinates| is set to true, its origin (0,0) is the top-left
  // of the primary display. Otherwise it is the top-left of the window that has
  // the IME focus.
  OnCursorRectChanged@1(Rect rect,
                        [MinVersion=8] bool is_screen_coordinates);

  // Notifies Chrome that the current composition is canceled.
  [MinVersion=1] OnCancelComposition@2();

  // Show virtual keyboard of Chrome OS if needed.
  [MinVersion=2] ShowImeIfNeeded@3();

  // Notifies Chrome that the cursor position has changed and
  // also sends surrounding text.
  //
  // |rect| describes the coordinates in physical pixels.
  // If |is_screen_coordinates| is set to true, its origin (0,0) is the top-left
  // of the primary display. Otherwise it is the top-left of the window that has
  // the IME focus.
  //
  // |text_range|, |text_in_range| and |selection_range| are piggy-backed
  // into this method because Chrome OS IME tries to retrieve these information
  // synchronously, so we need to update them all at once to keep consistency.
  [MinVersion=5] OnCursorRectChangedWithSurroundingText@4(
      Rect rect,              // The cursor position.
      Range text_range,       // The range of |text_in_range| in the current
                                  // text in the editor.
      string text_in_range,       // The text around the cursor.
      Range selection_range,  // The range of the selected text
                                  // in the current text in the editor.
      [MinVersion=8] bool is_screen_coordinates  // Whether or not the |rect|
                                                 // are in screen coordinates.
      );

  // Requests Chrome to hide the virtual keyboard.
  // Howver, hiding can be canceled if a text field gets focus.
  // TODO(yhanada): We might be able to remove this method by adding an argument
  //                to OnTextInputTypeChanged().
  [MinVersion=9] RequestHideIme@5();
};

// Next method ID: 7
interface ImeInstance {
  // DEPRECATED: Please use Init@6 instead.
  InitDeprecated@0(ImeHost host_ptr);

  // Establishes full-duplex communication with the host.
  [MinVersion=6] Init@6(ImeHost host_ptr) => ();

  // Sets composition text and attributes requested by the host IME.
  SetCompositionText@1(string text, array<CompositionSegment> segments);

  // Commits the last set composition text and clears the composition.
  ConfirmCompositionText@2();

  // Commits the specified text and clears the composition.
  InsertText@3(string text);

  // Informs the virtual keyboard availability and bounds on screen is changing.
  // |is_available| whether a virtual keyboard is visible or not.
  // |new_bounds| Represents a virtual keyboard bounds covering below windows in
  // screen coordinate. physical pixel as a unit.
  [MinVersion=3] OnKeyboardAppearanceChanging@4(
      Rect new_bounds,
      [MinVersion=7] bool is_available);

  // Deletes current selection plus the specified number of char16 values
  // before and after selection or caret.
  [MinVersion=4] ExtendSelectionAndDelete@5(uint64 before, uint64 after);
};