chromium/ui/events/mojom/BUILD.gn

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

import("//mojo/public/tools/bindings/mojom.gni")

mojom("mojom") {
  generate_java = true
  sources = [
    "event.mojom",
    "event_constants.mojom",
    "keyboard_codes.mojom",
    "scroll_granularity.mojom",
  ]

  public_deps = [
    "//mojo/public/mojom/base",
    "//ui/gfx/geometry/mojom",
    "//ui/latency/mojom",
  ]

  shared_cpp_typemaps = [
    {
      types = [
        {
          mojom = "ui.mojom.EventPointerType"
          cpp = "::ui::EventPointerType"
        },
        {
          mojom = "ui.mojom.ScrollGranularity"
          cpp = "::ui::ScrollGranularity"
        },
      ]
      traits_headers = [ "//ui/events/ipc/ui_events_param_traits_macros.h" ]
      traits_public_deps = [ "//ui/events/ipc" ]
    },
  ]

  cpp_typemaps = shared_cpp_typemaps
  cpp_typemaps += [
    {
      types = [
        # TODO(crbug.com/41257096): Map directly to ui::Event.
        {
          mojom = "ui.mojom.Event"
          cpp = "::std::unique_ptr<::ui::Event>"
          move_only = true
        },
        {
          mojom = "ui.mojom.EventMomentumPhase"
          cpp = "::ui::EventMomentumPhase"
        },
        {
          mojom = "ui.mojom.PointerDetails"
          cpp = "::ui::PointerDetails"
        },
        {
          mojom = "ui.mojom.ScrollEventPhase"
          cpp = "::ui::ScrollEventPhase"
        },
        {
          mojom = "ui.mojom.GestureDeviceType"
          cpp = "::ui::GestureDeviceType"
        },
      ]

      traits_sources = [ "event_mojom_traits.cc" ]
      traits_headers = [ "//ui/events/event.h" ]
      traits_private_headers = [ "event_mojom_traits.h" ]
      traits_public_deps = [
        "//ui/events",
        "//ui/events:dom_keycode_converter",
        "//ui/gfx/geometry/mojom",
        "//ui/latency/mojom",
      ]
      traits_deps = [ "//ipc:param_traits" ]
    },
  ]

  blink_cpp_typemaps = shared_cpp_typemaps

  # Generate TypeScript WebUI bindings and JavaScript legacy JS bindings (for
  # Blink).
  webui_module_path = "chrome://resources/mojo/ui/events/mojom"
  generate_legacy_js_bindings = true
}

mojom("event_latency_metadata_mojom") {
  generate_java = true
  sources = [ "event_latency_metadata.mojom" ]
  public_deps = [ "//mojo/public/mojom/base" ]

  cpp_typemaps = [
    {
      types = [
        {
          mojom = "ui.mojom.EventLatencyMetadata"
          cpp = "::ui::EventLatencyMetadata"
        },
      ]

      traits_headers = [ "event_latency_metadata_mojom_traits.h" ]
      traits_sources = [ "event_latency_metadata_mojom_traits.cc" ]
      traits_deps = [ "//ui/events:events_base" ]
    },
  ]
}