// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module blink.mojom;
import "mojo/public/mojom/base/string16.mojom";
import "ui/gfx/geometry/mojom/geometry.mojom";
// This enum defines the various gesture actions to be supported for
// corresponding stylus writing gestures detected by Android platform's stylus
// writing service.
enum StylusWritingGestureAction {
DELETE_TEXT,
ADD_SPACE_OR_TEXT,
REMOVE_SPACES,
SPLIT_OR_MERGE,
SELECT_TEXT,
};
// This enum defines the different granularities which can be used when applying a gesture.
enum StylusWritingGestureGranularity {
// Apply to the characters contained within the gesture's range.
CHARACTER,
// Apply to all words whose centers are contained within the gesture's range.
WORD,
};
// This structure contains the gesture data sent by the stylus writing service
// to perform the corresponding gesture action in html input.
struct StylusWritingGestureData {
// The gesture action to be performed for this gesture.
StylusWritingGestureAction action;
// The resolution with which to apply the gesture to the given text.
// This only applies to gestures which affect a range of text (eg. DELETE_TEXT)
// and should remain as the default value (CHARACTER) for other gestures.
StylusWritingGestureGranularity granularity;
// The DELETE_TEXT, REMOVE_SPACES gestures would contain two points, that is
// where the gesture started and ended to determine the text offset under the
// gesture. These points can be represented as two zero-sized rectangles.
// ADD_SPACE_OR_TEXT needs to be done after determining cursor position at
// one given point in the gesture, and hence would have only start rectangle.
// So, a start rectangle is always present in all gestures.
gfx.mojom.Rect start_rect;
// For multiline gestures, a rectangle for the last line included in the
// gesture is needed in addition to a rectangle for the first line included
// in the gesture (stored above). This is because the IME is not aware of the
// text direction.
gfx.mojom.Rect? end_rect;
// This is the alternate text to be inserted at current cursor in case the
// gesture could not be applied using above start and/or end points in the
// current focused input.
mojo_base.mojom.String16 text_alternative;
// This contains text to be added at a given point in the gesture. This is
// applicable only to gesture action ADD_SPACE_OR_TEXT and it would contain
// space character if there was no text to insert in the gesture.
mojo_base.mojom.String16? text_to_insert;
};