Chromium Code Reviews| Index: components/viz/hit_test/query/hit_test_query.cc |
| diff --git a/components/viz/hit_test/query/hit_test_query.cc b/components/viz/hit_test/query/hit_test_query.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6f8e7a73ed952cb83cc9aaabfb10ff60bcf328ea |
| --- /dev/null |
| +++ b/components/viz/hit_test/query/hit_test_query.cc |
| @@ -0,0 +1,43 @@ |
| +// 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/hit_test/query/hit_test_query.h" |
| + |
| +namespace viz { |
| +namespace hit_test { |
| + |
| +HitTestQuery::HitTestQuery() {} |
| + |
| +HitTestQuery::~HitTestQuery() {} |
| + |
| +Target HitTestQuery::FindTargetForLocation(const gfx::Point& location_in_root) { |
| + DCHECK(!display_hit_test_data_list_.empty()); |
| + Target confirmed_target_so_far; |
| + Target tentative_target_so_far; |
| + tentative_target_so_far.location_in_target = location_in_root; |
| + for (uint32_t i = 0; i < display_hit_test_data_list_.size(); ++i) { |
|
rjkroege
2017/06/12 17:17:24
there's a way to make a vector using a pre-defined
|
| + DisplayHitTestData data = display_hit_test_data_list_[i]; |
| + if (data.bounds.Contains(tentative_target_so_far.location_in_target)) { |
| + if (!data.transform.IsIdentity()) { |
| + DCHECK(data.transform.TransformPointReverse( |
|
rjkroege
2017/06/12 17:17:24
the statement inside the DCHECK is going to not ex
riajiang
2017/06/13 18:42:29
Ah I see! I'll move the transform out of DCHECK an
|
| + &tentative_target_so_far.location_in_target)); |
| + } |
| + tentative_target_so_far.id = data.id; |
| + 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. |
| + 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 |