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 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1139 void View::ResetAccelerators() { | 1139 void View::ResetAccelerators() { |
1140 if (accelerators_.get()) | 1140 if (accelerators_.get()) |
1141 UnregisterAccelerators(false); | 1141 UnregisterAccelerators(false); |
1142 } | 1142 } |
1143 | 1143 |
1144 bool View::AcceleratorPressed(const ui::Accelerator& accelerator) { | 1144 bool View::AcceleratorPressed(const ui::Accelerator& accelerator) { |
1145 return false; | 1145 return false; |
1146 } | 1146 } |
1147 | 1147 |
1148 bool View::CanHandleAccelerators() const { | 1148 bool View::CanHandleAccelerators() const { |
1149 return enabled() && IsDrawn() && GetWidget() && GetWidget()->IsVisible(); | 1149 const Widget* widget = GetWidget(); |
1150 if (!enabled() || !IsDrawn() || !widget || !widget->IsVisible()) { | |
msw
2016/02/04 22:45:36
nit: curlies not needed
meacer
2016/02/09 20:33:32
Done.
| |
1151 return false; | |
1152 } | |
1153 #if defined(USE_AURA) | |
1154 // Aura windows have an associated FocusManagerEventHandler which adds | |
1155 // currently focused view as an event PreTarget. However, the focused view | |
1156 // isn't always the right view to handle accelerators: It should only | |
1157 // handle them when active. Only top level widgets can be active, so | |
1158 // for child widgets check if they are focused instead. | |
1159 bool child = GetWidget() && GetWidget()->GetTopLevelWidget() != GetWidget(); | |
msw
2016/02/04 22:45:36
nit: re-use |widget| here and below.
meacer
2016/02/09 20:33:32
Done.
| |
1160 bool focus_in_child = | |
1161 GetWidget() && | |
1162 GetWidget()->GetRootView()->Contains(GetFocusManager()->GetFocusedView()); | |
1163 if ((child && !focus_in_child) || (!child && !widget->IsActive())) { | |
msw
2016/02/04 22:45:36
nit: curlies not needed
meacer
2016/02/09 20:33:32
Done.
| |
1164 return false; | |
1165 } | |
1166 #endif | |
1167 return true; | |
1150 } | 1168 } |
1151 | 1169 |
1152 // Focus ----------------------------------------------------------------------- | 1170 // Focus ----------------------------------------------------------------------- |
1153 | 1171 |
1154 bool View::HasFocus() const { | 1172 bool View::HasFocus() const { |
1155 const FocusManager* focus_manager = GetFocusManager(); | 1173 const FocusManager* focus_manager = GetFocusManager(); |
1156 return focus_manager && (focus_manager->GetFocusedView() == this); | 1174 return focus_manager && (focus_manager->GetFocusedView() == this); |
1157 } | 1175 } |
1158 | 1176 |
1159 View* View::GetNextFocusableView() { | 1177 View* View::GetNextFocusableView() { |
(...skipping 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2404 // Message the RootView to do the drag and drop. That way if we're removed | 2422 // Message the RootView to do the drag and drop. That way if we're removed |
2405 // the RootView can detect it and avoid calling us back. | 2423 // the RootView can detect it and avoid calling us back. |
2406 gfx::Point widget_location(event.location()); | 2424 gfx::Point widget_location(event.location()); |
2407 ConvertPointToWidget(this, &widget_location); | 2425 ConvertPointToWidget(this, &widget_location); |
2408 widget->RunShellDrag(this, data, widget_location, drag_operations, source); | 2426 widget->RunShellDrag(this, data, widget_location, drag_operations, source); |
2409 // WARNING: we may have been deleted. | 2427 // WARNING: we may have been deleted. |
2410 return true; | 2428 return true; |
2411 } | 2429 } |
2412 | 2430 |
2413 } // namespace views | 2431 } // namespace views |
OLD | NEW |