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

Side by Side Diff: ui/views/view_targeter_delegate.cc

Issue 2561253002: [ash-md] Adds support for Z-order iteration in views::View (Closed)
Patch Set: [ash-md] Adds support for Z-order iteration in views::View (using GetChildrenOrderedByVisualOrder) Created 4 years 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.cc ('K') | « ui/views/view.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 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/view_targeter_delegate.h" 5 #include "ui/views/view_targeter_delegate.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 8
9 #include "ui/gfx/geometry/rect_conversions.h" 9 #include "ui/gfx/geometry/rect_conversions.h"
10 #include "ui/views/rect_based_targeting_utils.h" 10 #include "ui/views/rect_based_targeting_utils.h"
(...skipping 24 matching lines...) Expand all
35 // |rect_view_distance| is used to keep track of the distance 35 // |rect_view_distance| is used to keep track of the distance
36 // between the center point of |rect_view| and the center 36 // between the center point of |rect_view| and the center
37 // point of |rect|. 37 // point of |rect|.
38 View* rect_view = NULL; 38 View* rect_view = NULL;
39 int rect_view_distance = INT_MAX; 39 int rect_view_distance = INT_MAX;
40 40
41 // |point_view| represents the view that would have been returned 41 // |point_view| represents the view that would have been returned
42 // from this function call if point-based targeting were used. 42 // from this function call if point-based targeting were used.
43 View* point_view = NULL; 43 View* point_view = NULL;
44 44
45 for (int i = root->child_count() - 1; i >= 0; --i) { 45 View::Views children = root->GetChildrenOrderedByVisualOrder();
46 View* child = root->child_at(i); 46 DCHECK_EQ(root->child_count(), static_cast<int>(children.size()));
47 47 for (int i = children.size() - 1; i >= 0; --i) {
48 View* child = children[i];
48 if (!child->CanProcessEventsWithinSubtree()) 49 if (!child->CanProcessEventsWithinSubtree())
49 continue; 50 continue;
50 51
51 // Ignore any children which are invisible or do not intersect |rect|. 52 // Ignore any children which are invisible or do not intersect |rect|.
52 if (!child->visible()) 53 if (!child->visible())
53 continue; 54 continue;
54 gfx::RectF rect_in_child_coords_f(rect); 55 gfx::RectF rect_in_child_coords_f(rect);
55 View::ConvertRectToTarget(root, child, &rect_in_child_coords_f); 56 View::ConvertRectToTarget(root, child, &rect_in_child_coords_f);
56 gfx::Rect rect_in_child_coords = gfx::ToEnclosingRect( 57 gfx::Rect rect_in_child_coords = gfx::ToEnclosingRect(
57 rect_in_child_coords_f); 58 rect_in_child_coords_f);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 int cur_dist = views::DistanceSquaredFromCenterToPoint(touch_center, 98 int cur_dist = views::DistanceSquaredFromCenterToPoint(touch_center,
98 local_bounds); 99 local_bounds);
99 if (!rect_view || cur_dist < rect_view_distance) 100 if (!rect_view || cur_dist < rect_view_distance)
100 rect_view = root; 101 rect_view = root;
101 } 102 }
102 103
103 return rect_view ? rect_view : point_view; 104 return rect_view ? rect_view : point_view;
104 } 105 }
105 106
106 } // namespace views 107 } // namespace views
OLDNEW
« ui/views/view.cc ('K') | « ui/views/view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698