diff options
author | jdduke@chromium.org <jdduke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-18 17:01:08 +0000 |
---|---|---|
committer | jdduke@chromium.org <jdduke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-18 17:02:23 +0000 |
commit | f26c25264c611465b6a7a3fced003d157653df7b (patch) | |
tree | a9c6ae3546131d129332e05222df9fe69f24d030 /ui/events/gestures | |
parent | bb5afcdfe7dda12171e59148a84775da48b86e3f (diff) | |
download | chromium_src-f26c25264c611465b6a7a3fced003d157653df7b.zip chromium_src-f26c25264c611465b6a7a3fced003d157653df7b.tar.gz chromium_src-f26c25264c611465b6a7a3fced003d157653df7b.tar.bz2 |
Remove NOTIMPLEMENTED guard in MotionEvent{Web|Aura}::GetToolType
As MotionEvent::GetToolType is now used in the common gesture detection path,
remove the NOTIMPLEMENTED for types that don't currently route the pointer
tool type. Returning TOOL_TYPE_UNKNOWN is sufficient for now.
Also update MotionEventAura to strictly validate pointer indices when fetching
pointer properties.
BUG=404586
Review URL: https://codereview.chromium.org/481953002
Cr-Commit-Position: refs/heads/master@{#290272}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@290272 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/events/gestures')
-rw-r--r-- | ui/events/gestures/motion_event_aura.cc | 23 | ||||
-rw-r--r-- | ui/events/gestures/motion_event_aura_unittest.cc | 11 |
2 files changed, 23 insertions, 11 deletions
diff --git a/ui/events/gestures/motion_event_aura.cc b/ui/events/gestures/motion_event_aura.cc index 771b67f..ab20860 100644 --- a/ui/events/gestures/motion_event_aura.cc +++ b/ui/events/gestures/motion_event_aura.cc @@ -85,49 +85,50 @@ int MotionEventAura::GetActionIndex() const { DCHECK(cached_action_ == ACTION_POINTER_DOWN || cached_action_ == ACTION_POINTER_UP); DCHECK_GE(cached_action_index_, 0); - DCHECK_LE(cached_action_index_, static_cast<int>(pointer_count_)); + DCHECK_LT(cached_action_index_, static_cast<int>(pointer_count_)); return cached_action_index_; } size_t MotionEventAura::GetPointerCount() const { return pointer_count_; } int MotionEventAura::GetPointerId(size_t pointer_index) const { - DCHECK_LE(pointer_index, pointer_count_); + DCHECK_LT(pointer_index, pointer_count_); return active_touches_[pointer_index].touch_id; } float MotionEventAura::GetX(size_t pointer_index) const { - DCHECK_LE(pointer_index, pointer_count_); + DCHECK_LT(pointer_index, pointer_count_); return active_touches_[pointer_index].x; } float MotionEventAura::GetY(size_t pointer_index) const { - DCHECK_LE(pointer_index, pointer_count_); + DCHECK_LT(pointer_index, pointer_count_); return active_touches_[pointer_index].y; } float MotionEventAura::GetRawX(size_t pointer_index) const { - DCHECK_LE(pointer_index, pointer_count_); + DCHECK_LT(pointer_index, pointer_count_); return active_touches_[pointer_index].raw_x; } float MotionEventAura::GetRawY(size_t pointer_index) const { - DCHECK_LE(pointer_index, pointer_count_); + DCHECK_LT(pointer_index, pointer_count_); return active_touches_[pointer_index].raw_y; } float MotionEventAura::GetTouchMajor(size_t pointer_index) const { - DCHECK_LE(pointer_index, pointer_count_); + DCHECK_LT(pointer_index, pointer_count_); return active_touches_[pointer_index].major_radius * 2; } float MotionEventAura::GetPressure(size_t pointer_index) const { - DCHECK_LE(pointer_index, pointer_count_); + DCHECK_LT(pointer_index, pointer_count_); return active_touches_[pointer_index].pressure; } MotionEvent::ToolType MotionEventAura::GetToolType(size_t pointer_index) const { - NOTIMPLEMENTED(); + // TODO(jdduke): Plumb tool type from the platform, crbug.com/404128. + DCHECK_LT(pointer_index, pointer_count_); return MotionEvent::TOOL_TYPE_UNKNOWN; } @@ -175,7 +176,7 @@ MotionEventAura::PointData::PointData() } int MotionEventAura::GetSourceDeviceId(size_t pointer_index) const { - DCHECK_LE(pointer_index, pointer_count_); + DCHECK_LT(pointer_index, pointer_count_); return active_touches_[pointer_index].source_device_id; } @@ -212,7 +213,7 @@ void MotionEventAura::UpdateCachedAction(const TouchEvent& touch) { cached_action_ = ACTION_POINTER_UP; cached_action_index_ = static_cast<int>(GetIndexFromId(touch.touch_id())); - DCHECK_LE(cached_action_index_, static_cast<int>(pointer_count_)); + DCHECK_LT(cached_action_index_, static_cast<int>(pointer_count_)); } break; case ET_TOUCH_CANCELLED: diff --git a/ui/events/gestures/motion_event_aura_unittest.cc b/ui/events/gestures/motion_event_aura_unittest.cc index c45348e..3ef793e 100644 --- a/ui/events/gestures/motion_event_aura_unittest.cc +++ b/ui/events/gestures/motion_event_aura_unittest.cc @@ -320,4 +320,15 @@ TEST(MotionEventAuraTest, Cancel) { EXPECT_EQ(2U, static_cast<MotionEventAura*>(cancel.get())->GetPointerCount()); } +TEST(MotionEventAuraTest, ToolType) { + MotionEventAura event; + + // For now, all pointers have an unknown tool type. + // TODO(jdduke): Expand this test when ui::TouchEvent identifies the source + // touch type, crbug.com/404128. + event.OnTouch(TouchWithType(ET_TOUCH_PRESSED, 7)); + ASSERT_EQ(1U, event.GetPointerCount()); + EXPECT_EQ(MotionEvent::TOOL_TYPE_UNKNOWN, event.GetToolType(0)); +} + } // namespace ui |