chromium/third_party/blink/public/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("//build/buildflag_header.gni")
import("//build/config/devtools.gni")
import("//mojo/public/tools/bindings/mojom.gni")
import("//third_party/blink/public/public_features.gni")
import("//third_party/blink/renderer/build/scripts/scripts.gni")
import("//third_party/blink/renderer/config.gni")
import("//third_party/blink/renderer/core/core.gni")
import("//third_party/webrtc/webrtc.gni")
import("//tools/grit/grit_rule.gni")
import("//tools/grit/repack.gni")

if (is_android) {
  import("//build/config/android/config.gni")
  import("//build/config/android/rules.gni")
}

blink_public_output_dir = "$root_gen_dir/third_party/blink/public"

group("blink") {
  public_deps = [ ":blink_headers" ]
  deps = [
    "//third_party/blink/renderer/controller",
    "//third_party/blink/renderer/core",
    "//third_party/blink/renderer/modules",
    "//third_party/blink/renderer/platform",
  ]
  if (use_blink_extensions_chromeos) {
    deps += [ "//third_party/blink/renderer/extensions/chromeos" ]
  }
  if (use_blink_extensions_webview) {
    deps += [ "//third_party/blink/renderer/extensions/webview" ]
  }
}

group("test_support") {
  testonly = true
  public_deps = [
    ":test_headers",
    "//third_party/blink/common:test_support",
    "//third_party/blink/renderer/core/exported:test_support",
    "//third_party/blink/renderer/modules/exported:test_support",
    "//third_party/blink/renderer/modules/mediastream:test_support",
    "//third_party/blink/renderer/modules/peerconnection:test_support",
    "//third_party/blink/renderer/platform:test_support",
  ]
}

group("all_blink") {
  # This includes some test targets. Don't link into production!
  testonly = true

  public_deps = [
    "//third_party/blink/common",
    "//third_party/blink/common:blink_common_unittests",
    "//third_party/blink/renderer/controller",
    "//third_party/blink/renderer/controller:blink_unittests",
    "//third_party/blink/renderer/core",
    "//third_party/blink/renderer/modules",
    "//third_party/blink/renderer/platform:blink_platform_unittests",
    "//third_party/blink/renderer/platform/heap:blink_heap_unittests",
    "//third_party/blink/renderer/platform/wtf:wtf_unittests",
  ]
}

config("blink_headers_config") {
  # Allow :blink_headers to include v8.h without linking to it.
  configs = [ "//v8:external_config" ]
}

# Public feature flags used outside of Blink.
buildflag_header("buildflags") {
  header = "public_buildflags.h"
  flags = [
    "USE_MINIKIN_HYPHENATION=$use_minikin_hyphenation",
    "ENABLE_UNHANDLED_TAP=$enable_unhandled_tap",
  ]
}

if (is_android) {
  java_cpp_enum("blink_headers_java_enums_srcjar") {
    sources = [
      "./common/input/web_input_event.h",
      "./mojom/context_menu/context_menu.mojom",
      "./mojom/input/input_handler.mojom",
      "./platform/web_text_input_mode.h",
      "./platform/web_text_input_type.h",
    ]
  }

  android_library("blink_headers_java") {
    deps = [
      "//services/network/public/mojom:mojom_java",
      "//third_party/androidx:androidx_annotation_annotation_java",
    ]
    srcjar_deps = [ ":blink_headers_java_enums_srcjar" ]
  }
}

source_set("test_headers") {
  testonly = true
  sources = [
    "common/interest_group/test/interest_group_test_utils.h",
    "common/interest_group/test_interest_group_builder.h",
    "common/origin_trials/scoped_test_origin_trial_policy.h",
    "platform/scheduler/test/renderer_scheduler_test_support.h",
    "platform/scheduler/test/web_fake_thread_scheduler.h",
    "platform/scheduler/test/web_mock_thread_scheduler.h",
    "test/frame_widget_test_helper.h",
    "test/test_web_frame_content_dumper.h",
    "test/test_web_frame_helper.h",
  ]
  public_deps = [ ":blink_headers" ]
  deps = [
    "//base:base",
    "//cc:cc",
    "//testing/gmock:gmock",
  ]
}

# Depend on this target to use public blink API headers for things like enums
# and public structures without actually linking against any Blink libraries.
#
# See public/common/BUILD.gn for the headers that can be referenced both from
# the browser- and renderer-side components.
source_set("blink_headers") {
  sources = [
    "platform/audio/web_audio_device_source_type.h",
    "platform/browser_interface_broker_proxy.h",
    "platform/child_url_loader_factory_bundle.h",
    "platform/cross_variant_mojo_util.h",
    "platform/file_path_conversion.h",
    "platform/interface_registry.h",
    "platform/media/web_media_player_delegate.h",
    "platform/modules/mediastream/media_stream_types.h",
    "platform/modules/mediastream/secure_display_link_tracker.h",
    "platform/modules/mediastream/web_media_stream.h",
    "platform/modules/mediastream/web_media_stream_audio_sink.h",
    "platform/modules/mediastream/web_media_stream_sink.h",
    "platform/modules/mediastream/web_media_stream_source.h",
    "platform/modules/mediastream/web_media_stream_track.h",
    "platform/modules/mediastream/web_platform_media_stream_source.h",
    "platform/modules/remoteplayback/remote_playback_source.h",
    "platform/modules/remoteplayback/web_remote_playback_client.h",
    "platform/modules/service_worker/web_service_worker_error.h",
    "platform/modules/service_worker/web_service_worker_fetch_context.h",
    "platform/modules/service_worker/web_service_worker_network_provider.h",
    "platform/modules/service_worker/web_service_worker_object_info.h",
    "platform/modules/service_worker/web_service_worker_provider.h",
    "platform/modules/service_worker/web_service_worker_provider_client.h",
    "platform/modules/service_worker/web_service_worker_provider_context.h",
    "platform/modules/service_worker/web_service_worker_registration_object_info.h",
    "platform/modules/video_capture/web_video_capture_impl_manager.h",
    "platform/modules/webrtc/webrtc_logging.h",
    "platform/platform.h",
    "platform/resource_load_info_notifier_wrapper.h",
    "platform/scheduler/web_agent_group_scheduler.h",
    "platform/scheduler/web_renderer_process_type.h",
    "platform/scheduler/web_scoped_virtual_time_pauser.h",
    "platform/scheduler/web_thread_scheduler.h",
    "platform/task_type.h",
    "platform/tracked_child_url_loader_factory_bundle.h",
    "platform/url_conversion.h",
    "platform/url_loader_throttle_provider.h",
    "platform/user_metrics_action.h",
    "platform/weak_wrapper_resource_load_info_notifier.h",
    "platform/web_audio_bus.h",
    "platform/web_audio_device.h",
    "platform/web_audio_latency_hint.h",
    "platform/web_audio_sink_descriptor.h",
    "platform/web_audio_source_provider.h",
    "platform/web_audio_source_provider_impl.h",
    "platform/web_background_resource_fetch_assets.h",
    "platform/web_blob_info.h",
    "platform/web_cache.h",
    "platform/web_callbacks.h",
    "platform/web_common.h",
    "platform/web_computed_ax_tree.h",
    "platform/web_connection_type.h",
    "platform/web_content_decryption_module.h",
    "platform/web_content_decryption_module_access.h",
    "platform/web_content_decryption_module_exception.h",
    "platform/web_content_decryption_module_result.h",
    "platform/web_content_decryption_module_session.h",
    "platform/web_content_security_policy_struct.h",
    "platform/web_content_settings_client.h",
    "platform/web_crypto.h",
    "platform/web_crypto_algorithm.h",
    "platform/web_crypto_algorithm_params.h",
    "platform/web_crypto_key.h",
    "platform/web_crypto_key_algorithm.h",
    "platform/web_crypto_key_algorithm_params.h",
    "platform/web_data.h",
    "platform/web_dedicated_or_shared_worker_fetch_context.h",
    "platform/web_dedicated_worker.h",
    "platform/web_dedicated_worker_host_factory_client.h",
    "platform/web_distillability.h",
    "platform/web_document_subresource_filter.h",
    "platform/web_drag_data.h",
    "platform/web_effective_connection_type.h",
    "platform/web_encoding_data.h",
    "platform/web_encrypted_media_client.h",
    "platform/web_encrypted_media_key_information.h",
    "platform/web_encrypted_media_request.h",
    "platform/web_encrypted_media_types.h",
    "platform/web_fetch_client_settings_object.h",
    "platform/web_file_system_type.h",
    "platform/web_font.h",
    "platform/web_font_description.h",
    "platform/web_font_render_style.h",
    "platform/web_gesture_curve.h",
    "platform/web_graphics_context_3d_provider.h",
    "platform/web_graphics_shared_image_interface_provider.h",
    "platform/web_http_body.h",
    "platform/web_http_header_visitor.h",
    "platform/web_icon_sizes_parser.h",
    "platform/web_image_generator.h",
    "platform/web_input_event_result.h",
    "platform/web_isolated_world_info.h",
    "platform/web_loader_freeze_mode.h",
    "platform/web_media_key_system_configuration.h",
    "platform/web_media_key_system_media_capability.h",
    "platform/web_media_player.h",
    "platform/web_media_player_client.h",
    "platform/web_media_player_encrypted_media_client.h",
    "platform/web_media_player_source.h",
    "platform/web_media_source.h",
    "platform/web_memory_pressure_listener.h",
    "platform/web_navigation_body_loader.h",
    "platform/web_network_state_notifier.h",
    "platform/web_policy_container.h",
    "platform/web_prescient_networking.h",
    "platform/web_private_ptr.h",
    "platform/web_runtime_features.h",
    "platform/web_scoped_page_pauser.h",
    "platform/web_scroll_anchor_data.h",
    "platform/web_security_origin.h",
    "platform/web_set_sink_id_callbacks.h",
    "platform/web_source_buffer.h",
    "platform/web_source_buffer_client.h",
    "platform/web_spell_check_panel_host_client.h",
    "platform/web_string.h",
    "platform/web_surface_layer_bridge.h",
    "platform/web_text_input_info.h",
    "platform/web_text_input_mode.h",
    "platform/web_text_input_type.h",
    "platform/web_text_run.h",
    "platform/web_theme_engine.h",
    "platform/web_thread_safe_data.h",
    "platform/web_time_range.h",
    "platform/web_touch_action.h",
    "platform/web_url.h",
    "platform/web_url_error.h",
    "platform/web_url_request.h",
    "platform/web_url_request_extra_data.h",
    "platform/web_url_request_util.h",
    "platform/web_url_response.h",
    "platform/web_v8_value_converter.h",
    "platform/web_vector.h",
    "platform/web_video_frame_submitter.h",
    "platform/web_worker_fetch_context.h",
    "platform/websocket_handshake_throttle.h",
    "platform/websocket_handshake_throttle_provider.h",
    "web/blink.h",
    "web/modules/autofill/web_form_element_observer.h",
    "web/modules/canvas/canvas_test_utils.h",
    "web/modules/credentialmanagement/throttle_helper.h",
    "web/modules/media/audio/audio_device_factory.h",
    "web/modules/media/audio/audio_input_ipc_factory.h",
    "web/modules/media/audio/audio_output_ipc_factory.h",
    "web/modules/media/web_media_player_util.h",
    "web/modules/mediastream/encoded_video_frame.h",
    "web/modules/mediastream/media_stream_video_sink.h",
    "web/modules/mediastream/media_stream_video_source.h",
    "web/modules/mediastream/web_media_player_ms.h",
    "web/modules/mediastream/web_media_stream_device_observer.h",
    "web/modules/mediastream/web_media_stream_utils.h",
    "web/modules/service_worker/web_navigation_preload_request.h",
    "web/modules/service_worker/web_service_worker_context_client.h",
    "web/modules/service_worker/web_service_worker_context_proxy.h",
    "web/web_array_buffer.h",
    "web/web_array_buffer_converter.h",
    "web/web_associated_url_loader.h",
    "web/web_associated_url_loader_client.h",
    "web/web_associated_url_loader_options.h",
    "web/web_autofill_client.h",
    "web/web_autofill_state.h",
    "web/web_ax_context.h",
    "web/web_ax_enums.h",
    "web/web_ax_object.h",
    "web/web_blob.h",
    "web/web_console_message.h",
    "web/web_content_capture_client.h",
    "web/web_content_holder.h",
    "web/web_crypto_histograms.h",
    "web/web_crypto_normalize.h",
    "web/web_css_origin.h",
    "web/web_custom_element.h",
    "web/web_disallow_transition_scope.h",
    "web/web_document.h",
    "web/web_document_loader.h",
    "web/web_dom_activity_logger.h",
    "web/web_dom_event.h",
    "web/web_dom_file_system.h",
    "web/web_dom_media_stream_track.h",
    "web/web_dom_message_event.h",
    "web/web_drag_status.h",
    "web/web_draggable_region.h",
    "web/web_element.h",
    "web/web_element_collection.h",
    "web/web_embedded_worker.h",
    "web/web_embedded_worker_start_data.h",
    "web/web_form_control_element.h",
    "web/web_form_element.h",
    "web/web_form_related_change_type.h",
    "web/web_frame.h",
    "web/web_frame_content_dumper.h",
    "web/web_frame_load_type.h",
    "web/web_frame_owner_properties.h",
    "web/web_frame_serializer.h",
    "web/web_frame_serializer_client.h",
    "web/web_frame_widget.h",
    "web/web_heap.h",
    "web/web_history_commit_type.h",
    "web/web_history_item.h",
    "web/web_hit_test_result.h",
    "web/web_image.h",
    "web/web_image_cache.h",
    "web/web_input_element.h",
    "web/web_input_method_controller.h",
    "web/web_label_element.h",
    "web/web_language_detection_details.h",
    "web/web_lifecycle_update.h",
    "web/web_link_preview_triggerer.h",
    "web/web_local_frame.h",
    "web/web_local_frame_client.h",
    "web/web_local_frame_observer.h",
    "web/web_manifest_manager.h",
    "web/web_meaningful_layout.h",
    "web/web_media_inspector.h",
    "web/web_message_port_converter.h",
    "web/web_meta_element.h",
    "web/web_navigation_control.h",
    "web/web_navigation_params.h",
    "web/web_navigation_policy.h",
    "web/web_navigation_type.h",
    "web/web_no_state_prefetch_client.h",
    "web/web_node.h",
    "web/web_non_composited_widget_client.h",
    "web/web_option_element.h",
    "web/web_page_popup.h",
    "web/web_pepper_socket.h",
    "web/web_pepper_socket_client.h",
    "web/web_performance_metrics_for_nested_contexts.h",
    "web/web_performance_metrics_for_reporting.h",
    "web/web_picture_in_picture_window_options.h",
    "web/web_plugin.h",
    "web/web_plugin_container.h",
    "web/web_plugin_document.h",
    "web/web_plugin_params.h",
    "web/web_plugin_script_forbidden_scope.h",
    "web/web_popup_menu_info.h",
    "web/web_print_client.h",
    "web/web_print_page_description.h",
    "web/web_print_params.h",
    "web/web_print_preset_options.h",
    "web/web_range.h",
    "web/web_remote_frame.h",
    "web/web_render_theme.h",
    "web/web_savable_resources_test_support.h",
    "web/web_scoped_window_focus_allowed_indicator.h",
    "web/web_script_controller.h",
    "web/web_script_execution_callback.h",
    "web/web_script_source.h",
    "web/web_searchable_form_data.h",
    "web/web_security_policy.h",
    "web/web_select_element.h",
    "web/web_select_list_element.h",
    "web/web_selector.h",
    "web/web_serialized_script_value.h",
    "web/web_serialized_script_value_version.h",
    "web/web_settings.h",
    "web/web_shared_storage_worklet_thread.h",
    "web/web_shared_worker.h",
    "web/web_shared_worker_client.h",
    "web/web_testing_support.h",
    "web/web_text_check_client.h",
    "web/web_text_checking_completion.h",
    "web/web_text_checking_result.h",
    "web/web_text_decoration_type.h",
    "web/web_user_level_memory_pressure_signal_generator.h",
    "web/web_v8_context_snapshot.h",
    "web/web_v8_features.h",
    "web/web_view.h",
    "web/web_view_client.h",
    "web/web_view_observer.h",
    "web/web_widget.h",
    "web/web_window_features.h",
  ]

  if (is_mac) {
    sources += [
      "platform/mac/web_sandbox_support.h",
      "platform/mac/web_scrollbar_theme.h",
    ]
  }

  if (is_linux || is_chromeos) {
    sources += [ "platform/linux/web_sandbox_support.h" ]
  }

  if (is_win) {
    sources += [
      "platform/web_font_prewarmer.h",
      "platform/web_font_rendering_client.h",
      "web/win/web_font_family_names.h",
      "web/win/web_font_rendering.h",
    ]
  }

  public_configs = [
    ":blink_headers_config",

    # Blink exposes icu headers in the public API.
    "//third_party/icu:icu_config",
  ]

  public_deps = [
    ":devtools_inspector_resources_grit",
    ":resources_grit",
    ":runtime_features_for_public",
    "//net",
    "//services/network/public/mojom:mojom_shared",
    "//services/service_manager/public/cpp",
    "//skia",
    "//third_party/blink/public/common",
    "//third_party/blink/public/common:headers",
    "//third_party/blink/renderer/platform:make_platform_generated",
    "//ui/accessibility:ax_base",
    "//ui/base/dragdrop/mojom:mojom_shared",
    "//ui/base/ime",
    "//ui/base/ime/mojom",
    "//ui/base/prediction:prediction",
    "//url",
  ]

  if (is_mac) {
    public_deps += [ "//ui/gfx" ]
  }

  deps = [
    "//base:base",
    "//cc:cc",
    "//cc/paint:paint",
    "//components/viz/common",
    "//media/capture:capture_base",
    "//media/capture:capture_lib",
    "//media/webrtc:webrtc",
    "//mojo/public/cpp/bindings:bindings",
    "//mojo/public/cpp/system:system",
    "//printing/mojom",
    "//services/device/public/mojom:mojom_shared_cpp_sources",
    "//services/network/public/cpp:cpp",
    "//services/network/public/mojom",
    "//third_party/blink/renderer/platform/wtf:wtf",
    "//third_party/webrtc_overrides:webrtc_component",
    "//ui/base:base",
    "//v8:v8_headers",
  ]
}

blink_python_runner("runtime_features_for_public") {
  script = "../renderer/build/scripts/make_runtime_features_for_public.py"

  runtime_enabled_features_json5 =
      "../renderer/platform/runtime_enabled_features.json5"
  inputs =
      scripts_for_json5_files + [
        runtime_enabled_features_json5,
        "../renderer/build/scripts/templates/features_generated.h.tmpl",
        "../renderer/build/scripts/templates/web_runtime_features_base.h.tmpl",
      ]

  outputs = [
    "$blink_public_output_dir/common/features_generated.h",
    "$blink_public_output_dir/platform/web_runtime_features_base.h",
  ]

  args = [
    rebase_path(runtime_enabled_features_json5, root_build_dir),
    "--output_dir",
    rebase_path(blink_public_output_dir, root_build_dir),
  ]
}

devtools_frontend_path = "//$devtools_root_location"

group("blink_devtools_frontend_resources") {
  public_deps = [ "$devtools_frontend_path:devtools_frontend_resources" ]
}

group("blink_devtools_inspector_resources") {
  public_deps = [ ":devtools_inspector_resources_grit" ]
}

group("blink_devtools_frontend_resources_files") {
  testonly = true
  data_deps = [ "$devtools_frontend_path:devtools_all_files" ]
}

group("blink_generate_devtools_grd") {
  public_deps = [ "$devtools_frontend_path:generate_devtools_grd" ]
}

resources_out_dir = "$blink_public_output_dir/resources"

grit("resources") {
  output_dir = resources_out_dir
  source = "blink_resources.grd"
  outputs = [
    "grit/blink_resources.h",
    "blink_resources.pak",
  ]
  use_brotli = true
}

grit("devtools_inspector_resources") {
  # Required because the .grd is generated.
  enable_input_discovery_for_gn_analyze = false

  source = "$root_out_dir/resources/inspector_overlay/inspector_overlay_resources.grd"
  output_dir = resources_out_dir
  outputs = [
    "grit/inspector_overlay_resources_map.h",
    "inspector_overlay_resources.pak",
  ]

  _shared_intermediate_dir = rebase_path(root_out_dir, root_build_dir)
  _devtools_grd_path = "$shared_intermediate_dir/$devtools_grd_location"
  _devtools_grd_path_no_ext = get_path_info(_devtools_grd_path, "dir") + "/" +
                              get_path_info(_devtools_grd_path, "name")

  defines = [
    "SHARED_INTERMEDIATE_DIR=" + _shared_intermediate_dir,
    "DEVTOOLS_GRD_PATH=" + _devtools_grd_path_no_ext,
  ]

  deps = [
    "$devtools_frontend_path:generate_devtools_inspector_overlay_resources",
  ]
}

grit("image_resources") {
  output_dir = resources_out_dir
  source = "blink_image_resources.grd"
  outputs = [
    "grit/blink_image_resources.h",
    "blink_image_resources_100_percent.pak",
    "blink_image_resources_200_percent.pak",
  ]
}

group("scaled_resources") {
  public_deps = [
    ":image_resources",
    "//third_party/blink/renderer/modules/media_controls:media_controls_resources",
  ]
}

repack("scaled_resources_100_percent") {
  output = "$root_gen_dir/third_party/blink/public/resources/blink_scaled_resources_100_percent.pak"
  sources = [
    "$root_gen_dir/third_party/blink/public/resources/blink_image_resources_100_percent.pak",
    "$root_gen_dir/third_party/blink/renderer/modules/media_controls/resources/media_controls_resources_100_percent.pak",
  ]
  deps = [ ":scaled_resources" ]
}

repack("scaled_resources_200_percent") {
  output = "$root_gen_dir/third_party/blink/public/resources/blink_scaled_resources_200_percent.pak"
  sources = [
    "$root_gen_dir/third_party/blink/public/resources/blink_image_resources_200_percent.pak",
    "$root_gen_dir/third_party/blink/renderer/modules/media_controls/resources/media_controls_resources_200_percent.pak",
  ]
  deps = [ ":scaled_resources" ]
}