| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_targeter.h" | 5 #include "ui/views/widget/root_view_targeter.h" |
| 6 | 6 |
| 7 #include "ui/views/view.h" | 7 #include "ui/views/view.h" |
| 8 #include "ui/views/view_targeter_delegate.h" | 8 #include "ui/views/view_targeter_delegate.h" |
| 9 #include "ui/views/views_switches.h" | 9 #include "ui/views/views_switches.h" |
| 10 #include "ui/views/widget/root_view.h" | 10 #include "ui/views/widget/root_view.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 View* root, | 24 View* root, |
| 25 const ui::GestureEvent& gesture) { | 25 const ui::GestureEvent& gesture) { |
| 26 CHECK_EQ(root, root_view_); | 26 CHECK_EQ(root, root_view_); |
| 27 | 27 |
| 28 // Return the default gesture handler if one is already set. | 28 // Return the default gesture handler if one is already set. |
| 29 if (root_view_->gesture_handler_) { | 29 if (root_view_->gesture_handler_) { |
| 30 CHECK(root_view_->gesture_handler_set_before_processing_); | 30 CHECK(root_view_->gesture_handler_set_before_processing_); |
| 31 return root_view_->gesture_handler_; | 31 return root_view_->gesture_handler_; |
| 32 } | 32 } |
| 33 | 33 |
| 34 // If no default gesture handler has already been set, do not perform any | |
| 35 // targeting for a ET_GESTURE_END event. | |
| 36 // TODO(tdanderson): This check belongs in | |
| 37 // RootView::OnEventProcessingStarted() instead of here. | |
| 38 if (gesture.type() == ui::ET_GESTURE_END) | |
| 39 return NULL; | |
| 40 | |
| 41 // If rect-based targeting is enabled, use the gesture's bounding box to | 34 // If rect-based targeting is enabled, use the gesture's bounding box to |
| 42 // determine the target. Otherwise use the center point of the gesture's | 35 // determine the target. Otherwise use the center point of the gesture's |
| 43 // bounding box to determine the target. | 36 // bounding box to determine the target. |
| 44 gfx::Rect rect(gesture.location(), gfx::Size(1, 1)); | 37 gfx::Rect rect(gesture.location(), gfx::Size(1, 1)); |
| 45 if (views::switches::IsRectBasedTargetingEnabled() && | 38 if (views::switches::IsRectBasedTargetingEnabled() && |
| 46 !gesture.details().bounding_box().IsEmpty()) { | 39 !gesture.details().bounding_box().IsEmpty()) { |
| 47 // TODO(tdanderson): Pass in the bounding box to GetEventHandlerForRect() | 40 // TODO(tdanderson): Pass in the bounding box to GetEventHandlerForRect() |
| 48 // once crbug.com/313392 is resolved. | 41 // once crbug.com/313392 is resolved. |
| 49 rect.set_size(gesture.details().bounding_box().size()); | 42 rect.set_size(gesture.details().bounding_box().size()); |
| 50 rect.Offset(-rect.width() / 2, -rect.height() / 2); | 43 rect.Offset(-rect.width() / 2, -rect.height() / 2); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 75 // the GESTURE_END event corresponding to the removal of the last touch | 68 // the GESTURE_END event corresponding to the removal of the last touch |
| 76 // point. In either case, no further re-targeting of |gesture| should be | 69 // point. In either case, no further re-targeting of |gesture| should be |
| 77 // permitted. | 70 // permitted. |
| 78 if (!root_view_->gesture_handler_) | 71 if (!root_view_->gesture_handler_) |
| 79 return NULL; | 72 return NULL; |
| 80 | 73 |
| 81 return previous_target->GetParentTarget(); | 74 return previous_target->GetParentTarget(); |
| 82 } | 75 } |
| 83 | 76 |
| 84 } // namespace views | 77 } // namespace views |
| OLD | NEW |