OLD | NEW |
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 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. | 5 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. |
6 | 6 |
7 #include "ui/views/view.h" | 7 #include "ui/views/view.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cmath> | 10 #include <cmath> |
(...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
842 View* rect_view = NULL; | 842 View* rect_view = NULL; |
843 int rect_view_distance = INT_MAX; | 843 int rect_view_distance = INT_MAX; |
844 | 844 |
845 // |point_view| represents the view that would have been returned | 845 // |point_view| represents the view that would have been returned |
846 // from this function call if point-based targeting were used. | 846 // from this function call if point-based targeting were used. |
847 View* point_view = NULL; | 847 View* point_view = NULL; |
848 | 848 |
849 for (int i = child_count() - 1; i >= 0; --i) { | 849 for (int i = child_count() - 1; i >= 0; --i) { |
850 View* child = child_at(i); | 850 View* child = child_at(i); |
851 | 851 |
| 852 if (!child->CanProcessEventsWithinSubtree()) |
| 853 continue; |
| 854 |
852 // Ignore any children which are invisible or do not intersect |rect|. | 855 // Ignore any children which are invisible or do not intersect |rect|. |
853 if (!child->visible()) | 856 if (!child->visible()) |
854 continue; | 857 continue; |
855 gfx::RectF rect_in_child_coords_f(rect); | 858 gfx::RectF rect_in_child_coords_f(rect); |
856 ConvertRectToTarget(this, child, &rect_in_child_coords_f); | 859 ConvertRectToTarget(this, child, &rect_in_child_coords_f); |
857 gfx::Rect rect_in_child_coords = gfx::ToEnclosingRect( | 860 gfx::Rect rect_in_child_coords = gfx::ToEnclosingRect( |
858 rect_in_child_coords_f); | 861 rect_in_child_coords_f); |
859 if (!child->HitTestRect(rect_in_child_coords)) | 862 if (!child->HitTestRect(rect_in_child_coords)) |
860 continue; | 863 continue; |
861 | 864 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
897 gfx::Point touch_center(rect.CenterPoint()); | 900 gfx::Point touch_center(rect.CenterPoint()); |
898 int cur_dist = views::DistanceSquaredFromCenterToPoint(touch_center, | 901 int cur_dist = views::DistanceSquaredFromCenterToPoint(touch_center, |
899 local_bounds); | 902 local_bounds); |
900 if (!rect_view || cur_dist < rect_view_distance) | 903 if (!rect_view || cur_dist < rect_view_distance) |
901 rect_view = this; | 904 rect_view = this; |
902 } | 905 } |
903 | 906 |
904 return rect_view ? rect_view : point_view; | 907 return rect_view ? rect_view : point_view; |
905 } | 908 } |
906 | 909 |
| 910 bool View::CanProcessEventsWithinSubtree() const { |
| 911 return true; |
| 912 } |
| 913 |
907 View* View::GetTooltipHandlerForPoint(const gfx::Point& point) { | 914 View* View::GetTooltipHandlerForPoint(const gfx::Point& point) { |
908 if (!HitTestPoint(point)) | 915 if (!HitTestPoint(point)) |
909 return NULL; | 916 return NULL; |
910 | 917 |
911 // Walk the child Views recursively looking for the View that most | 918 // Walk the child Views recursively looking for the View that most |
912 // tightly encloses the specified point. | 919 // tightly encloses the specified point. |
913 for (int i = child_count() - 1; i >= 0; --i) { | 920 for (int i = child_count() - 1; i >= 0; --i) { |
914 View* child = child_at(i); | 921 View* child = child_at(i); |
915 if (!child->visible()) | 922 if (!child->visible()) |
916 continue; | 923 continue; |
917 | 924 |
| 925 if (!child->CanProcessEventsWithinSubtree()) |
| 926 continue; |
| 927 |
918 gfx::Point point_in_child_coords(point); | 928 gfx::Point point_in_child_coords(point); |
919 ConvertPointToTarget(this, child, &point_in_child_coords); | 929 ConvertPointToTarget(this, child, &point_in_child_coords); |
920 View* handler = child->GetTooltipHandlerForPoint(point_in_child_coords); | 930 View* handler = child->GetTooltipHandlerForPoint(point_in_child_coords); |
921 if (handler) | 931 if (handler) |
922 return handler; | 932 return handler; |
923 } | 933 } |
924 return this; | 934 return this; |
925 } | 935 } |
926 | 936 |
927 gfx::NativeCursor View::GetCursor(const ui::MouseEvent& event) { | 937 gfx::NativeCursor View::GetCursor(const ui::MouseEvent& event) { |
(...skipping 1562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2490 // Message the RootView to do the drag and drop. That way if we're removed | 2500 // Message the RootView to do the drag and drop. That way if we're removed |
2491 // the RootView can detect it and avoid calling us back. | 2501 // the RootView can detect it and avoid calling us back. |
2492 gfx::Point widget_location(event.location()); | 2502 gfx::Point widget_location(event.location()); |
2493 ConvertPointToWidget(this, &widget_location); | 2503 ConvertPointToWidget(this, &widget_location); |
2494 widget->RunShellDrag(this, data, widget_location, drag_operations, source); | 2504 widget->RunShellDrag(this, data, widget_location, drag_operations, source); |
2495 // WARNING: we may have been deleted. | 2505 // WARNING: we may have been deleted. |
2496 return true; | 2506 return true; |
2497 } | 2507 } |
2498 | 2508 |
2499 } // namespace views | 2509 } // namespace views |
OLD | NEW |