| Index: content/browser/renderer_host/input/web_input_event_builders_android.cc
|
| diff --git a/content/browser/renderer_host/input/web_input_event_builders_android.cc b/content/browser/renderer_host/input/web_input_event_builders_android.cc
|
| index 979f8269d3a04943a8e59e86c6041cdfcbc1653f..a2ed46fcd38a2210b14dfa017f9cb4b35c4e9062 100644
|
| --- a/content/browser/renderer_host/input/web_input_event_builders_android.cc
|
| +++ b/content/browser/renderer_host/input/web_input_event_builders_android.cc
|
| @@ -20,100 +20,6 @@ using blink::WebTouchEvent;
|
| using blink::WebTouchPoint;
|
|
|
| namespace content {
|
| -namespace {
|
| -
|
| -WebInputEvent::Type ToWebInputEventType(MotionEventAndroid::Action action) {
|
| - switch (action) {
|
| - case MotionEventAndroid::ACTION_DOWN:
|
| - return WebInputEvent::TouchStart;
|
| - case MotionEventAndroid::ACTION_MOVE:
|
| - return WebInputEvent::TouchMove;
|
| - case MotionEventAndroid::ACTION_UP:
|
| - return WebInputEvent::TouchEnd;
|
| - case MotionEventAndroid::ACTION_CANCEL:
|
| - return WebInputEvent::TouchCancel;
|
| - case MotionEventAndroid::ACTION_POINTER_DOWN:
|
| - return WebInputEvent::TouchStart;
|
| - case MotionEventAndroid::ACTION_POINTER_UP:
|
| - return WebInputEvent::TouchEnd;
|
| - }
|
| - NOTREACHED() << "Invalid MotionEventAndroid::Action.";
|
| - return WebInputEvent::Undefined;
|
| -}
|
| -
|
| -// Note that |is_action_pointer| is meaningful only in the context of
|
| -// |ACTION_POINTER_UP| and |ACTION_POINTER_DOWN|; other actions map directly to
|
| -// WebTouchPoint::State.
|
| -WebTouchPoint::State ToWebTouchPointState(MotionEventAndroid::Action action,
|
| - bool is_action_pointer) {
|
| - switch (action) {
|
| - case MotionEventAndroid::ACTION_DOWN:
|
| - return WebTouchPoint::StatePressed;
|
| - case MotionEventAndroid::ACTION_MOVE:
|
| - return WebTouchPoint::StateMoved;
|
| - case MotionEventAndroid::ACTION_UP:
|
| - return WebTouchPoint::StateReleased;
|
| - case MotionEventAndroid::ACTION_CANCEL:
|
| - return WebTouchPoint::StateCancelled;
|
| - case MotionEventAndroid::ACTION_POINTER_DOWN:
|
| - return is_action_pointer ? WebTouchPoint::StatePressed
|
| - : WebTouchPoint::StateStationary;
|
| - case MotionEventAndroid::ACTION_POINTER_UP:
|
| - return is_action_pointer ? WebTouchPoint::StateReleased
|
| - : WebTouchPoint::StateStationary;
|
| - }
|
| - NOTREACHED() << "Invalid MotionEventAndroid::Action.";
|
| - return WebTouchPoint::StateUndefined;
|
| -}
|
| -
|
| -WebTouchPoint BuildWebTouchPoint(const MotionEventAndroid& event,
|
| - size_t pointer_index,
|
| - float px_to_dp) {
|
| - WebTouchPoint touch;
|
| - touch.id = event.GetPointerId(pointer_index);
|
| - touch.state = ToWebTouchPointState(
|
| - event.GetAction(),
|
| - static_cast<int>(pointer_index) == event.GetActionIndex());
|
| - touch.position.x = event.GetX(pointer_index) * px_to_dp;
|
| - touch.position.y = event.GetY(pointer_index) * px_to_dp;
|
| - // TODO(joth): Raw event co-ordinates.
|
| - touch.screenPosition = touch.position;
|
| -
|
| - const int radius_major =
|
| - static_cast<int>(event.GetTouchMajor(pointer_index) * 0.5f * px_to_dp);
|
| - const int radius_minor =
|
| - static_cast<int>(event.GetTouchMinor(pointer_index) * 0.5f * px_to_dp);
|
| - const float major_angle_in_radians_clockwise_from_vertical =
|
| - event.GetOrientation();
|
| -
|
| - float major_angle_in_degrees_clockwise_from_vertical = 0;
|
| - if (!std::isnan(major_angle_in_radians_clockwise_from_vertical)) {
|
| - major_angle_in_degrees_clockwise_from_vertical =
|
| - major_angle_in_radians_clockwise_from_vertical * 180.f / M_PI;
|
| - }
|
| - // Android provides a major axis orientation clockwise with respect to the
|
| - // vertical of [-90, 90]. The proposed W3C extension specifies the angle that
|
| - // the ellipse described by radiusX and radiusY is rotated clockwise about
|
| - // its center, with a value of [0, 90], see
|
| - // http://www.w3.org/TR/2011/WD-touch-events-20110505/.
|
| - if (major_angle_in_degrees_clockwise_from_vertical >= 0) {
|
| - touch.radiusX = radius_minor;
|
| - touch.radiusY = radius_major;
|
| - touch.rotationAngle = major_angle_in_degrees_clockwise_from_vertical;
|
| - } else {
|
| - touch.radiusX = radius_major;
|
| - touch.radiusY = radius_minor;
|
| - touch.rotationAngle = major_angle_in_degrees_clockwise_from_vertical + 90.f;
|
| - }
|
| - DCHECK_GE(touch.rotationAngle, 0.f);
|
| - DCHECK_LE(touch.rotationAngle, 90.f);
|
| -
|
| - touch.force = event.GetPressure(pointer_index);
|
| -
|
| - return touch;
|
| -}
|
| -
|
| -} // namespace
|
|
|
| WebKeyboardEvent WebKeyboardEventBuilder::Build(WebInputEvent::Type type,
|
| int modifiers,
|
| @@ -229,25 +135,8 @@ WebGestureEvent WebGestureEventBuilder::Build(WebInputEvent::Type type,
|
|
|
| blink::WebTouchEvent WebTouchEventBuilder::Build(
|
| const MotionEventAndroid& event,
|
| - float device_scale_factor) {
|
| - blink::WebTouchEvent result;
|
| -
|
| - result.type = ToWebInputEventType(event.GetAction());
|
| - DCHECK(WebInputEvent::isTouchEventType(result.type));
|
| -
|
| - result.timeStampSeconds =
|
| - (event.GetEventTime() - base::TimeTicks()).InSecondsF();
|
| -
|
| - result.touchesLength =
|
| - std::min(event.GetPointerCount(),
|
| - static_cast<size_t>(WebTouchEvent::touchesLengthCap));
|
| - DCHECK_GT(result.touchesLength, 0U);
|
| -
|
| - const float px_to_dp = 1.f / device_scale_factor;
|
| - for (size_t i = 0; i < result.touchesLength; ++i)
|
| - result.touches[i] = BuildWebTouchPoint(event, i, px_to_dp);
|
| -
|
| - return result;
|
| + float scale) {
|
| + return CreateWebTouchEventFromMotionEvent(event, scale);
|
| }
|
|
|
| } // namespace content
|
|
|