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

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, 7 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 // |starting_view| is NULL |starting_widget| is consuled to determine which 313 // |starting_view| is NULL |starting_widget| is consuled to determine which
313 // Widget to start from. See 314 // Widget to start from. See
314 // WidgetDelegate::ShouldAdvanceFocusToTopLevelWidget() for details. If both 315 // WidgetDelegate::ShouldAdvanceFocusToTopLevelWidget() for details. If both
315 // |starting_view| and |starting_widget| are NULL, traversal starts at 316 // |starting_view| and |starting_widget| are NULL, traversal starts at
316 // |widget_|. 317 // |widget_|.
317 View* GetNextFocusableView(View* starting_view, 318 View* GetNextFocusableView(View* starting_view,
318 Widget* starting_widget, 319 Widget* starting_widget,
319 bool reverse, 320 bool reverse,
320 bool dont_loop); 321 bool dont_loop);
321 322
323 bool keyboard_accessible() const { return keyboard_accessible_; }
324
325 // Updates |keyboard_accessible_| to the given value and advances focus if
326 // necessary.
327 void SetKeyboardAccessible(bool keyboard_accessible);
328
322 private: 329 private:
323 // Returns the focusable view found in the FocusTraversable specified starting 330 // Returns the focusable view found in the FocusTraversable specified starting
324 // at the specified view. This traverses down along the FocusTraversable 331 // at the specified view. This traverses down along the FocusTraversable
325 // hierarchy. 332 // hierarchy.
326 // Returns NULL if no focusable view were found. 333 // Returns NULL if no focusable view were found.
327 View* FindFocusableView(FocusTraversable* focus_traversable, 334 View* FindFocusableView(FocusTraversable* focus_traversable,
328 View* starting_view, 335 View* starting_view,
329 bool reverse); 336 bool reverse);
330 337
331 // Process arrow key traversal. Returns true if the event has been consumed 338 // Process arrow key traversal. Returns true if the event has been consumed
332 // and should not be processed further. 339 // and should not be processed further.
333 bool ProcessArrowKeyTraversal(const ui::KeyEvent& event); 340 bool ProcessArrowKeyTraversal(const ui::KeyEvent& event);
334 341
342 // Whether |view| is currently focusable as per the platform's interpretation
343 // of |keyboard_accesible_|.
344 bool IsFocusable(View* view) const;
345
335 // Whether arrow key traversal is enabled. 346 // Whether arrow key traversal is enabled.
336 static bool arrow_key_traversal_enabled_; 347 static bool arrow_key_traversal_enabled_;
337 348
338 // The top-level Widget this FocusManager is associated with. 349 // The top-level Widget this FocusManager is associated with.
339 Widget* widget_; 350 Widget* widget_;
340 351
341 // The object which handles an accelerator when |accelerator_manager_| doesn't 352 // The object which handles an accelerator when |accelerator_manager_| doesn't
342 // handle it. 353 // handle it.
343 std::unique_ptr<FocusManagerDelegate> delegate_; 354 std::unique_ptr<FocusManagerDelegate> delegate_;
344 355
(...skipping 12 matching lines...) Expand all
357 368
358 // The reason why the focus most recently changed. 369 // The reason why the focus most recently changed.
359 FocusChangeReason focus_change_reason_; 370 FocusChangeReason focus_change_reason_;
360 371
361 // The list of registered FocusChange listeners. 372 // The list of registered FocusChange listeners.
362 base::ObserverList<FocusChangeListener, true> focus_change_listeners_; 373 base::ObserverList<FocusChangeListener, true> focus_change_listeners_;
363 374
364 // See description above getter. 375 // See description above getter.
365 bool is_changing_focus_; 376 bool is_changing_focus_;
366 377
378 // This is true if full keyboard accessibility is needed. This causes
379 // IsAccessibilityFocusable() to be checked rather than IsFocusable(). This
380 // can be set depending on platform constraints. FocusSearch uses this in
381 // addition to its own accessibility mode, which handles accessibility at the
382 // FocusTraversable level. Currently only used on Mac, when Full Keyboard
383 // access is enabled.
384 // Default value is false.
385 bool keyboard_accessible_;
386
367 DISALLOW_COPY_AND_ASSIGN(FocusManager); 387 DISALLOW_COPY_AND_ASSIGN(FocusManager);
368 }; 388 };
369 389
370 } // namespace views 390 } // namespace views
371 391
372 #endif // UI_VIEWS_FOCUS_FOCUS_MANAGER_H_ 392 #endif // UI_VIEWS_FOCUS_FOCUS_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698