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 #include "services/viz/hit_test/public/interfaces/hit_test_region_list.mojom.h" | |
8 | |
9 namespace viz { | |
10 | |
11 HitTestQuery::HitTestQuery() = default; | |
12 | |
13 HitTestQuery::~HitTestQuery() = default; | |
14 | |
15 Target HitTestQuery::FindTargetForLocation(const gfx::Point& location_in_root) { | |
16 Target target; | |
17 if (!aggregated_hit_test_region_list_size_) | |
18 return target; | |
19 | |
20 FindTargetInRegionForLocation(location_in_root, | |
21 aggregated_hit_test_region_list_, &target); | |
22 return target; | |
rjkroege
2017/07/18 21:38:49
I am generally opposed to return-by-value here. Th
| |
23 } | |
24 | |
25 bool HitTestQuery::FindTargetInRegionForLocation( | |
26 const gfx::Point& location_in_parent, | |
27 AggregatedHitTestRegion* region, | |
28 Target* target) const { | |
29 gfx::Point location_transformed(location_in_parent); | |
30 region->transform.TransformPoint(&location_transformed); | |
rjkroege
2017/07/18 21:38:49
region data cannot be trusted. Please file a bug f
sadrul
2017/07/19 15:40:08
The TODO can probably go in the SetAggregatedHitTe
sadrul
2017/07/19 15:40:08
Can you explain why you are doing the transform he
riajiang
2017/07/19 17:45:55
Done. http://crbug.com/746470
riajiang
2017/07/19 17:45:55
Because we need to transform from parent's coordin
riajiang
2017/07/19 19:22:14
As discussed offline, transformation needed here.
| |
31 if (!region->rect.Contains(location_transformed)) | |
32 return false; | |
33 | |
34 AggregatedHitTestRegion* child_region = region + 1; | |
35 AggregatedHitTestRegion* child_region_end = region + region->child_count; | |
36 if (child_region_end > (aggregated_hit_test_region_list_ + | |
sadrul
2017/07/19 15:40:08
Should be >= here, right?
riajiang
2017/07/19 17:45:55
This is > now since I changed |child_region_end| b
| |
37 aggregated_hit_test_region_list_size_)) { | |
38 return false; | |
39 } | |
40 | |
41 gfx::Point location_in_target(location_transformed); | |
42 location_in_target.Offset(-region->rect.x(), -region->rect.y()); | |
43 while (child_region <= child_region_end) { | |
sadrul
2017/07/19 15:40:08
Should be <
For the regular iterators, we exclude
riajiang
2017/07/19 17:45:55
Okay I see. Changed |child_region_end| to be |chil
| |
44 if (FindTargetInRegionForLocation(location_in_target, child_region, | |
45 target)) { | |
46 return true; | |
47 } | |
48 | |
49 child_region = child_region + child_region->child_count + 1; | |
rjkroege
2017/07/18 21:38:49
if any child_count > child_region_count, you need
riajiang
2017/07/19 17:45:55
Added in the bug.
| |
50 } | |
51 | |
52 if (region->flags & mojom::kHitTestMine) { | |
53 target->frame_sink_id = region->frame_sink_id; | |
rjkroege
2017/07/18 21:38:49
the viz/host has a window <-> framesink map. there
riajiang
2017/07/19 17:45:55
I didn't find it in viz/host - is it existing code
rjkroege
2017/07/19 18:01:25
so: viz-host is code in the mus-ws process. we nee
riajiang
2017/07/19 19:22:14
I see, will do when adding the map.
| |
54 target->location_in_target = location_in_target; | |
55 target->flags = region->flags; | |
rjkroege
2017/07/18 21:38:49
invalid flags should be reported as a security fau
riajiang
2017/07/19 17:45:55
Added in the bug.
| |
56 return true; | |
57 } | |
58 return false; | |
59 } | |
60 | |
61 } // namespace viz | |
OLD | NEW |