summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authormazda@chromium.org <mazda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-31 05:11:08 +0000
committermazda@chromium.org <mazda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-31 05:11:08 +0000
commit99175d766e9677fb37e476ddc852081e0a9aaeb9 (patch)
treeed0a290033680e14d42259f5d6a084598ad7b509 /ui
parentc816214d936219205b0e8678406ed0c26cba5640 (diff)
downloadchromium_src-99175d766e9677fb37e476ddc852081e0a9aaeb9.zip
chromium_src-99175d766e9677fb37e476ddc852081e0a9aaeb9.tar.gz
chromium_src-99175d766e9677fb37e476ddc852081e0a9aaeb9.tar.bz2
Avoid copying mouse events where possible in RootWindow.
This CL adds ConvertLocationToTarget to LocatedEvent and uses it to avoid unnecessary copies. Copying a mouse event nullifies its native events. That's a problematic for EventRewriter because it cannot know if Search key is pressed while mouse click without NativeEvent (Information on whether Search key is pressed is lost). EventRewriter needs to know whether Search key is pressed for remapping Search key to other modifier keys based on user's modifier key remapping settings. EventRewriter also remaps Alt+Left mouse button to Right mouse button, so the fix is needed to handle it properly. BUG=145242, 145385 Review URL: https://chromiumcodereview.appspot.com/10890041 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@154383 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/aura/root_window.cc24
-rw-r--r--ui/base/event.h8
2 files changed, 14 insertions, 18 deletions
diff --git a/ui/aura/root_window.cc b/ui/aura/root_window.cc
index eb7b07d..41b97422 100644
--- a/ui/aura/root_window.cc
+++ b/ui/aura/root_window.cc
@@ -300,9 +300,8 @@ bool RootWindow::DispatchGestureEvent(ui::GestureEvent* event) {
}
if (target) {
- ui::GestureEvent translated_event(
- *event, static_cast<Window*>(this), target);
- ui::GestureStatus status = ProcessGestureEvent(target, &translated_event);
+ event->ConvertLocationToTarget(static_cast<Window*>(this), target);
+ ui::GestureStatus status = ProcessGestureEvent(target, event);
return status != ui::GESTURE_STATUS_UNKNOWN;
}
@@ -932,9 +931,9 @@ bool RootWindow::OnHostScrollEvent(ui::ScrollEvent* event) {
Window::ConvertPointToTarget(this, target, &location_in_window);
if (IsNonClientLocation(target, location_in_window))
flags |= ui::EF_IS_NON_CLIENT;
- ui::ScrollEvent translated_event(
- *event, static_cast<Window*>(this), target, event->type(), flags);
- return ProcessMouseEvent(target, &translated_event);
+ event->set_flags(flags);
+ event->ConvertLocationToTarget(static_cast<Window*>(this), target);
+ return ProcessMouseEvent(target, event);
}
return false;
}
@@ -1097,16 +1096,9 @@ bool RootWindow::DispatchMouseEventToTarget(ui::MouseEvent* event,
Window::ConvertPointToTarget(this, target, &location_in_window);
if (IsNonClientLocation(target, location_in_window))
flags |= ui::EF_IS_NON_CLIENT;
- if (event->type() == ui::ET_MOUSEWHEEL) {
- ui::MouseWheelEvent translated_event(
- *static_cast<ui::MouseWheelEvent*>(event),
- static_cast<Window*>(this), target, event->type(), flags);
- return ProcessMouseEvent(target, &translated_event);
- } else {
- ui::MouseEvent translated_event(
- *event, static_cast<Window*>(this), target, event->type(), flags);
- return ProcessMouseEvent(target, &translated_event);
- }
+ event->set_flags(flags);
+ event->ConvertLocationToTarget(static_cast<Window*>(this), target);
+ return ProcessMouseEvent(target, event);
}
return false;
}
diff --git a/ui/base/event.h b/ui/base/event.h
index bc388e3..5905aa2 100644
--- a/ui/base/event.h
+++ b/ui/base/event.h
@@ -147,6 +147,11 @@ class UI_EXPORT LocatedEvent : public Event {
// This is applied to both |location_| and |root_location_|.
virtual void UpdateForRootTransform(const Transform& root_transform);
+ template <class T> void ConvertLocationToTarget(T* source, T* target) {
+ if (target && target != source)
+ T::ConvertPointToTarget(source, target, &location_);
+ }
+
protected:
explicit LocatedEvent(const base::NativeEvent& native_event);
@@ -162,8 +167,7 @@ class UI_EXPORT LocatedEvent : public Event {
system_location_(model.system_location_) {
// TODO(erg): May need to create system_location_ by converting location to
// system coordinates here.
- if (target && target != source)
- T::ConvertPointToTarget(source, target, &location_);
+ ConvertLocationToTarget(source, target);
}
// Used for synthetic events in testing.