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

Side by Side Diff: mojo/ui/associates/resolved_hits.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
« no previous file with comments | « mojo/ui/associates/mock_view_inspector.cc ('k') | mojo/ui/associates/resolved_hits.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_RESOLVED_HIT_TEST_H_
6 #define MOJO_UI_ASSOCIATES_RESOLVED_HIT_TEST_H_
7
8 #include <iosfwd>
9 #include <memory>
10 #include <unordered_map>
11
12 #include "base/callback.h"
13 #include "base/macros.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "mojo/services/ui/views/interfaces/view_associates.mojom.h"
16
17 namespace mojo {
18 namespace ui {
19
20 using SceneTokenValueToViewTokenMap =
21 std::unordered_map<uint32_t, mojo::ui::ViewTokenPtr>;
22
23 // A hit test result combined with a map explaining how scenes are mapped
24 // to views.
25 class ResolvedHits {
26 public:
27 ResolvedHits(mojo::gfx::composition::HitTestResultPtr result);
28 ~ResolvedHits();
29
30 // The hit test result, not null unless |TakeResult| was called.
31 const mojo::gfx::composition::HitTestResult* result() const {
32 return result_.get();
33 }
34 mojo::gfx::composition::HitTestResultPtr TakeResult() {
35 return result_.Pass();
36 }
37
38 // A map from scene token value to view token containing all scenes which
39 // could be resolved.
40 const SceneTokenValueToViewTokenMap& map() const { return map_; }
41
42 // Adds a mapping for the specified scene token value to a view token.
43 void AddMapping(uint32_t scene_token_value,
44 mojo::ui::ViewTokenPtr view_token);
45
46 private:
47 mojo::gfx::composition::HitTestResultPtr result_;
48 SceneTokenValueToViewTokenMap map_;
49
50 DISALLOW_COPY_AND_ASSIGN(ResolvedHits);
51 };
52
53 // Provides a resolved description of the hit test results, or null if the
54 // hit test could not be performed at all.
55 // TODO(jeffbrown): Would prefer to use |std::unique_ptr| here but it doesn't
56 // play nice with base::Callback right now.
57 using ResolvedHitsCallback = base::Callback<void(scoped_ptr<ResolvedHits>)>;
58
59 std::ostream& operator<<(std::ostream& os, const mojo::ui::ResolvedHits& value);
60 std::ostream& operator<<(std::ostream& os, const mojo::ui::ResolvedHits* value);
61
62 } // namespace ui
63 } // namespace mojo
64
65 #endif // MOJO_UI_ASSOCIATES_RESOLVED_HIT_TEST_H_
OLDNEW
« no previous file with comments | « mojo/ui/associates/mock_view_inspector.cc ('k') | mojo/ui/associates/resolved_hits.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698