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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/ui/associates/resolved_hits.h
diff --git a/mojo/ui/associates/resolved_hits.h b/mojo/ui/associates/resolved_hits.h
new file mode 100644
index 0000000000000000000000000000000000000000..933ad09e80c6e3cace6d833384e89f90fbb38faa
--- /dev/null
+++ b/mojo/ui/associates/resolved_hits.h
@@ -0,0 +1,65 @@
+// Copyright 2016 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 MOJO_UI_ASSOCIATES_RESOLVED_HIT_TEST_H_
+#define MOJO_UI_ASSOCIATES_RESOLVED_HIT_TEST_H_
+
+#include <iosfwd>
+#include <memory>
+#include <unordered_map>
+
+#include "base/callback.h"
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "mojo/services/ui/views/interfaces/view_associates.mojom.h"
+
+namespace mojo {
+namespace ui {
+
+using SceneTokenValueToViewTokenMap =
+ std::unordered_map<uint32_t, mojo::ui::ViewTokenPtr>;
+
+// A hit test result combined with a map explaining how scenes are mapped
+// to views.
+class ResolvedHits {
+ public:
+ ResolvedHits(mojo::gfx::composition::HitTestResultPtr result);
+ ~ResolvedHits();
+
+ // The hit test result, not null unless |TakeResult| was called.
+ const mojo::gfx::composition::HitTestResult* result() const {
+ return result_.get();
+ }
+ mojo::gfx::composition::HitTestResultPtr TakeResult() {
+ return result_.Pass();
+ }
+
+ // A map from scene token value to view token containing all scenes which
+ // could be resolved.
+ const SceneTokenValueToViewTokenMap& map() const { return map_; }
+
+ // Adds a mapping for the specified scene token value to a view token.
+ void AddMapping(uint32_t scene_token_value,
+ mojo::ui::ViewTokenPtr view_token);
+
+ private:
+ mojo::gfx::composition::HitTestResultPtr result_;
+ SceneTokenValueToViewTokenMap map_;
+
+ DISALLOW_COPY_AND_ASSIGN(ResolvedHits);
+};
+
+// Provides a resolved description of the hit test results, or null if the
+// hit test could not be performed at all.
+// TODO(jeffbrown): Would prefer to use |std::unique_ptr| here but it doesn't
+// play nice with base::Callback right now.
+using ResolvedHitsCallback = base::Callback<void(scoped_ptr<ResolvedHits>)>;
+
+std::ostream& operator<<(std::ostream& os, const mojo::ui::ResolvedHits& value);
+std::ostream& operator<<(std::ostream& os, const mojo::ui::ResolvedHits* value);
+
+} // namespace ui
+} // namespace mojo
+
+#endif // MOJO_UI_ASSOCIATES_RESOLVED_HIT_TEST_H_
« 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