// services/viz/public/mojom/compositing/tracked_element_rects.mojom-blink.cc is auto generated by mojom_bindings_generator.py, do not edit

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

#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-private-field"
#endif

#include "services/viz/public/mojom/compositing/tracked_element_rects.mojom-blink.h"
#include <stdint.h>
#include <utility>
#include "mojo/public/cpp/bindings/lib/default_construct_tag_internal.h"
#include "mojo/public/cpp/bindings/lib/serialization.h"
#include "mojo/public/cpp/bindings/lib/validate_params.h"
#include "mojo/public/cpp/bindings/lib/validation_errors.h"
#include "mojo/public/cpp/bindings/mojo_buildflags.h"
#include "third_party/perfetto/include/perfetto/tracing/traced_value.h"

#include "services/viz/public/mojom/compositing/tracked_element_rects.mojom-params-data.h"
#include "services/viz/public/mojom/compositing/tracked_element_rects.mojom-shared-message-ids.h"

#include "services/viz/public/mojom/compositing/tracked_element_rects.mojom-blink-import-headers.h"
#include "services/viz/public/mojom/compositing/tracked_element_rects.mojom-blink-test-utils.h"
#include "mojo/public/cpp/bindings/lib/wtf_serialization.h"


namespace viz::mojom::blink {
TrackedElementRect::TrackedElementRect()
    : tracked_element_id(),
      visible_bounds(),
      should_add_to_compositor_frame_metadata(),
      should_exclude_fixed_and_sticky_occlusions(),
      frame_token(),
      parent_frame_token() {}

TrackedElementRect::TrackedElementRect(
    const ::base::Token& tracked_element_id_in,
    const ::gfx::Rect& visible_bounds_in,
    bool should_add_to_compositor_frame_metadata_in,
    bool should_exclude_fixed_and_sticky_occlusions_in,
    const std::optional<::blink::FrameToken>& frame_token_in,
    const std::optional<::blink::LocalFrameToken>& parent_frame_token_in)
    : tracked_element_id(std::move(tracked_element_id_in)),
      visible_bounds(std::move(visible_bounds_in)),
      should_add_to_compositor_frame_metadata(std::move(should_add_to_compositor_frame_metadata_in)),
      should_exclude_fixed_and_sticky_occlusions(std::move(should_exclude_fixed_and_sticky_occlusions_in)),
      frame_token(std::move(frame_token_in)),
      parent_frame_token(std::move(parent_frame_token_in)) {}

TrackedElementRect::~TrackedElementRect() = default;

void TrackedElementRect::WriteIntoTrace(
    perfetto::TracedValue traced_context) const {
  [[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "tracked_element_id"), this->tracked_element_id,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::base::Token&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "visible_bounds"), this->visible_bounds,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::gfx::Rect&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "should_add_to_compositor_frame_metadata"), this->should_add_to_compositor_frame_metadata,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type bool>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "should_exclude_fixed_and_sticky_occlusions"), this->should_exclude_fixed_and_sticky_occlusions,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type bool>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "frame_token"), this->frame_token,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const std::optional<::blink::FrameToken>&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "parent_frame_token"), this->parent_frame_token,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const std::optional<::blink::LocalFrameToken>&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
}

bool TrackedElementRect::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  return Data_::Validate(data, validation_context);
}
TrackedElementRects::TrackedElementRects()
    : element_data() {}

TrackedElementRects::TrackedElementRects(
    ::blink::HashMap<int32_t, ::blink::Vector<TrackedElementRectPtr>> element_data_in)
    : element_data(std::move(element_data_in)) {}

TrackedElementRects::~TrackedElementRects() = default;

void TrackedElementRects::WriteIntoTrace(
    perfetto::TracedValue traced_context) const {
  [[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "element_data"), this->element_data,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type ::blink::HashMap<int32_t, ::blink::Vector<TrackedElementRectPtr>>>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
}

bool TrackedElementRects::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  return Data_::Validate(data, validation_context);
}


}  // viz::mojom::blink


namespace mojo {


// static
bool StructTraits<::viz::mojom::blink::TrackedElementRect::DataView, ::viz::mojom::blink::TrackedElementRectPtr>::Read(
    ::viz::mojom::blink::TrackedElementRect::DataView input,
    ::viz::mojom::blink::TrackedElementRectPtr* output) {
  bool success = true;
  ::viz::mojom::blink::TrackedElementRectPtr result(::viz::mojom::blink::TrackedElementRect::New());
  
      if (success && !input.ReadTrackedElementId(&result->tracked_element_id))
        success = false;
      if (success && !input.ReadVisibleBounds(&result->visible_bounds))
        success = false;
      if (success)
        result->should_add_to_compositor_frame_metadata = input.should_add_to_compositor_frame_metadata();
      if (success)
        result->should_exclude_fixed_and_sticky_occlusions = input.should_exclude_fixed_and_sticky_occlusions();
      if (success && !input.ReadFrameToken(&result->frame_token))
        success = false;
      if (success && !input.ReadParentFrameToken(&result->parent_frame_token))
        success = false;
  *output = std::move(result);
  return success;
}


// static
bool StructTraits<::viz::mojom::blink::TrackedElementRects::DataView, ::viz::mojom::blink::TrackedElementRectsPtr>::Read(
    ::viz::mojom::blink::TrackedElementRects::DataView input,
    ::viz::mojom::blink::TrackedElementRectsPtr* output) {
  bool success = true;
  ::viz::mojom::blink::TrackedElementRectsPtr result(::viz::mojom::blink::TrackedElementRects::New());
  
      if (success && !input.ReadElementData(&result->element_data))
        success = false;
  *output = std::move(result);
  return success;
}

}  // namespace mojo


// Symbols declared in the -test-utils.h header are defined here instead of a
// separate .cc file to save compile time.


namespace viz::mojom::blink {




}  // viz::mojom::blink


#if defined(__clang__)
#pragma clang diagnostic pop
#endif