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

Side by Side Diff: ui/views/focus/focus_manager.h

Issue 1690543004: MacViews: Implement Full Keyboard Access. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix FocusManagerTest.StoreFocusedView Created 4 years, 10 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 #ifndef UI_VIEWS_FOCUS_FOCUS_MANAGER_H_ 5 #ifndef UI_VIEWS_FOCUS_FOCUS_MANAGER_H_
6 #define UI_VIEWS_FOCUS_FOCUS_MANAGER_H_ 6 #define UI_VIEWS_FOCUS_FOCUS_MANAGER_H_
7 7
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 10
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 // attached to the window hierarchy anymore. 194 // attached to the window hierarchy anymore.
195 void ValidateFocusedView(); 195 void ValidateFocusedView();
196 196
197 // Stores the focused view. Used when the widget loses activation. 197 // Stores the focused view. Used when the widget loses activation.
198 // |clear_native_focus| indicates whether this should invoke ClearFocus(). 198 // |clear_native_focus| indicates whether this should invoke ClearFocus().
199 // Typically |true| should be passed in. 199 // Typically |true| should be passed in.
200 void StoreFocusedView(bool clear_native_focus); 200 void StoreFocusedView(bool clear_native_focus);
201 201
202 // Restore the view saved with a previous call to StoreFocusedView(). Used 202 // Restore the view saved with a previous call to StoreFocusedView(). Used
203 // when the widget becomes active. Returns true when the previous view was 203 // when the widget becomes active. Returns true when the previous view was
204 // successfully refocused - otherwise false. 204 // successfully refocused - otherwise false. In case, the stored view is no
205 // longer focusable, it advances focus and returns false.
205 bool RestoreFocusedView(); 206 bool RestoreFocusedView();
206 207
207 // Sets the |view| to be restored when calling RestoreFocusView. This is used 208 // Sets the |view| to be restored when calling RestoreFocusView. This is used
208 // to set where the focus should go on restoring a Window created without 209 // to set where the focus should go on restoring a Window created without
209 // focus being set. 210 // focus being set.
210 void SetStoredFocusView(View* view); 211 void SetStoredFocusView(View* view);
211 212
212 // Returns the View that either currently has focus, or if no view has focus 213 // Returns the View that either currently has focus, or if no view has focus
213 // the view that last had focus. 214 // the view that last had focus.
214 View* GetStoredFocusView(); 215 View* GetStoredFocusView();
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 // |starting_view| is NULL |starting_widget| is consuled to determine which 319 // |starting_view| is NULL |starting_widget| is consuled to determine which
319 // Widget to start from. See 320 // Widget to start from. See
320 // WidgetDelegate::ShouldAdvanceFocusToTopLevelWidget() for details. If both 321 // WidgetDelegate::ShouldAdvanceFocusToTopLevelWidget() for details. If both
321 // |starting_view| and |starting_widget| are NULL, traversal starts at 322 // |starting_view| and |starting_widget| are NULL, traversal starts at
322 // |widget_|. 323 // |widget_|.
323 View* GetNextFocusableView(View* starting_view, 324 View* GetNextFocusableView(View* starting_view,
324 Widget* starting_widget, 325 Widget* starting_widget,
325 bool reverse, 326 bool reverse,
326 bool dont_loop); 327 bool dont_loop);
327 328
329 // Returns keyboard_accessibility_.
330 bool IsKeyboardAccessibilityEnabled() { return keyboard_accessibility_; }
tapted 2016/02/23 03:01:19 for accessors like this, we just do bool keyboard
karandeepb 2016/03/15 02:19:50 Done.
331
332 // Updates keyboard_accessibility_ to the given value and advances focus if
tapted 2016/02/23 03:01:19 keyboard_accessibility_ -> |keyboard_accessibility
karandeepb 2016/03/15 02:19:50 Done.
333 // necessary.
334 void SetKeyboardAccessibility(bool keyboard_accessibility);
335
328 private: 336 private:
329 // Returns the focusable view found in the FocusTraversable specified starting 337 // Returns the focusable view found in the FocusTraversable specified starting
330 // at the specified view. This traverses down along the FocusTraversable 338 // at the specified view. This traverses down along the FocusTraversable
331 // hierarchy. 339 // hierarchy.
332 // Returns NULL if no focusable view were found. 340 // Returns NULL if no focusable view were found.
333 View* FindFocusableView(FocusTraversable* focus_traversable, 341 View* FindFocusableView(FocusTraversable* focus_traversable,
334 View* starting_view, 342 View* starting_view,
335 bool reverse); 343 bool reverse);
336 344
337 // Process arrow key traversal. Returns true if the event has been consumed 345 // Process arrow key traversal. Returns true if the event has been consumed
338 // and should not be processed further. 346 // and should not be processed further.
339 bool ProcessArrowKeyTraversal(const ui::KeyEvent& event); 347 bool ProcessArrowKeyTraversal(const ui::KeyEvent& event);
340 348
349 // Returns true if a view is not NULL and is focusable (checking
tapted 2016/02/23 03:01:20 NULL -> null
karandeepb 2016/03/15 02:19:51 Done.
350 // IsAccessibilityFocusable() if keyboard_accessibility_ is true).
tapted 2016/02/23 03:01:20 keyboard_accessibility_ -> |keyboard_accessibility
karandeepb 2016/03/15 02:19:50 Done.
351 bool IsFocusable(View* view);
tapted 2016/02/23 03:01:19 const method?
karandeepb 2016/03/15 02:19:50 Done.
352
341 // Whether arrow key traversal is enabled. 353 // Whether arrow key traversal is enabled.
342 static bool arrow_key_traversal_enabled_; 354 static bool arrow_key_traversal_enabled_;
343 355
344 // The top-level Widget this FocusManager is associated with. 356 // The top-level Widget this FocusManager is associated with.
345 Widget* widget_; 357 Widget* widget_;
346 358
347 // The object which handles an accelerator when |accelerator_manager_| doesn't 359 // The object which handles an accelerator when |accelerator_manager_| doesn't
348 // handle it. 360 // handle it.
349 scoped_ptr<FocusManagerDelegate> delegate_; 361 scoped_ptr<FocusManagerDelegate> delegate_;
350 362
(...skipping 12 matching lines...) Expand all
363 375
364 // The reason why the focus most recently changed. 376 // The reason why the focus most recently changed.
365 FocusChangeReason focus_change_reason_; 377 FocusChangeReason focus_change_reason_;
366 378
367 // The list of registered FocusChange listeners. 379 // The list of registered FocusChange listeners.
368 base::ObserverList<FocusChangeListener, true> focus_change_listeners_; 380 base::ObserverList<FocusChangeListener, true> focus_change_listeners_;
369 381
370 // See description above getter. 382 // See description above getter.
371 bool is_changing_focus_; 383 bool is_changing_focus_;
372 384
385 // This is true if full keyboard accessibility is needed and you want to
tapted 2016/02/23 03:01:20 `you want to check` sounds funny. Perhaps `FocusSe
karandeepb 2016/03/15 02:19:50 Done.
386 // check IsAccessibilityFocusable(), rather than IsFocusable(). This can be
387 // set depending on platform constraints, for example, on Mac, this is true
tapted 2016/02/23 03:01:20 `constraints, for example,` -> `constraints. For E
karandeepb 2016/03/15 02:19:50 Done.
388 // when Full Keyboard Access mode is on. FocusSearch uses this in addition to
389 // its own accessibility mode, which handles accessibility at the view level.
390 // Default value is false.
391 bool keyboard_accessibility_;
tapted 2016/02/23 03:01:20 maybe `keyboard_accessible_` is a better name
karandeepb 2016/03/15 02:19:50 Done.
392
373 DISALLOW_COPY_AND_ASSIGN(FocusManager); 393 DISALLOW_COPY_AND_ASSIGN(FocusManager);
374 }; 394 };
375 395
376 } // namespace views 396 } // namespace views
377 397
378 #endif // UI_VIEWS_FOCUS_FOCUS_MANAGER_H_ 398 #endif // UI_VIEWS_FOCUS_FOCUS_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698