OLD | NEW |
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 "mojo/services/window_manager/view_target.h" | 5 #include "mojo/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 "mojo/services/window_manager/view_targeter.h" | 10 #include "mojo/services/window_manager/view_targeter.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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(View* view_to_wrap) |
| 137 : view_(view_to_wrap), focus_controller_(nullptr) { |
137 DCHECK(view_->GetLocalProperty(kViewTargetKey) == nullptr); | 138 DCHECK(view_->GetLocalProperty(kViewTargetKey) == nullptr); |
138 view_->SetLocalProperty(kViewTargetKey, this); | 139 view_->SetLocalProperty(kViewTargetKey, this); |
139 } | 140 } |
140 | 141 |
141 bool ViewTarget::ConvertPointForAncestor(const ViewTarget* ancestor, | 142 bool ViewTarget::ConvertPointForAncestor(const ViewTarget* ancestor, |
142 gfx::Point* point) const { | 143 gfx::Point* point) const { |
143 gfx::Vector2d offset; | 144 gfx::Vector2d offset; |
144 bool result = GetTargetOffsetRelativeTo(ancestor, &offset); | 145 bool result = GetTargetOffsetRelativeTo(ancestor, &offset); |
145 *point += offset; | 146 *point += offset; |
146 return result; | 147 return result; |
(...skipping 11 matching lines...) Expand all Loading... |
158 gfx::Vector2d* offset) const { | 159 gfx::Vector2d* offset) const { |
159 const ViewTarget* v = this; | 160 const ViewTarget* v = this; |
160 for (; v && v != ancestor; v = v->GetParent()) { | 161 for (; v && v != ancestor; v = v->GetParent()) { |
161 gfx::Rect bounds = v->GetBounds(); | 162 gfx::Rect bounds = v->GetBounds(); |
162 *offset += gfx::Vector2d(bounds.x(), bounds.y()); | 163 *offset += gfx::Vector2d(bounds.x(), bounds.y()); |
163 } | 164 } |
164 return v == ancestor; | 165 return v == ancestor; |
165 } | 166 } |
166 | 167 |
167 } // namespace mojo | 168 } // namespace mojo |
OLD | NEW |