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

Side by Side Diff: ui/views/widget/root_view.cc

Issue 10790019: Add gesture target fuzzing to views (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 5 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
« ui/views/view_constants.h ('K') | « ui/views/view_constants.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/views/widget/root_view.h" 5 #include "ui/views/widget/root_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 // Reset touch_pressed_handler_ to indicate that no processing is occurring. 447 // Reset touch_pressed_handler_ to indicate that no processing is occurring.
448 touch_pressed_handler_ = NULL; 448 touch_pressed_handler_ = NULL;
449 449
450 return status; 450 return status;
451 } 451 }
452 452
453 ui::GestureStatus RootView::OnGestureEvent(const GestureEvent& event) { 453 ui::GestureStatus RootView::OnGestureEvent(const GestureEvent& event) {
454 GestureEvent e(event, this); 454 GestureEvent e(event, this);
455 ui::GestureStatus status = ui::GESTURE_STATUS_UNKNOWN; 455 ui::GestureStatus status = ui::GESTURE_STATUS_UNKNOWN;
456 456
457 if (gesture_handler_) { 457 // TODO(tdanderson): Store radius values for a ui::ET_GESTURE_LONG_PRESS
458 // event so that fuzzing may also be used for a long press.
459 bool useFuzzing = event.type() == ui::ET_GESTURE_TAP;
sky 2012/07/17 19:54:32 Why do this here? Shouldn't we fuzz only if there
tdanderson 2012/07/18 22:35:42 There could be a |gesture_handler_| from either GE
sky 2012/07/19 00:06:38 Why? It seems wrong to me to change the target vie
460
461 if (useFuzzing) {
462 float radius = event.details().radius_x();
463 gfx::Point adjustedLoc(event.x() - radius, event.y() - radius);
464 ConvertPointToScreen(this, &adjustedLoc);
sadrul 2012/07/16 22:16:14 Why is it necessary to convert to screen coordinat
rjkroege 2012/07/16 23:35:48 Aside: are screen coords in DIP or physical?
tdanderson 2012/07/17 19:07:07 Please see my reply in view.cc and let me know if
tdanderson 2012/07/18 22:35:42 Done.
465 gfx::Rect touchRect(adjustedLoc.x(), adjustedLoc.y(), radius*2, radius*2);
466
467 gfx::Rect closestOverlappedRect;
468 FindClosestOverlappedRect(touchRect, closestOverlappedRect);
469
470 if (!closestOverlappedRect.IsEmpty()) {
471 gfx::Point newLoc(closestOverlappedRect.CenterPoint());
472 ConvertPointFromScreen(this, &newLoc);
473 e.location_ = newLoc;
sky 2012/07/17 19:54:32 What is |e|?
tdanderson 2012/07/18 22:35:42 This was present before I touched the code. It is
474 }
475 }
476
477 if (gesture_handler_ && !useFuzzing) {
sadrul 2012/07/16 22:16:14 Hm... I think with this change here, we can end u
tdanderson 2012/07/17 19:07:07 Yes, I see the problem here. But if the fuzzing lo
sadrul 2012/07/17 19:26:45 Yes. But I do not think we can avoid this (apart f
tdanderson 2012/07/18 22:35:42 This is the approach I have taken in my latest CL.
458 // Allow |gesture_handler_| to delete this during processing. 478 // Allow |gesture_handler_| to delete this during processing.
459 View* handler = gesture_handler_; 479 View* handler = gesture_handler_;
460 GestureEvent handler_event(event, this, gesture_handler_); 480 GestureEvent handler_event(event, this, gesture_handler_);
461 // TODO: should only do this for the last touch id that goes up. 481 // TODO: should only do this for the last touch id that goes up.
462 if (event.type() == ui::ET_GESTURE_END) 482 if (event.type() == ui::ET_GESTURE_END)
463 gesture_handler_ = NULL; 483 gesture_handler_ = NULL;
464 return handler->ProcessGestureEvent(handler_event); 484 return handler->ProcessGestureEvent(handler_event);
465 } 485 }
466 486
467 // Walk up the tree until we find a view that wants the gesture event. 487 // Walk up the tree until we find a view that wants the gesture event.
468 for (gesture_handler_ = GetEventHandlerForPoint(e.location()); 488 for (gesture_handler_ = GetEventHandlerForPoint(e.location());
469 gesture_handler_ && (gesture_handler_ != this); 489 gesture_handler_ && (gesture_handler_ != this);
470 gesture_handler_ = gesture_handler_->parent()) { 490 gesture_handler_ = gesture_handler_->parent()) {
491
471 if (!gesture_handler_->enabled()) { 492 if (!gesture_handler_->enabled()) {
472 // Disabled views eat events but are treated as not handled. 493 // Disabled views eat events but are treated as not handled.
473 return ui::GESTURE_STATUS_UNKNOWN; 494 return ui::GESTURE_STATUS_UNKNOWN;
474 } 495 }
475 496
476 // See if this view wants to handle the Gesture. 497 // See if this view wants to handle the Gesture.
477 GestureEvent gesture_event(e, this, gesture_handler_); 498 GestureEvent gesture_event(e, this, gesture_handler_);
478 status = gesture_handler_->ProcessGestureEvent(gesture_event); 499 status = gesture_handler_->ProcessGestureEvent(gesture_event);
479 500
480 // The view could have removed itself from the tree when handling 501 // The view could have removed itself from the tree when handling
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 } 584 }
564 585
565 void RootView::SetMouseLocationAndFlags(const MouseEvent& event) { 586 void RootView::SetMouseLocationAndFlags(const MouseEvent& event) {
566 last_mouse_event_flags_ = event.flags(); 587 last_mouse_event_flags_ = event.flags();
567 last_mouse_event_x_ = event.x(); 588 last_mouse_event_x_ = event.x();
568 last_mouse_event_y_ = event.y(); 589 last_mouse_event_y_ = event.y();
569 } 590 }
570 591
571 } // namespace internal 592 } // namespace internal
572 } // namespace views 593 } // namespace views
OLDNEW
« ui/views/view_constants.h ('K') | « ui/views/view_constants.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698