Index: components/viz/host/hit_test/hit_test_query.h |
diff --git a/components/viz/host/hit_test/hit_test_query.h b/components/viz/host/hit_test/hit_test_query.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1f76c87bdd0b4d0eb24d7c0577359b36af93e0c2 |
--- /dev/null |
+++ b/components/viz/host/hit_test/hit_test_query.h |
@@ -0,0 +1,62 @@ |
+// 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. |
+ |
+#ifndef COMPONENTS_VIZ_HOST_HIT_TEST_HIT_TEST_QUERY_H_ |
+#define COMPONENTS_VIZ_HOST_HIT_TEST_HIT_TEST_QUERY_H_ |
+ |
+#include <vector> |
+ |
+#include "base/macros.h" |
+#include "components/viz/common/display_hit_test_data.h" |
+#include "ui/gfx/geometry/point.h" |
+ |
+namespace viz { |
+namespace hit_test { |
+ |
+struct Target { |
+ cc::FrameSinkId id; |
+ // Coordinates in the coordinate system of the target FrameSinkId. |
+ gfx::Point location_in_target; |
+ // Different flags are defined in services/viz/public/interfaces/ |
+ // hit_test_data.mojom. |
+ uint32_t flags; |
+}; |
+ |
+// Finds the target for a given location based on DisplayHitTestDataList |
+// aggregated by HitTestComponent. |
+// TODO(riajiang): Handle 3d space cases correctly. |
+class HitTestQuery { |
+ public: |
+ HitTestQuery(); |
+ ~HitTestQuery(); |
+ |
+ // TODO(riajiang): Read from shmem directly once it's set up and delete this |
+ // function. For now, use fake data. |
+ void set_display_hit_test_data_list( |
+ DisplayHitTestDataList display_hit_test_data_list) { |
+ display_hit_test_data_list_ = std::move(display_hit_test_data_list); |
+ } |
+ |
+ // Finds Target for |location_in_root|, including the FrameSinkId of the |
+ // target, updated location in the coordinate system of the target and |
+ // hit-test flags for the target. |
+ Target FindTargetForLocation(const gfx::Point& location_in_root); |
+ |
+ private: |
+ // Helper function to find |target| for |location_in_parent| in the |region|, |
+ // returns true if a target is found and false otherwise. |location_in_parent| |
+ // is in the coordinate space of |region|'s parent. |
+ bool FindTargetInRegionForLocation(const gfx::Point& location_in_parent, |
+ DisplayHitTestData* region, |
+ Target* target) const; |
+ |
+ DisplayHitTestDataList display_hit_test_data_list_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(HitTestQuery); |
+}; |
+ |
+} // namespace hit_test |
+} // namespace viz |
+ |
+#endif // COMPONENTS_VIZ_HOST_HIT_TEST_HIT_TEST_QUERY_H_ |