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 #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 Loading... | |
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, |
tapted
2016/03/15 05:05:32
nit: no comma after 'case'
karandeepb
2016/03/17 07:24:46
Done.
| |
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 Loading... | |
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 focusable (checking | |
349 // IsAccessibilityFocusable() if |keyboard_accessible_ | is true). |view| | |
tapted
2016/03/15 05:05:32
nit: spacing after keyboard_accessible_
Also I th
karandeepb
2016/03/17 07:24:47
Done.
| |
350 // must not be null. | |
351 bool IsFocusable(View* view) const; | |
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 Loading... | |
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 which causes | |
tapted
2016/03/15 05:05:32
nit: True if full keyboard accessibility is needed
karandeepb
2016/03/17 07:24:46
Done.
| |
386 // IsAccessibilityFocusable() to be checked rather than IsFocusable(). This | |
387 // can be set depending on platform constraints. For example, on Mac, this is | |
388 // true when Full Keyboard Access mode is on. FocusSearch uses this in | |
389 // addition to its own accessibility mode, which handles accessibility at the | |
390 // FocusTraversable level. 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_ |
OLD | NEW |