// third_party/blink/public/mojom/widget/device_emulation_params.mojom-blink.cc is auto generated by mojom_bindings_generator.py, do not edit

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

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

#include "third_party/blink/public/mojom/widget/device_emulation_params.mojom-blink.h"

#include <math.h>
#include <stdint.h>
#include <utility>

#include "base/hash/md5_constexpr.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/task/common/task_annotator.h"
#include "base/trace_event/trace_conversion_helper.h"
#include "base/trace_event/traced_value.h"
#include "mojo/public/cpp/bindings/lib/generated_code_util.h"
#include "mojo/public/cpp/bindings/lib/message_internal.h"
#include "mojo/public/cpp/bindings/lib/serialization_util.h"
#include "mojo/public/cpp/bindings/lib/unserialized_message_context.h"
#include "mojo/public/cpp/bindings/lib/validate_params.h"
#include "mojo/public/cpp/bindings/lib/validation_context.h"
#include "mojo/public/cpp/bindings/lib/validation_errors.h"
#include "mojo/public/interfaces/bindings/interface_control_messages.mojom.h"

#include "third_party/blink/public/mojom/widget/device_emulation_params.mojom-params-data.h"
#include "third_party/blink/public/mojom/widget/device_emulation_params.mojom-shared-message-ids.h"

#include "third_party/blink/public/mojom/widget/device_emulation_params.mojom-blink-import-headers.h"
#include "mojo/public/cpp/bindings/lib/wtf_serialization.h"


#ifndef THIRD_PARTY_BLINK_PUBLIC_MOJOM_WIDGET_DEVICE_EMULATION_PARAMS_MOJOM_BLINK_JUMBO_H_
#define THIRD_PARTY_BLINK_PUBLIC_MOJOM_WIDGET_DEVICE_EMULATION_PARAMS_MOJOM_BLINK_JUMBO_H_
#endif
namespace blink {
namespace mojom {
namespace blink {
DeviceEmulationParams::DeviceEmulationParams()
    : screen_type(),
      screen_size(),
      view_position(),
      view_size(),
      device_scale_factor(),
      scale(),
      viewport_offset(),
      viewport_scale(),
      screen_orientation_type(),
      screen_orientation_angle(),
      window_segments() {}

DeviceEmulationParams::DeviceEmulationParams(
    EmulatedScreenType screen_type_in,
    const ::gfx::Size& screen_size_in,
    const base::Optional<::gfx::Point>& view_position_in,
    const ::gfx::Size& view_size_in,
    float device_scale_factor_in,
    float scale_in,
    const ::gfx::PointF& viewport_offset_in,
    float viewport_scale_in,
    ::blink::mojom::blink::ScreenOrientation screen_orientation_type_in,
    uint32_t screen_orientation_angle_in,
    WTF::Vector<::gfx::Rect> window_segments_in)
    : screen_type(std::move(screen_type_in)),
      screen_size(std::move(screen_size_in)),
      view_position(std::move(view_position_in)),
      view_size(std::move(view_size_in)),
      device_scale_factor(std::move(device_scale_factor_in)),
      scale(std::move(scale_in)),
      viewport_offset(std::move(viewport_offset_in)),
      viewport_scale(std::move(viewport_scale_in)),
      screen_orientation_type(std::move(screen_orientation_type_in)),
      screen_orientation_angle(std::move(screen_orientation_angle_in)),
      window_segments(std::move(window_segments_in)) {}

DeviceEmulationParams::~DeviceEmulationParams() = default;

void DeviceEmulationParams::AsValueInto(base::trace_event::TracedValue* value) const {
  value->SetString("screen_type", base::trace_event::ValueToString(this->screen_type));
  value->SetString("screen_size", base::trace_event::ValueToString(this->screen_size, "<value of type const ::gfx::Size&>"));
  value->SetString("view_position", base::trace_event::ValueToString(this->view_position, "<value of type const base::Optional<::gfx::Point>&>"));
  value->SetString("view_size", base::trace_event::ValueToString(this->view_size, "<value of type const ::gfx::Size&>"));
  value->SetDouble("device_scale_factor", this->device_scale_factor);
  value->SetDouble("scale", this->scale);
  value->SetString("viewport_offset", base::trace_event::ValueToString(this->viewport_offset, "<value of type const ::gfx::PointF&>"));
  value->SetDouble("viewport_scale", this->viewport_scale);
  value->SetString("screen_orientation_type", base::trace_event::ValueToString(this->screen_orientation_type));
  value->SetString("screen_orientation_angle", base::NumberToString(this->screen_orientation_angle));
  value->BeginArray("window_segments");
  for (const auto& item0 : this->window_segments) {
    value->AppendString(base::trace_event::ValueToString(item0, "<value of type const ::gfx::Rect&>"));
  }
  value->EndArray();
}

bool DeviceEmulationParams::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  return Data_::Validate(data, validation_context);
}
}  // namespace blink
}  // namespace mojom
}  // namespace blink

namespace mojo {


// static
bool StructTraits<::blink::mojom::blink::DeviceEmulationParams::DataView, ::blink::mojom::blink::DeviceEmulationParamsPtr>::Read(
    ::blink::mojom::blink::DeviceEmulationParams::DataView input,
    ::blink::mojom::blink::DeviceEmulationParamsPtr* output) {
  bool success = true;
  ::blink::mojom::blink::DeviceEmulationParamsPtr result(::blink::mojom::blink::DeviceEmulationParams::New());
  
      if (success && !input.ReadScreenType(&result->screen_type))
        success = false;
      if (success && !input.ReadScreenSize(&result->screen_size))
        success = false;
      if (success && !input.ReadViewPosition(&result->view_position))
        success = false;
      if (success && !input.ReadViewSize(&result->view_size))
        success = false;
      if (success)
        result->device_scale_factor = input.device_scale_factor();
      if (success)
        result->scale = input.scale();
      if (success && !input.ReadViewportOffset(&result->viewport_offset))
        success = false;
      if (success)
        result->viewport_scale = input.viewport_scale();
      if (success && !input.ReadScreenOrientationType(&result->screen_orientation_type))
        success = false;
      if (success)
        result->screen_orientation_angle = input.screen_orientation_angle();
      if (success && !input.ReadWindowSegments(&result->window_segments))
        success = false;
  *output = std::move(result);
  return success;
}

}  // namespace mojo

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