Commit c5fb6520 authored by sadrul@chromium.org's avatar sadrul@chromium.org

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
parent 3c1c0bee
......@@ -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();
......
......@@ -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 {
......
......@@ -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.
......
......@@ -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) {
......
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