summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authordavemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-17 17:10:26 +0000
committerdavemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-17 17:10:26 +0000
commitec7b271972848c075878d14fe07f29197ebec6d6 (patch)
tree1bcb43f652089f561c4ee4aa009b8f08a0324acc /content
parent1b62b89312329852d43103c6ab718bd60cfacdcf (diff)
downloadchromium_src-ec7b271972848c075878d14fe07f29197ebec6d6.zip
chromium_src-ec7b271972848c075878d14fe07f29197ebec6d6.tar.gz
chromium_src-ec7b271972848c075878d14fe07f29197ebec6d6.tar.bz2
Use times from the initiation of events to determine whether two
successive clicks should be considered a double click. Also implements triple click for web content in aura. BUG=None TEST=aura_unittests::EventTest.* Review URL: https://chromiumcodereview.appspot.com/9133013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117907 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/renderer_host/web_input_event_aurax11.cc56
1 files changed, 6 insertions, 50 deletions
diff --git a/content/browser/renderer_host/web_input_event_aurax11.cc b/content/browser/renderer_host/web_input_event_aurax11.cc
index 9a97e41..ab870f7 100644
--- a/content/browser/renderer_host/web_input_event_aurax11.cc
+++ b/content/browser/renderer_host/web_input_event_aurax11.cc
@@ -57,11 +57,6 @@ namespace {
// This matches Firefox behavior.
const int kPixelsPerTick = 53;
-double XEventTimeToWebEventTime(Time time) {
- // Convert from time in ms to time in s.
- return time / 1000.0;
-}
-
int EventFlagsToWebEventModifiers(int flags) {
int modifiers = 0;
if (flags & ui::EF_SHIFT_DOWN)
@@ -154,30 +149,6 @@ WebKit::WebUChar GetControlCharacter(int windows_key_code, bool shift) {
return 0;
}
-// We have to count clicks (for double-clicks) manually.
-unsigned int g_num_clicks = 0;
-double g_last_click_time = 0.0;
-int g_last_click_x = 0;
-int g_last_click_y = 0;
-WebKit::WebMouseEvent::Button g_last_click_button =
- WebKit::WebMouseEvent::ButtonNone;
-
-bool ShouldForgetPreviousClick(double time, int x, int y) {
- const double double_click_time = 0.250; // in seconds
- const int double_click_distance = 5;
- return (time - g_last_click_time) > double_click_time ||
- std::abs(x - g_last_click_x) > double_click_distance ||
- std::abs(y - g_last_click_y) > double_click_distance;
-}
-
-void ResetClickCountState() {
- g_num_clicks = 0;
- g_last_click_time = 0.0;
- g_last_click_x = 0;
- g_last_click_y = 0;
- g_last_click_button = WebKit::WebMouseEvent::ButtonNone;
-}
-
WebKit::WebTouchPoint::State TouchPointStateFromEvent(
const aura::TouchEvent* event) {
switch (event->type()) {
@@ -216,7 +187,7 @@ WebKit::WebMouseEvent MakeWebMouseEventFromAuraEvent(aura::MouseEvent* event) {
WebKit::WebMouseEvent webkit_event;
webkit_event.modifiers = EventFlagsToWebEventModifiers(event->flags());
- webkit_event.timeStampSeconds = event->time_stamp().ToDoubleT();
+ webkit_event.timeStampSeconds = event->time_stamp().InSecondsF();
webkit_event.button = WebKit::WebMouseEvent::ButtonNone;
if (event->flags() & ui::EF_LEFT_MOUSE_BUTTON)
@@ -229,18 +200,7 @@ WebKit::WebMouseEvent MakeWebMouseEventFromAuraEvent(aura::MouseEvent* event) {
switch (event->type()) {
case ui::ET_MOUSE_PRESSED:
webkit_event.type = WebKit::WebInputEvent::MouseDown;
- if (!ShouldForgetPreviousClick(event->time_stamp().ToDoubleT(),
- event->location().x(), event->location().y()) &&
- webkit_event.button == g_last_click_button) {
- ++g_num_clicks;
- } else {
- g_num_clicks = 1;
- g_last_click_time = event->time_stamp().ToDoubleT();
- g_last_click_x = event->location().x();
- g_last_click_y = event->location().y();
- g_last_click_button = webkit_event.button;
- }
- webkit_event.clickCount = g_num_clicks;
+ webkit_event.clickCount = event->GetClickCount();
break;
case ui::ET_MOUSE_RELEASED:
webkit_event.type = WebKit::WebInputEvent::MouseUp;
@@ -250,9 +210,6 @@ WebKit::WebMouseEvent MakeWebMouseEventFromAuraEvent(aura::MouseEvent* event) {
case ui::ET_MOUSE_MOVED:
case ui::ET_MOUSE_DRAGGED:
webkit_event.type = WebKit::WebInputEvent::MouseMove;
- if (ShouldForgetPreviousClick(event->time_stamp().ToDoubleT(),
- event->location().x(), event->location().y()))
- ResetClickCountState();
break;
default:
NOTIMPLEMENTED() << "Received unexpected event: " << event->type();
@@ -269,7 +226,7 @@ WebKit::WebMouseWheelEvent MakeWebMouseWheelEventFromAuraEvent(
webkit_event.type = WebKit::WebInputEvent::MouseWheel;
webkit_event.button = WebKit::WebMouseEvent::ButtonNone;
webkit_event.modifiers = EventFlagsToWebEventModifiers(event->flags());
- webkit_event.timeStampSeconds = event->time_stamp().ToDoubleT();
+ webkit_event.timeStampSeconds = event->time_stamp().InSecondsF();
webkit_event.deltaY = ui::GetMouseWheelOffset(event->native_event());
webkit_event.wheelTicksY = webkit_event.deltaY / kPixelsPerTick;
@@ -283,7 +240,7 @@ WebKit::WebMouseWheelEvent MakeWebMouseWheelEventFromAuraEvent(
webkit_event.type = WebKit::WebInputEvent::MouseWheel;
webkit_event.button = WebKit::WebMouseEvent::ButtonNone;
webkit_event.modifiers = EventFlagsToWebEventModifiers(event->flags());
- webkit_event.timeStampSeconds = event->time_stamp().ToDoubleT();
+ webkit_event.timeStampSeconds = event->time_stamp().InSecondsF();
webkit_event.hasPreciseScrollingDeltas = true;
webkit_event.deltaX = event->x_offset();
webkit_event.wheelTicksX = webkit_event.deltaX / kPixelsPerTick;
@@ -299,8 +256,7 @@ WebKit::WebKeyboardEvent MakeWebKeyboardEventFromAuraEvent(
WebKit::WebKeyboardEvent webkit_event;
XKeyEvent* native_key_event = &native_event->xkey;
- webkit_event.timeStampSeconds =
- XEventTimeToWebEventTime(native_key_event->time);
+ webkit_event.timeStampSeconds = event->time_stamp().InSecondsF();
webkit_event.modifiers = XStateToWebEventModifiers(native_key_event->state);
switch (native_event->type) {
@@ -406,7 +362,7 @@ WebKit::WebTouchPoint* UpdateWebTouchEventFromAuraEvent(
// Update the type of the touch event.
web_event->type = TouchEventTypeFromEvent(event);
- web_event->timeStampSeconds = event->time_stamp().ToDoubleT();
+ web_event->timeStampSeconds = event->time_stamp().InSecondsF();
return point;
}