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

syntax = "proto2";

import "components/feed/core/proto/ui/piet/binding_refs.proto";
import "components/feed/core/proto/ui/piet/text.proto";

package components.feed.core.proto.ui.piet;

option optimize_for = LITE_RUNTIME;

option java_package = "org.chromium.components.feed.core.proto.ui.piet";
option java_outer_classname = "AccessibilityProto";
option cc_enable_arenas = true;

// Defines accessibility related attributes for Piet elements.
message Accessibility {
  oneof description_data {
    // A string that may be spoken by the system. (TalkBack on Android,
    // VoiceOver on iOS, browser on Web)
    ParameterizedText description = 1;

    // In case this is coming from a template.
    ParameterizedTextBindingRef description_binding = 3;
  }

  // Roles that this UI element plays in the UI. These annotations will be used
  // by the accessibility framework for applying role-specific treatments.
  repeated AccessibilityRole roles = 2;

  oneof accessibility_id_data {
    // A string that uniquely identifies this UI element. This is used by
    // automated UI testing frameworks. The identifier's scope is determined by
    // the test framework, which typically allows searching by identifier across
    // an element type or within a container.

    // NOTE: parameters are not supported for accessibility_id. Only the 'text'
    // field should be used to specify the identifier.
    ParameterizedText accessibility_id = 4;

    // ID coming from a template.
    ParameterizedTextBindingRef accessibility_id_binding = 5;
  }

  oneof context_data {
    // A string that may be spoken by the system that describes the result of an
    // action. For example, "Opens the article." This provides additional
    // context over the description.

    // NOTE: Only supported by iOS and maps to accessibilityHint on an
    // accessible element.
    ParameterizedText context = 6;

    // In case this is coming from a template.
    ParameterizedTextBindingRef context_binding = 7;
  }
}

// Semantic roles played by a UI element related to accessibility.
enum AccessibilityRole {
  // No special role. The default value, maps to 0.
  ACCESSIBILITY_ROLE_UNSPECIFIED = 0;

  // Indicates that the UI element is a list containing other elements.
  LIST = 1;

  // Indicates that the UI element is a header for a section.
  HEADER = 2;
}
