// 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";

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 = "BindingRefsProto";
option cc_enable_arenas = true;

// A BindingRef (binding reference) identifies a BindingValue of a specific type
// in a Binding. This is used when defining Templates, to bind to content.
//
// It is acceptable for multiple BindingRefs with the same binding_id to exist
// within the same binding context, e.g. if the same text were to be used more
// than once in the same Frame.
//
// It is NOT acceptable for multiple BindingValues in the same binding context
// to have the same binding_id; ERR_DUPLICATE_BINDING_VALUE will be raised.
//
// Some types of BindingRefs may be optional. If an optional binding is not
// provided, the element containing that binding will be omitted from the
// resulting view hierarchy. If a required binding is not provided,
// ERR_MISSING_BINDING_VALUE is raised.

message CustomBindingRef {
  // The unique ID for this binding. See comments at the top of the file.
  optional string binding_id = 1;

  // Indicates whether this binding reference is optional.
  optional bool is_optional = 2;
}

message ModuleBindingRef {
  // The unique ID for this binding. See comments at the top of the file.
  optional string binding_id = 1;

  // Indicates whether this binding reference is optional.
  optional bool is_optional = 2;
}

message ParameterizedTextBindingRef {
  // The unique ID for this binding. See comments at the top of the file.
  optional string binding_id = 1;

  // Indicates whether this binding reference is optional.
  optional bool is_optional = 2;
}

message ChunkedTextBindingRef {
  // The unique ID for this binding. See comments at the top of the file.
  optional string binding_id = 1;

  // Indicates whether this binding reference is optional.
  optional bool is_optional = 2;
}

message ImageBindingRef {
  // The unique ID for this binding. See comments at the top of the file.
  optional string binding_id = 1;

  // Indicates whether this binding reference is optional.
  optional bool is_optional = 2;
}

// GridCellWidthBindings are always optional. If not provided, the default is
// [width.weight = 1].
message GridCellWidthBindingRef {
  // The unique ID for this binding. See comments at the top of the file.
  optional string binding_id = 1;
}

message ElementBindingRef {
  // The unique ID for this binding. See comments at the top of the file.
  optional string binding_id = 1;

  // Indicates whether this binding reference is optional.
  optional bool is_optional = 2;
}

message TemplateBindingRef {
  // The unique ID for this binding. See comments at the top of the file.
  optional string binding_id = 1;

  // Indicates whether this binding reference is optional.
  optional bool is_optional = 2;
}

// Actions binding references are always optional.
message ActionsBindingRef {
  // The unique ID for this binding. See comments at the top of the file.
  optional string binding_id = 1;
}

// Style binding references are always optional.
message StyleBindingRef {
  // The unique ID for this binding. See comments at the top of the file.
  optional string binding_id = 1;
}

// Visibility bindings are always optional.
message VisibilityBindingRef {
  // The unique ID for this binding. See comments at the top of the file.
  optional string binding_id = 1;
}

// LogData binding references are always optional.
message LogDataBindingRef {
  // The unique ID for this binding. See comments at the top of the file.
  optional string binding_id = 1;
}
