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

Unified Diff: ui/views/view.h

Issue 1898633004: Views: Add new SetFocusBehavior method. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/touchui/touch_selection_menu_runner_views.cc ('k') | ui/views/view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/view.h
diff --git a/ui/views/view.h b/ui/views/view.h
index 5a50125a9f4d8d95c6bca1b82df8836550f62fa6..9bd74aadcf3e9424d2ef4c2307d51fe4ed5bb7d4 100644
--- a/ui/views/view.h
+++ b/ui/views/view.h
@@ -116,6 +116,18 @@ class VIEWS_EXPORT View : public ui::LayerDelegate,
public:
typedef std::vector<View*> Views;
+ enum class FocusBehavior {
+ // Use when the view is never focusable. Default.
tapted 2016/04/21 05:33:06 nit: view->View (2 others below)
karandeepb 2016/04/21 10:33:33 Done.
+ NEVER,
+
+ // Use when the view is to be focusable both in regular and accessibility
+ // mode.
+ ALWAYS,
+
+ // Use when the view is focusable only during accessibility mode.
+ ACCESSIBLE_ONLY,
+ };
+
struct ViewHierarchyChangedDetails {
ViewHierarchyChangedDetails()
: is_add(false),
@@ -767,25 +779,17 @@ class VIEWS_EXPORT View : public ui::LayerDelegate,
// IMPORTANT NOTE: loops in the focus hierarchy are not supported.
void SetNextFocusableView(View* view);
- // Sets whether this view is capable of taking focus. It will clear focus if
- // the focused view is set to be non-focusable.
- // Note that this is false by default so that a view used as a container does
- // not get the focus.
- void SetFocusable(bool focusable);
+ // Sets |focus_behavior_| as per the passed value. Advances focus if
tapted 2016/04/21 05:33:06 nit: I think it's enough just to say // Sets |foc
karandeepb 2016/04/21 10:33:33 Done.
+ // necessary.
+ void SetFocusBehavior(FocusBehavior focus_behavior);
- // Returns true if this view is |focusable_|, |enabled_| and drawn.
+ // Returns true if this view is focusable, |enabled_| and drawn.
bool IsFocusable() const;
// Return whether this view is focusable when the user requires full keyboard
// access, even though it may not be normally focusable.
bool IsAccessibilityFocusable() const;
- // Set whether this view can be made focusable if the user requires
- // full keyboard access, even though it's not normally focusable. It will
- // clear focus if the focused view is set to be non-focusable.
- // Note that this is false by default.
- void SetAccessibilityFocusable(bool accessibility_focusable);
-
// Convenience method to retrieve the FocusManager associated with the
// Widget that contains this view. This can return NULL if this view is not
// part of a view hierarchy with a Widget.
@@ -1141,9 +1145,9 @@ class VIEWS_EXPORT View : public ui::LayerDelegate,
// Focus ---------------------------------------------------------------------
- // Returns last value passed to SetFocusable(). Use IsFocusable() to determine
- // if a view can take focus right now.
- bool focusable() const { return focusable_; }
+ // Returns true if ALWAYS is the last set focus behavior. Use IsFocusable() to
+ // determine if a view can take focus right now.
+ bool focusable() const { return focus_behavior_ == FocusBehavior::ALWAYS; }
tapted 2016/04/21 05:33:07 Maybe we want to rename this now to CanFocus? (or
karandeepb 2016/04/21 10:33:33 Will do this in https://codereview.chromium.org/18
// Override to be notified when focus has changed either to or from this View.
virtual void OnFocus();
@@ -1544,12 +1548,8 @@ class VIEWS_EXPORT View : public ui::LayerDelegate,
// Next view to be focused when the Shift-Tab key combination is pressed.
View* previous_focusable_view_;
- // Whether this view can be focused.
- bool focusable_;
-
- // Whether this view is focusable if the user requires full keyboard access,
- // even though it may not be normally focusable.
- bool accessibility_focusable_;
+ // The focus behavior of the view in regular and accessibility mode.
+ FocusBehavior focus_behavior_;
// Context menus -------------------------------------------------------------
« no previous file with comments | « ui/views/touchui/touch_selection_menu_runner_views.cc ('k') | ui/views/view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698