chromium/third_party/blink/renderer/core/editing/ime/edit_context.idl

// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// The goal of the EditContext is to expose the lower-level APIs provided by
// modern operating systems to facilitate various input modalities to unlock
// advanced editing scenarios.

// Spec draft:
// https://w3c.github.io/edit-context/#editcontext-interface

[
    Exposed=Window,
    ActiveScriptWrappable
] interface EditContext : EventTarget {
    [CallWith=ScriptState] constructor(optional EditContextInit options = {});
    [RaisesException] void updateSelection(unsigned long start, unsigned long end);
    void updateControlBounds(DOMRect controlBounds);
    void updateSelectionBounds(DOMRect selectionBounds);
    void updateCharacterBounds(unsigned long rangeStart, sequence<DOMRect> characterBounds);
    [RaisesException] void updateText(unsigned long start, unsigned long end, DOMString newText);
    sequence<HTMLElement> attachedElements();

    readonly attribute DOMString text;
    readonly attribute unsigned long selectionStart;
    readonly attribute unsigned long selectionEnd;
    readonly attribute unsigned long characterBoundsRangeStart;
    sequence<DOMRect> characterBounds();

    // Event handler attributes
    attribute EventHandler ontextupdate;
    attribute EventHandler ontextformatupdate;
    attribute EventHandler oncharacterboundsupdate;
    attribute EventHandler oncompositionstart;
    attribute EventHandler oncompositionend;
};