# Copyright 2017 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# Contributing to Chrome DevTools Protocol: https://goo.gle/devtools-contribution-guide-cdp

domain Input

  type TouchPoint extends object
    properties
      # X coordinate of the event relative to the main frame's viewport in CSS pixels.
      number x
      # Y coordinate of the event relative to the main frame's viewport in CSS pixels. 0 refers to
      # the top of the viewport and Y increases as it proceeds towards the bottom of the viewport.
      number y
      # X radius of the touch area (default: 1.0).
      optional number radiusX
      # Y radius of the touch area (default: 1.0).
      optional number radiusY
      # Rotation angle (default: 0.0).
      optional number rotationAngle
      # Force (default: 1.0).
      optional number force
      # The normalized tangential pressure, which has a range of [-1,1] (default: 0).
      experimental optional number tangentialPressure
      # The plane angle between the Y-Z plane and the plane containing both the stylus axis and the Y axis, in degrees of the range [-90,90], a positive tiltX is to the right (default: 0)
      optional number tiltX
      # The plane angle between the X-Z plane and the plane containing both the stylus axis and the X axis, in degrees of the range [-90,90], a positive tiltY is towards the user (default: 0).
      optional number tiltY
      # The clockwise rotation of a pen stylus around its own major axis, in degrees in the range [0,359] (default: 0).
      experimental optional integer twist
      # Identifier used to track touch sources between events, must be unique within an event.
      optional number id

  experimental type GestureSourceType extends string
    enum
      default
      touch
      mouse

  type MouseButton extends string
    enum
        none
        left
        middle
        right
        back
        forward

  # UTC time in seconds, counted from January 1, 1970.
  type TimeSinceEpoch extends number

  experimental type DragDataItem extends object
    properties
      # Mime type of the dragged data.
      string mimeType
      # Depending of the value of `mimeType`, it contains the dragged link,
      # text, HTML markup or any other data.
      string data

      # Title associated with a link. Only valid when `mimeType` == "text/uri-list".
      optional string title

      # Stores the base URL for the contained markup. Only valid when `mimeType`
      # == "text/html".
      optional string baseURL


  experimental type DragData extends object
    properties
      array of DragDataItem items
      # List of filenames that should be included when dropping
      optional array of string files
      # Bit field representing allowed drag operations. Copy = 1, Link = 2, Move = 16
      integer dragOperationsMask

  # Dispatches a drag event into the page.
  experimental command dispatchDragEvent
    parameters
      # Type of the drag event.
      enum type
        dragEnter
        dragOver
        drop
        dragCancel
      # X coordinate of the event relative to the main frame's viewport in CSS pixels.
      number x
      # Y coordinate of the event relative to the main frame's viewport in CSS pixels. 0 refers to
      # the top of the viewport and Y increases as it proceeds towards the bottom of the viewport.
      number y
      DragData data
      # Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8
      # (default: 0).
      optional integer modifiers

  # Dispatches a key event to the page.
  command dispatchKeyEvent
    parameters
      # Type of the key event.
      enum type
        keyDown
        keyUp
        rawKeyDown
        char
      # Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8
      # (default: 0).
      optional integer modifiers
      # Time at which the event occurred.
      optional TimeSinceEpoch timestamp
      # Text as generated by processing a virtual key code with a keyboard layout. Not needed for
      # for `keyUp` and `rawKeyDown` events (default: "")
      optional string text
      # Text that would have been generated by the keyboard if no modifiers were pressed (except for
      # shift). Useful for shortcut (accelerator) key handling (default: "").
      optional string unmodifiedText
      # Unique key identifier (e.g., 'U+0041') (default: "").
      optional string keyIdentifier
      # Unique DOM defined string value for each physical key (e.g., 'KeyA') (default: "").
      optional string code
      # Unique DOM defined string value describing the meaning of the key in the context of active
      # modifiers, keyboard layout, etc (e.g., 'AltGr') (default: "").
      optional string key
      # Windows virtual key code (default: 0).
      optional integer windowsVirtualKeyCode
      # Native virtual key code (default: 0).
      optional integer nativeVirtualKeyCode
      # Whether the event was generated from auto repeat (default: false).
      optional boolean autoRepeat
      # Whether the event was generated from the keypad (default: false).
      optional boolean isKeypad
      # Whether the event was a system key event (default: false).
      optional boolean isSystemKey
      # Whether the event was from the left or right side of the keyboard. 1=Left, 2=Right (default:
      # 0).
      optional integer location
      # Editing commands to send with the key event (e.g., 'selectAll') (default: []).
      # These are related to but not equal the command names used in `document.execCommand` and NSStandardKeyBindingResponding.
      # See https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/editing/commands/editor_command_names.h for valid command names.
      experimental optional array of string commands

  # This method emulates inserting text that doesn't come from a key press,
  # for example an emoji keyboard or an IME.
  experimental command insertText
    parameters
      # The text to insert.
      string text

  # This method sets the current candidate text for IME.
  # Use imeCommitComposition to commit the final text.
  # Use imeSetComposition with empty string as text to cancel composition.
  experimental command imeSetComposition
    parameters
      # The text to insert
      string text
      # selection start
      integer selectionStart
      # selection end
      integer selectionEnd
      # replacement start
      optional integer replacementStart
      # replacement end
      optional integer replacementEnd

  # Dispatches a mouse event to the page.
  command dispatchMouseEvent
    parameters
      # Type of the mouse event.
      enum type
        mousePressed
        mouseReleased
        mouseMoved
        mouseWheel
      # X coordinate of the event relative to the main frame's viewport in CSS pixels.
      number x
      # Y coordinate of the event relative to the main frame's viewport in CSS pixels. 0 refers to
      # the top of the viewport and Y increases as it proceeds towards the bottom of the viewport.
      number y
      # Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8
      # (default: 0).
      optional integer modifiers
      # Time at which the event occurred.
      optional TimeSinceEpoch timestamp
      # Mouse button (default: "none").
      optional MouseButton button
      # A number indicating which buttons are pressed on the mouse when a mouse event is triggered.
      # Left=1, Right=2, Middle=4, Back=8, Forward=16, None=0.
      optional integer buttons
      # Number of times the mouse button was clicked (default: 0).
      optional integer clickCount
      # The normalized pressure, which has a range of [0,1] (default: 0).
      experimental optional number force
      # The normalized tangential pressure, which has a range of [-1,1] (default: 0).
      experimental optional number tangentialPressure
      # The plane angle between the Y-Z plane and the plane containing both the stylus axis and the Y axis, in degrees of the range [-90,90], a positive tiltX is to the right (default: 0).
      optional number tiltX
      # The plane angle between the X-Z plane and the plane containing both the stylus axis and the X axis, in degrees of the range [-90,90], a positive tiltY is towards the user (default: 0).
      optional number tiltY
      # The clockwise rotation of a pen stylus around its own major axis, in degrees in the range [0,359] (default: 0).
      experimental optional integer twist
      # X delta in CSS pixels for mouse wheel event (default: 0).
      optional number deltaX
      # Y delta in CSS pixels for mouse wheel event (default: 0).
      optional number deltaY
      # Pointer type (default: "mouse").
      optional enum pointerType
        mouse
        pen

  # Dispatches a touch event to the page.
  command dispatchTouchEvent
    parameters
      # Type of the touch event. TouchEnd and TouchCancel must not contain any touch points, while
      # TouchStart and TouchMove must contains at least one.
      enum type
        touchStart
        touchEnd
        touchMove
        touchCancel
      # Active touch points on the touch device. One event per any changed point (compared to
      # previous touch event in a sequence) is generated, emulating pressing/moving/releasing points
      # one by one.
      array of TouchPoint touchPoints
      # Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8
      # (default: 0).
      optional integer modifiers
      # Time at which the event occurred.
      optional TimeSinceEpoch timestamp

  # Cancels any active dragging in the page.
  command cancelDragging

  # Emulates touch event from the mouse event parameters.
  experimental command emulateTouchFromMouseEvent
    parameters
      # Type of the mouse event.
      enum type
        mousePressed
        mouseReleased
        mouseMoved
        mouseWheel
      # X coordinate of the mouse pointer in DIP.
      integer x
      # Y coordinate of the mouse pointer in DIP.
      integer y
      # Mouse button. Only "none", "left", "right" are supported.
      MouseButton button
      # Time at which the event occurred (default: current time).
      optional TimeSinceEpoch timestamp
      # X delta in DIP for mouse wheel event (default: 0).
      optional number deltaX
      # Y delta in DIP for mouse wheel event (default: 0).
      optional number deltaY
      # Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8
      # (default: 0).
      optional integer modifiers
      # Number of times the mouse button was clicked (default: 0).
      optional integer clickCount

  # Ignores input events (useful while auditing page).
  command setIgnoreInputEvents
    parameters
      # Ignores input events processing when set to true.
      boolean ignore

  # Prevents default drag and drop behavior and instead emits `Input.dragIntercepted` events.
  # Drag and drop behavior can be directly controlled via `Input.dispatchDragEvent`.
  experimental command setInterceptDrags
    parameters
      boolean enabled

  # Synthesizes a pinch gesture over a time period by issuing appropriate touch events.
  experimental command synthesizePinchGesture
    parameters
      # X coordinate of the start of the gesture in CSS pixels.
      number x
      # Y coordinate of the start of the gesture in CSS pixels.
      number y
      # Relative scale factor after zooming (>1.0 zooms in, <1.0 zooms out).
      number scaleFactor
      # Relative pointer speed in pixels per second (default: 800).
      optional integer relativeSpeed
      # Which type of input events to be generated (default: 'default', which queries the platform
      # for the preferred input type).
      optional GestureSourceType gestureSourceType

  # Synthesizes a scroll gesture over a time period by issuing appropriate touch events.
  experimental command synthesizeScrollGesture
    parameters
      # X coordinate of the start of the gesture in CSS pixels.
      number x
      # Y coordinate of the start of the gesture in CSS pixels.
      number y
      # The distance to scroll along the X axis (positive to scroll left).
      optional number xDistance
      # The distance to scroll along the Y axis (positive to scroll up).
      optional number yDistance
      # The number of additional pixels to scroll back along the X axis, in addition to the given
      # distance.
      optional number xOverscroll
      # The number of additional pixels to scroll back along the Y axis, in addition to the given
      # distance.
      optional number yOverscroll
      # Prevent fling (default: true).
      optional boolean preventFling
      # Swipe speed in pixels per second (default: 800).
      optional integer speed
      # Which type of input events to be generated (default: 'default', which queries the platform
      # for the preferred input type).
      optional GestureSourceType gestureSourceType
      # The number of times to repeat the gesture (default: 0).
      optional integer repeatCount
      # The number of milliseconds delay between each repeat. (default: 250).
      optional integer repeatDelayMs
      # The name of the interaction markers to generate, if not empty (default: "").
      optional string interactionMarkerName

  # Synthesizes a tap gesture over a time period by issuing appropriate touch events.
  experimental command synthesizeTapGesture
    parameters
      # X coordinate of the start of the gesture in CSS pixels.
      number x
      # Y coordinate of the start of the gesture in CSS pixels.
      number y
      # Duration between touchdown and touchup events in ms (default: 50).
      optional integer duration
      # Number of times to perform the tap (e.g. 2 for double tap, default: 1).
      optional integer tapCount
      # Which type of input events to be generated (default: 'default', which queries the platform
      # for the preferred input type).
      optional GestureSourceType gestureSourceType

  # Emitted only when `Input.setInterceptDrags` is enabled. Use this data with `Input.dispatchDragEvent` to
  # restore normal drag and drop behavior.
  experimental event dragIntercepted
    parameters
      DragData data
