Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Side by Side Diff: components/mus/gesture_manager.cc

Issue 1362793002: Construct and check for mojo::Event's LocationData as needed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Also audit wheel_data and brush_data. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/mus/gesture_manager.h" 5 #include "components/mus/gesture_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "components/mus/gesture_manager_delegate.h" 9 #include "components/mus/gesture_manager_delegate.h"
10 #include "components/mus/public/cpp/keys.h" 10 #include "components/mus/public/cpp/keys.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 // TODO(sky): I'm doing this until things are converted. Seems as though we 48 // TODO(sky): I'm doing this until things are converted. Seems as though we
49 // shouldn't do this long term. 49 // shouldn't do this long term.
50 if (result.empty()) 50 if (result.empty())
51 result.push_back(deepest); 51 result.push_back(deepest);
52 return result; 52 return result;
53 } 53 }
54 54
55 mojo::EventPtr CloneEventForView(const mojo::Event& event, 55 mojo::EventPtr CloneEventForView(const mojo::Event& event,
56 const ServerView* view) { 56 const ServerView* view) {
57 mojo::EventPtr result(event.Clone()); 57 mojo::EventPtr result(event.Clone());
58 const gfx::PointF location(event.pointer_data->location->x, 58 if (event.pointer_data && event.pointer_data->location) {
59 event.pointer_data->location->y); 59 const gfx::PointF location(event.pointer_data->location->x,
60 const gfx::PointF target_location( 60 event.pointer_data->location->y);
61 ConvertPointFBetweenViews(view->GetRoot(), view, location)); 61 const gfx::PointF target_location(
62 result->pointer_data->location->x = target_location.x(); 62 ConvertPointFBetweenViews(view->GetRoot(), view, location));
63 result->pointer_data->location->y = target_location.y(); 63 result->pointer_data->location->x = target_location.x();
64 result->pointer_data->location->y = target_location.y();
65 }
64 return result.Pass(); 66 return result.Pass();
65 } 67 }
66 68
67 } // namespace 69 } // namespace
68 70
69 // GestureStateChange ---------------------------------------------------------- 71 // GestureStateChange ----------------------------------------------------------
70 72
71 GestureStateChange::GestureStateChange() 73 GestureStateChange::GestureStateChange()
72 : chosen_gesture(GestureManager::kInvalidGestureId) {} 74 : chosen_gesture(GestureManager::kInvalidGestureId) {}
73 75
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 const ServerView* root) 530 const ServerView* root)
529 : delegate_(delegate), root_view_(root) {} 531 : delegate_(delegate), root_view_(root) {}
530 532
531 GestureManager::~GestureManager() { 533 GestureManager::~GestureManager() {
532 // Explicitly delete the pointers first as this may result in calling back to 534 // Explicitly delete the pointers first as this may result in calling back to
533 // us to cleanup and delete gestures. 535 // us to cleanup and delete gestures.
534 active_pointers_.clear(); 536 active_pointers_.clear();
535 } 537 }
536 538
537 bool GestureManager::ProcessEvent(const mojo::Event& event) { 539 bool GestureManager::ProcessEvent(const mojo::Event& event) {
538 if (!event.pointer_data) 540 if (!event.pointer_data || !event.pointer_data->location)
539 return false; 541 return false;
540 542
541 ScheduledDeleteProcessor delete_processor(this); 543 ScheduledDeleteProcessor delete_processor(this);
542 const gfx::Point location(static_cast<int>(event.pointer_data->location->x), 544 const gfx::Point location(static_cast<int>(event.pointer_data->location->x),
543 static_cast<int>(event.pointer_data->location->y)); 545 static_cast<int>(event.pointer_data->location->y));
544 switch (event.action) { 546 switch (event.action) {
545 case mojo::EVENT_TYPE_POINTER_DOWN: { 547 case mojo::EVENT_TYPE_POINTER_DOWN: {
546 if (GetPointerById(event.pointer_data->pointer_id)) { 548 if (GetPointerById(event.pointer_data->pointer_id)) {
547 DVLOG(1) << "received more than one down for a pointer without a " 549 DVLOG(1) << "received more than one down for a pointer without a "
548 << "corresponding up, id=" << event.pointer_data->pointer_id; 550 << "corresponding up, id=" << event.pointer_data->pointer_id;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 void GestureManager::ScheduleDelete(Pointer* pointer) { 689 void GestureManager::ScheduleDelete(Pointer* pointer) {
688 auto iter = 690 auto iter =
689 std::find(active_pointers_.begin(), active_pointers_.end(), pointer); 691 std::find(active_pointers_.begin(), active_pointers_.end(), pointer);
690 if (iter != active_pointers_.end()) { 692 if (iter != active_pointers_.end()) {
691 active_pointers_.weak_erase(iter); 693 active_pointers_.weak_erase(iter);
692 pointers_to_delete_.push_back(pointer); 694 pointers_to_delete_.push_back(pointer);
693 } 695 }
694 } 696 }
695 697
696 } // namespace mus 698 } // namespace mus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698