// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Next MinVersion: 23
module arc.mojom;
import "ash/components/arc/mojom/gfx.mojom";
// Represents the type of text input field currently focused.
[Extensible]
enum TextInputType {
[Default] NONE,
TEXT,
PASSWORD,
SEARCH,
EMAIL,
NUMBER,
TELEPHONE,
URL,
DATE,
TIME,
DATETIME,
// Corresponds to InputType.TYPE_NULL of Android.
ANDROID_NULL,
};
// Maps to ui::TextInputFlags in ui/base/ime/text_input_flags.h.
// Some flags are still missing here because they're not yet supported in ARC++
// IME.
const int32 TEXT_INPUT_FLAG_NONE = 0;
const int32 TEXT_INPUT_FLAG_AUTOCAPITALIZE_NONE = 64; // 1 << 6
const int32 TEXT_INPUT_FLAG_AUTOCAPITALIZE_CHARACTERS = 128; // 1 << 7
const int32 TEXT_INPUT_FLAG_AUTOCAPITALIZE_WORDS = 256; // 1 << 8
const int32 TEXT_INPUT_FLAG_AUTOCAPITALIZE_SENTENCES = 512; // 1 << 9
[Extensible]
enum SegmentStyle {
DEFAULT,
EMPHASIZED,
NONE,
};
[Extensible]
enum CursorCoordinateSpace {
// (0, 0) is the top-left of the main display.
SCREEN,
// (0, 0) is the top-left of the current display.
DISPLAY,
// (0, 0) is the top-left of the notification display.
NOTIFICATION,
};
// 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.
// This field is deprecated, use |style| instead.
bool emphasized;
// Visual style of this segment.
[MinVersion=18] SegmentStyle style;
};
// Represents the information of a key event.
struct KeyEventData {
// Whether the event is a press event or a release event.
bool pressed;
// The key touched in the event represented in |ui::KeyboardCode|.
int32 key_code;
// The flags for modifiers state.
bool is_shift_down;
bool is_control_down;
bool is_alt_down;
bool is_capslock_on;
// An optional field used if |key_code| is undefined.
// It should be one of evdev codes (i.e. KEY_* defines)
// in <linux/input-event-codes.h>.
[MinVersion=16] uint32 scan_code;
[MinVersion=20] bool is_alt_gr_down;
[MinVersion=23] bool is_repeat;
};
// Deprecated method IDs: 1, 4, 5, 6
// Next method ID: 10
interface ImeHost {
// Notifies Chrome that the text input focus is changed.
// Each bit of the bitmask |flags| corresponds to TEXT_INPUT_FLAG_*.
OnTextInputTypeChanged@0(
TextInputType type,
[MinVersion=10] bool is_personalized_learning_allowed,
[MinVersion=11] int32 flags);
// Notifies Chrome that the cursor position has changed.
//
// |rect| describes the coordinates in physical pixels in the given
// coordinates.
[MinVersion=19] OnCursorRectChanged@8(
Rect rect,
CursorCoordinateSpace coordinateSpace);
// Notifies Chrome that the current composition is canceled.
[MinVersion=1] OnCancelComposition@2();
// Show virtual keyboard of Chrome OS if needed.
[MinVersion=2] ShowVirtualKeyboardIfEnabled@3();
// Notifies Chrome that the cursor position has changed and
// also sends surrounding text.
//
// |rect| describes the coordinates in physical pixels in the given
// coordinates.
//
// |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=19] OnCursorRectChangedWithSurroundingText@9(
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.
CursorCoordinateSpace coordinateSpace // The coordinate space of |rect|.
);
// Sends a key event to Chrome to pass it to the Chrome OS IME.
[MinVersion=14] SendKeyEvent@7(KeyEventData key_event_data)
=> (bool is_consumed);
};
// Represents a text input field that is hosted inside ARC++, allowing Chrome OS
// browser process to manipulate text within Android apps.
// Deprecated method IDs: 0
// Next method ID: 9
interface ImeInstance {
// Establishes full-duplex communication with the host.
[MinVersion=6] Init@6(pending_remote<ImeHost> host_remote) => ();
// Sets composition text and attributes requested by the host IME.
SetCompositionText@1(
string text,
array<CompositionSegment> segments,
[MinVersion=21] Range? selection_range);
// Sets selection text and attributes requested by the host IME.
[MinVersion=12] SetSelectionText@7(Range selection);
// Commits the last set composition text and clears the composition.
ConfirmCompositionText@2();
// Commits the specified text and clears the composition.
// |new_cursor_position| indicates where to place the cursor after commit,
// relative to |text|.
// If |new_cursor_position| > 0, then it is relative to the end (1 being the
// end of the text). If |new_cursor_position| <= 0, then it is relative to the
// start (0 being the beginning of the text).
InsertText@3(
string text,
[MinVersion=17] int32 new_cursor_position);
// 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);
// Sets composing region requested by the host IME.
[MinVersion=15] SetComposingRegion@8(Range range);
};