From 827ec31990fa00c3d1e4d5b076c8f5a0a9425114 Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Thu, 18 Jan 2024 07:25:57 +0000 Subject: [PATCH] Remove the dependency on WTL from `renderer_style_handler.cc` This commit updates renderer_style_handler.cc with WIL so as not to depend on WTL (#861). This is a mechanical code change. There must be no observable behavior change. #codehealth PiperOrigin-RevId: 599404848 --- src/renderer/BUILD.bazel | 9 ++++++--- src/renderer/renderer_style_handler.cc | 12 ++++-------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/renderer/BUILD.bazel b/src/renderer/BUILD.bazel index 141e343e1..5469eaaac 100644 --- a/src/renderer/BUILD.bazel +++ b/src/renderer/BUILD.bazel @@ -40,7 +40,7 @@ load( "BRANDING", "MACOS_BUNDLE_ID_PREFIX", ) -load("//bazel/win32:build_defs.bzl", "copts_wtl", "features_gdi") +load("//bazel/win32:build_defs.bzl", "features_gdi") package(default_visibility = ["//:__subpackages__"]) @@ -214,13 +214,16 @@ mozc_cc_library( name = "renderer_style_handler", srcs = ["renderer_style_handler.cc"], hdrs = ["renderer_style_handler.h"], - copts = copts_wtl(), # for Windows features = features_gdi(), # for Windows deps = [ "//base:singleton", "//protocol:renderer_cc_proto", ] + mozc_select( - windows = ["//third_party/wtl"], + windows = [ + "//bazel/win32:gdi32", + "//bazel/win32:user32", + "@com_microsoft_wil//:wil", + ], ), ) diff --git a/src/renderer/renderer_style_handler.cc b/src/renderer/renderer_style_handler.cc index b29c52016..28a9b67bf 100644 --- a/src/renderer/renderer_style_handler.cc +++ b/src/renderer/renderer_style_handler.cc @@ -29,14 +29,10 @@ #include "renderer/renderer_style_handler.h" -// clang-format off #if defined(_WIN32) #include -#include -#include -#include +#include #endif // _WIN32 -// clang-format on #include "base/singleton.h" #include "protocol/renderer_style.pb.h" @@ -205,9 +201,9 @@ void RendererStyleHandler::GetDefaultRendererStyle(RendererStyle *style) { void RendererStyleHandler::GetDPIScalingFactor(double *x, double *y) { #ifdef _WIN32 - WTL::CDC desktop_dc(::GetDC(nullptr)); - const int dpi_x = desktop_dc.GetDeviceCaps(LOGPIXELSX); - const int dpi_y = desktop_dc.GetDeviceCaps(LOGPIXELSY); + wil::unique_hdc_window desktop_dc(::GetDC(nullptr)); + const int dpi_x = ::GetDeviceCaps(desktop_dc.get(), LOGPIXELSX); + const int dpi_y = ::GetDeviceCaps(desktop_dc.get(), LOGPIXELSY); if (x != nullptr) { *x = static_cast(dpi_x) / kDefaultDPI; }