| 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 "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/view_manager/public/cpp/view.h" | 8 #include "mojo/services/view_manager/public/cpp/view.h" |
| 9 #include "mojo/services/view_manager/public/cpp/view_property.h" | 9 #include "mojo/services/view_manager/public/cpp/view_property.h" |
| 10 #include "services/window_manager/view_targeter.h" | 10 #include "services/window_manager/view_targeter.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 | 50 |
| 51 const ViewTarget* root_target = source->GetRoot(); | 51 const ViewTarget* root_target = source->GetRoot(); |
| 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() const { |
| 61 std::vector<ViewTarget*> targets; | 61 std::vector<ViewTarget*> targets; |
| 62 for (mojo::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 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 // supplied a TargetHandler, usually the aura::WindowDelegate. Here, we're | 112 // supplied a TargetHandler, usually the aura::WindowDelegate. Here, we're |
| 113 // just forwarding events to other Views which may be in other processes, so | 113 // just forwarding events to other Views which may be in other processes, so |
| 114 // always accept. | 114 // always accept. |
| 115 return true; | 115 return true; |
| 116 } | 116 } |
| 117 | 117 |
| 118 ui::EventTarget* ViewTarget::GetParentTarget() { | 118 ui::EventTarget* ViewTarget::GetParentTarget() { |
| 119 return TargetFromView(view_->parent()); | 119 return TargetFromView(view_->parent()); |
| 120 } | 120 } |
| 121 | 121 |
| 122 scoped_ptr<ui::EventTargetIterator> ViewTarget::GetChildIterator() { | 122 scoped_ptr<ui::EventTargetIterator> ViewTarget::GetChildIterator() const { |
| 123 return scoped_ptr<ui::EventTargetIterator>( | 123 return scoped_ptr<ui::EventTargetIterator>( |
| 124 new ui::CopyingEventTargetIteratorImpl<ViewTarget>(GetChildren())); | 124 new ui::CopyingEventTargetIteratorImpl<ViewTarget>(GetChildren())); |
| 125 } | 125 } |
| 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) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 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 window_manager | 167 } // namespace window_manager |
| OLD | NEW |