Chromium Code Reviews| Index: components/viz/host/hit_test/hit_test_query.cc |
| diff --git a/components/viz/host/hit_test/hit_test_query.cc b/components/viz/host/hit_test/hit_test_query.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..22471f95975d593a37b15e02836c0c6f2f489c47 |
| --- /dev/null |
| +++ b/components/viz/host/hit_test/hit_test_query.cc |
| @@ -0,0 +1,53 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "components/viz/host/hit_test/hit_test_query.h" |
| + |
| +namespace viz { |
| +namespace hit_test { |
| + |
| +HitTestQuery::HitTestQuery() {} |
| + |
| +HitTestQuery::~HitTestQuery() {} |
| + |
| +Target HitTestQuery::FindTargetForLocation(const gfx::Point& location_in_root) { |
| + // TODO(riajiang): Assumptions I'm making about the list of DisplayHitTestData |
| + // 1. The list is in descending z-order. |
|
rjkroege
2017/06/15 19:58:35
so: larger indicies mean closer to the eyepoint?
riajiang
2017/06/16 02:56:54
Yes, I'm assuming that for now for the correct tra
|
| + // 2. Children entries have their own FrameSinkId, but those that are just |
|
rjkroege
2017/06/15 19:58:35
entries here mean "region"?
riajiang
2017/06/16 02:56:54
Yes. Updated.
|
| + // bounding boxes have the FrameSinkId of their parent. |
| + // 3. Children count includes children of children. |
| + // 4. After applying transform to the incoming point, point is in the same |
|
rjkroege
2017/06/15 19:58:35
you need ascii art. Or an associated .md file wit
riajiang
2017/06/16 02:56:54
Added ascii art example for now. Maybe will move a
|
| + // coordinate system as the bounds it is comparing against. |
| + // 5. Transform contains transform for the position. |
| + // 6. HIT_TEST_MINE means the region can receive events, i.e., not just a |
| + // bounding box. |
| + DCHECK(!display_hit_test_data_list_.empty()); |
| + Target confirmed_target_so_far; |
|
rjkroege
2017/06/15 19:58:35
You should use Target* instead of copying whole Ta
riajiang
2017/06/16 02:56:54
Do you mean confirmed_target_so_far is copying the
|
| + Target tentative_target_so_far; |
| + tentative_target_so_far.location_in_target = location_in_root; |
|
rjkroege
2017/06/15 19:58:35
I'd put a blank line here.
riajiang
2017/06/16 02:56:54
Done.
|
| + for (uint32_t i = 0; i < display_hit_test_data_list_.size(); ++i) { |
|
rjkroege
2017/06/15 19:58:35
use an iterator
riajiang
2017/06/16 02:56:54
Done.
|
| + DisplayHitTestData data = display_hit_test_data_list_[i]; |
| + gfx::Point location(tentative_target_so_far.location_in_target); |
|
gklassen
2017/06/15 19:51:20
What happens if we transform a point for a child r
riajiang
2017/06/16 02:56:54
Do you maybe mean that the point P does not match
|
| + if (!data.transform.IsIdentity()) |
| + data.transform.TransformPoint(&location); |
| + if (data.bounds.Contains(location)) { |
| + tentative_target_so_far.id = data.id; |
| + tentative_target_so_far.location_in_target = location; |
|
rjkroege
2017/06/15 19:58:36
I think it's safe to begin by thinking about this
|
| + tentative_target_so_far.flags = data.flags; |
| + // TODO(riajiang): Check properly once HitTestRegionFlags is well defined |
| + // after https://codereview.chromium.org/2908783002/. |
| + // HIT_TEST_MINE is set to be true, which means it can receive events. |
|
rjkroege
2017/06/15 19:58:35
if you encounter a region with hit_test_mine set,
riajiang
2017/06/16 02:56:54
We should also check child_count? If a region has
|
| + if (data.flags) |
| + confirmed_target_so_far = tentative_target_so_far; |
| + if (!data.child_count) |
| + break; |
| + } else { |
| + i += data.child_count; |
| + } |
| + } |
| + return confirmed_target_so_far; |
| +} |
| + |
| +} // namespace hit_test |
| +} // namespace viz |