1// Copyright 2020 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
5module ui.mojom;
6
7import "mojo/public/mojom/base/string16.mojom";
8import "mojo/public/mojom/base/text_direction.mojom";
9import "ui/base/ime/mojom/ime_types.mojom";
10import "ui/base/ime/mojom/virtual_keyboard_types.mojom";
11import "ui/gfx/geometry/mojom/geometry.mojom";
12import "ui/gfx/range/mojom/range.mojom";
13
14// This structure contains ime text span and its bounds.
15struct ImeTextSpanInfo {
16  ui.mojom.ImeTextSpan span;
17  gfx.mojom.Rect bounds;
18};
19
20// This structure represents the current editing state.
21struct TextInputState {
22  // Type of the input field.
23  ui.mojom.TextInputType type = ui.mojom.TextInputType.NONE;
24
25  // The mode of input field.
26  ui.mojom.TextInputMode mode = ui.mojom.TextInputMode.kDefault;
27
28  // The action of the input field.
29  ui.mojom.TextInputAction action = ui.mojom.TextInputAction.kDefault;
30
31  // The flags of input field (autocorrect, autocomplete, etc.)
32  // See ui/base/ime/text_input_flags.h for definitions.
33  uint32 flags;
34
35  // The value of input field.
36  mojo_base.mojom.BigString16? value;
37
38  // The current selection range, or the caret position if nothing is selected.
39  gfx.mojom.Range selection;
40
41  // The current composition range if there is one.
42  gfx.mojom.Range? composition;
43
44  // Whether or not inline composition can be performed for the current input.
45  bool can_compose_inline = true;
46
47  // Whether or not the IME should be shown as a result of this update. Even if
48  // true, the IME will only be shown if the input is appropriate (e.g. not
49  // TEXT_INPUT_TYPE_NONE).
50  bool show_ime_if_needed;
51
52  // Whether or not the IME should always be hidden as a result of this update.
53  bool always_hide_ime;
54
55  // Whether or not this is a reply to a request from IME.
56  bool reply_to_request;
57
58  // Store control and selection bounds of EditContext.
59  // These optionals will be nullopts if there isn't any active EditContext.
60  // For non EditContext scenarios, the bounds are returned via
61  // |GetCompositionCharacterBounds|
62  gfx.mojom.Rect? edit_context_control_bounds;
63  gfx.mojom.Rect? edit_context_selection_bounds;
64
65  // The virtualkeyboardpolicy of the input field.
66  ui.mojom.VirtualKeyboardPolicy vk_policy =
67    ui.mojom.VirtualKeyboardPolicy.AUTO;
68
69  // Whether or not show()/hide() API is called from VirtualKeyboard by web
70  // authors when the virtualkeyboardpolicy is manual.
71  ui.mojom.VirtualKeyboardVisibilityRequest last_vk_visibility_request =
72    ui.mojom.VirtualKeyboardVisibilityRequest.NONE;
73
74  // Information of ime text spans at the cursor position.
75  array<ImeTextSpanInfo> ime_text_spans_info;
76};
77
78