Commit 71db5985 authored by Hans Wennborg's avatar Hans Wennborg Committed by Commit Bot

Make ui::SourceEventType an enum class, fixing new -Wshadow warning

New Clang versions started taking enumerators into account for the
-Wshadow warning:

../../ui/compositor/layer_animation_element.h:41:5: warning: declaration
shadows a variable in namespace 'ui' [-Wshadow]
    UNKNOWN = 0,
    ^
../../ui/latency/latency_info.h:97:3: note: previous declaration is here
  UNKNOWN,
  ^

By making ui::SourceEventType an enum class, we avoid putting the enumerators
in such a large namespace as ui.

TBR=jochen

Bug: 895475
Change-Id: I99347d754cb21dacb5d7c4bae975d3310dcb19fd
Reviewed-on: https://chromium-review.googlesource.com/c/1284951
Commit-Queue: Hans Wennborg <hans@chromium.org>
Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#600177}
parent 07086b32
......@@ -70,7 +70,7 @@ void RenderWidgetHostLatencyTracker::ComputeInputLatencyHistograms(
std::string event_name = WebInputEvent::GetName(type);
if (latency.source_event_type() == ui::KEY_PRESS)
if (latency.source_event_type() == ui::SourceEventType::KEY_PRESS)
event_name = "KeyPress";
std::string default_action_status =
......@@ -112,7 +112,7 @@ void RenderWidgetHostLatencyTracker::OnInputEvent(
active_multi_finger_gesture_ = touch_event.touches_length != 1;
}
if (latency->source_event_type() == ui::KEY_PRESS) {
if (latency->source_event_type() == ui::SourceEventType::KEY_PRESS) {
DCHECK(event.GetType() == WebInputEvent::kChar ||
event.GetType() == WebInputEvent::kRawKeyDown);
}
......
......@@ -11,7 +11,6 @@
IPC_ENUM_TRAITS_MAX_VALUE(ui::LatencyComponentType,
ui::LATENCY_COMPONENT_TYPE_LAST)
IPC_ENUM_TRAITS_MAX_VALUE(ui::SourceEventType,
ui::SourceEventType::SOURCE_EVENT_TYPE_LAST)
IPC_ENUM_TRAITS_MAX_VALUE(ui::SourceEventType, ui::SourceEventType::LAST)
#endif // UI_LATENCY_IPC_LATENCY_INFO_PARAM_TRAITS_MACROS_H_
......@@ -93,7 +93,7 @@ enum LatencyComponentType {
LATENCY_COMPONENT_TYPE_LAST = INPUT_EVENT_LATENCY_FRAME_SWAP_COMPONENT,
};
enum SourceEventType {
enum class SourceEventType {
UNKNOWN,
WHEEL,
MOUSE,
......@@ -104,7 +104,7 @@ enum SourceEventType {
TOUCHPAD,
FRAME,
OTHER,
SOURCE_EVENT_TYPE_LAST = OTHER,
LAST = OTHER,
};
class LatencyInfo {
......
......@@ -12,23 +12,23 @@ namespace {
ui::mojom::SourceEventType UISourceEventTypeToMojo(ui::SourceEventType type) {
switch (type) {
case ui::UNKNOWN:
case ui::SourceEventType::UNKNOWN:
return ui::mojom::SourceEventType::UNKNOWN;
case ui::WHEEL:
case ui::SourceEventType::WHEEL:
return ui::mojom::SourceEventType::WHEEL;
case ui::MOUSE:
case ui::SourceEventType::MOUSE:
return ui::mojom::SourceEventType::MOUSE;
case ui::TOUCH:
case ui::SourceEventType::TOUCH:
return ui::mojom::SourceEventType::TOUCH;
case ui::INERTIAL:
case ui::SourceEventType::INERTIAL:
return ui::mojom::SourceEventType::INERTIAL;
case ui::KEY_PRESS:
case ui::SourceEventType::KEY_PRESS:
return ui::mojom::SourceEventType::KEY_PRESS;
case ui::TOUCHPAD:
case ui::SourceEventType::TOUCHPAD:
return ui::mojom::SourceEventType::TOUCHPAD;
case ui::FRAME:
case ui::SourceEventType::FRAME:
return ui::mojom::SourceEventType::FRAME;
case ui::OTHER:
case ui::SourceEventType::OTHER:
return ui::mojom::SourceEventType::OTHER;
}
NOTREACHED();
......@@ -38,23 +38,23 @@ ui::mojom::SourceEventType UISourceEventTypeToMojo(ui::SourceEventType type) {
ui::SourceEventType MojoSourceEventTypeToUI(ui::mojom::SourceEventType type) {
switch (type) {
case ui::mojom::SourceEventType::UNKNOWN:
return ui::UNKNOWN;
return ui::SourceEventType::UNKNOWN;
case ui::mojom::SourceEventType::WHEEL:
return ui::WHEEL;
return ui::SourceEventType::WHEEL;
case ui::mojom::SourceEventType::MOUSE:
return ui::MOUSE;
return ui::SourceEventType::MOUSE;
case ui::mojom::SourceEventType::TOUCH:
return ui::TOUCH;
return ui::SourceEventType::TOUCH;
case ui::mojom::SourceEventType::INERTIAL:
return ui::INERTIAL;
return ui::SourceEventType::INERTIAL;
case ui::mojom::SourceEventType::KEY_PRESS:
return ui::KEY_PRESS;
return ui::SourceEventType::KEY_PRESS;
case ui::mojom::SourceEventType::TOUCHPAD:
return ui::TOUCHPAD;
return ui::SourceEventType::TOUCHPAD;
case ui::mojom::SourceEventType::FRAME:
return ui::FRAME;
return ui::SourceEventType::FRAME;
case ui::mojom::SourceEventType::OTHER:
return ui::OTHER;
return ui::SourceEventType::OTHER;
}
NOTREACHED();
return ui::SourceEventType::UNKNOWN;
......
......@@ -15,7 +15,7 @@ static_assert(static_cast<int>(ui::mojom::LatencyComponentType::kMaxValue) ==
"Enum size mismatch");
static_assert(static_cast<int>(ui::mojom::SourceEventType::kMaxValue) ==
static_cast<int>(ui::SOURCE_EVENT_TYPE_LAST),
static_cast<int>(ui::SourceEventType::LAST),
"Enum size mismatch");
template <>
......
......@@ -52,7 +52,7 @@ TEST_F(StructTraitsTest, LatencyInfo) {
EXPECT_EQ(10, latency.ukm_source_id());
EXPECT_TRUE(latency.terminated());
latency.set_source_event_type(ui::TOUCH);
latency.set_source_event_type(ui::SourceEventType::TOUCH);
mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
LatencyInfo output;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment