naiveproxy/services/ws/public/mojom/ime/ime.mojom

198 lines
6.1 KiB
Plaintext
Raw Normal View History

2018-12-10 05:59:24 +03:00
// 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.
module ws.mojom;
import "mojo/public/mojom/base/text_direction.mojom";
import "mojo/public/mojom/base/string16.mojom";
import "ui/events/mojo/event.mojom";
import "ui/gfx/geometry/mojo/geometry.mojom";
import "ui/gfx/range/mojo/range.mojom";
import "ui/platform_window/mojo/text_input_state.mojom";
// Specifies where to display the candidate window.
enum CandidateWindowPosition {
// Candidate window follows the cursor.
kCursor,
// Candidate window is locked to the beginning of the composition.
kComposition
};
struct CandidateWindowProperties {
// Number of candidates to display per page.
int32 page_size;
// Should candidate window be rendered vertical or horizontal.
bool vertical;
// Text that is shown at the bottom of the candidate window.
string auxiliary_text;
// True to display auxiliary text, false to hide it.
bool auxiliary_text_visible;
// Position and visibility of cursor in the candidate window.
int32 cursor_position;
bool cursor_visible;
// Where to display the candidate window.
CandidateWindowPosition window_position;
};
// Represents a candidate window entry.
struct CandidateWindowEntry {
// Value of the candidate.
mojo_base.mojom.String16 value;
// Short string displayed next to the candidate, often the shortcut key or
// index.
mojo_base.mojom.String16 label;
// Additional text describing the candidate.
mojo_base.mojom.String16 annotation;
// The usage or detailed description of the candidate.
mojo_base.mojom.String16 description_title;
mojo_base.mojom.String16 description_body;
};
// See comments for ui::ImeTextSpan::Type for more details.
enum ImeTextSpanType {
kComposition,
kSuggestion,
kMisspellingSuggestion,
};
// This enum represents the thickness of an underline segment of text,
// the thickness of a ui::ImeTextSpan element.
// The possible values are:
// * kNone: When you don't want to paint the underline.
// * kThin: For regular size.
// * kThick: For thick underlines.
enum ImeTextSpanThickness {
kNone,
kThin,
kThick,
};
// Represents an underlined segment of text currently composed by IME.
// Corresponds to ui::ImeTextSpan.
struct ImeTextSpan {
ImeTextSpanType type;
uint32 start_offset;
uint32 end_offset;
uint32 underline_color;
ImeTextSpanThickness thickness;
uint32 background_color;
uint32 suggestion_highlight_color;
array<string> suggestions;
};
// Represents a text currently being composed by IME. Corresponds to
// ui::CompositionText.
struct CompositionText {
mojo_base.mojom.String16 text;
array<ImeTextSpan> ime_text_spans;
gfx.mojom.Range selection;
};
// See comments for ui::TextInputMode for more details.
enum TextInputMode {
kDefault,
kNone,
kText,
kTel,
kUrl,
kEmail,
kNumeric,
kDecimal,
kSearch,
};
// Parameters needed to start an IME session.
struct StartSessionDetails {
TextInputClient client;
InputMethod& input_method_request;
// Initial details about |client| required by IMEDriver.
ui.mojom.TextInputType text_input_type;
TextInputMode text_input_mode;
mojo_base.mojom.TextDirection text_direction;
int32 text_input_flags;
gfx.mojom.Rect caret_bounds;
};
// A service which provides the IMEDriver interface is responsible for doing
// the composition logic. After starting a session, it receives events from
// the client via the InputMethod interface, and sends composition events to
// the client via the TextInputClient.
interface IMEDriver {
StartSession(StartSessionDetails details);
};
// An IME driver register should register itself to Mus using the IMERegistrar
// interface.
interface IMERegistrar {
RegisterDriver(IMEDriver driver);
};
// A client sends updates to the IME driver using the InputMethod interface.
// This interface is provided by IME drivers, and also by Mus as a lightweight
// proxy between IME drivers and clients.
interface InputMethod {
OnTextInputTypeChanged(ui.mojom.TextInputType text_input_type);
// Client sends |caret_bounds| in focused window coordinates,
// Mus translates it to global coordinates and sends it to IME app.
OnCaretBoundsChanged(gfx.mojom.Rect caret_bounds);
// Called to process a key event. The callback function will be called to
// notify the client if the event was handled or not. A handled event may
// generate zero or more composition events which will be sent to the client
// using the "input method result" functions of TextInputClient interface.
ProcessKeyEvent(ui.mojom.Event key_event) => (bool handled);
CancelComposition();
// Plumbs requests to show the virtual keyboard.
ShowVirtualKeyboardIfEnabled();
};
// IME drivers send updates to clients using the TextInputClient interface.
interface TextInputClient {
// Functions corresponding to "input method result" functions of
// ui::TextInputClient. See comments for InputMethod::ProcessKeyEvent() for
// when these are called.
// Sets composition text and attributes. See comments for
// ui::TextInputClient::SetCompositionText() for more details.
SetCompositionText(CompositionText composition);
// Converts current composition text into final content.
ConfirmCompositionText();
// Removes current composition text.
ClearCompositionText();
// Inserts a given text at the insertion point. Current composition text or
// selection will be removed. This method should never be called when the
// current text input type is TEXT_INPUT_TYPE_NONE.
InsertText(mojo_base.mojom.String16 text);
// Inserts a single character at the insertion point. Unlike InsertText(),
// the character is not processed. See ui::TextInputClient::InsertChar()
// for more details.
InsertChar(ui.mojom.Event event);
// Dispatch a key event skipping IME. Returns true if event was consumed.
DispatchKeyEventPostIME(ui.mojom.Event event) => (bool stopped_propagation);
// TODO(moshayedi): Add functions corresponding to ui::TextInputClient for:
// - Input context information
// - Document content operations
// - Miscellaneous functions
// crbug.com/631527.
};