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

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

Issue 1894383002: MacViews: Implement Full Keyboard Access. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@SetFocusBehavior
Patch Set: Rebased. 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 #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 #include <memory> 10 #include <memory>
(...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. In case the stored view is no longer focusable,
205 // 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 bool keyboard_accessible() const { return keyboard_accessible_; }
330
331 // Updates |keyboard_accessible_| to the given value and advances focus if
332 // necessary.
333 void SetKeyboardAccessible(bool keyboard_accessible);
334
328 private: 335 private:
329 // Returns the focusable view found in the FocusTraversable specified starting 336 // Returns the focusable view found in the FocusTraversable specified starting
330 // at the specified view. This traverses down along the FocusTraversable 337 // at the specified view. This traverses down along the FocusTraversable
331 // hierarchy. 338 // hierarchy.
332 // Returns NULL if no focusable view were found. 339 // Returns NULL if no focusable view were found.
333 View* FindFocusableView(FocusTraversable* focus_traversable, 340 View* FindFocusableView(FocusTraversable* focus_traversable,
334 View* starting_view, 341 View* starting_view,
335 bool reverse); 342 bool reverse);
336 343
337 // Process arrow key traversal. Returns true if the event has been consumed 344 // Process arrow key traversal. Returns true if the event has been consumed
338 // and should not be processed further. 345 // and should not be processed further.
339 bool ProcessArrowKeyTraversal(const ui::KeyEvent& event); 346 bool ProcessArrowKeyTraversal(const ui::KeyEvent& event);
340 347
348 // Returns true if the |view| is accessibility focusable (checking
349 // IsFocusable() if |keyboard_accessible_| is false on Mac).
350 bool IsFocusable(View* view) const;
351
341 // Whether arrow key traversal is enabled. 352 // Whether arrow key traversal is enabled.
342 static bool arrow_key_traversal_enabled_; 353 static bool arrow_key_traversal_enabled_;
343 354
344 // The top-level Widget this FocusManager is associated with. 355 // The top-level Widget this FocusManager is associated with.
345 Widget* widget_; 356 Widget* widget_;
346 357
347 // The object which handles an accelerator when |accelerator_manager_| doesn't 358 // The object which handles an accelerator when |accelerator_manager_| doesn't
348 // handle it. 359 // handle it.
349 std::unique_ptr<FocusManagerDelegate> delegate_; 360 std::unique_ptr<FocusManagerDelegate> delegate_;
350 361
(...skipping 12 matching lines...) Expand all
363 374
364 // The reason why the focus most recently changed. 375 // The reason why the focus most recently changed.
365 FocusChangeReason focus_change_reason_; 376 FocusChangeReason focus_change_reason_;
366 377
367 // The list of registered FocusChange listeners. 378 // The list of registered FocusChange listeners.
368 base::ObserverList<FocusChangeListener, true> focus_change_listeners_; 379 base::ObserverList<FocusChangeListener, true> focus_change_listeners_;
369 380
370 // See description above getter. 381 // See description above getter.
371 bool is_changing_focus_; 382 bool is_changing_focus_;
372 383
384 // This is true if full keyboard accessibility is needed. This causes
385 // IsAccessibilityFocusable() to be checked rather than IsFocusable(). This
386 // can be set depending on platform constraints. FocusSearch uses this in
387 // addition to its own accessibility mode, which handles accessibility at the
388 // FocusTraversable level. Currently only used on Mac, when Full Keyboard
389 // access is enabled.
390 // Default value is false.
391 bool keyboard_accessible_;
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