Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: ui/views/view.cc

Issue 1690543004: MacViews: Implement Full Keyboard Access. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 View* View::GetPreviousFocusableView() { 1192 View* View::GetPreviousFocusableView() {
1193 return previous_focusable_view_; 1193 return previous_focusable_view_;
1194 } 1194 }
1195 1195
1196 void View::SetNextFocusableView(View* view) { 1196 void View::SetNextFocusableView(View* view) {
1197 if (view) 1197 if (view)
1198 view->previous_focusable_view_ = this; 1198 view->previous_focusable_view_ = this;
1199 next_focusable_view_ = view; 1199 next_focusable_view_ = view;
1200 } 1200 }
1201 1201
1202 void View::SetFocusable(bool focusable) { 1202 void View::SetFocusBehavior(FocusBehavior focus_behavior) {
1203 if (focusable_ == focusable) 1203 switch (focus_behavior) {
1204 return; 1204 case FocusBehavior::ALWAYS:
1205 1205 SetFocusable(true);
1206 focusable_ = focusable; 1206 SetAccessibilityFocusable(true);
1207 AdvanceFocusIfNecessary(); 1207 break;
1208 case FocusBehavior::NEVER:
1209 SetFocusable(false);
1210 SetAccessibilityFocusable(false);
1211 break;
1212 case FocusBehavior::ACCESSIBLE_ONLY:
1213 SetFocusable(false);
1214 SetAccessibilityFocusable(true);
1215 break;
1216 }
1208 } 1217 }
1209 1218
1210 bool View::IsFocusable() const { 1219 bool View::IsFocusable() const {
1211 return focusable_ && enabled_ && IsDrawn(); 1220 return focusable_ && enabled_ && IsDrawn();
1212 } 1221 }
1213 1222
1214 bool View::IsAccessibilityFocusable() const { 1223 bool View::IsAccessibilityFocusable() const {
1215 return (focusable_ || accessibility_focusable_) && enabled_ && IsDrawn(); 1224 return (focusable_ || accessibility_focusable_) && enabled_ && IsDrawn();
1216 } 1225 }
1217 1226
1218 void View::SetAccessibilityFocusable(bool accessibility_focusable) {
1219 if (accessibility_focusable_ == accessibility_focusable)
1220 return;
1221
1222 accessibility_focusable_ = accessibility_focusable;
1223 AdvanceFocusIfNecessary();
1224 }
1225
1226 FocusManager* View::GetFocusManager() { 1227 FocusManager* View::GetFocusManager() {
1227 Widget* widget = GetWidget(); 1228 Widget* widget = GetWidget();
1228 return widget ? widget->GetFocusManager() : NULL; 1229 return widget ? widget->GetFocusManager() : NULL;
1229 } 1230 }
1230 1231
1231 const FocusManager* View::GetFocusManager() const { 1232 const FocusManager* View::GetFocusManager() const {
1232 const Widget* widget = GetWidget(); 1233 const Widget* widget = GetWidget();
1233 return widget ? widget->GetFocusManager() : NULL; 1234 return widget ? widget->GetFocusManager() : NULL;
1234 } 1235 }
1235 1236
1236 void View::RequestFocus() { 1237 void View::RequestFocus() {
1237 FocusManager* focus_manager = GetFocusManager(); 1238 FocusManager* focus_manager = GetFocusManager();
1238 if (focus_manager && IsFocusable()) 1239 if (focus_manager && IsAccessibilityFocusable())
karandeepb 2016/04/18 11:29:02 Does changing IsFocusable to IsAccessibilityFocusa
1239 focus_manager->SetFocusedView(this); 1240 focus_manager->SetFocusedView(this);
1240 } 1241 }
1241 1242
1242 bool View::SkipDefaultKeyEventProcessing(const ui::KeyEvent& event) { 1243 bool View::SkipDefaultKeyEventProcessing(const ui::KeyEvent& event) {
1243 return false; 1244 return false;
1244 } 1245 }
1245 1246
1246 FocusTraversable* View::GetFocusTraversable() { 1247 FocusTraversable* View::GetFocusTraversable() {
1247 return NULL; 1248 return NULL;
1248 } 1249 }
(...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after
2304 if (!leave_data_intact) { 2305 if (!leave_data_intact) {
2305 accelerators_->clear(); 2306 accelerators_->clear();
2306 accelerators_.reset(); 2307 accelerators_.reset();
2307 } 2308 }
2308 registered_accelerator_count_ = 0; 2309 registered_accelerator_count_ = 0;
2309 } 2310 }
2310 } 2311 }
2311 2312
2312 // Focus ----------------------------------------------------------------------- 2313 // Focus -----------------------------------------------------------------------
2313 2314
2315 void View::SetFocusable(bool focusable) {
2316 if (focusable_ == focusable)
2317 return;
2318
2319 focusable_ = focusable;
2320 AdvanceFocusIfNecessary();
2321 }
2322
2323 void View::SetAccessibilityFocusable(bool accessibility_focusable) {
2324 if (accessibility_focusable_ == accessibility_focusable)
2325 return;
2326
2327 accessibility_focusable_ = accessibility_focusable;
2328 AdvanceFocusIfNecessary();
2329 }
2330
2314 void View::InitFocusSiblings(View* v, int index) { 2331 void View::InitFocusSiblings(View* v, int index) {
2315 int count = child_count(); 2332 int count = child_count();
2316 2333
2317 if (count == 0) { 2334 if (count == 0) {
2318 v->next_focusable_view_ = NULL; 2335 v->next_focusable_view_ = NULL;
2319 v->previous_focusable_view_ = NULL; 2336 v->previous_focusable_view_ = NULL;
2320 } else { 2337 } else {
2321 if (index == count) { 2338 if (index == count) {
2322 // We are inserting at the end, but the end of the child list may not be 2339 // We are inserting at the end, but the end of the child list may not be
2323 // the last focusable element. Let's try to find an element with no next 2340 // the last focusable element. Let's try to find an element with no next
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
2426 // Message the RootView to do the drag and drop. That way if we're removed 2443 // Message the RootView to do the drag and drop. That way if we're removed
2427 // the RootView can detect it and avoid calling us back. 2444 // the RootView can detect it and avoid calling us back.
2428 gfx::Point widget_location(event.location()); 2445 gfx::Point widget_location(event.location());
2429 ConvertPointToWidget(this, &widget_location); 2446 ConvertPointToWidget(this, &widget_location);
2430 widget->RunShellDrag(this, data, widget_location, drag_operations, source); 2447 widget->RunShellDrag(this, data, widget_location, drag_operations, source);
2431 // WARNING: we may have been deleted. 2448 // WARNING: we may have been deleted.
2432 return true; 2449 return true;
2433 } 2450 }
2434 2451
2435 } // namespace views 2452 } // namespace views
OLDNEW
« ui/views/view.h ('K') | « ui/views/view.h ('k') | ui/views/view_targeter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698