Chromium Code Reviews| 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 ViewTargeter* view_targeter = targeter(); | |
|
sadrul
2014/08/05 16:41:17
Do a DCHECK() here that GetWidget() is not null
tdanderson
2014/08/05 17:18:09
Done.
| |
| 1035 if (!view_targeter) | |
| 1036 view_targeter = GetWidget()->GetRootView()->targeter(); | |
| 1037 CHECK(view_targeter); | |
| 1038 return view_targeter; | |
| 1039 } | |
| 1040 | |
| 1033 bool View::CanAcceptEvent(const ui::Event& event) { | 1041 bool View::CanAcceptEvent(const ui::Event& event) { |
| 1034 return IsDrawn(); | 1042 return IsDrawn(); |
| 1035 } | 1043 } |
| 1036 | 1044 |
| 1037 ui::EventTarget* View::GetParentTarget() { | 1045 ui::EventTarget* View::GetParentTarget() { |
| 1038 return parent_; | 1046 return parent_; |
| 1039 } | 1047 } |
| 1040 | 1048 |
| 1041 scoped_ptr<ui::EventTargetIterator> View::GetChildIterator() const { | 1049 scoped_ptr<ui::EventTargetIterator> View::GetChildIterator() const { |
| 1042 return scoped_ptr<ui::EventTargetIterator>( | 1050 return scoped_ptr<ui::EventTargetIterator>( |
| (...skipping 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2263 if (HitTestPoint(location)) { | 2271 if (HitTestPoint(location)) { |
| 2264 ConvertPointToScreen(this, &location); | 2272 ConvertPointToScreen(this, &location); |
| 2265 ShowContextMenu(location, ui::MENU_SOURCE_MOUSE); | 2273 ShowContextMenu(location, ui::MENU_SOURCE_MOUSE); |
| 2266 } | 2274 } |
| 2267 } else { | 2275 } else { |
| 2268 OnMouseReleased(event); | 2276 OnMouseReleased(event); |
| 2269 } | 2277 } |
| 2270 // WARNING: we may have been deleted. | 2278 // WARNING: we may have been deleted. |
| 2271 } | 2279 } |
| 2272 | 2280 |
| 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 ---------------------------------------------------------------- | 2281 // Accelerators ---------------------------------------------------------------- |
| 2282 | 2282 |
| 2283 void View::RegisterPendingAccelerators() { | 2283 void View::RegisterPendingAccelerators() { |
| 2284 if (!accelerators_.get() || | 2284 if (!accelerators_.get() || |
| 2285 registered_accelerator_count_ == accelerators_->size()) { | 2285 registered_accelerator_count_ == accelerators_->size()) { |
| 2286 // No accelerators are waiting for registration. | 2286 // No accelerators are waiting for registration. |
| 2287 return; | 2287 return; |
| 2288 } | 2288 } |
| 2289 | 2289 |
| 2290 if (!GetWidget()) { | 2290 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 | 2420 // 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. | 2421 // the RootView can detect it and avoid calling us back. |
| 2422 gfx::Point widget_location(event.location()); | 2422 gfx::Point widget_location(event.location()); |
| 2423 ConvertPointToWidget(this, &widget_location); | 2423 ConvertPointToWidget(this, &widget_location); |
| 2424 widget->RunShellDrag(this, data, widget_location, drag_operations, source); | 2424 widget->RunShellDrag(this, data, widget_location, drag_operations, source); |
| 2425 // WARNING: we may have been deleted. | 2425 // WARNING: we may have been deleted. |
| 2426 return true; | 2426 return true; |
| 2427 } | 2427 } |
| 2428 | 2428 |
| 2429 } // namespace views | 2429 } // namespace views |
| OLD | NEW |