Skip to content

Commit

Permalink
ui: Use BUILDFLAG for OS checking
Browse files Browse the repository at this point in the history
Use BUILDFLAG(IS_XXX) instead of defined(OS_XXX).

Generated by `os_buildflag_migration.py` (https://crrev.com/c/3311983).

[email protected]

Bug: 1234043
Test: No functionality change
Change-Id: I4f8ec92041831401428228f801af312f7a9fc3fa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3403549
Reviewed-by: Nico Weber <[email protected]>
Commit-Queue: Nico Weber <[email protected]>
Cr-Commit-Position: refs/heads/main@{#961720}
  • Loading branch information
xhwang-chromium authored and Chromium LUCI CQ committed Jan 21, 2022
1 parent bb9ac15 commit 89a8454
Show file tree
Hide file tree
Showing 17 changed files with 48 additions and 47 deletions.
4 changes: 2 additions & 2 deletions ui/display/display.cc
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ Display::Display(int64_t id, const gfx::Rect& bounds)
// using it. Using a not supported profile can result in fatal errors in the
// GPU process.
auto color_space = gfx::ColorSpace::CreateSRGB();
#if !defined(OS_ANDROID)
#if !BUILDFLAG(IS_ANDROID)
if (HasForceDisplayColorProfile())
color_space = GetForcedDisplayColorProfile();
#endif
Expand Down Expand Up @@ -307,7 +307,7 @@ void Display::SetScaleAndBounds(float device_scale_factor,
const gfx::Rect& bounds_in_pixel) {
gfx::Insets insets = bounds_.InsetsFrom(work_area_);
if (!HasForceDeviceScaleFactor()) {
#if defined(OS_APPLE)
#if BUILDFLAG(IS_APPLE)
// Unless an explicit scale factor was provided for testing, ensure the
// scale is integral.
device_scale_factor = static_cast<int>(device_scale_factor);
Expand Down
2 changes: 1 addition & 1 deletion ui/display/display_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void DisplayUtil::DisplayToScreenInfo(ScreenInfo* screen_info,
screen_info->orientation_angle = 90;
#endif

#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
screen_info->orientation_type = GetOrientationTypeForMobile(display);
#else
screen_info->orientation_type = GetOrientationTypeForDesktop(display);
Expand Down
2 changes: 1 addition & 1 deletion ui/display/screen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Screen::~Screen() = default;

// static
Screen* Screen::GetScreen() {
#if defined(OS_APPLE)
#if BUILDFLAG(IS_APPLE)
// TODO(scottmg): https://crbug.com/558054
if (!g_screen)
g_screen = CreateNativeScreen();
Expand Down
6 changes: 3 additions & 3 deletions ui/latency/latency_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
#include "services/metrics/public/cpp/ukm_source_id.h"
#include "third_party/perfetto/protos/perfetto/trace/track_event/chrome_latency_info.pbzero.h"

#if !defined(OS_IOS)
#if !BUILDFLAG(IS_IOS)
#include "ipc/ipc_param_traits.h" // nogncheck
#include "mojo/public/cpp/bindings/struct_traits.h" // nogncheck
#endif

namespace ui {

#if !defined(OS_IOS)
#if !BUILDFLAG(IS_IOS)
namespace mojom {
class LatencyInfoDataView;
}
Expand Down Expand Up @@ -199,7 +199,7 @@ class LatencyInfo {
// gesture_scroll_id_.
int64_t touch_trace_id_ = 0;

#if !defined(OS_IOS)
#if !BUILDFLAG(IS_IOS)
friend struct IPC::ParamTraits<ui::LatencyInfo>;
friend struct mojo::StructTraits<ui::mojom::LatencyInfoDataView,
ui::LatencyInfo>;
Expand Down
8 changes: 4 additions & 4 deletions ui/platform_window/platform_window_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/native_widget_types.h"

#if defined(OS_FUCHSIA)
#if BUILDFLAG(IS_FUCHSIA)
#include "ui/gfx/geometry/insets.h"
#endif // defined(OS_FUCHSIA)
#endif // BUILDFLAG(IS_FUCHSIA)

namespace gfx {
class Rect;
Expand Down Expand Up @@ -52,7 +52,7 @@ class COMPONENT_EXPORT(PLATFORM_WINDOW) PlatformWindowDelegate {
// The dimensions of the window, in physical window coordinates.
gfx::Rect bounds;

#if defined(OS_FUCHSIA)
#if BUILDFLAG(IS_FUCHSIA)
// The widths of border regions which are obscured by overlapping
// platform UI elements like onscreen keyboards.
//
Expand All @@ -67,7 +67,7 @@ class COMPONENT_EXPORT(PLATFORM_WINDOW) PlatformWindowDelegate {
// | onscreen keyboard | | overlap |
// +------------------------+ --- ---
gfx::Insets system_ui_overlap;
#endif // defined(OS_FUCHSIA)
#endif // BUILDFLAG(IS_FUCHSIA)
};

PlatformWindowDelegate();
Expand Down
10 changes: 5 additions & 5 deletions ui/platform_window/platform_window_init_properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/native_widget_types.h"

#if defined(OS_FUCHSIA)
#if BUILDFLAG(IS_FUCHSIA)
#include <fuchsia/ui/composition/cpp/fidl.h>
#include <fuchsia/ui/views/cpp/fidl.h>
#include <lib/ui/scenic/cpp/view_ref_pair.h>
Expand Down Expand Up @@ -49,11 +49,11 @@ enum class PlatformWindowShadowType {

class WorkspaceExtensionDelegate;

#if defined(OS_FUCHSIA)
#if BUILDFLAG(IS_FUCHSIA)
class ScenicWindowDelegate;
#endif

#if defined(OS_LINUX) || defined(OS_CHROMEOS)
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
class X11ExtensionDelegate;
#endif

Expand Down Expand Up @@ -82,7 +82,7 @@ struct COMPONENT_EXPORT(PLATFORM_WINDOW) PlatformWindowInitProperties {
// Widget::InitProperties::WindowOpacity.
PlatformWindowOpacity opacity = PlatformWindowOpacity::kOpaqueWindow;

#if defined(OS_FUCHSIA)
#if BUILDFLAG(IS_FUCHSIA)
// Scenic 3D API uses `view_token` for links, whereas Flatland
// API uses `view_creation_token`. Therefore, at most one of these fields must
// be set. If `allow_null_view_token_for_test` is true, they may both be
Expand Down Expand Up @@ -112,7 +112,7 @@ struct COMPONENT_EXPORT(PLATFORM_WINDOW) PlatformWindowInitProperties {

PlatformWindowShadowType shadow_type = PlatformWindowShadowType::kDefault;

#if defined(OS_LINUX) || defined(OS_CHROMEOS)
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
bool prefer_dark_theme = false;
gfx::ImageSkia* icon = nullptr;
absl::optional<int> background_color;
Expand Down
4 changes: 2 additions & 2 deletions ui/shell_dialogs/run_all_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_paths.h"

#if defined(OS_APPLE)
#if BUILDFLAG(IS_APPLE)
#include "base/test/mock_chrome_application_mac.h"
#endif

Expand All @@ -36,7 +36,7 @@ ShellDialogsTestSuite::ShellDialogsTestSuite(int argc, char** argv)
void ShellDialogsTestSuite::Initialize() {
base::TestSuite::Initialize();

#if defined(OS_APPLE)
#if BUILDFLAG(IS_APPLE)
mock_cr_app::RegisterMockCrApp();
#endif

Expand Down
2 changes: 1 addition & 1 deletion ui/snapshot/snapshot_aura.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void GrabWindowSnapshotAsyncAura(aura::Window* window,
std::move(callback)));
}

#if !defined(OS_WIN)
#if !BUILDFLAG(IS_WIN)
bool GrabWindowSnapshot(gfx::NativeWindow window,
const gfx::Rect& snapshot_bounds,
gfx::Image* image) {
Expand Down
23 changes: 12 additions & 11 deletions ui/snapshot/snapshot_aura_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -196,24 +196,25 @@ class SnapshotAuraTest : public testing::TestWithParam<bool> {

INSTANTIATE_TEST_SUITE_P(All, SnapshotAuraTest, ::testing::Bool());

#if defined(OS_WIN) && !defined(NDEBUG)
#if BUILDFLAG(IS_WIN) && !defined(NDEBUG)
// https://crbug.com/852512
#define MAYBE_FullScreenWindow DISABLED_FullScreenWindow
#elif defined(OS_LINUX)
#elif BUILDFLAG(IS_LINUX)
// https://crbug.com/1143031
#define MAYBE_FullScreenWindow DISABLED_FullScreenWindow
#else
#define MAYBE_FullScreenWindow FullScreenWindow
#endif
TEST_P(SnapshotAuraTest, MAYBE_FullScreenWindow) {
#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_FUCHSIA)
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_FUCHSIA)
// TODO(https://crbug.com/1143031): Fix this test to run in < action_timeout()
// on the Linux Debug & TSAN bots.
const base::test::ScopedRunLoopTimeout increased_run_timeout(
FROM_HERE, TestTimeouts::action_max_timeout());
#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_FUCHSIA)
#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) ||
// BUILDFLAG(IS_FUCHSIA)

#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// TODO(https://crbug.com/850556): Make work on Win10.
base::win::Version version = base::win::GetVersion();
if (version >= base::win::Version::WIN10)
Expand All @@ -229,7 +230,7 @@ TEST_P(SnapshotAuraTest, MAYBE_FullScreenWindow) {
}

TEST_P(SnapshotAuraTest, PartialBounds) {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// TODO(https://crbug.com/850556): Make work on Win10.
base::win::Version version = base::win::GetVersion();
if (version >= base::win::Version::WIN10)
Expand All @@ -245,7 +246,7 @@ TEST_P(SnapshotAuraTest, PartialBounds) {
}

TEST_P(SnapshotAuraTest, Rotated) {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// TODO(https://crbug.com/850556): Make work on Win10.
base::win::Version version = base::win::GetVersion();
if (version >= base::win::Version::WIN10)
Expand All @@ -263,7 +264,7 @@ TEST_P(SnapshotAuraTest, Rotated) {
}

TEST_P(SnapshotAuraTest, UIScale) {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// TODO(https://crbug.com/850556): Make work on Win10.
base::win::Version version = base::win::GetVersion();
if (version >= base::win::Version::WIN10)
Expand All @@ -287,7 +288,7 @@ TEST_P(SnapshotAuraTest, UIScale) {
}

TEST_P(SnapshotAuraTest, DeviceScaleFactor) {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// TODO(https://crbug.com/850556): Make work on Win10.
base::win::Version version = base::win::GetVersion();
if (version >= base::win::Version::WIN10)
Expand All @@ -310,7 +311,7 @@ TEST_P(SnapshotAuraTest, DeviceScaleFactor) {
}

TEST_P(SnapshotAuraTest, RotateAndUIScale) {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// TODO(https://crbug.com/850556): Make work on Win10.
base::win::Version version = base::win::GetVersion();
if (version >= base::win::Version::WIN10)
Expand All @@ -335,7 +336,7 @@ TEST_P(SnapshotAuraTest, RotateAndUIScale) {
}

TEST_P(SnapshotAuraTest, RotateAndUIScaleAndScaleFactor) {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// TODO(https://crbug.com/850556): Make work on Win10.
base::win::Version version = base::win::GetVersion();
if (version >= base::win::Version::WIN10)
Expand Down
2 changes: 1 addition & 1 deletion ui/surface/transport_dib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ std::unique_ptr<SkCanvas> TransportDIB::GetPlatformCanvas(int w,
if (!base::CheckMul(h, base::CheckMul(w, bpp)).AssignIfValid(&canvas_size))
return nullptr;

#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// This DIB already mapped the file into this process, but PlatformCanvas
// will map it again.
DCHECK(!memory()) << "Mapped file twice in the same process.";
Expand Down
4 changes: 2 additions & 2 deletions ui/views_content_client/views_content_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace ui {

#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
ViewsContentClient::ViewsContentClient(
HINSTANCE instance, sandbox::SandboxInterfaceInfo* sandbox_info)
: instance_(instance), sandbox_info_(sandbox_info) {
Expand All @@ -30,7 +30,7 @@ int ViewsContentClient::RunMain() {
ViewsContentMainDelegate delegate(this);
content::ContentMainParams params(&delegate);

#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
params.instance = instance_;
params.sandbox_info = sandbox_info_;
#else
Expand Down
6 changes: 3 additions & 3 deletions ui/views_content_client/views_content_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace ui {
// // Create desired windows and views here. Runs on the UI thread.
// }
//
// #if defined(OS_WIN)
// #if BUILDFLAG(IS_WIN)
// int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t*, int) {
// sandbox::SandboxInterfaceInfo sandbox_info = {nullptr};
// content::InitializeSandboxInfo(&sandbox_info);
Expand All @@ -52,7 +52,7 @@ class VIEWS_CONTENT_CLIENT_EXPORT ViewsContentClient {
base::OnceCallback<void(content::BrowserContext* browser_context,
gfx::NativeWindow window_context)>;

#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
ViewsContentClient(HINSTANCE instance,
sandbox::SandboxInterfaceInfo* sandbox_info);
#else
Expand Down Expand Up @@ -95,7 +95,7 @@ class VIEWS_CONTENT_CLIENT_EXPORT ViewsContentClient {
base::OnceClosure& quit_closure() { return quit_closure_; }

private:
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
HINSTANCE instance_;
raw_ptr<sandbox::SandboxInterfaceInfo> sandbox_info_;
#else
Expand Down
2 changes: 1 addition & 1 deletion ui/views_content_client/views_content_client_main_parts.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ViewsContentClientMainParts::ViewsContentClientMainParts(
ViewsContentClientMainParts::~ViewsContentClientMainParts() {
}

#if !defined(OS_APPLE)
#if !BUILDFLAG(IS_APPLE)
void ViewsContentClientMainParts::PreBrowserMain() {}
#endif

Expand Down
2 changes: 1 addition & 1 deletion ui/views_content_client/views_content_client_main_parts.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class ViewsContentClientMainParts : public content::BrowserMainParts {
ViewsContentClientMainParts(content::MainFunctionParams content_params,
ViewsContentClient* views_content_client);

#if defined(OS_APPLE)
#if BUILDFLAG(IS_APPLE)
views::TestViewsDelegate* views_delegate() { return views_delegate_.get(); }
#endif

Expand Down
6 changes: 3 additions & 3 deletions ui/views_content_client/views_content_main_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
#include "ui/views_content_client/views_content_client.h"
#include "ui/views_content_client/views_content_client_main_parts.h"

#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include "base/logging_win.h"
#endif

namespace ui {
namespace {

#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// {83FAC8EE-7A0E-4dbb-A3F6-6F500D7CAB1A}
const GUID kViewsContentClientProviderName =
{ 0x83fac8ee, 0x7a0e, 0x4dbb,
Expand Down Expand Up @@ -54,7 +54,7 @@ bool ViewsContentMainDelegate::BasicStartupComplete(int* exit_code) {
logging::LOG_TO_SYSTEM_DEBUG_LOG | logging::LOG_TO_STDERR;
bool success = logging::InitLogging(settings);
CHECK(success);
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
logging::LogEventProvider::Initialize(kViewsContentClientProviderName);
#endif

Expand Down
2 changes: 1 addition & 1 deletion ui/wm/core/compound_event_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace {
// Returns true if the cursor should be hidden on touch events.
// TODO(tdanderson|rsadam): Move this function into CursorClient.
bool ShouldHideCursorOnTouch(const ui::TouchEvent& event) {
#if defined(OS_WIN) || BUILDFLAG(IS_CHROMEOS_ASH)
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_CHROMEOS_ASH)
return true;
#else
// Linux Aura does not hide the cursor on touch by default.
Expand Down
10 changes: 5 additions & 5 deletions ui/wm/core/compound_event_filter_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@

namespace {

#if BUILDFLAG(IS_CHROMEOS_ASH) || defined(OS_WIN)
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_WIN)
base::TimeTicks GetTime() {
return ui::EventTimeForNow();
}
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || defined(OS_WIN)
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_WIN)
}

namespace wm {
Expand Down Expand Up @@ -112,7 +112,7 @@ TEST_F(CompoundEventFilterTest, CursorVisibilityChange) {
}
#endif // BUILDFLAG(IS_CHROMEOS_ASH)

#if BUILDFLAG(IS_CHROMEOS_ASH) || defined(OS_WIN)
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_WIN)
// Touch visually hides the cursor on ChromeOS and Windows.
TEST_F(CompoundEventFilterTest, TouchHidesCursor) {
std::unique_ptr<CompoundEventFilter> compound_filter(new CompoundEventFilter);
Expand Down Expand Up @@ -167,7 +167,7 @@ TEST_F(CompoundEventFilterTest, TouchHidesCursor) {
EXPECT_FALSE(cursor_client.IsCursorVisible());
aura::Env::GetInstance()->RemovePreTargetHandler(compound_filter.get());
}
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || defined(OS_WIN)
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_WIN)

// Tests that if an event filter consumes a gesture, then it doesn't focus the
// window.
Expand Down Expand Up @@ -224,7 +224,7 @@ TEST_F(CompoundEventFilterTest, DontHideWhenMouseDown) {
aura::Env::GetInstance()->RemovePreTargetHandler(compound_filter.get());
}

#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// Windows synthesizes mouse messages for touch events. We should not be
// showing the cursor when we receive such messages.
TEST_F(CompoundEventFilterTest, DontShowCursorOnMouseMovesFromTouch) {
Expand Down

0 comments on commit 89a8454

Please sign in to comment.