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

Side by Side Diff: services/window_manager/view_target.cc

Issue 788453002: Put code in //services/window_manager in namespace window_manager (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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 | « services/window_manager/view_target.h ('k') | services/window_manager/view_target_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "services/window_manager/view_target.h" 5 #include "services/window_manager/view_target.h"
6 6
7 #include "mojo/converters/geometry/geometry_type_converters.h" 7 #include "mojo/converters/geometry/geometry_type_converters.h"
8 #include "mojo/services/public/cpp/view_manager/view.h" 8 #include "mojo/services/public/cpp/view_manager/view.h"
9 #include "mojo/services/public/cpp/view_manager/view_property.h" 9 #include "mojo/services/public/cpp/view_manager/view_property.h"
10 #include "services/window_manager/view_targeter.h" 10 #include "services/window_manager/view_targeter.h"
11 #include "services/window_manager/window_manager_app.h" 11 #include "services/window_manager/window_manager_app.h"
12 #include "ui/events/event.h" 12 #include "ui/events/event.h"
13 #include "ui/events/event_target_iterator.h" 13 #include "ui/events/event_target_iterator.h"
14 #include "ui/events/event_targeter.h" 14 #include "ui/events/event_targeter.h"
15 #include "ui/gfx/geometry/rect.h" 15 #include "ui/gfx/geometry/rect.h"
16 #include "ui/gfx/point3_f.h" 16 #include "ui/gfx/point3_f.h"
17 #include "ui/gfx/transform.h" 17 #include "ui/gfx/transform.h"
18 18
19 namespace mojo { 19 namespace window_manager {
20 20
21 namespace { 21 namespace {
22 22
23 DEFINE_OWNED_VIEW_PROPERTY_KEY(ViewTarget, kViewTargetKey, nullptr); 23 DEFINE_OWNED_VIEW_PROPERTY_KEY(ViewTarget, kViewTargetKey, nullptr);
24 24
25 } // namespace 25 } // namespace
26 26
27 ViewTarget::~ViewTarget() { 27 ViewTarget::~ViewTarget() {
28 } 28 }
29 29
30 // static 30 // static
31 ViewTarget* ViewTarget::TargetFromView(View* view) { 31 ViewTarget* ViewTarget::TargetFromView(mojo::View* view) {
32 if (!view) 32 if (!view)
33 return nullptr; 33 return nullptr;
34 34
35 ViewTarget* target = view->GetLocalProperty(kViewTargetKey); 35 ViewTarget* target = view->GetLocalProperty(kViewTargetKey);
36 if (target) 36 if (target)
37 return target; 37 return target;
38 38
39 return new ViewTarget(view); 39 return new ViewTarget(view);
40 } 40 }
41 41
(...skipping 10 matching lines...) Expand all
52 CHECK_EQ(root_target, target->GetRoot()); 52 CHECK_EQ(root_target, target->GetRoot());
53 53
54 if (source != root_target) 54 if (source != root_target)
55 source->ConvertPointForAncestor(root_target, point); 55 source->ConvertPointForAncestor(root_target, point);
56 if (target != root_target) 56 if (target != root_target)
57 target->ConvertPointFromAncestor(root_target, point); 57 target->ConvertPointFromAncestor(root_target, point);
58 } 58 }
59 59
60 std::vector<ViewTarget*> ViewTarget::GetChildren() { 60 std::vector<ViewTarget*> ViewTarget::GetChildren() {
61 std::vector<ViewTarget*> targets; 61 std::vector<ViewTarget*> targets;
62 for (View* child : view_->children()) 62 for (mojo::View* child : view_->children())
63 targets.push_back(TargetFromView(child)); 63 targets.push_back(TargetFromView(child));
64 return targets; 64 return targets;
65 } 65 }
66 66
67 const ViewTarget* ViewTarget::GetParent() const { 67 const ViewTarget* ViewTarget::GetParent() const {
68 return TargetFromView(view_->parent()); 68 return TargetFromView(view_->parent());
69 } 69 }
70 70
71 gfx::Rect ViewTarget::GetBounds() const { 71 gfx::Rect ViewTarget::GetBounds() const {
72 return view_->bounds().To<gfx::Rect>(); 72 return view_->bounds().To<gfx::Rect>();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 126
127 ui::EventTargeter* ViewTarget::GetEventTargeter() { 127 ui::EventTargeter* ViewTarget::GetEventTargeter() {
128 return targeter_.get(); 128 return targeter_.get();
129 } 129 }
130 130
131 void ViewTarget::ConvertEventToTarget(ui::EventTarget* target, 131 void ViewTarget::ConvertEventToTarget(ui::EventTarget* target,
132 ui::LocatedEvent* event) { 132 ui::LocatedEvent* event) {
133 event->ConvertLocationToTarget(this, static_cast<ViewTarget*>(target)); 133 event->ConvertLocationToTarget(this, static_cast<ViewTarget*>(target));
134 } 134 }
135 135
136 ViewTarget::ViewTarget(View* view_to_wrap) : view_(view_to_wrap) { 136 ViewTarget::ViewTarget(mojo::View* view_to_wrap) : view_(view_to_wrap) {
137 DCHECK(view_->GetLocalProperty(kViewTargetKey) == nullptr); 137 DCHECK(view_->GetLocalProperty(kViewTargetKey) == nullptr);
138 view_->SetLocalProperty(kViewTargetKey, this); 138 view_->SetLocalProperty(kViewTargetKey, this);
139 } 139 }
140 140
141 bool ViewTarget::ConvertPointForAncestor(const ViewTarget* ancestor, 141 bool ViewTarget::ConvertPointForAncestor(const ViewTarget* ancestor,
142 gfx::Point* point) const { 142 gfx::Point* point) const {
143 gfx::Vector2d offset; 143 gfx::Vector2d offset;
144 bool result = GetTargetOffsetRelativeTo(ancestor, &offset); 144 bool result = GetTargetOffsetRelativeTo(ancestor, &offset);
145 *point += offset; 145 *point += offset;
146 return result; 146 return result;
(...skipping 10 matching lines...) Expand all
157 bool ViewTarget::GetTargetOffsetRelativeTo(const ViewTarget* ancestor, 157 bool ViewTarget::GetTargetOffsetRelativeTo(const ViewTarget* ancestor,
158 gfx::Vector2d* offset) const { 158 gfx::Vector2d* offset) const {
159 const ViewTarget* v = this; 159 const ViewTarget* v = this;
160 for (; v && v != ancestor; v = v->GetParent()) { 160 for (; v && v != ancestor; v = v->GetParent()) {
161 gfx::Rect bounds = v->GetBounds(); 161 gfx::Rect bounds = v->GetBounds();
162 *offset += gfx::Vector2d(bounds.x(), bounds.y()); 162 *offset += gfx::Vector2d(bounds.x(), bounds.y());
163 } 163 }
164 return v == ancestor; 164 return v == ancestor;
165 } 165 }
166 166
167 } // namespace mojo 167 } // namespace window_manager
OLDNEW
« no previous file with comments | « services/window_manager/view_target.h ('k') | services/window_manager/view_target_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698