OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. | 5 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. |
6 | 6 |
7 #include "ui/views/view.h" | 7 #include "ui/views/view.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cmath> | 10 #include <cmath> |
(...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1023 return widget ? widget->GetInputMethod() : NULL; | 1023 return widget ? widget->GetInputMethod() : NULL; |
1024 } | 1024 } |
1025 | 1025 |
1026 scoped_ptr<ViewTargeter> | 1026 scoped_ptr<ViewTargeter> |
1027 View::SetEventTargeter(scoped_ptr<ViewTargeter> targeter) { | 1027 View::SetEventTargeter(scoped_ptr<ViewTargeter> targeter) { |
1028 scoped_ptr<ViewTargeter> old_targeter = targeter_.Pass(); | 1028 scoped_ptr<ViewTargeter> old_targeter = targeter_.Pass(); |
1029 targeter_ = targeter.Pass(); | 1029 targeter_ = targeter.Pass(); |
1030 return old_targeter.Pass(); | 1030 return old_targeter.Pass(); |
1031 } | 1031 } |
1032 | 1032 |
| 1033 ViewTargeter* View::GetEffectiveViewTargeter() const { |
| 1034 DCHECK(GetWidget()); |
| 1035 ViewTargeter* view_targeter = targeter(); |
| 1036 if (!view_targeter) |
| 1037 view_targeter = GetWidget()->GetRootView()->targeter(); |
| 1038 CHECK(view_targeter); |
| 1039 return view_targeter; |
| 1040 } |
| 1041 |
1033 bool View::CanAcceptEvent(const ui::Event& event) { | 1042 bool View::CanAcceptEvent(const ui::Event& event) { |
1034 return IsDrawn(); | 1043 return IsDrawn(); |
1035 } | 1044 } |
1036 | 1045 |
1037 ui::EventTarget* View::GetParentTarget() { | 1046 ui::EventTarget* View::GetParentTarget() { |
1038 return parent_; | 1047 return parent_; |
1039 } | 1048 } |
1040 | 1049 |
1041 scoped_ptr<ui::EventTargetIterator> View::GetChildIterator() const { | 1050 scoped_ptr<ui::EventTargetIterator> View::GetChildIterator() const { |
1042 return scoped_ptr<ui::EventTargetIterator>( | 1051 return scoped_ptr<ui::EventTargetIterator>( |
(...skipping 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2263 if (HitTestPoint(location)) { | 2272 if (HitTestPoint(location)) { |
2264 ConvertPointToScreen(this, &location); | 2273 ConvertPointToScreen(this, &location); |
2265 ShowContextMenu(location, ui::MENU_SOURCE_MOUSE); | 2274 ShowContextMenu(location, ui::MENU_SOURCE_MOUSE); |
2266 } | 2275 } |
2267 } else { | 2276 } else { |
2268 OnMouseReleased(event); | 2277 OnMouseReleased(event); |
2269 } | 2278 } |
2270 // WARNING: we may have been deleted. | 2279 // WARNING: we may have been deleted. |
2271 } | 2280 } |
2272 | 2281 |
2273 ViewTargeter* View::GetEffectiveViewTargeter() const { | |
2274 ViewTargeter* view_targeter = targeter(); | |
2275 if (!view_targeter) | |
2276 view_targeter = GetWidget()->GetRootView()->targeter(); | |
2277 CHECK(view_targeter); | |
2278 return view_targeter; | |
2279 } | |
2280 | |
2281 // Accelerators ---------------------------------------------------------------- | 2282 // Accelerators ---------------------------------------------------------------- |
2282 | 2283 |
2283 void View::RegisterPendingAccelerators() { | 2284 void View::RegisterPendingAccelerators() { |
2284 if (!accelerators_.get() || | 2285 if (!accelerators_.get() || |
2285 registered_accelerator_count_ == accelerators_->size()) { | 2286 registered_accelerator_count_ == accelerators_->size()) { |
2286 // No accelerators are waiting for registration. | 2287 // No accelerators are waiting for registration. |
2287 return; | 2288 return; |
2288 } | 2289 } |
2289 | 2290 |
2290 if (!GetWidget()) { | 2291 if (!GetWidget()) { |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2420 // Message the RootView to do the drag and drop. That way if we're removed | 2421 // Message the RootView to do the drag and drop. That way if we're removed |
2421 // the RootView can detect it and avoid calling us back. | 2422 // the RootView can detect it and avoid calling us back. |
2422 gfx::Point widget_location(event.location()); | 2423 gfx::Point widget_location(event.location()); |
2423 ConvertPointToWidget(this, &widget_location); | 2424 ConvertPointToWidget(this, &widget_location); |
2424 widget->RunShellDrag(this, data, widget_location, drag_operations, source); | 2425 widget->RunShellDrag(this, data, widget_location, drag_operations, source); |
2425 // WARNING: we may have been deleted. | 2426 // WARNING: we may have been deleted. |
2426 return true; | 2427 return true; |
2427 } | 2428 } |
2428 | 2429 |
2429 } // namespace views | 2430 } // namespace views |
OLD | NEW |