summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--content/browser/renderer_host/render_widget_host_view_win.cc27
-rw-r--r--content/browser/renderer_host/web_input_event_aurax11.cc10
-rw-r--r--ui/aura/gestures/gesture_recognizer_unittest.cc31
-rw-r--r--ui/aura/test/aura_test_base.cc1
-rw-r--r--ui/base/gestures/gesture_configuration.h1
-rw-r--r--ui/base/gestures/gesture_sequence.cc24
-rw-r--r--ui/base/gestures/gesture_types.cc11
-rw-r--r--ui/base/gestures/gesture_types.h22
8 files changed, 62 insertions, 65 deletions
diff --git a/content/browser/renderer_host/render_widget_host_view_win.cc b/content/browser/renderer_host/render_widget_host_view_win.cc
index d6dcddd..9149c23 100644
--- a/content/browser/renderer_host/render_widget_host_view_win.cc
+++ b/content/browser/renderer_host/render_widget_host_view_win.cc
@@ -400,15 +400,13 @@ class LocalGestureEvent :
public:
LocalGestureEvent(
HWND hwnd,
- ui::EventType type,
+ const ui::GestureEventDetails& details,
const gfx::Point& location,
int flags,
base::Time time,
- float param_first,
- float param_second,
unsigned int touch_id_bitfield)
: touch_ids_bitfield_(touch_id_bitfield),
- type_(type) {
+ type_(details.type()) {
// location is given in window coordinates, based on the parent window.
// Map to the appropriate window's coordinates. For a root window the
// coordinates won't change, because the parent shares our rect.
@@ -420,9 +418,19 @@ class LocalGestureEvent :
data().y = client_point.y;
data().globalX = screen_point.x;
data().globalY = screen_point.y;
- data().deltaX = param_first;
- data().deltaY = param_second;
- data().type = ConvertToWebInputEvent(type);
+ data().deltaX = details.generic_x();
+ data().deltaY = details.generic_y();
+ data().type = ConvertToWebInputEvent(type_);
+
+ // WebKit gesture events do not have bounding-boxes yet, and expect the data
+ // in deltaX/deltaY instead (and instead of bounding box, WebKit expects the
+ // radius). This is currently used only for tap events. So special case this
+ // particular case.
+ // http://crbug.com/138572
+ if (type_ == ui::ET_GESTURE_TAP) {
+ data().deltaX = details.bounding_box().width() / 2;
+ data().deltaY = details.bounding_box().height() / 2;
+ }
}
virtual int GetLowestTouchId() const OVERRIDE {
@@ -1287,9 +1295,8 @@ ui::GestureEvent* RenderWidgetHostViewWin::CreateGestureEvent(
int flags,
base::Time time,
unsigned int touch_id_bitfield) {
-
- return new LocalGestureEvent(m_hWnd, details.type(), location, flags, time,
- details.generic_x(), details.generic_y(), touch_id_bitfield);
+ return new LocalGestureEvent(m_hWnd, details, location, flags, time,
+ touch_id_bitfield);
}
ui::TouchEvent* RenderWidgetHostViewWin::CreateTouchEvent(
diff --git a/content/browser/renderer_host/web_input_event_aurax11.cc b/content/browser/renderer_host/web_input_event_aurax11.cc
index 9eab75a..96d124a 100644
--- a/content/browser/renderer_host/web_input_event_aurax11.cc
+++ b/content/browser/renderer_host/web_input_event_aurax11.cc
@@ -413,6 +413,16 @@ WebKit::WebGestureEvent MakeWebGestureEventFromAuraEvent(
gesture_event.deltaY = event->details().generic_y();
gesture_event.modifiers = EventFlagsToWebEventModifiers(event->flags());
+ // WebKit gesture events do not have bounding-boxes yet, and expect the data
+ // in deltaX/deltaY instead (and instead of bounding box, WebKit expects the
+ // radius). This is currently used only for tap events. So special case this
+ // particular case.
+ // http://crbug.com/138572
+ if (event->type() == ui::ET_GESTURE_TAP) {
+ gesture_event.deltaX = event->details().bounding_box().width() / 2;
+ gesture_event.deltaY = event->details().bounding_box().height() / 2;
+ }
+
return gesture_event;
}
diff --git a/ui/aura/gestures/gesture_recognizer_unittest.cc b/ui/aura/gestures/gesture_recognizer_unittest.cc
index 3f52c1a..db1bd15 100644
--- a/ui/aura/gestures/gesture_recognizer_unittest.cc
+++ b/ui/aura/gestures/gesture_recognizer_unittest.cc
@@ -51,9 +51,7 @@ class GestureEventConsumeDelegate : public TestWindowDelegate {
scroll_x_(0),
scroll_y_(0),
velocity_x_(0),
- velocity_y_(0),
- radius_x_(0),
- radius_y_(0) {
+ velocity_y_(0) {
}
virtual ~GestureEventConsumeDelegate() {}
@@ -81,8 +79,6 @@ class GestureEventConsumeDelegate : public TestWindowDelegate {
scroll_y_ = 0;
velocity_x_ = 0;
velocity_y_ = 0;
- radius_x_ = 0;
- radius_y_ = 0;
}
bool tap() const { return tap_; }
@@ -113,14 +109,12 @@ class GestureEventConsumeDelegate : public TestWindowDelegate {
int touch_id() const { return touch_id_; }
float velocity_x() const { return velocity_x_; }
float velocity_y() const { return velocity_y_; }
- float radius_x() const { return radius_x_; }
- float radius_y() const { return radius_y_; }
+ const gfx::Rect& bounding_box() const { return bounding_box_; }
virtual ui::GestureStatus OnGestureEvent(GestureEvent* gesture) OVERRIDE {
+ bounding_box_ = gesture->details().bounding_box();
switch (gesture->type()) {
case ui::ET_GESTURE_TAP:
- radius_x_ = gesture->details().radius_x();
- radius_y_ = gesture->details().radius_y();
tap_location_ = gesture->location();
tap_ = true;
break;
@@ -200,9 +194,8 @@ class GestureEventConsumeDelegate : public TestWindowDelegate {
float scroll_y_;
float velocity_x_;
float velocity_y_;
- int radius_x_;
- int radius_y_;
int touch_id_;
+ gfx::Rect bounding_box_;
DISALLOW_COPY_AND_ASSIGN(GestureEventConsumeDelegate);
};
@@ -489,8 +482,8 @@ TEST_F(GestureRecognizerTest, GestureEventTapRegion) {
EXPECT_FALSE(delegate->scroll_end());
gfx::Point actual_point(delegate->tap_location());
- EXPECT_EQ(12, delegate->radius_x());
- EXPECT_EQ(12, delegate->radius_y());
+ EXPECT_EQ(24, delegate->bounding_box().width());
+ EXPECT_EQ(24, delegate->bounding_box().height());
EXPECT_EQ(100, actual_point.x());
EXPECT_EQ(200, actual_point.y());
}
@@ -530,8 +523,8 @@ TEST_F(GestureRecognizerTest, GestureEventTapRegion) {
EXPECT_FALSE(delegate->scroll_end());
gfx::Point actual_point(delegate->tap_location());
- EXPECT_EQ(23, delegate->radius_x());
- EXPECT_EQ(20, delegate->radius_y());
+ EXPECT_EQ(46, delegate->bounding_box().width());
+ EXPECT_EQ(40, delegate->bounding_box().height());
EXPECT_EQ(373, actual_point.x());
EXPECT_EQ(290, actual_point.y());
}
@@ -587,8 +580,8 @@ TEST_F(GestureRecognizerTest, GestureEventTapRegion) {
EXPECT_FALSE(delegate->scroll_end());
gfx::Point actual_point(delegate->tap_location());
- EXPECT_EQ(14, delegate->radius_x());
- EXPECT_EQ(14, delegate->radius_y());
+ EXPECT_EQ(28, delegate->bounding_box().width());
+ EXPECT_EQ(28, delegate->bounding_box().height());
EXPECT_EQ(49, actual_point.x());
EXPECT_EQ(200, actual_point.y());
}
@@ -676,8 +669,8 @@ TEST_F(GestureRecognizerTest, GestureEventTapRegion) {
EXPECT_FALSE(delegate->scroll_end());
gfx::Point actual_point(delegate->tap_location());
- EXPECT_EQ(17, delegate->radius_x());
- EXPECT_EQ(18, delegate->radius_y());
+ EXPECT_EQ(35, delegate->bounding_box().width());
+ EXPECT_EQ(36, delegate->bounding_box().height());
EXPECT_EQ(396, actual_point.x());
EXPECT_EQ(149, actual_point.y());
}
diff --git a/ui/aura/test/aura_test_base.cc b/ui/aura/test/aura_test_base.cc
index 977e344..e9609ee 100644
--- a/ui/aura/test/aura_test_base.cc
+++ b/ui/aura/test/aura_test_base.cc
@@ -43,6 +43,7 @@ void AuraTestBase::SetUp() {
ui::GestureConfiguration::set_points_buffered_for_velocity(10);
ui::GestureConfiguration::set_rail_break_proportion(15);
ui::GestureConfiguration::set_rail_start_proportion(2);
+ ui::GestureConfiguration::set_default_radius(0);
helper_.reset(new AuraTestHelper(&message_loop_));
helper_->SetUp();
}
diff --git a/ui/base/gestures/gesture_configuration.h b/ui/base/gestures/gesture_configuration.h
index 206ce91..1b0caa4 100644
--- a/ui/base/gestures/gesture_configuration.h
+++ b/ui/base/gestures/gesture_configuration.h
@@ -21,6 +21,7 @@ class UI_EXPORT GestureConfiguration {
static int default_radius() {
return default_radius_;
}
+ static void set_default_radius(int radius) { default_radius_ = radius; }
static double long_press_time_in_seconds() {
return long_press_time_in_seconds_;
}
diff --git a/ui/base/gestures/gesture_sequence.cc b/ui/base/gestures/gesture_sequence.cc
index e8d5790..c582580 100644
--- a/ui/base/gestures/gesture_sequence.cc
+++ b/ui/base/gestures/gesture_sequence.cc
@@ -493,14 +493,15 @@ void GestureSequence::RecreateBoundingBox() {
for (int i = 0; i < kMaxGesturePoints; ++i) {
if (!points_[i].in_use())
continue;
- if (left > points_[i].x())
- left = points_[i].x();
- if (right < points_[i].x())
- right = points_[i].x();
- if (top > points_[i].y())
- top = points_[i].y();
- if (bottom < points_[i].y())
- bottom = points_[i].y();
+ gfx::Rect rect = points_[i].enclosing_rectangle();
+ if (left > rect.x())
+ left = rect.x();
+ if (right < rect.right())
+ right = rect.right();
+ if (top > rect.y())
+ top = rect.y();
+ if (bottom < rect.bottom())
+ bottom = rect.bottom();
}
bounding_box_last_center_ = bounding_box_.CenterPoint();
bounding_box_.SetRect(left, top, right - left, bottom - top);
@@ -559,6 +560,7 @@ GestureEvent* GestureSequence::CreateGestureEvent(
unsigned int touch_id_bitmask) {
GestureEventDetails gesture_details(details);
gesture_details.set_touch_points(point_count_);
+ gesture_details.set_bounding_box(bounding_box_);
return helper_->CreateGestureEvent(gesture_details, location, flags,
timestamp, touch_id_bitmask);
}
@@ -576,7 +578,7 @@ void GestureSequence::AppendTapDownGestureEvent(const GesturePoint& point,
void GestureSequence::AppendBeginGestureEvent(const GesturePoint& point,
Gestures* gestures) {
gestures->push_back(CreateGestureEvent(
- GestureEventDetails(ui::ET_GESTURE_BEGIN, point_count_, 0),
+ GestureEventDetails(ui::ET_GESTURE_BEGIN, 0, 0),
point.first_touch_position(),
flags_,
base::Time::FromDoubleT(point.last_touch_time()),
@@ -586,7 +588,7 @@ void GestureSequence::AppendBeginGestureEvent(const GesturePoint& point,
void GestureSequence::AppendEndGestureEvent(const GesturePoint& point,
Gestures* gestures) {
gestures->push_back(CreateGestureEvent(
- GestureEventDetails(ui::ET_GESTURE_END, point_count_, 0),
+ GestureEventDetails(ui::ET_GESTURE_END, 0, 0),
point.first_touch_position(),
flags_,
base::Time::FromDoubleT(point.last_touch_time()),
@@ -598,7 +600,7 @@ void GestureSequence::AppendClickGestureEvent(const GesturePoint& point,
gfx::Rect er = point.enclosing_rectangle();
gfx::Point center = er.CenterPoint();
gestures->push_back(CreateGestureEvent(
- GestureEventDetails(ui::ET_GESTURE_TAP, er.width() / 2, er.height() / 2),
+ GestureEventDetails(ui::ET_GESTURE_TAP, 0, 0),
center,
flags_,
base::Time::FromDoubleT(point.last_touch_time()),
diff --git a/ui/base/gestures/gesture_types.cc b/ui/base/gestures/gesture_types.cc
index 8c18e56..2d32980 100644
--- a/ui/base/gestures/gesture_types.cc
+++ b/ui/base/gestures/gesture_types.cc
@@ -22,22 +22,11 @@ GestureEventDetails::GestureEventDetails(ui::EventType type,
data.velocity.y = delta_y;
break;
- case ui::ET_GESTURE_TAP:
- data.radius.x = delta_x;
- data.radius.y = delta_y;
- break;
-
case ui::ET_GESTURE_LONG_PRESS:
data.touch_id = static_cast<int>(delta_x);
CHECK_EQ(0.f, delta_y) << "Unknown data in delta_y for long press.";
break;
- case ui::ET_GESTURE_BEGIN:
- case ui::ET_GESTURE_END:
- set_touch_points(static_cast<int>(delta_x));
- CHECK_EQ(0.f, delta_y) << "Unknown data in delta_y for begin/end";
- break;
-
case ui::ET_GESTURE_PINCH_UPDATE:
data.scale = delta_x;
CHECK_EQ(0.f, delta_y) << "Unknown data in delta_y for pinch";
diff --git a/ui/base/gestures/gesture_types.h b/ui/base/gestures/gesture_types.h
index 6dd39b6..56dad14 100644
--- a/ui/base/gestures/gesture_types.h
+++ b/ui/base/gestures/gesture_types.h
@@ -8,6 +8,7 @@
#include "base/logging.h"
#include "base/time.h"
#include "ui/base/events.h"
+#include "ui/gfx/rect.h"
namespace ui {
@@ -20,6 +21,9 @@ struct UI_EXPORT GestureEventDetails {
int touch_points() const { return touch_points_; }
void set_touch_points(int touch_points) { touch_points_ = touch_points; }
+ const gfx::Rect& bounding_box() const { return bounding_box_; }
+ void set_bounding_box(const gfx::Rect& box) { bounding_box_ = box; }
+
float scroll_x() const {
CHECK_EQ(ui::ET_GESTURE_SCROLL_UPDATE, type_);
return data.scroll.x;
@@ -38,15 +42,6 @@ struct UI_EXPORT GestureEventDetails {
return data.velocity.y;
}
- float radius_x() const {
- CHECK_EQ(ui::ET_GESTURE_TAP, type_);
- return data.radius.x;
- }
- float radius_y() const {
- CHECK_EQ(ui::ET_GESTURE_TAP, type_);
- return data.radius.y;
- }
-
int touch_id() const {
CHECK_EQ(ui::ET_GESTURE_LONG_PRESS, type_);
return data.touch_id;
@@ -97,11 +92,6 @@ struct UI_EXPORT GestureEventDetails {
float y;
} velocity;
- struct { // TAP radius.
- float x;
- float y;
- } radius;
-
int touch_id; // LONG_PRESS touch-id.
struct { // SWIPE direction.
@@ -118,6 +108,10 @@ struct UI_EXPORT GestureEventDetails {
} data;
int touch_points_; // Number of active touch points in the gesture.
+
+ // Bounding box is an axis-aligned rectangle that contains all the
+ // enclosing rectangles of the touch-points in the gesture.
+ gfx::Rect bounding_box_;
};
// An abstract type to represent touch-events. The gesture-recognizer uses this