summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-16 20:51:57 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-16 20:51:57 +0000
commit47d131129d7cc312be2904659967b26e47899d7e (patch)
tree256ca163d290b980c91387a4074fe0669e27555b /ui
parent0b7f7111811658085e91ccbfbc3c222c81b52a6c (diff)
downloadchromium_src-47d131129d7cc312be2904659967b26e47899d7e.zip
chromium_src-47d131129d7cc312be2904659967b26e47899d7e.tar.gz
chromium_src-47d131129d7cc312be2904659967b26e47899d7e.tar.bz2
views: Convert IsFocusable() to just focusable() since it's just a simple accessor.
BUG=105879 R=ben@chromium.org Review URL: http://codereview.chromium.org/8964001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114852 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/views/controls/button/checkbox.cc2
-rw-r--r--ui/views/controls/button/custom_button.cc4
-rw-r--r--ui/views/controls/button/custom_button.h1
-rw-r--r--ui/views/controls/button/text_button.cc4
-rw-r--r--ui/views/controls/label.cc2
-rw-r--r--ui/views/controls/textfield/textfield.cc5
-rw-r--r--ui/views/controls/textfield/textfield.h1
-rw-r--r--ui/views/view.cc8
-rw-r--r--ui/views/view.h18
9 files changed, 14 insertions, 31 deletions
diff --git a/ui/views/controls/button/checkbox.cc b/ui/views/controls/button/checkbox.cc
index 1221efa..ef36dc1 100644
--- a/ui/views/controls/button/checkbox.cc
+++ b/ui/views/controls/button/checkbox.cc
@@ -61,7 +61,7 @@ void Checkbox::GetAccessibleState(ui::AccessibleViewState* state) {
}
void Checkbox::OnPaintFocusBorder(gfx::Canvas* canvas) {
- if (HasFocus() && (IsFocusable() || IsAccessibilityFocusableInRootView())) {
+ if (HasFocus() && (focusable() || IsAccessibilityFocusableInRootView())) {
gfx::Rect bounds(GetTextBounds());
// Increate the bounding box by one on each side so that that focus border
// does not draw on top of the letters.
diff --git a/ui/views/controls/button/custom_button.cc b/ui/views/controls/button/custom_button.cc
index d46ad12..78b59e1 100644
--- a/ui/views/controls/button/custom_button.cc
+++ b/ui/views/controls/button/custom_button.cc
@@ -279,10 +279,6 @@ void CustomButton::ViewHierarchyChanged(bool is_add, View *parent,
SetState(BS_NORMAL);
}
-bool CustomButton::IsFocusable() const {
- return (state_ != BS_DISABLED) && View::IsFocusable();
-}
-
void CustomButton::OnBlur() {
if (IsHotTracked())
SetState(BS_NORMAL);
diff --git a/ui/views/controls/button/custom_button.h b/ui/views/controls/button/custom_button.h
index b428e0a..4e22fbc 100644
--- a/ui/views/controls/button/custom_button.h
+++ b/ui/views/controls/button/custom_button.h
@@ -118,7 +118,6 @@ class VIEWS_EXPORT CustomButton : public Button,
virtual void ViewHierarchyChanged(bool is_add,
View* parent,
View* child) OVERRIDE;
- virtual bool IsFocusable() const OVERRIDE;
virtual void OnBlur() OVERRIDE;
// The button state (defined in implementation)
diff --git a/ui/views/controls/button/text_button.cc b/ui/views/controls/button/text_button.cc
index 46b37b3..38a8021 100644
--- a/ui/views/controls/button/text_button.cc
+++ b/ui/views/controls/button/text_button.cc
@@ -753,7 +753,7 @@ std::string TextButton::GetClassName() const {
}
void TextButton::OnPaintFocusBorder(gfx::Canvas* canvas) {
- if ((IsFocusable() || IsAccessibilityFocusableInRootView()) && HasFocus()) {
+ if ((focusable() || IsAccessibilityFocusableInRootView()) && HasFocus()) {
gfx::Rect rect(GetLocalBounds());
rect.Inset(kFocusRectInset, kFocusRectInset);
canvas->DrawFocusRect(rect);
@@ -841,7 +841,7 @@ std::string NativeTextButton::GetClassName() const {
void NativeTextButton::OnPaintFocusBorder(gfx::Canvas* canvas) {
#if defined(OS_WIN)
- if ((IsFocusable() || IsAccessibilityFocusableInRootView()) && HasFocus()) {
+ if ((focusable() || IsAccessibilityFocusableInRootView()) && HasFocus()) {
gfx::Rect rect(GetLocalBounds());
rect.Inset(kFocusRectInset, kFocusRectInset);
canvas->DrawFocusRect(rect);
diff --git a/ui/views/controls/label.cc b/ui/views/controls/label.cc
index 5fc6f86..9972443 100644
--- a/ui/views/controls/label.cc
+++ b/ui/views/controls/label.cc
@@ -182,7 +182,7 @@ void Label::SetHasFocusBorder(bool has_focus_border) {
gfx::Insets Label::GetInsets() const {
gfx::Insets insets = View::GetInsets();
- if (IsFocusable() || has_focus_border_) {
+ if (focusable() || has_focus_border_) {
insets += gfx::Insets(kFocusBorderPadding, kFocusBorderPadding,
kFocusBorderPadding, kFocusBorderPadding);
}
diff --git a/ui/views/controls/textfield/textfield.cc b/ui/views/controls/textfield/textfield.cc
index ffbabe0..e2beb4d 100644
--- a/ui/views/controls/textfield/textfield.cc
+++ b/ui/views/controls/textfield/textfield.cc
@@ -92,6 +92,7 @@ TextfieldController* Textfield::GetController() const {
void Textfield::SetReadOnly(bool read_only) {
read_only_ = read_only;
+ set_focusable(!read_only);
if (native_wrapper_) {
native_wrapper_->UpdateReadOnly();
native_wrapper_->UpdateTextColor();
@@ -330,10 +331,6 @@ gfx::Size Textfield::GetPreferredSize() {
insets.width(), font_.GetHeight() + insets.height());
}
-bool Textfield::IsFocusable() const {
- return View::IsFocusable() && !read_only_;
-}
-
void Textfield::AboutToRequestFocusFromTabTraversal(bool reverse) {
SelectAll();
}
diff --git a/ui/views/controls/textfield/textfield.h b/ui/views/controls/textfield/textfield.h
index 5ff542d..b976354 100644
--- a/ui/views/controls/textfield/textfield.h
+++ b/ui/views/controls/textfield/textfield.h
@@ -225,7 +225,6 @@ class VIEWS_EXPORT Textfield : public View {
// Overridden from View:
virtual void Layout() OVERRIDE;
virtual gfx::Size GetPreferredSize() OVERRIDE;
- virtual bool IsFocusable() const OVERRIDE;
virtual void AboutToRequestFocusFromTabTraversal(bool reverse) OVERRIDE;
virtual bool SkipDefaultKeyEventProcessing(const KeyEvent& e) OVERRIDE;
virtual void OnEnabledChanged() OVERRIDE;
diff --git a/ui/views/view.cc b/ui/views/view.cc
index ee8be17..244f261 100644
--- a/ui/views/view.cc
+++ b/ui/views/view.cc
@@ -895,7 +895,7 @@ void View::SetNextFocusableView(View* view) {
}
bool View::IsFocusableInRootView() const {
- return IsFocusable() && IsDrawn();
+ return focusable_ && enabled_ && IsDrawn();
}
bool View::IsAccessibilityFocusableInRootView() const {
@@ -1093,7 +1093,7 @@ void View::OnPaintBorder(gfx::Canvas* canvas) {
}
void View::OnPaintFocusBorder(gfx::Canvas* canvas) {
- if ((IsFocusable() || IsAccessibilityFocusableInRootView()) && HasFocus()) {
+ if ((focusable() || IsAccessibilityFocusableInRootView()) && HasFocus()) {
TRACE_EVENT2("views", "views::OnPaintFocusBorder",
"width", canvas->GetSkCanvas()->getDevice()->width(),
"height", canvas->GetSkCanvas()->getDevice()->height());
@@ -1229,10 +1229,6 @@ void View::GetHitTestMask(gfx::Path* mask) const {
// Focus -----------------------------------------------------------------------
-bool View::IsFocusable() const {
- return focusable_ && enabled_ && visible_;
-}
-
void View::OnFocus() {
// TODO(beng): Investigate whether it's possible for us to move this to
// Focus().
diff --git a/ui/views/view.h b/ui/views/view.h
index 09cbdf5..15aeb38 100644
--- a/ui/views/view.h
+++ b/ui/views/view.h
@@ -248,8 +248,7 @@ class VIEWS_EXPORT View : public ui::LayerDelegate,
// Return whether a view is visible
bool visible() const { return visible_; }
- // Return whether this view and its ancestors are visible. Returns true if the
- // path from this view to the root view is visible.
+ // Returns true if this view is drawn on screen.
virtual bool IsDrawn() const;
// Set whether this view is enabled. A disabled view does not receive keyboard
@@ -662,14 +661,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 can accept the focus.
+ // Sets whether this view is capable of taking focus.
// Note that this is false by default so that a view used as a container does
// not get the focus.
void set_focusable(bool focusable) { focusable_ = focusable; }
+ // Returns true if this view is capable of taking focus.
+ bool focusable() const { return focusable_ && enabled_ && visible_; }
+
// Returns true if the view is focusable (IsFocusable) and visible in the root
// view. See also IsFocusable.
- bool IsFocusableInRootView() const;
+ virtual bool IsFocusableInRootView() const;
// Return whether this view is focusable when the user requires full keyboard
// access, even though it may not be normally focusable.
@@ -695,7 +697,7 @@ class VIEWS_EXPORT View : public ui::LayerDelegate,
// Invoked when a view is about to be requested for focus due to the focus
// traversal. Reverse is this request was generated going backward
// (Shift-Tab).
- virtual void AboutToRequestFocusFromTabTraversal(bool reverse) { }
+ virtual void AboutToRequestFocusFromTabTraversal(bool reverse) {}
// Invoked when a key is pressed before the key event is processed (and
// potentially eaten) by the focus manager for tab traversal, accelerators and
@@ -1008,12 +1010,6 @@ class VIEWS_EXPORT View : public ui::LayerDelegate,
// Focus ---------------------------------------------------------------------
- // Returns whether this view can accept focus.
- // A view can accept focus if it's enabled, focusable and visible.
- // This method is intended for views to use when calculating preferred size.
- // The FocusManager and other places use IsFocusableInRootView.
- virtual bool IsFocusable() const;
-
// Override to be notified when focus has changed either to or from this View.
virtual void OnFocus();
virtual void OnBlur();