Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(517)

Side by Side Diff: mojo/ui/associates/view_tree_hit_tester_client.h

Issue 1778593003: Mozart: Add helpers for building view associates. (Closed) Base URL: git@github.com:domokit/mojo.git@moz-6
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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 #ifndef MOJO_UI_ASSOCIATES_VIEW_TREE_HIT_TESTER_CLIENT_H_
6 #define MOJO_UI_ASSOCIATES_VIEW_TREE_HIT_TESTER_CLIENT_H_
7
8 #include <queue>
9
10 #include "base/callback.h"
11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/weak_ptr.h"
14 #include "mojo/services/gfx/composition/interfaces/hit_tests.mojom.h"
15 #include "mojo/services/ui/views/interfaces/view_trees.mojom.h"
16 #include "mojo/ui/associates/view_inspector_client.h"
17
18 namespace mojo {
19 namespace ui {
20
21 // Holds a hit tester for a view tree and keeps it up to date as the
22 // hit tester is invalidated.
23 class ViewTreeHitTesterClient
24 : public base::RefCounted<ViewTreeHitTesterClient> {
25 public:
26 ViewTreeHitTesterClient(
27 const scoped_refptr<ViewInspectorClient>& view_inspector_client,
28 mojo::ui::ViewTreeTokenPtr view_tree_token);
29
30 // Performs a hit test for the specified point then invokes the callback.
31 // Note: May invoke the callback immediately if no remote calls were required.
32 void HitTest(mojo::PointPtr point, const ResolvedHitsCallback& callback);
33
34 // Sets a callback to invoke when the hit tester changes.
35 void set_hit_tester_changed_callback(const base::Closure& callback) {
36 hit_tester_changed_callback_ = callback;
37 }
38
39 private:
40 friend class base::RefCounted<ViewTreeHitTesterClient>;
41 ~ViewTreeHitTesterClient();
42
43 void OnHitTestResult(mojo::gfx::composition::HitTestResultPtr result);
44
45 void UpdateHitTester();
46 void ReleaseHitTester();
47 void OnHitTesterInvalidated(bool renderer_changed);
48 void OnHitTesterDied();
49
50 scoped_refptr<ViewInspectorClient> view_inspector_client_;
51 mojo::ui::ViewTreeTokenPtr view_tree_token_;
52 mojo::gfx::composition::HitTesterPtr hit_tester_;
53
54 std::queue<ResolvedHitsCallback> pending_callbacks_;
55 base::Closure hit_tester_changed_callback_;
56
57 base::WeakPtrFactory<ViewTreeHitTesterClient> weak_factory_;
58
59 DISALLOW_COPY_AND_ASSIGN(ViewTreeHitTesterClient);
60 };
61
62 } // namespace ui
63 } // namespace mojo
64
65 #endif // MOJO_UI_ASSOCIATES_VIEW_TREE_HIT_TESTER_CLIENT_H_
OLDNEW
« no previous file with comments | « mojo/ui/associates/view_inspector_client_apptest.cc ('k') | mojo/ui/associates/view_tree_hit_tester_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698