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()) | 852 if (!child->CanProcessEventsWithinSubtree()) |
sadrul
2014/06/12 20:28:49
Should this also move up to the beginning of the f
tdanderson
2014/06/12 23:37:03
No, since that would change existing behaviour. CP
| |
853 continue; | 853 continue; |
854 | 854 |
855 // Ignore any children which are invisible or do not intersect |rect|. | 855 // Ignore any children which are invisible or do not intersect |rect|. |
856 if (!child->visible()) | 856 if (!child->visible()) |
857 continue; | 857 continue; |
858 gfx::RectF rect_in_child_coords_f(rect); | 858 gfx::RectF rect_in_child_coords_f(rect); |
859 ConvertRectToTarget(this, child, &rect_in_child_coords_f); | 859 ConvertRectToTarget(this, child, &rect_in_child_coords_f); |
860 gfx::Rect rect_in_child_coords = gfx::ToEnclosingRect( | 860 gfx::Rect rect_in_child_coords = gfx::ToEnclosingRect( |
861 rect_in_child_coords_f); | 861 rect_in_child_coords_f); |
862 if (!child->HitTestRect(rect_in_child_coords)) | 862 if (!child->HitTestRect(rect_in_child_coords)) |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
905 } | 905 } |
906 | 906 |
907 return rect_view ? rect_view : point_view; | 907 return rect_view ? rect_view : point_view; |
908 } | 908 } |
909 | 909 |
910 bool View::CanProcessEventsWithinSubtree() const { | 910 bool View::CanProcessEventsWithinSubtree() const { |
911 return true; | 911 return true; |
912 } | 912 } |
913 | 913 |
914 View* View::GetTooltipHandlerForPoint(const gfx::Point& point) { | 914 View* View::GetTooltipHandlerForPoint(const gfx::Point& point) { |
915 if (!HitTestPoint(point)) | 915 if (!HitTestPoint(point) || !CanProcessEventsWithinSubtree()) |
916 return NULL; | 916 return NULL; |
917 | 917 |
918 // Walk the child Views recursively looking for the View that most | 918 // Walk the child Views recursively looking for the View that most |
919 // tightly encloses the specified point. | 919 // tightly encloses the specified point. |
920 for (int i = child_count() - 1; i >= 0; --i) { | 920 for (int i = child_count() - 1; i >= 0; --i) { |
921 View* child = child_at(i); | 921 View* child = child_at(i); |
922 if (!child->visible()) | 922 if (!child->visible()) |
923 continue; | 923 continue; |
924 | 924 |
925 if (!child->CanProcessEventsWithinSubtree()) | |
926 continue; | |
927 | |
928 gfx::Point point_in_child_coords(point); | 925 gfx::Point point_in_child_coords(point); |
929 ConvertPointToTarget(this, child, &point_in_child_coords); | 926 ConvertPointToTarget(this, child, &point_in_child_coords); |
930 View* handler = child->GetTooltipHandlerForPoint(point_in_child_coords); | 927 View* handler = child->GetTooltipHandlerForPoint(point_in_child_coords); |
931 if (handler) | 928 if (handler) |
932 return handler; | 929 return handler; |
933 } | 930 } |
934 return this; | 931 return this; |
935 } | 932 } |
936 | 933 |
937 gfx::NativeCursor View::GetCursor(const ui::MouseEvent& event) { | 934 gfx::NativeCursor View::GetCursor(const ui::MouseEvent& event) { |
(...skipping 1562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2500 // Message the RootView to do the drag and drop. That way if we're removed | 2497 // Message the RootView to do the drag and drop. That way if we're removed |
2501 // the RootView can detect it and avoid calling us back. | 2498 // the RootView can detect it and avoid calling us back. |
2502 gfx::Point widget_location(event.location()); | 2499 gfx::Point widget_location(event.location()); |
2503 ConvertPointToWidget(this, &widget_location); | 2500 ConvertPointToWidget(this, &widget_location); |
2504 widget->RunShellDrag(this, data, widget_location, drag_operations, source); | 2501 widget->RunShellDrag(this, data, widget_location, drag_operations, source); |
2505 // WARNING: we may have been deleted. | 2502 // WARNING: we may have been deleted. |
2506 return true; | 2503 return true; |
2507 } | 2504 } |
2508 | 2505 |
2509 } // namespace views | 2506 } // namespace views |
OLD | NEW |