diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-19 01:36:29 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-19 01:36:29 +0000 |
commit | c5fb6520d76ffd57cf453b0b9e54c1bcd8aed922 (patch) | |
tree | 40f8dc37f7f73d35bb721a399dcfb164833f8005 | |
parent | 3c1c0bee1791d9884196df6616a14811808a5c90 (diff) | |
download | chromium_src-c5fb6520d76ffd57cf453b0b9e54c1bcd8aed922.zip chromium_src-c5fb6520d76ffd57cf453b0b9e54c1bcd8aed922.tar.gz chromium_src-c5fb6520d76ffd57cf453b0b9e54c1bcd8aed922.tar.bz2 |
touch: Make sure the correct radius values are used for touch events.
The device may not always report the radii values for a touch event. In such
cases, instead of making up a default value, always use 0 so that it is easy to
determine if the radius is the real radius reported by the device or not. Also,
at the same time, make sure that the radius value sent to webkit follows the
spec. Also fix the radii adjustment for device-scale-factor.
BUG=128553
TEST=manually with test-pages
Review URL: https://chromiumcodereview.appspot.com/10383249
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@138006 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | content/browser/renderer_host/web_input_event_aurax11.cc | 5 | ||||
-rw-r--r-- | ui/aura/event.cc | 10 | ||||
-rw-r--r-- | ui/aura/event.h | 4 | ||||
-rw-r--r-- | ui/base/x/events_x.cc | 4 |
4 files changed, 13 insertions, 10 deletions
diff --git a/content/browser/renderer_host/web_input_event_aurax11.cc b/content/browser/renderer_host/web_input_event_aurax11.cc index 8b20ea2..905a52e 100644 --- a/content/browser/renderer_host/web_input_event_aurax11.cc +++ b/content/browser/renderer_host/web_input_event_aurax11.cc @@ -410,8 +410,9 @@ WebKit::WebTouchPoint* UpdateWebTouchEventFromAuraEvent( if (!point) return NULL; - point->radiusX = event->radius_x(); - point->radiusY = event->radius_y(); + // The spec requires the radii values to be positive (and 1 when unknown). + point->radiusX = std::max(1.f, event->radius_x()); + point->radiusY = std::max(1.f, event->radius_y()); point->rotationAngle = event->rotation_angle(); point->force = event->force(); diff --git a/ui/aura/event.cc b/ui/aura/event.cc index 0d9f590..a4c990c 100644 --- a/ui/aura/event.cc +++ b/ui/aura/event.cc @@ -271,8 +271,8 @@ TouchEvent::TouchEvent(ui::EventType type, base::TimeDelta time_stamp) : LocatedEvent(type, location, location, 0), touch_id_(touch_id), - radius_x_(1.0f), - radius_y_(1.0f), + radius_x_(0.0f), + radius_y_(0.0f), rotation_angle_(0.0f), force_(0.0f) { set_time_stamp(time_stamp); @@ -285,8 +285,10 @@ void TouchEvent::UpdateForRootTransform(const ui::Transform& root_transform) { LocatedEvent::UpdateForRootTransform(root_transform); gfx::Point3f scale; ui::InterpolatedTransform::FactorTRS(root_transform, NULL, NULL, &scale); - radius_x_ *= scale.x(); - radius_y_ *= scale.y(); + if (scale.x()) + radius_x_ /= scale.x(); + if (scale.y()) + radius_y_ /= scale.y(); } ui::EventType TouchEvent::GetEventType() const { diff --git a/ui/aura/event.h b/ui/aura/event.h index e9cc7e8..c3fa722 100644 --- a/ui/aura/event.h +++ b/ui/aura/event.h @@ -230,10 +230,10 @@ class AURA_EXPORT TouchEvent : public LocatedEvent, // for each separable additional touch that the hardware can detect. const int touch_id_; - // Radius of the X (major) axis of the touch ellipse. 1.0 if unknown. + // Radius of the X (major) axis of the touch ellipse. 0.0 if unknown. float radius_x_; - // Radius of the Y (minor) axis of the touch ellipse. 1.0 if unknown. + // Radius of the Y (minor) axis of the touch ellipse. 0.0 if unknown. float radius_y_; // Angle of the major axis away from the X axis. Default 0.0. diff --git a/ui/base/x/events_x.cc b/ui/base/x/events_x.cc index 47cb746..4d822e4 100644 --- a/ui/base/x/events_x.cc +++ b/ui/base/x/events_x.cc @@ -834,12 +834,12 @@ int GetTouchId(const base::NativeEvent& xev) { float GetTouchRadiusX(const base::NativeEvent& native_event) { return GetTouchParamFromXEvent(native_event, - ui::TouchFactory::TP_TOUCH_MAJOR, 2.0) / 2.0; + ui::TouchFactory::TP_TOUCH_MAJOR, 0.0) / 2.0; } float GetTouchRadiusY(const base::NativeEvent& native_event) { return GetTouchParamFromXEvent(native_event, - ui::TouchFactory::TP_TOUCH_MINOR, 2.0) / 2.0; + ui::TouchFactory::TP_TOUCH_MINOR, 0.0) / 2.0; } float GetTouchAngle(const base::NativeEvent& native_event) { |