// Copyright 2014 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.

// TODO(nektar): Migrate entire file to Mojoq.
// Must also be kept in sync with chrome/common/extensions/api/automation.idl.
[camel_case_enum_to_string=true] namespace ui {

  // For new entries to the following four enums, also add to
  // chrome/common/extensions/api/automation.idl. This is enforced
  // by a PRESUBMIT check.
  //
  // Explanation of the comments next to these events:
  //
  // Web: this event is only used in web content. Unless a specific platform
  //      is specified, it fires a native event on multiple platforms.
  //
  // Native: this event is only used in native UI.
  //
  // Implicit: it would be cleaner if we just updated the AX node
  //     and each platform fired the appropriate events to indicate which
  //     platform-specific attributes changed.
  //
  // If unspecified, the event is used across web and native on multiple
  // platforms.
  enum AXEvent {
    activedescendantchanged,   // Web
    alert,
    aria_attribute_changed,    // Implicit
    autocorrection_occured,    // Unknown: http://crbug.com/392498
    blur,                      // Remove: http://crbug.com/392502
    checked_state_changed,     // Implicit
    children_changed,
    clicked,
    document_selection_changed,
    expanded_changed,          // Web
    focus,
    hide,                      // Remove: http://crbug.com/392502
    hit_test_result,
    hover,
    image_frame_updated,       // Web
    invalid_status_changed,    // Implicit
    layout_complete,           // Web
    live_region_created,       // Implicit
    live_region_changed,       // Web
    load_complete,             // Web
    location_changed,          // Web
    media_started_playing,     // Automation
    media_stopped_playing,     // Automation
    menu_end,                  // Native / Win
    menu_list_item_selected,   // Web
    menu_list_value_changed,   // Web
    menu_popup_end,            // Native / Win
    menu_popup_start,          // Native / Win
    menu_start,                // Native / Win
    mouse_canceled,
    mouse_dragged,
    mouse_moved,
    mouse_pressed,
    mouse_released,
    row_collapsed,             // Web / Mac
    row_count_changed,         // Web / Mac
    row_expanded,              // Web / Mac
    scroll_position_changed,   // Web
    scrolled_to_anchor,        // Web
    selected_children_changed, // Web
    selection,                 // Native
    selection_add,             // Native
    selection_remove,          // Native
    show,                      // Remove: http://crbug.com/392502
    text_changed,
    text_selection_changed,
    tree_changed,              // Accessibility tree changed. Don't
                               // explicitly fire an accessibility event,
                               // only implicitly due to the change.
    value_changed
  };

  enum AXRole {
    abbr,
    alert_dialog,
    alert,
    anchor,
    annotation,
    application,
    article,
    audio,
    banner,
    blockquote,
    button,
    button_drop_down,  // Not used on Web.
    canvas,
    caption,
    caret,
    cell,
    check_box,
    client,
    color_well,
    column_header,
    column,
    combo_box_grouping,
    combo_box_menu_button,
    complementary,
    content_info,
    date,
    date_time,
    definition,
    description_list_detail,
    description_list,
    description_list_term,
    desktop,
    details,
    dialog,
    directory,
    disclosure_triangle,
    document,
    embedded_object,
    feed,
    figcaption,
    figure,
    footer,
    form,
    generic_container,
    grid,
    group,
    heading,
    iframe,
    iframe_presentational,
    ignored,
    image_map,
    image,
    inline_text_box,
    input_time,
    label_text,
    legend,
    line_break,
    link,
    list_box_option,
    list_box,
    list_item,
    list_marker,
    list,
    location_bar,
    log,
    main,
    mark,
    marquee,
    math,
    menu,
    menu_bar,
    menu_button,
    menu_item,
    menu_item_check_box,
    menu_item_radio,
    menu_list_option,
    menu_list_popup,
    meter,
    navigation,
    note,
    pane,
    paragraph,
    pop_up_button,
    pre,
    presentational,
    progress_indicator,
    radio_button,
    radio_group,
    region,
    root_web_area,
    row_header,
    row,
    ruby,
    svg_root,
    scroll_bar,
    search,
    search_box,
    slider,
    slider_thumb,
    spin_button_part,
    spin_button,
    splitter,
    static_text,
    status,
    switch,
    tab_list,
    tab_panel,
    tab,
    table_header_container,
    table,
    term,
    text_field,
    text_field_with_combo_box,
    time,
    timer,
    title_bar,
    toggle_button,
    toolbar,
    tree_grid,
    tree_item,
    tree,
    unknown,
    tooltip,
    video,
    web_area,
    web_view,
    window
  };

  enum AXState {
    collapsed,
    default,
    editable,
    expanded,
    focusable,
    haspopup,
    // Grows horizontally, e.g. most toolbars and separators.
    horizontal,
    hovered,
    invisible,
    linked,
    multiline,
    multiselectable,
    protected,
    required,
    richly_editable,
    selectable,
    selected,
    // Grows vertically, e.g. menu or combo box.
    vertical,
    visited
  };

  // An action to be taken on an accessibility node.
  // In contrast to |AXDefaultActionVerb|, these describe what happens to the
  // object, e.g. "FOCUS".
  enum AXAction {
    blur,

    custom_action,

    // Decrement a slider or range control by one step value.
    decrement,

    // Do the default action for an object, typically this means "click".
    do_default,

    focus,

    // Return the content of this image object in the image_data attribute.
    get_image_data,

    // Given a point, find the object it corresponds to and fire a
    // |AXActionData.hit_test_event_to_fire| event on it in response.
    hit_test,

    // Increment a slider or range control by one step value.
    increment,

    // Load inline text boxes for this subtree, providing information
    // about word boundaries, line layout, and individual character
    // bounding boxes.
    load_inline_text_boxes,

    // Delete any selected text in the control's text value and
    // insert |AXActionData::value| in its place, like when typing or pasting.
    replace_selected_text,

    // Scrolls by approximately one screen in a specific direction. Should be
    // called on a node that has scrollable boolean set to true.
    scroll_backward,
    scroll_forward,
    scroll_up,
    scroll_down,
    scroll_left,
    scroll_right,

    // Scroll any scrollable containers to make the target object visible
    // on the screen.  Optionally pass a subfocus rect in
    // AXActionData.target_rect, in node-local coordinates.
    scroll_to_make_visible,

    // Scroll the given object to a specified point on the screen in
    // global screen coordinates. Pass a point in AXActionData.target_point.
    scroll_to_point,

    set_scroll_offset,
    set_selection,

    // Don't focus this node, but set it as the sequential focus navigation
    // starting point, so that pressing Tab moves to the next element
    // following this one, for example.
    set_sequential_focus_navigation_starting_point,

    // Replace the value of the control with AXActionData::value and
    // reset the selection, if applicable.
    set_value,

    show_context_menu
  };

  enum AXActionFlags {
    request_images,
    request_inline_text_boxes
  };

  // A list of valid values for the |AXIntAttribute| |default_action_verb|.
  // These will describe the action that will be performed on a given node when
  // executing the default action, which is a click.
  // In contrast to |AXAction|, these describe what the user can do on the
  // object, e.g. "PRESS", not what happens to the object as a result.
  // Only one verb can be used at a time to describe the default action.
  enum AXDefaultActionVerb {
    activate,
    check,
    click,

    // A click will be performed on one of the node's ancestors.
    // This happens when the node itself is not clickable, but one of its
    // ancestors has click handlers attached which are able to capture the click
    // as it bubbles up.
    click_ancestor,

    jump,
    open,
    press,
    select,
    uncheck
  };

  // A change to the accessibility tree.
  enum AXMutation {
    node_created,
    subtree_created,
    node_changed,
    node_removed
  };

  [cpp_enum_prefix_override="ax_attr"] enum AXStringAttribute {
    access_key,
    // Only used when invalid_state == invalid_state_other.
    aria_invalid_value,
    auto_complete,
    chrome_channel,  // Automation only.
    class_name, // views and Android
    container_live_relevant,
    container_live_status,
    description,
    display,
    // Only present when different from parent.
    font_family,
    html_tag,
    image_data_url,
    inner_html,
    key_shortcuts,
    // Only present when different from parent.
    language,
    name,
    live_relevant,
    live_status,
    placeholder,
    role,
    role_description,
    url,
    value
  };

  [cpp_enum_prefix_override="ax_attr"] enum AXIntAttribute {
    default_action_verb,
    // Scrollable container attributes.
    scroll_x,
    scroll_x_min,
    scroll_x_max,
    scroll_y,
    scroll_y_min,
    scroll_y_max,

    // Attributes for retrieving the endpoints of a selection.
    text_sel_start,
    text_sel_end,

    // aria_col* and aria_row* attributes
    aria_column_count,
    aria_cell_column_index,
    aria_row_count,
    aria_cell_row_index,

    // Table attributes.
    table_row_count,
    table_column_count,
    table_header_id,

    // Table row attributes.
    table_row_index,
    table_row_header_id,

    // Table column attributes.
    table_column_index,
    table_column_header_id,

    // Table cell attributes.
    table_cell_column_index,
    table_cell_column_span,
    table_cell_row_index,
    table_cell_row_span,
    sort_direction,

    // Tree control attributes.
    hierarchical_level,

    // What information was used to compute the object's name
    // (of type AXNameFrom).
    name_from,

    // What information was used to compute the object's description
    // (of type AXDescriptionFrom).
    description_from,

    // Relationships between this element and other elements.
    activedescendant_id,
    details_id,
    errormessage_id,
    in_page_link_target_id,
    member_of_id,
    next_on_line_id,
    previous_on_line_id,

    // Identifies a child tree which this node hosts.
    child_tree_id,

    // Input restriction, if any, such as readonly or disabled.
    // Of type AXRestriction, see below.
    // No value or enabled control or other object that is not disabled.
    restriction,

    // Position or Number of items in current set of listitems or treeitems
    set_size,
    pos_in_set,

    // In the case of AX_ROLE_COLOR_WELL, specifies the selected color.
    color_value,

    // Indicates the element that represents the current item within a container
    // or set of related elements.
    aria_current_state,

    // Text attributes.

    // Foreground and background color in RGBA.
    background_color,
    color,

    // Indicates if a form control has invalid input or
    // if an element has an aria-invalid attribute.
    invalid_state,

    // Of type AXCheckedState
    checked_state,

    // Specifies the direction of the text, e.g., right-to-left.
    text_direction,

    // Bold, italic, underline, etc.
    text_style,

    // Focus traversal in views and Android.
    previous_focus_id,
    next_focus_id
  };

  [cpp_enum_prefix_override="ax_attr"] enum AXFloatAttribute {
    // Range attributes.
    value_for_range,
    min_value_for_range,
    max_value_for_range,
    step_value_for_range,

    // Text attributes.
    // Font size is in pixels.
    font_size
  };

  [cpp_enum_prefix_override="ax_attr"] enum AXBoolAttribute {
    // Generic busy state, does not have to be on a live region.
    busy,
    // The object is at the root of an editable field, such as a content
    // editable.
    editable_root,

    // Live region attributes.
    container_live_atomic,
    container_live_busy,
    live_atomic,

    // If a dialog box is marked as explicitly modal
    modal,

    // If this is set, all of the other fields in this struct should
    // be ignored and only the locations should change.
    update_location_only,

    // Set on a canvas element if it has fallback content.
    canvas_has_fallback,

    // Indicates this node is scrollable (Android only).
    scrollable,

    // A hint to clients that the node is clickable.
    clickable,

    // Indicates that this node clips its children, i.e. may have
    // overflow: hidden or clip children by default.
    clips_children
  };

  [cpp_enum_prefix_override="ax_attr"] enum AXIntListAttribute {
    // Ids of nodes that are children of this node logically, but are
    // not children of this node in the tree structure. As an example,
    // a table cell is a child of a row, and an 'indirect' child of a
    // column.
    indirect_child_ids,

    // Relationships between this element and other elements.
    controls_ids,
    describedby_ids,
    flowto_ids,
    labelledby_ids,
    radio_group_ids,

    // For static text. Character indices where line breaks occur. Note that
    // this attribute is only available on Chrome OS and will be deprecated
    // soon.
    line_breaks,

    // For static text. These int lists must be the same size; they represent
    // the start and end character offset of each marker. Examples of markers
    // include spelling and grammar errors, and find-in-page matches.
    marker_types,
    marker_starts,
    marker_ends,

    // For a table, the cell ids in row-major order, with duplicate entries
    // when there's a rowspan or colspan, and with -1 for missing cells.
    // There are always exactly rows * columns entries.
    cell_ids,

    // For a table, the unique cell ids in row-major order of their first
    // occurrence.
    unique_cell_ids,

    // For inline text. This is the pixel position of the end of this
    // character within the bounding rectangle of this object, in the
    // direction given by AX_ATTR_TEXT_DIRECTION. For example, for left-to-right
    // text, the first offset is the right coordinate of the first character
    // within the object's bounds, the second offset is the right coordinate
    // of the second character, and so on.
    character_offsets,

    // Used for caching. Do not read directly. Use
    // |AXNode::GetOrComputeLineStartOffsets|
    // For all text fields and content editable roots: A list of the start
    // offsets of each line inside this object.
    cached_line_starts,

    // For inline text. These int lists must be the same size; they represent
    // the start and end character offset of each word within this text.
    word_starts,
    word_ends,

    // Used for an UI element to define custom actions for it. For example, a
    // list UI will allow a user to reorder items in the list by dragging the
    // items. Developer can expose those actions as custom actions. Currently
    // custom actions are used only in Android window.
    custom_action_ids
  };

  [cpp_enum_prefix_override="ax_attr"] enum AXStringListAttribute {
    // Descriptions for custom actions. This must be aligned with
    // custom_action_ids.
    custom_action_descriptions
  };

  // TODO(dmazzoni, nektar): make this list not grow exponentially as new
  // MarkerTypes are added
  enum AXMarkerType {
    // Assignments are ignored by the parser, but are kept here for clarity.
    spelling = 1,
    grammar = 2,
    spelling_grammar = 3,
    text_match = 4,
    spelling_text_match = 5,
    grammar_text_match = 6,
    spelling_grammar_text_match = 7,
    // DocumentMarker::MarkerType::Composition = 8 is ignored for accessibility
    // purposes
    active_suggestion = 16,
    spelling_active_suggestion = 17,
    grammar_active_suggestion = 18,
    spelling_grammar_active_suggestion = 19,
    text_match_active_suggestion = 20,
    spelling_text_match_active_suggestion = 21,
    grammar_text_match_active_suggestion = 22,
    spelling_grammar_text_match_active_suggestion = 23,
    suggestion = 32,
    spelling_suggestion = 33,
    grammar_suggestion = 34,
    spelling_grammar_suggestion = 35,
    text_match_suggestion = 36,
    spelling_text_match_suggestion = 37,
    grammar_text_match_suggestion = 38,
    spelling_grammar_text_match_suggestion = 39,
    // We again skip over DocumentMarker::MarkerType::Composition = 8 here
    active_suggestion_suggestion = 48,
    spelling_active_suggestion_suggestion = 49,
    grammar_active_suggestion_suggestion = 50,
    spelling_grammar_active_suggestion_suggestion = 51,
    text_match_active_suggestion_suggestion = 52,
    spelling_text_match_active_suggestion_suggestion = 53,
    grammar_text_match_active_suggestion_suggestion = 54,
    spelling_grammar_text_match_active_suggestion_suggestion = 55
  };

  enum AXTextDirection {
    ltr,
    rtl,
    ttb,
    btt
  };

  // A Java counterpart will be generated for this enum.
  // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.ui.accessibility
  [cpp_enum_prefix_override="ax"] enum AXTextStyle {
    // Assignments are ignored by the parser, but are kept here for clarity.
    text_style_bold = 1,
    text_style_italic = 2,
    text_style_bold_italic = 3,
    text_style_underline = 4,
    text_style_bold_underline = 5,
    text_style_italic_underline = 6,
    text_style_bold_italic_underline = 7,
    text_style_line_through = 8,
    text_style_bold_line_through = 9,
    text_style_italic_line_through = 10,
    text_style_bold_italic_line_through = 11,
    text_style_underline_line_through = 12,
    text_style_bold_underline_line_through = 13,
    text_style_italic_underline_line_through = 14,
    text_style_bold_italic_underline_line_through = 15
  };

  enum AXAriaCurrentState {
    false,
    true,
    page,
    step,
    location,
    unclipped_location,
    date,
    time
  };

  enum AXInvalidState {
    false,
    true,
    spelling,
    grammar,
    other
  };

  // Input restriction associated with an object.
  // No value for a control means it is enabled.
  // Use read_only for a textbox that allows focus/selection but not input.
  // Use disabled for a control or group of controls that disallows input.
  enum AXRestriction {
    read_only,
    disabled
  };

  enum AXCheckedState {
    false,
    true,
    mixed
  };

  enum AXSortDirection {
    unsorted,
    ascending,
    descending,
    other
  };

  enum AXNameFrom {
    uninitialized,
    attribute,
    attribute_explicitly_empty,
    contents,
    placeholder,
    related_element,
    value
  };

  enum AXDescriptionFrom {
    uninitialized,
    attribute,
    contents,
    placeholder,
    related_element
  };

  enum AXEventFrom {
    user,
    page,
    action
  };

  // Touch gestures on Chrome OS.
  enum AXGesture {
    click,
    swipe_left_1,
    swipe_up_1,
    swipe_right_1,
    swipe_down_1,
    swipe_left_2,
    swipe_up_2,
    swipe_right_2,
    swipe_down_2,
    swipe_left_3,
    swipe_up_3,
    swipe_right_3,
    swipe_down_3,
    swipe_left_4,
    swipe_up_4,
    swipe_right_4,
    swipe_down_4,
    tap_2
  };

  enum AXTextAffinity {
    downstream,
    upstream
  };

  // Compares two nodes in an accessibility tree in pre-order traversal.
  enum AXTreeOrder {
    // Not in the same tree, or other error.
    undefined,

    // First node is before the second one.
    before,

    // Nodes are the same.
    equal,

    // First node is after the second one.
    after
  };
};
