Index: ui/events/blink/blink_event_util.cc |
diff --git a/ui/events/blink/blink_event_util.cc b/ui/events/blink/blink_event_util.cc |
index 9a3a648ae3306e5517b87255acd1c5d0f1fac847..b389600f23b33709d46b444a4dcb420368403f6b 100644 |
--- a/ui/events/blink/blink_event_util.cc |
+++ b/ui/events/blink/blink_event_util.cc |
@@ -103,9 +103,25 @@ WebTouchPoint CreateWebTouchPoint(const MotionEvent& event, |
DCHECK_GE(major_radius, 0); |
DCHECK_GE(minor_radius, 0); |
DCHECK_GE(major_radius, minor_radius); |
- // Allow a small bound tolerance to account for floating point conversion. |
- DCHECK_GT(orientation_deg, -90.01f); |
- DCHECK_LT(orientation_deg, 90.01f); |
+ if (event.GetToolType(pointer_index) == MotionEvent::TOOL_TYPE_STYLUS) { |
+ // Orientation lies in [-180, 180] for a stylus. Normalise to [-90, 90). |
+ // Allow a small bound tolerance to account for floating point conversion. |
+ // TODO(e_hakkinen): crbug.com/493728: Pass also unaltered orientation |
+ // to touch in order not to lose quadrant information. |
+ DCHECK_GT(orientation_deg, -180.01f); |
+ DCHECK_LT(orientation_deg, 180.01f); |
+ if (orientation_deg >= 90.f) |
+ orientation_deg -= 180.f; |
+ else if (orientation_deg < -90.f) |
+ orientation_deg += 180.f; |
+ } else { |
+ // Orientation lies in [-90, 90] for a touch. Normalise to [-90, 90). |
+ // Allow a small bound tolerance to account for floating point conversion. |
+ DCHECK_GT(orientation_deg, -90.01f); |
+ DCHECK_LT(orientation_deg, 90.01f); |
+ if (orientation_deg >= 90.f) |
+ orientation_deg -= 180.f; |
+ } |
if (orientation_deg >= 0) { |
// The case orientation_deg == 0 is handled here on purpose: although the |
// 'else' block is equivalent in this case, we want to pass the 0 value |