Commit 40451659 authored by Michael Spang's avatar Michael Spang Committed by Commit Bot

ui: ozone: Remove casts from PlatformEvent to ui::Event*

These are no longer necessary since PlatformEvent is now a typedef to
ui::Event*.

BUG=none
TEST=compile

Change-Id: I49749511c7db8d0f2f96add58201ad6d288445f3
Reviewed-on: https://chromium-review.googlesource.com/978468
Commit-Queue: Michael Spang <spang@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#545807}
parent 9f8faccf
......@@ -110,8 +110,7 @@ class TestEventFactoryEvdev : public EventFactoryEvdev {
~TestEventFactoryEvdev() override {}
private:
uint32_t DispatchEvent(PlatformEvent platform_event) override {
Event* event = static_cast<Event*>(platform_event);
uint32_t DispatchEvent(PlatformEvent event) override {
callback_.Run(event);
return POST_DISPATCH_NONE;
}
......
......@@ -9,28 +9,31 @@
namespace ui {
void DispatchEventFromNativeUiEvent(
const PlatformEvent& native_event,
const PlatformEvent& event,
base::OnceCallback<void(ui::Event*)> callback) {
ui::Event* native_ui_event = static_cast<ui::Event*>(native_event);
if (native_ui_event->IsKeyEvent()) {
ui::KeyEvent key_event(native_event);
// NB: ui::Events are constructed here using the overload that takes a
// const PlatformEvent& (here ui::Event* const&) rather than the copy
// constructor. This has side effects and cannot be changed to use the
// copy constructor or Event::Clone.
if (event->IsKeyEvent()) {
ui::KeyEvent key_event(event);
std::move(callback).Run(&key_event);
} else if (native_ui_event->IsMouseWheelEvent()) {
ui::MouseWheelEvent wheel_event(native_event);
} else if (event->IsMouseWheelEvent()) {
ui::MouseWheelEvent wheel_event(event);
std::move(callback).Run(&wheel_event);
} else if (native_ui_event->IsMouseEvent()) {
ui::MouseEvent mouse_event(native_event);
} else if (event->IsMouseEvent()) {
ui::MouseEvent mouse_event(event);
std::move(callback).Run(&mouse_event);
} else if (native_ui_event->IsTouchEvent()) {
ui::TouchEvent touch_event(native_event);
} else if (event->IsTouchEvent()) {
ui::TouchEvent touch_event(event);
std::move(callback).Run(&touch_event);
} else if (native_ui_event->IsScrollEvent()) {
ui::ScrollEvent scroll_event(native_event);
} else if (event->IsScrollEvent()) {
ui::ScrollEvent scroll_event(event);
std::move(callback).Run(&scroll_event);
} else if (native_ui_event->IsGestureEvent()) {
std::move(callback).Run(native_ui_event);
} else if (event->IsGestureEvent()) {
std::move(callback).Run(event);
// TODO(mohsen): Use the same pattern for scroll/touch/wheel events.
// Apparently, there is no need for them to wrap the |native_event|.
// Apparently, there is no need for them to wrap the |event|.
} else {
NOTREACHED();
}
......
......@@ -129,9 +129,8 @@ PlatformImeController* DrmWindowHost::GetPlatformImeController() {
return nullptr;
}
bool DrmWindowHost::CanDispatchEvent(const PlatformEvent& ne) {
DCHECK(ne);
Event* event = static_cast<Event*>(ne);
bool DrmWindowHost::CanDispatchEvent(const PlatformEvent& event) {
DCHECK(event);
// If there is a grab, capture events here.
gfx::AcceleratedWidget grabber = window_manager_->event_grabber();
......@@ -170,10 +169,9 @@ bool DrmWindowHost::CanDispatchEvent(const PlatformEvent& ne) {
return true;
}
uint32_t DrmWindowHost::DispatchEvent(const PlatformEvent& native_event) {
DCHECK(native_event);
uint32_t DrmWindowHost::DispatchEvent(const PlatformEvent& event) {
DCHECK(event);
Event* event = static_cast<Event*>(native_event);
if (event->IsLocatedEvent()) {
// Make the event location relative to this window's origin.
LocatedEvent* located_event = event->AsLocatedEvent();
......@@ -183,8 +181,8 @@ uint32_t DrmWindowHost::DispatchEvent(const PlatformEvent& native_event) {
located_event->set_root_location_f(location);
}
DispatchEventFromNativeUiEvent(
native_event, base::BindOnce(&PlatformWindowDelegate::DispatchEvent,
base::Unretained(delegate_)));
event, base::BindOnce(&PlatformWindowDelegate::DispatchEvent,
base::Unretained(delegate_)));
return POST_DISPATCH_STOP_PROPAGATION;
}
......
......@@ -234,8 +234,7 @@ PlatformImeController* WaylandWindow::GetPlatformImeController() {
return nullptr;
}
bool WaylandWindow::CanDispatchEvent(const PlatformEvent& native_event) {
Event* event = static_cast<Event*>(native_event);
bool WaylandWindow::CanDispatchEvent(const PlatformEvent& event) {
if (event->IsMouseEvent())
return has_pointer_focus_;
if (event->IsKeyEvent())
......
......@@ -69,12 +69,11 @@ bool X11WindowOzone::DispatchXEvent(XEvent* xev) {
return true;
}
bool X11WindowOzone::CanDispatchEvent(const PlatformEvent& platform_event) {
bool X11WindowOzone::CanDispatchEvent(const PlatformEvent& event) {
return handle_next_event_;
}
uint32_t X11WindowOzone::DispatchEvent(const PlatformEvent& platform_event) {
auto* event = static_cast<Event*>(platform_event);
uint32_t X11WindowOzone::DispatchEvent(const PlatformEvent& event) {
if (!window_manager_->event_grabber() ||
window_manager_->event_grabber() == this) {
// This is unfortunately needed otherwise events that depend on global state
......
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