Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "components/viz/host/hit_test/hit_test_query.h" | |
| 6 | |
| 7 namespace viz { | |
| 8 namespace hit_test { | |
| 9 | |
| 10 HitTestQuery::HitTestQuery() {} | |
| 11 | |
| 12 HitTestQuery::~HitTestQuery() {} | |
| 13 | |
| 14 Target HitTestQuery::FindTargetForLocation(const gfx::Point& location_in_root) { | |
| 15 // TODO(riajiang): Assumptions I'm making about the list of DisplayHitTestData | |
| 16 // 1. The list is in descending (back to front) z-order. | |
| 17 // 2. Children regions have their own FrameSinkId, but those that are just | |
| 18 // bounding boxes have the FrameSinkId of their parent. | |
| 19 // 3. Children count includes children of children. | |
| 20 // 4. After applying transform to the incoming point, point is in the same | |
| 21 // coordinate system as the bounds it is comparing against. | |
| 22 // For example, | |
| 23 // +e-------------+ | |
| 24 // | +c---------| | |
| 25 // | 1 |+a--+ | | |
| 26 // | || 2 | | | |
| 27 // | |+b--------| | |
| 28 // | || | | |
| 29 // | || 3 | | |
| 30 // +--------------+ | |
| 31 // In this case, after applying identity transform, 1 is in the coordinate | |
| 32 // system of e; apply the transfrom-from-e-to-c and transform-from-c-to-a | |
| 33 // then we get 2 in the coordinate system of a; apply the | |
| 34 // transfrom-from-e-to-c and transform-from-c-to-b then we get 3 in the | |
| 35 // coordinate system of b. | |
| 36 // 5. Transform contains transform for the position. | |
| 37 // 6. HIT_TEST_MINE means the region can receive events, i.e., not just a | |
| 38 // bounding box. | |
| 39 DCHECK(!display_hit_test_data_list_.empty()); | |
| 40 Target confirmed_target_so_far; | |
| 41 Target tentative_target_so_far; | |
| 42 tentative_target_so_far.location_in_target = location_in_root; | |
| 43 | |
| 44 for (DisplayHitTestData::const_iterator it = | |
| 45 display_hit_test_data_list_.begin(); | |
| 46 it != display_hit_test_data_list_.end(); ++it) { | |
|
sadrul
2017/06/16 17:09:51
Use for (const auto& region : display_hit_test_dat
| |
| 47 gfx::Point location(tentative_target_so_far.location_in_target); | |
| 48 if (!it->transform.IsIdentity()) | |
| 49 it->transform.TransformPoint(&location); | |
| 50 if (it->bounds.Contains(location)) { | |
| 51 tentative_target_so_far.id = it->id; | |
| 52 tentative_target_so_far.location_in_target = location; | |
| 53 tentative_target_so_far.flags = it->flags; | |
| 54 // TODO(riajiang): Check properly once HitTestRegionFlags is well defined | |
| 55 // after https://codereview.chromium.org/2908783002/. | |
| 56 // HIT_TEST_MINE is set to be true, which means it can receive events. | |
|
sadrul
2017/06/16 17:09:51
I would be OK with starting with a different set o
| |
| 57 if (it->flags) | |
| 58 confirmed_target_so_far = tentative_target_so_far; | |
|
sadrul
2017/06/16 17:09:51
It's not clear to me yet how kHitTestIgnore flag w
riajiang
2017/06/23 02:46:36
If it's kHitTestIgnore, then that child cannot rec
| |
| 59 if (!it->child_count) | |
| 60 break; | |
| 61 } else { | |
| 62 it += it->child_count; | |
| 63 } | |
| 64 } | |
| 65 return confirmed_target_so_far; | |
| 66 } | |
| 67 | |
| 68 } // namespace hit_test | |
| 69 } // namespace viz | |
| OLD | NEW |