| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "mojo/ui/associates/view_tree_hit_tester_client.h" | 5 #include "mojo/ui/associates/view_tree_hit_tester_client.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 | 9 |
| 10 namespace mojo { | 10 namespace mojo { |
| 11 namespace ui { | 11 namespace ui { |
| 12 | 12 |
| 13 ViewTreeHitTesterClient::ViewTreeHitTesterClient( | 13 ViewTreeHitTesterClient::ViewTreeHitTesterClient( |
| 14 const scoped_refptr<ViewInspectorClient>& view_inspector_client, | 14 const scoped_refptr<ViewInspectorClient>& view_inspector_client, |
| 15 mojo::ui::ViewTreeTokenPtr view_tree_token) | 15 mojo::ui::ViewTreeTokenPtr view_tree_token) |
| 16 : view_inspector_client_(view_inspector_client), | 16 : view_inspector_client_(view_inspector_client), |
| 17 view_tree_token_(view_tree_token.Pass()), | 17 view_tree_token_(view_tree_token.Pass()), |
| 18 weak_factory_(this) { | 18 weak_factory_(this) { |
| 19 DCHECK(view_inspector_client_); | 19 DCHECK(view_inspector_client_); |
| 20 DCHECK(view_tree_token_); | 20 DCHECK(view_tree_token_); |
| 21 | 21 |
| 22 UpdateHitTester(); | 22 UpdateHitTester(); |
| 23 } | 23 } |
| 24 | 24 |
| 25 ViewTreeHitTesterClient::~ViewTreeHitTesterClient() {} | 25 ViewTreeHitTesterClient::~ViewTreeHitTesterClient() {} |
| 26 | 26 |
| 27 void ViewTreeHitTesterClient::HitTest(mojo::PointPtr point, | 27 void ViewTreeHitTesterClient::HitTest(mojo::PointFPtr point, |
| 28 const ResolvedHitsCallback& callback) { | 28 const ResolvedHitsCallback& callback) { |
| 29 if (!hit_tester_) { | 29 if (!hit_tester_) { |
| 30 callback.Run(nullptr); | 30 callback.Run(nullptr); |
| 31 return; | 31 return; |
| 32 } | 32 } |
| 33 | 33 |
| 34 // TODO(jeffbrown): Here we are assuming that the hit test callbacks will be | 34 // TODO(jeffbrown): Here we are assuming that the hit test callbacks will be |
| 35 // invoked in FIFO order. It might be a good idea to eliminate that | 35 // invoked in FIFO order. It might be a good idea to eliminate that |
| 36 // assumption. | 36 // assumption. |
| 37 pending_callbacks_.push(callback); | 37 pending_callbacks_.push(callback); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 83 |
| 84 void ViewTreeHitTesterClient::OnHitTesterDied() { | 84 void ViewTreeHitTesterClient::OnHitTesterDied() { |
| 85 ReleaseHitTester(); | 85 ReleaseHitTester(); |
| 86 | 86 |
| 87 if (!hit_tester_changed_callback_.is_null()) | 87 if (!hit_tester_changed_callback_.is_null()) |
| 88 hit_tester_changed_callback_.Run(); | 88 hit_tester_changed_callback_.Run(); |
| 89 } | 89 } |
| 90 | 90 |
| 91 } // namespace ui | 91 } // namespace ui |
| 92 } // namespace mojo | 92 } // namespace mojo |
| OLD | NEW |